Search in sources :

Example 21 with ToolWindowManagerEx

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

the class NlPreviewManager method initToolWindow.

protected void initToolWindow() {
    myToolWindowForm = new NlPreviewForm(this);
    final String toolWindowId = getToolWindowId();
    myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(toolWindowId, false, ToolWindowAnchor.RIGHT, myProject, true);
    myToolWindow.setIcon(AndroidIcons.AndroidPreview);
    ((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject)).addToolWindowManagerListener(new ToolWindowManagerAdapter() {

        @Override
        public void stateChanged() {
            if (myProject.isDisposed()) {
                return;
            }
            final ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(toolWindowId);
            if (window != null && window.isAvailable()) {
                final boolean visible = window.isVisible();
                AndroidEditorSettings.getInstance().getGlobalState().setVisible(visible);
                if (myToolWindowForm != null) {
                    if (visible) {
                        myToolWindowForm.activate();
                    } else {
                        myToolWindowForm.deactivate();
                    }
                }
            }
        }
    });
    final JComponent contentPanel = myToolWindowForm.getComponent();
    final ContentManager contentManager = myToolWindow.getContentManager();
    @SuppressWarnings("ConstantConditions") final Content content = contentManager.getFactory().createContent(contentPanel, null, false);
    content.setDisposer(myToolWindowForm);
    content.setCloseable(false);
    content.setPreferredFocusableComponent(contentPanel);
    contentManager.addContent(content);
    contentManager.setSelectedContent(content, true);
    myToolWindow.setAvailable(false, null);
    myToolWindowForm.setUseInteractiveSelector(isUseInteractiveSelector());
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager) ToolWindowManagerAdapter(com.intellij.openapi.wm.ex.ToolWindowManagerAdapter) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 22 with ToolWindowManagerEx

use of com.intellij.openapi.wm.ex.ToolWindowManagerEx in project intellij-code-outline by sitano.

the class CodeOutlinePlugin method unregForProject.

/**
     * Removes the code outline tool window from the given project.
     *
     * @param project the project to unregister
     */
private synchronized void unregForProject(Project project) {
    ToolWindowManager twm = ToolWindowManager.getInstance(project);
    CodeOutlineToolWindow window = windows.get(project);
    if (window != null) {
        ToolWindowManagerEx twmEx = (ToolWindowManagerEx) twm;
        twmEx.removeToolWindowManagerListener(window.getToolWindowManagerListener());
    }
    try {
        twm.unregisterToolWindow(TOOLWINDOW_ID);
    } catch (IllegalArgumentException ignored) {
    }
    CodeOutlineToolWindow win = windows.remove(project);
    if (win == null)
        return;
    win.stop();
}
Also used : ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 23 with ToolWindowManagerEx

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

the class DockablePopupManager method createToolWindow.

public void createToolWindow(final PsiElement element, PsiElement originalElement) {
    assert myToolWindow == null;
    final T component = createComponent();
    final ToolWindowManagerEx toolWindowManagerEx = ToolWindowManagerEx.getInstanceEx(myProject);
    final ToolWindow toolWindow = toolWindowManagerEx.getToolWindow(getToolwindowId());
    myToolWindow = toolWindow == null ? toolWindowManagerEx.registerToolWindow(getToolwindowId(), true, ToolWindowAnchor.RIGHT, myProject) : toolWindow;
    myToolWindow.setIcon(AllIcons.Toolwindows.Documentation);
    myToolWindow.setAvailable(true, null);
    myToolWindow.setToHideOnEmptyContent(false);
    setToolwindowDefaultState();
    ((ToolWindowEx) myToolWindow).setTitleActions(createRestorePopupAction());
    final ContentManager contentManager = myToolWindow.getContentManager();
    final ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    final Content content = contentFactory.createContent(component, getTitle(element), false);
    contentManager.addContent(content);
    contentManager.addContentManagerListener(new ContentManagerAdapter() {

        @Override
        public void contentRemoved(ContentManagerEvent event) {
            restorePopupBehavior();
        }
    });
    new UiNotifyConnector(component, new Activatable() {

        @Override
        public void showNotify() {
            restartAutoUpdate(myAutoUpdateDocumentation);
        }

        @Override
        public void hideNotify() {
            restartAutoUpdate(false);
        }
    });
    myToolWindow.show(null);
    PropertiesComponent.getInstance().setValue(getShowInToolWindowProperty(), Boolean.TRUE.toString());
    restartAutoUpdate(PropertiesComponent.getInstance().getBoolean(getAutoUpdateEnabledProperty(), true));
    doUpdateComponent(element, originalElement, component);
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) ToolWindowEx(com.intellij.openapi.wm.ex.ToolWindowEx) Activatable(com.intellij.util.ui.update.Activatable) UiNotifyConnector(com.intellij.util.ui.update.UiNotifyConnector) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 24 with ToolWindowManagerEx

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

the class RunContentManagerImpl method init.

// must be called on EDT
private void init() {
    ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(myProject);
    if (toolWindowManager == null) {
        return;
    }
    for (Executor executor : ExecutorRegistry.getInstance().getRegisteredExecutors()) {
        registerToolWindow(executor, toolWindowManager);
    }
    RunDashboardManager dashboardManager = RunDashboardManager.getInstance(myProject);
    initToolWindow(null, dashboardManager.getToolWindowId(), dashboardManager.getToolWindowIcon(), dashboardManager.getDashboardContentManager());
    toolWindowManager.addToolWindowManagerListener(new ToolWindowManagerAdapter() {

        @Override
        public void stateChanged() {
            if (myProject.isDisposed()) {
                return;
            }
            ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
            Set<String> currentWindows = new THashSet<>();
            ContainerUtil.addAll(currentWindows, toolWindowManager.getToolWindowIds());
            myToolwindowIdZBuffer.retainAll(currentWindows);
            final String activeToolWindowId = toolWindowManager.getActiveToolWindowId();
            if (activeToolWindowId != null) {
                if (myToolwindowIdZBuffer.remove(activeToolWindowId)) {
                    myToolwindowIdZBuffer.addFirst(activeToolWindowId);
                }
            }
        }
    });
}
Also used : THashSet(gnu.trove.THashSet) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) ToolWindowManagerAdapter(com.intellij.openapi.wm.ex.ToolWindowManagerAdapter) RunDashboardManager(com.intellij.execution.dashboard.RunDashboardManager) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 25 with ToolWindowManagerEx

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

the class TogglePresentationModeAction method storeToolWindows.

static boolean storeToolWindows(@Nullable Project project) {
    if (project == null)
        return false;
    ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(project);
    DesktopLayout layout = new DesktopLayout();
    layout.copyFrom(manager.getLayout());
    boolean hasVisible = hideAllToolWindows(manager);
    if (hasVisible) {
        manager.setLayoutToRestoreLater(layout);
        manager.activateEditorComponent();
    }
    return hasVisible;
}
Also used : DesktopLayout(com.intellij.openapi.wm.impl.DesktopLayout) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Aggregations

ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)37 Project (com.intellij.openapi.project.Project)14 ToolWindow (com.intellij.openapi.wm.ToolWindow)13 ToolWindowManagerAdapter (com.intellij.openapi.wm.ex.ToolWindowManagerAdapter)9 Content (com.intellij.ui.content.Content)7 ToolWindowEx (com.intellij.openapi.wm.ex.ToolWindowEx)6 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)5 Presentation (com.intellij.openapi.actionSystem.Presentation)4 ToolWindowManagerListener (com.intellij.openapi.wm.ex.ToolWindowManagerListener)4 DesktopLayout (com.intellij.openapi.wm.impl.DesktopLayout)4 Disposable (com.intellij.openapi.Disposable)3 ToolWindowType (com.intellij.openapi.wm.ToolWindowType)3 ContentManager (com.intellij.ui.content.ContentManager)2 LightToolWindow (com.intellij.designer.LightToolWindow)1 com.intellij.execution (com.intellij.execution)1 RunDashboardManager (com.intellij.execution.dashboard.RunDashboardManager)1 ConsoleViewImpl (com.intellij.execution.impl.ConsoleViewImpl)1 ConsoleView (com.intellij.execution.ui.ConsoleView)1 OccurenceNavigator (com.intellij.ide.OccurenceNavigator)1 ProjectViewImpl (com.intellij.ide.projectView.impl.ProjectViewImpl)1