39
39
public class FileListControlFieldEditor extends FieldEditor {
40
40
41
41
// file list control
42
- private FileListControl list ;
42
+ private FileListControl myListControl ;
43
43
private int browseType ;
44
44
private Composite topLayout ;
45
45
private static final String DEFAULT_SEPARATOR = ";" ; //$NON-NLS-1$
46
46
47
- //values
48
- // private String[] values = null;
49
-
50
47
/**
51
48
* Creates a file list control field editor.
52
49
*
@@ -60,10 +57,10 @@ public class FileListControlFieldEditor extends FieldEditor {
60
57
* the browseType of the file list control
61
58
*/
62
59
public FileListControlFieldEditor (String name , String labelText , Composite parent , int type ) {
63
- super (name , labelText , parent );
60
+ super ();
64
61
browseType = type ;
65
- // Set the browse strategy for the list editor
66
- list . setType ( type );
62
+ init ( name , labelText );
63
+ createControl ( parent );
67
64
}
68
65
69
66
/**
@@ -82,13 +79,33 @@ public FileListControlFieldEditor(String name, String labelText, Composite paren
82
79
* the browseType of the file list control
83
80
*/
84
81
public FileListControlFieldEditor (String name , String labelText , String tooltip , String contextId , Composite parent ,
85
- int type ) {
82
+ String value , int type ) {
86
83
this (name , labelText , parent , type );
87
84
// can't use setToolTip(tooltip) as label not created yet
88
85
getLabelControl (parent ).setToolTipText (tooltip );
89
86
if (!contextId .isEmpty ())
90
- PlatformUI .getWorkbench ().getHelpSystem ().setHelp (list .getListControl (), contextId );
87
+ PlatformUI .getWorkbench ().getHelpSystem ().setHelp (myListControl .getListControl (), contextId );
88
+ myListControl .setList (parseString (value ));
91
89
}
90
+ /**
91
+ * Creates a file list control field editor.
92
+ *
93
+ * @param name
94
+ * the name of the preference this field editor works on
95
+ * @param labelText
96
+ * the label text of the field editor
97
+ * @param parent
98
+ * the parent of the field editor's control
99
+ * @param value
100
+ * the field editor's value
101
+ * @param type
102
+ * the browseType of the file list control
103
+ */
104
+ // public FileListControlFieldEditor(String name, String labelText, Composite parent, String value, int type) {
105
+ // this(name, labelText, parent, type);
106
+ // browseType = type;
107
+ // // this.values = parseString(value);
108
+ // }
92
109
93
110
/**
94
111
* Sets the field editor's tool tip text to the argument, which
@@ -128,26 +145,6 @@ public String getToolTipText() {
128
145
return getLabelControl ().getToolTipText ();
129
146
}
130
147
131
- /**
132
- * Creates a file list control field editor.
133
- *
134
- * @param name
135
- * the name of the preference this field editor works on
136
- * @param labelText
137
- * the label text of the field editor
138
- * @param parent
139
- * the parent of the field editor's control
140
- * @param value
141
- * the field editor's value
142
- * @param type
143
- * the browseType of the file list control
144
- */
145
- public FileListControlFieldEditor (String name , String labelText , Composite parent , String value , int type ) {
146
- this (name , labelText , parent , type );
147
- browseType = type ;
148
- // this.values = parseString(value);
149
- }
150
-
151
148
/**
152
149
* Sets the filter-path for the underlying Browse dialog. Only applies when
153
150
* browseType is 'file' or 'dir'.
@@ -157,7 +154,7 @@ public FileListControlFieldEditor(String name, String labelText, Composite paren
157
154
* @since 7.0
158
155
*/
159
156
public void setFilterPath (String filterPath ) {
160
- list .setFilterPath (filterPath );
157
+ myListControl .setFilterPath (filterPath );
161
158
}
162
159
163
160
/**
@@ -169,7 +166,7 @@ public void setFilterPath(String filterPath) {
169
166
* @since 7.0
170
167
*/
171
168
public void setFilterExtensions (String [] filterExtensions ) {
172
- list .setFilterExtensions (filterExtensions );
169
+ myListControl .setFilterExtensions (filterExtensions );
173
170
}
174
171
175
172
/**
@@ -188,8 +185,8 @@ protected void doFillIntoGrid(Composite parent, int numColumns) {
188
185
gddata .horizontalSpan = 2 ;
189
186
topLayout .setLayoutData (gddata );
190
187
// file list control
191
- list = new FileListControl (topLayout , getLabelText (), getType () , false );
192
- list .addChangeListener (new IFileListChangeListener () {
188
+ myListControl = new FileListControl (topLayout , getLabelText (), browseType , false );
189
+ myListControl .addChangeListener (new IFileListChangeListener () {
193
190
194
191
@ Override
195
192
public void fileListChanged (FileListControl fileList , String oldValue [], String newValue []) {
@@ -205,41 +202,32 @@ private void handleFileListChange(FileListControl fileList, String oldValue[], S
205
202
fireValueChanged (VALUE , createList (oldValue ), createList (newValue ));
206
203
}
207
204
208
- /**
209
- * Returns the browseType of this field editor's file list control
210
- *
211
- * @return
212
- */
213
- private int getType () {
214
- return browseType ;
215
- }
216
-
217
205
/**
218
206
* @return the file list control
219
207
*/
220
208
protected List getListControl () {
221
- return list .getListControl ();
209
+ return myListControl .getListControl ();
222
210
}
223
211
224
212
/* (non-Javadoc)
225
213
* @see org.eclipse.jface.preference.FieldEditor#doLoad()
226
214
*/
227
215
@ Override
228
216
protected void doLoad () {
229
- list .selectionChanged ();
217
+ myListControl .selectionChanged ();
230
218
}
231
219
232
220
/* (non-Javadoc)
233
221
* @see org.eclipse.jface.preference.FieldEditor#doLoadDefault()
234
222
*/
235
223
@ Override
236
224
protected void doLoadDefault () {
237
- if (list != null ) {
238
- list .removeAll ();
225
+ if (myListControl != null ) {
226
+ myListControl .removeAll ();
239
227
String s = getPreferenceStore ().getDefaultString (getPreferenceName ());
240
228
String [] array = parseString (s );
241
- list .setList (array );
242
- list .selectionChanged ();
229
+ myListControl .setList (array );
230
+ myListControl .selectionChanged ();
243
231
}
244
232
}
245
233
@@ -248,13 +236,13 @@ protected void doLoadDefault() {
248
236
*/
249
237
@ Override
250
238
protected void doStore () {
251
- String s = createList (list .getItems ());
239
+ String s = createList (myListControl .getItems ());
252
240
if (s != null )
253
241
getPreferenceStore ().setValue (getPreferenceName (), s );
254
242
}
255
243
256
244
public String [] getStringListValue () {
257
- return list .getItems ();
245
+ return myListControl .getItems ();
258
246
}
259
247
260
248
/**
@@ -319,12 +307,12 @@ protected void adjustForNumColumns(int numColumns) {
319
307
320
308
@ Override
321
309
public Label getLabelControl (Composite parent ) {
322
- return list .getLabelControl ();
310
+ return myListControl .getLabelControl ();
323
311
}
324
312
325
313
@ Override
326
314
public void setEnabled (boolean enabled , Composite parent ) {
327
- list .setEnabled (enabled );
315
+ myListControl .setEnabled (enabled );
328
316
}
329
317
330
318
}
0 commit comments