Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2015-09-02 02:39:10 +0000
committerDoug Schaefer2015-09-02 20:38:59 +0000
commit40ff5f2a668fc029ec2220a44bdb45f3a79bce2b (patch)
treed52c1ec6a3b56641519e19d13fed945a70e544bd /toolchains
parent0e382c064b7a7b6d21b7e29afd0d751b229e00d2 (diff)
downloadorg.eclipse.cdt-40ff5f2a668fc029ec2220a44bdb45f3a79bce2b.tar.gz
org.eclipse.cdt-40ff5f2a668fc029ec2220a44bdb45f3a79bce2b.tar.xz
org.eclipse.cdt-40ff5f2a668fc029ec2220a44bdb45f3a79bce2b.zip
Add support for multiple board packages suppliers.
Default URLs for Arduino and the ESP8266 community. Preference page to allow user to add their own. Change-Id: Ia40d2729d6b5e26225dbecf85a845322b4a71f5f
Diffstat (limited to 'toolchains')
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core.tests/src/org/eclipse/cdt/arduino/core/tests/BoardManagerTests.java4
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoPreferences.java35
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoManager.java150
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoToolSystem.java2
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ToolDependency.java2
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.ui/plugin.xml6
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/Activator.java15
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/Messages.java3
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/messages.properties3
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/preferences/ArduinoBoardsPreferencePage.java19
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/preferences/ArduinoPreferenceInitializer.java23
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/preferences/ArduinoPreferencePage.java55
12 files changed, 182 insertions, 135 deletions
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core.tests/src/org/eclipse/cdt/arduino/core/tests/BoardManagerTests.java b/toolchains/arduino/org.eclipse.cdt.arduino.core.tests/src/org/eclipse/cdt/arduino/core/tests/BoardManagerTests.java
index 86416879f7b..d9005b1c229 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core.tests/src/org/eclipse/cdt/arduino/core/tests/BoardManagerTests.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core.tests/src/org/eclipse/cdt/arduino/core/tests/BoardManagerTests.java
@@ -1,6 +1,6 @@
package org.eclipse.cdt.arduino.core.tests;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotEquals;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager;
import org.junit.Test;
@@ -9,7 +9,7 @@ public class BoardManagerTests {
@Test
public void loadPackagesTest() throws Exception {
- assertNotNull(ArduinoManager.instance.getPackageIndex());
+ assertNotEquals(0, ArduinoManager.instance.getPackageIndices().size());
}
}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoPreferences.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoPreferences.java
index a131ec1c648..534b0dc2c74 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoPreferences.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoPreferences.java
@@ -10,19 +10,42 @@ package org.eclipse.cdt.arduino.core.internal;
import java.nio.file.Path;
import java.nio.file.Paths;
-import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.osgi.service.prefs.BackingStoreException;
public class ArduinoPreferences {
- public static String ARDUINO_HOME = "arduinoHome"; //$NON-NLS-1$
+ private static final String ARDUINO_HOME = "arduinoHome"; //$NON-NLS-1$
+ private static final String BOARD_URLS = "boardUrls"; //$NON-NLS-1$
+
+ private static final String defaultHome = Paths.get(System.getProperty("user.home"), ".arduinocdt").toString(); //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String defaultBoardUrls = "http://downloads.arduino.cc/packages/package_index.json" //$NON-NLS-1$
+ + "\nhttp://arduino.esp8266.com/stable/package_esp8266com_index.json"; //$NON-NLS-1$
+
+ private static IEclipsePreferences getPrefs() {
+ return InstanceScope.INSTANCE.getNode(Activator.getId());
+ }
public static Path getArduinoHome() {
- String pathStr = Platform.getPreferencesService().getString(Activator.getId(), ARDUINO_HOME, null, null);
- return pathStr != null ? Paths.get(pathStr) : getDefaultArduinoHome();
+ return Paths.get(getPrefs().get(ARDUINO_HOME, defaultHome));
}
- public static Path getDefaultArduinoHome() {
- return Paths.get(System.getProperty("user.home"), ".arduinocdt"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static String getBoardUrls() {
+ return getPrefs().get(BOARD_URLS, defaultBoardUrls);
}
+ public static void setBoardUrls(String boardUrls) {
+ IEclipsePreferences prefs = getPrefs();
+ prefs.put(BOARD_URLS, boardUrls);
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e) {
+ Activator.log(e);
+ }
+ }
+
+ public static String getDefaultBoardUrls() {
+ return defaultBoardUrls;
+ }
}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoManager.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoManager.java
index ca6c26cc1fa..030dbd88c74 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoManager.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoManager.java
@@ -16,10 +16,12 @@ import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
+import java.io.Reader;
import java.lang.reflect.Type;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.PosixFilePermission;
import java.util.ArrayList;
@@ -65,69 +67,107 @@ public class ArduinoManager {
public static final String PACKAGE_OPTION_ID = "org.eclipse.cdt.arduino.option.package"; //$NON-NLS-1$
public static final String AVR_TOOLCHAIN_ID = "org.eclipse.cdt.arduino.toolChain.avr"; //$NON-NLS-1$
- private Path packageIndexPath = ArduinoPreferences.getArduinoHome().resolve("package_index.json"); //$NON-NLS-1$
- private PackageIndex packageIndex;
-
- private Path libraryIndexPath = ArduinoPreferences.getArduinoHome().resolve("library_index.json"); //$NON-NLS-1$
+ public static final String LIBRARIES_URL = "http://downloads.arduino.cc/libraries/library_index.json"; //$NON-NLS-1$
+ private List<PackageIndex> packageIndices;
private LibraryIndex libraryIndex;
- public ArduinoManager() {
+ public void loadIndices() {
new Job(Messages.ArduinoBoardManager_0) {
protected IStatus run(IProgressMonitor monitor) {
- try {
- // library index has the same parent right now
- Files.createDirectories(packageIndexPath.getParent());
-
- URL packageUrl = new URL("http://downloads.arduino.cc/packages/package_index.json"); //$NON-NLS-1$
- try (InputStream in = packageUrl.openStream()) {
- Files.copy(in, packageIndexPath, StandardCopyOption.REPLACE_EXISTING);
- }
-
- URL libraryUrl = new URL("http://downloads.arduino.cc/libraries/library_index.json"); //$NON-NLS-1$
- try (InputStream in = libraryUrl.openStream()) {
- Files.copy(in, libraryIndexPath, StandardCopyOption.REPLACE_EXISTING);
- }
- } catch (IOException e) {
- return new Status(IStatus.ERROR, Activator.getId(), e.getLocalizedMessage(), e);
+ String[] boardUrls = ArduinoPreferences.getBoardUrls().split("\n"); //$NON-NLS-1$
+ packageIndices = new ArrayList<>(boardUrls.length);
+ for (String boardUrl : boardUrls) {
+ loadPackageIndex(boardUrl, true);
}
+
+ loadLibraryIndex(true);
return Status.OK_STATUS;
}
}.schedule();
}
- public PackageIndex getPackageIndex() throws CoreException {
- if (packageIndex == null) {
- try (FileReader reader = new FileReader(packageIndexPath.toFile())) {
- packageIndex = new Gson().fromJson(reader, PackageIndex.class);
- packageIndex.setOwners(this);
- } catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), "Reading package index", e));
+ private void loadPackageIndex(String url, boolean download) {
+ try {
+ URL packageUrl = new URL(url.trim());
+ Path packagePath = ArduinoPreferences.getArduinoHome()
+ .resolve(Paths.get(packageUrl.getPath()).getFileName());
+ File packageFile = packagePath.toFile();
+ if (download) {
+ Files.copy(packageUrl.openStream(), packagePath, StandardCopyOption.REPLACE_EXISTING);
+ }
+ if (packageFile.exists()) {
+ try (Reader reader = new FileReader(packageFile)) {
+ PackageIndex index = new Gson().fromJson(reader, PackageIndex.class);
+ index.setOwners(ArduinoManager.this);
+ packageIndices.add(index);
+ }
+ }
+ } catch (IOException e) {
+ Activator.log(e);
+ }
+ }
+
+ public List<PackageIndex> getPackageIndices() throws CoreException {
+ if (packageIndices == null) {
+ String[] boardUrls = ArduinoPreferences.getBoardUrls().split("\n"); //$NON-NLS-1$
+ packageIndices = new ArrayList<>(boardUrls.length);
+ for (String boardUrl : boardUrls) {
+ loadPackageIndex(boardUrl, false);
+ }
+ }
+ return packageIndices;
+ }
+
+ private void loadLibraryIndex(boolean download) {
+ try {
+ URL librariesUrl = new URL(LIBRARIES_URL);
+ Path librariesPath = ArduinoPreferences.getArduinoHome()
+ .resolve(Paths.get(librariesUrl.getPath()).getFileName());
+ File librariesFile = librariesPath.toFile();
+ if (download) {
+ Files.copy(librariesUrl.openStream(), librariesPath, StandardCopyOption.REPLACE_EXISTING);
+ }
+ if (librariesFile.exists()) {
+ try (Reader reader = new FileReader(librariesFile)) {
+ libraryIndex = new Gson().fromJson(reader, LibraryIndex.class);
+ }
}
+ } catch (IOException e) {
+ Activator.log(e);
}
- return packageIndex;
+
}
public LibraryIndex getLibraryIndex() throws CoreException {
if (libraryIndex == null) {
- try (FileReader reader = new FileReader(libraryIndexPath.toFile())) {
- libraryIndex = new Gson().fromJson(reader, LibraryIndex.class);
- libraryIndex.resolve();
- } catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), "Reading library index", e));
- }
+ loadLibraryIndex(false);
}
return libraryIndex;
}
public ArduinoBoard getBoard(String boardName, String platformName, String packageName) throws CoreException {
- return getPackageIndex().getPackage(packageName).getPlatform(platformName).getBoard(boardName);
+ for (PackageIndex index : packageIndices) {
+ ArduinoPackage pkg = index.getPackage(packageName);
+ if (pkg != null) {
+ ArduinoPlatform platform = pkg.getPlatform(platformName);
+ if (platform != null) {
+ ArduinoBoard board = platform.getBoard(boardName);
+ if (board != null) {
+ return board;
+ }
+ }
+ }
+ }
+ return null;
}
public List<ArduinoBoard> getBoards() throws CoreException {
List<ArduinoBoard> boards = new ArrayList<>();
- for (ArduinoPackage pkg : getPackageIndex().getPackages()) {
- for (ArduinoPlatform platform : pkg.getLatestPlatforms()) {
- boards.addAll(platform.getBoards());
+ for (PackageIndex index : packageIndices) {
+ for (ArduinoPackage pkg : index.getPackages()) {
+ for (ArduinoPlatform platform : pkg.getLatestPlatforms()) {
+ boards.addAll(platform.getBoards());
+ }
}
}
return boards;
@@ -135,17 +175,37 @@ public class ArduinoManager {
public List<ArduinoBoard> getInstalledBoards() throws CoreException {
List<ArduinoBoard> boards = new ArrayList<>();
- for (ArduinoPackage pkg : getPackageIndex().getPackages()) {
- for (ArduinoPlatform platform : pkg.getInstalledPlatforms()) {
- boards.addAll(platform.getBoards());
+ for (PackageIndex index : packageIndices) {
+ for (ArduinoPackage pkg : index.getPackages()) {
+ for (ArduinoPlatform platform : pkg.getInstalledPlatforms()) {
+ boards.addAll(platform.getBoards());
+ }
}
}
return boards;
}
+ public ArduinoPackage getPackage(String packageName) {
+ for (PackageIndex index : packageIndices) {
+ ArduinoPackage pkg = index.getPackage(packageName);
+ if (pkg != null) {
+ return pkg;
+ }
+ }
+ return null;
+ }
+
public ArduinoTool getTool(String packageName, String toolName, String version) {
- ArduinoPackage pkg = packageIndex.getPackage(packageName);
- return pkg != null ? pkg.getTool(toolName, version) : null;
+ for (PackageIndex index : packageIndices) {
+ ArduinoPackage pkg = index.getPackage(packageName);
+ if (pkg != null) {
+ ArduinoTool tool = pkg.getTool(toolName, version);
+ if (tool != null) {
+ return tool;
+ }
+ }
+ }
+ return null;
}
private static final String LIBRARIES = "libraries"; //$NON-NLS-1$
@@ -178,7 +238,7 @@ public class ArduinoManager {
try {
settings.flush();
} catch (BackingStoreException e) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), "Saving preferences", e));
+ Activator.log(e);
}
new Job("Install libraries") {
@@ -209,7 +269,7 @@ public class ArduinoManager {
IProgressMonitor monitor) {
try {
URL dl = new URL(url);
- Path dlDir = ArduinoPreferences.getArduinoHome().resolve("downloads");
+ Path dlDir = ArduinoPreferences.getArduinoHome().resolve("downloads"); //$NON-NLS-1$
Files.createDirectories(dlDir);
Path archivePath = dlDir.resolve(archiveFileName);
Files.copy(dl.openStream(), archivePath, StandardCopyOption.REPLACE_EXISTING);
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoToolSystem.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoToolSystem.java
index 0a5d9850267..669dd360b65 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoToolSystem.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoToolSystem.java
@@ -52,7 +52,7 @@ public class ArduinoToolSystem {
case Platform.OS_MACOSX:
switch (host) {
case "i386-apple-darwin11": //$NON-NLS-1$
- case "x86_64-apple-darwin:": //$NON-NLS-1$
+ case "x86_64-apple-darwin": //$NON-NLS-1$
return true;
default:
return false;
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ToolDependency.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ToolDependency.java
index c69e02b8a72..8bd1ef3635d 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ToolDependency.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ToolDependency.java
@@ -40,7 +40,7 @@ public class ToolDependency {
public ArduinoTool getTool() throws CoreException {
ArduinoPackage pkg = platform.getPackage();
if (!pkg.getName().equals(packager)) {
- pkg = pkg.getManager().getPackageIndex().getPackage(packager);
+ pkg = pkg.getManager().getPackage(packager);
}
return pkg.getTool(name, version);
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.ui/plugin.xml b/toolchains/arduino/org.eclipse.cdt.arduino.ui/plugin.xml
index a453e907a50..c3a33f866c0 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.ui/plugin.xml
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.ui/plugin.xml
@@ -90,10 +90,4 @@
name="Boards">
</page>
</extension>
- <extension
- point="org.eclipse.core.runtime.preferences">
- <initializer
- class="org.eclipse.cdt.arduino.ui.internal.preferences.ArduinoPreferenceInitializer">
- </initializer>
- </extension>
</plugin>
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/Activator.java b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/Activator.java
index 930484a856b..11f84062e9f 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/Activator.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/Activator.java
@@ -10,14 +10,12 @@
*******************************************************************************/
package org.eclipse.cdt.arduino.ui.internal;
+import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -26,8 +24,6 @@ import org.osgi.framework.ServiceReference;
*/
public class Activator extends AbstractUIPlugin {
- private IPreferenceStore corePreferenceStore;
-
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.cdt.arduino.ui"; //$NON-NLS-1$
@@ -40,6 +36,8 @@ public class Activator extends AbstractUIPlugin {
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
+ // Load up the Arduino indices
+ ArduinoManager.instance.loadIndices();
}
public void stop(BundleContext context) throws Exception {
@@ -86,11 +84,4 @@ public class Activator extends AbstractUIPlugin {
return ref != null ? context.getService(ref) : null;
}
- public IPreferenceStore getCorePreferenceStore() {
- if (corePreferenceStore == null) {
- corePreferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.cdt.qrduino.core"); //$NON-NLS-1$
- }
- return corePreferenceStore;
- }
-
}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/Messages.java b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/Messages.java
index 68933038836..c64034526d5 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/Messages.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/Messages.java
@@ -14,8 +14,6 @@ public class Messages extends NLS {
public static String ArduinoLaunchConsole_0;
public static String ArduinoLaunchConsole_1;
public static String ArduinoLaunchConsole_2;
- public static String ArduinoPreferencePage_0;
- public static String ArduinoPreferencePage_1;
public static String ArduinoTargetPropertyPage_0;
public static String ArduinoTargetPropertyPage_1;
public static String ArduinoTargetPropertyPage_2;
@@ -28,6 +26,7 @@ public class Messages extends NLS {
public static String NewArduinoTargetWizardPage_5;
public static String ArduinoBoardsPreferencePage_desc;
public static String LibrariesPropertyPage_desc;
+ public static String ArduinoPreferencePage_desc;
static {
// initialize resource bundle
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/messages.properties b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/messages.properties
index 9f0e3a2ab30..a0c4bb4d5ed 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/messages.properties
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/messages.properties
@@ -8,8 +8,6 @@
ArduinoLaunchConsole_0=Arduino
ArduinoLaunchConsole_1=Start Arduino Console
ArduinoLaunchConsole_2=Arduino Console Output
-ArduinoPreferencePage_0=Arduino IDE Install Location
-ArduinoPreferencePage_1=Arduino C++ Preferences
ArduinoTargetPropertyPage_0=Serial Port:
ArduinoTargetPropertyPage_1=No serial ports
ArduinoTargetPropertyPage_2=Board type:
@@ -26,3 +24,4 @@ libraries and tools. For more information, see http://arduino.cc.
LibrariesPropertyPage_desc=Select libraries to use in your project and click OK or Apply. \
If necessary the library will be installed. By adding libraries you agree to the licenses of those \
libraries. For more information, see http://arduino.cc
+ArduinoPreferencePage_desc=Enter URLs for package_index.json files one per line. \ No newline at end of file
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/preferences/ArduinoBoardsPreferencePage.java b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/preferences/ArduinoBoardsPreferencePage.java
index 1a1d4548cbd..65680e8fbe5 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/preferences/ArduinoBoardsPreferencePage.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/preferences/ArduinoBoardsPreferencePage.java
@@ -7,7 +7,6 @@
*******************************************************************************/
package org.eclipse.cdt.arduino.ui.internal.preferences;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
@@ -16,9 +15,7 @@ import java.util.Set;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoard;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager;
-import org.eclipse.cdt.arduino.core.internal.board.ArduinoPackage;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoPlatform;
-import org.eclipse.cdt.arduino.core.internal.board.PackageIndex;
import org.eclipse.cdt.arduino.ui.internal.Activator;
import org.eclipse.cdt.arduino.ui.internal.Messages;
import org.eclipse.core.runtime.CoreException;
@@ -52,7 +49,6 @@ public class ArduinoBoardsPreferencePage extends PreferencePage implements IWork
@Override
public void init(IWorkbench workbench) {
- setPreferenceStore(Activator.getDefault().getCorePreferenceStore());
}
@Override
@@ -136,20 +132,7 @@ public class ArduinoBoardsPreferencePage extends PreferencePage implements IWork
table.removeAll();
try {
- PackageIndex packageIndex = ArduinoManager.instance.getPackageIndex();
- List<ArduinoBoard> boards = new ArrayList<>();
- for (ArduinoPackage pkg : packageIndex.getPackages()) {
- for (ArduinoPlatform platform : pkg.getLatestPlatforms()) {
- try {
- for (ArduinoBoard board : platform.getBoards()) {
- boards.add(board);
- }
- } catch (CoreException e) {
- Activator.log(e);
- }
- }
- }
-
+ List<ArduinoBoard> boards = ArduinoManager.instance.getBoards();
Collections.sort(boards, new Comparator<ArduinoBoard>() {
public int compare(ArduinoBoard o1, ArduinoBoard o2) {
return o1.getName().compareTo(o2.getName());
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/preferences/ArduinoPreferenceInitializer.java b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/preferences/ArduinoPreferenceInitializer.java
deleted file mode 100644
index 914192a7048..00000000000
--- a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/preferences/ArduinoPreferenceInitializer.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.cdt.arduino.ui.internal.preferences;
-
-import org.eclipse.cdt.arduino.core.internal.ArduinoPreferences;
-import org.eclipse.cdt.arduino.ui.internal.Activator;
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-import org.eclipse.jface.preference.IPreferenceStore;
-
-public class ArduinoPreferenceInitializer extends AbstractPreferenceInitializer {
-
- @Override
- public void initializeDefaultPreferences() {
- IPreferenceStore store = Activator.getDefault().getCorePreferenceStore();
- store.setDefault(ArduinoPreferences.ARDUINO_HOME, ArduinoPreferences.getDefaultArduinoHome().toString());
- }
-
-}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/preferences/ArduinoPreferencePage.java b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/preferences/ArduinoPreferencePage.java
index ef64075dc22..50f1c781c2d 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/preferences/ArduinoPreferencePage.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/preferences/ArduinoPreferencePage.java
@@ -11,37 +11,58 @@
package org.eclipse.cdt.arduino.ui.internal.preferences;
import org.eclipse.cdt.arduino.core.internal.ArduinoPreferences;
-import org.eclipse.cdt.arduino.ui.internal.Activator;
+import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager;
import org.eclipse.cdt.arduino.ui.internal.Messages;
-import org.eclipse.jface.preference.DirectoryFieldEditor;
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-public class ArduinoPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+public class ArduinoPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
- public ArduinoPreferencePage() {
- super(GRID);
+ private Text urlsText;
+
+ @Override
+ public void init(IWorkbench workbench) {
}
@Override
- public IPreferenceStore getPreferenceStore() {
- // TODO Auto-generated method stub
- return super.getPreferenceStore();
+ protected Control createContents(Composite parent) {
+ Composite control = new Composite(parent, SWT.NONE);
+ control.setLayout(new GridLayout());
+
+ Text desc = new Text(control, SWT.READ_ONLY | SWT.WRAP);
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, false);
+ layoutData.widthHint = 500;
+ desc.setLayoutData(layoutData);
+ desc.setBackground(parent.getBackground());
+ desc.setText(Messages.ArduinoPreferencePage_desc);
+
+ urlsText = new Text(control, SWT.BORDER);
+ urlsText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ urlsText.setText(ArduinoPreferences.getBoardUrls());
+
+ return control;
}
@Override
- protected void createFieldEditors() {
- addField(new DirectoryFieldEditor(ArduinoPreferences.ARDUINO_HOME, Messages.ArduinoPreferencePage_0,
- getFieldEditorParent()));
+ public boolean performOk() {
+ ArduinoPreferences.setBoardUrls(urlsText.getText());
+ ArduinoManager.instance.loadIndices();
+ return true;
}
@Override
- public void init(IWorkbench workbench) {
- setDescription(Messages.ArduinoPreferencePage_1);
- // Preferences are stored in core
- setPreferenceStore(Activator.getDefault().getCorePreferenceStore());
+ protected void performDefaults() {
+ String defaultBoardUrl = ArduinoPreferences.getDefaultBoardUrls();
+ urlsText.setText(defaultBoardUrl);
+ ArduinoPreferences.setBoardUrls(defaultBoardUrl);
+ super.performDefaults();
}
}

Back to the top