mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 06:05:01 +07:00
IDEA-84683: Make debugger actions toolbar configurable
This commit is contained in:
@@ -119,21 +119,13 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
|
||||
});
|
||||
}
|
||||
|
||||
DefaultActionGroup stepping = new DefaultActionGroup();
|
||||
DefaultActionGroup topToolbar = new DefaultActionGroup();
|
||||
ActionManager actionManager = ActionManager.getInstance();
|
||||
stepping.add(actionManager.getAction(DebuggerActions.SHOW_EXECUTION_POINT));
|
||||
stepping.addSeparator();
|
||||
stepping.add(actionManager.getAction(DebuggerActions.STEP_OVER));
|
||||
stepping.add(actionManager.getAction(DebuggerActions.STEP_INTO));
|
||||
stepping.add(actionManager.getAction(DebuggerActions.FORCE_STEP_INTO));
|
||||
stepping.add(actionManager.getAction(DebuggerActions.STEP_OUT));
|
||||
stepping.addSeparator();
|
||||
stepping.add(actionManager.getAction(DebuggerActions.POP_FRAME));
|
||||
stepping.addSeparator();
|
||||
stepping.add(actionManager.getAction(DebuggerActions.RUN_TO_CURSOR));
|
||||
stepping.addSeparator();
|
||||
stepping.add(actionManager.getAction(DebuggerActions.EVALUATE_EXPRESSION));
|
||||
myUi.getOptions().setTopToolbar(stepping, ActionPlaces.DEBUGGER_TOOLBAR);
|
||||
topToolbar.addAll(getCustomizedActionGroup(XDebuggerActions.TOOL_WINDOW_TOP_TOOLBAR_GROUP));
|
||||
topToolbar.add(actionManager.getAction(DebuggerActions.POP_FRAME), new Constraints(Anchor.AFTER, XDebuggerActions.STEP_OUT));
|
||||
topToolbar.add(Separator.getInstance(), new Constraints(Anchor.BEFORE, DebuggerActions.POP_FRAME));
|
||||
topToolbar.add(Separator.getInstance(), new Constraints(Anchor.AFTER, DebuggerActions.POP_FRAME));
|
||||
myUi.getOptions().setTopToolbar(topToolbar, ActionPlaces.DEBUGGER_TOOLBAR);
|
||||
|
||||
|
||||
myWatchPanel = new MainWatchPanel(getProject(), getContextManager());
|
||||
@@ -258,38 +250,34 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
|
||||
|
||||
myDebugUIEnvironment.initLogs(myRunContentDescriptor, getLogManager());
|
||||
|
||||
DefaultActionGroup group = new DefaultActionGroup();
|
||||
DefaultActionGroup leftToolbar = new DefaultActionGroup();
|
||||
|
||||
if (executionResult instanceof DefaultExecutionResult) {
|
||||
final AnAction[] actions = ((DefaultExecutionResult)executionResult).getRestartActions();
|
||||
if (actions != null) {
|
||||
group.addAll(actions);
|
||||
leftToolbar.addAll(actions);
|
||||
if (actions.length > 0) {
|
||||
group.addSeparator();
|
||||
leftToolbar.addSeparator();
|
||||
}
|
||||
}
|
||||
}
|
||||
final AnAction[] profileActions = executionResult.getActions();
|
||||
group.addAll(profileActions);
|
||||
leftToolbar.addAll(profileActions);
|
||||
|
||||
addActionToGroup(group, XDebuggerActions.RESUME);
|
||||
addActionToGroup(group, XDebuggerActions.PAUSE);
|
||||
addActionToGroup(group, IdeActions.ACTION_STOP_PROGRAM);
|
||||
leftToolbar.add(getCustomizedActionGroup(XDebuggerActions.TOOL_WINDOW_LEFT_TOOLBAR_GROUP));
|
||||
if (executionResult instanceof DefaultExecutionResult) {
|
||||
group.addAll(((DefaultExecutionResult)executionResult).getAdditionalStopActions());
|
||||
AnAction[] actions = ((DefaultExecutionResult)executionResult).getAdditionalStopActions();
|
||||
for (AnAction action : actions) {
|
||||
leftToolbar.add(action, new Constraints(Anchor.AFTER, IdeActions.ACTION_STOP_PROGRAM));
|
||||
}
|
||||
}
|
||||
|
||||
group.addSeparator();
|
||||
leftToolbar.addSeparator();
|
||||
addAction(leftToolbar, DebuggerActions.EXPORT_THREADS);
|
||||
addAction(leftToolbar, DebuggerActions.DUMP_THREADS);
|
||||
leftToolbar.addSeparator();
|
||||
|
||||
addActionToGroup(group, XDebuggerActions.VIEW_BREAKPOINTS);
|
||||
addActionToGroup(group, XDebuggerActions.MUTE_BREAKPOINTS);
|
||||
|
||||
group.addSeparator();
|
||||
addAction(group, DebuggerActions.EXPORT_THREADS);
|
||||
addAction(group, DebuggerActions.DUMP_THREADS);
|
||||
group.addSeparator();
|
||||
|
||||
group.add(myUi.getOptions().getLayoutActions());
|
||||
leftToolbar.add(myUi.getOptions().getLayoutActions());
|
||||
|
||||
final AnAction[] commonSettings = myUi.getOptions().getSettingsActionsList();
|
||||
final AnAction commonSettingsList = myUi.getOptions().getSettingsActions();
|
||||
@@ -317,15 +305,15 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
|
||||
settings.addSeparator();
|
||||
addActionToGroup(settings, XDebuggerActions.AUTO_TOOLTIP);
|
||||
|
||||
group.add(settings);
|
||||
leftToolbar.add(settings);
|
||||
|
||||
group.addSeparator();
|
||||
leftToolbar.addSeparator();
|
||||
|
||||
addActionToGroup(group, PinToolwindowTabAction.ACTION_NAME);
|
||||
addActionToGroup(leftToolbar, PinToolwindowTabAction.ACTION_NAME);
|
||||
|
||||
myDebugUIEnvironment.initActions(myRunContentDescriptor, group);
|
||||
myDebugUIEnvironment.initActions(myRunContentDescriptor, leftToolbar);
|
||||
|
||||
myUi.getOptions().setLeftToolbar(group, ActionPlaces.DEBUGGER_TOOLBAR);
|
||||
myUi.getOptions().setLeftToolbar(leftToolbar, ActionPlaces.DEBUGGER_TOOLBAR);
|
||||
|
||||
return myRunContentDescriptor;
|
||||
}
|
||||
|
||||
+24
-14
@@ -63,8 +63,12 @@ public class CustomActionsSchema implements ExportableComponent, NamedJDOMExtern
|
||||
|
||||
private final HashMap<String , ActionGroup> myIdToActionGroup = new HashMap<String, ActionGroup>();
|
||||
|
||||
private static final List<Pair> myIdToNameList = new ArrayList<Pair>();
|
||||
static {
|
||||
private final List<Pair> myIdToNameList = new ArrayList<Pair>();
|
||||
|
||||
@NonNls private static final String GROUP = "group";
|
||||
private static final Logger LOG = Logger.getInstance("#" + CustomActionsSchema.class.getName());
|
||||
|
||||
public CustomActionsSchema() {
|
||||
myIdToNameList.add(new Pair(IdeActions.GROUP_MAIN_MENU, ActionsTreeUtil.MAIN_MENU_TITLE));
|
||||
myIdToNameList.add(new Pair(IdeActions.GROUP_MAIN_TOOLBAR, ActionsTreeUtil.MAIN_TOOLBAR));
|
||||
myIdToNameList.add(new Pair(IdeActions.GROUP_EDITOR_POPUP, ActionsTreeUtil.EDITOR_POPUP));
|
||||
@@ -76,10 +80,18 @@ public class CustomActionsSchema implements ExportableComponent, NamedJDOMExtern
|
||||
myIdToNameList.add(new Pair(IdeActions.GROUP_COMMANDER_POPUP, ActionsTreeUtil.COMMANDER_POPUP));
|
||||
myIdToNameList.add(new Pair(IdeActions.GROUP_J2EE_VIEW_POPUP, ActionsTreeUtil.J2EE_POPUP));
|
||||
myIdToNameList.add(new Pair(IdeActions.GROUP_NAVBAR_POPUP, "Navigation Bar"));
|
||||
}
|
||||
|
||||
@NonNls private static final String GROUP = "group";
|
||||
private static final Logger LOG = Logger.getInstance("#" + CustomActionsSchema.class.getName());
|
||||
CustomizableActionGroupProvider.CustomizableActionGroupRegistrar registrar =
|
||||
new CustomizableActionGroupProvider.CustomizableActionGroupRegistrar() {
|
||||
@Override
|
||||
public void addCustomizableActionGroup(@NotNull String groupId, @NotNull String groupTitle) {
|
||||
myIdToNameList.add(new Pair(groupId, groupTitle));
|
||||
}
|
||||
};
|
||||
for (CustomizableActionGroupProvider provider : CustomizableActionGroupProvider.EP_NAME.getExtensions()) {
|
||||
provider.registerGroups(registrar);
|
||||
}
|
||||
}
|
||||
|
||||
public static CustomActionsSchema getInstance() {
|
||||
return ServiceManager.getService(CustomActionsSchema.class);
|
||||
@@ -199,7 +211,7 @@ public class CustomActionsSchema implements ExportableComponent, NamedJDOMExtern
|
||||
}
|
||||
}
|
||||
|
||||
public static void fillActionGroups(DefaultMutableTreeNode root){
|
||||
public void fillActionGroups(DefaultMutableTreeNode root){
|
||||
final ActionManager actionManager = ActionManager.getInstance();
|
||||
for (Pair pair : myIdToNameList) {
|
||||
final ActionGroup actionGroup = (ActionGroup)actionManager.getAction(pair.first);
|
||||
@@ -210,23 +222,21 @@ public class CustomActionsSchema implements ExportableComponent, NamedJDOMExtern
|
||||
}
|
||||
|
||||
|
||||
public boolean isCorrectActionGroup(ActionGroup group) {
|
||||
public boolean isCorrectActionGroup(ActionGroup group, String defaultGroupName) {
|
||||
if (myActions.isEmpty()){
|
||||
return false;
|
||||
}
|
||||
if (group.getTemplatePresentation() != null &&
|
||||
group.getTemplatePresentation().getText() != null) {
|
||||
|
||||
final String text = group.getTemplatePresentation().getText();
|
||||
|
||||
final String text = group.getTemplatePresentation().getText();
|
||||
if (text != null) {
|
||||
for (ActionUrl url : myActions) {
|
||||
if (url.getGroupPath().contains(text)) {
|
||||
if (url.getGroupPath().contains(text) || url.getGroupPath().contains(defaultGroupName)) {
|
||||
return true;
|
||||
}
|
||||
if (url.getComponent() instanceof Group) {
|
||||
final Group urlGroup = (Group)url.getComponent();
|
||||
String id = urlGroup.getName() != null ? urlGroup.getName() : urlGroup.getId();
|
||||
if (id == null || id.equals(text)) {
|
||||
if (id == null || id.equals(text) || id.equals(defaultGroupName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -256,7 +266,7 @@ public class CustomActionsSchema implements ExportableComponent, NamedJDOMExtern
|
||||
return result;
|
||||
}
|
||||
|
||||
public void removeIconCustomization(String actionId) {
|
||||
public void removeIconCustomization(String actionId) {
|
||||
myIconCustomizations.remove(actionId);
|
||||
}
|
||||
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.ide.ui.customization;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This extension allows to add an action group to the list of customizable actions in Settings | Menus and Toolbars.
|
||||
* Use {@code CustomActionsSchema.getInstance().getCorrectedAction(id)} to get customized version of a group.
|
||||
*
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class CustomizableActionGroupProvider {
|
||||
public static final ExtensionPointName<CustomizableActionGroupProvider> EP_NAME = ExtensionPointName.create("com.intellij.customizableActionGroupProvider");
|
||||
|
||||
public abstract void registerGroups(CustomizableActionGroupRegistrar registrar);
|
||||
|
||||
public interface CustomizableActionGroupRegistrar {
|
||||
void addCustomizableActionGroup(@NotNull String groupId, @NotNull String groupTitle);
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class CustomizationUtil {
|
||||
}
|
||||
|
||||
public static ActionGroup correctActionGroup(final ActionGroup group, final CustomActionsSchema schema, final String defaultGroupName) {
|
||||
if (!schema.isCorrectActionGroup(group)){
|
||||
if (!schema.isCorrectActionGroup(group, defaultGroupName)){
|
||||
return group;
|
||||
}
|
||||
String text = group.getTemplatePresentation().getText();
|
||||
@@ -161,7 +161,7 @@ public class CustomizationUtil {
|
||||
Group rootGroup = new Group("root", null, null);
|
||||
DefaultMutableTreeNode root = new DefaultMutableTreeNode(rootGroup);
|
||||
root.removeAllChildren();
|
||||
CustomActionsSchema.fillActionGroups(root);
|
||||
schema.fillActionGroups(root);
|
||||
final JTree defaultTree = new Tree(new DefaultTreeModel(root));
|
||||
|
||||
final ArrayList<ActionUrl> actions = new ArrayList<ActionUrl>();
|
||||
|
||||
@@ -112,6 +112,8 @@
|
||||
<extensionPoint name="fileIconPatcher" interface="com.intellij.ide.FileIconPatcher"/>
|
||||
<extensionPoint name="iconLayerProvider" interface="com.intellij.ide.IconLayerProvider"/>
|
||||
|
||||
<extensionPoint name="customizableActionGroupProvider" interface="com.intellij.ide.ui.customization.CustomizableActionGroupProvider"/>
|
||||
|
||||
<extensionPoint name="generalOptionsProvider" beanClass="com.intellij.ide.GeneralSettingsConfigurableEP"/>
|
||||
|
||||
<extensionPoint name="statusBarComponent" interface="com.intellij.openapi.wm.StatusBarCustomComponentFactory"/>
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
|
||||
<applicationConfigurable provider="com.intellij.xdebugger.impl.settings.DebuggerConfigurableProvider"/>
|
||||
|
||||
<customizableActionGroupProvider implementation="com.intellij.xdebugger.impl.ui.XDebugTabCustomizableActionGroupProvider"/>
|
||||
|
||||
<xdebugger.debuggerSupport implementation="com.intellij.xdebugger.impl.XDebuggerSupport" order="first"/>
|
||||
|
||||
<executor implementation="com.intellij.execution.executors.DefaultDebugExecutor" order="first,after run"/>
|
||||
|
||||
@@ -29,6 +29,8 @@ import com.intellij.execution.ui.layout.LayoutAttractionPolicy;
|
||||
import com.intellij.execution.ui.layout.LayoutViewOptions;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.ide.ui.customization.CustomActionsSchema;
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
@@ -68,6 +70,10 @@ public abstract class DebuggerSessionTabBase extends LogConsoleManagerBase imple
|
||||
.initFocusContent(DebuggerContentInfo.CONSOLE_CONTENT, LayoutViewOptions.STARTUP, new LayoutAttractionPolicy.FocusOnce(false));
|
||||
}
|
||||
|
||||
protected static ActionGroup getCustomizedActionGroup(final String id) {
|
||||
return (ActionGroup)CustomActionsSchema.getInstance().getCorrectedAction(id);
|
||||
}
|
||||
|
||||
public abstract RunContentDescriptor getRunContentDescriptor();
|
||||
|
||||
@Override
|
||||
|
||||
@@ -66,10 +66,6 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
|
||||
myIcon = icon;
|
||||
}
|
||||
|
||||
private static ActionGroup getActionGroup(final String id) {
|
||||
return (ActionGroup)ActionManager.getInstance().getAction(id);
|
||||
}
|
||||
|
||||
private Content createConsoleContent() {
|
||||
Content result = myUi.createContent(DebuggerContentInfo.CONSOLE_CONTENT, myConsole.getComponent(),
|
||||
XDebuggerBundle.message("debugger.session.tab.console.content.name"),
|
||||
@@ -87,7 +83,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
|
||||
AllIcons.Debugger.Value, null);
|
||||
result.setCloseable(false);
|
||||
|
||||
ActionGroup group = getActionGroup(XDebuggerActions.VARIABLES_TREE_TOOLBAR_GROUP);
|
||||
ActionGroup group = getCustomizedActionGroup(XDebuggerActions.VARIABLES_TREE_TOOLBAR_GROUP);
|
||||
result.setActions(group, ActionPlaces.DEBUGGER_TOOLBAR, variablesView.getTree());
|
||||
|
||||
return result;
|
||||
@@ -159,7 +155,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
|
||||
restartAction.registerShortcut(myUi.getComponent());
|
||||
}
|
||||
|
||||
leftToolbar.addAll(getActionGroup(XDebuggerActions.TOOL_WINDOW_LEFT_TOOLBAR_GROUP));
|
||||
leftToolbar.addAll(getCustomizedActionGroup(XDebuggerActions.TOOL_WINDOW_LEFT_TOOLBAR_GROUP));
|
||||
|
||||
//group.addSeparator();
|
||||
//addAction(group, DebuggerActions.EXPORT_THREADS);
|
||||
@@ -199,7 +195,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
|
||||
leftToolbar.add(new ContextHelpAction(executor.getHelpId()));
|
||||
|
||||
DefaultActionGroup topToolbar = new DefaultActionGroup();
|
||||
topToolbar.addAll(getActionGroup(XDebuggerActions.TOOL_WINDOW_TOP_TOOLBAR_GROUP));
|
||||
topToolbar.addAll(getCustomizedActionGroup(XDebuggerActions.TOOL_WINDOW_TOP_TOOLBAR_GROUP));
|
||||
|
||||
session.getDebugProcess().registerAdditionalActions(leftToolbar, topToolbar);
|
||||
myUi.getOptions().setLeftToolbar(leftToolbar, ActionPlaces.DEBUGGER_TOOLBAR);
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.ui;
|
||||
|
||||
import com.intellij.ide.ui.customization.CustomizableActionGroupProvider;
|
||||
import com.intellij.xdebugger.impl.actions.XDebuggerActions;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class XDebugTabCustomizableActionGroupProvider extends CustomizableActionGroupProvider {
|
||||
@Override
|
||||
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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user