Search in sources :

Example 16 with ContentManager

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

the class OccurenceNavigatorActionBase method getNavigator.

@Nullable
protected OccurenceNavigator getNavigator(DataContext dataContext) {
    ContentManager contentManager = ContentManagerUtil.getContentManagerFromContext(dataContext, false);
    if (contentManager != null) {
        Content content = contentManager.getSelectedContent();
        if (content == null)
            return null;
        JComponent component = content.getComponent();
        return findNavigator(component);
    }
    return (OccurenceNavigator) getOccurenceNavigatorFromContext(dataContext);
}
Also used : Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager) OccurenceNavigator(com.intellij.ide.OccurenceNavigator) Nullable(org.jetbrains.annotations.Nullable)

Example 17 with ContentManager

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

the class CloseActiveTabAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    ContentManager contentManager = ContentManagerUtil.getContentManagerFromContext(e.getDataContext(), true);
    boolean processed = false;
    if (contentManager != null && contentManager.canCloseContents()) {
        final Content selectedContent = contentManager.getSelectedContent();
        if (selectedContent != null && selectedContent.isCloseable()) {
            contentManager.removeContent(selectedContent, true);
            processed = true;
        }
    }
    if (!processed && contentManager != null) {
        final DataContext context = DataManager.getInstance().getDataContext(contentManager.getComponent());
        final ToolWindow tw = PlatformDataKeys.TOOL_WINDOW.getData(context);
        if (tw != null) {
            tw.hide(null);
        }
    }
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager)

Example 18 with ContentManager

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

the class TodoCheckinHandler method showTodo.

private void showTodo(TodoCheckinHandlerWorker worker) {
    String title = "For commit (" + DateFormatUtil.formatDateTime(System.currentTimeMillis()) + ")";
    ServiceManager.getService(myProject, TodoView.class).addCustomTodoView(new TodoTreeBuilderFactory() {

        @Override
        public TodoTreeBuilder createTreeBuilder(JTree tree, DefaultTreeModel treeModel, Project project) {
            return new CustomChangelistTodosTreeBuilder(tree, treeModel, myProject, title, worker.inOneList());
        }
    }, title, new TodoPanelSettings(myConfiguration.myTodoPanelSettings));
    ApplicationManager.getApplication().invokeLater(() -> {
        ToolWindowManager manager = ToolWindowManager.getInstance(myProject);
        if (manager != null) {
            ToolWindow window = manager.getToolWindow("TODO");
            if (window != null) {
                window.show(() -> {
                    ContentManager cm = window.getContentManager();
                    Content[] contents = cm.getContents();
                    if (contents.length > 0) {
                        cm.setSelectedContent(contents[contents.length - 1], true);
                    }
                });
            }
        }
    }, ModalityState.NON_MODAL, myProject.getDisposed());
}
Also used : ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) ContentManager(com.intellij.ui.content.ContentManager) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Project(com.intellij.openapi.project.Project) ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content)

Example 19 with ContentManager

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

the class VcsLogContentProvider method findAndSelectContent.

public static <U extends AbstractVcsLogUi> boolean findAndSelectContent(@NotNull Project project, @NotNull Class<U> clazz, @NotNull Condition<U> condition) {
    ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS);
    ContentManager manager = toolWindow.getContentManager();
    JComponent component = ContentUtilEx.findContentComponent(manager, c -> {
        if (c instanceof VcsLogPanel) {
            AbstractVcsLogUi ui = ((VcsLogPanel) c).getUi();
            return clazz.isInstance(ui) && condition.value((U) ui);
        }
        return false;
    });
    if (component == null)
        return false;
    if (!toolWindow.isVisible())
        toolWindow.activate(null);
    return ContentUtilEx.selectContent(manager, component, true);
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) AbstractVcsLogUi(com.intellij.vcs.log.ui.AbstractVcsLogUi) ContentManager(com.intellij.ui.content.ContentManager) VcsLogPanel(com.intellij.vcs.log.ui.VcsLogPanel)

Example 20 with ContentManager

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

the class CloseLogTabAction method update.

@Override
public void update(@NotNull AnActionEvent e) {
    super.update(e);
    if (e.getProject() == null) {
        e.getPresentation().setEnabledAndVisible(false);
        return;
    }
    ContentManager contentManager = getContentManager(e.getProject());
    if (contentManager == null || getTabbedContent(contentManager) == null) {
        e.getPresentation().setEnabledAndVisible(false);
        return;
    }
    e.getPresentation().setEnabledAndVisible(true);
}
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