@Override public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) { toolWindow.setIcon(EducationalCoreIcons.TaskDescription); final Course course = StudyTaskManager.getInstance(project).getCourse(); if (course != null) { final StudyToolWindow studyToolWindow; if (StudyUtils.hasJavaFx() && StudySettings.getInstance().shouldUseJavaFx()) { studyToolWindow = new StudyJavaFxToolWindow(); } else { studyToolWindow = new StudySwingToolWindow(); } studyToolWindow.init(project, true); final ContentManager contentManager = toolWindow.getContentManager(); final Content content = contentManager.getFactory().createContent(studyToolWindow, null, false); contentManager.addContent(content); Disposer.register(project, studyToolWindow); } }
public static void addOrReplaceContent(ContentManager manager, Content content, boolean select) { final String contentName = content.getDisplayName(); Content[] contents = manager.getContents(); Content oldContentFound = null; for(Content oldContent: contents) { if (!oldContent.isPinned() && oldContent.getDisplayName().equals(contentName)) { oldContentFound = oldContent; break; } } manager.addContent(content); if (oldContentFound != null) { manager.removeContent(oldContentFound, true); } if (select) { manager.setSelectedContent(content); } }
public ContentTabLabel(final Content content, TabContentLayout layout) { super(layout.myUi, true); myLayout = layout; myContent = content; update(); myBehavior = new BaseButtonBehavior(this) { protected void execute(final MouseEvent e) { final ContentManager mgr = contentManager(); if (mgr.getIndexOfContent(myContent) >= 0) { mgr.setSelectedContent(myContent, true); } } }; myBehavior.setActionTrigger(MouseEvent.MOUSE_PRESSED); myBehavior.setMouseDeadzone(TimedDeadzone.NULL); }
/** * Searches through all {@link Content simple} and {@link TabbedContent tabbed} contents of the given ContentManager, * and selects the one which holds the specified {@code contentComponent}. * * @return true if the necessary content was found (and thus selected) among content components of the given ContentManager. */ public static boolean selectContent(@NotNull ContentManager manager, @NotNull final JComponent contentComponent, boolean requestFocus) { for (Content content : manager.getContents()) { if (content instanceof TabbedContentImpl) { boolean found = ((TabbedContentImpl)content).findAndSelectContent(contentComponent); if (found) { manager.setSelectedContent(content, requestFocus); return true; } } else if (Comparing.equal(content.getComponent(), contentComponent)) { manager.setSelectedContent(content, requestFocus); return true; } } return false; }
/** * 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(@NotNull ContentManager manager, @NotNull 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; }
public void actionPerformed(AnActionEvent e) { DataContext dataContext = e.getDataContext(); Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project == null) { return; } ToolWindowManager windowManager = ToolWindowManager.getInstance(project); if (windowManager.isEditorComponentActive()) { doNavigate(dataContext, project); return; } ContentManager contentManager = PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.getData(dataContext); if (contentManager == null) return; doNavigate(contentManager); }
public void update(AnActionEvent event){ Presentation presentation = event.getPresentation(); DataContext dataContext = event.getDataContext(); Project project = CommonDataKeys.PROJECT.getData(dataContext); presentation.setEnabled(false); if (project == null) { return; } final ToolWindowManager windowManager = ToolWindowManager.getInstance(project); if (windowManager.isEditorComponentActive()) { final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project); EditorWindow currentWindow = EditorWindow.DATA_KEY.getData(dataContext); if (currentWindow == null){ editorManager.getCurrentWindow (); } if (currentWindow != null) { final VirtualFile[] files = currentWindow.getFiles(); presentation.setEnabled(files.length > 1); } return; } ContentManager contentManager = PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.getData(dataContext); presentation.setEnabled(contentManager != null && contentManager.getContentCount() > 1 && contentManager.isSingleSelection()); }
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); } } }
private ToggleToolbarAction(@NotNull ToolWindow toolWindow, @NotNull PropertiesComponent propertiesComponent) { super("Show Toolbar"); myPropertiesComponent = propertiesComponent; myToolWindow = toolWindow; 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); } }); }
public void select() { if (ApplicationManager.getApplication().isUnitTestMode()) return; UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { if (myRunContentDescriptor != null) { ToolWindow toolWindow = ExecutionManager.getInstance(myProject).getContentManager() .getToolWindowByDescriptor(myRunContentDescriptor); Content content = myRunContentDescriptor.getAttachedContent(); if (toolWindow == null || content == null) return; ContentManager manager = toolWindow.getContentManager(); if (ArrayUtil.contains(content, manager.getContents()) && !manager.isSelected(content)) { manager.setSelectedContent(content); } } } }); }
@Override public void addMessageToConsoleWindow(final String message, final TextAttributes attributes) { if (!Registry.is("vcs.showConsole")) { return; } if (StringUtil.isEmptyOrSpaces(message)) { return; } ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { // for default and disposed projects the ContentManager is not available. if (myProject.isDisposed() || myProject.isDefault()) return; final ContentManager contentManager = getContentManager(); if (contentManager == null) { myPendingOutput.add(Pair.create(message, attributes)); } else { getOrCreateConsoleContent(contentManager); myEditorAdapter.appendString(message, attributes); } } }, ModalityState.defaultModalityState()); }
private ContentManager getContentManager(boolean dataFlowToThis) { if (dataFlowToThis) { if (myBackContentManager == null) { ToolWindow backToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(BACK_TOOLWINDOW_ID, true, ToolWindowAnchor.BOTTOM, myProject); myBackContentManager = backToolWindow.getContentManager(); new ContentManagerWatcher(backToolWindow, myBackContentManager); } return myBackContentManager; } if (myForthContentManager == null) { ToolWindow forthToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(FORTH_TOOLWINDOW_ID, true, ToolWindowAnchor.BOTTOM, myProject); myForthContentManager = forthToolWindow.getContentManager(); new ContentManagerWatcher(forthToolWindow, myForthContentManager); } return myForthContentManager; }
@Override protected void initSession(XDebugSession session, RunProfileState state, Executor executor) { XDebugSessionTab tab = ((XDebugSessionImpl)session).getSessionTab(); if (tab != null) { RunnerLayoutUi ui = tab.getUi(); ContentManager contentManager = ui.getContentManager(); Content content = findContent(contentManager, XDebuggerBundle.message("debugger.session.tab.watches.title")); if (content != null) { contentManager.removeContent(content, true); } content = findContent(contentManager, XDebuggerBundle.message("debugger.session.tab.console.content.name")); if (content != null) { contentManager.removeContent(content, true); } initEduConsole(session, ui); } }
@Override protected void initToolWindow() { myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(UIDesignerBundle.message("toolwindow.ui.designer.name"), false, getAnchor(), myProject, true); myToolWindow.setIcon(UIDesignerIcons.ToolWindowUIDesigner); if (!ApplicationManager.getApplication().isHeadlessEnvironment()) { myToolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true"); } initGearActions(); ContentManager contentManager = myToolWindow.getContentManager(); Content content = contentManager.getFactory() .createContent(myToolWindowPanel.getToolWindowPanel(), UIDesignerBundle.message("toolwindow.ui.designer.title"), false); content.setCloseable(false); content.setPreferredFocusableComponent(myToolWindowPanel.getComponentTree()); contentManager.addContent(content); contentManager.setSelectedContent(content, true); myToolWindow.setAvailable(false, null); }
/** * Show skipped commits * * @param project the context project * @param skippedCommits the skipped commits */ public static void showSkipped(final Project project, final SortedMap<VirtualFile, List<GitRebaseUtils.CommitInfo>> skippedCommits) { UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { ContentManager contentManager = ProjectLevelVcsManagerEx.getInstanceEx(project).getContentManager(); if (contentManager == null) { return; } GitSkippedCommits skipped = new GitSkippedCommits(contentManager, project, skippedCommits); Content content = ContentFactory.SERVICE.getInstance().createContent(skipped, "Skipped Commits", true); ContentsUtil.addContent(contentManager, content, true); ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS).activate(null); } }); }
@NotNull private static String calcTabName(@NotNull ContentManager cm, @NotNull List<VirtualFile> roots) { String name = VcsLogContentProvider.TAB_NAME + " (" + roots.get(0).getName(); if (roots.size() > 1) { name += "+"; } name += ")"; String candidate = name; int cnt = 1; while (hasContentsWithName(cm, candidate)) { candidate = name + "-" + cnt; cnt++; } return candidate; }
private static boolean checkIfProjectLogMatches(@NotNull Project project, @NotNull GitVcs vcs, @NotNull ContentManager cm, @NotNull List<VirtualFile> requestedRoots) { VirtualFile[] projectRoots = ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(vcs); if (Comparing.haveEqualElements(requestedRoots, Arrays.asList(projectRoots))) { Content[] contents = cm.getContents(); for (Content content : contents) { if (VcsLogContentProvider.TAB_NAME.equals(content.getDisplayName())) { cm.setSelectedContent(content); return true; } } } return false; }
public CvsTabbedWindowComponent(JComponent component, boolean addDefaultToolbar, @Nullable ActionGroup toolbarActions, ContentManager contentManager, String helpId) { super(new BorderLayout()); myAddToolbar = addDefaultToolbar; myComponent = component; myContentManager = contentManager; myHelpId = helpId; add(myComponent, BorderLayout.CENTER); if (myAddToolbar) { DefaultActionGroup actionGroup = new DefaultActionGroup(null, false); actionGroup.add(new CloseAction()); if (toolbarActions != null) { actionGroup.add(toolbarActions); } actionGroup.add(new ContextHelpAction(helpId)); add(ActionManager.getInstance(). createActionToolbar("DefaultCvsComponentToolbar", actionGroup, false).getComponent(), BorderLayout.WEST); } }
public void actionPerformed(final AnActionEvent e) { final Project project = e.getData(CommonDataKeys.PROJECT); if (project == null) { return; } final CopiesPanel copiesPanel = new CopiesPanel(project); ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS); final ContentManager contentManager = toolWindow.getContentManager(); Content content = ContentFactory.SERVICE.getInstance().createContent(copiesPanel.getComponent(), SvnBundle.message("dialog.show.svn.map.title"), true); ContentsUtil.addOrReplaceContent(contentManager, content, true); toolWindow.activate(new Runnable() { public void run() { IdeFocusManager.getInstance(project).requestFocus(copiesPanel.getPreferredFocusedComponent(), true); } }); /*SwingUtilities.invokeLater(new Runnable() { public void run() { IdeFocusManager.getInstance(project).requestFocus(copiesPanel.getPrefferedFocusComponent(), true); } });*/ }
public static void showInVersionControlToolWindow(final Project project, final String title, final List<FilePath> filesToShow, final String prompt) { final IntersectingLocalChangesPanel component = new IntersectingLocalChangesPanel(project, filesToShow, prompt); ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS); final ContentManager contentManager = toolWindow.getContentManager(); Content content = ContentFactory .SERVICE.getInstance().createContent(component.getPanel(), title, true); ContentsUtil.addContent(contentManager, content, true); toolWindow.activate(new Runnable() { public void run() { IdeFocusManager.getInstance(project).requestFocus(component.getPrefferedFocusComponent(), true); } }); }
public static void showMe(final Project project, final SvnFileRevision revision, final VirtualFile file) { if (ModalityState.NON_MODAL.equals(ModalityState.current())) { ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS); final ContentManager contentManager = toolWindow.getContentManager(); final MyDialog dialog = new MyDialog(project, revision, file); // TODO: Temporary memory leak fix - rewrite this part not to create dialog if only createCenterPanel(), but not show() is invoked Disposer.register(project, dialog.getDisposable()); Content content = ContentFactory.SERVICE.getInstance().createContent(dialog.createCenterPanel(), SvnBundle.message("merge.source.details.title", (file == null) ? revision.getURL() : file.getName(), revision.getRevisionNumber().asString()), true); ContentsUtil.addOrReplaceContent(contentManager, content, true); toolWindow.activate(null); } else { new MyDialog(project, revision, file).show(); } }
private Content setUpToolWindow() { //Create runner UI layout final RunnerLayoutUi.Factory factory = RunnerLayoutUi.Factory.getInstance(myProject); final RunnerLayoutUi layoutUi = factory.create("", "", "session", myProject); // Adding actions DefaultActionGroup group = new DefaultActionGroup(); group.add(myKillAction); group.addSeparator(); layoutUi.getOptions().setLeftToolbar(group, ActionPlaces.UNKNOWN); final Content console = layoutUi.createContent(CONSOLE_ID, myConsole.getComponent(), "", null, null); layoutUi.addContent(console, 0, PlaceInGrid.right, false); final JComponent uiComponent = layoutUi.getComponent(); myPanel.add(uiComponent, BorderLayout.CENTER); final ContentManager manager = myToolWindow.getContentManager(); final ContentFactory contentFactory = ContentFactory.SERVICE.getInstance(); final Content content = contentFactory.createContent(uiComponent, null, true); manager.addContent(content); return content; }
public ToolWindow getToolWindow() { if (myToolWindow == null) { myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(GroovyBundle.message("dynamic.tool.window.id"), true, ToolWindowAnchor.RIGHT); myToolWindow.setIcon(JetgroovyIcons.Groovy.DynamicProperty_13); myToolWindow.setTitle(GroovyBundle.message("dynamic.window")); myToolWindow.setToHideOnEmptyContent(true); final JPanel panel = buildBigPanel(); final ContentManager contentManager = myToolWindow.getContentManager(); final Content content = contentManager.getFactory().createContent(panel, "", false); content.setPreferredFocusableComponent(myTreeTable); contentManager.addContent(content); } return myToolWindow; }
@Override protected void initToolWindow() { myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(DesignerBundle.message("designer.toolwindow.name"), false, getAnchor(), myProject, true); myToolWindow.setIcon(UIDesignerNewIcons.ToolWindow); if (!ApplicationManager.getApplication().isHeadlessEnvironment()) { myToolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true"); } ((ToolWindowEx)myToolWindow).setTitleActions(myToolWindowContent.createActions()); initGearActions(); ContentManager contentManager = myToolWindow.getContentManager(); Content content = contentManager.getFactory() .createContent(myToolWindowContent.getToolWindowPanel(), DesignerBundle.message("designer.toolwindow.title"), false); content.setCloseable(false); content.setPreferredFocusableComponent(myToolWindowContent.getComponentTree()); contentManager.addContent(content); contentManager.setSelectedContent(content, true); myToolWindow.setAvailable(false, null); }
public CcLogsToolWindow(@NotNull Project project) { ToolWindow toolWindow = ToolWindowManager.getInstance(project).registerToolWindow("Logs Clever Cloud", false, ToolWindowAnchor.BOTTOM); ContentManager contentManager = toolWindow.getContentManager(); ProjectSettings projectSettings = ServiceManager.getService(project, ProjectSettings.class); ArrayList<Application> applications = projectSettings.applications; for (Application application : applications) { TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project); ConsoleView console = builder.getConsole(); Content logs = contentManager.getFactory().createContent(console.getComponent(), application.name, false); contentManager.addContent(logs); writeLogs(project, application, console); String oldLogs = CcApi.getInstance(project).logRequest(application); if (oldLogs != null && !oldLogs.isEmpty()) { WebSocketCore.printSocket(console, oldLogs); } else if (oldLogs != null && oldLogs.isEmpty()) { WebSocketCore.printSocket(console, "No logs available.\n"); } } }
@Override public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) { logger.info("Initializing Pastes ToolWindow"); toolWindow.setStripeTitle("Ultimate PasteBin"); toolWindow.setTitle("Ultimate PasteBin"); ContentManager contentManager = toolWindow.getContentManager(); Content content = contentManager.getFactory().createContent(toolWindow.getComponent(), null, false); ToolWindowService service = ServiceManager.getService(ToolWindowService.class); // Panel with toolbar SimpleToolWindowPanel simpleToolWindowPanel = new SimpleToolWindowPanel(true); // Scrolable panel JBScrollPane jbScrollPane = new JBScrollPane(service.getTree()); simpleToolWindowPanel.add(jbScrollPane); simpleToolWindowPanel.setToolbar(createToolbar()); content.setComponent(simpleToolWindowPanel); contentManager.addContent(content); toolWindow.activate(this::firstTimeOpen); }
private void updateToolWindow(@NotNull Project project, @NotNull ToolWindow toolWindow) { ContentManager contentManager = toolWindow.getContentManager(); contentManager.removeAllContents(true); FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); Editor selectedEditor = fileEditorManager.getSelectedTextEditor(); if (selectedEditor == null) return; PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(selectedEditor.getDocument()); if (psiFile == null || !psiFile.getLanguage().equals(PythonLanguage.INSTANCE)) { return; } FileEditor fileEditor = fileEditorManager.getSelectedEditor(psiFile.getVirtualFile()); StructureView structureView = new PTestStructureViewFactory().getStructureViewBuilder(psiFile).createStructureView(fileEditor, project); Content content = ContentFactory.SERVICE.getInstance().createContent(structureView.getComponent(), "", false); contentManager.addContent(content); }
@Override public void createToolWindowContent( @NotNull final Project project, @NotNull ToolWindow toolWindow) { toolWindow.setAvailable(true, null); toolWindow.setToHideOnEmptyContent(true); RunnerLayoutUi runnerLayoutUi = BuckUIManager.getInstance(project).getLayoutUi(project); Content consoleContent = createConsoleContent(runnerLayoutUi, project); runnerLayoutUi.addContent(consoleContent, 0, PlaceInGrid.center, false); runnerLayoutUi.getOptions().setLeftToolbar( getLeftToolbarActions(project), ActionPlaces.UNKNOWN); runnerLayoutUi.updateActionsNow(); final ContentManager contentManager = toolWindow.getContentManager(); Content content = contentManager.getFactory().createContent( runnerLayoutUi.getComponent(), "", true); contentManager.addContent(content); updateBuckToolWindowTitle(project); }
@Override public void createToolWindowContent(@NotNull final Project project, @NotNull ToolWindow toolWindow) { final MCSettingsProvider settings = MCSettingsProvider.getInstance(project); final ContentManager contentManager = toolWindow.getContentManager(); final ContentFactory contentFactory = ContentFactory.SERVICE.getInstance(); final String mayaLogPath = PathManager.getPluginTempPath() + String.format(MayaCommInterface.LOG_FILENAME_STRING, settings.getPort()); final MayaLogConsole console = new MayaLogConsole(project, new File(mayaLogPath), Charset.defaultCharset(), 0L, "MayaLog", false, GlobalSearchScope.allScope(project)); final Content content = contentFactory.createContent(console.getComponent(), "", false); contentManager.addContent(content); toolWindow.setAvailable(true, null); toolWindow.setToHideOnEmptyContent(true); toolWindow.activate(console::activate); }
public OCamlTopLevelConsoleView(@NotNull final Project project, @NotNull final ContentManager contentManager, final Sdk topLevelSdk) throws ExecutionException { super(project, contentManager); myConsoleNumber = ++ourLastConsoleNumber; final GeneralCommandLine cmd = createCommandLine(topLevelSdk); myConsoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole(); myProcessHandler = new OSProcessHandler(cmd.createProcess(), cmd.getCommandLineString()); myConsoleView.attachToProcess(myProcessHandler); ProcessTerminatedListener.attach(myProcessHandler); setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); final DefaultActionGroup group = new DefaultActionGroup(); group.add(getOCamlToolWindowOpenCloseAction(true, false)); group.addAll(myConsoleView.createConsoleActions()); group.add(getOCamlToolWindowSettingsAction()); group.add(getOCamlToolWindowOpenCloseAction(false, true)); final JComponent toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, false).getComponent(); toolbar.setMaximumSize(new Dimension(toolbar.getPreferredSize().width, Integer.MAX_VALUE)); add(toolbar); add(myConsoleView.getComponent()); myConsoleView.getComponent().requestFocus(); myProcessHandler.startNotify(); }
private void registerToolWindowIfNeeded() { if (myToolWindowWasRegistered || !toolWindowShouldBeRegistered()) return; final ToolWindow toolWindow = myToolWindowManager.registerToolWindow(TOOL_WINDOW_ID, true, ToolWindowAnchor.BOTTOM, false); toolWindow.setIcon(OCamlIconUtil.getSmallOCamlIcon()); toolWindow.setTitle(TOOL_WINDOW_ID); myToolWindowWasRegistered = true; final ContentManager contentManager = toolWindow.getContentManager(); contentManager.addContentManagerListener(new ContentManagerAdapter() { @Override public void contentRemoved(@NotNull final ContentManagerEvent event) { if (contentManager.getContentCount() == 0) { OCamlToolWindowUtil.addAndSelectStartContent(myProject, contentManager); } } }); OCamlToolWindowUtil.addAndSelectStartContent(myProject, contentManager); }
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); } } }); } }
public void actionPerformed(AnActionEvent e) { DataContext dataContext = e.getDataContext(); Project project = PlatformDataKeys.PROJECT.getData(dataContext); if (project == null) { return; } ToolWindowManager windowManager = ToolWindowManager.getInstance(project); if (windowManager.isEditorComponentActive()) { doNavigate(dataContext, project); return; } ContentManager contentManager = PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.getData(dataContext); if (contentManager == null) return; doNavigate(contentManager); }
public void update(AnActionEvent event){ Presentation presentation = event.getPresentation(); DataContext dataContext = event.getDataContext(); Project project = PlatformDataKeys.PROJECT.getData(dataContext); presentation.setEnabled(false); if (project == null) { return; } final ToolWindowManager windowManager = ToolWindowManager.getInstance(project); if (windowManager.isEditorComponentActive()) { final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project); EditorWindow currentWindow = EditorWindow.DATA_KEY.getData(dataContext); if (currentWindow == null){ editorManager.getCurrentWindow (); } if (currentWindow != null) { final VirtualFile[] files = currentWindow.getFiles(); presentation.setEnabled(files.length > 1); } return; } ContentManager contentManager = PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.getData(dataContext); presentation.setEnabled(contentManager != null && contentManager.getContentCount() > 1 && contentManager.isSingleSelection()); }
public void addMessageToConsoleWindow(final String message, final TextAttributes attributes) { if (!Registry.is("vcs.showConsole")) { return; } if (StringUtil.isEmptyOrSpaces(message)) { return; } ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { // for default and disposed projects the ContentManager is not available. if (myProject.isDisposed() || myProject.isDefault()) return; final ContentManager contentManager = getContentManager(); if (contentManager == null) { myPendingOutput.add(new Pair<String, TextAttributes>(message, attributes)); } else { getOrCreateConsoleContent(contentManager); myEditorAdapter.appendString(message, attributes); } } }, ModalityState.defaultModalityState()); }
public UpdateInfoTree showUpdateProjectInfo(UpdatedFiles updatedFiles, String displayActionName, ActionInfo actionInfo, boolean canceled) { if (! myProject.isOpen() || myProject.isDisposed()) return null; ContentManager contentManager = getContentManager(); if (contentManager == null) { return null; // content manager is made null during dispose; flag is set later } final UpdateInfoTree updateInfoTree = new UpdateInfoTree(contentManager, myProject, updatedFiles, displayActionName, actionInfo); Content content = ContentFactory.SERVICE.getInstance().createContent(updateInfoTree, canceled ? VcsBundle.message("toolwindow.title.update.action.canceled.info", displayActionName) : VcsBundle.message("toolwindow.title.update.action.info", displayActionName), true); Disposer.register(content, updateInfoTree); ContentsUtil.addContent(contentManager, content, true); ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.VCS).activate(null); updateInfoTree.expandRootChildren(); return updateInfoTree; }