List of usage examples for com.intellij.openapi.actionSystem PlatformDataKeys CONTENT_MANAGER
DataKey CONTENT_MANAGER
To view the source code for com.intellij.openapi.actionSystem PlatformDataKeys CONTENT_MANAGER.
Click Source Link
From source file:com.intellij.ide.actions.ToggleToolbarAction.java
License:Apache License
private ToggleToolbarAction(@NotNull ToolWindow toolWindow, @NotNull PropertiesComponent propertiesComponent) { super("Show Toolbar"); myPropertiesComponent = propertiesComponent; myToolWindow = toolWindow;/*from w ww . j ava2 s. c o m*/ myToolWindow.getContentManager().addContentManagerListener(new ContentManagerAdapter() { @Override public void contentAdded(ContentManagerEvent event) { JComponent component = event.getContent().getComponent(); setContentToolbarVisible(component, getVisibilityValue()); // support nested content managers, e.g. RunnerLayoutUi as content component ContentManager contentManager = component instanceof DataProvider ? PlatformDataKeys.CONTENT_MANAGER.getData((DataProvider) component) : null; if (contentManager != null) contentManager.addContentManagerListener(this); } }); }
From source file:com.intellij.ui.content.ContentManagerUtil.java
License:Apache License
/** * This is utility method. It returns <code>ContentManager</code> from the current context. */// www. j ava 2 s . c o m public static ContentManager getContentManagerFromContext(DataContext dataContext, boolean requiresVisibleToolWindow) { Project project = CommonDataKeys.PROJECT.getData(dataContext); 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 = PlatformDataKeys.CONTENT_MANAGER.getData(dataContext); if (fromContext != null) return fromContext; return toolWindow != null ? toolWindow.getContentManager() : null; }