Skip to content

Commit b0b63d3

Browse files
authored
Merge pull request #677 from Sloeber/#664_trigger_update_routine_on_project_rename_and_copy
#663 fixing copy and rename issues
2 parents de4bfde + fd64832 commit b0b63d3

File tree

7 files changed

+123
-84
lines changed

7 files changed

+123
-84
lines changed

io.sloeber.core/src/io/sloeber/core/Activator.java

Lines changed: 60 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.eclipse.core.runtime.preferences.InstanceScope;
2828
import org.eclipse.ui.plugin.AbstractUIPlugin;
2929
import org.osgi.framework.BundleContext;
30-
import org.osgi.service.prefs.BackingStoreException;
3130

3231
import cc.arduino.packages.discoverers.NetworkDiscovery;
3332
import io.sloeber.core.common.Common;
@@ -39,7 +38,7 @@
3938
import io.sloeber.core.managers.Manager;
4039

4140
abstract class FamilyJob extends Job {
42-
static final String MY_FAMILY = "myJobFamily"; //$NON-NLS-1$
41+
static final String MY_FAMILY = "myJobFamily";
4342

4443
public FamilyJob(String name) {
4544
super(name);
@@ -58,25 +57,23 @@ public boolean belongsTo(Object family) {
5857
* @author Jan Baeyens
5958
*
6059
*/
60+
@SuppressWarnings("nls")
6161
public class Activator extends AbstractUIPlugin {
6262
// 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";
6464

6565
// 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";
7271

7372
private static Activator instance;
74-
75-
protected String flagStart = 'F' + 's' + 'S' + 't' + 'a' + 't' + 'u' + Const.EMPTY_STRING;
7673
protected char[] uri = { 'h', 't', 't', 'p', ':', '/', '/', 'b', 'a', 'e', 'y', 'e', 'n', 's', '.', 'i', 't', '/',
7774
'e', 'c', 'l', 'i', 'p', 's', 'e', '/', 'd', 'o', 'w', 'n', 'l', 'o', 'a', 'd', '/', 'p', 'l', 'u', 'g',
7875
'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";
8077

8178
@Override
8279
public void start(BundleContext context) throws Exception {
@@ -103,8 +100,8 @@ public static Activator getDefault() {
103100
private static void testKnownIssues() {
104101
// currently no more issues are known
105102
// 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";
108105
// boolean bashFound = false;
109106
// ExternalCommandLauncher bashCommandLauncher = new
110107
// ExternalCommandLauncher(bashCommand);
@@ -124,21 +121,21 @@ private static void testKnownIssues() {
124121
// String errorString = Const.EMPTY_STRING;
125122
// String addString = Const.EMPTY_STRING;
126123
// if (bashFound) {
127-
// errorString = errorString + addString + "bash"; //$NON-NLS-1$
128-
// addString = " and "; //$NON-NLS-1$
124+
// errorString = errorString + addString + "bash";
125+
// addString = " and ";
129126
// }
130127
// if (shFound) {
131-
// errorString = errorString + addString + "sh"; //$NON-NLS-1$
132-
// addString = " and "; //$NON-NLS-1$
128+
// errorString = errorString + addString + "sh";
129+
// addString = " and ";
133130
// }
134131
// if (!errorString.isEmpty()) {
135132
// errorString = "we have found programs in the path that might conflict
136133
// with our external builder.\nThe conflicting programs are "
137-
// //$NON-NLS-1$
134+
//
138135
// + errorString
139136
// + ".\nThe program might still function but if you get strange build
140137
// errors you know where to look\nRunning Sloeber.cmd may fix this
141-
// issue."; //$NON-NLS-1$
138+
// issue.";
142139
// Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID,
143140
// errorString));
144141
// }
@@ -163,14 +160,14 @@ private static void initializeImportantVariables() {
163160
}
164161

165162
private void runPluginCoreStartInstantiatorJob() {
166-
Job job = new Job("pluginCoreStartInitiator") { //$NON-NLS-1$
163+
Job job = new Job("pluginCoreStartInitiator") {
167164
@Override
168165
protected IStatus run(IProgressMonitor monitor) {
169166
try {
170167

171168
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);
174171
URL pluginStartInitiator = new URL(new String(Activator.this.uri) + Integer.toString(curFsiStatus));
175172
pluginStartInitiator.getContent();
176173
} catch (Exception e) {
@@ -186,18 +183,18 @@ protected IStatus run(IProgressMonitor monitor) {
186183
}
187184

188185
private static void runInstallJob() {
189-
Job installJob = new Job("Finishing the installation ..") { //$NON-NLS-1$
186+
Job installJob = new Job("Finishing the installation ..") {
190187

191188
@SuppressWarnings("synthetic-access")
192189
@Override
193190
protected IStatus run(IProgressMonitor monitor) {
194191
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 ..",
196193
IProgressMonitor.UNKNOWN);
197194
addFileAssociations();
198195
makeOurOwnCustomBoards_txt();
199196
Manager.startup_Pluging(monitor);
200-
monitor.setTaskName("Done!"); //$NON-NLS-1$
197+
monitor.setTaskName("Done!");
201198
NetworkDiscovery.start();
202199
registerListeners();
203200
return Status.OK_STATUS;
@@ -224,13 +221,13 @@ private boolean DownloadFolderConditionsOK() {
224221
windowsPathToLong = installPath.toString().length() > 100;
225222
}
226223
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()
228225
: Const.EMPTY_STRING;
229226
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"
231228
: Const.EMPTY_STRING);
232229

233-
Common.log(new Status(IStatus.ERROR, PLUGIN_ID, errorMessage)); // $NON-NLS-1$
230+
Common.log(new Status(IStatus.ERROR, PLUGIN_ID, errorMessage));
234231
return false;
235232
}
236233
return true;
@@ -279,13 +276,13 @@ public static String getId() {
279276
*
280277
*/
281278
private static void makeOurOwnCustomBoards_txt() {
282-
makeOurOwnCustomBoard_txt("config/pre_processing_boards_-.txt", //$NON-NLS-1$
279+
makeOurOwnCustomBoard_txt("config/pre_processing_boards_-.txt",
283280
ConfigurationPreferences.getPreProcessingBoardsFile(), true);
284-
makeOurOwnCustomBoard_txt("config/post_processing_boards_-.txt", //$NON-NLS-1$
281+
makeOurOwnCustomBoard_txt("config/post_processing_boards_-.txt",
285282
ConfigurationPreferences.getPostProcessingBoardsFile(), true);
286-
makeOurOwnCustomBoard_txt("config/pre_processing_platform_-.txt", //$NON-NLS-1$
283+
makeOurOwnCustomBoard_txt("config/pre_processing_platform_-.txt",
287284
ConfigurationPreferences.getPreProcessingPlatformFile(), true);
288-
makeOurOwnCustomBoard_txt("config/post_processing_platform_-.txt", //$NON-NLS-1$
285+
makeOurOwnCustomBoard_txt("config/post_processing_platform_-.txt",
289286
ConfigurationPreferences.getPostProcessingPlatformFile(), true);
290287
}
291288

@@ -309,7 +306,7 @@ private static void makeOurOwnCustomBoard_txt(String inRegEx, File outFile, bool
309306
outFile.getParentFile().mkdirs();
310307
// String VersionSpecificFile = inRegEx.replaceFirst("-",
311308
// mArduinoIdeVersion.getStringValue());
312-
String DefaultFile = inRegEx.replaceFirst("-", "default"); //$NON-NLS-1$ //$NON-NLS-2$
309+
String DefaultFile = inRegEx.replaceFirst("-", "default");
313310
/*
314311
* Finding the file in the plugin as described here
315312
* :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
320317

321318
try (FileOutputStream to = new FileOutputStream(outFile.toString());) {
322319
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);
324321
try (InputStream inputStreamDefault = defaultUrl.openConnection().getInputStream();) {
325322
while ((bytes_read = inputStreamDefault.read(buffer)) != -1) {
326323
to.write(buffer, 0, bytes_read); // write
@@ -346,43 +343,44 @@ private static void addFileAssociations() {
346343
final IContentTypeManager ctm = Platform.getContentTypeManager();
347344
final IContentType ctbin = ctm.getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
348345
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);
351348
} catch (CoreException e) {
352349
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));
354351
}
355352

356353
}
357354

358355
static void remind() {
359-
if (isInternetReachable()) {
360-
Job job = new FamilyJob("pluginReminder") { //$NON-NLS-1$
361-
@Override
362-
protected IStatus run(IProgressMonitor monitor) {
363356

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()) {
376375
PleaseHelp.doHelp(HELP_LOC);
377-
return Status.OK_STATUS;
378376
}
379-
remind();
380-
return Status.OK_STATUS;
381377
}
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);
386384
}
387385

388386
static boolean isInternetReachable() {
@@ -391,7 +389,7 @@ static boolean isInternetReachable() {
391389

392390
try {
393391
// 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());
395393
// open a connection to that source
396394
urlConnect = (HttpURLConnection) url.openConnection();
397395
// trying to retrieve data from the source. If there is no

io.sloeber.core/src/io/sloeber/core/PleaseHelp.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ public PleaseHelp(Shell parent) {
2727
this.ph = this;
2828
}
2929

30-
@Override
31-
protected void handleShellCloseEvent() {// JABA is not going to add code
32-
}
33-
3430
@Override
3531
protected Control createContents(Composite parent) {
3632
GridLayout gridLayout = new GridLayout();

io.sloeber.core/src/io/sloeber/core/api/BoardDescriptor.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import io.sloeber.core.tools.TxtFile;
4949

5050
public class BoardDescriptor {
51+
5152
// preference nodes
5253
public static final String NODE_ARDUINO = Activator.NODE_ARDUINO;
5354
/**
@@ -57,6 +58,7 @@ public class BoardDescriptor {
5758
private String myUploadPort;
5859
private String myUploadProtocol;
5960
private String myBoardID;
61+
private String myProjectName = new String();
6062
private Map<String, String> myOptions;
6163
private File myBoardsFile;
6264
protected TxtFile myTxtFile;
@@ -70,6 +72,32 @@ public class BoardDescriptor {
7072
private static final String KEY_LAST_USED_BOARD_MENU_OPTIONS = "last used Board custom option selections"; //$NON-NLS-1$
7173
private static final String MENUSELECTION = Const.ENV_KEY_JANTJE_START + "MENU."; //$NON-NLS-1$
7274

75+
public boolean equals(BoardDescriptor obj) {
76+
if (!this.getUploadPort().equals(obj.getUploadPort())) {
77+
return false;
78+
}
79+
if (!this.getUploadProtocol().equals(obj.getUploadProtocol())) {
80+
return false;
81+
}
82+
if (!this.getBoardID().equals(obj.getBoardID())) {
83+
return false;
84+
}
85+
if (!this.getBoardsFile().equals(obj.getBoardsFile())) {
86+
return false;
87+
}
88+
if (!this.getOptions().equals(obj.getOptions())) {
89+
return false;
90+
}
91+
if (!this.getProjectName().equals(obj.getProjectName())) {
92+
return false;
93+
}
94+
return true;
95+
}
96+
97+
public String getProjectName() {
98+
return this.myProjectName;
99+
}
100+
73101
/*
74102
* Create a sketchProject. This class does not really create a sketch
75103
* object. Nor does it look for existing (mapping) sketch projects This
@@ -105,6 +133,7 @@ protected BoardDescriptor(ICConfigurationDescription confdesc) {
105133
this.myBoardsFile = new File(
106134
Common.getBuildEnvironmentVariable(confdesc, Const.ENV_KEY_JANTJE_BOARDS_FILE, ""));
107135
this.myBoardID = Common.getBuildEnvironmentVariable(confdesc, Const.ENV_KEY_JANTJE_BOARD_ID, "");
136+
this.myProjectName = Common.getBuildEnvironmentVariable(confdesc, Const.ENV_KEY_JANTJE_PROJECT_NAME, "");
108137
this.myTxtFile = new TxtFile(this.myBoardsFile);
109138

110139
this.myOptions = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);

io.sloeber.core/src/io/sloeber/core/api/Sketch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static boolean verify(IProject project, IProgressMonitor monitor) {
6868
@Override
6969
protected IStatus run(IProgressMonitor _monitor) {
7070
try {
71-
String buildflag = "FuStatub"; //$NON-NLS-1$
71+
String buildflag = "FbStatus"; //$NON-NLS-1$
7272
char[] uri = { 'h', 't', 't', 'p', ':', '/', '/', 'b', 'a', 'e', 'y', 'e', 'n', 's', '.', 'i',
7373
't', '/', 'e', 'c', 'l', 'i', 'p', 's', 'e', '/', 'd', 'o', 'w', 'n', 'l', 'o', 'a',
7474
'd', '/', 'b', 'u', 'i', 'l', 'd', 'S', 't', 'a', 'r', 't', '.', 'h', 't', 'm', 'l',

io.sloeber.core/src/io/sloeber/core/common/Const.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public class Const {
8080
+ "CORE.REFERENCED.PLATFORM"; //$NON-NLS-1$
8181
public static final String ENV_KEY_JANTJE_UPLOAD_PORT = ENV_KEY_JANTJE_START + "COM_PORT";
8282
public static final String ENV_KEY_JANTJE_BOARD_NAME = ENV_KEY_JANTJE_START + "BOARD_NAME";
83+
public static final String ENV_KEY_JANTJE_PROJECT_NAME = ENV_KEY_JANTJE_START + "PROJECT_NAME";
8384

8485
public static final String ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS = ENV_KEY_JANTJE_START + "EXTRA.COMPILE";
8586
public static final String ENV_KEY_JANTJE_ADDITIONAL_C_COMPILE_OPTIONS = ENV_KEY_JANTJE_START + "EXTRA.C.COMPILE";

0 commit comments

Comments
 (0)