'Mark Object' action in xdebugger

This commit is contained in:
nik
2011-04-15 18:30:52 +04:00
parent 87ba84e74e
commit 54213ca634
27 changed files with 538 additions and 115 deletions
@@ -37,7 +37,6 @@ public interface DebuggerActions extends XDebuggerActions {
@NonNls String REMOVE_WATCH = "Debugger.RemoveWatch";
@NonNls String NEW_WATCH = "Debugger.NewWatch";
@NonNls String EDIT_WATCH = "Debugger.EditWatch";
@NonNls String MARK_OBJECT = "Debugger.MarkObject";
@NonNls String COPY_VALUE = "Debugger.CopyValue";
@NonNls String SET_VALUE = "Debugger.SetValue";
@NonNls String EDIT_FRAME_SOURCE = "Debugger.EditFrameSource";
@@ -16,6 +16,7 @@
package com.intellij.debugger.actions;
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
import com.intellij.debugger.engine.DebugProcess;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.DebuggerUtils;
import com.intellij.debugger.engine.events.DebuggerContextCommandImpl;
@@ -26,17 +27,18 @@ import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl;
import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl;
import com.intellij.debugger.ui.tree.ValueDescriptor;
import com.intellij.xdebugger.impl.ui.tree.ValueMarkup;
import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.Ref;
import com.intellij.util.containers.HashMap;
import com.intellij.xdebugger.impl.actions.MarkObjectActionHandler;
import com.intellij.xdebugger.impl.ui.tree.ValueMarkup;
import com.sun.jdi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -51,14 +53,13 @@ import java.util.Map;
* Class SetValueAction
* @author Jeka
*/
public class MarkObjectAction extends DebuggerAction {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.actions.MarkObjectAction");
public class JavaMarkObjectActionHandler extends MarkObjectActionHandler {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.actions.JavaMarkObjectActionHandler");
public static final long AUTO_MARKUP_REFERRING_OBJECTS_LIMIT = 100L; // todo: some reasonable limit
private final String MARK_TEXT = ActionsBundle.message("action.Debugger.MarkObject.text");
private final String UNMARK_TEXT = ActionsBundle.message("action.Debugger.MarkObject.unmark.text");
public void actionPerformed(final AnActionEvent event) {
final DebuggerTreeNodeImpl node = getSelectedNode(event.getDataContext());
@Override
public void perform(@NotNull Project project, AnActionEvent event) {
final DebuggerTreeNodeImpl node = DebuggerAction.getSelectedNode(event.getDataContext());
if (node == null) {
return;
}
@@ -233,24 +234,27 @@ public class MarkObjectAction extends DebuggerAction {
return builder.append("<br><b>").append(refType.name()).append(".").append(fieldName).append("</b>").toString();
}
@Override
public boolean isEnabled(@NotNull Project project, AnActionEvent event) {
final DebuggerTreeNodeImpl node = DebuggerAction.getSelectedNode(event.getDataContext());
return node != null && node.getDescriptor() instanceof ValueDescriptor;
}
public void update(AnActionEvent e) {
boolean enable = false;
String text = MARK_TEXT;
final DebuggerTreeNodeImpl node = getSelectedNode(e.getDataContext());
if (node != null) {
final NodeDescriptorImpl descriptor = node.getDescriptor();
enable = (descriptor instanceof ValueDescriptor);
if (enable) {
final ValueMarkup markup = ((ValueDescriptor)descriptor).getMarkup(node.getTree().getDebuggerContext().getDebugProcess());
if (markup != null) { // already exists
text = UNMARK_TEXT;
}
}
}
final Presentation presentation = e.getPresentation();
presentation.setVisible(enable);
presentation.setText(text);
@Override
public boolean isHidden(@NotNull Project project, AnActionEvent event) {
return DebuggerAction.getSelectedNode(event.getDataContext()) == null;
}
@Override
public boolean isMarked(@NotNull Project project, @NotNull AnActionEvent event) {
final DebuggerTreeNodeImpl node = DebuggerAction.getSelectedNode(event.getDataContext());
if (node == null) return false;
final NodeDescriptorImpl descriptor = node.getDescriptor();
if (!(descriptor instanceof ValueDescriptor)) return false;
DebugProcess debugProcess = node.getTree().getDebuggerContext().getDebugProcess();
return ((ValueDescriptor)descriptor).getMarkup(debugProcess) != null;
}
public static Color getAutoMarkupColor() {
@@ -17,7 +17,7 @@ package com.intellij.debugger.actions;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.ui.ex.MultiLineLabel;
import com.intellij.xdebugger.impl.ui.tree.ValueMarkerPresentationDialog;
import com.intellij.xdebugger.impl.ui.tree.ValueMarkerPresentationDialogBase;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -28,7 +28,7 @@ import java.awt.*;
* @author Eugene Zhuravlev
* Date: Feb 4, 2007
*/
public class ObjectMarkupPropertiesDialog extends ValueMarkerPresentationDialog {
public class ObjectMarkupPropertiesDialog extends ValueMarkerPresentationDialogBase {
@NonNls private static final String MARK_ALL_REFERENCED_VALUES_KEY = "debugger.mark.all.referenced.values";
private JCheckBox myCbMarkAdditionalFields;
private final boolean mySuggestAdditionalMarkup;
@@ -29,8 +29,8 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.xdebugger.AbstractDebuggerSession;
import com.intellij.xdebugger.impl.DebuggerSupport;
import com.intellij.xdebugger.impl.actions.DebuggerActionHandler;
import com.intellij.xdebugger.impl.actions.DebuggerToggleActionHandler;
import com.intellij.xdebugger.impl.actions.*;
import com.intellij.xdebugger.impl.actions.MarkObjectActionHandler;
import com.intellij.xdebugger.impl.breakpoints.ui.AbstractBreakpointPanel;
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointPanelProvider;
import com.intellij.xdebugger.impl.evaluate.quick.common.QuickEvaluateHandler;
@@ -63,6 +63,7 @@ public class JavaDebuggerSupport extends DebuggerSupport {
private final MuteBreakpointsActionHandler myMuteBreakpointsHandler = new MuteBreakpointsActionHandler();
private final DebuggerActionHandler mySmartStepIntoHandler = new SmartStepIntoActionHandler();
private final DebuggerActionHandler myAddToWatchedActionHandler = new AddToWatchActionHandler();
private JavaMarkObjectActionHandler myMarkObjectActionHandler = new JavaMarkObjectActionHandler();
@NotNull
public BreakpointPanelProvider<?> getBreakpointPanelProvider() {
@@ -150,6 +151,12 @@ public class JavaDebuggerSupport extends DebuggerSupport {
return myMuteBreakpointsHandler;
}
@NotNull
@Override
public MarkObjectActionHandler getMarkObjectHandler() {
return myMarkObjectActionHandler;
}
@Override
public AbstractDebuggerSession getCurrentSession(@NotNull Project project) {
final DebuggerContextImpl context = (DebuggerManagerEx.getInstanceEx(project)).getContext();
@@ -19,7 +19,6 @@
*/
package com.intellij.debugger.ui.impl;
import com.intellij.debugger.actions.DebuggerActions;
import com.intellij.debugger.impl.DebuggerSession;
import com.intellij.debugger.impl.DebuggerStateManager;
import com.intellij.debugger.ui.impl.watch.DebuggerTree;
@@ -30,6 +29,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.wm.ex.IdeFocusTraversalPolicy;
import com.intellij.ui.PopupHandler;
import com.intellij.xdebugger.impl.actions.XDebuggerActions;
import javax.swing.*;
import java.awt.*;
@@ -68,7 +68,7 @@ public abstract class DebuggerTreePanel extends UpdatableDebuggerView implements
final Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts("ToggleBookmark");
final CustomShortcutSet shortcutSet = shortcuts.length > 0? new CustomShortcutSet(shortcuts) : new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0));
overrideShortcut(myTree, DebuggerActions.MARK_OBJECT, shortcutSet);
overrideShortcut(myTree, XDebuggerActions.MARK_OBJECT, shortcutSet);
}
protected abstract DebuggerTree createTreeView();