mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-15 12:29:26 +01:00
Moved platform (and related methods) from Base to BaseNoGui (work in progress).
This commit is contained in:
parent
7776ffac4f
commit
4c1b187313
@ -140,7 +140,7 @@ public class NetworkDiscovery implements Discovery, ServiceListener, cc.arduino.
|
|||||||
|
|
||||||
String label = name + " at " + address;
|
String label = name + " at " + address;
|
||||||
if (board != null) {
|
if (board != null) {
|
||||||
String boardName = Base.getPlatform().resolveDeviceByBoardID(BaseNoGui.packages, board);
|
String boardName = BaseNoGui.getPlatform().resolveDeviceByBoardID(BaseNoGui.packages, board);
|
||||||
label += " (" + boardName + ")";
|
label += " (" + boardName + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class SerialDiscovery implements Discovery {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BoardPort> discovery() {
|
public List<BoardPort> discovery() {
|
||||||
Platform os = Base.getPlatform();
|
Platform os = BaseNoGui.getPlatform();
|
||||||
String devicesListOutput = os.preListAllCandidateDevices();
|
String devicesListOutput = os.preListAllCandidateDevices();
|
||||||
|
|
||||||
List<BoardPort> res = new ArrayList<BoardPort>();
|
List<BoardPort> res = new ArrayList<BoardPort>();
|
||||||
|
@ -67,8 +67,6 @@ public class Base {
|
|||||||
/** Set true if this a proper release rather than a numbered revision. */
|
/** Set true if this a proper release rather than a numbered revision. */
|
||||||
static public boolean RELEASE = BaseNoGui.RELEASE;
|
static public boolean RELEASE = BaseNoGui.RELEASE;
|
||||||
|
|
||||||
static Platform platform;
|
|
||||||
|
|
||||||
private static DiscoveryManager discoveryManager = new DiscoveryManager();
|
private static DiscoveryManager discoveryManager = new DiscoveryManager();
|
||||||
|
|
||||||
static private boolean commandLine;
|
static private boolean commandLine;
|
||||||
@ -212,7 +210,7 @@ public class Base {
|
|||||||
|
|
||||||
// Set the look and feel before opening the window
|
// Set the look and feel before opening the window
|
||||||
try {
|
try {
|
||||||
platform.setLookAndFeel();
|
BaseNoGui.getPlatform().setLookAndFeel();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String mess = e.getMessage();
|
String mess = e.getMessage();
|
||||||
if (mess.indexOf("ch.randelshofer.quaqua.QuaquaLookAndFeel") == -1) {
|
if (mess.indexOf("ch.randelshofer.quaqua.QuaquaLookAndFeel") == -1) {
|
||||||
@ -241,21 +239,7 @@ public class Base {
|
|||||||
|
|
||||||
|
|
||||||
static protected void initPlatform() {
|
static protected void initPlatform() {
|
||||||
try {
|
BaseNoGui.initPlatform();
|
||||||
Class<?> platformClass = Class.forName("processing.app.Platform");
|
|
||||||
if (OSUtils.isMacOS()) {
|
|
||||||
platformClass = Class.forName("processing.app.macosx.Platform");
|
|
||||||
} else if (OSUtils.isWindows()) {
|
|
||||||
platformClass = Class.forName("processing.app.windows.Platform");
|
|
||||||
} else if (OSUtils.isLinux()) {
|
|
||||||
platformClass = Class.forName("processing.app.linux.Platform");
|
|
||||||
}
|
|
||||||
platform = (Platform) platformClass.newInstance();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Base.showError(_("Problem Setting the Platform"),
|
|
||||||
_("An unknown error occurred while trying to load\n" +
|
|
||||||
"platform-specific code for your machine."), e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -282,7 +266,7 @@ public class Base {
|
|||||||
protected static enum ACTION { GUI, NOOP, VERIFY, UPLOAD, GET_PREF };
|
protected static enum ACTION { GUI, NOOP, VERIFY, UPLOAD, GET_PREF };
|
||||||
|
|
||||||
public Base(String[] args) throws Exception {
|
public Base(String[] args) throws Exception {
|
||||||
platform.init(this);
|
BaseNoGui.getPlatform().init(this);
|
||||||
|
|
||||||
// Get the sketchbook path, and make sure it's set properly
|
// Get the sketchbook path, and make sure it's set properly
|
||||||
String sketchbookPath = Preferences.get("sketchbook.path");
|
String sketchbookPath = Preferences.get("sketchbook.path");
|
||||||
@ -1919,7 +1903,7 @@ public class Base {
|
|||||||
|
|
||||||
|
|
||||||
static public Platform getPlatform() {
|
static public Platform getPlatform() {
|
||||||
return platform;
|
return BaseNoGui.getPlatform();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1956,7 +1940,7 @@ public class Base {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
settingsFolder = platform.getSettingsFolder();
|
settingsFolder = BaseNoGui.getPlatform().getSettingsFolder();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
showError(_("Problem getting data folder"),
|
showError(_("Problem getting data folder"),
|
||||||
_("Error getting the Arduino data folder."), e);
|
_("Error getting the Arduino data folder."), e);
|
||||||
@ -2176,7 +2160,7 @@ public class Base {
|
|||||||
|
|
||||||
File sketchbookFolder = null;
|
File sketchbookFolder = null;
|
||||||
try {
|
try {
|
||||||
sketchbookFolder = platform.getDefaultSketchbookFolder();
|
sketchbookFolder = BaseNoGui.getPlatform().getDefaultSketchbookFolder();
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) { }
|
||||||
|
|
||||||
if (sketchbookFolder == null) {
|
if (sketchbookFolder == null) {
|
||||||
@ -2232,7 +2216,7 @@ public class Base {
|
|||||||
*/
|
*/
|
||||||
static public void openURL(String url) {
|
static public void openURL(String url) {
|
||||||
try {
|
try {
|
||||||
platform.openURL(url);
|
BaseNoGui.getPlatform().openURL(url);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
showWarning(_("Problem Opening URL"),
|
showWarning(_("Problem Opening URL"),
|
||||||
@ -2246,7 +2230,7 @@ public class Base {
|
|||||||
* @return true If a means of opening a folder is known to be available.
|
* @return true If a means of opening a folder is known to be available.
|
||||||
*/
|
*/
|
||||||
static protected boolean openFolderAvailable() {
|
static protected boolean openFolderAvailable() {
|
||||||
return platform.openFolderAvailable();
|
return BaseNoGui.getPlatform().openFolderAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2256,7 +2240,7 @@ public class Base {
|
|||||||
*/
|
*/
|
||||||
static public void openFolder(File file) {
|
static public void openFolder(File file) {
|
||||||
try {
|
try {
|
||||||
platform.openFolder(file);
|
BaseNoGui.getPlatform().openFolder(file);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
showWarning(_("Problem Opening Folder"),
|
showWarning(_("Problem Opening Folder"),
|
||||||
|
@ -27,6 +27,8 @@ public class BaseNoGui {
|
|||||||
|
|
||||||
static public Map<String, TargetPackage> packages;
|
static public Map<String, TargetPackage> packages;
|
||||||
|
|
||||||
|
static Platform platform;
|
||||||
|
|
||||||
static File portableFolder = null;
|
static File portableFolder = null;
|
||||||
|
|
||||||
// Returns a File object for the given pathname. If the pathname
|
// Returns a File object for the given pathname. If the pathname
|
||||||
@ -79,6 +81,10 @@ public class BaseNoGui {
|
|||||||
return getHardwareFolder().getAbsolutePath();
|
return getHardwareFolder().getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public Platform getPlatform() {
|
||||||
|
return platform;
|
||||||
|
}
|
||||||
|
|
||||||
static public File getPortableFolder() {
|
static public File getPortableFolder() {
|
||||||
return portableFolder;
|
return portableFolder;
|
||||||
}
|
}
|
||||||
@ -129,6 +135,24 @@ public class BaseNoGui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static protected void initPlatform() {
|
||||||
|
try {
|
||||||
|
Class<?> platformClass = Class.forName("processing.app.Platform");
|
||||||
|
if (OSUtils.isMacOS()) {
|
||||||
|
platformClass = Class.forName("processing.app.macosx.Platform");
|
||||||
|
} else if (OSUtils.isWindows()) {
|
||||||
|
platformClass = Class.forName("processing.app.windows.Platform");
|
||||||
|
} else if (OSUtils.isLinux()) {
|
||||||
|
platformClass = Class.forName("processing.app.linux.Platform");
|
||||||
|
}
|
||||||
|
platform = (Platform) platformClass.newInstance();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Base.showError(_("Problem Setting the Platform"),
|
||||||
|
_("An unknown error occurred while trying to load\n" +
|
||||||
|
"platform-specific code for your machine."), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static public void initPortableFolder() {
|
static public void initPortableFolder() {
|
||||||
// Portable folder
|
// Portable folder
|
||||||
portableFolder = getContentFile("portable");
|
portableFolder = getContentFile("portable");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user