mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Support installing of board platforms using pref page.
Change-Id: Ieaa9704027183a25657d2f4ec0f446949bb5e27f
This commit is contained in:
parent
9b8aa0e12c
commit
8d2489c8ac
42 changed files with 1146 additions and 450 deletions
|
@ -2,7 +2,7 @@ package org.eclipse.cdt.arduino.core.tests;
|
|||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoardManager;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BoardManagerTests {
|
||||
|
|
|
@ -17,11 +17,13 @@ Require-Bundle: org.eclipse.core.runtime,
|
|||
org.eclipse.remote.serial.core;bundle-version="1.0.0",
|
||||
com.google.gson;bundle-version="2.2.4",
|
||||
org.apache.httpcomponents.httpclient;bundle-version="4.3.6",
|
||||
org.apache.httpcomponents.httpcore;bundle-version="4.3.3"
|
||||
org.apache.httpcomponents.httpcore;bundle-version="4.3.3",
|
||||
org.apache.commons.compress;bundle-version="1.6.0"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-ClassPath: libs/freemarker-2.3.22.jar,
|
||||
.
|
||||
Export-Package: org.eclipse.cdt.arduino.core,
|
||||
org.eclipse.cdt.arduino.core.board
|
||||
Export-Package: org.eclipse.cdt.arduino.core.internal;x-friends:="org.eclipse.cdt.arduino.ui",
|
||||
org.eclipse.cdt.arduino.core.internal.board;x-friends:="org.eclipse.cdt.arduino.ui",
|
||||
org.eclipse.cdt.arduino.core.internal.build;x-friends:="org.eclipse.cdt.arduino.ui"
|
||||
Bundle-Localization: plugin
|
||||
|
|
|
@ -109,7 +109,7 @@
|
|||
<connectionService
|
||||
connectionTypeId="org.eclipse.cdt.arduino.core.connectionType"
|
||||
factory="org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection$Factory"
|
||||
service="org.eclipse.cdt.arduino.core.IArduinoRemoteConnection">
|
||||
service="org.eclipse.cdt.arduino.core.internal.IArduinoRemoteConnection">
|
||||
</connectionService>
|
||||
<connectionService
|
||||
connectionTypeId="org.eclipse.cdt.arduino.core.connectionType"
|
||||
|
@ -164,4 +164,14 @@
|
|||
</run>
|
||||
</runtime>
|
||||
</extension>
|
||||
<extension
|
||||
id="arduinoBuilder"
|
||||
point="org.eclipse.core.resources.builders">
|
||||
<builder
|
||||
hasNature="true">
|
||||
<run
|
||||
class="org.eclipse.cdt.arduino.core.internal.build.ArduinoBuilder">
|
||||
</run>
|
||||
</builder>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
|
|
@ -1,42 +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
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.arduino.core;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
public class ArduinoHome {
|
||||
|
||||
public static final String preferenceName = "arduinoHome"; //$NON-NLS-1$
|
||||
private static final String qualifiedName = "org.eclipse.cdt.arduino.ui"; //$NON-NLS-1$
|
||||
|
||||
public static File getArduinoHome() {
|
||||
String arduinoHome = Platform.getPreferencesService().getString(qualifiedName, preferenceName, getDefault(),
|
||||
null);
|
||||
if (Platform.getOS().equals(Platform.OS_MACOSX)) {
|
||||
arduinoHome += "/Contents/Java"; //$NON-NLS-1$
|
||||
}
|
||||
return new File(arduinoHome);
|
||||
}
|
||||
|
||||
public static String getDefault() {
|
||||
switch (Platform.getOS()) {
|
||||
case Platform.OS_MACOSX:
|
||||
return "/Applications/Arduino.app"; //$NON-NLS-1$
|
||||
case Platform.OS_WIN32:
|
||||
return "C:\\Program Files (x86)\\Arduino"; //$NON-NLS-1$
|
||||
default:
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package org.eclipse.cdt.arduino.core.board;
|
||||
|
||||
public class Board {
|
||||
|
||||
private String name;
|
||||
|
||||
private transient String id;
|
||||
private transient Platform platform;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Board setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Board setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Platform getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
Board setOwners(Platform platform) {
|
||||
this.platform = platform;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBuildSetting(String setting) {
|
||||
String key = id + ".build." + setting; //$NON-NLS-1$
|
||||
return platform.getBoardsFile().getProperty(key);
|
||||
}
|
||||
|
||||
public String getPlatformId() {
|
||||
return platform.getArchitecture();
|
||||
}
|
||||
|
||||
public String getPackageId() {
|
||||
return platform.getPackage().getName();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package org.eclipse.cdt.arduino.core.board;
|
||||
|
||||
public class Help {
|
||||
|
||||
private String online;
|
||||
|
||||
public String getOnline() {
|
||||
return online;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package org.eclipse.cdt.arduino.core.board;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
public class Package {
|
||||
|
||||
private String name;
|
||||
private String maintainer;
|
||||
private String websiteURL;
|
||||
private String email;
|
||||
private Help help;
|
||||
private List<Platform> platforms;
|
||||
private List<Tool> tools;
|
||||
|
||||
private transient ArduinoBoardManager manager;
|
||||
|
||||
void setOwners(ArduinoBoardManager manager) {
|
||||
this.manager = manager;
|
||||
for (Platform platform : platforms) {
|
||||
platform.setOwners(this);
|
||||
}
|
||||
}
|
||||
|
||||
ArduinoBoardManager getManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getMaintainer() {
|
||||
return maintainer;
|
||||
}
|
||||
|
||||
public String getWebsiteURL() {
|
||||
return websiteURL;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public Help getHelp() {
|
||||
return help;
|
||||
}
|
||||
|
||||
public List<Platform> getPlatforms() {
|
||||
return platforms;
|
||||
}
|
||||
|
||||
public Platform getPlatform(String architecture) {
|
||||
for (Platform platform : platforms) {
|
||||
if (platform.getArchitecture().equals(architecture)) {
|
||||
return platform;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Tool> getTools() {
|
||||
return tools;
|
||||
}
|
||||
|
||||
public void install(IProgressMonitor monitor) {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
package org.eclipse.cdt.arduino.core.board;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
public class Platform {
|
||||
|
||||
private String name;
|
||||
private String architecture;
|
||||
private String version;
|
||||
private String category;
|
||||
private String url;
|
||||
private String archiveName;
|
||||
private String checksum;
|
||||
private String size;
|
||||
private List<Board> boards;
|
||||
private List<ToolDependency> toolsDependencies;
|
||||
|
||||
private transient Package pkg;
|
||||
private transient Properties boardsFile;
|
||||
|
||||
void setOwners(Package pkg) {
|
||||
this.pkg = pkg;
|
||||
for (Board board : boards) {
|
||||
board.setOwners(this);
|
||||
}
|
||||
}
|
||||
|
||||
public Package getPackage() {
|
||||
return pkg;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getArchitecture() {
|
||||
return architecture;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getArchiveName() {
|
||||
return archiveName;
|
||||
}
|
||||
|
||||
public String getChecksum() {
|
||||
return checksum;
|
||||
}
|
||||
|
||||
public String getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public List<Board> getBoards() {
|
||||
return boards;
|
||||
}
|
||||
|
||||
public Board getBoard(String boardId) {
|
||||
for (Board board : boards) {
|
||||
if (boardId.equals(board.getId())) {
|
||||
return board;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ToolDependency> getToolsDependencies() {
|
||||
return toolsDependencies;
|
||||
}
|
||||
|
||||
void install() throws IOException {
|
||||
Path boardPath = pkg.getManager().getArduinoHome().resolve("hardware").resolve(pkg.getName()) //$NON-NLS-1$
|
||||
.resolve(architecture).resolve(version);
|
||||
boardsFile = new Properties();
|
||||
try (Reader reader = new FileReader(boardPath.toFile())) {
|
||||
boardsFile.load(reader);
|
||||
}
|
||||
|
||||
// Replace the boards with a real ones
|
||||
boards = new ArrayList<>();
|
||||
for (Map.Entry<Object, Object> entry : boardsFile.entrySet()) {
|
||||
String key = (String) entry.getKey();
|
||||
String[] fragments = key.split("."); //$NON-NLS-1$
|
||||
if (fragments.length == 2 && "name".equals(fragments[1])) { //$NON-NLS-1$
|
||||
boards.add(new Board().setId(fragments[0]).setName((String) entry.getValue()).setOwners(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Properties getBoardsFile() {
|
||||
return boardsFile;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package org.eclipse.cdt.arduino.core.board;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Tool {
|
||||
|
||||
private String name;
|
||||
private String version;
|
||||
private List<ToolSystem> systems;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public List<ToolSystem> getSystems() {
|
||||
return systems;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package org.eclipse.cdt.arduino.core.board;
|
||||
|
||||
public class ToolDependency {
|
||||
|
||||
private String packager;
|
||||
private String name;
|
||||
private String version;
|
||||
|
||||
public String getPackager() {
|
||||
return packager;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package org.eclipse.cdt.arduino.core.board;
|
||||
|
||||
public class ToolSystem {
|
||||
|
||||
private String host;
|
||||
private String archiveFileName;
|
||||
private String url;
|
||||
private String checksum;
|
||||
private String size;
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public String getArchiveFileName() {
|
||||
return archiveFileName;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getChecksum() {
|
||||
return checksum;
|
||||
}
|
||||
|
||||
public String getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
}
|
|
@ -10,6 +10,10 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.arduino.core.internal;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.internal.build.ArduinoBuilder;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
|
@ -43,6 +47,14 @@ public class Activator extends Plugin {
|
|||
|
||||
public void start(BundleContext bundleContext) throws Exception {
|
||||
plugin = this;
|
||||
|
||||
// register listener for build config changes
|
||||
CoreModel.getDefault().addCProjectDescriptionListener(new ICProjectDescriptionListener() {
|
||||
@Override
|
||||
public void handleEvent(CProjectDescriptionEvent event) {
|
||||
ArduinoBuilder.handleProjectDescEvent(event);
|
||||
}
|
||||
}, CProjectDescriptionEvent.APPLIED);
|
||||
}
|
||||
|
||||
public void stop(BundleContext bundleContext) throws Exception {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.arduino.core;
|
||||
package org.eclipse.cdt.arduino.core.internal;
|
||||
|
||||
|
||||
public interface ArduinoLaunchConsoleService {
|
|
@ -0,0 +1,28 @@
|
|||
/*******************************************************************************
|
||||
* 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.core.internal;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
public class ArduinoPreferences {
|
||||
|
||||
public static String ARDUINO_HOME = "arduinoHome"; //$NON-NLS-1$
|
||||
|
||||
public static Path getArduinoHome() {
|
||||
String pathStr = Platform.getPreferencesService().getString(Activator.getId(), ARDUINO_HOME, null, null);
|
||||
return pathStr != null ? Paths.get(pathStr) : getDefaultArduinoHome();
|
||||
}
|
||||
|
||||
public static Path getDefaultArduinoHome() {
|
||||
return Paths.get(System.getProperty("user.home"), ".arduinocdt"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.arduino.core;
|
||||
package org.eclipse.cdt.arduino.core.internal;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -22,16 +22,15 @@ import java.util.Collection;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.internal.Activator;
|
||||
import org.eclipse.cdt.arduino.core.internal.ArduinoProjectNature;
|
||||
import org.eclipse.cdt.arduino.core.internal.Messages;
|
||||
import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.internal.build.ArduinoBuilder;
|
||||
import org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
|
||||
import org.eclipse.core.resources.ICommand;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
|
@ -69,6 +68,12 @@ public class ArduinoProjectGenerator {
|
|||
System.arraycopy(oldIds, 0, newIds, 0, oldIds.length);
|
||||
newIds[newIds.length - 1] = ArduinoProjectNature.ID;
|
||||
projDesc.setNatureIds(newIds);
|
||||
|
||||
// Add Arduino Builder
|
||||
ICommand command = projDesc.newCommand();
|
||||
command.setBuilderName(ArduinoBuilder.ID);
|
||||
projDesc.setBuildSpec(new ICommand[] { command });
|
||||
|
||||
project.setDescription(projDesc, monitor);
|
||||
|
||||
// create the CDT natures and build setup
|
|
@ -13,9 +13,8 @@ package org.eclipse.cdt.arduino.core.internal;
|
|||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.ArduinoHome;
|
||||
import org.eclipse.cdt.arduino.core.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.board.Board;
|
||||
import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.internal.board.Board;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector;
|
||||
|
@ -36,7 +35,7 @@ public class AvrLanguageSettingsProvider extends GCCBuiltinSpecsDetector {
|
|||
try {
|
||||
IConfiguration config = ManagedBuildManager.getConfigurationForDescription(currentCfgDescription);
|
||||
Board board = ArduinoBoardManager.instance.getBoard(config);
|
||||
String mcu = board.getBuildSetting("mcu"); //$NON-NLS-1$
|
||||
String mcu = board.getProperty("build.mcu"); //$NON-NLS-1$
|
||||
if (mcu != null) {
|
||||
opts += " -mmcu=" + mcu; //$NON-NLS-1$
|
||||
}
|
||||
|
@ -51,7 +50,8 @@ public class AvrLanguageSettingsProvider extends GCCBuiltinSpecsDetector {
|
|||
protected List<String> parseOptions(String line) {
|
||||
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||
if (line.startsWith(" /arduino/")) { //$NON-NLS-1$
|
||||
File full = new File(ArduinoHome.getArduinoHome().getParentFile(), line.trim());
|
||||
// TODO
|
||||
File full = new File(ArduinoPreferences.getArduinoHome().toFile(), line.trim());
|
||||
return parseOptions(" " + full.getAbsolutePath()); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.ArduinoHome;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
|
||||
|
@ -63,13 +62,13 @@ public class EnvVarSupplier implements IConfigurationEnvironmentVariableSupplier
|
|||
public EnvVarSupplier() {
|
||||
arduinoHome = new EnvVar();
|
||||
arduinoHome.name = "ARDUINO_HOME"; //$NON-NLS-1$
|
||||
arduinoHome.value = clean(ArduinoHome.getArduinoHome().getAbsolutePath());
|
||||
arduinoHome.value = clean(ArduinoPreferences.getArduinoHome().toString());
|
||||
|
||||
arduinoLibs = new EnvVar();
|
||||
arduinoLibs.name = "ARDUINO_USER_LIBS"; //$NON-NLS-1$
|
||||
arduinoLibs.value = clean(System.getProperty("user.home") + "/Documents/Arduino/libraries"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
String avrDir = ArduinoHome.getArduinoHome().toString() + "/hardware/tools/avr/bin"; //$NON-NLS-1$
|
||||
String avrDir = ArduinoPreferences.getArduinoHome().toString() + "/hardware/tools/avr/bin"; //$NON-NLS-1$
|
||||
String installDir = Platform.getInstallLocation().getURL().getPath();
|
||||
path = new EnvVar();
|
||||
path.name = "PATH"; //$NON-NLS-1$
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
/*******************************************************************************
|
||||
* 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.core.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
public class HierarchicalProperties {
|
||||
|
||||
private String value;
|
||||
private Map<String, HierarchicalProperties> children;
|
||||
|
||||
public HierarchicalProperties() {
|
||||
}
|
||||
|
||||
public HierarchicalProperties(Properties properties) {
|
||||
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
|
||||
String key = (String) entry.getKey();
|
||||
String value = (String) entry.getValue();
|
||||
putProperty(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public String getProperty(String qualifiedKey) {
|
||||
if (children == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int i = qualifiedKey.indexOf('.');
|
||||
if (i < 0) {
|
||||
HierarchicalProperties child = children.get(qualifiedKey);
|
||||
return child != null ? child.getValue() : null;
|
||||
} else {
|
||||
String key = qualifiedKey.substring(0, i);
|
||||
HierarchicalProperties child = children.get(key);
|
||||
if (child != null) {
|
||||
String childKey = qualifiedKey.substring(i + 1);
|
||||
return child.getProperty(childKey);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void putProperty(String qualifiedKey, String value) {
|
||||
if (children == null) {
|
||||
children = new HashMap<>();
|
||||
}
|
||||
|
||||
int i = qualifiedKey.indexOf('.');
|
||||
if (i < 0) {
|
||||
HierarchicalProperties child = children.get(qualifiedKey);
|
||||
if (child == null) {
|
||||
child = new HierarchicalProperties();
|
||||
children.put(qualifiedKey, child);
|
||||
child.setValue(value);
|
||||
}
|
||||
} else {
|
||||
String key = qualifiedKey.substring(0, i);
|
||||
HierarchicalProperties child = children.get(key);
|
||||
if (child == null) {
|
||||
child = new HierarchicalProperties();
|
||||
children.put(qualifiedKey, child);
|
||||
}
|
||||
String childKey = qualifiedKey.substring(i + 1);
|
||||
child.putProperty(childKey, value);
|
||||
}
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Map<String, HierarchicalProperties> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public HierarchicalProperties getChild(String key) {
|
||||
return children != null ? children.get(key) : null;
|
||||
}
|
||||
|
||||
public void putChild(String key, HierarchicalProperties node) {
|
||||
if (children == null) {
|
||||
children = new HashMap<>();
|
||||
}
|
||||
children.put(key, node);
|
||||
}
|
||||
|
||||
public List<HierarchicalProperties> listChildren() {
|
||||
int size = 0;
|
||||
for (Map.Entry<String, HierarchicalProperties> entry : children.entrySet()) {
|
||||
try {
|
||||
int i = Integer.parseInt(entry.getKey());
|
||||
if (i + 1 > size) {
|
||||
size = i + 1;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<HierarchicalProperties> list = new ArrayList<>(size);
|
||||
for (Map.Entry<String, HierarchicalProperties> entry : children.entrySet()) {
|
||||
try {
|
||||
int i = Integer.parseInt(entry.getKey());
|
||||
list.set(i, entry.getValue());
|
||||
} catch (NumberFormatException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setChildren(List<HierarchicalProperties> list) {
|
||||
children.clear();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
HierarchicalProperties node = list.get(i);
|
||||
if (node != null) {
|
||||
children.put(Integer.toString(i), node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.arduino.core;
|
||||
package org.eclipse.cdt.arduino.core.internal;
|
||||
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
|
|
@ -8,13 +8,12 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.arduino.core.board;
|
||||
package org.eclipse.cdt.arduino.core.internal.board;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -25,6 +24,7 @@ import org.apache.http.client.methods.HttpGet;
|
|||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.eclipse.cdt.arduino.core.internal.Activator;
|
||||
import org.eclipse.cdt.arduino.core.internal.ArduinoPreferences;
|
||||
import org.eclipse.cdt.arduino.core.internal.Messages;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
|
@ -56,9 +56,7 @@ public class ArduinoBoardManager {
|
|||
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$
|
||||
|
||||
// TODO make this a preference
|
||||
private Path arduinoHome = Paths.get(System.getProperty("user.home"), ".arduinocdt"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private Path packageIndexPath;
|
||||
private Path packageIndexPath = ArduinoPreferences.getArduinoHome().resolve("package_index.json"); //$NON-NLS-1$
|
||||
private PackageIndex packageIndex;
|
||||
|
||||
public ArduinoBoardManager() {
|
||||
|
@ -75,8 +73,7 @@ public class ArduinoBoardManager {
|
|||
if (entity == null) {
|
||||
return new Status(IStatus.ERROR, Activator.getId(), Messages.ArduinoBoardManager_1);
|
||||
}
|
||||
Files.createDirectories(arduinoHome);
|
||||
packageIndexPath = arduinoHome.resolve("package_index.json"); //$NON-NLS-1$
|
||||
Files.createDirectories(packageIndexPath.getParent());
|
||||
Files.copy(entity.getContent(), packageIndexPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
}
|
||||
|
@ -88,14 +85,11 @@ public class ArduinoBoardManager {
|
|||
}.schedule();
|
||||
}
|
||||
|
||||
Path getArduinoHome() {
|
||||
return arduinoHome;
|
||||
}
|
||||
|
||||
public PackageIndex getPackageIndex() throws IOException {
|
||||
if (packageIndex == null) {
|
||||
try (FileReader reader = new FileReader(packageIndexPath.toFile())) {
|
||||
packageIndex = new Gson().fromJson(reader, PackageIndex.class);
|
||||
packageIndex.setOwners(this);
|
||||
}
|
||||
}
|
||||
return packageIndex;
|
||||
|
@ -124,7 +118,7 @@ public class ArduinoBoardManager {
|
|||
return projDesc.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
|
||||
}
|
||||
|
||||
public Board getBoard(String boardId, String platformId, String packageId) {
|
||||
public Board getBoard(String boardId, String platformId, String packageId) throws CoreException {
|
||||
return packageIndex.getPackage(packageId).getPlatform(platformId).getBoard(boardId);
|
||||
}
|
||||
|
||||
|
@ -145,9 +139,9 @@ public class ArduinoBoardManager {
|
|||
|
||||
}
|
||||
|
||||
public List<Board> getBoards() {
|
||||
public List<Board> getBoards() throws CoreException {
|
||||
List<Board> boards = new ArrayList<>();
|
||||
for (Package pkg : packageIndex.getPackages()) {
|
||||
for (BoardPackage pkg : packageIndex.getPackages()) {
|
||||
for (Platform platform : pkg.getPlatforms()) {
|
||||
boards.addAll(platform.getBoards());
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*******************************************************************************
|
||||
* 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.core.internal.board;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.internal.HierarchicalProperties;
|
||||
|
||||
public class Board {
|
||||
|
||||
private String name;
|
||||
|
||||
private String id;
|
||||
|
||||
private Platform platform;
|
||||
private HierarchicalProperties properties;
|
||||
|
||||
public Board() {
|
||||
}
|
||||
|
||||
public Board(HierarchicalProperties properties) {
|
||||
this.properties = properties;
|
||||
this.id = this.properties.getValue();
|
||||
this.name = this.properties.getChild("name").getValue(); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Platform getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
Board setOwners(Platform platform) {
|
||||
this.platform = platform;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getProperty(String key) {
|
||||
return properties.getProperty(key);
|
||||
}
|
||||
|
||||
public String getPlatformId() {
|
||||
return platform.getArchitecture();
|
||||
}
|
||||
|
||||
public String getPackageId() {
|
||||
return platform.getPackage().getName();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
/*******************************************************************************
|
||||
* 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.core.internal.board;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
public class BoardPackage {
|
||||
|
||||
private String name;
|
||||
private String maintainer;
|
||||
private String websiteURL;
|
||||
private String email;
|
||||
private Help help;
|
||||
private List<Platform> platforms;
|
||||
private List<Tool> tools;
|
||||
|
||||
private transient ArduinoBoardManager manager;
|
||||
|
||||
void setOwners(ArduinoBoardManager manager) {
|
||||
this.manager = manager;
|
||||
for (Platform platform : platforms) {
|
||||
platform.setOwners(this);
|
||||
}
|
||||
}
|
||||
|
||||
ArduinoBoardManager getManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getMaintainer() {
|
||||
return maintainer;
|
||||
}
|
||||
|
||||
public String getWebsiteURL() {
|
||||
return websiteURL;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public Help getHelp() {
|
||||
return help;
|
||||
}
|
||||
|
||||
public Collection<Platform> getPlatforms() {
|
||||
return Collections.unmodifiableCollection(platforms);
|
||||
}
|
||||
|
||||
/**
|
||||
* Only the latest versions of the platforms.
|
||||
*
|
||||
* @return latest platforms
|
||||
*/
|
||||
public Collection<Platform> getLatestPlatforms() {
|
||||
Map<String, Platform> platformMap = new HashMap<>();
|
||||
for (Platform platform : platforms) {
|
||||
Platform p = platformMap.get(platform.getName());
|
||||
if (p == null || compareVersions(platform.getVersion(), p.getVersion()) > 0) {
|
||||
platformMap.put(platform.getName(), platform);
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.unmodifiableCollection(platformMap.values());
|
||||
}
|
||||
|
||||
private int compareVersions(String version1, String version2) {
|
||||
if (version1 == null) {
|
||||
return version2 == null ? 0 : -1;
|
||||
}
|
||||
|
||||
if (version2 == null) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
String[] v1 = version1.split("\\."); //$NON-NLS-1$
|
||||
String[] v2 = version2.split("\\."); //$NON-NLS-1$
|
||||
for (int i = 0; i < Math.max(v1.length, v2.length); ++i) {
|
||||
if (v1.length <= i) {
|
||||
return v2.length < i ? 0 : -1;
|
||||
}
|
||||
|
||||
if (v2.length <= i) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
int vi1 = Integer.parseInt(v1[i]);
|
||||
int vi2 = Integer.parseInt(v2[i]);
|
||||
if (vi1 < vi2) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (vi1 > vi2) {
|
||||
return 1;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
// not numbers, do string compares
|
||||
int c = v1[i].compareTo(v2[i]);
|
||||
if (c < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (c > 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Platform getPlatform(String architecture) {
|
||||
for (Platform platform : platforms) {
|
||||
if (platform.getArchitecture().equals(architecture)) {
|
||||
return platform;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Tool> getTools() {
|
||||
return tools;
|
||||
}
|
||||
|
||||
public void install(IProgressMonitor monitor) {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
/*******************************************************************************
|
||||
* 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.core.internal.board;
|
||||
|
||||
public class Help {
|
||||
|
||||
private String online;
|
||||
|
||||
public String getOnline() {
|
||||
return online;
|
||||
}
|
||||
|
||||
}
|
|
@ -5,20 +5,20 @@
|
|||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.arduino.core.board;
|
||||
package org.eclipse.cdt.arduino.core.internal.board;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PackageIndex {
|
||||
|
||||
private List<Package> packages;
|
||||
private List<BoardPackage> packages;
|
||||
|
||||
public List<Package> getPackages() {
|
||||
public List<BoardPackage> getPackages() {
|
||||
return packages;
|
||||
}
|
||||
|
||||
public Package getPackage(String packageName) {
|
||||
for (Package pkg : packages) {
|
||||
public BoardPackage getPackage(String packageName) {
|
||||
for (BoardPackage pkg : packages) {
|
||||
if (pkg.getName().equals(packageName)) {
|
||||
return pkg;
|
||||
}
|
||||
|
@ -26,4 +26,10 @@ public class PackageIndex {
|
|||
return null;
|
||||
}
|
||||
|
||||
void setOwners(ArduinoBoardManager manager) {
|
||||
for (BoardPackage pkg : packages) {
|
||||
pkg.setOwners(manager);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,216 @@
|
|||
/*******************************************************************************
|
||||
* 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.core.internal.board;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.compress.archivers.ArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.ArchiveException;
|
||||
import org.apache.commons.compress.archivers.ArchiveInputStream;
|
||||
import org.apache.commons.compress.archivers.ArchiveStreamFactory;
|
||||
import org.apache.commons.compress.compressors.CompressorException;
|
||||
import org.apache.commons.compress.compressors.CompressorStreamFactory;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.eclipse.cdt.arduino.core.internal.Activator;
|
||||
import org.eclipse.cdt.arduino.core.internal.ArduinoPreferences;
|
||||
import org.eclipse.cdt.arduino.core.internal.HierarchicalProperties;
|
||||
import org.eclipse.cdt.arduino.core.internal.Messages;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class Platform {
|
||||
|
||||
private String name;
|
||||
private String architecture;
|
||||
private String version;
|
||||
private String category;
|
||||
private String url;
|
||||
private String archiveFileName;
|
||||
private String checksum;
|
||||
private String size;
|
||||
private List<Board> boards;
|
||||
private List<ToolDependency> toolsDependencies;
|
||||
|
||||
private transient BoardPackage pkg;
|
||||
private transient HierarchicalProperties boardsFile;
|
||||
|
||||
void setOwners(BoardPackage pkg) {
|
||||
this.pkg = pkg;
|
||||
for (Board board : boards) {
|
||||
board.setOwners(this);
|
||||
}
|
||||
}
|
||||
|
||||
public BoardPackage getPackage() {
|
||||
return pkg;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getArchitecture() {
|
||||
return architecture;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getArchiveFileName() {
|
||||
return archiveFileName;
|
||||
}
|
||||
|
||||
public String getChecksum() {
|
||||
return checksum;
|
||||
}
|
||||
|
||||
public String getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public List<Board> getBoards() throws CoreException {
|
||||
if (isInstalled() && boardsFile == null) {
|
||||
Properties boardProps = new Properties();
|
||||
try (Reader reader = new FileReader(getInstallPath().resolve("boards.txt").toFile())) { //$NON-NLS-1$
|
||||
boardProps.load(reader);
|
||||
} catch (IOException e) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), "Loading boards", e));
|
||||
}
|
||||
|
||||
boardsFile = new HierarchicalProperties(boardProps);
|
||||
|
||||
// Replace the boards with a real ones
|
||||
boards = new ArrayList<>();
|
||||
for (HierarchicalProperties child : boardsFile.getChildren().values()) {
|
||||
if (child.getChild("name") != null) { //$NON-NLS-1$
|
||||
// assume things with names are boards
|
||||
boards.add(new Board(child).setOwners(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
return boards;
|
||||
}
|
||||
|
||||
public Board getBoard(String boardId) throws CoreException {
|
||||
for (Board board : getBoards()) {
|
||||
if (boardId.equals(board.getId())) {
|
||||
return board;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ToolDependency> getToolsDependencies() {
|
||||
return toolsDependencies;
|
||||
}
|
||||
|
||||
public boolean isInstalled() {
|
||||
return getInstallPath().resolve("boards.txt").toFile().exists(); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private Path getInstallPath() {
|
||||
return ArduinoPreferences.getArduinoHome().resolve("hardware").resolve(pkg.getName()).resolve(architecture) //$NON-NLS-1$
|
||||
.resolve(version);
|
||||
}
|
||||
|
||||
public IStatus install(IProgressMonitor monitor) throws CoreException {
|
||||
try {
|
||||
try (CloseableHttpClient client = HttpClients.createDefault()) {
|
||||
HttpGet get = new HttpGet(url);
|
||||
try (CloseableHttpResponse response = client.execute(get)) {
|
||||
if (response.getStatusLine().getStatusCode() >= 400) {
|
||||
return new Status(IStatus.ERROR, Activator.getId(), response.getStatusLine().getReasonPhrase());
|
||||
} else {
|
||||
HttpEntity entity = response.getEntity();
|
||||
if (entity == null) {
|
||||
return new Status(IStatus.ERROR, Activator.getId(), Messages.ArduinoBoardManager_1);
|
||||
}
|
||||
// the archive has the version number as the root
|
||||
// directory
|
||||
Path installPath = getInstallPath().getParent();
|
||||
Files.createDirectories(installPath);
|
||||
Path archivePath = installPath.resolve(archiveFileName);
|
||||
Files.copy(entity.getContent(), archivePath, StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
// extract
|
||||
ArchiveInputStream archiveIn = null;
|
||||
try {
|
||||
String compressor = null;
|
||||
String archiver = null;
|
||||
if (archiveFileName.endsWith("tar.bz2")) { //$NON-NLS-1$
|
||||
compressor = CompressorStreamFactory.BZIP2;
|
||||
archiver = ArchiveStreamFactory.TAR;
|
||||
} else if (archiveFileName.endsWith(".tar.gz") || archiveFileName.endsWith(".tgz")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
compressor = CompressorStreamFactory.GZIP;
|
||||
archiver = ArchiveStreamFactory.TAR;
|
||||
} else if (archiveFileName.endsWith(".tar.xz")) { //$NON-NLS-1$
|
||||
compressor = CompressorStreamFactory.XZ;
|
||||
archiver = ArchiveStreamFactory.TAR;
|
||||
} else if (archiveFileName.endsWith(".zip")) { //$NON-NLS-1$
|
||||
archiver = ArchiveStreamFactory.ZIP;
|
||||
}
|
||||
|
||||
InputStream in = new BufferedInputStream(new FileInputStream(archivePath.toFile()));
|
||||
if (compressor != null) {
|
||||
in = new CompressorStreamFactory().createCompressorInputStream(compressor, in);
|
||||
}
|
||||
archiveIn = new ArchiveStreamFactory().createArchiveInputStream(archiver, in);
|
||||
|
||||
for (ArchiveEntry entry = archiveIn.getNextEntry(); entry != null; entry = archiveIn
|
||||
.getNextEntry()) {
|
||||
if (entry.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO check for soft links in tar files.
|
||||
Path entryPath = installPath.resolve(entry.getName());
|
||||
Files.createDirectories(entryPath.getParent());
|
||||
Files.copy(archiveIn, entryPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
} finally {
|
||||
if (archiveIn != null) {
|
||||
archiveIn.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
} catch (IOException | CompressorException | ArchiveException e) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), "Installing Platform", e));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*******************************************************************************
|
||||
* 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.core.internal.board;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Tool {
|
||||
|
||||
private String name;
|
||||
private String version;
|
||||
private List<ToolSystem> systems;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public List<ToolSystem> getSystems() {
|
||||
return systems;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*******************************************************************************
|
||||
* 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.core.internal.board;
|
||||
|
||||
public class ToolDependency {
|
||||
|
||||
private String packager;
|
||||
private String name;
|
||||
private String version;
|
||||
|
||||
public String getPackager() {
|
||||
return packager;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/*******************************************************************************
|
||||
* 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.core.internal.board;
|
||||
|
||||
public class ToolSystem {
|
||||
|
||||
private String host;
|
||||
private String archiveFileName;
|
||||
private String url;
|
||||
private String checksum;
|
||||
private String size;
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public String getArchiveFileName() {
|
||||
return archiveFileName;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getChecksum() {
|
||||
return checksum;
|
||||
}
|
||||
|
||||
public String getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/*******************************************************************************
|
||||
* 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.core.internal.build;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.internal.Activator;
|
||||
import org.eclipse.cdt.arduino.core.internal.ArduinoProjectNature;
|
||||
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
/**
|
||||
* This class is responsible for generating the Makefile for the current build
|
||||
* config.
|
||||
*/
|
||||
public class ArduinoBuilder extends IncrementalProjectBuilder {
|
||||
|
||||
public static final String ID = Activator.getId() + ".arduinoBuilder"; //$NON-NLS-1$
|
||||
|
||||
@Override
|
||||
protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) throws CoreException {
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
|
||||
IConfiguration config = info.getDefaultConfiguration();
|
||||
|
||||
// TODO if there are references we want to watch, return them here
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void handleProjectDescEvent(CProjectDescriptionEvent event) {
|
||||
try {
|
||||
IProject project = event.getProject();
|
||||
// Is this an arduino project?
|
||||
if (!ArduinoProjectNature.hasNature(project)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// See if CDT config changed and sync the Resource config
|
||||
ICConfigurationDescription newConfigDesc = event.getNewCProjectDescription().getActiveConfiguration();
|
||||
ICConfigurationDescription oldConfigDesc = event.getOldCProjectDescription().getActiveConfiguration();
|
||||
if (!newConfigDesc.equals(oldConfigDesc)) {
|
||||
System.out.println("Active config changed: " + newConfigDesc.getName()); //$NON-NLS-1$
|
||||
String configName = newConfigDesc.getName();
|
||||
if (project.hasBuildConfig(configName)) {
|
||||
IProjectDescription projDesc = project.getDescription();
|
||||
projDesc.setActiveBuildConfig(configName);
|
||||
project.setDescription(projDesc, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -15,12 +15,12 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.ArduinoLaunchConsoleService;
|
||||
import org.eclipse.cdt.arduino.core.IArduinoRemoteConnection;
|
||||
import org.eclipse.cdt.arduino.core.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.board.Board;
|
||||
import org.eclipse.cdt.arduino.core.internal.Activator;
|
||||
import org.eclipse.cdt.arduino.core.internal.ArduinoLaunchConsoleService;
|
||||
import org.eclipse.cdt.arduino.core.internal.IArduinoRemoteConnection;
|
||||
import org.eclipse.cdt.arduino.core.internal.Messages;
|
||||
import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.internal.board.Board;
|
||||
import org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
|
||||
|
|
|
@ -14,8 +14,8 @@ import java.io.IOException;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.IArduinoRemoteConnection;
|
||||
import org.eclipse.cdt.arduino.core.internal.Activator;
|
||||
import org.eclipse.cdt.arduino.core.internal.IArduinoRemoteConnection;
|
||||
import org.eclipse.cdt.serial.SerialPort;
|
||||
import org.eclipse.remote.core.IRemoteCommandShellService;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
|
|
|
@ -69,15 +69,21 @@
|
|||
point="org.eclipse.ui.preferencePages">
|
||||
<page
|
||||
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
|
||||
class="org.eclipse.cdt.arduino.ui.internal.ArduinoPreferencePage"
|
||||
class="org.eclipse.cdt.arduino.ui.internal.preferences.ArduinoPreferencePage"
|
||||
id="org.eclipse.cdt.arduino.preference.page"
|
||||
name="%preferencePage.name">
|
||||
</page>
|
||||
<page
|
||||
category="org.eclipse.cdt.arduino.preference.page"
|
||||
class="org.eclipse.cdt.arduino.ui.internal.preferences.ArduinoBoardsPreferencePage"
|
||||
id="org.eclipse.cdt.arduino.preference.page.boards"
|
||||
name="Boards">
|
||||
</page>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.core.runtime.preferences">
|
||||
<initializer
|
||||
class="org.eclipse.cdt.arduino.ui.internal.ArduinoPreferenceInitializer">
|
||||
class="org.eclipse.cdt.arduino.ui.internal.preferences.ArduinoPreferenceInitializer">
|
||||
</initializer>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
|
|
@ -13,8 +13,11 @@ package org.eclipse.cdt.arduino.ui.internal;
|
|||
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;
|
||||
|
||||
|
@ -23,6 +26,8 @@ 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$
|
||||
|
||||
|
@ -77,4 +82,11 @@ 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
package org.eclipse.cdt.arduino.ui.internal;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.ArduinoHome;
|
||||
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().getPreferenceStore();
|
||||
store.setDefault(ArduinoHome.preferenceName, ArduinoHome.getDefault());
|
||||
}
|
||||
|
||||
}
|
|
@ -13,7 +13,7 @@ package org.eclipse.cdt.arduino.ui.internal.launch;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.ArduinoLaunchConsoleService;
|
||||
import org.eclipse.cdt.arduino.core.internal.ArduinoLaunchConsoleService;
|
||||
import org.eclipse.cdt.arduino.ui.internal.Messages;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
|
|
@ -0,0 +1,217 @@
|
|||
/*******************************************************************************
|
||||
* 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 java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.internal.board.Board;
|
||||
import org.eclipse.cdt.arduino.core.internal.board.BoardPackage;
|
||||
import org.eclipse.cdt.arduino.core.internal.board.PackageIndex;
|
||||
import org.eclipse.cdt.arduino.core.internal.board.Platform;
|
||||
import org.eclipse.cdt.arduino.ui.internal.Activator;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.jface.layout.TableColumnLayout;
|
||||
import org.eclipse.jface.preference.PreferencePage;
|
||||
import org.eclipse.jface.viewers.ColumnWeightData;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Table;
|
||||
import org.eclipse.swt.widgets.TableColumn;
|
||||
import org.eclipse.swt.widgets.TableItem;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
|
||||
public class ArduinoBoardsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
|
||||
|
||||
private Table table;
|
||||
private Button installButton;
|
||||
private Set<Board> toInstall = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public void init(IWorkbench workbench) {
|
||||
setPreferenceStore(Activator.getDefault().getCorePreferenceStore());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Control createContents(Composite parent) {
|
||||
Composite comp = new Composite(parent, SWT.NONE);
|
||||
comp.setLayout(new GridLayout(2, false));
|
||||
|
||||
Composite tableComp = new Composite(comp, SWT.NONE);
|
||||
tableComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
|
||||
table = new Table(tableComp, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);
|
||||
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
table.setHeaderVisible(true);
|
||||
table.setLinesVisible(true);
|
||||
|
||||
TableColumn packageColumn = new TableColumn(table, SWT.LEAD);
|
||||
packageColumn.setText("Board");
|
||||
|
||||
TableColumn platformColumn = new TableColumn(table, SWT.LEAD);
|
||||
platformColumn.setText("Platform");
|
||||
|
||||
TableColumn installedColumn = new TableColumn(table, SWT.LEAD);
|
||||
installedColumn.setText("Installed");
|
||||
|
||||
TableColumnLayout tableLayout = new TableColumnLayout();
|
||||
tableLayout.setColumnData(packageColumn, new ColumnWeightData(5, 150, true));
|
||||
tableLayout.setColumnData(platformColumn, new ColumnWeightData(5, 150, true));
|
||||
tableLayout.setColumnData(installedColumn, new ColumnWeightData(2, 75, true));
|
||||
tableComp.setLayout(tableLayout);
|
||||
|
||||
table.addListener(SWT.Selection, new Listener() {
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
updateButtons();
|
||||
}
|
||||
});
|
||||
|
||||
Composite buttonComp = new Composite(comp, SWT.NONE);
|
||||
buttonComp.setLayout(new GridLayout());
|
||||
buttonComp.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
|
||||
|
||||
installButton = new Button(buttonComp, SWT.PUSH);
|
||||
installButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
|
||||
installButton.setText("Install");
|
||||
installButton.addListener(SWT.Selection, new Listener() {
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
for (TableItem item : table.getSelection()) {
|
||||
Board board = (Board) item.getData();
|
||||
toInstall.add(board);
|
||||
item.setText(2, "selected");
|
||||
updateButtons();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
updateTable();
|
||||
updateButtons();
|
||||
|
||||
return comp;
|
||||
}
|
||||
|
||||
private void updateTable() {
|
||||
if (table == null || table.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
table.removeAll();
|
||||
|
||||
try {
|
||||
PackageIndex packageIndex = ArduinoBoardManager.instance.getPackageIndex();
|
||||
List<Board> boards = new ArrayList<>();
|
||||
for (BoardPackage pkg : packageIndex.getPackages()) {
|
||||
for (Platform platform : pkg.getLatestPlatforms()) {
|
||||
try {
|
||||
for (Board board : platform.getBoards()) {
|
||||
boards.add(board);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(boards, new Comparator<Board>() {
|
||||
public int compare(Board o1, Board o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
});
|
||||
|
||||
for (Board board : boards) {
|
||||
TableItem item = new TableItem(table, SWT.NONE);
|
||||
item.setData(board);
|
||||
item.setText(0, board.getName());
|
||||
item.setText(1, board.getPlatform().getName());
|
||||
String msg;
|
||||
if (toInstall.contains(board)) {
|
||||
msg = "selected";
|
||||
} else {
|
||||
msg = board.getPlatform().isInstalled() ? "yes" : "no";
|
||||
}
|
||||
item.setText(2, msg);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateButtons() {
|
||||
if (table == null || table.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean enable = false;
|
||||
for (TableItem item : table.getSelection()) {
|
||||
Board board = (Board) item.getData();
|
||||
if (toInstall.contains(board)) {
|
||||
continue;
|
||||
}
|
||||
Platform platform = board.getPlatform();
|
||||
if (!platform.isInstalled()) {
|
||||
enable = true;
|
||||
}
|
||||
}
|
||||
installButton.setEnabled(enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performOk() {
|
||||
new Job("Installing Arduino Board Platforms") {
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
Set<Platform> platforms = new HashSet<>();
|
||||
for (Board board : toInstall) {
|
||||
platforms.add(board.getPlatform());
|
||||
}
|
||||
|
||||
for (Platform platform : platforms) {
|
||||
try {
|
||||
platform.install(monitor);
|
||||
} catch (CoreException e) {
|
||||
return e.getStatus();
|
||||
}
|
||||
}
|
||||
|
||||
toInstall.clear();
|
||||
|
||||
if (table != null && !table.isDisposed()) {
|
||||
table.getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateTable();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
}.schedule();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/*******************************************************************************
|
||||
* 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());
|
||||
}
|
||||
|
||||
}
|
|
@ -8,11 +8,14 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.arduino.ui.internal;
|
||||
package org.eclipse.cdt.arduino.ui.internal.preferences;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.ArduinoHome;
|
||||
import org.eclipse.cdt.arduino.core.internal.ArduinoPreferences;
|
||||
import org.eclipse.cdt.arduino.ui.internal.Activator;
|
||||
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.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
|
||||
|
@ -22,16 +25,23 @@ public class ArduinoPreferencePage extends FieldEditorPreferencePage implements
|
|||
super(GRID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPreferenceStore getPreferenceStore() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getPreferenceStore();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createFieldEditors() {
|
||||
addField(new DirectoryFieldEditor(ArduinoHome.preferenceName, Messages.ArduinoPreferencePage_0,
|
||||
addField(new DirectoryFieldEditor(ArduinoPreferences.ARDUINO_HOME, Messages.ArduinoPreferencePage_0,
|
||||
getFieldEditorParent()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(IWorkbench workbench) {
|
||||
setDescription(Messages.ArduinoPreferencePage_1);
|
||||
setPreferenceStore(Activator.getDefault().getPreferenceStore());
|
||||
// Preferences are stored in core
|
||||
setPreferenceStore(Activator.getDefault().getCorePreferenceStore());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package org.eclipse.cdt.arduino.ui.internal.project;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.ArduinoProjectGenerator;
|
||||
import org.eclipse.cdt.arduino.core.internal.ArduinoProjectGenerator;
|
||||
import org.eclipse.cdt.arduino.ui.internal.Activator;
|
||||
import org.eclipse.cdt.arduino.ui.internal.Messages;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
|
|
@ -3,12 +3,13 @@ package org.eclipse.cdt.arduino.ui.internal.remote;
|
|||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.IArduinoRemoteConnection;
|
||||
import org.eclipse.cdt.arduino.core.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.board.Board;
|
||||
import org.eclipse.cdt.arduino.core.internal.IArduinoRemoteConnection;
|
||||
import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.internal.board.Board;
|
||||
import org.eclipse.cdt.arduino.ui.internal.Activator;
|
||||
import org.eclipse.cdt.arduino.ui.internal.Messages;
|
||||
import org.eclipse.cdt.serial.SerialPort;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
|
@ -71,6 +72,7 @@ public class ArduinoTargetPropertyPage extends PropertyPage implements IWorkbenc
|
|||
boardSelector = new Combo(comp, SWT.READ_ONLY);
|
||||
boardSelector.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
try {
|
||||
Board currentBoard = ArduinoBoardManager.instance.getBoard(arduinoRemote.getBoardId(),
|
||||
arduinoRemote.getPlatformId(), arduinoRemote.getPackageId());
|
||||
Collection<Board> boardList = ArduinoBoardManager.instance.getBoards();
|
||||
|
@ -86,6 +88,9 @@ public class ArduinoTargetPropertyPage extends PropertyPage implements IWorkbenc
|
|||
i++;
|
||||
}
|
||||
boardSelector.select(boardSel);
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
|
||||
return comp;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.eclipse.cdt.arduino.ui.internal.remote;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.IArduinoRemoteConnection;
|
||||
import org.eclipse.cdt.arduino.core.internal.IArduinoRemoteConnection;
|
||||
import org.eclipse.cdt.arduino.ui.internal.Activator;
|
||||
import org.eclipse.jface.wizard.Wizard;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
|
|
|
@ -2,11 +2,12 @@ package org.eclipse.cdt.arduino.ui.internal.remote;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.board.Board;
|
||||
import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.internal.board.Board;
|
||||
import org.eclipse.cdt.arduino.ui.internal.Activator;
|
||||
import org.eclipse.cdt.arduino.ui.internal.Messages;
|
||||
import org.eclipse.cdt.serial.SerialPort;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.wizard.WizardPage;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
|
@ -88,11 +89,15 @@ public class NewArduinoTargetWizardPage extends WizardPage {
|
|||
|
||||
boardCombo = new Combo(comp, SWT.READ_ONLY);
|
||||
boardCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
try {
|
||||
boards = ArduinoBoardManager.instance.getBoards().toArray(new Board[0]);
|
||||
for (Board board : boards) {
|
||||
boardCombo.add(board.getName());
|
||||
}
|
||||
boardCombo.select(0);
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
boardCombo.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
|
|
Loading…
Add table
Reference in a new issue