Mercurial > projects > dwt-addons
comparison dwtx/jface/preference/FieldEditorPreferencePage.d @ 104:04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
These new wrappers now use the tango.util.containers instead of the tango.util.collections.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 07 Aug 2008 15:01:33 +0200 |
parents | 46a6e0e6ccd4 |
children |
comparison
equal
deleted
inserted
replaced
103:2d6540440fe6 | 104:04b47443bb01 |
---|---|
16 | 16 |
17 import dwtx.jface.preference.PreferencePage; | 17 import dwtx.jface.preference.PreferencePage; |
18 import dwtx.jface.preference.FieldEditor; | 18 import dwtx.jface.preference.FieldEditor; |
19 import dwtx.jface.preference.FieldEditorPreferencePage; | 19 import dwtx.jface.preference.FieldEditorPreferencePage; |
20 | 20 |
21 import tango.util.collection.ArraySeq; | |
22 import tango.util.collection.model.Seq; | |
23 // import java.util.Iterator; | 21 // import java.util.Iterator; |
24 // import java.util.List; | 22 // import java.util.List; |
25 | 23 |
26 import dwt.DWT; | 24 import dwt.DWT; |
27 import dwt.layout.GridData; | 25 import dwt.layout.GridData; |
31 import dwtx.jface.resource.ImageDescriptor; | 29 import dwtx.jface.resource.ImageDescriptor; |
32 import dwtx.jface.util.IPropertyChangeListener; | 30 import dwtx.jface.util.IPropertyChangeListener; |
33 import dwtx.jface.util.PropertyChangeEvent; | 31 import dwtx.jface.util.PropertyChangeEvent; |
34 | 32 |
35 import dwt.dwthelper.utils; | 33 import dwt.dwthelper.utils; |
34 import dwtx.dwtxhelper.Collection; | |
36 | 35 |
37 /** | 36 /** |
38 * A special abstract preference page to host field editors. | 37 * A special abstract preference page to host field editors. |
39 * <p> | 38 * <p> |
40 * Subclasses must implement the <code>createFieldEditors</code> method | 39 * Subclasses must implement the <code>createFieldEditors</code> method |
76 protected static const int MARGIN_HEIGHT = 0; | 75 protected static const int MARGIN_HEIGHT = 0; |
77 | 76 |
78 /** | 77 /** |
79 * The field editors, or <code>null</code> if not created yet. | 78 * The field editors, or <code>null</code> if not created yet. |
80 */ | 79 */ |
81 private Seq!(Object) fields = null; | 80 private List fields = null; |
82 | 81 |
83 /** | 82 /** |
84 * The layout style; either <code>FLAT</code> or <code>GRID</code>. | 83 * The layout style; either <code>FLAT</code> or <code>GRID</code>. |
85 */ | 84 */ |
86 private int style; | 85 private int style; |
146 * | 145 * |
147 * @param editor the field editor | 146 * @param editor the field editor |
148 */ | 147 */ |
149 protected void addField(FieldEditor editor) { | 148 protected void addField(FieldEditor editor) { |
150 if (fields is null) { | 149 if (fields is null) { |
151 fields = new ArraySeq!(Object); | 150 fields = new ArrayList(); |
152 } | 151 } |
153 fields.append(editor); | 152 fields.add(editor); |
154 } | 153 } |
155 | 154 |
156 /** | 155 /** |
157 * Adjust the layout of the field editors so that | 156 * Adjust the layout of the field editors so that |
158 * they are properly aligned. | 157 * they are properly aligned. |
171 /** | 170 /** |
172 * Applys the font to the field editors managed by this page. | 171 * Applys the font to the field editors managed by this page. |
173 */ | 172 */ |
174 protected void applyFont() { | 173 protected void applyFont() { |
175 if (fields !is null) { | 174 if (fields !is null) { |
176 foreach( e; fields ){ | 175 Iterator e = fields.iterator(); |
177 FieldEditor pe = cast(FieldEditor) e; | 176 while (e.hasNext()) { |
177 FieldEditor pe = cast(FieldEditor) e.next(); | |
178 pe.applyFont_package(); | 178 pe.applyFont_package(); |
179 } | 179 } |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
186 * @return the number of columns | 186 * @return the number of columns |
187 */ | 187 */ |
188 private int calcNumberOfColumns() { | 188 private int calcNumberOfColumns() { |
189 int result = 0; | 189 int result = 0; |
190 if (fields !is null) { | 190 if (fields !is null) { |
191 foreach( e; fields ){ | 191 Iterator e = fields.iterator(); |
192 FieldEditor pe = cast(FieldEditor) e; | 192 while (e.hasNext()) { |
193 FieldEditor pe = cast(FieldEditor) e.next(); | |
193 result = Math.max(result, pe.getNumberOfControls()); | 194 result = Math.max(result, pe.getNumberOfControls()); |
194 } | 195 } |
195 } | 196 } |
196 return result; | 197 return result; |
197 } | 198 } |
266 * resources, but must call <code>super.dispose</code>. | 267 * resources, but must call <code>super.dispose</code>. |
267 */ | 268 */ |
268 public override void dispose() { | 269 public override void dispose() { |
269 super.dispose(); | 270 super.dispose(); |
270 if (fields !is null) { | 271 if (fields !is null) { |
271 foreach( e; fields ){ | 272 Iterator e = fields.iterator(); |
272 FieldEditor pe = cast(FieldEditor) e; | 273 while (e.hasNext()) { |
274 FieldEditor pe = cast(FieldEditor) e.next(); | |
273 pe.setPage(null); | 275 pe.setPage(null); |
274 pe.setPropertyChangeListener(null); | 276 pe.setPropertyChangeListener(null); |
275 pe.setPreferenceStore(null); | 277 pe.setPreferenceStore(null); |
276 } | 278 } |
277 } | 279 } |
302 /** | 304 /** |
303 * Initializes all field editors. | 305 * Initializes all field editors. |
304 */ | 306 */ |
305 protected void initialize() { | 307 protected void initialize() { |
306 if (fields !is null) { | 308 if (fields !is null) { |
307 foreach( e; fields ){ | 309 Iterator e = fields.iterator(); |
308 FieldEditor pe = cast(FieldEditor) e; | 310 while (e.hasNext()) { |
311 FieldEditor pe = cast(FieldEditor) e.next(); | |
309 pe.setPage(this); | 312 pe.setPage(this); |
310 pe.setPropertyChangeListener(this); | 313 pe.setPropertyChangeListener(this); |
311 pe.setPreferenceStore(getPreferenceStore()); | 314 pe.setPreferenceStore(getPreferenceStore()); |
312 pe.load(); | 315 pe.load(); |
313 } | 316 } |
318 * The field editor preference page implementation of a <code>PreferencePage</code> | 321 * The field editor preference page implementation of a <code>PreferencePage</code> |
319 * method loads all the field editors with their default values. | 322 * method loads all the field editors with their default values. |
320 */ | 323 */ |
321 protected override void performDefaults() { | 324 protected override void performDefaults() { |
322 if (fields !is null) { | 325 if (fields !is null) { |
323 foreach( e; fields ){ | 326 Iterator e = fields.iterator(); |
324 FieldEditor pe = cast(FieldEditor) e; | 327 while (e.hasNext()) { |
328 FieldEditor pe = cast(FieldEditor) e.next(); | |
325 pe.loadDefault(); | 329 pe.loadDefault(); |
326 } | 330 } |
327 } | 331 } |
328 // Force a recalculation of my error state. | 332 // Force a recalculation of my error state. |
329 checkState(); | 333 checkState(); |
339 * | 343 * |
340 * @see FieldEditor#store() | 344 * @see FieldEditor#store() |
341 */ | 345 */ |
342 public override bool performOk() { | 346 public override bool performOk() { |
343 if (fields !is null) { | 347 if (fields !is null) { |
344 foreach( e; fields ){ | 348 Iterator e = fields.iterator(); |
345 FieldEditor pe = cast(FieldEditor) e; | 349 while (e.hasNext()) { |
350 FieldEditor pe = cast(FieldEditor) e.next(); | |
346 pe.store(); | 351 pe.store(); |
347 pe.setPresentsDefaultValue_package(false); | 352 pe.setPresentsDefaultValue_package(false); |
348 } | 353 } |
349 } | 354 } |
350 return true; | 355 return true; |