42
42
import processing .app .debug .TargetPlatform ;
43
43
import processing .app .debug .TargetPlatformException ;
44
44
import processing .app .helpers .FileUtils ;
45
+ import processing .app .helpers .OSUtils ;
45
46
import processing .app .helpers .PreferencesMap ;
46
47
import processing .app .helpers .filefilters .OnlyDirs ;
47
48
import processing .app .helpers .filefilters .OnlyFilesWithExtension ;
48
49
import processing .app .javax .swing .filechooser .FileNameExtensionFilter ;
49
50
import processing .app .legacy .PApplet ;
50
- import processing .app .legacy .PConstants ;
51
51
import processing .app .packages .Library ;
52
52
import processing .app .packages .LibraryList ;
53
53
import processing .app .tools .MenuScroller ;
@@ -68,19 +68,6 @@ public class Base {
68
68
/** Set true if this a proper release rather than a numbered revision. */
69
69
static public boolean RELEASE = false ;
70
70
71
- static Map <Integer , String > platformNames = new HashMap <Integer , String >();
72
- static {
73
- platformNames .put (PConstants .WINDOWS , "windows" );
74
- platformNames .put (PConstants .MACOSX , "macosx" );
75
- platformNames .put (PConstants .LINUX , "linux" );
76
- }
77
-
78
- static HashMap <String , Integer > platformIndices = new HashMap <String , Integer >();
79
- static {
80
- platformIndices .put ("windows" , PConstants .WINDOWS );
81
- platformIndices .put ("macosx" , PConstants .MACOSX );
82
- platformIndices .put ("linux" , PConstants .LINUX );
83
- }
84
71
static Platform platform ;
85
72
86
73
private static DiscoveryManager discoveryManager = new DiscoveryManager ();
@@ -263,11 +250,11 @@ static protected boolean isCommandLine() {
263
250
static protected void initPlatform () {
264
251
try {
265
252
Class <?> platformClass = Class .forName ("processing.app.Platform" );
266
- if (Base .isMacOS ()) {
253
+ if (OSUtils .isMacOS ()) {
267
254
platformClass = Class .forName ("processing.app.macosx.Platform" );
268
- } else if (Base .isWindows ()) {
255
+ } else if (OSUtils .isWindows ()) {
269
256
platformClass = Class .forName ("processing.app.windows.Platform" );
270
- } else if (Base .isLinux ()) {
257
+ } else if (OSUtils .isLinux ()) {
271
258
platformClass = Class .forName ("processing.app.linux.Platform" );
272
259
}
273
260
platform = (Platform ) platformClass .newInstance ();
@@ -473,7 +460,7 @@ public Base(String[] args) throws Exception {
473
460
// being passed in with 8.3 syntax, which makes the sketch loader code
474
461
// unhappy, since the sketch folder naming doesn't match up correctly.
475
462
// http://dev.processing.org/bugs/show_bug.cgi?id=1089
476
- if (isWindows ()) {
463
+ if (OSUtils . isWindows ()) {
477
464
try {
478
465
file = file .getCanonicalFile ();
479
466
} catch (IOException e ) {
@@ -1087,7 +1074,7 @@ public boolean handleClose(Editor editor) {
1087
1074
// untitled sketch, just give up and let the user quit.
1088
1075
// if (Preferences.getBoolean("sketchbook.closing_last_window_quits") ||
1089
1076
// (editor.untitled && !editor.getSketch().isModified())) {
1090
- if (Base .isMacOS ()) {
1077
+ if (OSUtils .isMacOS ()) {
1091
1078
Object [] options = { "OK" , "Cancel" };
1092
1079
String prompt =
1093
1080
_ ("<html> " +
@@ -1170,7 +1157,7 @@ public boolean handleQuit() {
1170
1157
// Save out the current prefs state
1171
1158
Preferences .save ();
1172
1159
1173
- if (!Base .isMacOS ()) {
1160
+ if (!OSUtils .isMacOS ()) {
1174
1161
// If this was fired from the menu or an AppleEvent (the Finder),
1175
1162
// then Mac OS X will send the terminate signal itself.
1176
1163
System .exit (0 );
@@ -1996,54 +1983,6 @@ static public String getPlatformName() {
1996
1983
}
1997
1984
1998
1985
1999
- /**
2000
- * Map a platform constant to its name.
2001
- * @param which PConstants.WINDOWS, PConstants.MACOSX, PConstants.LINUX
2002
- * @return one of "windows", "macosx", or "linux"
2003
- */
2004
- static public String getPlatformName (int which ) {
2005
- return platformNames .get (which );
2006
- }
2007
-
2008
-
2009
- static public int getPlatformIndex (String what ) {
2010
- Integer entry = platformIndices .get (what );
2011
- return (entry == null ) ? -1 : entry .intValue ();
2012
- }
2013
-
2014
-
2015
- // These were changed to no longer rely on PApplet and PConstants because
2016
- // of conflicts that could happen with older versions of core.jar, where
2017
- // the MACOSX constant would instead read as the LINUX constant.
2018
-
2019
-
2020
- /**
2021
- * returns true if Processing is running on a Mac OS X machine.
2022
- */
2023
- static public boolean isMacOS () {
2024
- //return PApplet.platform == PConstants.MACOSX;
2025
- return System .getProperty ("os.name" ).indexOf ("Mac" ) != -1 ;
2026
- }
2027
-
2028
-
2029
- /**
2030
- * returns true if running on windows.
2031
- */
2032
- static public boolean isWindows () {
2033
- //return PApplet.platform == PConstants.WINDOWS;
2034
- return System .getProperty ("os.name" ).indexOf ("Windows" ) != -1 ;
2035
- }
2036
-
2037
-
2038
- /**
2039
- * true if running on linux.
2040
- */
2041
- static public boolean isLinux () {
2042
- //return PApplet.platform == PConstants.LINUX;
2043
- return System .getProperty ("os.name" ).indexOf ("Linux" ) != -1 ;
2044
- }
2045
-
2046
-
2047
1986
// .................................................................
2048
1987
2049
1988
@@ -2176,7 +2115,7 @@ static public String getHardwarePath() {
2176
2115
static public String getAvrBasePath () {
2177
2116
String path = getHardwarePath () + File .separator + "tools" +
2178
2117
File .separator + "avr" + File .separator + "bin" + File .separator ;
2179
- if (Base .isLinux () && !(new File (path )).exists ()) {
2118
+ if (OSUtils .isLinux () && !(new File (path )).exists ()) {
2180
2119
return "" ; // use distribution provided avr tools if bundled tools missing
2181
2120
}
2182
2121
return path ;
@@ -2411,7 +2350,7 @@ static public File selectFolder(String prompt, File folder, Frame frame) {
2411
2350
static public void setIcon (Frame frame ) {
2412
2351
// don't use the low-res icon on Mac OS X; the window should
2413
2352
// already have the right icon from the .app file.
2414
- if (Base .isMacOS ()) return ;
2353
+ if (OSUtils .isMacOS ()) return ;
2415
2354
2416
2355
Image image = Toolkit .getDefaultToolkit ().createImage (PApplet .ICON_IMAGE );
2417
2356
frame .setIconImage (image );
@@ -2464,9 +2403,9 @@ static public void showReference(String filename) {
2464
2403
}
2465
2404
2466
2405
static public void showGettingStarted () {
2467
- if (Base .isMacOS ()) {
2406
+ if (OSUtils .isMacOS ()) {
2468
2407
Base .showReference (_ ("Guide_MacOSX.html" ));
2469
- } else if (Base .isWindows ()) {
2408
+ } else if (OSUtils .isWindows ()) {
2470
2409
Base .showReference (_ ("Guide_Windows.html" ));
2471
2410
} else {
2472
2411
Base .openURL (_ ("http://www.arduino.cc/playground/Learning/Linux" ));
@@ -2570,7 +2509,7 @@ static public void showError(String title, String message, Throwable e, int exit
2570
2509
// incomplete
2571
2510
static public int showYesNoCancelQuestion (Editor editor , String title ,
2572
2511
String primary , String secondary ) {
2573
- if (!Base .isMacOS ()) {
2512
+ if (!OSUtils .isMacOS ()) {
2574
2513
int result =
2575
2514
JOptionPane .showConfirmDialog (null , primary + "\n " + secondary , title ,
2576
2515
JOptionPane .YES_NO_CANCEL_OPTION ,
@@ -2646,7 +2585,7 @@ static public int showYesNoCancelQuestion(Editor editor, String title,
2646
2585
2647
2586
static public int showYesNoQuestion (Frame editor , String title ,
2648
2587
String primary , String secondary ) {
2649
- if (!Base .isMacOS ()) {
2588
+ if (!OSUtils .isMacOS ()) {
2650
2589
return JOptionPane .showConfirmDialog (editor ,
2651
2590
"<html><body>" +
2652
2591
"<b>" + primary + "</b>" +
@@ -2730,7 +2669,7 @@ static public File getContentFile(String name) {
2730
2669
String path = System .getProperty ("user.dir" );
2731
2670
2732
2671
// Get a path to somewhere inside the .app folder
2733
- if (Base .isMacOS ()) {
2672
+ if (OSUtils .isMacOS ()) {
2734
2673
// <key>javaroot</key>
2735
2674
// <string>$JAVAROOT</string>
2736
2675
String javaroot = System .getProperty ("javaroot" );
0 commit comments