1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.sf.commonclipse.preferences;
18
19 import net.sf.commonclipse.CCMessages;
20 import net.sf.commonclipse.CCPlugin;
21
22 import org.eclipse.jface.preference.BooleanFieldEditor;
23 import org.eclipse.jface.preference.RadioGroupFieldEditor;
24 import org.eclipse.ui.IWorkbench;
25 import org.eclipse.ui.IWorkbenchPreferencePage;
26
27
28 /***
29 * This class represents a preference page that is contributed to the Preferences dialog. By subclassing <code>
30 * FieldEditorPreferencePage</code>,
31 * we can use the field support built into JFace that allows us to create a page that is small and knows how to save,
32 * restore and apply itself.
33 * <p>
34 * This page is used to modify preferences only. They are stored in the preference store that belongs to the main
35 * plug-in class. That way, preferences can be accessed directly via the preference store.
36 * @author fgiust
37 * @version $Revision: 1.8 $ ($Author: fgiust $)
38 */
39
40 public class CCPreferencePage extends TabbedFieldEditorPreferencePage implements IWorkbenchPreferencePage
41 {
42
43 /***
44 * init preference page.
45 */
46 public CCPreferencePage()
47 {
48 super(GRID);
49 setPreferenceStore(CCPlugin.getDefault().getPreferenceStore());
50 }
51
52 /***
53 * Creates the field editors. Field editors are abstractions of the common GUI blocks needed to manipulate various
54 * types of preferences. Each field editor knows how to save and restore itself.
55 */
56 public void createFieldEditors()
57 {
58
59 addTab(CCMessages.getString("preference.tab.tostring"));
60
61 addField(new RadioGroupFieldEditor(
62 CCPlugin.P_TOSTRING_BEAN,
63 CCMessages.getString("preference.tostringtype"), 1, new String[][]{
64 {CCMessages.getString("preference.tostringtype.bean"), CCPlugin.TOSTRINGSTYLE_BEAN},
65 {CCMessages.getString("preference.tostringtype.fieds"),
66 CCPlugin.TOSTRINGSTYLE_FIELDS}},
67 getFieldEditorParent(),
68 true));
69
70 addField(new SpacerFieldEditor(getFieldEditorParent()));
71
72 ClassConstantFieldEditor selectEditor = new ClassConstantFieldEditor(CCPlugin.P_TOSTRING_STYLE, CCMessages
73 .getString("preference.customtostringtype"),
74 getFieldEditorParent());
75
76 String[] styles = new String[]{"org.apache.commons.lang.builder.ToStringStyle.DEFAULT_STYLE",
77 "org.apache.commons.lang.builder.ToStringStyle.MULTI_LINE_STYLE",
78 "org.apache.commons.lang.builder.ToStringStyle.NO_FIELD_NAMES_STYLE",
79 "org.apache.commons.lang.builder.ToStringStyle.SIMPLE_STYLE"};
80
81 selectEditor.setPredefinedValues(styles);
82
83 selectEditor.setErrorMessage(CCMessages.getString("preference.customtostring.error"));
84
85 addField(selectEditor);
86
87 addField(new SpacerFieldEditor(getFieldEditorParent()));
88
89 addTab(CCMessages.getString("preference.tab.general"));
90
91 addField(new BooleanFieldEditor(CCPlugin.P_TOSTRING_SUPER, CCMessages
92 .getString("preference.appendsuper.tostring"), getFieldEditorParent()));
93 addField(new BooleanFieldEditor(CCPlugin.P_HASHCODE_SUPER, CCMessages
94 .getString("preference.appendsuper.hashcode"), getFieldEditorParent()));
95 addField(new BooleanFieldEditor(
96 CCPlugin.P_EQUALS_SUPER,
97 CCMessages.getString("preference.appendsuper.equals"), getFieldEditorParent()));
98 addField(new BooleanFieldEditor(CCPlugin.P_COMPARETO_SUPER, CCMessages
99 .getString("preference.appendsuper.compareto"),
100 getFieldEditorParent()));
101
102 addField(new SpacerFieldEditor(getFieldEditorParent()));
103
104 addField(new BooleanFieldEditor(CCPlugin.P_FINALPARAMETERS,
105 CCMessages.getString("preference.finalparameters"),
106 getFieldEditorParent()));
107
108 addField(new BooleanFieldEditor(CCPlugin.P_EQUALS_INSTANCECHECK, CCMessages
109 .getString("preference.equals.equalitycheck"),
110 getFieldEditorParent()));
111
112 addField(new SpacerFieldEditor(getFieldEditorParent()));
113
114 addField(new BooleanFieldEditor(CCPlugin.P_DONTASKONOVERWRITE, CCMessages
115 .getString("preference.overwriteconfirmation"),
116 getFieldEditorParent()));
117
118 addField(new SpacerFieldEditor(getFieldEditorParent()));
119
120 addTab(CCMessages.getString("preference.tab.exclude"));
121
122 AddRemoveListFieldEditor excludedEditor = new AddRemoveListFieldEditor(CCPlugin.P_EXCLUDE, CCMessages
123 .getString("preference.excluded"),
124 getFieldEditorParent());
125
126 addField(excludedEditor);
127
128 }
129
130 /***
131 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
132 */
133 public void init(IWorkbench workbench)
134 {
135 }
136 }