Search in sources :

Example 1 with InstancesTracker

use of com.intellij.debugger.memory.component.InstancesTracker in project intellij-community by JetBrains.

the class TrackInstancesToggleAction method isSelected.

@Override
public boolean isSelected(AnActionEvent e) {
    ReferenceType selectedClass = getSelectedClass(e);
    final Project project = e.getProject();
    if (project != null && selectedClass != null && !project.isDisposed()) {
        InstancesTracker tracker = InstancesTracker.getInstance(project);
        return tracker.isTracked(selectedClass.name());
    }
    return false;
}
Also used : Project(com.intellij.openapi.project.Project) InstancesTracker(com.intellij.debugger.memory.component.InstancesTracker) ReferenceType(com.sun.jdi.ReferenceType)

Example 2 with InstancesTracker

use of com.intellij.debugger.memory.component.InstancesTracker 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 3 with InstancesTracker

use of com.intellij.debugger.memory.component.InstancesTracker in project intellij-community by JetBrains.

the class TrackInstancesToggleAction method setSelected.

@Override
public void setSelected(AnActionEvent e, boolean state) {
    final ReferenceType selectedClass = getSelectedClass(e);
    final Project project = e.getProject();
    if (selectedClass != null && project != null && !project.isDisposed()) {
        InstancesTracker tracker = InstancesTracker.getInstance(project);
        boolean isAlreadyTracked = tracker.isTracked(selectedClass.name());
        if (isAlreadyTracked && !state) {
            tracker.remove(selectedClass.name());
        }
        if (!isAlreadyTracked && state) {
            tracker.add(selectedClass.name(), TrackingType.CREATION);
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) InstancesTracker(com.intellij.debugger.memory.component.InstancesTracker) ReferenceType(com.sun.jdi.ReferenceType)

Aggregations

InstancesTracker (com.intellij.debugger.memory.component.InstancesTracker)3 Project (com.intellij.openapi.project.Project)2 ReferenceType (com.sun.jdi.ReferenceType)2 MemoryViewDebugProcessData (com.intellij.debugger.memory.component.MemoryViewDebugProcessData)1 ClassesFilteredView (com.intellij.debugger.memory.ui.ClassesFilteredView)1 ThreadsPanel (com.intellij.debugger.ui.impl.ThreadsPanel)1 ExecutionConsole (com.intellij.execution.ui.ExecutionConsole)1 ExecutionConsoleEx (com.intellij.execution.ui.ExecutionConsoleEx)1 RunnerLayoutUi (com.intellij.execution.ui.RunnerLayoutUi)1 Content (com.intellij.ui.content.Content)1 ContentManagerAdapter (com.intellij.ui.content.ContentManagerAdapter)1 ContentManagerEvent (com.intellij.ui.content.ContentManagerEvent)1 XDebugTabLayouter (com.intellij.xdebugger.ui.XDebugTabLayouter)1 NotNull (org.jetbrains.annotations.NotNull)1