diff --git a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/Presentation.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/Presentation.java index c58ab30b93bd..f0667e67d8db 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/Presentation.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/Presentation.java @@ -118,7 +118,7 @@ public final class Presentation implements Cloneable { return myText; } - public void setText(String text, boolean mayContainMnemonic) { + public void setText(@Nullable String text, boolean mayContainMnemonic) { int oldMnemonic = myMnemonic; int oldDisplayedMnemonicIndex = myDisplayedMnemonicIndex; String oldText = myText; diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/PropertiesGroupingStructureViewComponent.java b/plugins/properties/src/com/intellij/lang/properties/editor/PropertiesGroupingStructureViewComponent.java index 7547e9772c0b..8765943c7c4a 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/PropertiesGroupingStructureViewComponent.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/PropertiesGroupingStructureViewComponent.java @@ -22,10 +22,11 @@ import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; +import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NonNls; -import java.util.LinkedHashMap; -import java.util.Map; +import java.util.LinkedHashSet; +import java.util.Set; /** * @author cdr @@ -45,17 +46,16 @@ public class PropertiesGroupingStructureViewComponent extends StructureViewCompo } private class ChangeGroupSeparatorAction extends DefaultActionGroup { - // separator -> presentable text - private final Map myPredefinedSeparators = new LinkedHashMap(); + private final Set myPredefinedSeparators = new LinkedHashSet(); public ChangeGroupSeparatorAction() { super("Group by: ", true); - myPredefinedSeparators.put(".", "."); - myPredefinedSeparators.put("_", "__"); - myPredefinedSeparators.put("/", "/"); + myPredefinedSeparators.add("."); + myPredefinedSeparators.add("_"); + myPredefinedSeparators.add("/"); String currentSeparator = getCurrentSeparator(); - if (!myPredefinedSeparators.containsKey(currentSeparator)) { - myPredefinedSeparators.put(currentSeparator, currentSeparator); + if (!myPredefinedSeparators.contains(currentSeparator)) { + myPredefinedSeparators.add(currentSeparator); } refillActionGroup(); } @@ -63,7 +63,7 @@ public class PropertiesGroupingStructureViewComponent extends StructureViewCompo public final void update(AnActionEvent e) { String separator = getCurrentSeparator(); Presentation presentation = e.getPresentation(); - presentation.setText("Group by: " + myPredefinedSeparators.get(separator)); + presentation.setText("Group by: " + separator, false); } private String getCurrentSeparator() { @@ -72,11 +72,9 @@ public class PropertiesGroupingStructureViewComponent extends StructureViewCompo private void refillActionGroup() { removeAll(); - for (final String separator : myPredefinedSeparators.keySet()) { + for (final String separator : myPredefinedSeparators) { if (separator.equals(getCurrentSeparator())) continue; - String presentableText = myPredefinedSeparators.get(separator); - add(new AnAction(presentableText) { - + AnAction action = new AnAction() { @Override public void actionPerformed(AnActionEvent e) { ((PropertiesGroupingStructureViewModel)getTreeModel()).setSeparator(separator); @@ -84,7 +82,9 @@ public class PropertiesGroupingStructureViewComponent extends StructureViewCompo refillActionGroup(); rebuild(); } - }); + }; + action.getTemplatePresentation().setText(separator, false); + add(action); } add(new SelectSeparatorAction()); } @@ -96,7 +96,7 @@ public class PropertiesGroupingStructureViewComponent extends StructureViewCompo } public final void actionPerformed(AnActionEvent e) { - String[] strings = myPredefinedSeparators.keySet().toArray(new String[myPredefinedSeparators.size()]); + String[] strings = ArrayUtil.toStringArray(myPredefinedSeparators); String current = getCurrentSeparator(); String separator = Messages.showEditableChooseDialog(PropertiesBundle.message("select.property.separator.dialog.text"), PropertiesBundle.message("select.property.separator.dialog.title"), @@ -105,7 +105,7 @@ public class PropertiesGroupingStructureViewComponent extends StructureViewCompo if (separator == null) { return; } - myPredefinedSeparators.put(separator, separator); + myPredefinedSeparators.add(separator); refillActionGroup(); } }