1 package com.explosion.utilities.preferences.editandrender.form;
2
3 import java.awt.GridBagConstraints;
4 import java.awt.GridBagLayout;
5 import java.awt.Insets;
6
7 import javax.swing.JLabel;
8
9 import org.apache.log4j.LogManager;
10 import org.apache.log4j.Logger;
11
12 import com.explosion.utilities.exception.ExceptionManagerFactory;
13 import com.explosion.utilities.preferences.Preference;
14 import com.explosion.utilities.preferences.dialogs.EditCollectionPreferenceJPanel;
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 /***
38 * This class provides a way to edit and rebder collection preferences
39 * @author Stephen Cowx
40 * @version
41 */
42 public class CollectionPreferenceEditorAndRenderer extends FormBasedPreferenceRendererAndEditor {
43
44 private EditCollectionPreferenceJPanel panel;
45 private JLabel label = new JLabel();
46 private static Logger log = LogManager.getLogger(CollectionPreferenceEditorAndRenderer.class);
47
48 /***
49 * Constructs an instance of this class
50 * @param preference
51 */
52 public CollectionPreferenceEditorAndRenderer(Preference preference)
53 {
54 super(preference);
55 try {
56 init();
57 } catch (Exception e) {
58 ExceptionManagerFactory.getExceptionManager().manageException(e, "Exception caught while initialising collection preference editor");
59 }
60 }
61
62 /***
63 * This method initialises this renderer editor combination
64 * @throws Exception
65 */
66 public void init() throws Exception
67 {
68 this.setLayout(new GridBagLayout());
69
70
71 label.setText(getPreference().getLongName());
72 panel = new EditCollectionPreferenceJPanel(getPreference());
73
74
75 this.add(label , new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
76 this.add(panel , new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
77 }
78
79
80 }