mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
customizations: perform reset to default over selection (IDEA-51564)
This commit is contained in:
+15
-7
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.ide.ui.customization.CustomizableActionsPanel">
|
||||
<grid id="63fa4" binding="myPanel" layout-manager="GridLayoutManager" row-count="9" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="63fa4" binding="myPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="43" y="59" width="556" height="366"/>
|
||||
@@ -8,17 +8,17 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="5879e" binding="myDetailsPanel" layout-manager="GridLayoutManager" row-count="8" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="5879e" layout-manager="GridLayoutManager" row-count="9" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="9" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<scrollpane class="com.intellij.ui.components.JBScrollPane" id="1fca1">
|
||||
<scrollpane id="1fca1" class="com.intellij.ui.components.JBScrollPane">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="8" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="0" row-span="9" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -82,12 +82,20 @@
|
||||
<text resource-bundle="messages/IdeBundle" key="button.edit.action.icon"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b4a3b" class="javax.swing.JButton" binding="myRestoreDefaultButton" default-binding="true">
|
||||
<component id="b4a3b" class="javax.swing.JButton" binding="myRestoreAllDefaultButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Re&store Default"/>
|
||||
<text value="Restore A&ll Defaults"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="a19c6" class="javax.swing.JButton" binding="myRestoreDefaultButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="R&estore Default"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
|
||||
+45
-18
@@ -29,7 +29,6 @@ import com.intellij.openapi.keymap.impl.ui.Group;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.ui.DetailsComponent;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
@@ -60,9 +59,8 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
@@ -90,10 +88,9 @@ public class CustomizableActionsPanel {
|
||||
|
||||
|
||||
|
||||
private JPanel myDetailsPanel;
|
||||
private JButton myRestoreAllDefaultButton;
|
||||
private JButton myRestoreDefaultButton;
|
||||
public static final Icon FULLISH_ICON = IconLoader.getIcon("/toolbar/unknown.png");
|
||||
private DetailsComponent myDetailsComponent;
|
||||
|
||||
public CustomizableActionsPanel() {
|
||||
|
||||
@@ -144,6 +141,7 @@ public class CustomizableActionsPanel {
|
||||
}
|
||||
myMoveActionUpButton.setEnabled(isMoveSupported(myActionsTree, -1));
|
||||
myMoveActionDownButton.setEnabled(isMoveSupported(myActionsTree, 1));
|
||||
myRestoreDefaultButton.setEnabled(!findActionsUnderSelection().isEmpty());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -178,7 +176,7 @@ public class CustomizableActionsPanel {
|
||||
|
||||
myEditIconButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
myRestoreDefaultButton.setEnabled(true);
|
||||
myRestoreAllDefaultButton.setEnabled(true);
|
||||
final List<TreePath> expandedPaths = TreeUtil.collectExpandedPaths(myActionsTree);
|
||||
final TreePath selectionPath = myActionsTree.getLeadSelectionPath();
|
||||
if (selectionPath != null) {
|
||||
@@ -270,10 +268,25 @@ public class CustomizableActionsPanel {
|
||||
}
|
||||
});
|
||||
|
||||
myRestoreDefaultButton.addActionListener(new ActionListener() {
|
||||
myRestoreAllDefaultButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
mySelectedSchema.copyFrom(new CustomActionsSchema());
|
||||
patchActionsTreeCorrespondingToSchema(root);
|
||||
myRestoreAllDefaultButton.setEnabled(false);
|
||||
}
|
||||
});
|
||||
|
||||
myRestoreDefaultButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final List<ActionUrl> otherActions = new ArrayList<ActionUrl>(mySelectedSchema.getActions());
|
||||
otherActions.removeAll(findActionsUnderSelection());
|
||||
mySelectedSchema.copyFrom(new CustomActionsSchema());
|
||||
for (ActionUrl otherAction : otherActions) {
|
||||
mySelectedSchema.addAction(otherAction);
|
||||
}
|
||||
final List<TreePath> treePaths = TreeUtil.collectExpandedPaths(myActionsTree);
|
||||
patchActionsTreeCorrespondingToSchema(root);
|
||||
restorePathsAfterTreeOptimization(treePaths);
|
||||
myRestoreDefaultButton.setEnabled(false);
|
||||
}
|
||||
});
|
||||
@@ -283,18 +296,32 @@ public class CustomizableActionsPanel {
|
||||
myTreeExpansionMonitor = TreeExpansionMonitor.install(myActionsTree);
|
||||
}
|
||||
|
||||
private List<ActionUrl> findActionsUnderSelection() {
|
||||
final ArrayList<ActionUrl> actions = new ArrayList<ActionUrl>();
|
||||
final TreePath[] selectionPaths = myActionsTree.getSelectionPaths();
|
||||
if (selectionPaths != null) {
|
||||
for (TreePath path : selectionPaths) {
|
||||
final ActionUrl selectedUrl = CustomizationUtil.getActionUrl(path, ActionUrl.MOVE);
|
||||
final ArrayList<String> selectedGroupPath = new ArrayList<String>(selectedUrl.getGroupPath());
|
||||
final Object component = selectedUrl.getComponent();
|
||||
if (component instanceof Group) {
|
||||
selectedGroupPath.add(((Group)component).getName());
|
||||
for (ActionUrl action : mySelectedSchema.getActions()) {
|
||||
final ArrayList<String> groupPath = action.getGroupPath();
|
||||
final int idx = Collections.indexOfSubList(groupPath, selectedGroupPath);
|
||||
if (idx > -1) {
|
||||
actions.add(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
private void addCustomizedAction(ActionUrl url) {
|
||||
mySelectedSchema.addAction(url);
|
||||
myRestoreDefaultButton.setEnabled(true);
|
||||
}
|
||||
|
||||
public void initUi() {
|
||||
myDetailsComponent = new DetailsComponent();
|
||||
myDetailsComponent.setContent(myDetailsPanel);
|
||||
}
|
||||
|
||||
public DetailsComponent getDetails() {
|
||||
return myDetailsComponent;
|
||||
myRestoreAllDefaultButton.setEnabled(true);
|
||||
}
|
||||
|
||||
private void editToolbarIcon(String actionId, DefaultMutableTreeNode node) {
|
||||
@@ -401,7 +428,7 @@ public class CustomizableActionsPanel {
|
||||
mySelectedSchema = new CustomActionsSchema();
|
||||
mySelectedSchema.copyFrom(CustomActionsSchema.getInstance());
|
||||
patchActionsTreeCorrespondingToSchema((DefaultMutableTreeNode)myActionsTree.getModel().getRoot());
|
||||
myRestoreDefaultButton.setEnabled(mySelectedSchema.isModified(new CustomActionsSchema()));
|
||||
myRestoreAllDefaultButton.setEnabled(mySelectedSchema.isModified(new CustomActionsSchema()));
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
|
||||
Reference in New Issue
Block a user