Java Code Examples for com.intellij.ui.content.Content#getComponent()
The following examples show how to use
com.intellij.ui.content.Content#getComponent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CopyHandler.java From consulo with Apache License 2.0 | 6 votes |
public static void updateSelectionInActiveProjectView(PsiElement newElement, Project project, boolean selectInActivePanel) { String id = ToolWindowManager.getInstance(project).getActiveToolWindowId(); if (id != null) { ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(id); Content selectedContent = window.getContentManager().getSelectedContent(); if (selectedContent != null) { JComponent component = selectedContent.getComponent(); if (component instanceof TwoPaneIdeView) { ((TwoPaneIdeView) component).selectElement(newElement, selectInActivePanel); return; } } } if (ToolWindowId.PROJECT_VIEW.equals(id)) { ProjectView.getInstance(project).selectPsiElement(newElement, true); } else if (ToolWindowId.STRUCTURE_VIEW.equals(id)) { VirtualFile virtualFile = newElement.getContainingFile().getVirtualFile(); FileEditor editor = FileEditorManager.getInstance(newElement.getProject()).getSelectedEditor(virtualFile); StructureViewFactoryEx.getInstanceEx(project).getStructureViewWrapper().selectCurrentElement(editor, virtualFile, true); } }
Example 2
Source File: DuneCompiler.java From reasonml-idea-plugin with MIT License | 6 votes |
@Nullable @Override public ConsoleView getConsoleView() { ORToolWindowProvider windowProvider = ORToolWindowProvider.getInstance(project); ToolWindow duneToolWindow = windowProvider.getDuneToolWindow(); Content windowContent = duneToolWindow.getContentManager().getContent(0); if (windowContent == null) { return null; } SimpleToolWindowPanel component = (SimpleToolWindowPanel) windowContent.getComponent(); JComponent panelComponent = component.getComponent(); if (panelComponent == null) { return null; } return (ConsoleView) panelComponent.getComponent(0); }
Example 3
Source File: LafManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
public static void updateToolWindows() { for (Project project : ProjectManager.getInstance().getOpenProjects()) { final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); for (String id : toolWindowManager.getToolWindowIds()) { final ToolWindow toolWindow = toolWindowManager.getToolWindow(id); for (Content content : toolWindow.getContentManager().getContents()) { final JComponent component = content.getComponent(); if (component != null) { IJSwingUtilities.updateComponentTreeUI(component); } } final JComponent c = toolWindow.getComponent(); if (c != null) { IJSwingUtilities.updateComponentTreeUI(c); } } } }
Example 4
Source File: PredefinedSearchScopeProviderImpl.java From consulo with Apache License 2.0 | 6 votes |
private static void addHierarchyScope(@Nonnull Project project, Collection<SearchScope> result) { final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.HIERARCHY); if (toolWindow == null) { return; } final ContentManager contentManager = toolWindow.getContentManager(); final Content content = contentManager.getSelectedContent(); if (content == null) { return; } final String name = content.getDisplayName(); final JComponent component = content.getComponent(); if (!(component instanceof HierarchyBrowserBase)) { return; } final HierarchyBrowserBase hierarchyBrowserBase = (HierarchyBrowserBase)component; final PsiElement[] elements = hierarchyBrowserBase.getAvailableElements(); if (elements.length > 0) { result.add(new LocalSearchScope(elements, "Hierarchy '" + name + "' (visible nodes only)")); } }
Example 5
Source File: ExecutionHelper.java From consulo with Apache License 2.0 | 6 votes |
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(); } } } } }
Example 6
Source File: ContentUtilEx.java From consulo with Apache License 2.0 | 6 votes |
/** * Searches through all {@link Content simple} and {@link TabbedContent tabbed} contents of the given ContentManager, * trying to find the first one which matches the given condition. */ @Nullable public static JComponent findContentComponent(@Nonnull ContentManager manager, @Nonnull Condition<JComponent> condition) { for (Content content : manager.getContents()) { if (content instanceof TabbedContentImpl) { List<Pair<String, JComponent>> tabs = ((TabbedContentImpl)content).getTabs(); for (Pair<String, JComponent> tab : tabs) { if (condition.value(tab.second)) { return tab.second; } } } else if (condition.value(content.getComponent())) { return content.getComponent(); } } return null; }
Example 7
Source File: QuickDocUtil.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public static DocumentationComponent getActiveDocComponent(@Nonnull Project project) { DocumentationManager documentationManager = DocumentationManager.getInstance(project); DocumentationComponent component; JBPopup hint = documentationManager.getDocInfoHint(); if (hint != null) { component = (DocumentationComponent)((AbstractPopup)hint).getComponent(); } else if (documentationManager.hasActiveDockedDocWindow()) { ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.DOCUMENTATION); Content selectedContent = toolWindow == null ? null : toolWindow.getContentManager().getSelectedContent(); component = selectedContent == null ? null : (DocumentationComponent)selectedContent.getComponent(); } else { component = EditorMouseHoverPopupManager.getInstance().getDocumentationComponent(); } return component; }
Example 8
Source File: ReviewDialog.java From SmartIM4IntelliJ with Apache License 2.0 | 6 votes |
private void updateTarget() { targetPanel.setLayout(new GridLayout(0, 1, 0, 0)); if (IMWindowFactory.getDefault() == null || IMWindowFactory.getDefault().getProject() == null) { return; } ToolWindow window = ToolWindowManager.getInstance(IMWindowFactory.getDefault().getProject()) .getToolWindow(IMWindowFactory.TOOL_WINDOW_ID); if (window != null) { Content[] contents = window.getContentManager().getContents(); if (contents != null) { for (Content content : contents) { if (content.getComponent() != null && content.getComponent() instanceof IMPanel) { IMPanel panel = (IMPanel)content.getComponent(); List<IMChatConsole> chats = panel.getConsoleList(); if (!chats.isEmpty()) { targetPanel.add(new GroupPanel(content.getDisplayName(), chats)); } } } } } }
Example 9
Source File: AbstractVcsHelperImpl.java From consulo with Apache License 2.0 | 6 votes |
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(); } } } } }
Example 10
Source File: ToggleToolbarAction.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public AnAction[] getChildren(@Nullable AnActionEvent e) { ContentManager contentManager = myToolWindow.getContentManager(); Content selectedContent = contentManager.getSelectedContent(); JComponent contentComponent = selectedContent != null ? selectedContent.getComponent() : null; if (contentComponent == null) return EMPTY_ARRAY; List<AnAction> result = ContainerUtil.newSmartList(); for (final ActionToolbar toolbar : iterateToolbars(contentComponent)) { JComponent c = toolbar.getComponent(); if (c.isVisible() || !c.isValid()) continue; if (!result.isEmpty() && !(ContainerUtil.getLastItem(result) instanceof AnSeparator)) { result.add(AnSeparator.getInstance()); } List<AnAction> actions = toolbar.getActions(); for (AnAction action : actions) { if (action instanceof ToggleAction && !result.contains(action)) { result.add(action); } else if (action instanceof AnSeparator) { if (!result.isEmpty() && !(ContainerUtil.getLastItem(result) instanceof AnSeparator)) { result.add(AnSeparator.getInstance()); } } } } boolean popup = result.size() > 3; setPopup(popup); if (!popup && !result.isEmpty()) result.add(AnSeparator.getInstance()); return result.toArray(new AnAction[result.size()]); }
Example 11
Source File: BrowseHierarchyActionBase.java From consulo with Apache License 2.0 | 5 votes |
public static HierarchyBrowser createAndAddToPanel(@Nonnull Project project, @Nonnull final HierarchyProvider provider, @Nonnull PsiElement target) { final HierarchyBrowser hierarchyBrowser = provider.createHierarchyBrowser(target); final Content content; final HierarchyBrowserManager hierarchyBrowserManager = HierarchyBrowserManager.getInstance(project); final ContentManager contentManager = hierarchyBrowserManager.getContentManager(); final Content selectedContent = contentManager.getSelectedContent(); if (selectedContent != null && !selectedContent.isPinned()) { content = selectedContent; final Component component = content.getComponent(); if (component instanceof Disposable) { Disposer.dispose((Disposable)component); } content.setComponent(hierarchyBrowser.getComponent()); } else { content = ContentFactory.getInstance().createContent(hierarchyBrowser.getComponent(), null, true); contentManager.addContent(content); } contentManager.setSelectedContent(content); hierarchyBrowser.setContent(content); final Runnable runnable = new Runnable() { @Override public void run() { provider.browserActivated(hierarchyBrowser); } }; ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.HIERARCHY).activate(runnable); return hierarchyBrowser; }
Example 12
Source File: ReplaceInProjectManager.java From consulo with Apache License 2.0 | 5 votes |
@Override public void showSettings() { Content selectedContent = UsageViewContentManager.getInstance(myProject).getSelectedContent(true); JComponent component = selectedContent == null ? null : selectedContent.getComponent(); ReplaceInProjectManager findInProjectManager = getInstance(myProject); findInProjectManager.replaceInProject(DataManager.getInstance().getDataContext(component), myFindModel); }
Example 13
Source File: DocumentationManager.java From consulo with Apache License 2.0 | 5 votes |
@SuppressWarnings("unused") // used by plugin public void showJavaDocInfoAtToolWindow(@Nonnull PsiElement element, @Nonnull PsiElement original) { Content content = recreateToolWindow(element, original); if (content == null) return; DocumentationComponent component = (DocumentationComponent)content.getComponent(); myUpdateDocAlarm.cancelAllRequests(); doFetchDocInfo(component, new MyCollector(myProject, element, original, null, false)).doWhenDone(() -> component.clearHistory()); }
Example 14
Source File: OccurenceNavigatorActionBase.java From consulo with Apache License 2.0 | 5 votes |
@Nullable protected OccurenceNavigator getNavigator(DataContext dataContext) { ContentManager contentManager = ContentManagerUtil.getContentManagerFromContext(dataContext, false); if (contentManager != null) { Content content = contentManager.getSelectedContent(); if (content == null) return null; JComponent component = content.getComponent(); return findNavigator(component); } return (OccurenceNavigator)getOccurenceNavigatorFromContext(dataContext); }
Example 15
Source File: ExternalSystemUtil.java From consulo with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Nullable public static <T> T getToolWindowElement(@Nonnull Class<T> clazz, @Nonnull Project project, @Nonnull Key<T> key, @Nonnull ProjectSystemId externalSystemId) { if (project.isDisposed() || !project.isOpen()) { return null; } final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); if (toolWindowManager == null) { return null; } final ToolWindow toolWindow = ensureToolWindowContentInitialized(project, externalSystemId); if (toolWindow == null) { return null; } final ContentManager contentManager = toolWindow.getContentManager(); if (contentManager == null) { return null; } for (Content content : contentManager.getContents()) { final JComponent component = content.getComponent(); if (component instanceof DataProvider) { final Object data = ((DataProvider)component).getData(key); if (data != null && clazz.isInstance(data)) { return (T)data; } } } return null; }
Example 16
Source File: AbstractAutoTestManager.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private static ExecutionEnvironment getCurrentEnvironment(@Nonnull Content content) { JComponent component = content.getComponent(); if (component == null) { return null; } return DataManager.getInstance().getDataContext(component).getData(LangDataKeys.EXECUTION_ENVIRONMENT); }
Example 17
Source File: CompleteReviewAction.java From Crucible4IDEA with MIT License | 5 votes |
public void actionPerformed(AnActionEvent e) { final Project project = e.getData(PlatformDataKeys.PROJECT); if (project == null) return; CrucibleManager.getInstance(project).completeReview(myReview.getPermaId()); final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CrucibleBundle.message("crucible.toolwindow.id")); final ContentManager contentManager = toolWindow.getContentManager(); final Content foundContent = contentManager.findContent("Details for " + myReview.getPermaId()); contentManager.removeContent(foundContent, true); final Content dash = contentManager.findContent("Dashboard"); if (dash.getComponent() instanceof CruciblePanel) { ((CruciblePanel)dash.getComponent()).getReviewModel().updateModel(CrucibleFilter.ToReview); } }
Example 18
Source File: EsyCompiler.java From reasonml-idea-plugin with MIT License | 5 votes |
@Override public ConsoleView getConsoleView() { ORToolWindowProvider windowProvider = ORToolWindowProvider.getInstance(m_project); ToolWindow esyToolWindow = windowProvider.getEsyToolWindow(); Content windowContent = esyToolWindow.getContentManager().getContent(0); if (windowContent == null) { return null; } SimpleToolWindowPanel component = (SimpleToolWindowPanel) windowContent.getComponent(); JComponent panelComponent = component.getComponent(); if (panelComponent == null) { return null; } return (ConsoleView) panelComponent.getComponent(0); }
Example 19
Source File: BsCompilerImpl.java From reasonml-idea-plugin with MIT License | 5 votes |
@Nullable @Override public ConsoleView getConsoleView() { ORToolWindowProvider windowProvider = ORToolWindowProvider.getInstance(m_project); ToolWindow bsToolWindow = windowProvider.getBsToolWindow(); Content windowContent = bsToolWindow == null ? null : bsToolWindow.getContentManager().getContent(0); if (windowContent == null) { return null; } SimpleToolWindowPanel component = (SimpleToolWindowPanel) windowContent.getComponent(); JComponent panelComponent = component.getComponent(); return panelComponent == null ? null : (ConsoleView) panelComponent.getComponent(0); }
Example 20
Source File: ContentUtilEx.java From consulo with Apache License 2.0 | 4 votes |
public static void addTabbedContent(@Nonnull ContentManager manager, @Nonnull JComponent contentComponent, @Nonnull String groupPrefix, @Nonnull String tabName, boolean select, @Nullable Disposable childDisposable) { if (PropertiesComponent.getInstance().getBoolean(TabbedContent.SPLIT_PROPERTY_PREFIX + groupPrefix)) { final Content content = ContentFactory.getInstance().createContent(contentComponent, getFullName(groupPrefix, tabName), true); content.putUserData(Content.TABBED_CONTENT_KEY, Boolean.TRUE); content.putUserData(Content.TAB_GROUP_NAME_KEY, groupPrefix); for (Content c : manager.getContents()) { if (c.getComponent() == contentComponent) { if (select) { manager.setSelectedContent(c); } return; } } addContent(manager, content, select); registerDisposable(content, childDisposable, contentComponent); return; } TabbedContent tabbedContent = findTabbedContent(manager, groupPrefix); if (tabbedContent == null) { final Disposable disposable = Disposable.newDisposable(); tabbedContent = new TabbedContentImpl(contentComponent, tabName, true, groupPrefix); ContentsUtil.addOrReplaceContent(manager, tabbedContent, select); Disposer.register(tabbedContent, disposable); } else { for (Pair<String, JComponent> tab : new ArrayList<>(tabbedContent.getTabs())) { if (Comparing.equal(tab.second, contentComponent)) { tabbedContent.removeContent(tab.second); } } if (select) { manager.setSelectedContent(tabbedContent, true, true); } tabbedContent.addContent(contentComponent, tabName, true); } registerDisposable(tabbedContent, childDisposable, contentComponent); }