1 package com.explosion.utilities.preferences.groups.dialogs;
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.BorderLayout;
24 import java.awt.Dialog;
25 import java.awt.Dimension;
26 import java.awt.Frame;
27 import java.util.Vector;
28
29 import javax.swing.JScrollPane;
30
31 import com.explosion.utilities.preferences.dialogs.PreferencesTable;
32 import com.explosion.utilities.preferences.dialogs.TableBasedPreferenceEditorDialog;
33 import com.explosion.utilities.preferences.groups.PreferenceGroup;
34
35 /***
36 * @author Stephen Cowx Date created:@25-Jan-2003
37 * This displays all of the preferences in the group in a table, ready for editing
38 */
39 public class PreferenceGroupEditDialog extends TableBasedPreferenceEditorDialog
40 {
41
42 private PreferenceGroup preferenceGroup;
43
44 private PreferencesTable table;
45
46 public static Dimension editorDimension = new Dimension(400, 250);
47
48 public PreferenceGroupEditDialog(Dialog owner, String title, boolean editable)
49 {
50 super(owner, title, false, editable);
51 super.setLocationRelativeTo(owner);
52 }
53
54 public PreferenceGroupEditDialog(Frame owner, String title, boolean editable)
55 {
56 super(owner, title, false, editable);
57 super.setLocationRelativeTo(owner);
58 }
59
60 public void loadPreferences(Object preferences)
61 {
62 try
63 {
64 this.preferenceGroup = (PreferenceGroup) preferences;
65 Vector dataTables = new Vector();
66 JScrollPane scrollPane = new JScrollPane();
67 this.configPanel.add(scrollPane, BorderLayout.CENTER);
68 table = new PreferencesTable(preferenceGroup.getPreferencesVector(), this, this);
69
70 dataTables.addElement(table);
71 scrollPane.getViewport().add(table);
72 table.setTableHeader(null);
73
74 this.setDataTables(dataTables);
75 } catch (Exception e)
76 {
77 com.explosion.utilities.exception.ExceptionManagerFactory.getExceptionManager().manageException(e, null);
78 }
79 }
80
81 public PreferenceGroup getPersistentDescriptor()
82 {
83 return this.preferenceGroup;
84 }
85
86 /***
87 * This method saves the properties to persistent storage and calls the
88 * application.applyPreferences method
89 */
90 public void apply()
91 {
92 try
93 {
94 preferenceGroup.commit();
95 } catch (Exception e)
96 {
97 com.explosion.utilities.exception.ExceptionManagerFactory.getExceptionManager().manageException(e, null);
98 }
99 }
100
101 }
102