mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-2870
This commit is contained in:
@@ -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;
|
||||
|
||||
+17
-17
@@ -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<String,String> myPredefinedSeparators = new LinkedHashMap<String, String>();
|
||||
private final Set<String> myPredefinedSeparators = new LinkedHashSet<String>();
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user