Search in sources :

Example 1 with SimpleToolWindowPanel

use of com.intellij.openapi.ui.SimpleToolWindowPanel in project intellij-community by JetBrains.

the class PythonConsoleToolWindow method setContent.

private static void setContent(ToolWindow toolWindow, RunContentDescriptor contentDescriptor) {
    toolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true");
    Content content = toolWindow.getContentManager().findContent(contentDescriptor.getDisplayName());
    if (content == null) {
        content = createContent(contentDescriptor);
        toolWindow.getContentManager().addContent(content);
    } else {
        SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);
        resetContent(contentDescriptor, panel, content);
    }
    toolWindow.getContentManager().setSelectedContent(content);
}
Also used : Content(com.intellij.ui.content.Content) SimpleToolWindowPanel(com.intellij.openapi.ui.SimpleToolWindowPanel)

Example 2 with SimpleToolWindowPanel

use of com.intellij.openapi.ui.SimpleToolWindowPanel in project intellij-community by JetBrains.

the class EventLogToolWindowFactory method createContent.

static void createContent(Project project, ToolWindow toolWindow, EventLogConsole console, String title) {
    // update default Event Log tab title
    ContentManager contentManager = toolWindow.getContentManager();
    Content generalContent = contentManager.getContent(0);
    if (generalContent != null && contentManager.getContentCount() == 1) {
        generalContent.setDisplayName("General");
    }
    final Editor editor = console.getConsoleEditor();
    JPanel editorPanel = new JPanel(new AbstractLayoutManager() {

        private int getOffset() {
            return JBUI.scale(4);
        }

        @Override
        public Dimension preferredLayoutSize(Container parent) {
            Dimension size = parent.getComponent(0).getPreferredSize();
            return new Dimension(size.width + getOffset(), size.height);
        }

        @Override
        public void layoutContainer(Container parent) {
            int offset = getOffset();
            parent.getComponent(0).setBounds(offset, 0, parent.getWidth() - offset, parent.getHeight());
        }
    }) {

        @Override
        public Color getBackground() {
            return ((EditorEx) editor).getBackgroundColor();
        }
    };
    editorPanel.add(editor.getComponent());
    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true) {

        @Override
        public Object getData(@NonNls String dataId) {
            return PlatformDataKeys.HELP_ID.is(dataId) ? EventLog.HELP_ID : super.getData(dataId);
        }
    };
    panel.setContent(editorPanel);
    panel.addAncestorListener(new LogShownTracker(project));
    ActionToolbar toolbar = createToolbar(project, editor, console);
    toolbar.setTargetComponent(editor.getContentComponent());
    panel.setToolbar(toolbar.getComponent());
    Content content = ContentFactory.SERVICE.getInstance().createContent(panel, title, false);
    contentManager.addContent(content);
    contentManager.setSelectedContent(content);
}
Also used : NonNls(org.jetbrains.annotations.NonNls) EditorEx(com.intellij.openapi.editor.ex.EditorEx) ContentManager(com.intellij.ui.content.ContentManager) AbstractLayoutManager(com.intellij.util.ui.AbstractLayoutManager) SimpleToolWindowPanel(com.intellij.openapi.ui.SimpleToolWindowPanel) Content(com.intellij.ui.content.Content) Editor(com.intellij.openapi.editor.Editor)

Example 3 with SimpleToolWindowPanel

use of com.intellij.openapi.ui.SimpleToolWindowPanel in project intellij-plugins by JetBrains.

the class ActionScriptProfileRunner method startProfiling.

private static void startProfiling(final String runConfigurationName, final Module module) {
    if (!initProfilingAgent(module)) {
        return;
    }
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(module.getProject());
    if (toolWindowManager == null) {
        return;
    }
    ApplicationManager.getApplication().invokeLater(new Runnable() {

        @Override
        public void run() {
            ToolWindow toolWindow = toolWindowManager.getToolWindow(TOOLWINDOW_ID);
            if (toolWindow == null) {
                toolWindow = toolWindowManager.registerToolWindow(TOOLWINDOW_ID, true, ToolWindowAnchor.BOTTOM, module.getProject());
                final ContentManager contentManager = toolWindow.getContentManager();
                contentManager.addContentManagerListener(new ContentManagerAdapter() {

                    @Override
                    public void contentRemoved(ContentManagerEvent event) {
                        super.contentRemoved(event);
                        if (contentManager.getContentCount() == 0) {
                            toolWindowManager.unregisterToolWindow(TOOLWINDOW_ID);
                        }
                    }
                });
            }
            final ActionScriptProfileControlPanel profileControlPanel = new ActionScriptProfileControlPanel(runConfigurationName, module);
            final SimpleToolWindowPanel toolWindowPanel = new SimpleToolWindowPanel(false, true);
            toolWindowPanel.setContent(profileControlPanel.getMainPanel());
            final Content content = ContentFactory.SERVICE.getInstance().createContent(toolWindowPanel, runConfigurationName, false);
            toolWindow.getContentManager().addContent(content);
            toolWindow.getContentManager().setSelectedContent(content);
            content.setDisposer(profileControlPanel);
            final DefaultActionGroup actionGroup = profileControlPanel.createProfilerActionGroup();
            actionGroup.addSeparator();
            final AnAction closeTabAction = new TabbedContentAction.CloseAction(content);
            closeTabAction.getTemplatePresentation().setIcon(AllIcons.Actions.Cancel);
            actionGroup.add(closeTabAction);
            ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("FlexProfiler", actionGroup, false);
            toolbar.setTargetComponent(toolWindowPanel);
            toolWindowPanel.setToolbar(toolbar.getComponent());
            final ToolWindow finalToolWindow = toolWindow;
            profileControlPanel.setConnectionCallback(() -> {
                finalToolWindow.show(null);
                removePreloadingOfProfilerSwf();
            });
            toolWindow.hide(null);
            profileControlPanel.startProfiling();
        }
    });
}
Also used : TabbedContentAction(com.intellij.ui.content.tabs.TabbedContentAction) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) SimpleToolWindowPanel(com.intellij.openapi.ui.SimpleToolWindowPanel) ToolWindow(com.intellij.openapi.wm.ToolWindow) ActionScriptProfileControlPanel(com.jetbrains.actionscript.profiler.ui.ActionScriptProfileControlPanel)

Example 4 with SimpleToolWindowPanel

use of com.intellij.openapi.ui.SimpleToolWindowPanel in project intellij-plugins by JetBrains.

the class DartPubActionBase method showPubOutputConsole.

private static void showPubOutputConsole(@NotNull final Module module, @NotNull final GeneralCommandLine command, @NotNull final OSProcessHandler processHandler, @NotNull final VirtualFile pubspecYamlFile, @NotNull final String actionTitle) {
    final ConsoleView console;
    PubToolWindowContentInfo info = findExistingInfoForCommand(module.getProject(), command);
    if (info != null) {
        // rerunning the same pub command in the same tool window tab (corresponding tool window action invoked)
        console = info.console;
        console.clear();
    } else {
        console = createConsole(module.getProject(), pubspecYamlFile);
        info = new PubToolWindowContentInfo(module, pubspecYamlFile, command, actionTitle, console);
        final ActionToolbar actionToolbar = createToolWindowActionsBar(info);
        final SimpleToolWindowPanel toolWindowPanel = new SimpleToolWindowPanel(false, true);
        toolWindowPanel.setContent(console.getComponent());
        toolWindowPanel.setToolbar(actionToolbar.getComponent());
        final Content content = ContentFactory.SERVICE.getInstance().createContent(toolWindowPanel.getComponent(), actionTitle, true);
        content.putUserData(PUB_TOOL_WINDOW_CONTENT_INFO_KEY, info);
        Disposer.register(content, console);
        final ContentManager contentManager = MessageView.SERVICE.getInstance(module.getProject()).getContentManager();
        removeOldTabs(contentManager);
        contentManager.addContent(content);
        contentManager.setSelectedContent(content);
        final ToolWindow toolWindow = ToolWindowManager.getInstance(module.getProject()).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
        toolWindow.activate(null, true);
    }
    info.rerunPubCommandAction.setProcessHandler(processHandler);
    info.stopProcessAction.setProcessHandler(processHandler);
    processHandler.addProcessListener(new ProcessAdapter() {

        @Override
        public void processTerminated(final ProcessEvent event) {
            console.print(IdeBundle.message("finished.with.exit.code.text.message", event.getExitCode()), ConsoleViewContentType.SYSTEM_OUTPUT);
        }
    });
    console.print(DartBundle.message("working.dir.0", FileUtil.toSystemDependentName(pubspecYamlFile.getParent().getPath())) + "\n", ConsoleViewContentType.SYSTEM_OUTPUT);
    console.attachToProcess(processHandler);
    processHandler.startNotify();
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ConsoleView(com.intellij.execution.ui.ConsoleView) ProcessEvent(com.intellij.execution.process.ProcessEvent) Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager) SimpleToolWindowPanel(com.intellij.openapi.ui.SimpleToolWindowPanel)

Example 5 with SimpleToolWindowPanel

use of com.intellij.openapi.ui.SimpleToolWindowPanel in project flutter-intellij by flutter.

the class ObservatoryActionGroup method addInspector.

private void addInspector(FlutterApp app, @Nullable InspectorService inspectorService, ToolWindow toolWindow) {
    final ContentManager contentManager = toolWindow.getContentManager();
    final SimpleToolWindowPanel toolWindowPanel = new SimpleToolWindowPanel(true);
    final JBRunnerTabs runnerTabs = new JBRunnerTabs(myProject, ActionManager.getInstance(), null, this);
    final List<FlutterDevice> existingDevices = new ArrayList<>();
    for (FlutterApp otherApp : perAppViewState.keySet()) {
        existingDevices.add(otherApp.device());
    }
    final JPanel tabContainer = new JPanel(new BorderLayout());
    final Content content = contentManager.getFactory().createContent(null, app.device().getUniqueName(existingDevices), false);
    tabContainer.add(runnerTabs.getComponent(), BorderLayout.CENTER);
    content.setComponent(tabContainer);
    content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE);
    content.setIcon(FlutterIcons.Phone);
    contentManager.addContent(content);
    final PerAppState state = getOrCreateStateForApp(app);
    assert (state.content == null);
    state.content = content;
    final DefaultActionGroup toolbarGroup = createToolbar(toolWindow, app, runnerTabs);
    toolWindowPanel.setToolbar(ActionManager.getInstance().createActionToolbar("FlutterViewToolbar", toolbarGroup, true).getComponent());
    // If the inspector is available (non-profile mode), then show it.
    if (inspectorService != null) {
        addInspectorPanel("Widgets", runnerTabs, state, InspectorService.FlutterTreeType.widget, app, inspectorService, toolWindow, toolbarGroup, true);
        addInspectorPanel("Render Tree", runnerTabs, state, InspectorService.FlutterTreeType.renderObject, app, inspectorService, toolWindow, toolbarGroup, false);
    } else {
        toolbarGroup.add(new OverflowAction(this, app));
        final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("InspectorToolbar", toolbarGroup, true);
        final JComponent toolbarComponent = toolbar.getComponent();
        toolbarComponent.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
        tabContainer.add(toolbarComponent, BorderLayout.NORTH);
        // Add a message about the inspector not being available in profile mode.
        final JBLabel label = new JBLabel("Widget info not available in profile mode", SwingConstants.CENTER);
        label.setForeground(UIUtil.getLabelDisabledForeground());
        tabContainer.add(label, BorderLayout.CENTER);
    }
    final boolean isVertical = !toolWindow.getAnchor().isHorizontal();
    if (isVertical) {
        final JPanel dashboardsPanel = new JPanel(new BorderLayout());
        tabContainer.add(dashboardsPanel, BorderLayout.SOUTH);
        if (FlutterSettings.getInstance().isShowHeapDisplay()) {
            dashboardsPanel.add(FPSDisplay.createJPanelView(runnerTabs, app), BorderLayout.NORTH);
            dashboardsPanel.add(HeapDisplay.createJPanelView(runnerTabs, app), BorderLayout.SOUTH);
        }
    }
}
Also used : FlutterApp(io.flutter.run.daemon.FlutterApp) ContentManager(com.intellij.ui.content.ContentManager) SimpleToolWindowPanel(com.intellij.openapi.ui.SimpleToolWindowPanel) FlutterDevice(io.flutter.run.daemon.FlutterDevice) JBRunnerTabs(com.intellij.execution.ui.layout.impl.JBRunnerTabs) JBLabel(com.intellij.ui.components.JBLabel) Content(com.intellij.ui.content.Content)

Aggregations

SimpleToolWindowPanel (com.intellij.openapi.ui.SimpleToolWindowPanel)12 Content (com.intellij.ui.content.Content)8 ToolWindow (com.intellij.openapi.wm.ToolWindow)3 ContentManager (com.intellij.ui.content.ContentManager)3 TextConsoleBuilder (com.intellij.execution.filters.TextConsoleBuilder)2 ConsoleView (com.intellij.execution.ui.ConsoleView)2 ActionToolbar (com.intellij.openapi.actionSystem.ActionToolbar)2 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 JBRunnerTabs (com.intellij.execution.ui.layout.impl.JBRunnerTabs)1 TreeExpander (com.intellij.ide.TreeExpander)1 ContextHelpAction (com.intellij.ide.actions.ContextHelpAction)1 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)1 Editor (com.intellij.openapi.editor.Editor)1 EditorEx (com.intellij.openapi.editor.ex.EditorEx)1 IgnoredSettingsAction (com.intellij.openapi.vcs.changes.actions.IgnoredSettingsAction)1 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)1 JBLabel (com.intellij.ui.components.JBLabel)1 TabbedContentAction (com.intellij.ui.content.tabs.TabbedContentAction)1 AbstractLayoutManager (com.intellij.util.ui.AbstractLayoutManager)1