Package com.intellij.util.messages

Examples of com.intellij.util.messages.MessageBusConnection


    myTopic = topic;
    myMessageBus = messageBus;
  }

  public void add(@NotNull T listener) {
    final MessageBusConnection connection = myMessageBus.connect();
    connection.subscribe(myTopic, listener);
    myListenerToConnectionMap.put(listener, connection);
  }
View Full Code Here


    Disposer.register(parentDisposable, new Disposable() {
      public void dispose() {
        myListenerToConnectionMap.remove(listener);
      }
    });
    final MessageBusConnection connection = myMessageBus.connect(parentDisposable);
    connection.subscribe(myTopic, listener);
    myListenerToConnectionMap.put(listener, connection);
  }
View Full Code Here

    connection.subscribe(myTopic, listener);
    myListenerToConnectionMap.put(listener, connection);
  }

  public void remove(@NotNull T listener) {
    final MessageBusConnection connection = myListenerToConnectionMap.remove(listener);
    if (connection != null) {
      connection.disconnect();
    }
  }
View Full Code Here

    return new MessageBusConnectionImpl(this);
  }

  @NotNull
  public MessageBusConnection connect(@NotNull Disposable parentDisposable) {
    final MessageBusConnection connection = connect();
    Disposer.register(parentDisposable, connection);
    return connection;
  }
View Full Code Here

        final ContentEntry contentEntry = rootModel.addContentEntry(ourSourceRoot);
        contentEntry.addSourceFolder(ourSourceRoot, false);

        rootModel.commit();

        final MessageBusConnection connection = ourProject.getMessageBus().connect();
        connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
          public void beforeRootsChange(ModuleRootEvent event) {
            if (!event.isCausedByFileTypesChange()) {
              fail("Root modification in LightIdeaTestCase is not allowed.");
            }
          }

          public void rootsChanged(ModuleRootEvent event) {}
        });

        connection.subscribe(ProjectTopics.MODULES, new ModuleListener() {
          public void moduleAdded(Project project, Module module) {
            fail("Adding modules is not permitted in LightIdeaTestCase.");
          }

          public void beforeModuleRemoved(Project project, Module module) {}
View Full Code Here

                false,
                MergingUpdateQueue.ANY_COMPONENT);
    }

    public synchronized void start() {
        final MessageBusConnection myBusConnection = project.getMessageBus().connect(myQueue);
        myBusConnection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() {
            public void before(List<? extends VFileEvent> vFileEvents) {
            }

            public void after(List<? extends VFileEvent> vFileEvents) {
                for (VFileEvent vFileEvent : vFileEvents) {
//                    if (vFileEvent instanceof VFileMoveEvent) {
//                        if (isRelevant(vFileEvent.getPath())) {
//                            LeiningenProject leiningenProject = manager.byPath(vFileEvent.getPath());
//                            if (leiningenProject != null) {
//                                manager.removeLeiningenProject(leiningenProject);
//                            }
//
//                            VirtualFile newProjectFile = ((VFileMoveEvent)vFileEvent).getNewParent().findFileByRelativePath(((VFileMoveEvent) vFileEvent).getFile().getName());
//                            if ( newProjectFile != null ) {
//                                LeiningenProject newProject = new LeiningenProject(newProjectFile, theProject);
//                            }
//                        }
//                    }
//                    if (vFileEvent instanceof VFileDeleteEvent) {
//                        if (isRelevant(vFileEvent.getPath())) {
//                            LeiningenProject leiningenProject = manager.byPath(vFileEvent.getPath());
//                            if (leiningenProject != null) {
//                                manager.removeLeiningenProject(leiningenProject);
//                            }
//                        }
//                    }
                    if (vFileEvent instanceof VFileCreateEvent) {
                        if (isRelevant(vFileEvent.getPath())) {
                            manager.importLeiningenProject(
                                    vFileEvent.getFileSystem().findFileByPath(vFileEvent.getPath()),
                                    project
                            );
                        }
                    }
                }
            }

            private boolean isRelevant(String path) {
                return path != null && path.endsWith(LeiningenConstants.PROJECT_CLJ);
            }
        });

        myBusConnection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
            public void beforeRootsChange(ModuleRootEvent moduleRootEvent) {

            }

            public void rootsChanged(ModuleRootEvent moduleRootEvent) {
View Full Code Here

    }
    mySystemDirectory = system;

//    projectManager.addProjectManagerListener(new ProjectWatcher());

    final MessageBusConnection conn = application.getMessageBus().connect();
    conn.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
      @Override
      public void after(@NotNull List<? extends VFileEvent> events) {
        if (shouldTriggerMake(events)) {
//          scheduleAutoMake();
        }
View Full Code Here

  public MessageBusConnection connect() {
    return new MessageBusConnectionImpl(this);
  }

  public MessageBusConnection connect(Disposable parentDisposable) {
    final MessageBusConnection connection = connect();
    Disposer.register(parentDisposable, connection);
    return connection;
  }
View Full Code Here

* Created by mac on 12/13/13.
*/
public class TestModuleComponent implements ModuleComponent {
    public TestModuleComponent(Module module) {
        final Project finalProject = module.getProject();
        MessageBusConnection myConnection = finalProject.getMessageBus().connect(finalProject);
        myConnection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, getListener(finalProject, myConnection));
    }
View Full Code Here

TOP

Related Classes of com.intellij.util.messages.MessageBusConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.