public int addTab( String s, JComponent component, boolean selectTab, boolean replaceContent, boolean lockable, boolean addDefaultToolbar, ActionGroup toolbarActions, String helpId) { int existing = getComponentNumNamed(s); ContentManager contentManager = getContentManager(); if (existing != -1) { Content existingContent = contentManager.getContent(existing); if (!replaceContent) { contentManager.setSelectedContent(existingContent); return existing; } // if (!existingContent.isPinned()) { // getContentManager().removeContent(existingContent); // existingContent.release(); // } } CommitLogWindowComponent newComponent = new CommitLogWindowComponent( component, addDefaultToolbar, toolbarActions, contentManager, helpId); Content content = ContentFactory.SERVICE .getInstance() .createContent(newComponent.getShownComponent(), s, lockable); newComponent.setContent(content); contentManager.addContent(content); return getComponentAt(contentManager.getContentCount() - 1, selectTab); }
private void initialize() { if (myIsInitialized) { return; } myIsInitialized = true; myIsDisposed = false; myContentManager = ContentFactory.SERVICE.getInstance().createContentManager(true, myProject); myContentManager.addContentManagerListener( new ContentManagerAdapter() { public void contentRemoved(ContentManagerEvent event) { JComponent component = event.getContent().getComponent(); JComponent removedComponent = component instanceof CvsTabbedWindowComponent ? ((CvsTabbedWindowComponent) component).getComponent() : component; if (removedComponent == myErrorsView) { myErrorsView.dispose(); myErrorsView = null; } else if (myOutput != null && removedComponent == myOutput.getComponent()) { EditorFactory.getInstance().releaseEditor(myOutput); myOutput = null; } } }); ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject); ToolWindow toolWindow = toolWindowManager.registerToolWindow( ToolWindowId.CVS, myContentManager.getComponent(), ToolWindowAnchor.BOTTOM); toolWindow.setIcon(AllIcons.Providers.Cvs); toolWindow.installWatcher(myContentManager); }
private Content getOrCreateConsoleContent(final ContentManager contentManager) { final String displayName = VcsBundle.message("vcs.console.toolwindow.display.name"); Content content = contentManager.findContent(displayName); if (content == null) { releaseEditor(); final EditorFactory editorFactory = EditorFactory.getInstance(); final Editor editor = editorFactory.createViewer(editorFactory.createDocument(""), myProject); EditorSettings editorSettings = editor.getSettings(); editorSettings.setLineMarkerAreaShown(false); editorSettings.setIndentGuidesShown(false); editorSettings.setLineNumbersShown(false); editorSettings.setFoldingOutlineShown(false); ((EditorEx) editor).getScrollPane().setBorder(null); myEditorAdapter = new EditorAdapter(editor, myProject, false); final JPanel panel = new JPanel(new BorderLayout()); panel.add(editor.getComponent(), BorderLayout.CENTER); content = ContentFactory.SERVICE.getInstance().createContent(panel, displayName, true); contentManager.addContent(content); for (Pair<String, TextAttributes> pair : myPendingOutput) { myEditorAdapter.appendString(pair.first, pair.second); } myPendingOutput.clear(); } return content; }
private Content createTerminalInContentPanel( @NotNull AbstractTerminalRunner terminalRunner, final @NotNull ToolWindow toolWindow) { SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true); final Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false); content.setCloseable(true); myTerminalWidget = terminalRunner.createTerminalWidget(content); myTerminalWidget.addTabListener( new TabbedTerminalWidget.TabListener() { @Override public void tabClosed(JediTermWidget terminal) { UIUtil.invokeLaterIfNeeded( () -> { if (myTerminalWidget != null) { hideIfNoActiveSessions(toolWindow, myTerminalWidget); } }); } }); panel.setContent(myTerminalWidget.getComponent()); panel.addFocusListener(createFocusListener()); ActionToolbar toolbar = createToolbar(terminalRunner, myTerminalWidget, toolWindow); toolbar.getComponent().addFocusListener(createFocusListener()); toolbar.setTargetComponent(panel); panel.setToolbar(toolbar.getComponent()); content.setPreferredFocusableComponent(myTerminalWidget.getComponent()); return content; }
// Create the tool window content. public void createToolWindowContent(Project project, ToolWindow toolWindow) { this.toolWindow = toolWindow; this.quack(); ContentFactory contentFactory = ContentFactory.SERVICE.getInstance(); Content content = contentFactory.createContent(toolWindowContent, "", false); toolWindow.getContentManager().addContent(content); }
@Override 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; }
public void createToolWindowContent(@NotNull ToolWindow toolWindow) { // Create runner UI layout RunnerLayoutUi.Factory factory = RunnerLayoutUi.Factory.getInstance(myProject); RunnerLayoutUi layoutUi = factory.create("", "", "session", myProject); // Adding actions DefaultActionGroup group = new DefaultActionGroup(); layoutUi.getOptions().setLeftToolbar(group, ActionPlaces.UNKNOWN); Content console = layoutUi.createContent( GradleConsoleToolWindowFactory.ID, myConsoleView.getComponent(), "", null, null); AnAction[] consoleActions = myConsoleView.createConsoleActions(); for (AnAction action : consoleActions) { if (!shouldIgnoreAction(action)) { group.add(action); } } layoutUi.addContent(console, 0, PlaceInGrid.right, false); JComponent layoutComponent = layoutUi.getComponent(); myConsolePanel.add(layoutComponent, BorderLayout.CENTER); //noinspection ConstantConditions Content content = ContentFactory.SERVICE.getInstance().createContent(layoutComponent, null, true); toolWindow.getContentManager().addContent(content); }
@Override public void createToolWindowContent(Project project, ToolWindow toolWindow) { DiffManager.getInstance().registerDiffTool(new CommentsDiffTool()); final ContentManager contentManager = toolWindow.getContentManager(); final CruciblePanel cruciblePanel = new CruciblePanel(project); final Content content = ContentFactory.SERVICE .getInstance() .createContent(cruciblePanel, CrucibleBundle.message("crucible.main.name"), false); content.setCloseable(false); contentManager.addContent(content); }
private Content createNewContent( final ContentManager contentManager, final RunContentDescriptor descriptor, Executor executor) { final String processDisplayName = descriptor.getDisplayName(); final Content content = ContentFactory.SERVICE .getInstance() .createContent(descriptor.getComponent(), processDisplayName, true); content.putUserData(DESCRIPTOR_KEY, descriptor); content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE); contentManager.addContent(content); new CloseListener(content, executor); return content; }
// error tree view initialization must be invoked from event dispatch thread private void openMessageView() { if (isHeadlessMode()) { return; } if (myIndicator.isCanceled()) { return; } final JComponent component; synchronized (myMessageViewLock) { if (myErrorTreeView != null) { return; } myErrorTreeView = new CompilerErrorTreeView(myProject, myRestartWork); myErrorTreeView.setProcessController( new NewErrorTreeViewPanel.ProcessController() { @Override public void stopProcess() { cancel(); } @Override public boolean isProcessStopped() { return !myIndicator.isRunning(); } }); component = myErrorTreeView.getComponent(); } final MessageView messageView = MessageView.SERVICE.getInstance(myProject); final Content content = ContentFactory.SERVICE.getInstance().createContent(component, myContentName, true); CONTENT_ID_KEY.set(content, myContentId); SESSION_ID_KEY.set(content, mySessionId); messageView.getContentManager().addContent(content); myCloseListener.setContent(content, messageView.getContentManager()); removeAllContents(myProject, content); messageView.getContentManager().setSelectedContent(content); }
public int addTab( String s, JComponent component, boolean selectTab, boolean replaceContent, boolean lockable, boolean addDefaultToolbar, @Nullable final ActionGroup toolbarActions, @NonNls String helpId) { int existing = getComponentNumNamed(s); if (existing != -1) { Content existingContent = getContentManager().getContent(existing); final JComponent existingComponent = existingContent.getComponent(); if (existingComponent instanceof DeactivateListener) { ((DeactivateListener) existingComponent).deactivated(); } if (!replaceContent) { getContentManager().setSelectedContent(existingContent); return existing; } else if (!existingContent.isPinned()) { getContentManager().removeContent(existingContent, true); existingContent.release(); } } CvsTabbedWindowComponent newComponent = new CvsTabbedWindowComponent( component, addDefaultToolbar, toolbarActions, getContentManager(), helpId); Content content = ContentFactory.SERVICE .getInstance() .createContent(newComponent.getShownComponent(), s, lockable); newComponent.setContent(content); getContentManager().addContent(content); return getComponentAt(getContentManager().getContentCount() - 1, selectTab); }
public void initToolWindow(ToolWindow toolWindow) { // Create panels Content allTodosContent = ContentFactory.SERVICE .getInstance() .createContent(null, IdeBundle.message("title.project"), false); myAllTodos = new TodoPanel(myProject, myAllPanelSettings, false, allTodosContent) { protected TodoTreeBuilder createTreeBuilder( JTree tree, DefaultTreeModel treeModel, Project project) { AllTodosTreeBuilder builder = new AllTodosTreeBuilder(tree, treeModel, project); builder.init(); return builder; } }; allTodosContent.setComponent(myAllTodos); Disposer.register(this, myAllTodos); Content currentFileTodosContent = ContentFactory.SERVICE .getInstance() .createContent(null, IdeBundle.message("title.todo.current.file"), false); myCurrentFileTodos = new CurrentFileTodosPanel(myProject, myCurrentPanelSettings, currentFileTodosContent) { protected TodoTreeBuilder createTreeBuilder( JTree tree, DefaultTreeModel treeModel, Project project) { CurrentFileTodosTreeBuilder builder = new CurrentFileTodosTreeBuilder(tree, treeModel, project); builder.init(); return builder; } }; Disposer.register(this, myCurrentFileTodos); currentFileTodosContent.setComponent(myCurrentFileTodos); myChangeListTodosContent = ContentFactory.SERVICE .getInstance() .createContent( null, IdeBundle.message( "changelist.todo.title", ChangeListManager.getInstance(myProject).getDefaultChangeList().getName()), false); myChangeListTodos = new ChangeListTodosPanel(myProject, myCurrentPanelSettings, myChangeListTodosContent) { protected TodoTreeBuilder createTreeBuilder( JTree tree, DefaultTreeModel treeModel, Project project) { ChangeListTodosTreeBuilder builder = new ChangeListTodosTreeBuilder(tree, treeModel, project); builder.init(); return builder; } }; Disposer.register(this, myChangeListTodos); myChangeListTodosContent.setComponent(myChangeListTodos); myContentManager = toolWindow.getContentManager(); myContentManager.addContent(allTodosContent); myContentManager.addContent(currentFileTodosContent); if (myVCSManager.getAllActiveVcss().length > 0) { myVcsListener.myIsVisible = true; myContentManager.addContent(myChangeListTodosContent); } Content content = myContentManager.getContent(mySelectedIndex); content = content == null ? allTodosContent : content; myContentManager.setSelectedContent(content); }
private void createToolWindowContent(ToolWindow toolWindow) { ContentFactory contentFactory = ContentFactory.SERVICE.getInstance(); Content content = contentFactory.createContent(toolWindowContent, "", false); toolWindow.getContentManager().addContent(content); }
/** @return can be null if user cancelled operation */ @Nullable public static AntBuildMessageView openBuildMessageView( Project project, AntBuildFileBase buildFile, String[] targets) { final VirtualFile antFile = buildFile.getVirtualFile(); if (!LOG.assertTrue(antFile != null)) { return null; } // check if there are running instances of the same build file MessageView ijMessageView = MessageView.SERVICE.getInstance(project); Content[] contents = ijMessageView.getContentManager().getContents(); for (Content content : contents) { if (content.isPinned()) { continue; } AntBuildMessageView buildMessageView = content.getUserData(KEY); if (buildMessageView == null) { continue; } if (!antFile.equals(buildMessageView.getBuildFile().getVirtualFile())) { continue; } if (buildMessageView.isStopped()) { ijMessageView.getContentManager().removeContent(content, true); continue; } int result = Messages.showYesNoCancelDialog( AntBundle.message("ant.is.active.terminate.confirmation.text"), AntBundle.message("starting.ant.build.dialog.title"), Messages.getQuestionIcon()); switch (result) { case 0: // yes buildMessageView.stopProcess(); ijMessageView.getContentManager().removeContent(content, true); continue; case 1: // no continue; default: // cancel return null; } } final AntBuildMessageView messageView = new AntBuildMessageView(project, buildFile, targets); String contentName = buildFile.getPresentableName(); contentName = BUILD_CONTENT_NAME + " (" + contentName + ")"; final Content content = ContentFactory.SERVICE .getInstance() .createContent(messageView.getComponent(), contentName, true); content.putUserData(KEY, messageView); ijMessageView.getContentManager().addContent(content); ijMessageView.getContentManager().setSelectedContent(content); content.setDisposer( new Disposable() { @Override public void dispose() { Disposer.dispose(messageView.myAlarm); } }); new CloseListener(content, ijMessageView.getContentManager(), project); // Do not inline next two variabled. Seeking for NPE. ToolWindow messageToolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW); messageToolWindow.activate(null, false); return messageView; }
@Override public void createToolWindowContent(Project project, ToolWindow toolWindow) { HelpArea helpArea = project.getComponent(MyProjectComponent.class).getHelpArea(); Content content = ContentFactory.SERVICE.getInstance().createContent(helpArea, "", false); toolWindow.getContentManager().addContent(content); }