Search in sources :

Example 11 with ToolWindowEx

use of com.intellij.openapi.wm.ex.ToolWindowEx 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 12 with ToolWindowEx

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

the class ProjectViewImpl method setupImpl.

// public for tests
public synchronized void setupImpl(@NotNull ToolWindow toolWindow, final boolean loadPaneExtensions) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    myActionGroup = new DefaultActionGroup();
    myAutoScrollFromSourceHandler.install();
    myContentManager = toolWindow.getContentManager();
    if (!ApplicationManager.getApplication().isUnitTestMode()) {
        toolWindow.setDefaultContentUiType(ToolWindowContentUiType.COMBO);
        ((ToolWindowEx) toolWindow).setAdditionalGearActions(myActionGroup);
        toolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true");
    }
    GuiUtils.replaceJSplitPaneWithIDEASplitter(myPanel);
    SwingUtilities.invokeLater(() -> splitterProportions.restoreSplitterProportions(myPanel));
    if (loadPaneExtensions) {
        ensurePanesLoaded();
    }
    isInitialized = true;
    doAddUninitializedPanes();
    getContentManager().addContentManagerListener(new ContentManagerAdapter() {

        @Override
        public void selectionChanged(ContentManagerEvent event) {
            if (event.getOperation() == ContentManagerEvent.ContentOperation.add) {
                viewSelectionChanged();
            }
        }
    });
    viewSelectionChanged();
}
Also used : ToolWindowEx(com.intellij.openapi.wm.ex.ToolWindowEx) ContentManagerAdapter(com.intellij.ui.content.ContentManagerAdapter) ContentManagerEvent(com.intellij.ui.content.ContentManagerEvent)

Example 13 with ToolWindowEx

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

the class ProjectViewImpl method createToolbarActions.

private void createToolbarActions() {
    if (myActionGroup == null)
        return;
    List<AnAction> titleActions = ContainerUtil.newSmartList();
    myActionGroup.removeAll();
    if (ProjectViewDirectoryHelper.getInstance(myProject).supportsFlattenPackages()) {
        myActionGroup.addAction(new PaneOptionAction(myFlattenPackages, IdeBundle.message("action.flatten.packages"), IdeBundle.message("action.flatten.packages"), PlatformIcons.FLATTEN_PACKAGES_ICON, ourFlattenPackagesDefaults) {

            @Override
            public void setSelected(AnActionEvent event, boolean flag) {
                final AbstractProjectViewPane viewPane = getCurrentProjectViewPane();
                final SelectionInfo selectionInfo = SelectionInfo.create(viewPane);
                if (isGlobalOptions()) {
                    setFlattenPackages(flag, viewPane.getId());
                }
                super.setSelected(event, flag);
                selectionInfo.apply(viewPane);
            }

            @Override
            public boolean isSelected(AnActionEvent event) {
                if (isGlobalOptions())
                    return getGlobalOptions().getFlattenPackages();
                return super.isSelected(event);
            }
        }).setAsSecondary(true);
    }
    class FlattenPackagesDependableAction extends PaneOptionAction {

        FlattenPackagesDependableAction(@NotNull Map<String, Boolean> optionsMap, @NotNull String text, @NotNull String description, @NotNull Icon icon, boolean optionDefaultValue) {
            super(optionsMap, text, description, icon, optionDefaultValue);
        }

        @Override
        public void setSelected(AnActionEvent event, boolean flag) {
            if (isGlobalOptions()) {
                getGlobalOptions().setFlattenPackages(flag);
            }
            super.setSelected(event, flag);
        }

        @Override
        public void update(AnActionEvent e) {
            super.update(e);
            final Presentation presentation = e.getPresentation();
            presentation.setVisible(isFlattenPackages(myCurrentViewId));
        }
    }
    if (ProjectViewDirectoryHelper.getInstance(myProject).supportsHideEmptyMiddlePackages()) {
        myActionGroup.addAction(new HideEmptyMiddlePackagesAction()).setAsSecondary(true);
    }
    if (ProjectViewDirectoryHelper.getInstance(myProject).supportsFlattenPackages()) {
        myActionGroup.addAction(new FlattenPackagesDependableAction(myAbbreviatePackageNames, IdeBundle.message("action.abbreviate.qualified.package.names"), IdeBundle.message("action.abbreviate.qualified.package.names"), AllIcons.ObjectBrowser.AbbreviatePackageNames, ourAbbreviatePackagesDefaults) {

            @Override
            public boolean isSelected(AnActionEvent event) {
                return isFlattenPackages(myCurrentViewId) && isAbbreviatePackageNames(myCurrentViewId);
            }

            @Override
            public void setSelected(AnActionEvent event, boolean flag) {
                if (isGlobalOptions()) {
                    setAbbreviatePackageNames(flag, myCurrentViewId);
                }
                setPaneOption(myOptionsMap, flag, myCurrentViewId, true);
            }

            @Override
            public void update(AnActionEvent e) {
                super.update(e);
                if (ScopeViewPane.ID.equals(myCurrentViewId)) {
                    e.getPresentation().setEnabled(false);
                }
            }
        }).setAsSecondary(true);
    }
    if (isShowMembersOptionSupported()) {
        myActionGroup.addAction(new PaneOptionAction(myShowMembers, IdeBundle.message("action.show.members"), IdeBundle.message("action.show.hide.members"), AllIcons.ObjectBrowser.ShowMembers, ourShowMembersDefaults) {

            @Override
            public boolean isSelected(AnActionEvent event) {
                if (isGlobalOptions())
                    return getGlobalOptions().getShowMembers();
                return super.isSelected(event);
            }

            @Override
            public void setSelected(AnActionEvent event, boolean flag) {
                if (isGlobalOptions()) {
                    getGlobalOptions().setShowMembers(flag);
                }
                super.setSelected(event, flag);
            }
        }).setAsSecondary(true);
    }
    myActionGroup.addAction(myAutoScrollToSourceHandler.createToggleAction()).setAsSecondary(true);
    myActionGroup.addAction(myAutoScrollFromSourceHandler.createToggleAction()).setAsSecondary(true);
    myActionGroup.addAction(new ManualOrderAction()).setAsSecondary(true);
    myActionGroup.addAction(new SortByTypeAction()).setAsSecondary(true);
    myActionGroup.addAction(new FoldersAlwaysOnTopAction()).setAsSecondary(true);
    if (!myAutoScrollFromSourceHandler.isAutoScrollEnabled()) {
        titleActions.add(new ScrollFromSourceAction());
    }
    AnAction collapseAllAction = CommonActionsManager.getInstance().createCollapseAllAction(new TreeExpander() {

        @Override
        public void expandAll() {
        }

        @Override
        public boolean canExpand() {
            return false;
        }

        @Override
        public void collapseAll() {
            AbstractProjectViewPane pane = getCurrentProjectViewPane();
            JTree tree = pane.myTree;
            if (tree != null) {
                TreeUtil.collapseAll(tree, 0);
            }
        }

        @Override
        public boolean canCollapse() {
            return true;
        }
    }, getComponent());
    collapseAllAction.getTemplatePresentation().setIcon(AllIcons.General.CollapseAll);
    collapseAllAction.getTemplatePresentation().setHoveredIcon(AllIcons.General.CollapseAllHover);
    titleActions.add(collapseAllAction);
    getCurrentProjectViewPane().addToolbarActions(myActionGroup);
    ToolWindowEx window = (ToolWindowEx) ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.PROJECT_VIEW);
    if (window != null) {
        window.setTitleActions(titleActions.toArray(new AnAction[titleActions.size()]));
    }
}
Also used : NotNull(org.jetbrains.annotations.NotNull) ToolWindowEx(com.intellij.openapi.wm.ex.ToolWindowEx) THashMap(gnu.trove.THashMap)

Example 14 with ToolWindowEx

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

the class PyDataViewToolWindowFactory method createToolWindowContent.

@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    PyDataView.getInstance(project).init(toolWindow);
    final MessageBusConnection connection = project.getMessageBus().connect(project);
    connection.subscribe(XDebuggerManager.TOPIC, new ChangeContentXDebuggerManagerListener(project));
    connection.subscribe(RunContentManager.TOPIC, new RunContentWithExecutorListener() {

        @Override
        public void contentSelected(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) {
            if (!(executor instanceof DefaultDebugExecutor)) {
                return;
            }
            if (descriptor == null) {
                return;
            }
            ProcessHandler handler = descriptor.getProcessHandler();
            if (handler == null) {
                return;
            }
            PyDataView.getInstance(project).updateTabs(handler);
        }

        @Override
        public void contentRemoved(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) {
        }
    });
    addPythonConsoleListener(project);
    ((ToolWindowEx) toolWindow).setAdditionalGearActions(new DefaultActionGroup(new ColoredByDefaultAction()));
}
Also used : MessageBusConnection(com.intellij.util.messages.MessageBusConnection) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) ToolWindowEx(com.intellij.openapi.wm.ex.ToolWindowEx) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) Executor(com.intellij.execution.Executor) RunContentWithExecutorListener(com.intellij.execution.ui.RunContentWithExecutorListener) ProcessHandler(com.intellij.execution.process.ProcessHandler) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Example 15 with ToolWindowEx

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

the class NlAbstractWindowManager method createWindowContent.

protected void createWindowContent(@NotNull JComponent contentPane, @NotNull JComponent focusedComponent, @Nullable AnAction[] actions) {
    ContentManager contentManager = myToolWindow.getContentManager();
    Content content = contentManager.getFactory().createContent(contentPane, null, false);
    content.setCloseable(false);
    content.setPreferredFocusableComponent(focusedComponent);
    if (actions != null) {
        ToolWindowEx toolWindow = (ToolWindowEx) myToolWindow;
        toolWindow.setTitleActions(actions);
    }
    contentManager.addContent(content);
    contentManager.setSelectedContent(content, true);
}
Also used : ToolWindowEx(com.intellij.openapi.wm.ex.ToolWindowEx) Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager)

Aggregations

ToolWindowEx (com.intellij.openapi.wm.ex.ToolWindowEx)15 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)5 Project (com.intellij.openapi.project.Project)4 Content (com.intellij.ui.content.Content)3 ContentManager (com.intellij.ui.content.ContentManager)3 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)2 ToolWindowType (com.intellij.openapi.wm.ToolWindowType)2 Executor (com.intellij.execution.Executor)1 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)1 ProcessHandler (com.intellij.execution.process.ProcessHandler)1 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)1 RunContentWithExecutorListener (com.intellij.execution.ui.RunContentWithExecutorListener)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 ToolWindow (com.intellij.openapi.wm.ToolWindow)1 ToolWindowAnchor (com.intellij.openapi.wm.ToolWindowAnchor)1 InternalDecorator (com.intellij.openapi.wm.impl.InternalDecorator)1 ContentManagerAdapter (com.intellij.ui.content.ContentManagerAdapter)1 ContentManagerEvent (com.intellij.ui.content.ContentManagerEvent)1 MessageBusConnection (com.intellij.util.messages.MessageBusConnection)1