@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; }
private ContentManager getContentManagerForRunner(final Executor executor) { final ContentManager contentManager = myToolwindowIdToContentManagerMap.get(executor.getToolWindowId()); if (contentManager == null) { LOG.error("Runner " + executor.getId() + " is not registered"); } return contentManager; }
public RunContentDescriptor[] getAllDescriptors() { final List<RunContentDescriptor> descriptors = new ArrayList<RunContentDescriptor>(); final String[] ids = myToolwindowIdToContentManagerMap .keySet() .toArray(new String[myToolwindowIdToContentManagerMap.size()]); for (String id : ids) { final ContentManager contentManager = myToolwindowIdToContentManagerMap.get(id); final Content[] contents = contentManager.getContents(); for (final Content content : contents) { final RunContentDescriptor descriptor = getRunContentDescriptorByContent(content); if (descriptor != null) { descriptors.add(descriptor); } } } return descriptors.toArray(new RunContentDescriptor[descriptors.size()]); }
@Nullable public RunContentDescriptor getSelectedContent() { final String activeWindow = myToolwindowIdZbuffer.isEmpty() ? null : myToolwindowIdZbuffer.getFirst(); if (activeWindow != null) { final ContentManager contentManager = myToolwindowIdToContentManagerMap.get(activeWindow); if (contentManager != null) { final Content selectedContent = contentManager.getSelectedContent(); if (selectedContent != null) { final RunContentDescriptor runContentDescriptorByContent = getRunContentDescriptorByContent(selectedContent); if (runContentDescriptorByContent != null) { return runContentDescriptorByContent; } } } } return null; }
@NotNull public List<RunContentDescriptor> getAllDescriptors() { if (myToolwindowIdToContentManagerMap.isEmpty()) { return Collections.emptyList(); } final String[] ids = myToolwindowIdToContentManagerMap .keySet() .toArray(new String[myToolwindowIdToContentManagerMap.size()]); final List<RunContentDescriptor> descriptors = new ArrayList<RunContentDescriptor>(); for (String id : ids) { final ContentManager contentManager = myToolwindowIdToContentManagerMap.get(id); for (final Content content : contentManager.getContents()) { final RunContentDescriptor descriptor = getRunContentDescriptorByContent(content); if (descriptor != null) { descriptors.add(descriptor); } } } return descriptors; }
private void unregisterToolwindow(final String id) { final ContentManager manager = myToolwindowIdToContentManagerMap.get(id); manager.removeAllContents(true); myToolwindowIdToContentManagerMap.remove(id); myToolwindowIdZbuffer.remove(id); }