com.intellij.util.EventDispatcher Java Examples

The following examples show how to use com.intellij.util.EventDispatcher. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XBreakpointManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
public XBreakpointManagerImpl(final Project project, final XDebuggerManagerImpl debuggerManager, StartupManager startupManager) {
  myProject = project;
  myDebuggerManager = debuggerManager;
  myAllBreakpointsDispatcher = EventDispatcher.create(XBreakpointListener.class);
  myDependentBreakpointManager = new XDependentBreakpointManager(this);
  myLineBreakpointManager = new XLineBreakpointManager(project, myDependentBreakpointManager, startupManager);
  if (!project.isDefault()) {
    if (!ApplicationManager.getApplication().isUnitTestMode()) {
      HttpVirtualFileListener httpVirtualFileListener = this::updateBreakpointInFile;
      HttpFileSystem.getInstance().addFileListener(httpVirtualFileListener, project);
    }
    for (XBreakpointType<?, ?> type : XBreakpointUtil.getBreakpointTypes()) {
      addDefaultBreakpoint(type);
    }
  }
}
 
Example #2
Source File: XBreakpointManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private <T extends XBreakpointProperties> void addBreakpoint(final XBreakpointBase<?, T, ?> breakpoint, final boolean defaultBreakpoint, boolean initUI) {
  XBreakpointType type = breakpoint.getType();
  if (defaultBreakpoint) {
    LOG.assertTrue(!myDefaultBreakpoints.containsKey(type), "Cannot have more than one default breakpoint (type " + type.getId() + ")");
    myDefaultBreakpoints.put(type, breakpoint);
  }
  else {
    myBreakpoints.put(type, breakpoint);
  }
  myAllBreakpoints.add(breakpoint);
  if (breakpoint instanceof XLineBreakpointImpl) {
    myLineBreakpointManager.registerBreakpoint((XLineBreakpointImpl)breakpoint, initUI);
  }
  EventDispatcher<XBreakpointListener> dispatcher = myDispatchers.get(type);
  if (dispatcher != null) {
    //noinspection unchecked
    dispatcher.getMulticaster().breakpointAdded(breakpoint);
  }
  getBreakpointDispatcherMulticaster().breakpointAdded(breakpoint);
}
 
Example #3
Source File: XDependentBreakpointManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
public XDependentBreakpointManager(final XBreakpointManagerImpl breakpointManager) {
  myBreakpointManager = breakpointManager;
  myDispatcher = EventDispatcher.create(XDependentBreakpointListener.class);
  myBreakpointManager.addBreakpointListener(new XBreakpointAdapter<XBreakpoint<?>>() {
    public void breakpointRemoved(@Nonnull final XBreakpoint<?> breakpoint) {
      XDependentBreakpointInfo info = mySlave2Info.remove(breakpoint);
      if (info != null) {
        myMaster2Info.remove(info.myMasterBreakpoint, info);
      }

      Collection<XDependentBreakpointInfo> infos = myMaster2Info.removeAll((XBreakpointBase)breakpoint);
      if (infos != null) {
        for (XDependentBreakpointInfo breakpointInfo : infos) {
          XDependentBreakpointInfo removed = mySlave2Info.remove(breakpointInfo.mySlaveBreakpoint);
          if (removed != null) {
            myDispatcher.getMulticaster().dependencyCleared(breakpointInfo.mySlaveBreakpoint);
          }
        }
      }
    }
  });
}
 
Example #4
Source File: XBreakpointManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void doRemoveBreakpoint(XBreakpoint<?> breakpoint) {
  if (isDefaultBreakpoint(breakpoint)) {
    // removing default breakpoint should just disable it
    breakpoint.setEnabled(false);
  }
  else {
    XBreakpointType type = breakpoint.getType();
    XBreakpointBase<?, ?, ?> breakpointBase = (XBreakpointBase<?, ?, ?>)breakpoint;
    myBreakpoints.remove(type, breakpointBase);
    myAllBreakpoints.remove(breakpointBase);
    if (breakpointBase instanceof XLineBreakpointImpl) {
      myLineBreakpointManager.unregisterBreakpoint((XLineBreakpointImpl)breakpointBase);
    }
    breakpointBase.dispose();
    EventDispatcher<XBreakpointListener> dispatcher = myDispatchers.get(type);
    if (dispatcher != null) {
      //noinspection unchecked
      dispatcher.getMulticaster().breakpointRemoved(breakpoint);
    }
    getBreakpointDispatcherMulticaster().breakpointRemoved(breakpoint);
  }
}
 
Example #5
Source File: ArtifactImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ArtifactImpl createCopy(EventDispatcher<ArtifactListener> dispatcher) {
  final ArtifactImpl artifact = new ArtifactImpl(myName, myArtifactType, myBuildOnMake, myRootElement, myOutputPath, dispatcher);
  for (Map.Entry<ArtifactPropertiesProvider, ArtifactProperties<?>> entry : myProperties.entrySet()) {
    final ArtifactProperties newProperties = artifact.myProperties.get(entry.getKey());
    //noinspection unchecked
    newProperties.loadState(entry.getValue().getState());
  }
  return artifact;
}
 
Example #6
Source File: RemoveList.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void doNotify(final EventDispatcher<ChangeListListener> dispatcher) {
  if (myRemoved) {
    final ChangeListListener multicaster = dispatcher.getMulticaster();
    multicaster.changesMoved(myListCopy.getChanges(), myListCopy, myDefaultListCopy);
    multicaster.changeListRemoved(myListCopy);
  }
}
 
Example #7
Source File: MoveChanges.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void doNotify(final EventDispatcher<ChangeListListener> dispatcher) {
  if ((myMovedFrom != null) && (myListCopy != null)) {
    for(LocalChangeList fromList: myMovedFrom.keySet()) {
      final Collection<Change> changesInList = myMovedFrom.get(fromList);
      dispatcher.getMulticaster().changesMoved(changesInList, fromList, myListCopy);
    }
  }
}
 
Example #8
Source File: XBreakpointManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private <T extends XBreakpointProperties> EventDispatcher<XBreakpointListener> getOrCreateDispatcher(final XBreakpointType<?, T> type) {
  EventDispatcher<XBreakpointListener> dispatcher = myDispatchers.get(type);
  if (dispatcher == null) {
    dispatcher = EventDispatcher.create(XBreakpointListener.class);
    myDispatchers.put(type, dispatcher);
  }
  return dispatcher;
}
 
Example #9
Source File: XBreakpointManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void fireBreakpointChanged(XBreakpointBase<?, ?, ?> breakpoint) {
  if (!myAllBreakpoints.contains(breakpoint)) {
    return;
  }

  if (breakpoint instanceof XLineBreakpointImpl) {
    myLineBreakpointManager.breakpointChanged((XLineBreakpointImpl)breakpoint);
  }
  EventDispatcher<XBreakpointListener> dispatcher = myDispatchers.get(breakpoint.getType());
  if (dispatcher != null) {
    //noinspection unchecked
    dispatcher.getMulticaster().breakpointChanged(breakpoint);
  }
  getBreakpointDispatcherMulticaster().breakpointChanged(breakpoint);
}
 
Example #10
Source File: MessageBusImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private <L> InvocationHandler createTopicHandler(@Nonnull Topic<L> topic) {
  return (proxy, method, args) -> {
    if (method.getDeclaringClass().getName().equals("java.lang.Object")) {
      return EventDispatcher.handleObjectMethod(proxy, args, method.getName());
    }
    sendMessage(new Message(topic, method, args));
    return NA;
  };
}
 
Example #11
Source File: ArtifactImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ArtifactImpl(@Nonnull String name, @Nonnull ArtifactType artifactType, boolean buildOnMake, @Nonnull CompositePackagingElement<?> rootElement,
                    String outputPath,
                    EventDispatcher<ArtifactListener> dispatcher) {
  myName = name;
  myArtifactType = artifactType;
  myBuildOnMake = buildOnMake;
  myRootElement = rootElement;
  myOutputPath = outputPath;
  myDispatcher = dispatcher;
  myProperties = new HashMap<ArtifactPropertiesProvider, ArtifactProperties<?>>();
  resetProperties();
}
 
Example #12
Source File: AddList.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void doNotify(final EventDispatcher<ChangeListListener> dispatcher) {
  dispatcher.getMulticaster().changeListAdded(myNewListCopy);
}
 
Example #13
Source File: EditName.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void doNotify(final EventDispatcher<ChangeListListener> dispatcher) {
  if (myListCopy != null && (! myListCopy.isReadOnly())) {
    dispatcher.getMulticaster().changeListRenamed(myListCopy, myFromName);
  }
}
 
Example #14
Source File: SetDefault.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void doNotify(final EventDispatcher<ChangeListListener> dispatcher) {
  dispatcher.getMulticaster().defaultListChanged(myOldDefaultListCopy, myNewDefaultListCopy);
}
 
Example #15
Source File: SetReadOnly.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void doNotify(final EventDispatcher<ChangeListListener> dispatcher) {
  // +-
  dispatcher.getMulticaster().changeListChanged(myListCopy);
}
 
Example #16
Source File: EditComment.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void doNotify(final EventDispatcher<ChangeListListener> dispatcher) {
  if (myListCopy != null) {
    dispatcher.getMulticaster().changeListCommentChanged(myListCopy, myOldComment);
  }
}
 
Example #17
Source File: DelayedNotificator.java    From consulo with Apache License 2.0 4 votes vote down vote up
public DelayedNotificator(@Nonnull EventDispatcher<ChangeListListener> dispatcher,
                          @Nonnull ChangeListManagerImpl.Scheduler scheduler) {
  myDispatcher = dispatcher;
  myScheduler = scheduler;
}
 
Example #18
Source File: UIDataObject.java    From consulo with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public <T extends EventListener> Disposable addListener(Class<T> clazz, T value) {
  EventDispatcher<T> eventDispatcher = myListeners.computeIfAbsent(clazz, EventDispatcher::create);
  eventDispatcher.addListener(value);
  return () -> eventDispatcher.removeListener(value);
}
 
Example #19
Source File: UIDataObject.java    From consulo with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public <T extends EventListener> T getDispatcher(Class<T> clazz) {
  return (T)myListeners.computeIfAbsent(clazz, EventDispatcher::create).getMulticaster();
}
 
Example #20
Source File: ChangeListCommand.java    From consulo with Apache License 2.0 votes vote down vote up
void doNotify(final EventDispatcher<ChangeListListener> dispatcher);