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