public int addTab( String s, JComponent component, boolean selectTab, boolean replaceContent, boolean lockable, boolean addDefaultToolbar, ActionGroup toolbarActions, String helpId) { int existing = getComponentNumNamed(s); ContentManager contentManager = getContentManager(); if (existing != -1) { Content existingContent = contentManager.getContent(existing); if (!replaceContent) { contentManager.setSelectedContent(existingContent); return existing; } // if (!existingContent.isPinned()) { // getContentManager().removeContent(existingContent); // existingContent.release(); // } } CommitLogWindowComponent newComponent = new CommitLogWindowComponent( component, addDefaultToolbar, toolbarActions, contentManager, helpId); Content content = ContentFactory.SERVICE .getInstance() .createContent(newComponent.getShownComponent(), s, lockable); newComponent.setContent(content); contentManager.addContent(content); return getComponentAt(contentManager.getContentCount() - 1, selectTab); }
private CloseListener(Content content, ContentManager contentManager, Project project) { myContent = content; myContentManager = contentManager; myProject = project; contentManager.addContentManagerListener(this); ProjectManager.getInstance().addProjectManagerListener(myProject, this); }
public void contentRemoved(ContentManagerEvent event) { if (event.getContent() == myContent) { myContentManager.removeContentManagerListener(this); AntBuildMessageView buildMessageView = myContent.getUserData(KEY); if (!myCloseAllowed) { buildMessageView.stopProcess(); } ProjectManager.getInstance().removeProjectManagerListener(myProject, this); myContent.release(); myContent = null; buildMessageView.myBuildFile = null; buildMessageView.myPlainTextView.dispose(); } }
private void initialize() { if (!_isInitialized) { _isInitialized = true; _isDisposed = false; ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(_project); ToolWindow toolWindow = toolWindowManager.registerToolWindow( COMMIT_LOGS_TOOLWINDOW_ID, true, ToolWindowAnchor.BOTTOM); toolWindow.setIcon(COMMIT_LOGS_SMALL_ICON); _contentManager = toolWindow.getContentManager(); toolWindow.installWatcher(_contentManager); // _contentManager = // PeerFactory.getInstance().getContentFactory().createContentManager(true, _project); _contentManager.addContentManagerListener( new ContentManagerAdapter() { @Override public void contentRemoved(ContentManagerEvent event) { JComponent component = event.getContent().getComponent(); JComponent removedComponent = (component instanceof CommitLogWindowComponent) ? ((CommitLogWindowComponent) component).getComponent() : component; // if (removedComponent == myErrorsView) { // myErrorsView.dispose(); // myErrorsView = null; // } else for (Iterator iterator = _commitLogs.iterator(); iterator.hasNext(); ) { Editor editor = (Editor) iterator.next(); if (removedComponent == editor.getComponent()) { EditorFactory.getInstance().releaseEditor(editor); iterator.remove(); } } } }); // final JComponent component = _contentManager.getComponent(); } }
public void projectClosed(Project project) { if (myContent != null) { myContentManager.removeContent(myContent, true); } }