Skip to content

Commit

Permalink
Prepare preference page for adding json update option
Browse files Browse the repository at this point in the history
  • Loading branch information
jan committed Oct 23, 2024
1 parent 1fe98b0 commit 4924f85
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 58 deletions.
3 changes: 2 additions & 1 deletion io.sloeber.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.ui,
org.apache.commons.commons-io,
io.sloeber.autoBuild,
org.eclipse.jface,
io.sloeber.autoBuild.ui
io.sloeber.autoBuild.ui,
org.eclipse.swt
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Bundle-Vendor: Sloeber.io
Expand Down
8 changes: 7 additions & 1 deletion io.sloeber.ui/src/io/sloeber/ui/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ public class Messages extends NLS {
public static String packageTooltip;

public static String PlatformSelectionPage_hide_third_party_url;
public static String platformSelectionTip;
public static String PreferencePage_Internal_Behaviour_Group_Title;

public static String PreferencePage_Network_Group_Title;

public static String PreferencePage_UI_Behaviour_Group_Title;

public static String platformSelectionTip;
public static String pleaseWaitForInstallerJob;
public static String plotterViewChannel;
public static String plotterViewConnectedTo;
Expand Down
3 changes: 3 additions & 0 deletions io.sloeber.ui/src/io/sloeber/ui/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ BoardSelectionPage_platform_folder=Platform folder
BoardSelectionPage_platform_you_want_to_use=The platform you want to use
BoardSelectionPage_upload_protocol=Programmer protocol
PlatformSelectionPage_hide_third_party_url=Hide 3th party json files
PreferencePage_Internal_Behaviour_Group_Title=Internal behaviour
PreferencePage_Network_Group_Title=Stuff that needs a network
PreferencePage_UI_Behaviour_Group_Title=UI behaviour
always=Always
arduino_upload_project_handler_build_failed=The build failed\!
arduino_upload_project_handler_build_failed_so_no_upload=As the build failed the upload is not executed.
Expand Down
175 changes: 119 additions & 56 deletions io.sloeber.ui/src/io/sloeber/ui/preferences/PreferencePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@
import org.eclipse.jface.preference.ComboFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.PathEditor;
import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.eclipse.ui.themes.ITheme;
import org.eclipse.ui.themes.IThemeManager;

import io.sloeber.arduinoFramework.api.BoardsManager;
import io.sloeber.arduinoFramework.api.LibraryManager;
Expand Down Expand Up @@ -187,63 +194,127 @@ public void init(IWorkbench workbench) {
*/
@Override
protected void createFieldEditors() {
final Composite parent = getFieldEditorParent();
final Composite rootParent = getFieldEditorParent();
Dialog.applyDialogFont(rootParent);
IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
ITheme currentTheme = themeManager.getCurrentTheme();
FontRegistry fontRegistry = currentTheme.getFontRegistry();
Font headerFont =fontRegistry.get(JFaceResources.HEADER_FONT);

this.arduinoPrivateLibPathPathEditor = new PathEditor(KEY_PRIVATE_LIBRARY_PATHS, Messages.ui_private_lib_path,
Messages.ui_private_lib_path_help, parent);
addField(this.arduinoPrivateLibPathPathEditor);
arduinoPrivateLibPathPathEditor = new PathEditor(KEY_PRIVATE_LIBRARY_PATHS, Messages.ui_private_lib_path,
Messages.ui_private_lib_path_help, rootParent);
addField(arduinoPrivateLibPathPathEditor);

this.arduinoPrivateHardwarePathPathEditor = new PathEditor(KEY_PRIVATE_HARDWARE_PATHS, Messages.ui_private_hardware_path,
Messages.ui_private_hardware_path_help, parent);
addField(this.arduinoPrivateHardwarePathPathEditor);

Dialog.applyDialogFont(parent);
createLine(parent, 4);
String[][] YesNoAskOptions = new String[][] { { Messages.ui_ask_every_upload, "ASK" }, //$NON-NLS-1$
{ Messages.yes, TRUE }, { Messages.no, FALSE } };
this.buildBeforeUploadOptionEditor = new ComboFieldEditor(MyPreferences.KEY_BUILD_BEFORE_UPLOAD_OPTION,
Messages.ui_build_before_upload, YesNoAskOptions, parent);
addField(this.buildBeforeUploadOptionEditor);
createLine(parent, 4);

this.useArduinoToolchainSelectionEditor = new BooleanFieldEditor(KEY_TOOLCHAIN_SELECTION,
Messages.ui_use_arduino_toolchain_selection, BooleanFieldEditor.DEFAULT, parent);
addField(this.useArduinoToolchainSelectionEditor);

createLine(parent, 4);
this.openSerialMonitorOpensSerialsOptionEditor = new BooleanFieldEditor(MyPreferences.KEY_OPEN_SERIAL_WITH_MONITOR,
Messages.ui_open_serial_with_monitor, BooleanFieldEditor.DEFAULT, parent);
addField(this.openSerialMonitorOpensSerialsOptionEditor);
createLine(parent, 4);
arduinoPrivateHardwarePathPathEditor = new PathEditor(KEY_PRIVATE_HARDWARE_PATHS, Messages.ui_private_hardware_path,
Messages.ui_private_hardware_path_help, rootParent);
addField(arduinoPrivateHardwarePathPathEditor);


this.automaticallyImportLibrariesOptionEditor = new BooleanFieldEditor(KEY_AUTO_IMPORT_LIBRARIES,
Messages.ui_auto_import_libraries, BooleanFieldEditor.DEFAULT, parent);
addField(this.automaticallyImportLibrariesOptionEditor);
this.automaticallyInstallLibrariesOptionEditor = new BooleanFieldEditor(MyPreferences.KEY_AUTO_INSTALL_LIBRARIES,
Messages.ui_auto_install_libraries, BooleanFieldEditor.DEFAULT, parent);
addField(this.automaticallyInstallLibrariesOptionEditor);
Composite parent = new Composite(rootParent, SWT.NONE);
GridData gd1=new GridData(SWT.BEGINNING,SWT.CENTER,false,false);
//gd1.horizontalSpan=2;
parent.setLayoutData(gd1);
parent.setLayout(new GridLayout(1,false));

this.pragmaOnceHeaderOptionEditor = new BooleanFieldEditor(KEY_PRAGMA_ONCE_HEADERS, Messages.ui_pragma_once_headers,
BooleanFieldEditor.DEFAULT, parent);
addField(this.pragmaOnceHeaderOptionEditor);

this.cleanSerialMonitorAfterUploadEditor = new BooleanFieldEditor(MyPreferences.KEY_CLEAN_MONITOR_AFTER_UPLOAD,
Messages.ui_clean_serial_monitor_after_upload, BooleanFieldEditor.DEFAULT, parent);
addField(this.cleanSerialMonitorAfterUploadEditor);
Group UIboxparent= new Group(parent, SWT.BORDER_SOLID );
UIboxparent.setText(Messages.PreferencePage_UI_Behaviour_Group_Title);
UIboxparent.setFont(headerFont);
UIboxparent.setLayout(new GridLayout(2,true));
GridData gd11=new GridData(SWT.FILL,SWT.TOP,true,false);
//gd11.horizontalSpan=4;
UIboxparent.setLayoutData(gd11);

this.switchToSerialMonitorAfterUploadEditor = new BooleanFieldEditor(MyPreferences.SWITCH_TO_MONITOR_AFTER_UPLOAD,
Messages.ui_switch_to_serial_monitor_after_upload, BooleanFieldEditor.DEFAULT, parent);
addField(this.switchToSerialMonitorAfterUploadEditor);
Composite UIbox = new Composite(UIboxparent, SWT.NONE);
GridData gd12=new GridData(SWT.FILL,SWT.TOP,true,false);
gd12.horizontalSpan=2;
UIbox.setLayoutData(gd12);
UIbox.setLayout(new GridLayout(2,false));

this.enableParallelBuildForNewProjects = new BooleanFieldEditor(MyPreferences.KEY_ENABLE_PARALLEL_BUILD_FOR_NEW_PROJECTS,
Messages.ui_enable_parallel_build_for_new_projects, BooleanFieldEditor.DEFAULT, parent);
addField(this.enableParallelBuildForNewProjects);

String[][] YesNoAskOptions = new String[][] { { Messages.ui_ask_every_upload, "ASK" }, //$NON-NLS-1$
{ Messages.yes, TRUE }, { Messages.no, FALSE } };
buildBeforeUploadOptionEditor = new ComboFieldEditor(MyPreferences.KEY_BUILD_BEFORE_UPLOAD_OPTION,
Messages.ui_build_before_upload, YesNoAskOptions, UIbox);
addField(buildBeforeUploadOptionEditor);

Composite UIbox2 = new Composite(UIboxparent, SWT.NONE);
GridData gd13 = new GridData(SWT.FILL, SWT.TOP, true, false);
gd13.horizontalSpan = 2;
UIbox2.setLayoutData(gd13);
UIbox2.setLayout(new GridLayout(2, false));
Dialog.applyDialogFont(UIbox2);

openSerialMonitorOpensSerialsOptionEditor = new BooleanFieldEditor(MyPreferences.KEY_OPEN_SERIAL_WITH_MONITOR,
Messages.ui_open_serial_with_monitor, BooleanFieldEditor.DEFAULT, UIbox2);
addField(openSerialMonitorOpensSerialsOptionEditor);

automaticallyImportLibrariesOptionEditor = new BooleanFieldEditor(KEY_AUTO_IMPORT_LIBRARIES,
Messages.ui_auto_import_libraries, BooleanFieldEditor.DEFAULT, UIbox2);
addField(automaticallyImportLibrariesOptionEditor);

cleanSerialMonitorAfterUploadEditor = new BooleanFieldEditor(MyPreferences.KEY_CLEAN_MONITOR_AFTER_UPLOAD,
Messages.ui_clean_serial_monitor_after_upload, BooleanFieldEditor.DEFAULT, UIbox2);
addField(cleanSerialMonitorAfterUploadEditor);

switchToSerialMonitorAfterUploadEditor = new BooleanFieldEditor(MyPreferences.SWITCH_TO_MONITOR_AFTER_UPLOAD,
Messages.ui_switch_to_serial_monitor_after_upload, BooleanFieldEditor.DEFAULT, UIbox2);
addField(switchToSerialMonitorAfterUploadEditor);


Group internalBehaviourGroup= new Group(parent, SWT.BORDER_SOLID);
internalBehaviourGroup.setText(Messages.PreferencePage_Internal_Behaviour_Group_Title);
GridData gd2=new GridData(SWT.FILL,SWT.TOP,true,false);
//gd2.horizontalSpan=2;
internalBehaviourGroup.setLayout(new GridLayout(2,true));
internalBehaviourGroup.setLayoutData(gd2);
internalBehaviourGroup.setFont(headerFont);

Composite internalBehaviourbox = new Composite(internalBehaviourGroup, SWT.NONE);
GridData gd14 = new GridData(SWT.FILL, SWT.TOP, true, false);
gd14.horizontalSpan = 2;
internalBehaviourbox.setLayoutData(gd14);
internalBehaviourbox.setLayout(new GridLayout(2, false));
Dialog.applyDialogFont(internalBehaviourbox);

// internalBehaviourGroup.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
// internalBehaviourbox.setBackground(display.getSystemColor(SWT.COLOR_RED));

useArduinoToolchainSelectionEditor = new BooleanFieldEditor(KEY_TOOLCHAIN_SELECTION,
Messages.ui_use_arduino_toolchain_selection, BooleanFieldEditor.DEFAULT, internalBehaviourbox);
addField(useArduinoToolchainSelectionEditor);

pragmaOnceHeaderOptionEditor = new BooleanFieldEditor(KEY_PRAGMA_ONCE_HEADERS, Messages.ui_pragma_once_headers,
BooleanFieldEditor.DEFAULT, internalBehaviourbox);
addField(pragmaOnceHeaderOptionEditor);

enableParallelBuildForNewProjects = new BooleanFieldEditor(MyPreferences.KEY_ENABLE_PARALLEL_BUILD_FOR_NEW_PROJECTS,
Messages.ui_enable_parallel_build_for_new_projects, BooleanFieldEditor.DEFAULT, internalBehaviourbox);
addField(enableParallelBuildForNewProjects);

Group netWorkGroup= new Group(parent, SWT.BORDER_SOLID);
netWorkGroup.setText(Messages.PreferencePage_Network_Group_Title);
GridData gd3=new GridData(SWT.FILL,SWT.TOP,true,false);
//gd3.horizontalSpan=2;
netWorkGroup.setLayoutData(gd3);
netWorkGroup.setFont(headerFont);
netWorkGroup.setLayout(new GridLayout(2,true));

Composite netWorkbox = new Composite(netWorkGroup, SWT.NONE);
GridData gd15 = new GridData(SWT.FILL, SWT.TOP, true, false);
gd15.horizontalSpan = 2;
netWorkbox.setLayoutData(gd15);
netWorkbox.setLayout(new GridLayout(2, false));
Dialog.applyDialogFont(netWorkbox);

automaticallyInstallLibrariesOptionEditor = new BooleanFieldEditor(MyPreferences.KEY_AUTO_INSTALL_LIBRARIES,
Messages.ui_auto_install_libraries, BooleanFieldEditor.DEFAULT, netWorkbox);
addField(automaticallyInstallLibrariesOptionEditor);

enableBonjour = new BooleanFieldEditor(KEY_USE_BONJOUR,
Messages.ui_enable_bonjour, BooleanFieldEditor.DEFAULT, netWorkbox);
addField(enableBonjour);

this.enableBonjour = new BooleanFieldEditor(KEY_USE_BONJOUR,
Messages.ui_enable_bonjour, BooleanFieldEditor.DEFAULT, parent);
addField(this.enableBonjour);
}

/**
Expand All @@ -269,13 +340,5 @@ protected void performApply() {
super.performApply();
}

private static void createLine(Composite parent, int ncol) {
Label line = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.BOLD);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = ncol;
line.setLayoutData(gridData);
}



}

0 comments on commit 4924f85

Please sign in to comment.