1 package com.explosion.expf.preferences;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import java.awt.Dialog;
24 import java.awt.Frame;
25 import java.util.Vector;
26
27 import javax.swing.JButton;
28 import javax.swing.JScrollPane;
29
30 import com.explosion.expf.Application;
31 import com.explosion.expf.ExpModuleManager;
32 import com.explosion.utilities.preferences.dialogs.PreferencesTable;
33 import com.explosion.utilities.preferences.dialogs.TableBasedPreferenceEditorDialog;
34
35 public class StandardConfigurationDialog extends TableBasedPreferenceEditorDialog
36 {
37
38 private JButton button = new JButton("Dump preferences");
39
40 public StandardConfigurationDialog(Dialog owner, String title)
41 {
42 super(owner, title, true, true);
43 super.setLocationRelativeTo(owner);
44 }
45
46 public StandardConfigurationDialog(Frame owner, String title)
47 {
48 super(owner, title, true, true);
49 super.setLocationRelativeTo(owner);
50 }
51
52 Vector dataTables;
53
54 public void loadPreferences(Object preferences)
55 {
56 try
57 {
58 dataTables = new Vector();
59
60
61 populateTable("General", (Vector) preferences);
62
63
64 Vector v = Application.getModules();
65 if (v != null)
66 {
67 for (int i = 0; i < v.size(); i++)
68 {
69 ExpModuleManager descrip = (ExpModuleManager) v.elementAt(i);
70 Vector prefs = descrip.getPreferences();
71 populateTable(descrip.getName(), prefs);
72 }
73 }
74 } catch (Exception e)
75 {
76 com.explosion.utilities.exception.ExceptionManagerFactory.getExceptionManager().manageException(e, "Exception caught while saving properties");
77 }
78 }
79
80 /***
81 * @param descrip
82 * @param prefs
83 */
84 private void populateTable(String name, Vector prefs)
85 {
86 if (prefs != null)
87 {
88 JScrollPane scrollPane2 = new JScrollPane();
89 configTabbedPane.add(scrollPane2, name);
90 PreferencesTable table2 = new PreferencesTable(prefs, Application.getApplicationFrame(), this);
91 scrollPane2.getViewport().add(table2);
92 dataTables.addElement(table2);
93 table2.setTableHeader(null);
94 }
95 }
96
97 /***
98 * This method saves the properties to persistent storage and calls the
99 * application.applyPreferences method
100 */
101 public void apply()
102 {
103 Application.getInstance().applyPreferences();
104 myUpdateLookAndFeel();
105
106 try
107 {
108 Application.getInstance().savePreferences();
109 } catch (Exception ex)
110 {
111 com.explosion.utilities.exception.ExceptionManagerFactory.getExceptionManager().manageException(ex, "Unable to apply and save properties");
112 }
113 }
114
115 /***
116 * Runs through all of the editors and renderers updating their look and
117 * feel
118 */
119 private void myUpdateLookAndFeel()
120 {
121 try
122 {
123 Application.getInstance().updateLookAndFeel(this);
124 } catch (Exception e)
125 {
126 com.explosion.utilities.exception.ExceptionManagerFactory.getExceptionManager().manageException(e, "Exception caught while updating lookandfeel of property editors and renderers");
127 }
128 }
129
130 }