1 | /** | | 1 | /** |
2 | * Constructor to build new settings dialog. | | 2 | * The constructor for this dialog of settings with project scope. |
3 | */ | | 3 | */ |
4 | SettingsDialog() { | | 4 | public ProjectSettingsDialog() { |
5 | super(Translator.localize("dialog.settings"), | | 5 | super(Translator.localize("dialog.file.properties"), |
6 | ArgoDialog.OK_CANCEL_OPTION, | | 6 | ArgoDialog.OK_CANCEL_OPTION, |
7 | true); | | 7 | true); |
8 | | | 8 | |
9 | tabs = new JTabbedPane(); | | 9 | tabs = new JTabbedPane(); |
10 | | | 10 | |
11 | applyButton = new JButton(Translator.localize("button.apply")); | | 11 | applyButton = new JButton(Translator.localize("button.apply")); |
12 | String mnemonic = Translator.localize("button.apply.mnemonic"); | | 12 | String mnemonic = Translator.localize("button.apply.mnemonic"); |
13 | if (mnemonic != null && mnemonic.length() > 0) { | | 13 | if (mnemonic != null && mnemonic.length() > 0) { |
14 | applyButton.setMnemonic(mnemonic.charAt(0)); | | 14 | applyButton.setMnemonic(mnemonic.charAt(0)); |
15 | } | | 15 | } |
16 | applyButton.addActionListener(new ActionListener() { | | 16 | applyButton.addActionListener(new ActionListener() { |
17 | public void actionPerformed(ActionEvent e) { | | 17 | public void actionPerformed(ActionEvent e) { |
18 | handleSave(); | | 18 | handleSave(); |
19 | } | | 19 | } |
20 | }); | | 20 | }); |
21 | addButton(applyButton); | | 21 | addButton(applyButton); |
22 | | | 22 | |
23 | // Add settings from the settings registry. | | 23 | resetToDefaultButton = new JButton( |
24 | settingsTabs = GUI.getInstance().getSettingsTabs(); | | 24 | Translator.localize("button.reset-to-default")); |
25 | for (GUISettingsTabInterface stp : settingsTabs) { | | 25 | mnemonic = Translator.localize("button.reset-to-default.mnemonic"); |
26 | // TODO: Only fetch names and defer fetching panels until needed | | 26 | if (mnemonic != null && mnemonic.length() > 0) { |
27 | tabs.addTab( | | 27 | resetToDefaultButton.setMnemonic(mnemonic.charAt(0)); |
28 | Translator.localize(stp.getTabKey()), | | 28 | } |
29 | stp.getTabPanel()); | | 29 | resetToDefaultButton.addActionListener(new ActionListener() { |
30 | } | | 30 | public void actionPerformed(ActionEvent e) { |
31 | | | 31 | handleResetToDefault(); |
32 | // Increase width to accommodate all tabs on one row. | | 32 | } |
33 | final int minimumWidth = 500; | | 33 | }); |
34 | tabs.setPreferredSize(new Dimension(Math.max(tabs | | 34 | addButton(resetToDefaultButton); |
35 | .getPreferredSize().width, minimumWidth), tabs | | 35 | |
36 | .getPreferredSize().height)); | | 36 | // Add settings from the settings registry. |
37 | | | 37 | Iterator iter = GUI.getInstance().getProjectSettingsTabs().iterator(); |
38 | tabs.setTabPlacement(SwingConstants.LEFT); | | 38 | while (iter.hasNext()) { |
39 | setContent(tabs); | | 39 | GUISettingsTabInterface stp = |
40 | addWindowListener(this); | | 40 | (GUISettingsTabInterface) iter.next(); |
41 | } | | 41 | |
| | | 42 | tabs.addTab( |
| | | 43 | Translator.localize(stp.getTabKey()), |
| | | 44 | stp.getTabPanel()); |
| | | 45 | } |
| | | 46 | |
| | | 47 | // Increase width to accommodate all tabs on one row. |
| | | 48 | final int minimumWidth = 480; |
| | | 49 | tabs.setPreferredSize(new Dimension(Math.max(tabs |
| | | 50 | .getPreferredSize().width, minimumWidth), tabs |
| | | 51 | .getPreferredSize().height)); |
| | | 52 | |
| | | 53 | tabs.setTabPlacement(SwingConstants.LEFT); |
| | | 54 | setContent(tabs); |
| | | 55 | addWindowListener(this); |
| | | 56 | } |