Skip to content

Commit

Permalink
Merge branch 'java11' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
sampottinger committed Jan 18, 2019
2 parents 8a48178 + f68fd9e commit 46d25b9
Show file tree
Hide file tree
Showing 61 changed files with 3,938 additions and 975 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
.AppleDouble
*.iml
._*
*~
/build/shared/reference.zip
Expand Down
25 changes: 11 additions & 14 deletions app/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
<fail unless="core-built" message="Please build the core library first and make sure it is located at ../core/library/core.jar" />

<mkdir dir="bin" />

<!-- copy languages files -->
<copy todir="bin">
<fileset dir="src">
<include name="processing/app/languages/*.properties" />
</fileset>
</copy>

<!-- in some cases, pde.jar was not getting built
https://github.com/processing/processing/issues/1792 -->
<delete file="pde.jar" />
Expand All @@ -30,22 +30,19 @@

<javac source="1.8"
target="1.8"
destdir="bin"
excludes="**/tools/format/**"
encoding="UTF-8"
includeAntRuntime="false"
classpath="../core/library/core.jar;
../core/apple.jar;
lib/ant.jar;
lib/ant-launcher.jar;
destdir="bin"
excludes="**/tools/format/**"
encoding="UTF-8"
includeAntRuntime="false"
classpath="../core/library/core.jar;
../core/apple.jar;
lib/ant.jar;
lib/ant-launcher.jar;
lib/jna.jar;
lib/jna-platform.jar"
debug="on"
nowarn="true"
compiler="org.eclipse.jdt.core.JDTCompilerAdapter">
nowarn="true">
<src path="src" />
<compilerclasspath path="../java/mode/org.eclipse.jdt.core.jar;
../java/mode/jdtCompilerAdapter.jar" />
</javac>
</target>

Expand Down
4 changes: 2 additions & 2 deletions app/src/processing/app/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public boolean accept(File dir, String name) {
name.endsWith(".jdk") && !name.startsWith(".");
}
});
return new File(plugins[0], "Contents/Home/jre");
return new File(plugins[0], "Contents/Home");
}
// On all other platforms, it's the 'java' folder adjacent to Processing
return getContentFile("java");
Expand Down Expand Up @@ -412,4 +412,4 @@ static public int unsetenv(String variable) {
static public int getSystemDPI() {
return inst.getSystemDPI();
}
}
}
111 changes: 75 additions & 36 deletions app/src/processing/app/platform/ThinkDifferent.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@

import java.awt.event.*;
import java.io.File;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.List;

import javax.swing.*;

import com.apple.eawt.*;
import com.apple.eawt.AppEvent.*;
import com.apple.eawt.Application;

import processing.app.*;
import processing.app.ui.About;
Expand Down Expand Up @@ -65,44 +69,40 @@ static protected void init(final Base base) {
if (adapter == null) {
adapter = new ThinkDifferent(); //base);
}

application.setAboutHandler(new AboutHandler() {
public void handleAbout(AboutEvent ae) {
new About(null);
}

setHandler(application, "setAboutHandler", (proxy, method, args) -> {
new About(null);
return null;
});

application.setPreferencesHandler(new PreferencesHandler() {
public void handlePreferences(PreferencesEvent arg0) {
base.handlePrefs();
}

setHandler(application, "setPreferencesHandler", (proxy, method, args) -> {
base.handlePrefs();
return null;
});

application.setOpenFileHandler(new OpenFilesHandler() {
public void openFiles(OpenFilesEvent event) {
for (File file : event.getFiles()) {
base.handleOpen(file.getAbsolutePath());
}
setHandler(application, "setOpenFileHandler", (proxy, method, args) -> {
Method m = args[0].getClass().getMethod("getFiles");
for (File file : (List<File>) m.invoke(args[0])) {
base.handleOpen(file.getAbsolutePath());
}
return null;
});

application.setPrintFileHandler(new PrintFilesHandler() {
public void printFiles(PrintFilesEvent event) {
// TODO not yet implemented
}

setHandler(application, "setPrintFileHandler", (proxy, method, args) -> {
// TODO not yet implemented
return null;
});

application.setQuitHandler(new QuitHandler() {
public void handleQuitRequestWith(QuitEvent event, QuitResponse response) {
if (base.handleQuit()) {
response.performQuit();
} else {
response.cancelQuit();
}

setHandler(application, "setQuitHandler", (proxy, method, args) -> {
if (base.handleQuit()) {
args[1].getClass().getMethod("performQuit").invoke(args[1]);
} else {
args[1].getClass().getMethod("cancelQuit").invoke(args[1]);
}
return null;
});

// Set the menubar to be used when nothing else is open.
// Set the menubar to be used when nothing else is open.
JMenuBar defaultMenuBar = new JMenuBar();
JMenu fileMenu = buildFileMenu(base);
defaultMenuBar.add(fileMenu);
Expand All @@ -117,12 +117,12 @@ public void handleQuitRequestWith(QuitEvent event, QuitResponse response) {
e.printStackTrace(); // oh well, never mind
}
// } else {
// // The douchebags at Oracle didn't feel that a working f*king menubar
// // on OS X was important enough to make it into the 7u40 release.
// // The douchebags at Oracle didn't feel that a working f*king menubar
// // on OS X was important enough to make it into the 7u40 release.
// //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8007267
// // It languished in the JDK 8 source and has been backported for 7u60:
// //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8022667
//
//
// JFrame offscreen = new JFrame();
// offscreen.setUndecorated(true);
// offscreen.setJMenuBar(defaultMenuBar);
Expand All @@ -131,12 +131,51 @@ public void handleQuitRequestWith(QuitEvent event, QuitResponse response) {
// offscreen.setVisible(true);
// }
}


// public ThinkDifferent(Base base) {
// this.base = base;
// }

/**
* Sets a handler on an instance of {@link Application}, taking into account JVM version
* differences.
*
* @param app an instance of {@link Application}
* @param name the "set handler" method name
* @param handler the handler
*/
private static void setHandler(Application app, String name, InvocationHandler handler) {
// Determine which version of com.apple.eawt.Application to use and pass it a handler of the
// appropriate type
Method[] methods = app.getClass().getMethods();
for (Method m : methods) {
if (!name.equals(m.getName())) {
continue;
}
if (m.getParameterCount() != 1) {
continue;
}
Class paramType = m.getParameterTypes()[0];
try {
// Allow a null handler
Object proxy = null;
if (handler != null) {
proxy = Proxy.newProxyInstance(
paramType.getClassLoader(), new Class<?>[] { paramType }, handler);
}
m.invoke(app, proxy);
} catch (IllegalArgumentException ex) {
// TODO: Print error?: method doesn't take an interface, etc.
} catch (IllegalAccessException ex) {
// TODO: Print error?: Other method invocation problem
} catch (InvocationTargetException ex) {
ex.getCause().printStackTrace();
// TODO: Print ex.getCause() a different way?
}
break;
}
}

/**
* Gimpy file menu to be used on OS X when no sketches are open.
Expand All @@ -162,7 +201,7 @@ public void actionPerformed(ActionEvent e) {
fileMenu.add(item);

item = Toolkit.newJMenuItemShift(Language.text("menu.file.sketchbook"), 'K');
item.addActionListener(new ActionListener() {
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
base.getNextMode().showSketchbookFrame();
Expand Down

0 comments on commit 46d25b9

Please sign in to comment.