9
9
import org .eclipse .core .runtime .Status ;
10
10
import org .eclipse .core .runtime .preferences .IEclipsePreferences ;
11
11
import org .eclipse .core .runtime .preferences .InstanceScope ;
12
- import org .eclipse .swt . SWT ;
12
+ import org .eclipse .jface . dialogs . MessageDialog ;
13
13
import org .eclipse .swt .widgets .Display ;
14
- import org .eclipse .swt .widgets .MessageBox ;
15
- import org .eclipse .swt .widgets .Shell ;
16
- import org .eclipse .ui .PlatformUI ;
17
14
import org .osgi .service .prefs .BackingStoreException ;
18
15
19
16
/**
20
- * ArduinoPreferences is a class containing only static methods that help managing the preferences.
17
+ * ArduinoPreferences is a class containing only static methods that help
18
+ * managing the preferences.
21
19
*
22
20
* @author jan Baeyens
23
21
*
@@ -46,17 +44,19 @@ public static void setAutomaticallyIncludeLibraries(boolean value) {
46
44
}
47
45
48
46
/***
49
- * get the stored option whether a build before the upload is wanted or not. If nothing is stored the option is ask and this method will pop up a
47
+ * get the stored option whether a build before the upload is wanted or not.
48
+ * If nothing is stored the option is ask and this method will pop up a
50
49
* dialogbox
51
50
*
52
- * @return true if a build is wanted before upload false if no build is wanted before upload
51
+ * @return true if a build is wanted before upload false if no build is
52
+ * wanted before upload
53
53
*/
54
54
public static boolean getBuildBeforeUploadOption () {
55
55
56
56
switch (getGlobalString (KEY_BUILD_BEFORE_UPLOAD_OPTION , "ASK" )) { //$NON-NLS-1$
57
- case "YES" : //$NON-NLS-1$
57
+ case Const . TRUE :
58
58
return true ;
59
- case "NO" : //$NON-NLS-1$
59
+ case Const . FALSE :
60
60
return false ;
61
61
default :
62
62
break ;
@@ -70,17 +70,26 @@ boolean getAnswer() {
70
70
71
71
@ Override
72
72
public void run () {
73
- Shell theShell = PlatformUI .getWorkbench ().getDisplay ().getActiveShell ();
74
- MessageBox dialog = new MessageBox (theShell , SWT .ICON_QUESTION | SWT .YES | SWT .NO );
75
- dialog .setText (Messages .Build_before_upload );
76
- dialog .setMessage (Messages .do_you_want_to_build_before_upload );
73
+
74
+ MessageDialog dialog = new MessageDialog (null , Messages .Build_before_upload , null ,
75
+ Messages .do_you_want_to_build_before_upload , MessageDialog .QUESTION ,
76
+ new String [] { "Yes" , "No" , "Always" , "Never" }, 0 ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
77
+
77
78
switch (dialog .open ()) {
78
- case SWT .NO :
79
+ case 0 :
80
+ this .ret = true ;
81
+ break ;
82
+ case 1 :
79
83
this .ret = false ;
80
84
break ;
81
- case SWT .YES :
85
+ case 2 :
86
+ setGlobalValue (KEY_BUILD_BEFORE_UPLOAD_OPTION , Const .TRUE );
82
87
this .ret = true ;
83
88
break ;
89
+ case 3 :
90
+ setGlobalValue (KEY_BUILD_BEFORE_UPLOAD_OPTION , Const .FALSE );
91
+ this .ret = false ;
92
+ break ;
84
93
default :
85
94
this .ret = false ;
86
95
break ;
@@ -93,7 +102,8 @@ public void run() {
93
102
}
94
103
95
104
/**
96
- * This method reads the name of the last used arduino board from the instance preferences
105
+ * This method reads the name of the last used arduino board from the
106
+ * instance preferences
97
107
*
98
108
* @return the Arduino Board name
99
109
* @author Jan Baeyens
@@ -173,7 +183,8 @@ public static void setGlobalValue(String key, String Value) {
173
183
try {
174
184
myScope .flush ();
175
185
} catch (BackingStoreException e ) {
176
- Common .log (new Status (IStatus .WARNING , CORE_PLUGIN_ID , "failed to set global variable of type string " + key )); //$NON-NLS-1$
186
+ Common .log (
187
+ new Status (IStatus .WARNING , CORE_PLUGIN_ID , "failed to set global variable of type string " + key )); //$NON-NLS-1$
177
188
e .printStackTrace ();
178
189
}
179
190
}
@@ -195,7 +206,8 @@ protected static void setGlobalValue(String key, boolean Value) {
195
206
try {
196
207
myScope .flush ();
197
208
} catch (BackingStoreException e ) {
198
- Common .log (new Status (IStatus .WARNING , CORE_PLUGIN_ID , "failed to set global variable of type boolean " + key )); //$NON-NLS-1$
209
+ Common .log (new Status (IStatus .WARNING , CORE_PLUGIN_ID ,
210
+ "failed to set global variable of type boolean " + key )); //$NON-NLS-1$
199
211
e .printStackTrace ();
200
212
}
201
213
}
@@ -206,13 +218,15 @@ protected static void setGlobalValue(String key, long Value) {
206
218
try {
207
219
myScope .flush ();
208
220
} catch (BackingStoreException e ) {
209
- Common .log (new Status (IStatus .WARNING , CORE_PLUGIN_ID , "failed to set global variable of type long " + key )); //$NON-NLS-1$
221
+ Common .log (
222
+ new Status (IStatus .WARNING , CORE_PLUGIN_ID , "failed to set global variable of type long " + key )); //$NON-NLS-1$
210
223
e .printStackTrace ();
211
224
}
212
225
}
213
226
214
227
/**
215
- * This method returns the index of the last used line ending options are CR LF CR+LF none
228
+ * This method returns the index of the last used line ending options are CR
229
+ * LF CR+LF none
216
230
*
217
231
* @return the index of the last used setting
218
232
*/
@@ -221,7 +235,8 @@ public static int getLastUsedSerialLineEnd() {
221
235
}
222
236
223
237
/**
224
- * This method returns the index of the last used line ending options are CR LF CR+LF none
238
+ * This method returns the index of the last used line ending options are CR
239
+ * LF CR+LF none
225
240
*
226
241
* @return the index of the last used setting
227
242
*/
@@ -278,7 +293,8 @@ public static void setConfigured() {
278
293
}
279
294
280
295
/**
281
- * This method returns boolean whether the plugin is properly configured The plugin is configured properly if a board has been installed
296
+ * This method returns boolean whether the plugin is properly configured The
297
+ * plugin is configured properly if a board has been installed
282
298
*
283
299
* @return
284
300
*/
@@ -356,8 +372,8 @@ public static void setPrivateHardwarePaths(String[] folderName) {
356
372
* @return a list of all the folder locations that can contain hardware
357
373
*/
358
374
public static String [] getHardwarePaths () {
359
- return (getGlobalString (KEY_PRIVATE_HARDWARE_PATHS , EMPTY_STRING ) + File .pathSeparator + ConfigurationPreferences . getInstallationPath ())
360
- .split (File .pathSeparator );
375
+ return (getGlobalString (KEY_PRIVATE_HARDWARE_PATHS , EMPTY_STRING ) + File .pathSeparator
376
+ + ConfigurationPreferences . getInstallationPath ()) .split (File .pathSeparator );
361
377
}
362
378
363
379
}
0 commit comments