@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)); } }); }
@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; }
AppEngineRuntimeInstance() { createdDeployments = ArrayListMultimap.create(); projectClosingListener = new ProjectManagerListener() { @Override public void projectClosing(Project project) { disconnect(); } }; }
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()); }
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); } } }
@Override public void addProjectManagerListener(@NotNull final ProjectManagerListener listener, @NotNull Disposable parentDisposable) { addProjectManagerListener(listener); Disposer.register(parentDisposable, new Disposable() { @Override public void dispose() { removeProjectManagerListener(listener); } }); }
@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); }
@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); }
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); } } }
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); } } }
@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); } } }); }
@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); } }
@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; }
@Override public void addProjectManagerListener(@NotNull ProjectManagerListener listener) { myListeners.add(listener); }
@Override public void removeProjectManagerListener(@NotNull ProjectManagerListener listener) { boolean removed = myListeners.remove(listener); LOG.assertTrue(removed); }