@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; }
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 void initialize() { if (myIsInitialized) { return; } myIsInitialized = true; myIsDisposed = false; myContentManager = ContentFactory.SERVICE.getInstance().createContentManager(true, myProject); myContentManager.addContentManagerListener( new ContentManagerAdapter() { public void contentRemoved(ContentManagerEvent event) { JComponent component = event.getContent().getComponent(); JComponent removedComponent = component instanceof CvsTabbedWindowComponent ? ((CvsTabbedWindowComponent) component).getComponent() : component; if (removedComponent == myErrorsView) { myErrorsView.dispose(); myErrorsView = null; } else if (myOutput != null && removedComponent == myOutput.getComponent()) { EditorFactory.getInstance().releaseEditor(myOutput); myOutput = null; } } }); ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject); ToolWindow toolWindow = toolWindowManager.registerToolWindow( ToolWindowId.CVS, myContentManager.getComponent(), ToolWindowAnchor.BOTTOM); toolWindow.setIcon(AllIcons.Providers.Cvs); toolWindow.installWatcher(myContentManager); }
private void registerToolwindow(@NotNull final Executor executor) { final String toolWindowId = executor.getToolWindowId(); final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject); if (toolWindowManager == null) return; // headless environment if (toolWindowManager.getToolWindow(toolWindowId) != null) { return; } final ToolWindow toolWindow = toolWindowManager.registerToolWindow( toolWindowId, true, ToolWindowAnchor.BOTTOM, this, true); final ContentManager contentManager = toolWindow.getContentManager(); class MyDataProvider implements DataProvider { private int myInsideGetData = 0; public Object getData(String dataId) { myInsideGetData++; try { if (PlatformDataKeys.HELP_ID.is(dataId)) { return executor.getHelpId(); } else { return myInsideGetData == 1 ? DataManager.getInstance() .getDataContext(contentManager.getComponent()) .getData(dataId) : null; } } finally { myInsideGetData--; } } } contentManager.addDataProvider(new MyDataProvider()); toolWindow.setIcon(executor.getToolWindowIcon()); new ContentManagerWatcher(toolWindow, contentManager); contentManager.addContentManagerListener( new ContentManagerAdapter() { public void selectionChanged(final ContentManagerEvent event) { final Content content = event.getContent(); final RunContentDescriptor descriptor = content != null ? getRunContentDescriptorByContent(content) : null; getSyncPublisher().contentSelected(descriptor, executor); } }); myToolwindowIdToContentManagerMap.put(toolWindowId, contentManager); Disposer.register( contentManager, new Disposable() { public void dispose() { unregisterToolwindow(toolWindowId); } }); myToolwindowIdZbuffer.addLast(toolWindowId); }
@Nullable private RunContentDescriptor getDescriptorBy(ProcessHandler handler, Executor runnerInfo) { ContentManager contentManager = getContentManagerForRunner(runnerInfo); Content[] contents = contentManager.getContents(); for (Content content : contents) { RunContentDescriptor runContentDescriptor = content.getUserData(DESCRIPTOR_KEY); if (runContentDescriptor.getProcessHandler() == handler) { return runContentDescriptor; } } return null; }
@Nullable public RunContentDescriptor getSelectedContent(final Executor executor) { final ContentManager contentManager = getContentManagerForRunner(executor); if (contentManager != null) { final Content selectedContent = contentManager.getSelectedContent(); if (selectedContent != null) { final RunContentDescriptor runContentDescriptorByContent = getRunContentDescriptorByContent(selectedContent); if (runContentDescriptorByContent != null) { return runContentDescriptorByContent; } } } return null; }
private CloseListener(Content content, ContentManager contentManager, Project project) { myContent = content; myContentManager = contentManager; myProject = project; contentManager.addContentManagerListener(this); ProjectManager.getInstance().addProjectManagerListener(myProject, this); }
private void mockContentImport(Owner owner, final Map<String, Content> contents) { when(contentManager.importContent(eq(owner), any(Map.class), any(Set.class))) .thenAnswer( new Answer<ImportResult<Content>>() { @Override public ImportResult<Content> answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); Map<String, ContentData> contentData = (Map<String, ContentData>) args[1]; ImportResult<Content> importResult = new ImportResult<Content>(); Map<String, Content> output = importResult.getCreatedEntities(); if (contentData != null) { for (String pid : contentData.keySet()) { Content content = contents.get(pid); if (content != null) { output.put(content.getId(), content); } } } return importResult; } }); }
@Nullable private static RunContentDescriptor chooseReuseContentForDescriptor( final ContentManager contentManager, final RunContentDescriptor descriptor) { Content content = null; if (descriptor != null) { if (descriptor.isContentReuseProhibited()) { return null; } final Content attachedContent = descriptor.getAttachedContent(); if (attachedContent != null && attachedContent.isValid()) content = attachedContent; } if (content == null) { content = contentManager.getSelectedContent(); if (content != null && content.isPinned()) content = null; } if (content == null || !isTerminated(content)) { return null; } final RunContentDescriptor oldDescriptor = getRunContentDescriptorByContent(content); if (oldDescriptor != null && !oldDescriptor.isContentReuseProhibited()) { return oldDescriptor; } return null; }
@Test public void testRuleAssetType() { assertTrue(ContentManager.getHandler(AssetFormats.DRL).isRuleAsset()); assertTrue(ContentManager.getHandler(AssetFormats.DSL_TEMPLATE_RULE).isRuleAsset()); assertTrue(ContentManager.getHandler(AssetFormats.BUSINESS_RULE).isRuleAsset()); assertTrue(ContentManager.getHandler(AssetFormats.DECISION_SPREADSHEET_XLS).isRuleAsset()); assertTrue(ContentManager.getHandler(AssetFormats.DECISION_TABLE_GUIDED).isRuleAsset()); assertFalse(ContentManager.getHandler(AssetFormats.DRL_MODEL).isRuleAsset()); assertFalse(ContentManager.getHandler(AssetFormats.DSL).isRuleAsset()); assertFalse(ContentManager.getHandler(AssetFormats.MODEL).isRuleAsset()); assertFalse(ContentManager.getHandler(AssetFormats.ENUMERATION).isRuleAsset()); }
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 private static Content getRunContentByDescriptor( final ContentManager contentManager, final RunContentDescriptor descriptor) { final Content[] contents = contentManager.getContents(); for (final Content content : contents) { if (descriptor.equals(content.getUserData(DESCRIPTOR_KEY))) { return content; } } return null; }
@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; }
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(); } }
@Test public void testContentFormat() { assertTrue(ContentManager.getHandler(AssetFormats.DRL) instanceof DRLFileContentHandler); assertTrue(ContentManager.getHandler(AssetFormats.DSL) instanceof DSLDefinitionContentHandler); assertTrue( ContentManager.getHandler(AssetFormats.DSL_TEMPLATE_RULE) instanceof DSLRuleContentHandler); assertTrue(ContentManager.getHandler(AssetFormats.BUSINESS_RULE) instanceof BRLContentHandler); assertTrue( ContentManager.getHandler(AssetFormats.DECISION_SPREADSHEET_XLS) instanceof DecisionTableXLSHandler); assertTrue( ContentManager.getHandler(AssetFormats.ENUMERATION) instanceof EnumerationContentHandler); assertTrue( ContentManager.getHandler(AssetFormats.DECISION_TABLE_GUIDED) instanceof GuidedDTContentHandler); assertTrue( ContentManager.getHandler(AssetFormats.DRL_MODEL) instanceof FactModelContentHandler); assertTrue(ContentManager.getHandler("XXX") instanceof DefaultContentHandler); }
private Content createNewContent( final ContentManager contentManager, final RunContentDescriptor descriptor, Executor executor) { final String processDisplayName = descriptor.getDisplayName(); final Content content = ContentFactory.SERVICE .getInstance() .createContent(descriptor.getComponent(), processDisplayName, true); content.putUserData(DESCRIPTOR_KEY, descriptor); content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE); contentManager.addContent(content); new CloseListener(content, executor); return content; }
public void contentRemoved(ContentManagerEvent event) { if (event.getContent() == myContent) { synchronized (myMessageViewLock) { if (myErrorTreeView != null) { myErrorTreeView.dispose(); myErrorTreeView = null; if (myIndicator.isRunning()) { cancel(); } if (AppIcon.getInstance().hideProgress(myProject, "compiler")) { AppIcon.getInstance().setErrorBadge(myProject, null); } } } myContentManager.removeContentManagerListener(this); myContent.release(); myContent = null; } }
public PanelWithActionsAndCloseButton( ContentManager contentManager, @NonNls String helpId, final boolean verticalToolbar) { super(new BorderLayout()); myContentManager = contentManager; myHelpId = helpId; myVerticalToolbar = verticalToolbar; myCloseEnabled = true; if (myContentManager != null) { myContentManager.addContentManagerListener( new ContentManagerAdapter() { public void contentRemoved(ContentManagerEvent event) { if (event.getContent().getComponent() == PanelWithActionsAndCloseButton.this) { dispose(); myContentManager.removeContentManagerListener(this); } } }); } }
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(); } }
/** * This will take the information returned from the barcode scan, check if it is one of the * exhibits, and if it is will navigate to that page. * * @param context The application's environment. * @param contents A string containing the barcode scan information. */ static void processBarcodeContents(WireActivity context, String contents) { String potentialKey = null; String prefix = context.loadString(R.string.qr_prefix); if (contents.length() > prefix.length() && contents.substring(0, prefix.length()).equals(prefix)) { potentialKey = contents.substring(prefix.length()).replaceAll("_", " "); } if (potentialKey != null) { ExhibitList exhibitList = ContentManager.getExhibitList(); if (true == exhibitList.containsKey(potentialKey)) { ExhibitActivity.start(context, potentialKey); } } else { Toast.makeText( context.getApplicationContext(), context.loadString(R.string.qr_unknown), Toast.LENGTH_SHORT) .show(); Log.w(Common.class.getName(), "Unrecognized QR code " + contents); } } /* CommonUnitTest */
private Texture2D extractSpriteSheet(Element rootNode) { String path = rootNode.getChildText("TexturePath"); return ContentManager.loadTexture(this.texturePath + path); }
public void setContent(Content content, ContentManager contentManager) { myContent = content; myContentManager = contentManager; contentManager.addContentManagerListener(this); }
public void projectClosed(Project project) { if (myContent != null) { myContentManager.removeContent(myContent, true); } }
private void unregisterToolwindow(final String id) { final ContentManager manager = myToolwindowIdToContentManagerMap.get(id); manager.removeAllContents(true); myToolwindowIdToContentManagerMap.remove(id); myToolwindowIdZbuffer.remove(id); }
@Override public void projectClosed(Project project) { if (project.equals(myProject) && myContent != null) { myContentManager.removeContent(myContent, true); } }
public boolean removeRunContent( @NotNull final Executor executor, final RunContentDescriptor descriptor) { final ContentManager contentManager = getContentManagerForRunner(executor); final Content content = getRunContentByDescriptor(contentManager, descriptor); return content != null && contentManager.removeContent(content, true); }