mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
watches toolbar using ToolbarDecorator
This commit is contained in:
@@ -151,11 +151,6 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
|
||||
XDebuggerUIConstants.WATCHES_TAB_ICON, null);
|
||||
watches.setCloseable(false);
|
||||
watches.setAlertIcon(breakpointAlert);
|
||||
final DefaultActionGroup watchesGroup = new DefaultActionGroup();
|
||||
addAction(watchesGroup, DebuggerActions.NEW_WATCH);
|
||||
addAction(watchesGroup, XDebuggerActions.ADD_TO_WATCH);
|
||||
addAction(watchesGroup, DebuggerActions.REMOVE_WATCH);
|
||||
watches.setActions(watchesGroup, ActionPlaces.DEBUGGER_TOOLBAR, myWatchPanel.getTree());
|
||||
myUi.addContent(watches, 0, PlaceInGrid.right, false);
|
||||
|
||||
// frames
|
||||
|
||||
@@ -20,20 +20,20 @@
|
||||
*/
|
||||
package com.intellij.debugger.ui.impl;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.actions.AddToWatchActionHandler;
|
||||
import com.intellij.debugger.actions.DebuggerActions;
|
||||
import com.intellij.debugger.engine.evaluation.CodeFragmentKind;
|
||||
import com.intellij.debugger.engine.evaluation.DefaultCodeFragmentFactory;
|
||||
import com.intellij.debugger.engine.evaluation.TextWithImports;
|
||||
import com.intellij.debugger.engine.evaluation.TextWithImportsImpl;
|
||||
import com.intellij.debugger.engine.evaluation.DefaultCodeFragmentFactory;
|
||||
import com.intellij.debugger.impl.DebuggerContextImpl;
|
||||
import com.intellij.debugger.impl.DebuggerStateManager;
|
||||
import com.intellij.debugger.impl.PositionUtil;
|
||||
import com.intellij.debugger.ui.DebuggerExpressionComboBox;
|
||||
import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
|
||||
import com.intellij.debugger.ui.impl.watch.DebuggerTreeInplaceEditor;
|
||||
import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
|
||||
import com.intellij.debugger.ui.impl.watch.WatchItemDescriptor;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.dnd.DnDEvent;
|
||||
import com.intellij.ide.dnd.DnDManager;
|
||||
@@ -43,7 +43,10 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.AnActionButton;
|
||||
import com.intellij.ui.AnActionButtonRunnable;
|
||||
import com.intellij.ui.ListenerUtil;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -205,4 +208,35 @@ public class MainWatchPanel extends WatchPanel implements DataProvider {
|
||||
};
|
||||
editor.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createTreePanel(final WatchDebuggerTree tree) {
|
||||
final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(tree);
|
||||
decorator.setAddAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
executeAction(DebuggerActions.NEW_WATCH, tree);
|
||||
}
|
||||
});
|
||||
// TODO[den]: add "Add to watches action"
|
||||
decorator.setRemoveAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
executeAction(DebuggerActions.REMOVE_WATCH, tree);
|
||||
}
|
||||
});
|
||||
final JPanel panel = decorator.createPanel();
|
||||
panel.setBorder(null);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private static void executeAction(final String watch, final WatchDebuggerTree tree) {
|
||||
AnAction action = ActionManager.getInstance().getAction(watch);
|
||||
Presentation presentation = action.getTemplatePresentation().clone();
|
||||
DataContext context = DataManager.getInstance().getDataContext(tree);
|
||||
|
||||
AnActionEvent actionEvent =
|
||||
new AnActionEvent(null, context, ActionPlaces.DEBUGGER_TOOLBAR, presentation, ActionManager.getInstance(), 0);
|
||||
action.actionPerformed(actionEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Enumeration;
|
||||
|
||||
@@ -43,11 +44,15 @@ public abstract class WatchPanel extends DebuggerTreePanel {
|
||||
|
||||
public WatchPanel(Project project, DebuggerStateManager stateManager) {
|
||||
super(project, stateManager);
|
||||
add(ScrollPaneFactory.createScrollPane(getWatchTree()), BorderLayout.CENTER);
|
||||
add(createTreePanel(getWatchTree()), BorderLayout.CENTER);
|
||||
registerDisposable(DebuggerAction.installEditAction(getWatchTree(), DebuggerActions.EDIT_NODE_SOURCE));
|
||||
overrideShortcut(getWatchTree(), DebuggerActions.COPY_VALUE, CommonShortcuts.getCopy());
|
||||
}
|
||||
|
||||
protected JComponent createTreePanel(final WatchDebuggerTree tree) {
|
||||
return ScrollPaneFactory.createScrollPane(tree);
|
||||
}
|
||||
|
||||
protected DebuggerTree createTreeView() {
|
||||
return new WatchDebuggerTree(getProject());
|
||||
}
|
||||
|
||||
@@ -15,13 +15,15 @@
|
||||
*/
|
||||
package com.intellij.xdebugger.impl.frame;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.dnd.DnDEvent;
|
||||
import com.intellij.ide.dnd.DnDManager;
|
||||
import com.intellij.ide.dnd.DnDNativeTarget;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.CommonShortcuts;
|
||||
import com.intellij.openapi.actionSystem.CustomShortcutSet;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.ui.AnActionButton;
|
||||
import com.intellij.ui.AnActionButtonRunnable;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
@@ -56,6 +58,7 @@ public class XWatchesView extends XDebugViewBase implements DnDNativeTarget {
|
||||
private XDebuggerTreeRestorer myTreeRestorer;
|
||||
private final WatchesRootNode myRootNode;
|
||||
private final XDebugSessionData mySessionData;
|
||||
private final JPanel myDecoratedPanel;
|
||||
|
||||
public XWatchesView(final XDebugSession session, final Disposable parentDisposable, final XDebugSessionData sessionData) {
|
||||
super(session, parentDisposable);
|
||||
@@ -76,10 +79,36 @@ public class XWatchesView extends XDebugViewBase implements DnDNativeTarget {
|
||||
myRootNode = new WatchesRootNode(tree, sessionData.getWatchExpressions());
|
||||
tree.setRoot(myRootNode, false);
|
||||
|
||||
final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTreePanel.getTree()).disableUpDownActions();
|
||||
decorator.setAddAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
executeAction(XDebuggerActions.XNEW_WATCH);
|
||||
}
|
||||
});
|
||||
decorator.setRemoveAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
executeAction(XDebuggerActions.XREMOVE_WATCH);
|
||||
}
|
||||
});
|
||||
myDecoratedPanel = decorator.createPanel();
|
||||
myDecoratedPanel.setBorder(null);
|
||||
|
||||
myTreePanel.getTree().getEmptyText().setText(XDebuggerBundle.message("debugger.no.watches"));
|
||||
|
||||
}
|
||||
|
||||
private void executeAction(final String watch) {
|
||||
AnAction action = ActionManager.getInstance().getAction(watch);
|
||||
Presentation presentation = action.getTemplatePresentation().clone();
|
||||
DataContext context = DataManager.getInstance().getDataContext(myTreePanel.getTree());
|
||||
|
||||
AnActionEvent actionEvent =
|
||||
new AnActionEvent(null, context, ActionPlaces.DEBUGGER_TOOLBAR, presentation, ActionManager.getInstance(), 0);
|
||||
action.actionPerformed(actionEvent);
|
||||
}
|
||||
|
||||
public void addWatchExpression(@NotNull String expression, int index, final boolean navigateToWatchNode) {
|
||||
XDebuggerEvaluator evaluator = null;
|
||||
XStackFrame stackFrame = mySession.getCurrentStackFrame();
|
||||
@@ -128,7 +157,7 @@ public class XWatchesView extends XDebugViewBase implements DnDNativeTarget {
|
||||
}
|
||||
|
||||
public JPanel getMainPanel() {
|
||||
return myTreePanel.getMainPanel();
|
||||
return myDecoratedPanel;
|
||||
}
|
||||
|
||||
public void removeWatches(final List<? extends XDebuggerTreeNode> nodes) {
|
||||
|
||||
@@ -97,8 +97,6 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
|
||||
XDebuggerBundle.message("debugger.session.tab.watches.title"), XDebuggerUIConstants.WATCHES_TAB_ICON, null);
|
||||
watchesContent.setCloseable(false);
|
||||
|
||||
ActionGroup group = getActionGroup(XDebuggerActions.WATCHES_TREE_TOOLBAR_GROUP);
|
||||
watchesContent.setActions(group, ActionPlaces.DEBUGGER_TOOLBAR, myWatchesView.getTree());
|
||||
return watchesContent;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user