Search in sources :

Example 31 with ContentManager

use of com.intellij.ui.content.ContentManager in project android by JetBrains.

the class FloatingToolWindow method setToolWindowContent.

private void setToolWindowContent(@NotNull ToolWindowEx toolWindow) {
    ContentManager contentManager = toolWindow.getContentManager();
    Content content = contentManager.getSelectedContent();
    if (content == null) {
        content = contentManager.getFactory().createContent(myContent.getComponent(), null, false);
        content.setCloseable(false);
        content.setComponent(myContent.getComponent());
        content.setPreferredFocusableComponent(myContent.getFocusedComponent());
        content.setShouldDisposeContent(true);
        contentManager.addContent(content);
        contentManager.setSelectedContent(content, true);
    }
}
Also used : Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager)

Example 32 with ContentManager

use of com.intellij.ui.content.ContentManager 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)

Example 33 with ContentManager

use of com.intellij.ui.content.ContentManager in project intellij-plugins by JetBrains.

the class MxmlPreviewToolWindowManager method initToolWindow.

private void initToolWindow() {
    toolWindowForm = new MxmlPreviewToolWindowForm();
    String toolWindowId = FlashUIDesignerBundle.message("mxml.preview.tool.window.title");
    toolWindow = ToolWindowManager.getInstance(project).registerToolWindow(toolWindowId, false, ToolWindowAnchor.RIGHT, project, false);
    toolWindow.setIcon(PlatformIcons.UI_FORM_ICON);
    PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);
    toolWindowVisible = propertiesComponent.getBoolean(SETTINGS_TOOL_WINDOW_VISIBLE);
    if (toolWindowVisible) {
        toolWindow.show(null);
    } else {
        toolWindow.hide(null);
    }
    ((ToolWindowManagerEx) ToolWindowManager.getInstance(project)).addToolWindowManagerListener(new ToolWindowManagerAdapter() {

        @Override
        public void stateChanged() {
            if (project.isDisposed() || toolWindow == null || !toolWindow.isAvailable()) {
                return;
            }
            final boolean currentVisible = toolWindow.isVisible();
            if (currentVisible == toolWindowVisible) {
                return;
            }
            toolWindowVisible = currentVisible;
            PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);
            if (currentVisible) {
                propertiesComponent.setValue(SETTINGS_TOOL_WINDOW_VISIBLE, true);
                if (!lastPreviewChecked) {
                    lastPreviewChecked = true;
                    if (checkLastImage()) {
                        return;
                    }
                }
                render(true, false);
            } else {
                propertiesComponent.unsetValue(SETTINGS_TOOL_WINDOW_VISIBLE);
            }
        }
    });
    JPanel contentPanel = toolWindowForm.getContentPanel();
    ContentManager contentManager = toolWindow.getContentManager();
    Content content = contentManager.getFactory().createContent(contentPanel, null, false);
    content.setCloseable(false);
    content.setPreferredFocusableComponent(contentPanel);
    contentManager.addContent(content);
    contentManager.setSelectedContent(content, true);
    MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(project);
    connection.subscribe(DesignerApplicationManager.MESSAGE_TOPIC, new DocumentRenderedListener() {

        private boolean isApplicable(DocumentFactoryManager.DocumentInfo info) {
            return toolWindowVisible && toolWindowForm.getFile() != null && info.equals(DocumentFactoryManager.getInstance().getNullableInfo(toolWindowForm.getFile()));
        }

        @Override
        public void documentRendered(DocumentFactoryManager.DocumentInfo info) {
            if (isApplicable(info) && !toolWindowForm.waitingForGetDocument) {
                UIUtil.invokeLaterIfNeeded(() -> render(false, false));
            }
        }

        @Override
        public void errorOccurred() {
        }
    });
}
Also used : MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ContentManager(com.intellij.ui.content.ContentManager) ToolWindowManagerAdapter(com.intellij.openapi.wm.ex.ToolWindowManagerAdapter) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx) Content(com.intellij.ui.content.Content) PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 34 with ContentManager

use of com.intellij.ui.content.ContentManager in project intellij-community by JetBrains.

the class CvsTabbedWindow method addTab.

public void addTab(String title, JComponent component, boolean selectTab, boolean replaceContent, boolean lockable, boolean addDefaultToolbar, @Nullable final ActionGroup toolbarActions, @NonNls String helpId) {
    final ContentManager contentManager = getToolWindow().getContentManager();
    final Content existingContent = contentManager.findContent(title);
    if (existingContent != null) {
        final JComponent existingComponent = existingContent.getComponent();
        if (existingComponent instanceof DeactivateListener) {
            ((DeactivateListener) existingComponent).deactivated();
        }
        if (!replaceContent) {
            contentManager.setSelectedContent(existingContent);
            return;
        } else if (!existingContent.isPinned()) {
            contentManager.removeContent(existingContent, true);
            existingContent.release();
        }
    }
    final CvsTabbedWindowComponent newComponent = new CvsTabbedWindowComponent(component, addDefaultToolbar, toolbarActions, contentManager, helpId);
    final Content content = contentManager.getFactory().createContent(newComponent.getShownComponent(), title, lockable);
    newComponent.setContent(content);
    contentManager.addContent(content);
    if (selectTab) {
        getToolWindow().activate(null, false);
    }
}
Also used : Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager)

Example 35 with ContentManager

use of com.intellij.ui.content.ContentManager in project intellij-community by JetBrains.

the class CloseActiveTabAction method update.

public void update(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    ContentManager contentManager = ContentManagerUtil.getContentManagerFromContext(event.getDataContext(), true);
    presentation.setEnabled(contentManager != null && contentManager.canCloseContents());
    if (!presentation.isEnabled() && contentManager != null) {
        final DataContext context = DataManager.getInstance().getDataContext(contentManager.getComponent());
        presentation.setEnabled(PlatformDataKeys.TOOL_WINDOW.getData(context) != null);
    }
}
Also used : ContentManager(com.intellij.ui.content.ContentManager)

Aggregations

ContentManager (com.intellij.ui.content.ContentManager)53 Content (com.intellij.ui.content.Content)41 ToolWindow (com.intellij.openapi.wm.ToolWindow)14 Project (com.intellij.openapi.project.Project)6 RunnerLayoutUi (com.intellij.execution.ui.RunnerLayoutUi)4 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)4 ChangesViewContentManager (com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager)3 ToolWindowEx (com.intellij.openapi.wm.ex.ToolWindowEx)3 ToolWindowManagerAdapter (com.intellij.openapi.wm.ex.ToolWindowManagerAdapter)3 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)3 ContentFactory (com.intellij.ui.content.ContentFactory)3 ConsoleView (com.intellij.execution.ui.ConsoleView)2 ExecutionConsole (com.intellij.execution.ui.ExecutionConsole)2 HierarchyBrowserBase (com.intellij.ide.hierarchy.HierarchyBrowserBase)2 Disposable (com.intellij.openapi.Disposable)2 SimpleToolWindowPanel (com.intellij.openapi.ui.SimpleToolWindowPanel)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 TabInfo (com.intellij.ui.tabs.TabInfo)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2