public void openMessagesView(final VcsErrorViewPanel errorTreeView, final String tabDisplayName) { CommandProcessor commandProcessor = CommandProcessor.getInstance(); commandProcessor.executeCommand(myProject, new Runnable() { public void run() { final MessageView messageView = MessageView.SERVICE.getInstance(myProject); messageView.runWhenInitialized(new Runnable() { public void run() { final Content content = ContentFactory.SERVICE.getInstance().createContent(errorTreeView, tabDisplayName, true); messageView.getContentManager().addContent(content); Disposer.register(content, errorTreeView); messageView.getContentManager().setSelectedContent(content); removeContents(content, tabDisplayName); ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW).activate(null); } }); } }, VcsBundle.message("command.name.open.error.message.view"), null); }
protected void removeContents(Content notToRemove, final String tabDisplayName) { MessageView messageView = MessageView.SERVICE.getInstance(myProject); Content[] contents = messageView.getContentManager().getContents(); for (Content content : contents) { LOG.assertTrue(content != null); if (content.isPinned()) continue; if (tabDisplayName.equals(content.getDisplayName()) && content != notToRemove) { ErrorTreeView listErrorView = (ErrorTreeView)content.getComponent(); if (listErrorView != null) { if (messageView.getContentManager().removeContent(content, true)) { content.release(); } } } } }
private static void openMessagesView(@NotNull final ErrorViewPanel errorTreeView, @NotNull final Project myProject, @NotNull final String tabDisplayName) { CommandProcessor commandProcessor = CommandProcessor.getInstance(); commandProcessor.executeCommand(myProject, new Runnable() { @Override public void run() { final MessageView messageView = ServiceManager.getService(myProject, MessageView.class); final Content content = ContentFactory.SERVICE.getInstance().createContent(errorTreeView, tabDisplayName, true); messageView.getContentManager().addContent(content); Disposer.register(content, errorTreeView); messageView.getContentManager().setSelectedContent(content); removeContents(content, myProject, tabDisplayName); } }, "Open message view", null); }
private static void removeContents(@Nullable final Content notToRemove, @NotNull final Project myProject, @NotNull final String tabDisplayName) { MessageView messageView = ServiceManager.getService(myProject, MessageView.class); Content[] contents = messageView.getContentManager().getContents(); for (Content content : contents) { LOG.assertTrue(content != null); if (content.isPinned()) continue; if (tabDisplayName.equals(content.getDisplayName()) && content != notToRemove) { ErrorTreeView listErrorView = (ErrorTreeView)content.getComponent(); if (listErrorView != null) { if (messageView.getContentManager().removeContent(content, true)) { content.release(); } } } } }
public void openMessagesView(final VcsErrorViewPanel errorTreeView, final String tabDisplayName) { CommandProcessor commandProcessor = CommandProcessor.getInstance(); commandProcessor.executeCommand(myProject, new Runnable() { public void run() { final MessageView messageView = MessageView.SERVICE.getInstance(myProject); messageView.runWhenInitialized(new Runnable() { public void run() { final Content content = ContentFactory.getInstance().createContent(errorTreeView, tabDisplayName, true); messageView.getContentManager().addContent(content); Disposer.register(content, errorTreeView); messageView.getContentManager().setSelectedContent(content); removeContents(content, tabDisplayName); ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW).activate(null); } }); } }, VcsBundle.message("command.name.open.error.message.view"), null); }
private static void removeContents(@Nullable final Content notToRemove, @Nonnull final Project myProject, @Nonnull final String tabDisplayName) { MessageView messageView = ServiceManager.getService(myProject, MessageView.class); Content[] contents = messageView.getContentManager().getContents(); for (Content content : contents) { LOG.assertTrue(content != null); if (content.isPinned()) continue; if (tabDisplayName.equals(content.getDisplayName()) && content != notToRemove) { ErrorTreeView listErrorView = (ErrorTreeView)content.getComponent(); if (listErrorView != null) { if (messageView.getContentManager().removeContent(content, true)) { content.release(); } } } } }
@Nullable private Content findContent(@NotNull Pair<NotificationSource, ProjectSystemId> contentIdPair, @NotNull String contentDisplayName) { Content targetContent = null; final MessageView messageView = ServiceManager.getService(myProject, MessageView.class); for (Content content : messageView.getContentManager().getContents()) { if (contentIdPair.equals(content.getUserData(CONTENT_ID_KEY)) && StringUtil.equals(content.getDisplayName(), contentDisplayName) && !content.isPinned()) { targetContent = content; } } return targetContent; }
protected void openView(Project project, JComponent component) { final MessageView messageView = MessageView.SERVICE.getInstance(project); final Content content = ContentFactory.SERVICE.getInstance().createContent(component, getContentName(), true); messageView.getContentManager().addContent(content); messageView.getContentManager().setSelectedContent(content); ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW); if (toolWindow != null) { toolWindow.activate(null); } }
public void close() { MessageView messageView = MessageView.SERVICE.getInstance(myProject); Content content = messageView.getContentManager().getContent(this); if (content != null) { messageView.getContentManager().removeContent(content, true); } }
private void ensureAttachedToToolWindow() { if (!isOpen.compareAndSet(false, true)) return; MavenUtil.invokeLater(myProject, new Runnable() { public void run() { MessageView messageView = MessageView.SERVICE.getInstance(myProject); Content content = ContentFactory.SERVICE.getInstance().createContent( myConsoleView.getComponent(), myTitle, true); content.putUserData(CONSOLE_KEY, MavenConsoleImpl.this); messageView.getContentManager().addContent(content); messageView.getContentManager().setSelectedContent(content); // remove unused tabs for (Content each : messageView.getContentManager().getContents()) { if (each.isPinned()) continue; if (each == content) continue; MavenConsoleImpl console = each.getUserData(CONSOLE_KEY); if (console == null) continue; if (!myTitle.equals(console.myTitle)) continue; if (console.isFinished()) { messageView.getContentManager().removeContent(each, true); } } ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW); if (!toolWindow.isActive()) { toolWindow.activate(null, false); } } }); }
public void close() { MessageView messageView = MessageView.SERVICE.getInstance(myProject); for (Content each : messageView.getContentManager().getContents()) { MavenConsoleImpl console = each.getUserData(CONSOLE_KEY); if (console != null) { messageView.getContentManager().removeContent(each, true); return; } } }
private void ensureAttachedToToolWindow() { if (!isOpen.compareAndSet(false, true)) return; MavenUtil.invokeLater(myProject, new Runnable() { public void run() { MessageView messageView = MessageView.SERVICE.getInstance(myProject); Content content = ContentFactory.SERVICE.getInstance().createContent( myConsoleView.getComponent(), myTitle, true); content.putUserData(CONSOLE_KEY, MavenConsoleImpl.this); messageView.getContentManager().addContent(content); messageView.getContentManager().setSelectedContent(content); // remove unused tabs for (Content each : messageView.getContentManager().getContents()) { if (each.isPinned()) continue; if (each == content) continue; MavenConsoleImpl console = each.getUserData(CONSOLE_KEY); if (console == null) continue; if (!myTitle.equals(console.myTitle)) continue; if (console.isFinished()) { messageView.getContentManager().removeContent(each, false); } } ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW); if (!toolWindow.isActive()) { toolWindow.activate(null, false); } } }); }
private void close() { MessageView messageView = MessageView.SERVICE.getInstance(myProject); Content[] contents = messageView.getContentManager().getContents(); for (Content content : contents) { if (content.getComponent() == this) { messageView.getContentManager().removeContent(content, true); return; } } }
@javax.annotation.Nullable private Content findContent(@Nonnull Pair<NotificationSource, ProjectSystemId> contentIdPair, @Nonnull String contentDisplayName) { Content targetContent = null; final MessageView messageView = ServiceManager.getService(myProject, MessageView.class); for (Content content : messageView.getContentManager().getContents()) { if (contentIdPair.equals(content.getUserData(CONTENT_ID_KEY)) && StringUtil.equals(content.getDisplayName(), contentDisplayName) && !content.isPinned()) { targetContent = content; } } return targetContent; }
protected void openView(Project project, JComponent component) { final MessageView messageView = MessageView.SERVICE.getInstance(project); final Content content = ContentFactory.getInstance().createContent(component, getContentName(), true); messageView.getContentManager().addContent(content); messageView.getContentManager().setSelectedContent(content); ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW); if (toolWindow != null) { toolWindow.activate(null); } }
private static void openMessagesView(@Nonnull final ErrorViewPanel errorTreeView, @Nonnull final Project myProject, @Nonnull final String tabDisplayName) { CommandProcessor commandProcessor = CommandProcessor.getInstance(); commandProcessor.executeCommand(myProject, new Runnable() { @Override public void run() { final MessageView messageView = ServiceManager.getService(myProject, MessageView.class); final Content content = ContentFactory.getInstance().createContent(errorTreeView, tabDisplayName, true); messageView.getContentManager().addContent(content); Disposer.register(content, errorTreeView); messageView.getContentManager().setSelectedContent(content); removeContents(content, myProject, tabDisplayName); } }, "Open message view", null); }
@RequiredDispatchThread @NotNull private NewErrorTreeViewPanel getOrInitPanel() { if(myErrorPanel != null) { return myErrorPanel; } if(myToolwindowInit.compareAndSet(false, true)) { MessageView messageView = MessageView.SERVICE.getInstance(myProject); messageView.runWhenInitialized(() -> { final ContentManager contentManager = messageView.getContentManager(); Content[] contents = contentManager.getContents(); Content content = ContainerUtil.find(contents, content1 -> content1.getUserData(ourViewKey) != null); MyErrorPanel errorTreeViewPanel = null; if(content == null) { errorTreeViewPanel = new MyErrorPanel(myProject); content = ContentFactory.getInstance().createContent(errorTreeViewPanel, "Editor", false); content.putUserData(ourViewKey, Boolean.TRUE); contentManager.addContent(content); } else { errorTreeViewPanel = (MyErrorPanel) content.getComponent(); } contentManager.setSelectedContent(content, true); myErrorPanel = errorTreeViewPanel; }); } return myErrorPanel; }