* Preset UI changes

This commit is contained in:
Reinhard Pointner 2015-07-25 22:47:24 +00:00
parent 8299e849aa
commit b019cd9827
2 changed files with 7 additions and 12 deletions

View File

@ -124,7 +124,7 @@ public class PresetEditor extends JDialog {
c.add(inputGroup, "growx, wrap"); c.add(inputGroup, "growx, wrap");
c.add(formatGroup, "growx, wrap"); c.add(formatGroup, "growx, wrap");
c.add(searchGroup, "growx, wrap push"); c.add(searchGroup, "growx, wrap push");
c.add(new JButton(set), "tag apply"); c.add(new JButton(ok), "tag apply");
c.add(new JButton(delete), "tag cancel"); c.add(new JButton(delete), "tag cancel");
setSize(650, 570); setSize(650, 570);
@ -325,7 +325,7 @@ public class PresetEditor extends JDialog {
return result; return result;
} }
private final Action set = new AbstractAction("Set", ResourceManager.getIcon("dialog.continue")) { private final Action ok = new AbstractAction("Preset", ResourceManager.getIcon("dialog.continue")) {
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {

View File

@ -388,7 +388,6 @@ public class RenamePanel extends JComponent {
ActionPopup actionPopup = new ActionPopup("Presets", ResourceManager.getIcon("action.script")); ActionPopup actionPopup = new ActionPopup("Presets", ResourceManager.getIcon("action.script"));
if (persistentPresets.size() > 0) { if (persistentPresets.size() > 0) {
actionPopup.addDescription(new JLabel("Apply:"));
for (String it : persistentPresets.values()) { for (String it : persistentPresets.values()) {
try { try {
Preset p = (Preset) JsonReader.jsonToJava(it); Preset p = (Preset) JsonReader.jsonToJava(it);
@ -397,9 +396,9 @@ public class RenamePanel extends JComponent {
Logger.getLogger(RenamePanel.class.getName()).log(Level.WARNING, e.toString()); Logger.getLogger(RenamePanel.class.getName()).log(Level.WARNING, e.toString());
} }
} }
actionPopup.addSeparator();
} }
actionPopup.addDescription(new JLabel("Options:"));
actionPopup.add(new AbstractAction("Edit Presets", ResourceManager.getIcon("script.add")) { actionPopup.add(new AbstractAction("Edit Presets", ResourceManager.getIcon("script.add")) {
@Override @Override
@ -409,13 +408,7 @@ public class RenamePanel extends JComponent {
List<String> presetNames = new ArrayList<String>(persistentPresets.keySet()); List<String> presetNames = new ArrayList<String>(persistentPresets.keySet());
presetNames.add(newPresetOption); presetNames.add(newPresetOption);
SelectDialog<String> selectDialog = new SelectDialog<String>(getWindow(evt.getSource()), presetNames); String selection = (String) JOptionPane.showInputDialog(getWindow(evt.getSource()), "Edit or create a preset:", "Edit Preset", JOptionPane.PLAIN_MESSAGE, null, presetNames.toArray(), newPresetOption);
selectDialog.setLocation(getOffsetLocation(selectDialog.getOwner()));
selectDialog.setMinimumSize(new Dimension(250, 150));
selectDialog.setTitle("Edit Preset");
selectDialog.getHeaderLabel().setText("Edit or create a preset:");
selectDialog.setVisible(true);
String selection = selectDialog.getSelectedValue();
if (selection == null) if (selection == null)
return; return;
@ -439,7 +432,9 @@ public class RenamePanel extends JComponent {
persistentPresets.remove(selection); persistentPresets.remove(selection);
break; break;
case SET: case SET:
persistentPresets.put(selection, JsonWriter.objectToJson(presetEditor.getPreset())); preset = presetEditor.getPreset();
persistentPresets.put(selection, JsonWriter.objectToJson(preset));
new ApplyPresetAction(preset).actionPerformed(evt);
break; break;
case CANCEL: case CANCEL:
break; break;