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); }
@Nullable public RunContentDescriptor getSelectedContent() { for (String activeWindow : myToolwindowIdZbuffer) { final ContentManager contentManager = myToolwindowIdToContentManagerMap.get(activeWindow); if (contentManager == null) { continue; } final Content selectedContent = contentManager.getSelectedContent(); if (selectedContent == null) { if (contentManager.getContentCount() == 0) { // continue to the next window if the content manager is empty continue; } else { // stop iteration over windows because there is some content in the window and the window // is the last used one break; } } // here we have selected content return getRunContentDescriptorByContent(selectedContent); } return null; }