public void actionPerformed(AnActionEvent e) { ContentManager contentManager = ContentManagerUtil.getContentManagerFromContext(e.getDataContext(), true); boolean processed = false; if (contentManager != null && contentManager.canCloseContents()) { final Content selectedContent = contentManager.getSelectedContent(); if (selectedContent != null && selectedContent.isCloseable()) { contentManager.removeContent(selectedContent, true); processed = true; } } if (!processed && contentManager != null) { final DataContext context = DataManager.getInstance().getDataContext(contentManager.getComponent()); final ToolWindow tw = PlatformDataKeys.TOOL_WINDOW.getData(context); if (tw != null) { tw.hide(null); } } }
public void actionPerformed(AnActionEvent e) { ContentManager contentManager = ContentManagerUtil.getContentManagerFromContext(e.getDataContext(), true); boolean processed = false; if (contentManager != null && contentManager.canCloseContents()) { final Content selectedContent = contentManager.getSelectedContent(); if (selectedContent != null && selectedContent.isCloseable()) { contentManager.removeContent(selectedContent, true); processed = true; } } if (!processed && contentManager != null) { final DataContext context = DataManager.getInstance().getDataContext(contentManager.getComponent()); final ToolWindow tw = context.getData(PlatformDataKeys.TOOL_WINDOW); if (tw != null) { tw.hide(null); } } }
public void update(AnActionEvent event){ Presentation presentation = event.getPresentation(); ContentManager contentManager=ContentManagerUtil.getContentManagerFromContext(event.getDataContext(), true); presentation.setEnabled(contentManager != null && contentManager.canCloseContents()); if (!presentation.isEnabled() && contentManager != null) { final DataContext context = DataManager.getInstance().getDataContext(contentManager.getComponent()); presentation.setEnabled(PlatformDataKeys.TOOL_WINDOW.getData(context) != null); } }
@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); }
/** * @return selected content or <code>null</code> */ @Nullable private static Content getContent(final DataContext context){ Content[] contents = ViewContext.CONTENT_KEY.getData(context); if (contents != null && contents.length == 1) return contents[0]; ContentManager contentManager = ContentManagerUtil.getContentManagerFromContext(context, true); if (contentManager == null){ return null; } return contentManager.getSelectedContent(); }
public void update(AnActionEvent event) { Presentation presentation = event.getPresentation(); ContentManager contentManager = ContentManagerUtil.getContentManagerFromContext(event.getDataContext(), true); presentation.setEnabled(contentManager != null && contentManager.canCloseContents()); if (!presentation.isEnabled() && contentManager != null) { final DataContext context = DataManager.getInstance().getDataContext(contentManager.getComponent()); presentation.setEnabled(context.getData(PlatformDataKeys.TOOL_WINDOW) != null); } }
@Nullable private static Content getNonToolWindowContent(@Nonnull AnActionEvent e) { Content result = null; Content[] contents = e.getData(ViewContext.CONTENT_KEY); if (contents != null && contents.length == 1) result = contents[0]; if (result != null && result.isPinnable()) return result; ContentManager contentManager = ContentManagerUtil.getContentManagerFromContext(e.getDataContext(), true); result = contentManager != null? contentManager.getSelectedContent() : null; if (result != null && result.isPinnable()) return result; return null; }