Skip to content

Commit 04fc4d8

Browse files
committed
fix up Java Mode for changes to Base
1 parent d270d75 commit 04fc4d8

File tree

8 files changed

+47
-44
lines changed

8 files changed

+47
-44
lines changed

java/src/processing/mode/java/Commander.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.io.UnsupportedEncodingException;
3030

3131
import processing.app.Base;
32+
import processing.app.Platform;
3233
import processing.app.Preferences;
3334
import processing.app.RunnerListener;
3435
import processing.app.Sketch;
@@ -77,7 +78,7 @@ static public void main(String[] args) {
7778
// Do this early so that error messages go to the console
7879
Base.setCommandLine();
7980
// init the platform so that prefs and other native code is ready to go
80-
Base.initPlatform();
81+
Platform.init();
8182
// make sure a full JDK is installed
8283
//Base.initRequirements();
8384

@@ -145,7 +146,7 @@ public Commander(String[] args) {
145146
} else if (arg.startsWith(platformArg)) {
146147
// complainAndQuit("The --platform option has been removed from Processing 2.1.", false);
147148
String platformStr = arg.substring(platformArg.length());
148-
platform = Base.getPlatformIndex(platformStr);
149+
platform = Platform.getIndex(platformStr);
149150
if (platform == -1) {
150151
complainAndQuit(platformStr + " should instead be " +
151152
"'windows', 'macosx', or 'linux'.", true);
@@ -249,7 +250,7 @@ public Commander(String[] args) {
249250
// JavaMode javaMode =
250251
// new JavaMode(null, Base.getContentFile("modes/java"));
251252
JavaMode javaMode = (JavaMode)
252-
ModeContribution.load(null, Base.getContentFile("modes/java"),
253+
ModeContribution.load(null, Platform.getContentFile("modes/java"),
253254
"processing.mode.java.JavaMode").getMode();
254255
try {
255256
sketch = new Sketch(pdePath, javaMode);
@@ -280,8 +281,7 @@ public Commander(String[] args) {
280281
JavaBuild build = new JavaBuild(sketch);
281282
build.build(true);
282283
if (build != null) {
283-
284-
String variant = Base.getVariant();
284+
String variant = Platform.getVariant();
285285
success = build.exportApplication(outputFolder, platform, variant, embedJava);
286286
}
287287
}

java/src/processing/mode/java/JavaBuild.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ protected boolean exportApplication() throws IOException, SketchException {
786786

787787
File folder = null;
788788
for (String platformName : PConstants.platformNames) {
789-
int platform = Base.getPlatformIndex(platformName);
789+
int platform = Platform.getIndex(platformName);
790790

791791
// Can only embed Java on the native platform
792792
boolean embedJava = (platform == PApplet.platform) &&
@@ -796,18 +796,18 @@ protected boolean exportApplication() throws IOException, SketchException {
796796
if (Library.hasMultipleArch(platform, importedLibraries)) {
797797
// export the 32-bit version
798798
folder = new File(sketch.getFolder(), "application." + platformName + "32");
799-
if (!exportApplication(folder, platform, "32", embedJava && Base.getNativeBits() == 32 && "x86".equals(Base.getNativeArch()))) {
799+
if (!exportApplication(folder, platform, "32", embedJava && Platform.getNativeBits() == 32 && "x86".equals(Platform.getNativeArch()))) {
800800
return false;
801801
}
802802
// export the 64-bit version
803803
folder = new File(sketch.getFolder(), "application." + platformName + "64");
804-
if (!exportApplication(folder, platform, "64", embedJava && Base.getNativeBits() == 64 && "x86".equals(Base.getNativeArch()))) {
804+
if (!exportApplication(folder, platform, "64", embedJava && Platform.getNativeBits() == 64 && "x86".equals(Platform.getNativeArch()))) {
805805
return false;
806806
}
807807
if (platform == PConstants.LINUX) {
808808
// export the armv6hf version as well
809809
folder = new File(sketch.getFolder(), "application.linux-armv6hf");
810-
if (!exportApplication(folder, platform, "armv6hf", embedJava && Base.getNativeBits() == 32 && "arm".equals(Base.getNativeArch()))) {
810+
if (!exportApplication(folder, platform, "armv6hf", embedJava && Platform.getNativeBits() == 32 && "arm".equals(Platform.getNativeArch()))) {
811811
return false;
812812
}
813813
}
@@ -891,10 +891,10 @@ protected boolean exportApplication(File destFolder,
891891
if (exportPlatform == PConstants.MACOSX) {
892892
dotAppFolder = new File(destFolder, sketch.getName() + ".app");
893893

894-
File contentsOrig = new File(Base.getJavaHome(), "../../../../..");
894+
File contentsOrig = new File(Platform.getJavaHome(), "../../../../..");
895895

896896
if (embedJava) {
897-
File jdkFolder = new File(Base.getJavaHome(), "../../..");
897+
File jdkFolder = new File(Platform.getJavaHome(), "../../..");
898898
String jdkFolderName = jdkFolder.getCanonicalFile().getName();
899899
jvmRuntime = "<key>JVMRuntime</key>\n <string>" + jdkFolderName + "</string>";
900900
jdkPath = new File(dotAppFolder, "Contents/PlugIns/" + jdkFolderName).getAbsolutePath();
@@ -958,12 +958,12 @@ protected boolean exportApplication(File destFolder,
958958
*/
959959
} else if (exportPlatform == PConstants.LINUX) {
960960
if (embedJava) {
961-
Util.copyDirNative(Base.getJavaHome(), new File(destFolder, "java"));
961+
Util.copyDirNative(Platform.getJavaHome(), new File(destFolder, "java"));
962962
}
963963

964964
} else if (exportPlatform == PConstants.WINDOWS) {
965965
if (embedJava) {
966-
Util.copyDir(Base.getJavaHome(), new File(destFolder, "java"));
966+
Util.copyDir(Platform.getJavaHome(), new File(destFolder, "java"));
967967
}
968968
}
969969

@@ -1183,7 +1183,7 @@ protected boolean exportApplication(File destFolder,
11831183
pw.close();
11841184

11851185
// attempt to code sign if the Xcode tools appear to be installed
1186-
if (Base.isMacOS() && new File("/usr/bin/codesign_allocate").exists()) {
1186+
if (Platform.isMacOS() && new File("/usr/bin/codesign_allocate").exists()) {
11871187
if (embedJava) {
11881188
ProcessHelper.ffs("codesign", "--force", "--sign", "-", jdkPath);
11891189
}
@@ -1297,7 +1297,7 @@ protected boolean exportApplication(File destFolder,
12971297

12981298
String shellPath = shellScript.getAbsolutePath();
12991299
// will work on osx or *nix, but just dies on windows, oh well..
1300-
if (!Base.isWindows()) {
1300+
if (!Platform.isWindows()) {
13011301
Runtime.getRuntime().exec(new String[] { "chmod", "+x", shellPath });
13021302
}
13031303
}
@@ -1439,7 +1439,7 @@ protected void addDataFolder(ZipOutputStream zos) throws IOException {
14391439
String[] dataFiles = Util.listFiles(sketch.getDataFolder(), false);
14401440
int offset = sketch.getFolder().getAbsolutePath().length() + 1;
14411441
for (String path : dataFiles) {
1442-
if (Base.isWindows()) {
1442+
if (Platform.isWindows()) {
14431443
path = path.replace('\\', '/');
14441444
}
14451445
//File dataFile = new File(dataFiles[i]);

java/src/processing/mode/java/JavaEditor.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ public JMenu buildHelpMenu() {
344344
JMenuItem item;
345345

346346
// macosx already has its own about menu
347-
if (!Base.isMacOS()) {
347+
if (!Platform.isMacOS()) {
348348
item = new JMenuItem(Language.text("menu.help.about"));
349349
item.addActionListener(new ActionListener() {
350350
public void actionPerformed(ActionEvent e) {
@@ -497,39 +497,39 @@ public void menuCanceled(MenuEvent e) {
497497
item = new JMenuItem(Language.text("menu.help.getting_started"));
498498
item.addActionListener(new ActionListener() {
499499
public void actionPerformed(ActionEvent e) {
500-
Base.openURL(Language.text("menu.help.getting_started.url"));
500+
Platform.openURL(Language.text("menu.help.getting_started.url"));
501501
}
502502
});
503503
menu.add(item);
504504

505505
item = new JMenuItem(Language.text("menu.help.troubleshooting"));
506506
item.addActionListener(new ActionListener() {
507507
public void actionPerformed(ActionEvent e) {
508-
Base.openURL(Language.text("menu.help.troubleshooting.url"));
508+
Platform.openURL(Language.text("menu.help.troubleshooting.url"));
509509
}
510510
});
511511
menu.add(item);
512512

513513
item = new JMenuItem(Language.text("menu.help.faq"));
514514
item.addActionListener(new ActionListener() {
515515
public void actionPerformed(ActionEvent e) {
516-
Base.openURL(Language.text("menu.help.faq.url"));
516+
Platform.openURL(Language.text("menu.help.faq.url"));
517517
}
518518
});
519519
menu.add(item);
520520

521521
item = new JMenuItem(Language.text("menu.help.foundation"));
522522
item.addActionListener(new ActionListener() {
523523
public void actionPerformed(ActionEvent e) {
524-
Base.openURL(Language.text("menu.help.foundation.url"));
524+
Platform.openURL(Language.text("menu.help.foundation.url"));
525525
}
526526
});
527527
menu.add(item);
528528

529529
item = new JMenuItem(Language.text("menu.help.visit"));
530530
item.addActionListener(new ActionListener() {
531531
public void actionPerformed(ActionEvent e) {
532-
Base.openURL(Language.text("menu.help.visit.url"));
532+
Platform.openURL(Language.text("menu.help.visit.url"));
533533
}
534534
});
535535
menu.add(item);
@@ -664,7 +664,7 @@ public void handleExportApplication() {
664664
statusNotice(Language.text("export.notice.exporting"));
665665
try {
666666
if (exportApplicationPrompt()) {
667-
Base.openFolder(sketch.getFolder());
667+
Platform.openFolder(sketch.getFolder());
668668
statusNotice(Language.text("export.notice.exporting.done"));
669669
} else {
670670
// error message will already be visible
@@ -738,7 +738,7 @@ public void itemStateChanged(ItemEvent e) {
738738
});
739739

740740
// Only possible to export OS X applications on OS X
741-
if (!Base.isMacOS()) {
741+
if (!Platform.isMacOS()) {
742742
// Make sure they don't have a previous 'true' setting for this
743743
Preferences.setBoolean(EXPORT_MACOSX, false);
744744
}
@@ -749,7 +749,7 @@ public void itemStateChanged(ItemEvent e) {
749749
updateExportButton();
750750
}
751751
});
752-
if (!Base.isMacOS()) {
752+
if (!Platform.isMacOS()) {
753753
macosxButton.setEnabled(false);
754754
macosxButton.setToolTipText(Language.text("export.tooltip.macosx"));
755755
}
@@ -866,12 +866,12 @@ public void paintComponent(Graphics g) {
866866
embedPanel.setLayout(new BoxLayout(embedPanel, BoxLayout.Y_AXIS));
867867

868868
String platformName = null;
869-
if (Base.isMacOS()) {
869+
if (Platform.isMacOS()) {
870870
platformName = "Mac OS X";
871-
} else if (Base.isWindows()) {
872-
platformName = "Windows (" + Base.getNativeBits() + "-bit)";
873-
} else if (Base.isLinux()) {
874-
platformName = "Linux (" + Base.getNativeBits() + "-bit)";
871+
} else if (Platform.isWindows()) {
872+
platformName = "Windows (" + Platform.getNativeBits() + "-bit)";
873+
} else if (Platform.isLinux()) {
874+
platformName = "Linux (" + Platform.getNativeBits() + "-bit)";
875875
}
876876

877877
boolean embed = Preferences.getBoolean("export.application.embed_java");
@@ -893,7 +893,7 @@ public void paintComponent(Graphics g) {
893893
final JLabel warningLabel = new JLabel(embed ? embedWarning : nopeWarning);
894894
warningLabel.addMouseListener(new MouseAdapter() {
895895
public void mousePressed(MouseEvent event) {
896-
Base.openURL("http://java.com/download");
896+
Platform.openURL("http://java.com/download");
897897
}
898898
});
899899
warningLabel.setBorder(new EmptyBorder(3, 13 + indent, 3, 13));
@@ -921,7 +921,7 @@ public void itemStateChanged(ItemEvent e) {
921921

922922
//
923923

924-
if (Base.isMacOS()) {
924+
if (Platform.isMacOS()) {
925925
JPanel signPanel = new JPanel();
926926
signPanel.setLayout(new BoxLayout(signPanel, BoxLayout.Y_AXIS));
927927
signPanel.setBorder(new TitledBorder(Language.text("export.code_signing")));
@@ -972,7 +972,7 @@ public void itemStateChanged(ItemEvent e) {
972972

973973
area.addMouseListener(new MouseAdapter() {
974974
public void mousePressed(MouseEvent event) {
975-
Base.openURL("https://developer.apple.com/developer-id/");
975+
Platform.openURL("https://developer.apple.com/developer-id/");
976976
}
977977
});
978978

java/src/processing/mode/java/JavaMode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public String[] getIgnorable() {
107107

108108
public Library getCoreLibrary() {
109109
if (coreLibrary == null) {
110-
File coreFolder = Base.getContentFile("core");
110+
File coreFolder = Platform.getContentFile("core");
111111
coreLibrary = new Library(coreFolder);
112112
// try {
113113
// coreLibrary = getLibrary("processing.core");

java/src/processing/mode/java/pdex/ASTGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108

109109
import processing.app.Base;
110110
import processing.app.Library;
111+
import processing.app.Platform;
111112
import processing.app.SketchCode;
112113
import processing.app.Util;
113114
import processing.app.syntax.JEditTextArea;
@@ -326,7 +327,7 @@ protected void loadJars() {
326327
classPath = factory.createFromPath(tehPath.toString());
327328
log("Classpath created " + (classPath != null));
328329
log("Sketch classpath jars loaded.");
329-
if (Base.isMacOS()) {
330+
if (Platform.isMacOS()) {
330331
File f = new File(System.getProperty("java.home") + File.separator + "bundle"
331332
+ File.separator + "Classes" + File.separator + "classes.jar");
332333
log(f.getAbsolutePath() + " | classes.jar found?"

java/src/processing/mode/java/pdex/JavaTextArea.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
import processing.app.Base;
3939
import processing.app.Mode;
40+
import processing.app.Platform;
4041
import processing.app.syntax.JEditTextArea;
4142
import processing.app.syntax.PdeTextAreaDefaults;
4243
import processing.app.syntax.TextAreaDefaults;
@@ -234,7 +235,7 @@ public void processKeyEvent(KeyEvent evt) {
234235
if (evt.getID() == KeyEvent.KEY_TYPED) {
235236
processCompletionKeys(evt);
236237

237-
} else if (Base.isMacOS() && evt.getID() == KeyEvent.KEY_RELEASED) {
238+
} else if (Platform.isMacOS() && evt.getID() == KeyEvent.KEY_RELEASED) {
238239
processControlSpace(evt);
239240
}
240241
}
@@ -279,7 +280,7 @@ private void processCompletionKeys(final KeyEvent event) {
279280
Base.log("Typing: " + fetchPhrase(event));
280281
}
281282
} else if (keyChar == ' ') { // Trigger on Ctrl-Space
282-
if (!Base.isMacOS() && JavaMode.codeCompletionsEnabled &&
283+
if (!Platform.isMacOS() && JavaMode.codeCompletionsEnabled &&
283284
(event.isControlDown() || event.isMetaDown())) {
284285
SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
285286
protected Object doInBackground() throws Exception {

java/src/processing/mode/java/pdex/JavaTextAreaPainter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import javax.swing.text.Utilities;
4949

5050
import processing.app.Base;
51+
import processing.app.Platform;
5152
import processing.app.SketchCode;
5253
import processing.app.syntax.SyntaxDocument;
5354
import processing.app.syntax.TextAreaDefaults;
@@ -102,7 +103,7 @@ public JavaTextAreaPainter(JavaTextArea textArea, TextAreaDefaults defaults) {
102103
public void mouseClicked(MouseEvent evt) {
103104
if (!getEditor().hasJavaTabs()) { // Ctrl + Click disabled for java tabs
104105
if (evt.getButton() == MouseEvent.BUTTON1) {
105-
if ((evt.isControlDown() && !Base.isMacOS()) || evt.isMetaDown()) {
106+
if ((evt.isControlDown() && !Platform.isMacOS()) || evt.isMetaDown()) {
106107
handleCtrlClick(evt);
107108
}
108109
}

java/src/processing/mode/java/runner/Runner.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ public Runner(JavaBuild build, RunnerListener listener) throws SketchException {
8989
}
9090

9191
// Make sure all the imported libraries will actually run with this setup.
92-
int bits = Base.getNativeBits();
93-
String variant = Base.getVariant();
92+
int bits = Platform.getNativeBits();
93+
String variant = Platform.getVariant();
9494

9595
for (Library library : build.getImportedLibraries()) {
9696
if (!library.supportsArch(PApplet.platform, variant)) {
9797
sketchErr.println(library.getName() + " does not run on this architecture: " + variant);
9898
int opposite = (bits == 32) ? 64 : 32;
99-
if (Base.isMacOS()) {
99+
if (Platform.isMacOS()) {
100100
//if (library.supportsArch(PConstants.MACOSX, opposite)) { // should always be true
101101
throw new SketchException("To use " + library.getName() + ", " +
102102
"switch to " + opposite + "-bit mode in Preferences.");
@@ -167,7 +167,7 @@ public boolean launchVirtualMachine(boolean presenting) {
167167
String jdwpArg = "-agentlib:jdwp=transport=dt_socket,address=" + portStr + ",server=y,suspend=y";
168168

169169
// Everyone works the same under Java 7 (also on OS X)
170-
String[] commandArgs = new String[] { Base.getJavaPath(), jdwpArg };
170+
String[] commandArgs = new String[] { Platform.getJavaPath(), jdwpArg };
171171

172172
commandArgs = PApplet.concat(commandArgs, vmParams);
173173
commandArgs = PApplet.concat(commandArgs, sketchParams);
@@ -256,7 +256,7 @@ protected String[] getMachineParams() {
256256
params.add("-Xmx" + Preferences.get("run.options.memory.maximum") + "m");
257257
}
258258

259-
if (Base.isMacOS()) {
259+
if (Platform.isMacOS()) {
260260
params.add("-Xdock:name=" + build.getSketchClassName());
261261
// params.add("-Dcom.apple.mrj.application.apple.menu.about.name=" +
262262
// sketch.getMainClassName());
@@ -670,7 +670,7 @@ public static boolean handleCommonErrors(final String exceptionClass,
670670
listener.statusError("A library used by this sketch is not installed properly.");
671671
err.println("A library relies on native code that's not available.");
672672
err.println("Or only works properly when the sketch is run as a " +
673-
((Base.getNativeBits() == 32) ? "64-bit" : "32-bit") + " application.");
673+
((Platform.getNativeBits() == 32) ? "64-bit" : "32-bit") + " application.");
674674

675675
} else if (exceptionClass.equals("java.lang.StackOverflowError")) {
676676
listener.statusError("StackOverflowError: This sketch is attempting too much recursion.");

0 commit comments

Comments
 (0)