27
27
import org .eclipse .core .runtime .preferences .InstanceScope ;
28
28
import org .eclipse .ui .plugin .AbstractUIPlugin ;
29
29
import org .osgi .framework .BundleContext ;
30
- import org .osgi .service .prefs .BackingStoreException ;
31
30
32
31
import cc .arduino .packages .discoverers .NetworkDiscovery ;
33
32
import io .sloeber .core .common .Common ;
39
38
import io .sloeber .core .managers .Manager ;
40
39
41
40
abstract class FamilyJob extends Job {
42
- static final String MY_FAMILY = "myJobFamily" ; //$NON-NLS-1$
41
+ static final String MY_FAMILY = "myJobFamily" ;
43
42
44
43
public FamilyJob (String name ) {
45
44
super (name );
@@ -58,25 +57,23 @@ public boolean belongsTo(Object family) {
58
57
* @author Jan Baeyens
59
58
*
60
59
*/
60
+ @ SuppressWarnings ("nls" )
61
61
public class Activator extends AbstractUIPlugin {
62
62
// preference nodes
63
- public static final String NODE_ARDUINO = "io.sloeber.arduino" ; //$NON-NLS-1$
63
+ public static final String NODE_ARDUINO = "io.sloeber.arduino" ;
64
64
65
65
// The shared instance
66
- private static final String FLAGS_TART = "F" + "s" + "S" + "t" + "a" + "t" + "u" + "s" ; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
67
- private static final String FLAG_MONITOR = "F" + "m" + "S" + "t" + "a" + "t" + "u" + "s" ; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
68
- private static final String UPLOAD_FLAG = "F" + "u" + "S" + "t" + "a" + "t" + "u" + "s" ; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
69
- private static final String BUILD_FLAG = "F" + "u" + "S" + "t" + "a" + "t" + "u" + "b" ; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
70
- private static final String LOCAL_FLAG = "l" + FLAGS_TART ; //$NON-NLS-1$
71
- private static final String HELP_LOC = "http://www.baeyens.it/eclipse/remind.php" ; //$NON-NLS-1$
66
+ private static final String FLAG_START = "F" + "s" + "S" + "t" + "a" + "t" + "u" + "s" ;
67
+ private static final String UPLOAD_FLAG = "F" + "u" + "S" + "t" + "a" + "t" + "u" + "s" ;
68
+ private static final String BUILD_FLAG = "F" + "b" + "S" + "t" + "a" + "t" + "u" + "s" ;
69
+ private static final String LOCAL_FLAG = "l" + FLAG_START ;
70
+ private static final String HELP_LOC = "http://www.baeyens.it/eclipse/remind.php" ;
72
71
73
72
private static Activator instance ;
74
-
75
- protected String flagStart = 'F' + 's' + 'S' + 't' + 'a' + 't' + 'u' + Const .EMPTY_STRING ;
76
73
protected char [] uri = { 'h' , 't' , 't' , 'p' , ':' , '/' , '/' , 'b' , 'a' , 'e' , 'y' , 'e' , 'n' , 's' , '.' , 'i' , 't' , '/' ,
77
74
'e' , 'c' , 'l' , 'i' , 'p' , 's' , 'e' , '/' , 'd' , 'o' , 'w' , 'n' , 'l' , 'o' , 'a' , 'd' , '/' , 'p' , 'l' , 'u' , 'g' ,
78
75
'i' , 'n' , 'S' , 't' , 'a' , 'r' , 't' , '.' , 'h' , 't' , 'm' , 'l' , '?' , 's' , '=' };
79
- private static final String PLUGIN_ID = "io.sloeber.core" ; //$NON-NLS-1$
76
+ private static final String PLUGIN_ID = "io.sloeber.core" ;
80
77
81
78
@ Override
82
79
public void start (BundleContext context ) throws Exception {
@@ -103,8 +100,8 @@ public static Activator getDefault() {
103
100
private static void testKnownIssues () {
104
101
// currently no more issues are known
105
102
// if (Platform.getOS().equals(Platform.OS_WIN32)) {
106
- // String bashCommand = "where bash"; //$NON-NLS-1$
107
- // String shCommand = "where sh"; //$NON-NLS-1$
103
+ // String bashCommand = "where bash";
104
+ // String shCommand = "where sh";
108
105
// boolean bashFound = false;
109
106
// ExternalCommandLauncher bashCommandLauncher = new
110
107
// ExternalCommandLauncher(bashCommand);
@@ -124,21 +121,21 @@ private static void testKnownIssues() {
124
121
// String errorString = Const.EMPTY_STRING;
125
122
// String addString = Const.EMPTY_STRING;
126
123
// if (bashFound) {
127
- // errorString = errorString + addString + "bash"; //$NON-NLS-1$
128
- // addString = " and "; //$NON-NLS-1$
124
+ // errorString = errorString + addString + "bash";
125
+ // addString = " and ";
129
126
// }
130
127
// if (shFound) {
131
- // errorString = errorString + addString + "sh"; //$NON-NLS-1$
132
- // addString = " and "; //$NON-NLS-1$
128
+ // errorString = errorString + addString + "sh";
129
+ // addString = " and ";
133
130
// }
134
131
// if (!errorString.isEmpty()) {
135
132
// errorString = "we have found programs in the path that might conflict
136
133
// with our external builder.\nThe conflicting programs are "
137
- // //$NON-NLS-1$
134
+ //
138
135
// + errorString
139
136
// + ".\nThe program might still function but if you get strange build
140
137
// errors you know where to look\nRunning Sloeber.cmd may fix this
141
- // issue."; //$NON-NLS-1$
138
+ // issue.";
142
139
// Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID,
143
140
// errorString));
144
141
// }
@@ -163,14 +160,14 @@ private static void initializeImportantVariables() {
163
160
}
164
161
165
162
private void runPluginCoreStartInstantiatorJob () {
166
- Job job = new Job ("pluginCoreStartInitiator" ) { //$NON-NLS-1$
163
+ Job job = new Job ("pluginCoreStartInitiator" ) {
167
164
@ Override
168
165
protected IStatus run (IProgressMonitor monitor ) {
169
166
try {
170
167
171
168
IEclipsePreferences myScope = InstanceScope .INSTANCE .getNode (NODE_ARDUINO );
172
- int curFsiStatus = myScope .getInt (Activator . this . flagStart , 0 ) + 1 ;
173
- myScope .putInt (Activator . this . flagStart , curFsiStatus );
169
+ int curFsiStatus = myScope .getInt (FLAG_START , 0 ) + 1 ;
170
+ myScope .putInt (FLAG_START , curFsiStatus );
174
171
URL pluginStartInitiator = new URL (new String (Activator .this .uri ) + Integer .toString (curFsiStatus ));
175
172
pluginStartInitiator .getContent ();
176
173
} catch (Exception e ) {
@@ -186,18 +183,18 @@ protected IStatus run(IProgressMonitor monitor) {
186
183
}
187
184
188
185
private static void runInstallJob () {
189
- Job installJob = new Job ("Finishing the installation .." ) { //$NON-NLS-1$
186
+ Job installJob = new Job ("Finishing the installation .." ) {
190
187
191
188
@ SuppressWarnings ("synthetic-access" )
192
189
@ Override
193
190
protected IStatus run (IProgressMonitor monitor ) {
194
191
if (DownloadFolderConditionsOK ()) {
195
- monitor .beginTask ("Sit back, relax and watch us work for a little while .." , //$NON-NLS-1$
192
+ monitor .beginTask ("Sit back, relax and watch us work for a little while .." ,
196
193
IProgressMonitor .UNKNOWN );
197
194
addFileAssociations ();
198
195
makeOurOwnCustomBoards_txt ();
199
196
Manager .startup_Pluging (monitor );
200
- monitor .setTaskName ("Done!" ); //$NON-NLS-1$
197
+ monitor .setTaskName ("Done!" );
201
198
NetworkDiscovery .start ();
202
199
registerListeners ();
203
200
return Status .OK_STATUS ;
@@ -224,13 +221,13 @@ private boolean DownloadFolderConditionsOK() {
224
221
windowsPathToLong = installPath .toString ().length () > 100 ;
225
222
}
226
223
if (cantWrite || windowsPathToLong ) {
227
- String errorMessage = cantWrite ? "The plugin Needs write access to " + installPath .toString () //$NON-NLS-1$
224
+ String errorMessage = cantWrite ? "The plugin Needs write access to " + installPath .toString ()
228
225
: Const .EMPTY_STRING ;
229
226
errorMessage += ((windowsPathToLong && cantWrite ) ? '\n' : Const .EMPTY_STRING );
230
- errorMessage += (windowsPathToLong ? "The path " + installPath .toString () + " is to long" //$NON-NLS-1$ //$NON-NLS-2$
227
+ errorMessage += (windowsPathToLong ? "The path " + installPath .toString () + " is to long"
231
228
: Const .EMPTY_STRING );
232
229
233
- Common .log (new Status (IStatus .ERROR , PLUGIN_ID , errorMessage )); // $NON-NLS-1$
230
+ Common .log (new Status (IStatus .ERROR , PLUGIN_ID , errorMessage ));
234
231
return false ;
235
232
}
236
233
return true ;
@@ -279,13 +276,13 @@ public static String getId() {
279
276
*
280
277
*/
281
278
private static void makeOurOwnCustomBoards_txt () {
282
- makeOurOwnCustomBoard_txt ("config/pre_processing_boards_-.txt" , //$NON-NLS-1$
279
+ makeOurOwnCustomBoard_txt ("config/pre_processing_boards_-.txt" ,
283
280
ConfigurationPreferences .getPreProcessingBoardsFile (), true );
284
- makeOurOwnCustomBoard_txt ("config/post_processing_boards_-.txt" , //$NON-NLS-1$
281
+ makeOurOwnCustomBoard_txt ("config/post_processing_boards_-.txt" ,
285
282
ConfigurationPreferences .getPostProcessingBoardsFile (), true );
286
- makeOurOwnCustomBoard_txt ("config/pre_processing_platform_-.txt" , //$NON-NLS-1$
283
+ makeOurOwnCustomBoard_txt ("config/pre_processing_platform_-.txt" ,
287
284
ConfigurationPreferences .getPreProcessingPlatformFile (), true );
288
- makeOurOwnCustomBoard_txt ("config/post_processing_platform_-.txt" , //$NON-NLS-1$
285
+ makeOurOwnCustomBoard_txt ("config/post_processing_platform_-.txt" ,
289
286
ConfigurationPreferences .getPostProcessingPlatformFile (), true );
290
287
}
291
288
@@ -309,7 +306,7 @@ private static void makeOurOwnCustomBoard_txt(String inRegEx, File outFile, bool
309
306
outFile .getParentFile ().mkdirs ();
310
307
// String VersionSpecificFile = inRegEx.replaceFirst("-",
311
308
// mArduinoIdeVersion.getStringValue());
312
- String DefaultFile = inRegEx .replaceFirst ("-" , "default" ); //$NON-NLS-1$ //$NON-NLS-2$
309
+ String DefaultFile = inRegEx .replaceFirst ("-" , "default" );
313
310
/*
314
311
* Finding the file in the plugin as described here
315
312
* :http://blog.vogella.com/2010/07/06/reading-resources-from-plugin/
@@ -320,7 +317,7 @@ private static void makeOurOwnCustomBoard_txt(String inRegEx, File outFile, bool
320
317
321
318
try (FileOutputStream to = new FileOutputStream (outFile .toString ());) {
322
319
try {
323
- URL defaultUrl = new URL ("platform:/plugin/io.sloeber.core/" + DefaultFile ); //$NON-NLS-1$
320
+ URL defaultUrl = new URL ("platform:/plugin/io.sloeber.core/" + DefaultFile );
324
321
try (InputStream inputStreamDefault = defaultUrl .openConnection ().getInputStream ();) {
325
322
while ((bytes_read = inputStreamDefault .read (buffer )) != -1 ) {
326
323
to .write (buffer , 0 , bytes_read ); // write
@@ -346,43 +343,44 @@ private static void addFileAssociations() {
346
343
final IContentTypeManager ctm = Platform .getContentTypeManager ();
347
344
final IContentType ctbin = ctm .getContentType (CCorePlugin .CONTENT_TYPE_CXXSOURCE );
348
345
try {
349
- ctbin .addFileSpec ("ino" , IContentTypeSettings .FILE_EXTENSION_SPEC ); //$NON-NLS-1$
350
- ctbin .addFileSpec ("pde" , IContentTypeSettings .FILE_EXTENSION_SPEC ); //$NON-NLS-1$
346
+ ctbin .addFileSpec ("ino" , IContentTypeSettings .FILE_EXTENSION_SPEC );
347
+ ctbin .addFileSpec ("pde" , IContentTypeSettings .FILE_EXTENSION_SPEC );
351
348
} catch (CoreException e ) {
352
349
Common .log (new Status (IStatus .WARNING , Activator .getId (),
353
- "Failed to add *.ino and *.pde as file extensions." , e )); //$NON-NLS-1$
350
+ "Failed to add *.ino and *.pde as file extensions." , e ));
354
351
}
355
352
356
353
}
357
354
358
355
static void remind () {
359
- if (isInternetReachable ()) {
360
- Job job = new FamilyJob ("pluginReminder" ) { //$NON-NLS-1$
361
- @ Override
362
- protected IStatus run (IProgressMonitor monitor ) {
363
356
364
- IEclipsePreferences myScope = InstanceScope .INSTANCE .getNode (NODE_ARDUINO );
365
- int curFsiStatus = myScope .getInt (FLAGS_TART , 0 ) + myScope .getInt (FLAG_MONITOR , 0 )
366
- + myScope .getInt (UPLOAD_FLAG , 0 ) + myScope .getInt (BUILD_FLAG , 0 );
367
- int lastFsiStatus = myScope .getInt (LOCAL_FLAG , 0 );
368
- if ((curFsiStatus - lastFsiStatus ) >= 50 ) {
369
- myScope .putInt (LOCAL_FLAG , curFsiStatus );
370
-
371
- try {
372
- myScope .sync ();
373
- } catch (BackingStoreException e ) {
374
- // this should not happen
375
- }
357
+ Job job = new FamilyJob ("pluginReminder" ) {
358
+ @ Override
359
+ protected IStatus run (IProgressMonitor monitor ) {
360
+
361
+ IEclipsePreferences myScope = InstanceScope .INSTANCE .getNode (NODE_ARDUINO );
362
+ int curFsStatus = myScope .getInt (FLAG_START , 0 );
363
+ int curFuStatus = myScope .getInt (UPLOAD_FLAG , 0 );
364
+ int curFbStatus = myScope .getInt (BUILD_FLAG , 0 );
365
+ int curFsiStatus = curFsStatus + curFuStatus + curFbStatus ;
366
+ int lastFsiStatus = myScope .getInt (LOCAL_FLAG , 0 );
367
+ if ((curFsiStatus - lastFsiStatus ) >= 50 ) {
368
+ myScope .putInt (LOCAL_FLAG , curFsiStatus );
369
+ // try {
370
+ // myScope.flush();
371
+ // } catch (BackingStoreException e) {
372
+ // // this should not happen
373
+ // }
374
+ if (isInternetReachable ()) {
376
375
PleaseHelp .doHelp (HELP_LOC );
377
- return Status .OK_STATUS ;
378
376
}
379
- remind ();
380
- return Status .OK_STATUS ;
381
377
}
382
- };
383
- job .setPriority (Job .DECORATE );
384
- job .schedule (60000 );
385
- }
378
+ remind ();
379
+ return Status .OK_STATUS ;
380
+ }
381
+ };
382
+ job .setPriority (Job .DECORATE );
383
+ job .schedule (60000 );
386
384
}
387
385
388
386
static boolean isInternetReachable () {
@@ -391,7 +389,7 @@ static boolean isInternetReachable() {
391
389
392
390
try {
393
391
// make a URL to a known source
394
- URL url = new URL (HELP_LOC + "?systemhash=" + ConfigurationPreferences .getSystemHash ());//$NON-NLS-1$
392
+ URL url = new URL (HELP_LOC + "?systemhash=" + ConfigurationPreferences .getSystemHash ());
395
393
// open a connection to that source
396
394
urlConnect = (HttpURLConnection ) url .openConnection ();
397
395
// trying to retrieve data from the source. If there is no
0 commit comments