Search in sources :

Example 6 with ToolWindowEx

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

the class ContentManagerUtil method getContentManagerFromContext.

/**
   * This is utility method. It returns <code>ContentManager</code> from the current context.
   */
public static ContentManager getContentManagerFromContext(DataContext dataContext, boolean requiresVisibleToolWindow) {
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project == null) {
        return null;
    }
    ToolWindowManagerEx mgr = ToolWindowManagerEx.getInstanceEx(project);
    String id = mgr.getActiveToolWindowId();
    if (id == null) {
        if (mgr.isEditorComponentActive()) {
            id = mgr.getLastActiveToolWindowId();
        }
    }
    ToolWindowEx toolWindow = id != null ? (ToolWindowEx) mgr.getToolWindow(id) : null;
    if (requiresVisibleToolWindow && (toolWindow == null || !toolWindow.isVisible())) {
        return null;
    }
    ContentManager fromToolWindow = toolWindow != null ? toolWindow.getContentManager() : null;
    ContentManager fromContext = PlatformDataKeys.CONTENT_MANAGER.getData(dataContext);
    return ObjectUtils.chooseNotNull(fromContext, fromToolWindow);
}
Also used : Project(com.intellij.openapi.project.Project) ToolWindowEx(com.intellij.openapi.wm.ex.ToolWindowEx) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 7 with ToolWindowEx

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

the class BaseToolWindowToggleAction method setSelected.

@Override
public final void setSelected(AnActionEvent e, boolean state) {
    Project project = e.getProject();
    if (project == null) {
        return;
    }
    String id = ToolWindowManager.getInstance(project).getActiveToolWindowId();
    if (id == null) {
        return;
    }
    ToolWindowManagerEx mgr = ToolWindowManagerEx.getInstanceEx(project);
    ToolWindowEx toolWindow = (ToolWindowEx) mgr.getToolWindow(id);
    setSelected(toolWindow, state);
}
Also used : Project(com.intellij.openapi.project.Project) ToolWindowEx(com.intellij.openapi.wm.ex.ToolWindowEx) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 8 with ToolWindowEx

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

the class FloatingToolWindow method createToolWindow.

private ToolWindowEx createToolWindow(@NotNull ToolWindowManager toolWindowManager, @NotNull ToolWindowDefinition<T> definition) {
    String id = definition.getTitle();
    ToolWindowEx window = (ToolWindowEx) toolWindowManager.getToolWindow(id);
    if (window == null) {
        ToolWindowAnchor anchor = definition.getSide().isLeft() ? ToolWindowAnchor.LEFT : ToolWindowAnchor.RIGHT;
        window = (ToolWindowEx) toolWindowManager.registerToolWindow(id, false, anchor, this, true);
        window.setIcon(definition.getIcon());
        window.setType(ToolWindowType.FLOATING, null);
        window.setAutoHide(false);
        setToolWindowContent(window);
        setAdditionalGearPopupActions(window);
        setAdditionalActions(window);
    }
    return window;
}
Also used : ToolWindowEx(com.intellij.openapi.wm.ex.ToolWindowEx) ToolWindowAnchor(com.intellij.openapi.wm.ToolWindowAnchor)

Example 9 with ToolWindowEx

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

the class CaptureEditorLightToolWindowManager method initToolWindow.

@Override
protected void initToolWindow() {
    myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(getManagerName(), false, getAnchor(), myProject, true);
    myToolWindow.setIcon(getIcon());
    if (!ApplicationManager.getApplication().isHeadlessEnvironment()) {
        myToolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true");
    }
    ((ToolWindowEx) myToolWindow).setTitleActions(createActions());
    initGearActions();
    ContentManager contentManager = myToolWindow.getContentManager();
    Content content = contentManager.getFactory().createContent(getContent(), getToolWindowTitleBarText(), false);
    content.setCloseable(false);
    content.setPreferredFocusableComponent(getFocusedComponent());
    contentManager.addContent(content);
    contentManager.setSelectedContent(content, true);
    myToolWindow.setAvailable(false, null);
}
Also used : ToolWindowEx(com.intellij.openapi.wm.ex.ToolWindowEx) Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager)

Example 10 with ToolWindowEx

use of com.intellij.openapi.wm.ex.ToolWindowEx in project azure-tools-for-java by Microsoft.

the class ServerExplorerToolWindowFactory method addToolbarItems.

private void addToolbarItems(ToolWindow toolWindow, final AzureModule azureModule) {
    if (toolWindow instanceof ToolWindowEx) {
        ToolWindowEx toolWindowEx = (ToolWindowEx) toolWindow;
        try {
            Runnable forceRefreshTitleActions = () -> {
                try {
                    toolWindowEx.setTitleActions(new AnAction("Refresh", "Refresh Azure Nodes List", null) {

                        @Override
                        public void actionPerformed(AnActionEvent event) {
                            azureModule.load(true);
                        }

                        @Override
                        public void update(AnActionEvent e) {
                            boolean isDarkTheme = DefaultLoader.getUIHelper().isDarkTheme();
                            e.getPresentation().setIcon(UIHelperImpl.loadIcon(isDarkTheme ? RefreshableNode.REFRESH_ICON_DARK : RefreshableNode.REFRESH_ICON_LIGHT));
                        }
                    }, new AzureSignInAction(), new SelectSubscriptionsAction());
                } catch (Exception e) {
                    AzurePlugin.log(e.getMessage(), e);
                }
            };
            AuthMethodManager.getInstance().addSignInEventListener(forceRefreshTitleActions);
            AuthMethodManager.getInstance().addSignOutEventListener(forceRefreshTitleActions);
            forceRefreshTitleActions.run();
        } catch (Exception e) {
            AzurePlugin.log(e.getMessage(), e);
        }
    }
}
Also used : ToolWindowEx(com.intellij.openapi.wm.ex.ToolWindowEx) AzureSignInAction(com.microsoft.azuretools.ijidea.actions.AzureSignInAction) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) SelectSubscriptionsAction(com.microsoft.azuretools.ijidea.actions.SelectSubscriptionsAction) AnAction(com.intellij.openapi.actionSystem.AnAction)

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