Search in sources :

Example 51 with ToolWindow

use of com.intellij.openapi.wm.ToolWindow 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 52 with ToolWindow

use of com.intellij.openapi.wm.ToolWindow in project intellij-plugins by JetBrains.

the class BaseToolWindow method expandToolWindow.

public void expandToolWindow() {
    final Semaphore semaphore = new Semaphore(1);
    semaphore.tryAcquire();
    UIUtil.invokeLater(() -> {
        ToolWindow window = myToolWindowManager.getToolWindow(getToolWindowId());
        if (window != null) {
            window.show(() -> semaphore.release());
        } else {
            semaphore.release();
        }
    });
    waitForOpen(semaphore);
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) Semaphore(java.util.concurrent.Semaphore)

Example 53 with ToolWindow

use of com.intellij.openapi.wm.ToolWindow in project android by JetBrains.

the class EditorFixture method getThemePreview.

/**
   * Returns a fixture around the theme preview window, <b>if</b> the currently edited file
   * is a styles file and if the XML editor tab of the layout is currently showing.
   *
   * @param switchToTabIfNecessary if true, switch to the editor tab if it is not already showing
   * @return the theme preview fixture
   */
@Nullable
public ThemePreviewFixture getThemePreview(boolean switchToTabIfNecessary) {
    VirtualFile currentFile = getCurrentFile();
    if (ResourceHelper.getFolderType(currentFile) != ResourceFolderType.VALUES) {
        return null;
    }
    if (switchToTabIfNecessary) {
        selectEditorTab(Tab.EDITOR);
    }
    boolean visible = GuiQuery.getNonNull(() -> ToolWindowManager.getInstance(myFrame.getProject()).getToolWindow("Theme Preview").isActive());
    if (!visible) {
        myFrame.invokeMenuPath("View", "Tool Windows", "Theme Preview");
    }
    Wait.seconds(1).expecting("Theme Preview window to be visible").until(() -> GuiQuery.getNonNull(() -> {
        ToolWindow window = ToolWindowManager.getInstance(myFrame.getProject()).getToolWindow("Theme Preview");
        return window != null && window.isVisible();
    }));
    // Wait for it to be fully opened
    robot.waitForIdle();
    return new ThemePreviewFixture(robot, myFrame.getProject());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ToolWindow(com.intellij.openapi.wm.ToolWindow) ThemePreviewFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemePreviewFixture) Nullable(org.jetbrains.annotations.Nullable)

Example 54 with ToolWindow

use of com.intellij.openapi.wm.ToolWindow 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 55 with ToolWindow

use of com.intellij.openapi.wm.ToolWindow in project android by JetBrains.

the class AndroidDebuggerImplBase method activateDebugSessionWindow.

protected static boolean activateDebugSessionWindow(@NotNull Project project, @NotNull RunContentDescriptor descriptor) {
    final ProcessHandler processHandler = descriptor.getProcessHandler();
    final Content content = descriptor.getAttachedContent();
    if (processHandler == null || content == null) {
        return false;
    }
    final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();
    if (processHandler.isProcessTerminated()) {
        ExecutionManager.getInstance(project).getContentManager().removeRunContent(executor, descriptor);
        return false;
    }
    content.getManager().setSelectedContent(content);
    ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(executor.getToolWindowId());
    window.activate(null, false, true);
    return true;
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) Executor(com.intellij.execution.Executor) Content(com.intellij.ui.content.Content) ProcessHandler(com.intellij.execution.process.ProcessHandler)

Aggregations

ToolWindow (com.intellij.openapi.wm.ToolWindow)124 Content (com.intellij.ui.content.Content)37 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)34 Project (com.intellij.openapi.project.Project)21 ContentManager (com.intellij.ui.content.ContentManager)14 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)13 Nullable (org.jetbrains.annotations.Nullable)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 ConsoleView (com.intellij.execution.ui.ConsoleView)5 ToolWindowManagerAdapter (com.intellij.openapi.wm.ex.ToolWindowManagerAdapter)5 NotNull (org.jetbrains.annotations.NotNull)5 RunContentManager (com.intellij.execution.ui.RunContentManager)4 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)3 ProcessEvent (com.intellij.execution.process.ProcessEvent)3 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)3 ProjectView (com.intellij.ide.projectView.ProjectView)3 Presentation (com.intellij.openapi.actionSystem.Presentation)3 DumbAwareRunnable (com.intellij.openapi.project.DumbAwareRunnable)3 ChangesViewContentManager (com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager)3 ToolWindowEP (com.intellij.openapi.wm.ToolWindowEP)3