made variables toolbar customizable

This commit is contained in:
Egor.Ushakov
2016-08-11 11:09:10 +03:00
parent 1dcfea3f42
commit 4a70b0879f
11 changed files with 209 additions and 77 deletions
@@ -1027,6 +1027,10 @@ action.XDebugger.RemoveWatch.text=Remove Watch
action.XDebugger.RemoveAllWatches.text=Remove All Watches
action.XDebugger.NewWatch.text=New Watch...
action.XDebugger.EditWatch.text=Edit...
action.XDebugger.CopyWatch.text=Duplicate Watch
action.XDebugger.MoveWatchUp.text=Move Watch Up
action.XDebugger.MoveWatchDown.text=Move Watch Down
action.XDebugger.SwitchWatchesInVariables.text=Show watches in variables tab
action.XDebugger.AutoTooltip.text=Value auto tooltip
action.XDebugger.AutoTooltip.description=Toggles if value tooltip is shown automatically on mouse over
action.XDebugger.Inline.text=Show Values Inline
@@ -111,7 +111,6 @@ stack.frame.loading.text=Loading\u2026
invalid.frame=<invalid frame>
xdebugger.drag.text.0.elements={0} elements
xdebugger.drop.text.add.to.watches=Add to watches
debugger.session.tab.show.watches.in.variables=Show watches in variables tab
debugger.frames.not.available=Frames are not available
debugger.threads.not.available=Threads are not available
@@ -738,6 +738,14 @@
text="Duplicate Watch" use-shortcut-of="EditorDuplicate"/>
<action id="XDebugger.RemoveWatch" class="com.intellij.xdebugger.impl.frame.actions.XRemoveWatchAction" icon="AllIcons.Actions.Delete"
use-shortcut-of="$Delete"/>
<action id="XDebugger.MoveWatchUp" class="com.intellij.xdebugger.impl.frame.actions.XMoveWatchUp">
<keyboard-shortcut keymap="$default" first-keystroke="alt UP"/>
</action>
<action id="XDebugger.MoveWatchDown" class="com.intellij.xdebugger.impl.frame.actions.XMoveWatchDown">
<keyboard-shortcut keymap="$default" first-keystroke="alt DOWN"/>
</action>
<action id="XDebugger.SwitchWatchesInVariables" class="com.intellij.xdebugger.impl.frame.actions.XSwitchWatchesInVariables"
icon="AllIcons.Debugger.Watches"/>
<action id="XDebugger.RemoveAllWatches" class="com.intellij.xdebugger.impl.frame.actions.XRemoveAllWatchesAction"/>
<action id="XDebugger.MuteBreakpoints" class="com.intellij.xdebugger.impl.actions.MuteBreakpointAction"
icon="AllIcons.Debugger.MuteBreakpoints"/>
@@ -817,6 +825,10 @@
<group id="XDebugger.Watches.Tree.Toolbar">
<reference ref="XDebugger.NewWatch"/>
<reference ref="XDebugger.RemoveWatch"/>
<reference ref="XDebugger.MoveWatchUp"/>
<reference ref="XDebugger.MoveWatchDown"/>
<reference ref="XDebugger.CopyWatch"/>
<reference ref="XDebugger.SwitchWatchesInVariables"/>
</group>
<group id="XDebugger.Inspect.Tree.Popup">
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@ package com.intellij.xdebugger.impl.frame;
import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.xdebugger.XExpression;
import com.intellij.xdebugger.impl.ui.tree.nodes.WatchNode;
import com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode;
import org.jetbrains.annotations.NotNull;
@@ -15,7 +15,6 @@
*/
package com.intellij.xdebugger.impl.frame;
import com.intellij.icons.AllIcons;
import com.intellij.ide.DataManager;
import com.intellij.ide.dnd.DnDEvent;
import com.intellij.ide.dnd.DnDManager;
@@ -23,11 +22,14 @@ import com.intellij.ide.dnd.DnDNativeTarget;
import com.intellij.openapi.CompositeDisposable;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl;
import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.EmptyRunnable;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.ui.*;
import com.intellij.ui.CaptionPanel;
import com.intellij.ui.ClickListener;
import com.intellij.ui.DoubleClickListener;
import com.intellij.ui.ListenerUtil;
import com.intellij.ui.border.CustomLineBorder;
import com.intellij.util.Alarm;
import com.intellij.util.containers.ContainerUtil;
@@ -40,7 +42,7 @@ import com.intellij.xdebugger.frame.XStackFrame;
import com.intellij.xdebugger.impl.XDebugSessionImpl;
import com.intellij.xdebugger.impl.actions.XDebuggerActions;
import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl;
import com.intellij.xdebugger.impl.frame.actions.XWatchesTreeActionBase;
import com.intellij.xdebugger.impl.ui.DebuggerSessionTabBase;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import com.intellij.xdebugger.impl.ui.XDebugSessionData;
import com.intellij.xdebugger.impl.ui.XDebugSessionTab;
@@ -57,7 +59,10 @@ import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.event.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -75,8 +80,6 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget,
super(session);
myWatchesInVariables = watchesInVariables;
ActionManager actionManager = ActionManager.getInstance();
XDebuggerTree tree = getTree();
createNewRootNode(null);
@@ -101,74 +104,18 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget,
}
}.registerCustomShortcutSet(CommonShortcuts.getPaste(), tree, myDisposables);
ToolbarDecorator decorator = ToolbarDecorator.createDecorator(getTree());
ActionToolbarImpl toolbar = (ActionToolbarImpl)ActionManager.getInstance().createActionToolbar(
ActionPlaces.DEBUGGER_TOOLBAR,
DebuggerSessionTabBase.getCustomizedActionGroup(XDebuggerActions.WATCHES_TREE_TOOLBAR_GROUP),
!myWatchesInVariables);
toolbar.setBorder(new CustomLineBorder(CaptionPanel.CNT_ACTIVE_BORDER_COLOR, 0, 0,
myWatchesInVariables ? 0 : 1,
myWatchesInVariables ? 1 : 0));
decorator.setAddAction(button -> executeAction(XDebuggerActions.XNEW_WATCH));
decorator.setAddIcon(AllIcons.Debugger.NewWatch);
decorator.setAddActionName(actionManager.getAction(XDebuggerActions.XNEW_WATCH).getTemplatePresentation().getText());
AnAction removeWatchAction = actionManager.getAction(XDebuggerActions.XREMOVE_WATCH);
decorator.setRemoveAction(button -> executeAction(XDebuggerActions.XREMOVE_WATCH));
decorator.setRemoveActionName(removeWatchAction.getTemplatePresentation().getText());
decorator.setRemoveActionUpdater(e -> {
removeWatchAction.update(e);
return e.getPresentation().isEnabled();
});
decorator.addExtraAction(AnActionButton.fromAction(actionManager.getAction(XDebuggerActions.XCOPY_WATCH)));
decorator.addExtraAction(
new ToggleActionButton(XDebuggerBundle.message("debugger.session.tab.show.watches.in.variables"), AllIcons.Debugger.Watches) {
@Override
public boolean isSelected(AnActionEvent e) {
XDebugSessionTab tab = session.getSessionTab();
return tab == null || tab.isWatchesInVariables();
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
XDebugSessionTab tab = session.getSessionTab();
if (tab != null) {
tab.setWatchesInVariables(!tab.isWatchesInVariables());
}
}
});
decorator.setMoveUpAction(button -> {
List<? extends WatchNode> nodes = XWatchesTreeActionBase.getSelectedNodes(getTree(), WatchNode.class);
assert nodes.size() == 1;
myRootNode.moveUp(nodes.get(0));
updateSessionData();
});
decorator.setMoveUpActionUpdater(e -> {
List<? extends WatchNode> nodes = XWatchesTreeActionBase.getSelectedNodes(getTree(), WatchNode.class);
if (nodes.size() != 1) return false;
return myRootNode.getIndex(nodes.get(0)) > 0;
});
decorator.setMoveUpActionName("Move Watch Up");
decorator.setMoveDownAction(button -> {
List<? extends WatchNode> nodes = XWatchesTreeActionBase.getSelectedNodes(getTree(), WatchNode.class);
assert nodes.size() == 1;
myRootNode.moveDown(nodes.get(0));
updateSessionData();
});
decorator.setMoveDownActionUpdater(e -> {
List<? extends WatchNode> nodes = XWatchesTreeActionBase.getSelectedNodes(getTree(), WatchNode.class);
if (nodes.size() != 1) return false;
return myRootNode.getIndex(nodes.get(0)) < myRootNode.getWatchChildren().size() - 1;
});
decorator.setMoveDownActionName("Move Watch Down");
CustomLineBorder border = new CustomLineBorder(CaptionPanel.CNT_ACTIVE_BORDER_COLOR,
SystemInfo.isMac ? 1 : 0, 0,
SystemInfo.isMac ? 0 : 1, 0);
decorator.setToolbarBorder(border);
decorator.setPanelBorder(BorderFactory.createEmptyBorder());
getPanel().removeAll();
if (myWatchesInVariables) {
decorator.setToolbarPosition(ActionToolbarPosition.LEFT);
}
else {
if (!myWatchesInVariables) {
getTree().getEmptyText().setText(XDebuggerBundle.message("debugger.no.watches"));
}
getPanel().add(decorator.createPanel());
getPanel().add(toolbar.getComponent(), myWatchesInVariables ? BorderLayout.WEST : BorderLayout.NORTH);
installEditListeners();
}
@@ -362,6 +309,16 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget,
updateSessionData();
}
public void moveWatchUp(WatchNode node) {
myRootNode.moveUp(node);
updateSessionData();
}
public void moveWatchDown(WatchNode node) {
myRootNode.moveDown(node);
updateSessionData();
}
public void updateSessionData() {
List<XExpression> watchExpressions = ContainerUtil.newArrayList();
List<? extends WatchNode> children = myRootNode.getWatchChildren();
@@ -0,0 +1,56 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.xdebugger.impl.frame.actions;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.ui.CommonActionsPanel;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xdebugger.impl.frame.XWatchesView;
import com.intellij.xdebugger.impl.frame.XWatchesViewImpl;
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
import com.intellij.xdebugger.impl.ui.tree.nodes.WatchNodeImpl;
import com.intellij.xdebugger.impl.ui.tree.nodes.WatchesRootNode;
import com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author egor
*/
public class XMoveWatchDown extends XWatchesTreeActionBase {
public XMoveWatchDown() {
getTemplatePresentation().setIcon(CommonActionsPanel.Buttons.DOWN.getIcon());
}
protected boolean isEnabled(@NotNull AnActionEvent e, @NotNull XDebuggerTree tree) {
List<? extends WatchNodeImpl> nodes = getSelectedNodes(tree, WatchNodeImpl.class);
if (nodes.size() == 1) {
XDebuggerTreeNode root = tree.getRoot();
if (root instanceof WatchesRootNode) {
return root.getIndex(nodes.get(0)) < ((WatchesRootNode)root).getWatchChildren().size() - 1;
}
}
return false;
}
@Override
protected void perform(@NotNull AnActionEvent e, @NotNull XDebuggerTree tree, @NotNull XWatchesView watchesView) {
if (watchesView instanceof XWatchesViewImpl) {
((XWatchesViewImpl)watchesView).moveWatchDown(ContainerUtil.getFirstItem(getSelectedNodes(tree, WatchNodeImpl.class)));
}
}
}
@@ -0,0 +1,56 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.xdebugger.impl.frame.actions;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.ui.CommonActionsPanel;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xdebugger.impl.frame.XWatchesView;
import com.intellij.xdebugger.impl.frame.XWatchesViewImpl;
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
import com.intellij.xdebugger.impl.ui.tree.nodes.WatchNodeImpl;
import com.intellij.xdebugger.impl.ui.tree.nodes.WatchesRootNode;
import com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author egor
*/
public class XMoveWatchUp extends XWatchesTreeActionBase {
public XMoveWatchUp() {
getTemplatePresentation().setIcon(CommonActionsPanel.Buttons.UP.getIcon());
}
protected boolean isEnabled(@NotNull AnActionEvent e, @NotNull XDebuggerTree tree) {
List<? extends WatchNodeImpl> nodes = getSelectedNodes(tree, WatchNodeImpl.class);
if (nodes.size() == 1) {
XDebuggerTreeNode root = tree.getRoot();
if (root instanceof WatchesRootNode) {
return root.getIndex(nodes.get(0)) > 0;
}
}
return false;
}
@Override
protected void perform(@NotNull AnActionEvent e, @NotNull XDebuggerTree tree, @NotNull XWatchesView watchesView) {
if (watchesView instanceof XWatchesViewImpl) {
((XWatchesViewImpl)watchesView).moveWatchUp(ContainerUtil.getFirstItem(getSelectedNodes(tree, WatchNodeImpl.class)));
}
}
}
@@ -15,6 +15,7 @@
*/
package com.intellij.xdebugger.impl.frame.actions;
import com.intellij.openapi.actionSystem.ActionPlaces;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.xdebugger.impl.frame.XWatchesView;
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
@@ -30,7 +31,13 @@ public class XRemoveWatchAction extends XWatchesTreeActionBase {
@Override
public void update(AnActionEvent e) {
XDebuggerTree tree = XDebuggerTree.getTree(e);
e.getPresentation().setEnabledAndVisible(tree != null && !getSelectedNodes(tree, WatchNodeImpl.class).isEmpty());
boolean enabled = tree != null && !getSelectedNodes(tree, WatchNodeImpl.class).isEmpty();
if (ActionPlaces.DEBUGGER_TOOLBAR.equals(e.getPlace())) {
e.getPresentation().setEnabled(enabled);
}
else {
e.getPresentation().setEnabledAndVisible(enabled);
}
}
@Override
@@ -0,0 +1,39 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.xdebugger.impl.frame.actions;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.xdebugger.impl.ui.XDebugSessionTab;
/**
* @author egor
*/
public class XSwitchWatchesInVariables extends ToggleAction {
@Override
public boolean isSelected(AnActionEvent e) {
XDebugSessionTab tab = e.getData(XDebugSessionTab.TAB_KEY);
return tab == null || tab.isWatchesInVariables();
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
XDebugSessionTab tab = e.getData(XDebugSessionTab.TAB_KEY);
if (tab != null) {
tab.setWatchesInVariables(!tab.isWatchesInVariables());
}
}
}
@@ -56,7 +56,7 @@ public abstract class DebuggerSessionTabBase extends RunTab {
.initFocusContent(DebuggerContentInfo.CONSOLE_CONTENT, LayoutViewOptions.STARTUP, new LayoutAttractionPolicy.FocusOnce(false));
}
protected static ActionGroup getCustomizedActionGroup(final String id) {
public static ActionGroup getCustomizedActionGroup(final String id) {
return (ActionGroup)CustomActionsSchema.getInstance().getCorrectedAction(id);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,5 +26,6 @@ public class XDebugTabCustomizableActionGroupProvider extends CustomizableAction
public void registerGroups(CustomizableActionGroupRegistrar registrar) {
registrar.addCustomizableActionGroup(XDebuggerActions.TOOL_WINDOW_TOP_TOOLBAR_GROUP, "Debug Tool Window Top Toolbar");
registrar.addCustomizableActionGroup(XDebuggerActions.TOOL_WINDOW_LEFT_TOOLBAR_GROUP, "Debug Tool Window Left Toolbar");
registrar.addCustomizableActionGroup(XDebuggerActions.WATCHES_TREE_TOOLBAR_GROUP, "Debug Watches Toolbar");
}
}