private Content createCurrentErrorContent(final ToolWindow toolWindow) { final Ref<Content> contentRef = new Ref<>(); myCurrentErrorTreeViewPanel = new JSGraphQLErrorTreeViewPanel(myProject, myHelpId, () -> myLastResult = null, myActions) { public void close() { toolWindow.hide(() -> { myLastResult = null; final Content contentImpl = contentRef.get(); if (contentImpl != null) { toolWindow.getContentManager().removeContent(contentImpl, true); } Content newContentImpl = createCurrentErrorContent(toolWindow); toolWindow.getContentManager().setSelectedContent(newContentImpl); }); } }; Disposer.register(myProject, myCurrentErrorTreeViewPanel); contentRef.set(new ContentImpl(myCurrentErrorTreeViewPanel, "Current Errors", false)); toolWindow.getContentManager().addContent(contentRef.get(), 0); return contentRef.get(); }
private void createAllErrorsPanel() { ApplicationManager.getApplication().assertIsDispatchThread(); if (myProjectErrorTreeViewPanel == null) { final Ref<Content> contentRef = new Ref<>(); myProjectErrorTreeViewPanel = new JSGraphQLErrorTreeViewPanel(myProject, myHelpId, null, myActions) { public void close() { final NewErrorTreeViewPanel oldPanel = myProjectErrorTreeViewPanel; myProjectErrorTreeViewPanel = null; myToolWindow.hide(() -> { Content content = contentRef.get(); if (content != null) { myToolWindow.getContentManager().removeContent(content, true); } if (oldPanel != null) { Disposer.dispose(oldPanel); } }); } }; Disposer.register(myProject, myProjectErrorTreeViewPanel); contentRef.set(new ContentImpl(myProjectErrorTreeViewPanel, "Project Errors", false)); myToolWindow.getContentManager().addContent(contentRef.get()); } }
private Content createConsoleContent(final ConsoleView console, final String title, final String description) { final Content content = new ContentImpl(createConsolePanel(console), description, true); content.setTabName(title); content.setDisplayName(title); content.setIcon(HybrisIcons.HYBRIS_ICON); return content; }
private static void activateConsoleToolWindow(@NotNull Project project) { final ToolWindowManager manager = ToolWindowManager.getInstance(project); ToolWindow toolWindow = manager.getToolWindow(toolWindowId); if (toolWindow != null) { return; } toolWindow = manager.registerToolWindow(toolWindowId, true, ToolWindowAnchor.BOTTOM); final ConsoleView console = new ConsoleViewImpl(project, false); project.putUserData(CONSOLE_VIEW_KEY, console); toolWindow.getContentManager().addContent(new ContentImpl(console.getComponent(), "", false)); final ToolWindowManagerListener listener = new ToolWindowManagerListener() { @Override public void toolWindowRegistered(@NotNull String id) { } @Override public void stateChanged() { ToolWindow window = manager.getToolWindow(toolWindowId); if (window != null && !window.isVisible()) { manager.unregisterToolWindow(toolWindowId); ((ToolWindowManagerEx) manager).removeToolWindowManagerListener(this); } } }; toolWindow.show(new Runnable() { @Override public void run() { ((ToolWindowManagerEx) manager).addToolWindowManagerListener(listener); } }); }
public IdeaMantisConfigurable(@NotNull Project project) { this.settings = ConnectionSettings.getInstance(project); this.manager = ToolWindowManager.getInstance(project); this.task = new Task.Backgroundable(project, "Load Data...") { @Override public void run(@NotNull ProgressIndicator progressIndicator) { try { settings.setHostName(txtHostName.getText()); settings.setUserName(txtUserName.getText()); StringBuilder buf = new StringBuilder(); for(char ch : txtPassword.getPassword()) { buf.append(ch); } settings.setPassword(buf.toString()); int itemsPerPage; try { itemsPerPage = Integer.parseInt(txtIssuesPerPage.getText()); } catch (Exception ex) { itemsPerPage = -1; } settings.setItemsPerPage(itemsPerPage); settings.setProjectID(projectID); ApplicationManager.getApplication().invokeLater(()->{ ToolWindow window = manager.getToolWindow("Show MantisBT-Issues"); ContentImpl content = new ContentImpl(null, "", true); content.setDescription("reload comboBoxes"); window.getContentManager().addContent(content); }); settings.setFastTrack(chkFastTrackEnabled.isSelected()); } catch (Exception ex) { Helper.printException(ex); } finally { component.setCursor(Cursor.getDefaultCursor()); } } }; }
@Override public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) { toolWindow.setTitle(myExternalSystemId.getReadableName()); ContentManager contentManager = toolWindow.getContentManager(); final ExternalProjectsViewImpl projectsView = new ExternalProjectsViewImpl(project, (ToolWindowEx)toolWindow, myExternalSystemId); ExternalProjectsManager.getInstance(project).registerView(projectsView); ContentImpl tasksContent = new ContentImpl(projectsView, ExternalSystemBundle.message("tool.window.title.projects"), true); contentManager.addContent(tasksContent); }
public synchronized void connectToProcessHandler(ProcessHandler handler) { init(); if (myCurrentErrorTreeViewPanel != null) { myCurrentErrorTreeViewPanel.getErrorViewStructure().clear(); } ApplicationManager.getApplication().assertIsDispatchThread(); if (myToolWindow != null) { myConsoleView = new ConsoleViewImpl(myProject, GlobalSearchScope.allScope(myProject), true, false) { }; myConsoleView.attachToProcess(handler); myConsoleContent = new ContentImpl(myConsoleView.getComponent(), "Console", false); myToolWindow.getContentManager().addContent(myConsoleContent); } }
private static void processConsole(Project project, ProcessHandler processHandler) { ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole(); consoleView.clear(); consoleView.attachToProcess(processHandler); processHandler.startNotify(); ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); ToolWindow toolWindow; toolWindow = toolWindowManager.getToolWindow(TOOL_ID); // if already exist tool window then show it if (toolWindow != null) { toolWindow.show(null);// TODO add more tabs here? return; } toolWindow = toolWindowManager.registerToolWindow(TOOL_ID, true, ToolWindowAnchor.BOTTOM); toolWindow.setTitle("Android...."); toolWindow.setStripeTitle("Android Console"); toolWindow.setShowStripeButton(true); toolWindow.setIcon(PluginIcons.ICON_TOOL_WINDOW); JPanel panel = new JPanel((LayoutManager) new BorderLayout()); panel.add((Component) consoleView.getComponent(), "Center"); // Create toolbars DefaultActionGroup toolbarActions = new DefaultActionGroup(); AnAction[] consoleActions = consoleView.createConsoleActions();// 必须在 consoleView.getComponent() 调用后组件真正初始化之后调用 toolbarActions.addAll((AnAction[]) Arrays.copyOf(consoleActions, consoleActions.length)); toolbarActions.add((AnAction) new StopProcessAction("Stop process", "Stop process", processHandler)); // toolbarActions.add((AnAction) new CloseAction(defaultExecutor, runDescriptor, project)); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("unknown", (ActionGroup) toolbarActions, false); toolbar.setTargetComponent(consoleView.getComponent()); panel.add((Component) toolbar.getComponent(), "West"); ContentImpl consoleContent = new ContentImpl(panel, "Build", false); consoleContent.setManager(toolWindow.getContentManager()); toolbarActions.add(new CloseTabAction(consoleContent)); // addAdditionalConsoleEditorActions(consoleView, consoleContent); // consoleComponent.setActions(); toolWindow.getContentManager().addContent(consoleContent); toolWindow.getContentManager().addContent(new ContentImpl(new JButton("Test"), "Build2", false)); toolWindow.show(null); }
@NotNull @Override public ContentImpl createContent(JComponent component, String displayName, boolean isLockable) { return new ContentImpl(component, displayName, isLockable); }
/** * @param component component to add to window */ void add(@NotNull final JComponent component) { myContentManager.addContent(new ContentImpl(component, "", true)); }
public static void activateConsoleToolWindow(@NotNull Project project, @NotNull final Runnable runAfterActivation) { final ToolWindowManager manager = ToolWindowManager.getInstance(project); final String toolWindowId = AndroidBundle.message("android.console.tool.window.title"); ToolWindow toolWindow = manager.getToolWindow(toolWindowId); if (toolWindow != null) { runAfterActivation.run(); return; } toolWindow = manager.registerToolWindow(toolWindowId, true, ToolWindowAnchor.BOTTOM); final ConsoleView console = new ConsoleViewImpl(project, false); project.putUserData(CONSOLE_VIEW_KEY, console); toolWindow.getContentManager().addContent(new ContentImpl(console.getComponent(), "", false)); final ToolWindowManagerListener listener = new ToolWindowManagerListener() { @Override public void toolWindowRegistered(@NotNull String id) { } @Override public void stateChanged() { ToolWindow window = manager.getToolWindow(toolWindowId); if (window != null && !window.isVisible()) { ((ToolWindowManagerEx)manager).removeToolWindowManagerListener(this); ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { manager.unregisterToolWindow(toolWindowId); } }); } } }; toolWindow.show(new Runnable() { @Override public void run() { runAfterActivation.run(); ((ToolWindowManagerEx)manager).addToolWindowManagerListener(listener); } }); }
private void createToolWindowResultEditor(ToolWindow toolWindow) { final LightVirtualFile virtualFile = new LightVirtualFile("GraphQL.result.json", JsonFileType.INSTANCE, ""); fileEditor = PsiAwareTextEditorProvider.getInstance().createEditor(myProject, virtualFile); if(fileEditor instanceof TextEditor) { final Editor editor = ((TextEditor) fileEditor).getEditor(); final EditorEx editorEx = (EditorEx)editor; // set read-only mode editorEx.setViewer(true); editorEx.getSettings().setShowIntentionBulb(false); editor.getSettings().setAdditionalLinesCount(0); editor.getSettings().setCaretRowShown(false); editor.getSettings().setBlinkCaret(false); // query result header final JSGraphQLEditorHeaderComponent header = new JSGraphQLEditorHeaderComponent(); querySuccessLabel = new JBLabel(); querySuccessLabel.setVisible(false); querySuccessLabel.setIconTextGap(0); header.add(querySuccessLabel, BorderLayout.WEST); queryResultLabel = new JBLabel("", null, SwingConstants.LEFT); queryResultLabel.setBorder(new EmptyBorder(4, 6, 4, 6)); queryResultLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); queryResultLabel.setVisible(false); queryResultLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { final String fileUrl = (String)queryResultLabel.getClientProperty(FILE_URL_PROPERTY); if(fileUrl != null) { final VirtualFile queryFile = VirtualFileManager.getInstance().findFileByUrl(fileUrl); if(queryFile != null) { final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject); fileEditorManager.openFile(queryFile, true, true); } } } }); header.add(queryResultLabel, BorderLayout.CENTER); // finally set the header as permanent such that it's restored after searches editor.setHeaderComponent(header); editorEx.setPermanentHeaderComponent(header); } Disposer.register(this, fileEditor); final ContentImpl content = new ContentImpl(fileEditor.getComponent(), "Query result", true); content.setCloseable(false); toolWindow.getContentManager().addContent(content); }
@Nonnull @Override public ContentImpl createContent(javax.swing.JComponent component, String displayName, boolean isLockable) { return new ContentImpl(component, displayName, isLockable); }