Search in sources :

Example 61 with ToolWindow

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

the class AndroidToolWindowFactory method createLogcatContent.

private static Content createLogcatContent(RunnerLayoutUi layoutUi, final Project project, DeviceContext deviceContext) {
    final AndroidLogcatView logcatView = new AndroidLogcatView(project, deviceContext) {

        @Override
        protected boolean isActive() {
            ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID);
            return window.isVisible();
        }
    };
    ToolWindowManagerEx.getInstanceEx(project).addToolWindowManagerListener(new ToolWindowManagerAdapter() {

        boolean myToolWindowVisible;

        @Override
        public void stateChanged() {
            ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID);
            if (window != null) {
                boolean visible = window.isVisible();
                if (visible != myToolWindowVisible) {
                    myToolWindowVisible = visible;
                    logcatView.activate();
                    if (visible) {
                        ConsoleView console = logcatView.getLogConsole().getConsole();
                        if (console != null) {
                            checkFacetAndSdk(project, console);
                        }
                    }
                }
            }
        }
    });
    final MessageBusConnection connection = project.getMessageBus().connect(project);
    connection.subscribe(ProjectTopics.PROJECT_ROOTS, new MyAndroidPlatformListener(logcatView));
    JPanel logcatContentPanel = logcatView.getContentPanel();
    final Content logcatContent = layoutUi.createContent(ANDROID_LOGCAT_CONTENT_ID, logcatContentPanel, "logcat", AndroidIcons.Ddms.Logcat, null);
    logcatContent.putUserData(AndroidLogcatView.ANDROID_LOGCAT_VIEW_KEY, logcatView);
    logcatContent.setDisposer(logcatView);
    logcatContent.setCloseable(false);
    logcatContent.setPreferredFocusableComponent(logcatContentPanel);
    return logcatContent;
}
Also used : AndroidLogcatView(com.android.tools.idea.logcat.AndroidLogcatView) ToolWindow(com.intellij.openapi.wm.ToolWindow) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ConsoleView(com.intellij.execution.ui.ConsoleView) Content(com.intellij.ui.content.Content) ToolWindowManagerAdapter(com.intellij.openapi.wm.ex.ToolWindowManagerAdapter)

Example 62 with ToolWindow

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

the class AndroidUtils method activateConsoleToolWindow.

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);
                getApplication().invokeLater(() -> manager.unregisterToolWindow(toolWindowId));
            }
        }
    };
    toolWindow.show(() -> {
        runAfterActivation.run();
        ((ToolWindowManagerEx) manager).addToolWindowManagerListener(listener);
    });
}
Also used : ToolWindowManagerListener(com.intellij.openapi.wm.ex.ToolWindowManagerListener) ToolWindow(com.intellij.openapi.wm.ToolWindow) ConsoleView(com.intellij.execution.ui.ConsoleView) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) ContentImpl(com.intellij.ui.content.impl.ContentImpl) NotNull(org.jetbrains.annotations.NotNull) ConsoleViewImpl(com.intellij.execution.impl.ConsoleViewImpl) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 63 with ToolWindow

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

the class NlAbstractWindowManager method initToolWindow.

protected void initToolWindow(@NotNull final String id, @NotNull Icon icon) {
    myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(id, false, getAnchor(), myProject, true);
    myToolWindow.setIcon(icon);
    myToolWindow.setAvailable(false, null);
    myToolWindow.setAutoHide(false);
    myPreviousWindowType = myToolWindow.getType();
    myPreviousWindowAnchor = getEditorMode();
    ((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject)).addToolWindowManagerListener(new ToolWindowManagerAdapter() {

        @Override
        public void stateChanged() {
            if (myProject.isDisposed()) {
                return;
            }
            final ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(id);
            ToolWindowType newWindowType = window.getType();
            ToolWindowAnchor newWindowAnchor = getEditorMode();
            if (newWindowType != myPreviousWindowType || newWindowAnchor != myPreviousWindowAnchor) {
                // TODO: Report the window docking state
                NlUsageTrackerManager.getInstance(myDesignSurface).logAction(LayoutEditorEvent.LayoutEditorEventType.UNKNOWN_EVENT_TYPE);
                myPreviousWindowType = newWindowType;
                myPreviousWindowAnchor = newWindowAnchor;
            }
        }
    }, myProject);
    initGearActions();
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) LightToolWindow(com.intellij.designer.LightToolWindow) ToolWindowManagerAdapter(com.intellij.openapi.wm.ex.ToolWindowManagerAdapter) ToolWindowAnchor(com.intellij.openapi.wm.ToolWindowAnchor) ToolWindowType(com.intellij.openapi.wm.ToolWindowType) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 64 with ToolWindow

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

the class SliceManager method getContentManager.

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;
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) ContentManagerWatcher(com.intellij.ide.impl.ContentManagerWatcher)

Example 65 with ToolWindow

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

the class ProjectViewTestUtil method setupImpl.

public static void setupImpl(@NotNull Project project, boolean loadPaneExtensions) {
    ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(project);
    ToolWindow toolWindow = toolWindowManager.getToolWindow(ToolWindowId.PROJECT_VIEW);
    if (toolWindow == null) {
        ToolWindowEP[] beans = Extensions.getExtensions(ToolWindowEP.EP_NAME);
        for (final ToolWindowEP bean : beans) {
            if (bean.id.equals(ToolWindowId.PROJECT_VIEW)) {
                toolWindow = toolWindowManager.registerToolWindow(bean.id, new JLabel(), ToolWindowAnchor.fromText(bean.anchor), project, false, bean.canCloseContents);
                break;
            }
        }
    }
    ((ProjectViewImpl) ProjectView.getInstance(project)).setupImpl(toolWindow, loadPaneExtensions);
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) ToolWindowEP(com.intellij.openapi.wm.ToolWindowEP) ProjectViewImpl(com.intellij.ide.projectView.impl.ProjectViewImpl) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

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