| | | 1 | if (action.equals("ADD")) {↵
|
1 | JFileChooser fc = new JFileChooser();↵ | | 2 | JFileChooser fc = new JFileChooser();↵
|
2 | fc.setMultiSelectionEnabled(true);↵ | | 3 | fc.setMultiSelectionEnabled(true);↵
|
3 | // bug #996381 (fdietz), directories only!!↵ | | 4 | // bug #996381 (fdietz), directories only!!↵
|
4 | fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);↵ | | 5 | fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);↵
|
5 | fc.setFileHidingEnabled(false);↵ | | 6 | fc.setFileHidingEnabled(false);↵
|
|
6 | if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {↵ | | 7 | if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {↵
|
7 | File location = fc.getSelectedFile();↵ | | 8 | File location = fc.getSelectedFile();↵
|
8 | Profile p = new Profile(location.getName(), location);↵ | | 9 | Profile p = new Profile(location.getName(), location);↵
|
9 | // add profile to profiles.xml↵ | | 10 | // add profile to profiles.xml↵
|
10 | ProfileManager.getInstance().addProfile(p);↵ | | 11 | ProfileManager.getInstance().addProfile(p);↵
|
|
11 | ↵ | | 12 | ↵
|
12 | // add to listmodel↵ | | 13 | // add to listmodel↵
|
13 | model.addElement(p.getName());↵ | | 14 | model.addElement(p.getName());↵
|
14 | // select new item↵ | | 15 | // select new item↵
|
15 | list.setSelectedValue(p.getName(), true);↵ | | 16 | list.setSelectedValue(p.getName(), true);↵
|
16 | }↵ | | |
|
17 | ↵ | | 17 | }↵
|
18 | } else if (action.equals("EDIT")) {↵ | | 18 | } else if (action.equals("EDIT")) {↵
|
19 | String inputValue = JOptionPane.showInputDialog(↵ | | 19 | String inputValue = JOptionPane.showInputDialog(↵
|
20 | GlobalResourceLoader.getString(RESOURCE_PATH, "profiles",↵ | | 20 | GlobalResourceLoader.getString(RESOURCE_PATH, "profiles",↵
|
21 | "enter_name"), selection);↵ | | 21 | "enter_name"), selection);↵
|
|
22 | ↵ | | 22 | ↵
|
23 | if (inputValue == null) {↵ | | 23 | if (inputValue == null) {↵
|
24 | return;↵ | | |
|
25 | }↵ | | |
|
|
26 | ↵ | | 24 | return;↵
|
| | | 25 | }↵
|
| | | 26 | ↵
|
27 | // rename profile in profiles.xml↵ | | 27 | // rename profile in profiles.xml↵
|
28 | ProfileManager.getInstance().renameProfile(selection, inputValue);↵ | | 28 | ProfileManager.getInstance().renameProfile(selection, inputValue);↵
|
|
29 | ↵ | | 29 | ↵
|
30 | // modify listmodel↵ | | 30 | // modify listmodel↵
|
31 | model.setElementAt(inputValue, model.indexOf(selection));↵ | | 31 | model.setElementAt(inputValue, model.indexOf(selection));↵
|
|
32 | selection = inputValue; | | 32 | selection = inputValue;↵
|
| | | 33 | }
|