Java Code Examples for com.intellij.openapi.wm.ex.ToolWindowManagerEx#getToolWindow()
The following examples show how to use
com.intellij.openapi.wm.ex.ToolWindowManagerEx#getToolWindow() .
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: EditorPerfDecorations.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns the action executed when the icon is left-clicked. * * @return the action instance, or null if no action is required. */ @Nullable public AnAction getClickAction() { return new AnAction() { @Override public void actionPerformed(@NotNull AnActionEvent event) { if (isActive()) { final ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(getApp().getProject()); final ToolWindow flutterPerfToolWindow = toolWindowManager.getToolWindow(FlutterPerformanceView.TOOL_WINDOW_ID); if (flutterPerfToolWindow.isVisible()) { showPerfViewMessage(); return; } flutterPerfToolWindow.show(() -> showPerfViewMessage()); } } }; }
Example 2
Source File: EditorPerfDecorations.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns the action executed when the icon is left-clicked. * * @return the action instance, or null if no action is required. */ @Nullable public AnAction getClickAction() { return new AnAction() { @Override public void actionPerformed(@NotNull AnActionEvent event) { if (isActive()) { final ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(getApp().getProject()); final ToolWindow flutterPerfToolWindow = toolWindowManager.getToolWindow(FlutterPerformanceView.TOOL_WINDOW_ID); if (flutterPerfToolWindow.isVisible()) { showPerfViewMessage(); return; } flutterPerfToolWindow.show(() -> showPerfViewMessage()); } } }; }
Example 3
Source File: HideSideWindowsAction.java From consulo with Apache License 2.0 | 6 votes |
public void update(AnActionEvent event) { Presentation presentation = event.getPresentation(); Project project = event.getData(CommonDataKeys.PROJECT); if (project == null) { presentation.setEnabled(false); return; } ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(project); String id = toolWindowManager.getActiveToolWindowId(); if (id != null) { presentation.setEnabled(true); return; } id = toolWindowManager.getLastActiveToolWindowId(); if (id == null) { presentation.setEnabled(false); return; } ToolWindowEx toolWindow = (ToolWindowEx)toolWindowManager.getToolWindow(id); presentation.setEnabled(toolWindow.isVisible()); }
Example 4
Source File: ToggleFloatingModeAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void setSelected(AnActionEvent event, boolean flag) { Project project = event.getData(CommonDataKeys.PROJECT); if (project == null) { return; } String id = ToolWindowManager.getInstance(project).getActiveToolWindowId(); if (id == null) { return; } ToolWindowManagerEx mgr = ToolWindowManagerEx.getInstanceEx(project); ToolWindowEx toolWindow = (ToolWindowEx)mgr.getToolWindow(id); ToolWindowType type = toolWindow.getType(); if (ToolWindowType.FLOATING == type) { toolWindow.setType(toolWindow.getInternalType(), null); } else { toolWindow.setType(ToolWindowType.FLOATING, null); } }
Example 5
Source File: BaseToolWindowToggleAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public final void setSelected(AnActionEvent e, boolean state) { Project project = e.getData(CommonDataKeys.PROJECT); if (project == null) { return; } String id = ToolWindowManager.getInstance(project).getActiveToolWindowId(); if (id == null) { return; } ToolWindowManagerEx mgr = ToolWindowManagerEx.getInstanceEx(project); ToolWindowEx toolWindow = (ToolWindowEx)mgr.getToolWindow(id); setSelected(toolWindow, state); }
Example 6
Source File: ToggleWindowedModeAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void setSelected(AnActionEvent event, boolean flag) { Project project = event.getData(CommonDataKeys.PROJECT); if (project == null) { return; } String id = ToolWindowManager.getInstance(project).getActiveToolWindowId(); if (id == null) { return; } ToolWindowManagerEx mgr = ToolWindowManagerEx.getInstanceEx(project); ToolWindowEx toolWindow = (ToolWindowEx)mgr.getToolWindow(id); ToolWindowType type = toolWindow.getType(); if (ToolWindowType.WINDOWED == type) { toolWindow.setType(toolWindow.getInternalType(), null); } else { toolWindow.setType(ToolWindowType.WINDOWED, null); } }
Example 7
Source File: HideToolWindowAction.java From consulo with Apache License 2.0 | 6 votes |
public void update(AnActionEvent event) { Presentation presentation = event.getPresentation(); Project project = event.getData(CommonDataKeys.PROJECT); if (project == null) { presentation.setEnabled(false); return; } ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(project); String id = toolWindowManager.getActiveToolWindowId(); if (id != null) { presentation.setEnabled(true); return; } id = toolWindowManager.getLastActiveToolWindowId(); if (id == null) { presentation.setEnabled(false); return; } ToolWindow toolWindow = toolWindowManager.getToolWindow(id); presentation.setEnabled(toolWindow.isVisible()); }
Example 8
Source File: ContentManagerUtil.java From consulo with Apache License 2.0 | 5 votes |
/** * This is utility method. It returns <code>ContentManager</code> from the current context. */ public static ContentManager getContentManagerFromContext(DataContext dataContext, boolean requiresVisibleToolWindow){ Project project = dataContext.getData(CommonDataKeys.PROJECT); if (project == null) { return null; } ToolWindowManagerEx mgr=ToolWindowManagerEx.getInstanceEx(project); String id = mgr.getActiveToolWindowId(); if (id == null) { if(mgr.isEditorComponentActive()){ id = mgr.getLastActiveToolWindowId(); } } if(id == null){ return null; } ToolWindowEx toolWindow = (ToolWindowEx)mgr.getToolWindow(id); if (requiresVisibleToolWindow && !toolWindow.isVisible()) { return null; } final ContentManager fromContext = dataContext.getData(PlatformDataKeys.CONTENT_MANAGER); if (fromContext != null) return fromContext; return toolWindow != null ? toolWindow.getContentManager() : null; }
Example 9
Source File: HideAllToolWindowsAction.java From consulo with Apache License 2.0 | 5 votes |
public static void performAction(final Project project) { ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(project); ToolWindowLayout layout = new ToolWindowLayout(); layout.copyFrom(toolWindowManager.getLayout()); // to clear windows stack toolWindowManager.clearSideStack(); //toolWindowManager.activateEditorComponent(); String[] ids = toolWindowManager.getToolWindowIds(); boolean hasVisible = false; for (String id : ids) { ToolWindow toolWindow = toolWindowManager.getToolWindow(id); if (toolWindow.isVisible()) { toolWindow.hide(null); hasVisible = true; } } if (hasVisible) { toolWindowManager.setLayoutToRestoreLater(layout); toolWindowManager.activateEditorComponent(); } else { final ToolWindowLayout restoredLayout = toolWindowManager.getLayoutToRestoreLater(); if (restoredLayout != null) { toolWindowManager.setLayoutToRestoreLater(null); toolWindowManager.setLayout(restoredLayout); } } }
Example 10
Source File: TogglePresentationModeAction.java From consulo with Apache License 2.0 | 5 votes |
private static boolean hideAllToolWindows(ToolWindowManagerEx manager) { // to clear windows stack manager.clearSideStack(); String[] ids = manager.getToolWindowIds(); boolean hasVisible = false; for (String id : ids) { final ToolWindow toolWindow = manager.getToolWindow(id); if (toolWindow.isVisible()) { toolWindow.hide(null); hasVisible = true; } } return hasVisible; }
Example 11
Source File: RunContentManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess private void registerToolWindow(@Nonnull final Executor executor, @Nonnull ToolWindowManagerEx toolWindowManager) { final String toolWindowId = executor.getToolWindowId(); if (toolWindowManager.getToolWindow(toolWindowId) != null) { return; } final ToolWindow toolWindow = toolWindowManager.registerToolWindow(toolWindowId, true, ToolWindowAnchor.BOTTOM, this, true); final ContentManager contentManager = toolWindow.getContentManager(); contentManager.addDataProvider(new DataProvider() { private int myInsideGetData = 0; @Override public Object getData(@Nonnull Key<?> dataId) { myInsideGetData++; try { if (PlatformDataKeys.HELP_ID == dataId) { return executor.getHelpId(); } else { return myInsideGetData == 1 ? DataManager.getInstance().getDataContext(contentManager.getComponent()).getData(dataId) : null; } } finally { myInsideGetData--; } } }); toolWindow.setIcon(executor.getToolWindowIcon()); new ContentManagerWatcher(toolWindow, contentManager); initToolWindow(executor, toolWindowId, executor.getToolWindowIcon(), contentManager); }
Example 12
Source File: EditorTabbedContainer.java From consulo with Apache License 2.0 | 4 votes |
private void updateTabBorder() { if (!myProject.isOpen()) return; ToolWindowManagerEx mgr = (ToolWindowManagerEx)ToolWindowManager.getInstance(myProject); String[] ids = mgr.getToolWindowIds(); Insets border = JBUI.emptyInsets(); UISettings uiSettings = UISettings.getInstance(); List<String> topIds = mgr.getIdsOn(ToolWindowAnchor.TOP); List<String> bottom = mgr.getIdsOn(ToolWindowAnchor.BOTTOM); List<String> rightIds = mgr.getIdsOn(ToolWindowAnchor.RIGHT); List<String> leftIds = mgr.getIdsOn(ToolWindowAnchor.LEFT); if (!uiSettings.getHideToolStripes() && !uiSettings.getPresentationMode()) { border.top = !topIds.isEmpty() ? 1 : 0; border.bottom = !bottom.isEmpty() ? 1 : 0; border.left = !leftIds.isEmpty() ? 1 : 0; border.right = !rightIds.isEmpty() ? 1 : 0; } for (String each : ids) { ToolWindow eachWnd = mgr.getToolWindow(each); if (eachWnd == null || !eachWnd.isAvailable()) continue; if (eachWnd.isVisible() && eachWnd.getType() == ToolWindowType.DOCKED) { ToolWindowAnchor eachAnchor = eachWnd.getAnchor(); if (eachAnchor == ToolWindowAnchor.TOP) { border.top = 0; } else if (eachAnchor == ToolWindowAnchor.BOTTOM) { border.bottom = 0; } else if (eachAnchor == ToolWindowAnchor.LEFT) { border.left = 0; } else if (eachAnchor == ToolWindowAnchor.RIGHT) { border.right = 0; } } } myTabs.getPresentation().setPaintBorder(border.top, border.left, border.right, border.bottom).setTabSidePaintBorder(5); }