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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user