Java 类com.intellij.openapi.project.ProjectManagerListener 实例源码

项目:Gherkin-TS-Runner    文件:MainComponent.java   
@Override
public void initComponent() {
    MessageBus bus = ApplicationManager.getApplication().getMessageBus();
    connection = bus.connect();

    ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerListener() {
        @Override
        public void projectOpened(Project project) {
            Config config = Config.getInstance(project);

            if(config == null) {
                return;
            }

            if(!config.isConfigFilled()) {
                Notifications.Bus.notify(
                        new Notification("Settings Error", "Gherkin TS Runner", "Settings have to be filled.", NotificationType.WARNING)
                );
                return;
            }

            connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new GherkinFileEditorManagerListener(project));
        }
    });

}
项目:tools-idea    文件:ProjectManagerImpl.java   
@Override
public boolean canClose(Project project) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("enter: canClose()");
  }

  for (ProjectManagerListener listener : myListeners) {
    try {
      if (!listener.canCloseProject(project)) return false;
    }
    catch (Throwable e) {
      LOG.warn(e); // DO NOT LET ANY PLUGIN to prevent closing due to exception
    }
  }

  return true;
}
项目:google-cloud-intellij    文件:AppEngineRuntimeInstance.java   
AppEngineRuntimeInstance() {
  createdDeployments = ArrayListMultimap.create();
  projectClosingListener =
      new ProjectManagerListener() {
        @Override
        public void projectClosing(Project project) {
          disconnect();
        }
      };
}
项目:material-theme-jetbrains    文件:MTLafComponent.java   
private void replaceStatusBar() {
  final MessageBusConnection connect = ApplicationManager.getApplication().getMessageBus().connect();

  // On app init, set the statusbar borders
  connect.subscribe(ProjectManager.TOPIC, new ProjectManagerListener() {
    @Override
    public void projectOpened(@Nullable final Project projectFromCommandLine) {
      MTThemeManager.getInstance().setStatusBarBorders();
    }
  });

  // And also on config change
  connect.subscribe(ConfigNotifier.CONFIG_TOPIC, mtConfig -> MTThemeManager.getInstance().setStatusBarBorders());
}
项目:tools-idea    文件:ProjectManagerImpl.java   
private void fireProjectClosing(Project project) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("enter: fireProjectClosing()");
  }

  for (ProjectManagerListener listener : myListeners) {
    try {
      listener.projectClosing(project);
    }
    catch (Exception e) {
      LOG.error(e);
    }
  }
}
项目:tools-idea    文件:ProjectManagerImpl.java   
@Override
public void addProjectManagerListener(@NotNull final ProjectManagerListener listener, @NotNull Disposable parentDisposable) {
  addProjectManagerListener(listener);
  Disposer.register(parentDisposable, new Disposable() {
    @Override
    public void dispose() {
      removeProjectManagerListener(listener);
    }
  });
}
项目:tools-idea    文件:ProjectManagerImpl.java   
@Override
public void addProjectManagerListener(@NotNull Project project, @NotNull ProjectManagerListener listener) {
  List<ProjectManagerListener> listeners = project.getUserData(LISTENERS_IN_PROJECT_KEY);
  if (listeners == null) {
    listeners = ((UserDataHolderEx)project)
      .putUserDataIfAbsent(LISTENERS_IN_PROJECT_KEY, ContainerUtil.<ProjectManagerListener>createLockFreeCopyOnWriteList());
  }
  listeners.add(listener);
}
项目:tools-idea    文件:ProjectManagerImpl.java   
@Override
public void removeProjectManagerListener(@NotNull Project project, @NotNull ProjectManagerListener listener) {
  List<ProjectManagerListener> listeners = project.getUserData(LISTENERS_IN_PROJECT_KEY);
  LOG.assertTrue(listeners != null);
  boolean removed = listeners.remove(listener);
  LOG.assertTrue(removed);
}
项目:tools-idea    文件:ProjectManagerImpl.java   
private void fireProjectOpened(Project project) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("projectOpened");
  }

  for (ProjectManagerListener listener : myListeners) {
    try {
      listener.projectOpened(project);
    }
    catch (Exception e) {
      LOG.error(e);
    }
  }
}
项目:tools-idea    文件:ProjectManagerImpl.java   
private void fireProjectClosed(Project project) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("projectClosed");
  }

  for (ProjectManagerListener listener : myListeners) {
    try {
      listener.projectClosed(project);
    }
    catch (Exception e) {
      LOG.error(e);
    }
  }
}
项目:consulo    文件:WebWelcomeFrameManager.java   
@Inject
public WebWelcomeFrameManager(@Nonnull Application application) {
  application.getMessageBus().connect().subscribe(ProjectManager.TOPIC, new ProjectManagerListener() {
    @Override
    public void projectOpened(Project project) {
      Window window = myWindow;

      myWindow = null;

      if (window != null) {
        WebApplication.invokeOnCurrentSession(window::close);
      }
    }
  });
}
项目:consulo    文件:EditorTextField.java   
@Override
public void addNotify() {
  myDisposable = Disposer.newDisposable("ETF dispose");
  Disposer.register(myDisposable, this::releaseEditorLater);
  if (myProject != null) {
    ProjectManagerListener listener = new ProjectManagerListener() {
      @Override
      public void projectClosing(Project project) {
        releaseEditor(myEditor);
        myEditor = null;
      }
    };
    ProjectManager.getInstance().addProjectManagerListener(myProject, listener);
    Disposer.register(myDisposable, ()->ProjectManager.getInstance().removeProjectManagerListener(myProject, listener));
  }

  if (myEditor != null) {
    releaseEditorLater();
  }

  boolean isFocused = isFocusOwner();

  initEditor();

  super.addNotify();

  if (myNextFocusable != null) {
    myEditor.getContentComponent().setNextFocusableComponent(myNextFocusable);
    myNextFocusable = null;
  }
  revalidate();
  if (isFocused) {
    IdeFocusManager.getGlobalInstance().doForceFocusWhenFocusSettlesDown(this);
  }
}
项目:tools-idea    文件:ProjectManagerImpl.java   
@NotNull
private static List<ProjectManagerListener> getListeners(Project project) {
  List<ProjectManagerListener> array = project.getUserData(LISTENERS_IN_PROJECT_KEY);
  if (array == null) return Collections.emptyList();
  return array;
}
项目:tools-idea    文件:ProjectManagerImpl.java   
@Override
public void addProjectManagerListener(@NotNull ProjectManagerListener listener) {
  myListeners.add(listener);
}
项目:tools-idea    文件:ProjectManagerImpl.java   
@Override
public void removeProjectManagerListener(@NotNull ProjectManagerListener listener) {
  boolean removed = myListeners.remove(listener);
  LOG.assertTrue(removed);
}