@@ -28,7 +28,7 @@ public class ArduinoInstancePreferences extends ArduinoConst {
28
28
*/
29
29
public static boolean getBuildBeforeUploadOption () {
30
30
31
- switch (getGlobalValue (KEY_BUILD_BEFORE_UPLOAD_OPTION , "ASK" )) {
31
+ switch (getGlobalString (KEY_BUILD_BEFORE_UPLOAD_OPTION , "ASK" )) {
32
32
case "YES" :
33
33
return true ;
34
34
case "NO" :
@@ -74,7 +74,7 @@ public void run() {
74
74
* @author Jan Baeyens
75
75
*/
76
76
public static String getLastUsedArduinoBoardName () {
77
- return getGlobalValue (KEY_LAST_USED_ARDUINOBOARD );
77
+ return getGlobalString (KEY_LAST_USED_ARDUINOBOARD , "" );
78
78
}
79
79
80
80
/**
@@ -84,7 +84,7 @@ public static String getLastUsedArduinoBoardName() {
84
84
* @author Jan Baeyens
85
85
*/
86
86
public static String getLastUsedUploadPort () {
87
- return getGlobalValue (KEY_LAST_USED_COM_PORT );
87
+ return getGlobalString (KEY_LAST_USED_COM_PORT , "" );
88
88
}
89
89
90
90
/**
@@ -94,7 +94,7 @@ public static String getLastUsedUploadPort() {
94
94
* @author Jan Baeyens
95
95
*/
96
96
public static String getLastUsedUploadProgrammer () {
97
- return getGlobalValue (KEY_LAST_USED_PROGRAMMER , ArduinoConst .DEFAULT );
97
+ return getGlobalString (KEY_LAST_USED_PROGRAMMER , ArduinoConst .DEFAULT );
98
98
}
99
99
100
100
/**
@@ -135,19 +135,11 @@ public static void SetLastUsedArduinoBoard(String ArduinoBoardName) {
135
135
setGlobalValue (KEY_LAST_USED_ARDUINOBOARD , ArduinoBoardName );
136
136
}
137
137
138
- public static String getGlobalValue (String key , String defaultValue ) {
138
+ public static String getGlobalString (String key , String defaultValue ) {
139
139
IEclipsePreferences myScope = InstanceScope .INSTANCE .getNode (NODE_ARDUINO );
140
140
return myScope .get (key , defaultValue );
141
141
}
142
142
143
- public static String getGlobalValue (String key ) {
144
- return getGlobalValue (key , "" );
145
- }
146
-
147
- protected static boolean getGlobalBoolean (String key ) {
148
- return getGlobalBoolean (key , false );
149
- }
150
-
151
143
protected static boolean getGlobalBoolean (String key , boolean def ) {
152
144
IEclipsePreferences myScope = InstanceScope .INSTANCE .getNode (NODE_ARDUINO );
153
145
return myScope .getBoolean (key , def );
@@ -158,6 +150,11 @@ protected static int getGlobalInt(String key) {
158
150
return myScope .getInt (key , 0 );
159
151
}
160
152
153
+ protected static long getGlobalLong (String key ) {
154
+ IEclipsePreferences myScope = InstanceScope .INSTANCE .getNode (NODE_ARDUINO );
155
+ return myScope .getLong (key , 0 );
156
+ }
157
+
161
158
public static void setGlobalValue (String key , String Value ) {
162
159
163
160
IEclipsePreferences myScope = InstanceScope .INSTANCE .getNode (NODE_ARDUINO );
@@ -170,7 +167,7 @@ public static void setGlobalValue(String key, String Value) {
170
167
}
171
168
}
172
169
173
- protected static void setGlobalInt (String key , int Value ) {
170
+ protected static void setGlobalValue (String key , int Value ) {
174
171
IEclipsePreferences myScope = InstanceScope .INSTANCE .getNode (NODE_ARDUINO );
175
172
myScope .putInt (key , Value );
176
173
try {
@@ -181,7 +178,7 @@ protected static void setGlobalInt(String key, int Value) {
181
178
}
182
179
}
183
180
184
- protected static void setGlobalBoolean (String key , boolean Value ) {
181
+ protected static void setGlobalValue (String key , boolean Value ) {
185
182
IEclipsePreferences myScope = InstanceScope .INSTANCE .getNode (NODE_ARDUINO );
186
183
myScope .putBoolean (key , Value );
187
184
try {
@@ -192,14 +189,25 @@ protected static void setGlobalBoolean(String key, boolean Value) {
192
189
}
193
190
}
194
191
192
+ protected static void setGlobalValue (String key , long Value ) {
193
+ IEclipsePreferences myScope = InstanceScope .INSTANCE .getNode (NODE_ARDUINO );
194
+ myScope .putLong (key , Value );
195
+ try {
196
+ myScope .flush ();
197
+ } catch (BackingStoreException e ) {
198
+ Common .log (new Status (IStatus .WARNING , CORE_PLUGIN_ID , "failed to set global variable of type long " + key ));
199
+ e .printStackTrace ();
200
+ }
201
+ }
202
+
195
203
/**
196
204
* getUseIDESettings get the UseIDESettings flag value from the preference store
197
205
*
198
206
* @return the value in the preference store representing the UseIDESettings flag
199
207
* @author Jan Baeyens
200
208
*/
201
- public static String getIDEVersion () {
202
- return ( getGlobalValue ( KEY_ARDUINO_IDE_VERSION ) );
209
+ public static String getArduinoIDEVersion () {
210
+ return getGlobalString ( KEY_ARDUINO_IDE_VERSION , "" ). trim ( );
203
211
}
204
212
205
213
/**
@@ -211,15 +219,15 @@ public static String getIDEVersion() {
211
219
* @return true if it is arduino 1.0 or later; otherwise false
212
220
*/
213
221
public static boolean isArduinoIdeOne () {
214
- return !getIDEVersion ().startsWith ("00" );
222
+ return !getArduinoIDEVersion ().startsWith ("00" );
215
223
}
216
224
217
225
/*
218
226
* This method returns the define value for the define ARDUINO
219
227
*/
220
- public static String GetARDUINODefineValue () {
228
+ public static String GetArduinoDefineValue () {
221
229
String Ret ;
222
- Ret = getIDEVersion ().trim ();
230
+ Ret = getArduinoIDEVersion ().trim ();
223
231
if (Ret .startsWith ("1.5" )) {
224
232
if (Ret .contains ("." )) {
225
233
Ret = Ret .replace ("." , "" );
@@ -253,20 +261,20 @@ public static int GetLastUsedSerialLineEnd() {
253
261
* @return the index of the last used setting
254
262
*/
255
263
public static void SetLastUsedSerialLineEnd (int LastUsedIndex ) {
256
- setGlobalInt (KEY_RXTX_LAST_USED_LINE_INDES , LastUsedIndex );
264
+ setGlobalValue (KEY_RXTX_LAST_USED_LINE_INDES , LastUsedIndex );
257
265
}
258
266
259
267
public static boolean getLastUsedAutoScroll () {
260
- return getGlobalBoolean (KEY_RXTX_LAST_USED_AUTOSCROLL );
268
+ return getGlobalBoolean (KEY_RXTX_LAST_USED_AUTOSCROLL , false );
261
269
}
262
270
263
271
public static void setLastUsedAutoScroll (boolean autoScroll ) {
264
- setGlobalBoolean (KEY_RXTX_LAST_USED_AUTOSCROLL , autoScroll );
272
+ setGlobalValue (KEY_RXTX_LAST_USED_AUTOSCROLL , autoScroll );
265
273
266
274
}
267
275
268
276
public static String getLastUsedBoardsFile () {
269
- return getGlobalValue (KEY_LAST_USED_ARDUINO_BOARDS_FILE );
277
+ return getGlobalString (KEY_LAST_USED_ARDUINO_BOARDS_FILE , "" );
270
278
}
271
279
272
280
public static void setLastUsedBoardsFile (String boardsFile ) {
@@ -280,11 +288,11 @@ public static void setLastUsedMenuOption(String menuOptions) {
280
288
}
281
289
282
290
public static String getLastUsedMenuOption () {
283
- return getGlobalValue (KEY_LAST_USED_ARDUINO_MENU_OPTIONS );
291
+ return getGlobalString (KEY_LAST_USED_ARDUINO_MENU_OPTIONS , "" );
284
292
}
285
293
286
294
public static IPath getArduinoPath () {
287
- return Common .getArduinoIDEPathFromUserSelection (getGlobalValue (KEY_ARDUINOPATH ));
295
+ return Common .getArduinoIDEPathFromUserSelection (getGlobalString (KEY_ARDUINOPATH , "" ));
288
296
}
289
297
290
298
/**
@@ -306,12 +314,12 @@ public static boolean isConfigured(boolean showError) {
306
314
}
307
315
308
316
public static boolean getLastUsedScopeFilter () {
309
- return getGlobalBoolean (KEY_LAST_USED_SCOPE_FILTER_MENU_OPTION );
317
+ return getGlobalBoolean (KEY_LAST_USED_SCOPE_FILTER_MENU_OPTION , false );
310
318
311
319
}
312
320
313
321
public static void setLastUsedScopeFilter (boolean newFilter ) {
314
- setGlobalBoolean (KEY_LAST_USED_SCOPE_FILTER_MENU_OPTION , newFilter );
322
+ setGlobalValue (KEY_LAST_USED_SCOPE_FILTER_MENU_OPTION , newFilter );
315
323
316
324
}
317
325
@@ -323,14 +331,14 @@ public static int getLastUsedDefaultSketchSelection() {
323
331
}
324
332
325
333
public static void setLastUsedDefaultSketchSelection (int newFilter ) {
326
- setGlobalInt (ENV_KEY_JANTJE_SKETCH_TEMPLATE_USE_DEFAULT , newFilter );
334
+ setGlobalValue (ENV_KEY_JANTJE_SKETCH_TEMPLATE_USE_DEFAULT , newFilter );
327
335
}
328
336
329
337
//
330
338
// get/set last used sketch template folder parameters
331
339
//
332
340
public static String getLastTemplateFolderName () {
333
- return getGlobalValue (ENV_KEY_JANTJE_SKETCH_TEMPLATE_FOLDER );
341
+ return getGlobalString (ENV_KEY_JANTJE_SKETCH_TEMPLATE_FOLDER , "" );
334
342
}
335
343
336
344
public static void setLastTemplateFolderName (String folderName ) {
@@ -339,18 +347,26 @@ public static void setLastTemplateFolderName(String folderName) {
339
347
}
340
348
341
349
public static String getPrivateLibraryPath () {
342
- return getGlobalValue (KEY_PRIVATE_LIBRARY_PATH );
350
+ return getGlobalString (KEY_PRIVATE_LIBRARY_PATH , "" );
343
351
}
344
352
345
353
public static void setPrivateLibraryPath (String folderName ) {
346
354
setGlobalValue (KEY_PRIVATE_LIBRARY_PATH , folderName );
347
355
}
348
356
349
357
public static String getPrivateHardwarePath () {
350
- return getGlobalValue (KEY_PRIVATE_HARDWARE_PATH );
358
+ return getGlobalString (KEY_PRIVATE_HARDWARE_PATH , "" );
351
359
}
352
360
353
361
public static void setPrivateHardwarePath (String folderName ) {
354
362
setGlobalValue (KEY_PRIVATE_HARDWARE_PATH , folderName );
355
363
}
364
+
365
+ public static long getStoredPreferenceModificatonStamp () {
366
+ return getGlobalLong (KEY_PREFERENCE_MODIFICATION_STAMP );
367
+ }
368
+
369
+ public static void getStoredPreferenceModificatonStamp (long stamp ) {
370
+ setGlobalValue (KEY_PREFERENCE_MODIFICATION_STAMP , stamp );
371
+ }
356
372
}
0 commit comments