fix up Java Mode for changes to Base

This commit is contained in:
Ben Fry
2015-08-13 20:09:11 -04:00
parent 8c2b7a3805
commit 8789cf763e
8 changed files with 47 additions and 44 deletions

View File

@@ -29,6 +29,7 @@ import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import processing.app.Base;
import processing.app.Platform;
import processing.app.Preferences;
import processing.app.RunnerListener;
import processing.app.Sketch;
@@ -77,7 +78,7 @@ public class Commander implements RunnerListener {
// Do this early so that error messages go to the console
Base.setCommandLine();
// init the platform so that prefs and other native code is ready to go
Base.initPlatform();
Platform.init();
// make sure a full JDK is installed
//Base.initRequirements();
@@ -145,7 +146,7 @@ public class Commander implements RunnerListener {
} else if (arg.startsWith(platformArg)) {
// complainAndQuit("The --platform option has been removed from Processing 2.1.", false);
String platformStr = arg.substring(platformArg.length());
platform = Base.getPlatformIndex(platformStr);
platform = Platform.getIndex(platformStr);
if (platform == -1) {
complainAndQuit(platformStr + " should instead be " +
"'windows', 'macosx', or 'linux'.", true);
@@ -249,7 +250,7 @@ public class Commander implements RunnerListener {
// JavaMode javaMode =
// new JavaMode(null, Base.getContentFile("modes/java"));
JavaMode javaMode = (JavaMode)
ModeContribution.load(null, Base.getContentFile("modes/java"),
ModeContribution.load(null, Platform.getContentFile("modes/java"),
"processing.mode.java.JavaMode").getMode();
try {
sketch = new Sketch(pdePath, javaMode);
@@ -280,8 +281,7 @@ public class Commander implements RunnerListener {
JavaBuild build = new JavaBuild(sketch);
build.build(true);
if (build != null) {
String variant = Base.getVariant();
String variant = Platform.getVariant();
success = build.exportApplication(outputFolder, platform, variant, embedJava);
}
}

View File

@@ -786,7 +786,7 @@ public class JavaBuild {
File folder = null;
for (String platformName : PConstants.platformNames) {
int platform = Base.getPlatformIndex(platformName);
int platform = Platform.getIndex(platformName);
// Can only embed Java on the native platform
boolean embedJava = (platform == PApplet.platform) &&
@@ -796,18 +796,18 @@ public class JavaBuild {
if (Library.hasMultipleArch(platform, importedLibraries)) {
// export the 32-bit version
folder = new File(sketch.getFolder(), "application." + platformName + "32");
if (!exportApplication(folder, platform, "32", embedJava && Base.getNativeBits() == 32 && "x86".equals(Base.getNativeArch()))) {
if (!exportApplication(folder, platform, "32", embedJava && Platform.getNativeBits() == 32 && "x86".equals(Platform.getNativeArch()))) {
return false;
}
// export the 64-bit version
folder = new File(sketch.getFolder(), "application." + platformName + "64");
if (!exportApplication(folder, platform, "64", embedJava && Base.getNativeBits() == 64 && "x86".equals(Base.getNativeArch()))) {
if (!exportApplication(folder, platform, "64", embedJava && Platform.getNativeBits() == 64 && "x86".equals(Platform.getNativeArch()))) {
return false;
}
if (platform == PConstants.LINUX) {
// export the armv6hf version as well
folder = new File(sketch.getFolder(), "application.linux-armv6hf");
if (!exportApplication(folder, platform, "armv6hf", embedJava && Base.getNativeBits() == 32 && "arm".equals(Base.getNativeArch()))) {
if (!exportApplication(folder, platform, "armv6hf", embedJava && Platform.getNativeBits() == 32 && "arm".equals(Platform.getNativeArch()))) {
return false;
}
}
@@ -891,10 +891,10 @@ public class JavaBuild {
if (exportPlatform == PConstants.MACOSX) {
dotAppFolder = new File(destFolder, sketch.getName() + ".app");
File contentsOrig = new File(Base.getJavaHome(), "../../../../..");
File contentsOrig = new File(Platform.getJavaHome(), "../../../../..");
if (embedJava) {
File jdkFolder = new File(Base.getJavaHome(), "../../..");
File jdkFolder = new File(Platform.getJavaHome(), "../../..");
String jdkFolderName = jdkFolder.getCanonicalFile().getName();
jvmRuntime = "<key>JVMRuntime</key>\n <string>" + jdkFolderName + "</string>";
jdkPath = new File(dotAppFolder, "Contents/PlugIns/" + jdkFolderName).getAbsolutePath();
@@ -958,12 +958,12 @@ public class JavaBuild {
*/
} else if (exportPlatform == PConstants.LINUX) {
if (embedJava) {
Util.copyDirNative(Base.getJavaHome(), new File(destFolder, "java"));
Util.copyDirNative(Platform.getJavaHome(), new File(destFolder, "java"));
}
} else if (exportPlatform == PConstants.WINDOWS) {
if (embedJava) {
Util.copyDir(Base.getJavaHome(), new File(destFolder, "java"));
Util.copyDir(Platform.getJavaHome(), new File(destFolder, "java"));
}
}
@@ -1183,7 +1183,7 @@ public class JavaBuild {
pw.close();
// attempt to code sign if the Xcode tools appear to be installed
if (Base.isMacOS() && new File("/usr/bin/codesign_allocate").exists()) {
if (Platform.isMacOS() && new File("/usr/bin/codesign_allocate").exists()) {
if (embedJava) {
ProcessHelper.ffs("codesign", "--force", "--sign", "-", jdkPath);
}
@@ -1297,7 +1297,7 @@ public class JavaBuild {
String shellPath = shellScript.getAbsolutePath();
// will work on osx or *nix, but just dies on windows, oh well..
if (!Base.isWindows()) {
if (!Platform.isWindows()) {
Runtime.getRuntime().exec(new String[] { "chmod", "+x", shellPath });
}
}
@@ -1439,7 +1439,7 @@ public class JavaBuild {
String[] dataFiles = Util.listFiles(sketch.getDataFolder(), false);
int offset = sketch.getFolder().getAbsolutePath().length() + 1;
for (String path : dataFiles) {
if (Base.isWindows()) {
if (Platform.isWindows()) {
path = path.replace('\\', '/');
}
//File dataFile = new File(dataFiles[i]);

View File

@@ -344,7 +344,7 @@ public class JavaEditor extends Editor {
JMenuItem item;
// macosx already has its own about menu
if (!Base.isMacOS()) {
if (!Platform.isMacOS()) {
item = new JMenuItem(Language.text("menu.help.about"));
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@@ -497,7 +497,7 @@ public class JavaEditor extends Editor {
item = new JMenuItem(Language.text("menu.help.getting_started"));
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Base.openURL(Language.text("menu.help.getting_started.url"));
Platform.openURL(Language.text("menu.help.getting_started.url"));
}
});
menu.add(item);
@@ -505,7 +505,7 @@ public class JavaEditor extends Editor {
item = new JMenuItem(Language.text("menu.help.troubleshooting"));
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Base.openURL(Language.text("menu.help.troubleshooting.url"));
Platform.openURL(Language.text("menu.help.troubleshooting.url"));
}
});
menu.add(item);
@@ -513,7 +513,7 @@ public class JavaEditor extends Editor {
item = new JMenuItem(Language.text("menu.help.faq"));
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Base.openURL(Language.text("menu.help.faq.url"));
Platform.openURL(Language.text("menu.help.faq.url"));
}
});
menu.add(item);
@@ -521,7 +521,7 @@ public class JavaEditor extends Editor {
item = new JMenuItem(Language.text("menu.help.foundation"));
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Base.openURL(Language.text("menu.help.foundation.url"));
Platform.openURL(Language.text("menu.help.foundation.url"));
}
});
menu.add(item);
@@ -529,7 +529,7 @@ public class JavaEditor extends Editor {
item = new JMenuItem(Language.text("menu.help.visit"));
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Base.openURL(Language.text("menu.help.visit.url"));
Platform.openURL(Language.text("menu.help.visit.url"));
}
});
menu.add(item);
@@ -664,7 +664,7 @@ public class JavaEditor extends Editor {
statusNotice(Language.text("export.notice.exporting"));
try {
if (exportApplicationPrompt()) {
Base.openFolder(sketch.getFolder());
Platform.openFolder(sketch.getFolder());
statusNotice(Language.text("export.notice.exporting.done"));
} else {
// error message will already be visible
@@ -738,7 +738,7 @@ public class JavaEditor extends Editor {
});
// Only possible to export OS X applications on OS X
if (!Base.isMacOS()) {
if (!Platform.isMacOS()) {
// Make sure they don't have a previous 'true' setting for this
Preferences.setBoolean(EXPORT_MACOSX, false);
}
@@ -749,7 +749,7 @@ public class JavaEditor extends Editor {
updateExportButton();
}
});
if (!Base.isMacOS()) {
if (!Platform.isMacOS()) {
macosxButton.setEnabled(false);
macosxButton.setToolTipText(Language.text("export.tooltip.macosx"));
}
@@ -866,12 +866,12 @@ public class JavaEditor extends Editor {
embedPanel.setLayout(new BoxLayout(embedPanel, BoxLayout.Y_AXIS));
String platformName = null;
if (Base.isMacOS()) {
if (Platform.isMacOS()) {
platformName = "Mac OS X";
} else if (Base.isWindows()) {
platformName = "Windows (" + Base.getNativeBits() + "-bit)";
} else if (Base.isLinux()) {
platformName = "Linux (" + Base.getNativeBits() + "-bit)";
} else if (Platform.isWindows()) {
platformName = "Windows (" + Platform.getNativeBits() + "-bit)";
} else if (Platform.isLinux()) {
platformName = "Linux (" + Platform.getNativeBits() + "-bit)";
}
boolean embed = Preferences.getBoolean("export.application.embed_java");
@@ -893,7 +893,7 @@ public class JavaEditor extends Editor {
final JLabel warningLabel = new JLabel(embed ? embedWarning : nopeWarning);
warningLabel.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
Base.openURL("http://java.com/download");
Platform.openURL("http://java.com/download");
}
});
warningLabel.setBorder(new EmptyBorder(3, 13 + indent, 3, 13));
@@ -921,7 +921,7 @@ public class JavaEditor extends Editor {
//
if (Base.isMacOS()) {
if (Platform.isMacOS()) {
JPanel signPanel = new JPanel();
signPanel.setLayout(new BoxLayout(signPanel, BoxLayout.Y_AXIS));
signPanel.setBorder(new TitledBorder(Language.text("export.code_signing")));
@@ -972,7 +972,7 @@ public class JavaEditor extends Editor {
area.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
Base.openURL("https://developer.apple.com/developer-id/");
Platform.openURL("https://developer.apple.com/developer-id/");
}
});

View File

@@ -107,7 +107,7 @@ public class JavaMode extends Mode {
public Library getCoreLibrary() {
if (coreLibrary == null) {
File coreFolder = Base.getContentFile("core");
File coreFolder = Platform.getContentFile("core");
coreLibrary = new Library(coreFolder);
// try {
// coreLibrary = getLibrary("processing.core");

View File

@@ -108,6 +108,7 @@ import org.jsoup.select.Elements;
import processing.app.Base;
import processing.app.Library;
import processing.app.Platform;
import processing.app.SketchCode;
import processing.app.Util;
import processing.app.syntax.JEditTextArea;
@@ -326,7 +327,7 @@ public class ASTGenerator {
classPath = factory.createFromPath(tehPath.toString());
log("Classpath created " + (classPath != null));
log("Sketch classpath jars loaded.");
if (Base.isMacOS()) {
if (Platform.isMacOS()) {
File f = new File(System.getProperty("java.home") + File.separator + "bundle"
+ File.separator + "Classes" + File.separator + "classes.jar");
log(f.getAbsolutePath() + " | classes.jar found?"

View File

@@ -37,6 +37,7 @@ import javax.swing.SwingWorker;
import processing.app.Base;
import processing.app.Mode;
import processing.app.Platform;
import processing.app.syntax.JEditTextArea;
import processing.app.syntax.PdeTextAreaDefaults;
import processing.app.syntax.TextAreaDefaults;
@@ -234,7 +235,7 @@ public class JavaTextArea extends JEditTextArea {
if (evt.getID() == KeyEvent.KEY_TYPED) {
processCompletionKeys(evt);
} else if (Base.isMacOS() && evt.getID() == KeyEvent.KEY_RELEASED) {
} else if (Platform.isMacOS() && evt.getID() == KeyEvent.KEY_RELEASED) {
processControlSpace(evt);
}
}
@@ -279,7 +280,7 @@ public class JavaTextArea extends JEditTextArea {
Base.log("Typing: " + fetchPhrase(event));
}
} else if (keyChar == ' ') { // Trigger on Ctrl-Space
if (!Base.isMacOS() && JavaMode.codeCompletionsEnabled &&
if (!Platform.isMacOS() && JavaMode.codeCompletionsEnabled &&
(event.isControlDown() || event.isMetaDown())) {
SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
protected Object doInBackground() throws Exception {

View File

@@ -48,6 +48,7 @@ import javax.swing.text.Segment;
import javax.swing.text.Utilities;
import processing.app.Base;
import processing.app.Platform;
import processing.app.SketchCode;
import processing.app.syntax.SyntaxDocument;
import processing.app.syntax.TextAreaDefaults;
@@ -102,7 +103,7 @@ public class JavaTextAreaPainter extends TextAreaPainter
public void mouseClicked(MouseEvent evt) {
if (!getEditor().hasJavaTabs()) { // Ctrl + Click disabled for java tabs
if (evt.getButton() == MouseEvent.BUTTON1) {
if ((evt.isControlDown() && !Base.isMacOS()) || evt.isMetaDown()) {
if ((evt.isControlDown() && !Platform.isMacOS()) || evt.isMetaDown()) {
handleCtrlClick(evt);
}
}

View File

@@ -89,14 +89,14 @@ public class Runner implements MessageConsumer {
}
// Make sure all the imported libraries will actually run with this setup.
int bits = Base.getNativeBits();
String variant = Base.getVariant();
int bits = Platform.getNativeBits();
String variant = Platform.getVariant();
for (Library library : build.getImportedLibraries()) {
if (!library.supportsArch(PApplet.platform, variant)) {
sketchErr.println(library.getName() + " does not run on this architecture: " + variant);
int opposite = (bits == 32) ? 64 : 32;
if (Base.isMacOS()) {
if (Platform.isMacOS()) {
//if (library.supportsArch(PConstants.MACOSX, opposite)) { // should always be true
throw new SketchException("To use " + library.getName() + ", " +
"switch to " + opposite + "-bit mode in Preferences.");
@@ -167,7 +167,7 @@ public class Runner implements MessageConsumer {
String jdwpArg = "-agentlib:jdwp=transport=dt_socket,address=" + portStr + ",server=y,suspend=y";
// Everyone works the same under Java 7 (also on OS X)
String[] commandArgs = new String[] { Base.getJavaPath(), jdwpArg };
String[] commandArgs = new String[] { Platform.getJavaPath(), jdwpArg };
commandArgs = PApplet.concat(commandArgs, vmParams);
commandArgs = PApplet.concat(commandArgs, sketchParams);
@@ -256,7 +256,7 @@ public class Runner implements MessageConsumer {
params.add("-Xmx" + Preferences.get("run.options.memory.maximum") + "m");
}
if (Base.isMacOS()) {
if (Platform.isMacOS()) {
params.add("-Xdock:name=" + build.getSketchClassName());
// params.add("-Dcom.apple.mrj.application.apple.menu.about.name=" +
// sketch.getMainClassName());
@@ -670,7 +670,7 @@ public class Runner implements MessageConsumer {
listener.statusError("A library used by this sketch is not installed properly.");
err.println("A library relies on native code that's not available.");
err.println("Or only works properly when the sketch is run as a " +
((Base.getNativeBits() == 32) ? "64-bit" : "32-bit") + " application.");
((Platform.getNativeBits() == 32) ? "64-bit" : "32-bit") + " application.");
} else if (exceptionClass.equals("java.lang.StackOverflowError")) {
listener.statusError("StackOverflowError: This sketch is attempting too much recursion.");