15
15
import org .eclipse .jface .preference .ComboFieldEditor ;
16
16
import org .eclipse .jface .preference .FieldEditorPreferencePage ;
17
17
import org .eclipse .jface .preference .PathEditor ;
18
+ import org .eclipse .jface .resource .FontRegistry ;
19
+ import org .eclipse .jface .resource .JFaceResources ;
18
20
import org .eclipse .swt .SWT ;
21
+ import org .eclipse .swt .graphics .Font ;
19
22
import org .eclipse .swt .layout .GridData ;
23
+ import org .eclipse .swt .layout .GridLayout ;
20
24
import org .eclipse .swt .widgets .Composite ;
21
- import org .eclipse .swt .widgets .Label ;
25
+ import org .eclipse .swt .widgets .Group ;
22
26
import org .eclipse .ui .IWorkbench ;
23
27
import org .eclipse .ui .IWorkbenchPreferencePage ;
28
+ import org .eclipse .ui .PlatformUI ;
24
29
import org .eclipse .ui .preferences .ScopedPreferenceStore ;
30
+ import org .eclipse .ui .themes .ITheme ;
31
+ import org .eclipse .ui .themes .IThemeManager ;
25
32
26
33
import io .sloeber .arduinoFramework .api .BoardsManager ;
27
34
import io .sloeber .arduinoFramework .api .LibraryManager ;
@@ -187,63 +194,127 @@ public void init(IWorkbench workbench) {
187
194
*/
188
195
@ Override
189
196
protected void createFieldEditors () {
190
- final Composite parent = getFieldEditorParent ();
197
+ final Composite rootParent = getFieldEditorParent ();
198
+ Dialog .applyDialogFont (rootParent );
199
+ IThemeManager themeManager = PlatformUI .getWorkbench ().getThemeManager ();
200
+ ITheme currentTheme = themeManager .getCurrentTheme ();
201
+ FontRegistry fontRegistry = currentTheme .getFontRegistry ();
202
+ Font headerFont =fontRegistry .get (JFaceResources .HEADER_FONT );
191
203
192
- this . arduinoPrivateLibPathPathEditor = new PathEditor (KEY_PRIVATE_LIBRARY_PATHS , Messages .ui_private_lib_path ,
193
- Messages .ui_private_lib_path_help , parent );
194
- addField (this . arduinoPrivateLibPathPathEditor );
204
+ arduinoPrivateLibPathPathEditor = new PathEditor (KEY_PRIVATE_LIBRARY_PATHS , Messages .ui_private_lib_path ,
205
+ Messages .ui_private_lib_path_help , rootParent );
206
+ addField (arduinoPrivateLibPathPathEditor );
195
207
196
- this .arduinoPrivateHardwarePathPathEditor = new PathEditor (KEY_PRIVATE_HARDWARE_PATHS , Messages .ui_private_hardware_path ,
197
- Messages .ui_private_hardware_path_help , parent );
198
- addField (this .arduinoPrivateHardwarePathPathEditor );
199
-
200
- Dialog .applyDialogFont (parent );
201
- createLine (parent , 4 );
202
- String [][] YesNoAskOptions = new String [][] { { Messages .ui_ask_every_upload , "ASK" }, //$NON-NLS-1$
203
- { Messages .yes , TRUE }, { Messages .no , FALSE } };
204
- this .buildBeforeUploadOptionEditor = new ComboFieldEditor (MyPreferences .KEY_BUILD_BEFORE_UPLOAD_OPTION ,
205
- Messages .ui_build_before_upload , YesNoAskOptions , parent );
206
- addField (this .buildBeforeUploadOptionEditor );
207
- createLine (parent , 4 );
208
-
209
- this .useArduinoToolchainSelectionEditor = new BooleanFieldEditor (KEY_TOOLCHAIN_SELECTION ,
210
- Messages .ui_use_arduino_toolchain_selection , BooleanFieldEditor .DEFAULT , parent );
211
- addField (this .useArduinoToolchainSelectionEditor );
212
-
213
- createLine (parent , 4 );
214
- this .openSerialMonitorOpensSerialsOptionEditor = new BooleanFieldEditor (MyPreferences .KEY_OPEN_SERIAL_WITH_MONITOR ,
215
- Messages .ui_open_serial_with_monitor , BooleanFieldEditor .DEFAULT , parent );
216
- addField (this .openSerialMonitorOpensSerialsOptionEditor );
217
- createLine (parent , 4 );
208
+ arduinoPrivateHardwarePathPathEditor = new PathEditor (KEY_PRIVATE_HARDWARE_PATHS , Messages .ui_private_hardware_path ,
209
+ Messages .ui_private_hardware_path_help , rootParent );
210
+ addField (arduinoPrivateHardwarePathPathEditor );
218
211
219
212
220
- this .automaticallyImportLibrariesOptionEditor = new BooleanFieldEditor (KEY_AUTO_IMPORT_LIBRARIES ,
221
- Messages .ui_auto_import_libraries , BooleanFieldEditor .DEFAULT , parent );
222
- addField (this .automaticallyImportLibrariesOptionEditor );
223
- this .automaticallyInstallLibrariesOptionEditor = new BooleanFieldEditor (MyPreferences .KEY_AUTO_INSTALL_LIBRARIES ,
224
- Messages .ui_auto_install_libraries , BooleanFieldEditor .DEFAULT , parent );
225
- addField (this .automaticallyInstallLibrariesOptionEditor );
213
+ Composite parent = new Composite (rootParent , SWT .NONE );
214
+ GridData gd1 =new GridData (SWT .BEGINNING ,SWT .CENTER ,false ,false );
215
+ //gd1.horizontalSpan=2;
216
+ parent .setLayoutData (gd1 );
217
+ parent .setLayout (new GridLayout (1 ,false ));
226
218
227
- this .pragmaOnceHeaderOptionEditor = new BooleanFieldEditor (KEY_PRAGMA_ONCE_HEADERS , Messages .ui_pragma_once_headers ,
228
- BooleanFieldEditor .DEFAULT , parent );
229
- addField (this .pragmaOnceHeaderOptionEditor );
230
219
231
- this .cleanSerialMonitorAfterUploadEditor = new BooleanFieldEditor (MyPreferences .KEY_CLEAN_MONITOR_AFTER_UPLOAD ,
232
- Messages .ui_clean_serial_monitor_after_upload , BooleanFieldEditor .DEFAULT , parent );
233
- addField (this .cleanSerialMonitorAfterUploadEditor );
220
+ Group UIboxparent = new Group (parent , SWT .BORDER_SOLID );
221
+ UIboxparent .setText (Messages .PreferencePage_UI_Behaviour_Group_Title );
222
+ UIboxparent .setFont (headerFont );
223
+ UIboxparent .setLayout (new GridLayout (2 ,true ));
224
+ GridData gd11 =new GridData (SWT .FILL ,SWT .TOP ,true ,false );
225
+ //gd11.horizontalSpan=4;
226
+ UIboxparent .setLayoutData (gd11 );
234
227
235
- this .switchToSerialMonitorAfterUploadEditor = new BooleanFieldEditor (MyPreferences .SWITCH_TO_MONITOR_AFTER_UPLOAD ,
236
- Messages .ui_switch_to_serial_monitor_after_upload , BooleanFieldEditor .DEFAULT , parent );
237
- addField (this .switchToSerialMonitorAfterUploadEditor );
228
+ Composite UIbox = new Composite (UIboxparent , SWT .NONE );
229
+ GridData gd12 =new GridData (SWT .FILL ,SWT .TOP ,true ,false );
230
+ gd12 .horizontalSpan =2 ;
231
+ UIbox .setLayoutData (gd12 );
232
+ UIbox .setLayout (new GridLayout (2 ,false ));
238
233
239
- this .enableParallelBuildForNewProjects = new BooleanFieldEditor (MyPreferences .KEY_ENABLE_PARALLEL_BUILD_FOR_NEW_PROJECTS ,
240
- Messages .ui_enable_parallel_build_for_new_projects , BooleanFieldEditor .DEFAULT , parent );
241
- addField (this .enableParallelBuildForNewProjects );
242
234
235
+ String [][] YesNoAskOptions = new String [][] { { Messages .ui_ask_every_upload , "ASK" }, //$NON-NLS-1$
236
+ { Messages .yes , TRUE }, { Messages .no , FALSE } };
237
+ buildBeforeUploadOptionEditor = new ComboFieldEditor (MyPreferences .KEY_BUILD_BEFORE_UPLOAD_OPTION ,
238
+ Messages .ui_build_before_upload , YesNoAskOptions , UIbox );
239
+ addField (buildBeforeUploadOptionEditor );
240
+
241
+ Composite UIbox2 = new Composite (UIboxparent , SWT .NONE );
242
+ GridData gd13 = new GridData (SWT .FILL , SWT .TOP , true , false );
243
+ gd13 .horizontalSpan = 2 ;
244
+ UIbox2 .setLayoutData (gd13 );
245
+ UIbox2 .setLayout (new GridLayout (2 , false ));
246
+ Dialog .applyDialogFont (UIbox2 );
247
+
248
+ openSerialMonitorOpensSerialsOptionEditor = new BooleanFieldEditor (MyPreferences .KEY_OPEN_SERIAL_WITH_MONITOR ,
249
+ Messages .ui_open_serial_with_monitor , BooleanFieldEditor .DEFAULT , UIbox2 );
250
+ addField (openSerialMonitorOpensSerialsOptionEditor );
251
+
252
+ automaticallyImportLibrariesOptionEditor = new BooleanFieldEditor (KEY_AUTO_IMPORT_LIBRARIES ,
253
+ Messages .ui_auto_import_libraries , BooleanFieldEditor .DEFAULT , UIbox2 );
254
+ addField (automaticallyImportLibrariesOptionEditor );
255
+
256
+ cleanSerialMonitorAfterUploadEditor = new BooleanFieldEditor (MyPreferences .KEY_CLEAN_MONITOR_AFTER_UPLOAD ,
257
+ Messages .ui_clean_serial_monitor_after_upload , BooleanFieldEditor .DEFAULT , UIbox2 );
258
+ addField (cleanSerialMonitorAfterUploadEditor );
259
+
260
+ switchToSerialMonitorAfterUploadEditor = new BooleanFieldEditor (MyPreferences .SWITCH_TO_MONITOR_AFTER_UPLOAD ,
261
+ Messages .ui_switch_to_serial_monitor_after_upload , BooleanFieldEditor .DEFAULT , UIbox2 );
262
+ addField (switchToSerialMonitorAfterUploadEditor );
263
+
264
+
265
+ Group internalBehaviourGroup = new Group (parent , SWT .BORDER_SOLID );
266
+ internalBehaviourGroup .setText (Messages .PreferencePage_Internal_Behaviour_Group_Title );
267
+ GridData gd2 =new GridData (SWT .FILL ,SWT .TOP ,true ,false );
268
+ //gd2.horizontalSpan=2;
269
+ internalBehaviourGroup .setLayout (new GridLayout (2 ,true ));
270
+ internalBehaviourGroup .setLayoutData (gd2 );
271
+ internalBehaviourGroup .setFont (headerFont );
272
+
273
+ Composite internalBehaviourbox = new Composite (internalBehaviourGroup , SWT .NONE );
274
+ GridData gd14 = new GridData (SWT .FILL , SWT .TOP , true , false );
275
+ gd14 .horizontalSpan = 2 ;
276
+ internalBehaviourbox .setLayoutData (gd14 );
277
+ internalBehaviourbox .setLayout (new GridLayout (2 , false ));
278
+ Dialog .applyDialogFont (internalBehaviourbox );
279
+
280
+ // internalBehaviourGroup.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
281
+ // internalBehaviourbox.setBackground(display.getSystemColor(SWT.COLOR_RED));
282
+
283
+ useArduinoToolchainSelectionEditor = new BooleanFieldEditor (KEY_TOOLCHAIN_SELECTION ,
284
+ Messages .ui_use_arduino_toolchain_selection , BooleanFieldEditor .DEFAULT , internalBehaviourbox );
285
+ addField (useArduinoToolchainSelectionEditor );
286
+
287
+ pragmaOnceHeaderOptionEditor = new BooleanFieldEditor (KEY_PRAGMA_ONCE_HEADERS , Messages .ui_pragma_once_headers ,
288
+ BooleanFieldEditor .DEFAULT , internalBehaviourbox );
289
+ addField (pragmaOnceHeaderOptionEditor );
290
+
291
+ enableParallelBuildForNewProjects = new BooleanFieldEditor (MyPreferences .KEY_ENABLE_PARALLEL_BUILD_FOR_NEW_PROJECTS ,
292
+ Messages .ui_enable_parallel_build_for_new_projects , BooleanFieldEditor .DEFAULT , internalBehaviourbox );
293
+ addField (enableParallelBuildForNewProjects );
294
+
295
+ Group netWorkGroup = new Group (parent , SWT .BORDER_SOLID );
296
+ netWorkGroup .setText (Messages .PreferencePage_Network_Group_Title );
297
+ GridData gd3 =new GridData (SWT .FILL ,SWT .TOP ,true ,false );
298
+ //gd3.horizontalSpan=2;
299
+ netWorkGroup .setLayoutData (gd3 );
300
+ netWorkGroup .setFont (headerFont );
301
+ netWorkGroup .setLayout (new GridLayout (2 ,true ));
302
+
303
+ Composite netWorkbox = new Composite (netWorkGroup , SWT .NONE );
304
+ GridData gd15 = new GridData (SWT .FILL , SWT .TOP , true , false );
305
+ gd15 .horizontalSpan = 2 ;
306
+ netWorkbox .setLayoutData (gd15 );
307
+ netWorkbox .setLayout (new GridLayout (2 , false ));
308
+ Dialog .applyDialogFont (netWorkbox );
309
+
310
+ automaticallyInstallLibrariesOptionEditor = new BooleanFieldEditor (MyPreferences .KEY_AUTO_INSTALL_LIBRARIES ,
311
+ Messages .ui_auto_install_libraries , BooleanFieldEditor .DEFAULT , netWorkbox );
312
+ addField (automaticallyInstallLibrariesOptionEditor );
313
+
314
+ enableBonjour = new BooleanFieldEditor (KEY_USE_BONJOUR ,
315
+ Messages .ui_enable_bonjour , BooleanFieldEditor .DEFAULT , netWorkbox );
316
+ addField (enableBonjour );
243
317
244
- this .enableBonjour = new BooleanFieldEditor (KEY_USE_BONJOUR ,
245
- Messages .ui_enable_bonjour , BooleanFieldEditor .DEFAULT , parent );
246
- addField (this .enableBonjour );
247
318
}
248
319
249
320
/**
@@ -269,13 +340,5 @@ protected void performApply() {
269
340
super .performApply ();
270
341
}
271
342
272
- private static void createLine (Composite parent , int ncol ) {
273
- Label line = new Label (parent , SWT .SEPARATOR | SWT .HORIZONTAL | SWT .BOLD );
274
- GridData gridData = new GridData (GridData .FILL_HORIZONTAL );
275
- gridData .horizontalSpan = ncol ;
276
- line .setLayoutData (gridData );
277
- }
278
-
279
-
280
343
281
344
}
0 commit comments