Java 类com.intellij.openapi.project.impl.ProjectLifecycleListener 实例源码

项目:intellij-ce-playground    文件:StartupManagerImpl.java   
public void scheduleInitialVfsRefresh() {
  UIUtil.invokeLaterIfNeeded(new Runnable() {
    @Override
    public void run() {
      if (myProject.isDisposed()) return;

      markContentRootsForRefresh();

      Application app = ApplicationManager.getApplication();
      if (!app.isHeadlessEnvironment()) {
        final long sessionId = VirtualFileManager.getInstance().asyncRefresh(null);
        final MessageBusConnection connection = app.getMessageBus().connect();
        connection.subscribe(ProjectLifecycleListener.TOPIC, new ProjectLifecycleListener.Adapter() {
          @Override
          public void afterProjectClosed(@NotNull Project project) {
            RefreshQueue.getInstance().cancelSession(sessionId);
            connection.disconnect();
          }
        });
      }
      else {
        VirtualFileManager.getInstance().syncRefresh();
      }
    }
  });
}
项目:consulo    文件:EditorFactoryImpl.java   
public EditorFactoryImpl(EditorActionManager editorActionManager) {
  Application application = ApplicationManager.getApplication();
  MessageBus bus = application.getMessageBus();
  MessageBusConnection connect = bus.connect();
  connect.subscribe(ProjectLifecycleListener.TOPIC, new ProjectLifecycleListener() {
    @Override
    public void beforeProjectLoaded(@Nonnull final Project project) {
      // validate all editors are disposed after fireProjectClosed() was called, because it's the place where editor should be released
      Disposer.register(project, () -> {
        final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
        final boolean isLastProjectClosed = openProjects.length == 0;
        validateEditorsAreReleased(project, isLastProjectClosed);
      });
    }
  });

  ApplicationManager.getApplication().getMessageBus().connect().subscribe(EditorColorsManager.TOPIC, new EditorColorsListener() {
    @Override
    public void globalSchemeChange(EditorColorsScheme scheme) {
      refreshAllEditors();
    }
  });
  TypedAction typedAction = editorActionManager.getTypedAction();
  TypedActionHandler originalHandler = typedAction.getRawHandler();
  typedAction.setupRawHandler(new MyTypedHandler(originalHandler));
}
项目:consulo    文件:StartupManagerImpl.java   
public void scheduleInitialVfsRefresh() {
  GuiUtils.invokeLaterIfNeeded(() -> {
    if (myProject.isDisposed() || myInitialRefreshScheduled) return;

    myInitialRefreshScheduled = true;
    ((ProjectRootManagerImpl)ProjectRootManager.getInstance(myProject)).markRootsForRefresh();

    Application app = ApplicationManager.getApplication();
    if (!app.isCommandLine()) {
      final long sessionId = VirtualFileManager.getInstance().asyncRefresh(null);
      final MessageBusConnection connection = app.getMessageBus().connect();
      connection.subscribe(ProjectLifecycleListener.TOPIC, new ProjectLifecycleListener() {
        @Override
        public void afterProjectClosed(@Nonnull Project project) {
          if (project != myProject) return;

          RefreshQueue.getInstance().cancelSession(sessionId);
          connection.disconnect();
        }
      });
    }
    else {
      VirtualFileManager.getInstance().syncRefresh();
    }
  }, ModalityState.defaultModalityState());
}
项目:intellij-ce-playground    文件:IconDeferrerImpl.java   
public IconDeferrerImpl(MessageBus bus) {
  final MessageBusConnection connection = bus.connect();
  connection.subscribe(PsiModificationTracker.TOPIC, new PsiModificationTracker.Listener() {
    @Override
    public void modificationCountChanged() {
      clear();
    }
  });
  connection.subscribe(ProjectLifecycleListener.TOPIC, new ProjectLifecycleListener.Adapter() {
    @Override
    public void afterProjectClosed(@NotNull Project project) {
      clear();
    }
  });
}
项目:tools-idea    文件:StartupManagerImpl.java   
public synchronized void runPostStartupActivities() {
  final Application app = ApplicationManager.getApplication();

  if (myPostStartupActivitiesPassed) return;

  runActivities(myDumbAwarePostStartupActivities);
  DumbService.getInstance(myProject).runWhenSmart(new Runnable() {
    public void run() {
      synchronized (StartupManagerImpl.this) {
        app.assertIsDispatchThread();
        if (myProject.isDisposed()) return;
        runActivities(myDumbAwarePostStartupActivities); // they can register activities while in the dumb mode
        runActivities(myNotDumbAwarePostStartupActivities);

        myPostStartupActivitiesPassed = true;
      }
    }
  });

  if (!app.isUnitTestMode() && !myProject.isDisposed()) {
    if (!app.isHeadlessEnvironment()) {
      checkProjectRoots();
      final long sessionId = VirtualFileManager.getInstance().asyncRefresh(null);
      final MessageBusConnection connection = app.getMessageBus().connect();
      connection.subscribe(ProjectLifecycleListener.TOPIC, new ProjectLifecycleListener.Adapter() {
        @Override
        public void afterProjectClosed(@NotNull Project project) {
          RefreshQueue.getInstance().cancelSession(sessionId);
          connection.disconnect();
        }
      });
    }
    else {
      VirtualFileManager.getInstance().syncRefresh();
    }
  }

  Registry.get("ide.firstStartup").setValue(false);
}
项目:tools-idea    文件:IconDeferrerImpl.java   
public IconDeferrerImpl(MessageBus bus) {
  final MessageBusConnection connection = bus.connect();
  connection.subscribe(PsiModificationTracker.TOPIC, new PsiModificationTracker.Listener() {
    @Override
    public void modificationCountChanged() {
      clear();
    }
  });
  connection.subscribe(ProjectLifecycleListener.TOPIC, new ProjectLifecycleListener.Adapter() {
    @Override
    public void afterProjectClosed(@NotNull Project project) {
      clear();
    }
  });
}
项目:consulo    文件:IconDeferrerImpl.java   
public IconDeferrerImpl(MessageBus bus) {
  final MessageBusConnection connection = bus.connect();
  connection.subscribe(PsiModificationTracker.TOPIC, this::clear);
  connection.subscribe(ProjectLifecycleListener.TOPIC, new ProjectLifecycleListener() {
    @Override
    public void afterProjectClosed(@Nonnull Project project) {
      clear();
    }
  });
  LowMemoryWatcher.register(this::clear, connection);
}