Search in sources :

Example 16 with Content

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

the class JavaDebugProcess method createTabLayouter.

@NotNull
@Override
public XDebugTabLayouter createTabLayouter() {
    return new XDebugTabLayouter() {

        @Override
        public void registerAdditionalContent(@NotNull RunnerLayoutUi ui) {
            registerThreadsPanel(ui);
            registerMemoryViewPanel(ui);
        }

        @NotNull
        @Override
        public Content registerConsoleContent(@NotNull RunnerLayoutUi ui, @NotNull ExecutionConsole console) {
            Content content = null;
            if (console instanceof ExecutionConsoleEx) {
                ((ExecutionConsoleEx) console).buildUi(ui);
                content = ui.findContent(DebuggerContentInfo.CONSOLE_CONTENT);
            }
            if (content == null) {
                content = super.registerConsoleContent(ui, console);
            }
            return content;
        }

        private void registerThreadsPanel(@NotNull RunnerLayoutUi ui) {
            final ThreadsPanel panel = new ThreadsPanel(myJavaSession.getProject(), getDebuggerStateManager());
            final Content threadsContent = ui.createContent(DebuggerContentInfo.THREADS_CONTENT, panel, XDebuggerBundle.message("debugger.session.tab.threads.title"), AllIcons.Debugger.Threads, null);
            Disposer.register(threadsContent, panel);
            threadsContent.setCloseable(false);
            ui.addContent(threadsContent, 0, PlaceInGrid.left, true);
            ui.addListener(new ContentManagerAdapter() {

                @Override
                public void selectionChanged(ContentManagerEvent event) {
                    if (event.getContent() == threadsContent) {
                        if (threadsContent.isSelected()) {
                            panel.setUpdateEnabled(true);
                            if (panel.isRefreshNeeded()) {
                                panel.rebuildIfVisible(DebuggerSession.Event.CONTEXT);
                            }
                        } else {
                            panel.setUpdateEnabled(false);
                        }
                    }
                }
            }, threadsContent);
        }

        private void registerMemoryViewPanel(@NotNull RunnerLayoutUi ui) {
            final XDebugSession session = getSession();
            final DebugProcessImpl process = myJavaSession.getProcess();
            final InstancesTracker tracker = InstancesTracker.getInstance(myJavaSession.getProject());
            final ClassesFilteredView classesFilteredView = new ClassesFilteredView(session, process, tracker);
            final Content memoryViewContent = ui.createContent(MemoryViewManager.MEMORY_VIEW_CONTENT, classesFilteredView, "Memory View", AllIcons.Debugger.MemoryView.Active, null);
            memoryViewContent.setCloseable(false);
            memoryViewContent.setPinned(true);
            memoryViewContent.setShouldDisposeContent(true);
            final MemoryViewDebugProcessData data = new MemoryViewDebugProcessData(classesFilteredView);
            process.putUserData(MemoryViewDebugProcessData.KEY, data);
            ui.addListener(new ContentManagerAdapter() {

                @Override
                public void contentAdded(ContentManagerEvent event) {
                    changeMemoryViewMode(event);
                }

                @Override
                public void contentRemoved(ContentManagerEvent event) {
                    changeMemoryViewMode(event);
                }

                @Override
                public void selectionChanged(ContentManagerEvent event) {
                    changeMemoryViewMode(event);
                }

                private void changeMemoryViewMode(@Nullable ContentManagerEvent event) {
                    if (event != null && event.getContent() == memoryViewContent) {
                        final ContentManagerEvent.ContentOperation operation = event.getOperation();
                        final boolean isAddOperation = operation.equals(ContentManagerEvent.ContentOperation.add);
                        if (isAddOperation || operation.equals(ContentManagerEvent.ContentOperation.remove)) {
                            classesFilteredView.setActive(isAddOperation, process.getManagerThread());
                        }
                    }
                }
            }, classesFilteredView);
            ui.addContent(memoryViewContent, 0, PlaceInGrid.right, true);
        }
    };
}
Also used : ThreadsPanel(com.intellij.debugger.ui.impl.ThreadsPanel) InstancesTracker(com.intellij.debugger.memory.component.InstancesTracker) ContentManagerAdapter(com.intellij.ui.content.ContentManagerAdapter) NotNull(org.jetbrains.annotations.NotNull) ClassesFilteredView(com.intellij.debugger.memory.ui.ClassesFilteredView) MemoryViewDebugProcessData(com.intellij.debugger.memory.component.MemoryViewDebugProcessData) RunnerLayoutUi(com.intellij.execution.ui.RunnerLayoutUi) Content(com.intellij.ui.content.Content) XDebugTabLayouter(com.intellij.xdebugger.ui.XDebugTabLayouter) ExecutionConsole(com.intellij.execution.ui.ExecutionConsole) ExecutionConsoleEx(com.intellij.execution.ui.ExecutionConsoleEx) ContentManagerEvent(com.intellij.ui.content.ContentManagerEvent) NotNull(org.jetbrains.annotations.NotNull)

Example 17 with Content

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

the class NewErrorTreeViewPanel method close.

public void close() {
    MessageView messageView = MessageView.SERVICE.getInstance(myProject);
    Content content = messageView.getContentManager().getContent(this);
    if (content != null) {
        messageView.getContentManager().removeContent(content, true);
    }
}
Also used : MessageView(com.intellij.ui.content.MessageView) Content(com.intellij.ui.content.Content)

Example 18 with Content

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

the class TestErrorViewAction method openView.

protected void openView(Project project, JComponent component) {
    final MessageView messageView = MessageView.SERVICE.getInstance(project);
    final Content content = ContentFactory.SERVICE.getInstance().createContent(component, getContentName(), true);
    messageView.getContentManager().addContent(content);
    messageView.getContentManager().setSelectedContent(content);
    ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
    if (toolWindow != null) {
        toolWindow.activate(null);
    }
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) MessageView(com.intellij.ui.content.MessageView) Content(com.intellij.ui.content.Content)

Example 19 with Content

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

the class CompositeDiffPanel method setDiffRequest.

@Override
public void setDiffRequest(DiffRequest request) {
    final Map<String, DiffRequest> requestMap = myRequest.discloseRequest(request);
    HashMap<String, Pair<DiffViewer, Content>> mapCopy = new HashMap<>(myMap);
    myMap.clear();
    for (Map.Entry<String, DiffRequest> entry : requestMap.entrySet()) {
        final String key = entry.getKey();
        final DiffRequest diffRequest = entry.getValue();
        diffRequest.getGenericData().put(PlatformDataKeys.COMPOSITE_DIFF_VIEWER.getName(), this);
        final Pair<DiffViewer, Content> pair = mapCopy.get(key);
        DiffViewer viewer = pair != null ? pair.first : null;
        if (viewer != null && viewer.acceptsType(diffRequest.getType()) && viewer.canShowRequest(diffRequest)) {
            viewer.setDiffRequest(diffRequest);
            myMap.put(key, pair);
            mapCopy.remove(key);
        } else {
            final DiffViewer newViewer = myRequest.viewerForRequest(myWindow, myParentDisposable, key, diffRequest);
            if (newViewer == null)
                continue;
            final Content content = myUi.createContent(key, newViewer.getComponent(), key, null, newViewer.getPreferredFocusedComponent());
            content.setCloseable(false);
            content.setPinned(true);
            content.setDisposer(myParentDisposable);
            myUi.addContent(content);
            myMap.put(key, Pair.create(newViewer, content));
            if (pair != null)
                myUi.removeContent(pair.second, false);
        }
    }
    if (myMap.isEmpty()) {
        final ErrorDiffViewer errorDiffViewer = new ErrorDiffViewer(myWindow, request);
        final Content content = myUi.createContent(FICTIVE_KEY, errorDiffViewer.getComponent(), FICTIVE_KEY, null, errorDiffViewer.getPreferredFocusedComponent());
        content.setCloseable(false);
        content.setPinned(true);
        content.setDisposer(myParentDisposable);
        myUi.addContent(content);
        myMap.put(FICTIVE_KEY, Pair.<DiffViewer, Content>create(errorDiffViewer, content));
    }
    for (Pair<DiffViewer, Content> pair : mapCopy.values()) {
        myUi.removeContent(pair.second, false);
        if (pair.first instanceof Disposable)
            Disposer.dispose((Disposable) pair.first);
    }
}
Also used : Disposable(com.intellij.openapi.Disposable) HashMap(java.util.HashMap) DiffRequest(com.intellij.openapi.diff.DiffRequest) DiffViewer(com.intellij.openapi.diff.DiffViewer) Content(com.intellij.ui.content.Content) HashMap(java.util.HashMap) Map(java.util.Map) Pair(com.intellij.openapi.util.Pair)

Example 20 with Content

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

Aggregations

Content (com.intellij.ui.content.Content)157 ContentManager (com.intellij.ui.content.ContentManager)42 ToolWindow (com.intellij.openapi.wm.ToolWindow)37 NotNull (org.jetbrains.annotations.NotNull)19 ContentFactory (com.intellij.ui.content.ContentFactory)14 Project (com.intellij.openapi.project.Project)13 Nullable (org.jetbrains.annotations.Nullable)13 MessageView (com.intellij.ui.content.MessageView)10 Disposable (com.intellij.openapi.Disposable)8 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)8 RunnerLayoutUi (com.intellij.execution.ui.RunnerLayoutUi)7 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)7 ConsoleView (com.intellij.execution.ui.ConsoleView)6 SimpleToolWindowPanel (com.intellij.openapi.ui.SimpleToolWindowPanel)6 TabbedContent (com.intellij.ui.content.TabbedContent)6 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)5 Ref (com.intellij.openapi.util.Ref)5 ExecutionConsole (com.intellij.execution.ui.ExecutionConsole)4 ToolWindowManagerAdapter (com.intellij.openapi.wm.ex.ToolWindowManagerAdapter)4 Assert.assertNotNull (junit.framework.Assert.assertNotNull)4