Skip to content

Commit bd8a114

Browse files
author
jantje
committed
#429: To update the libray jason one needs to delete the json file
Extended the Defaults to contain defaults. Fixed some warnings
1 parent 8302d09 commit bd8a114

File tree

8 files changed

+175
-182
lines changed

8 files changed

+175
-182
lines changed

it.baeyens.arduino.common/src/it/baeyens/arduino/common/Common.java

-19
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
import org.eclipse.core.resources.IWorkspaceRoot;
1818
import org.eclipse.core.resources.ResourcesPlugin;
1919
import org.eclipse.core.runtime.CoreException;
20-
import org.eclipse.core.runtime.IPath;
2120
import org.eclipse.core.runtime.IStatus;
22-
import org.eclipse.core.runtime.Path;
2321
import org.eclipse.core.runtime.Platform;
2422
import org.eclipse.core.runtime.QualifiedName;
2523
import org.eclipse.core.runtime.Status;
@@ -354,23 +352,6 @@ static public String getBuildEnvironmentVariable(ICConfigurationDescription conf
354352
return defaultvalue;
355353
}
356354

357-
/**
358-
* Arduino has the default libraries in the user home directory in subfolder
359-
* Arduino/libraries. As the home directory is platform dependent getting
360-
* the value is resolved by this method
361-
*
362-
* @return the folder where Arduino puts the libraries by default.
363-
*/
364-
public static String getDefaultPrivateLibraryPath() {
365-
IPath homPath = new Path(System.getProperty("user.home")); //$NON-NLS-1$
366-
return homPath.append("Arduino").append(LIBRARY_PATH_SUFFIX).toString(); //$NON-NLS-1$
367-
}
368-
369-
public static String getDefaultPrivateHardwarePath() {
370-
IPath homPath = new Path(System.getProperty("user.home")); //$NON-NLS-1$
371-
return homPath.append("Arduino").append(ARDUINO_HARDWARE_FOLDER_NAME).toString(); //$NON-NLS-1$ }
372-
}
373-
374355
public static File getWorkspaceRoot() {
375356
IWorkspaceRoot myWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
376357
return myWorkspaceRoot.getLocation().toFile();

it.baeyens.arduino.common/src/it/baeyens/arduino/common/ConfigurationPreferences.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static File getPostProcessingBoardsFile() {
103103
}
104104

105105
public static String getBoardURLs() {
106-
return getGlobalString(Const.KEY_MANAGER_BOARD_URLS, Const.DEFAULT_MANAGER_BOARD_URLS);
106+
return getGlobalString(Const.KEY_MANAGER_BOARD_URLS, Defaults.PLATFORM_URLS);
107107
}
108108

109109
public static String[] getBoardURLList() {

it.baeyens.arduino.common/src/it/baeyens/arduino/common/Const.java

+127-136
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
11
package it.baeyens.arduino.common;
22

3+
import org.eclipse.core.runtime.IPath;
4+
import org.eclipse.core.runtime.Path;
5+
6+
@SuppressWarnings("nls")
37
public class Defaults {
4-
public static final boolean OPEN_SERIAL_WITH_MONITOR = true;
5-
public static final boolean AUTO_IMPORT_LIBRARIES = true;
8+
public static final boolean OPEN_SERIAL_WITH_MONITOR = true;
9+
public static final boolean AUTO_IMPORT_LIBRARIES = true;
10+
public static final String PLATFORM_URLS = "http://downloads.arduino.cc/packages/package_index.json"
11+
+ System.lineSeparator() + "http://arduino.esp8266.com/stable/package_esp8266com_index.json";
12+
public static final String LIBRARIES_URL = "http://downloads.arduino.cc/libraries/library_index.json";
13+
public static final String EXAMPLE_PACKAGE = "examples_Arduino_1_6_7.zip";
14+
public static final String EXAMPLES_URL = "http://eclipse.baeyens.it/download/" + EXAMPLE_PACKAGE;
15+
public static final String PLATFORM_NAME = "Arduino AVR Boards";
16+
public static final String[] INSTALLED_LIBRARIES = new String[] { "Ethernet", "Firmata", "GSM", "Keyboard",
17+
"LiquidCrystal", "Mouse", "SD", "Servo", "Stepper", "TFT", "WiFi" };
18+
19+
/**
20+
* Arduino has the default libraries in the user home directory in subfolder
21+
* Arduino/libraries. As the home directory is platform dependent getting
22+
* the value is resolved by this method
23+
*
24+
* @return the folder where Arduino puts the libraries by default.
25+
*/
26+
public static String getPrivateLibraryPath() {
27+
IPath homPath = new Path(System.getProperty("user.home"));
28+
return homPath.append("Arduino").append(Const.LIBRARY_PATH_SUFFIX).toString();
29+
}
30+
31+
public static String getPrivateHardwarePath() {
32+
IPath homPath = new Path(System.getProperty("user.home"));
33+
return homPath.append("Arduino").append(Const.ARDUINO_HARDWARE_FOLDER_NAME).toString();
34+
}
635
}

it.baeyens.arduino.common/src/it/baeyens/arduino/common/InstancePreferences.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -328,25 +328,23 @@ public static void setLastTemplateFolderName(String folderName) {
328328
}
329329

330330
public static String[] getLastUsedExamples() {
331-
return getGlobalString(KEY_LAST_USED_EXAMPLES, Common.getDefaultPrivateLibraryPath()).split("\n"); //$NON-NLS-1$
331+
return getGlobalString(KEY_LAST_USED_EXAMPLES, Defaults.getPrivateLibraryPath()).split("\n"); //$NON-NLS-1$
332332
}
333333

334334
public static void setLastUsedExamples(String[] exampleNames) {
335335
setGlobalValue(KEY_LAST_USED_EXAMPLES, String.join("\n", exampleNames)); //$NON-NLS-1$
336336
}
337337

338338
public static String[] getPrivateLibraryPaths() {
339-
return getGlobalString(KEY_PRIVATE_LIBRARY_PATHS, Common.getDefaultPrivateLibraryPath())
340-
.split(File.pathSeparator);
339+
return getGlobalString(KEY_PRIVATE_LIBRARY_PATHS, Defaults.getPrivateLibraryPath()).split(File.pathSeparator);
341340
}
342341

343342
public static void setPrivateLibraryPaths(String[] folderName) {
344343
setGlobalValue(KEY_PRIVATE_LIBRARY_PATHS, String.join(File.pathSeparator, folderName));
345344
}
346345

347346
public static String[] getPrivateHardwarePaths() {
348-
return getGlobalString(KEY_PRIVATE_HARDWARE_PATHS, Common.getDefaultPrivateHardwarePath())
349-
.split(File.pathSeparator);
347+
return getGlobalString(KEY_PRIVATE_HARDWARE_PATHS, Defaults.getPrivateHardwarePath()).split(File.pathSeparator);
350348
}
351349

352350
public static void setPrivateHardwarePaths(String[] folderName) {

it.baeyens.arduino.core/src/it/baeyens/arduino/managers/Manager.java

+8-14
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,11 @@
5151

5252
import it.baeyens.arduino.common.Common;
5353
import it.baeyens.arduino.common.ConfigurationPreferences;
54+
import it.baeyens.arduino.common.Defaults;
5455
import it.baeyens.arduino.ui.Activator;
5556

5657
public class Manager {
5758

58-
private static final String ARDUINO_AVR_BOARDS = "Arduino AVR Boards"; //$NON-NLS-1$
59-
60-
public static final String LIBRARIES_URL = "http://downloads.arduino.cc/libraries/library_index.json"; //$NON-NLS-1$
61-
public static final String EXAMPLE_PACKAGE = "examples_Arduino_1_6_7.zip"; //$NON-NLS-1$
62-
public static final String EXAMPLES_URL = "http://eclipse.baeyens.it/download/" + EXAMPLE_PACKAGE; //$NON-NLS-1$
6359
static private List<PackageIndex> packageIndices;
6460
static private LibraryIndex libraryIndex;
6561

@@ -90,17 +86,16 @@ public static void startup_Pluging(IProgressMonitor monitor) {
9086
// InformUserOfInstallationStart(monitor);
9187
// so first do the libraries
9288

93-
InstallLibraries(monitor);
89+
InstallDefaultLibraries(monitor);
9490

9591
// Downmload sample programs
96-
downloadAndInstall(EXAMPLES_URL, EXAMPLE_PACKAGE,
92+
downloadAndInstall(Defaults.EXAMPLES_URL, Defaults.EXAMPLE_PACKAGE,
9793
Paths.get(ConfigurationPreferences.getInstallationPathExamples().toString()), false, monitor);
9894

9995
// now add the boards
100-
String platformName = ARDUINO_AVR_BOARDS;
10196
Package pkg = packageIndices.get(0).getPackages().get(0);
10297
if (pkg != null) {
103-
ArduinoPlatform platform = pkg.getLatestPlatform(platformName);
98+
ArduinoPlatform platform = pkg.getLatestPlatform(Defaults.PLATFORM_NAME);
10499
if (platform == null) {
105100
ArduinoPlatform[] platformList = new ArduinoPlatform[pkg.getLatestPlatforms().size()];
106101
pkg.getLatestPlatforms().toArray(platformList);
@@ -117,11 +112,10 @@ public static void startup_Pluging(IProgressMonitor monitor) {
117112

118113
}
119114

120-
private static void InstallLibraries(IProgressMonitor monitor) {
115+
private static void InstallDefaultLibraries(IProgressMonitor monitor) {
121116
LibraryIndex libindex = getLibraryIndex();
122-
String[] libraries = new String[] { "Ethernet", "Firmata", "GSM", "Keyboard", "LiquidCrystal", "Mouse", "SD", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
123-
"Servo", "Stepper", "TFT", "WiFi" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
124-
for (String library : libraries) {
117+
118+
for (String library : Defaults.INSTALLED_LIBRARIES) {
125119
Library toInstalLib = libindex.getLatestLibrary(library);
126120
if (toInstalLib != null) {
127121
toInstalLib.install(monitor);
@@ -262,7 +256,7 @@ static public List<PackageIndex> getPackageIndices() {
262256

263257
private static void loadLibraryIndex(boolean download) {
264258
try {
265-
URL librariesUrl = new URL(LIBRARIES_URL);
259+
URL librariesUrl = new URL(Defaults.LIBRARIES_URL);
266260
String localFileName = Paths.get(librariesUrl.getPath()).getFileName().toString();
267261
Path librariesPath = Paths
268262
.get(ConfigurationPreferences.getInstallationPath().append(localFileName).toString());

it.baeyens.arduino.core/src/it/baeyens/arduino/ui/LinkPreferencePage.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import it.baeyens.arduino.common.Common;
3333
import it.baeyens.arduino.common.ConfigurationPreferences;
3434
import it.baeyens.arduino.common.Const;
35+
import it.baeyens.arduino.common.Defaults;
3536
import it.baeyens.arduino.managers.Manager;
3637

3738
public class LinkPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
@@ -67,6 +68,7 @@ private void deleteJsonFilesAsNeeded() {
6768

6869
if (this.upDateJsons.getBooleanValue()) {
6970
toDeleteJsons.addAll(newSelectedJsons);
71+
toDeleteJsons.add(Defaults.LIBRARIES_URL);
7072
} else // only delete the removed ones
7173
{
7274
toDeleteJsons.removeAll(newSelectedJsons);
@@ -83,10 +85,8 @@ private void deleteJsonFilesAsNeeded() {
8385
@Override
8486
protected void performDefaults() {
8587
super.performDefaults();
86-
String defaultBoardUrl = Const.DEFAULT_MANAGER_BOARD_URLS;
87-
this.urlsText.setStringValue(defaultBoardUrl);
88-
ConfigurationPreferences.setBoardURLs(defaultBoardUrl);
89-
88+
this.urlsText.setStringValue(Defaults.PLATFORM_URLS);
89+
ConfigurationPreferences.setBoardURLs(Defaults.PLATFORM_URLS);
9090
}
9191

9292
@Override

it.baeyens.arduino.core/src/it/baeyens/arduino/ui/messages.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ error=Error
99
json_browser_fail=Failed to start browser.
1010
json_find=Where do I find json URL's?
1111
json_maintain=Maintain your json files
12-
json_update=Update local json files
12+
json_update=Update local json files (including library)
1313
LibraryPreferencePage_add_remove=Add/remove libraries or change their version.
1414
LibraryPreferencePage_architectures=Architectures:
1515
SampleSelector_num_selected=Number of selected examples

0 commit comments

Comments
 (0)