diff --git a/.gitignore b/.gitignore index 9bf866d3b..52127a79a 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,9 @@ fabric.properties # Android studio 3.1+ serialized cache file .idea/caches/build_file_checksums.ser + +# testing boogers +bin-test + +# dated folders +/19* diff --git a/README.md b/README.md index 58de2892e..259aa164c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,15 @@ -This is an experimental fork to attempt the move to JDK 11. Because that's a major, API-breaking change, it would be Processing 4. +This is an experimental fork to attempt the move to JDK 11. Because that's a major, API-breaking change, it would be Processing 4. I'm working with Sam Pottinger to incorporate [his changes](https://github.com/sampottinger/processing) to see if that can be the basis for this new release. Getting things moved to OpenJDK 11 will help the longevity of the project. -**It's not clear if we'll ship an actual Processing 4.0**, since I have less free time than ever, and very little development help. If you'd like to help, contribute bug fixes. +**It's not clear if we'll ship an actual Processing 4.0**, since I have less free time than ever, and very little development help. If you'd like to help, contribute bug fixes. -Ben Fry, 4 October 2019 \ No newline at end of file +Ben Fry, 4 October 2019 + +--- + +## API changes + +As with all releases, I'll do everything possible to avoid breaking API. However, there will still be tweaks that have to be made. We'll try to keep them minor. + +* `Base.defaultFileMenu` is now `protected` instead of `static public` \ No newline at end of file diff --git a/app/.classpath b/app/.classpath index 72c373710..4918c7ea7 100644 --- a/app/.classpath +++ b/app/.classpath @@ -1,13 +1,16 @@ - + + + + + - - + diff --git a/app/.settings/org.eclipse.jdt.core.prefs b/app/.settings/org.eclipse.jdt.core.prefs index 991033770..404e1da2b 100644 --- a/app/.settings/org.eclipse.jdt.core.prefs +++ b/app/.settings/org.eclipse.jdt.core.prefs @@ -6,9 +6,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -22,6 +22,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore @@ -64,6 +65,7 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=igno org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled @@ -93,7 +95,8 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=18 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 91472a09e..7d4d8aa46 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -56,9 +56,9 @@ import processing.data.StringList; public class Base { // Added accessors for 0218 because the UpdateCheck class was not properly // updating the values, due to javac inlining the static final values. - static private final int REVISION = 270; + static private final int REVISION = 1270; /** This might be replaced by main() if there's a lib/version.txt file. */ - static private String VERSION_NAME = "0270"; //$NON-NLS-1$ + static private String VERSION_NAME = "1270"; //$NON-NLS-1$ /** Set true if this a proper release rather than a numbered revision. */ /** @@ -84,7 +84,7 @@ public class Base { Collections.synchronizedList(new ArrayList()); protected Editor activeEditor; /** A lone file menu to be used when all sketch windows are closed. */ - static public JMenu defaultFileMenu; + protected JMenu defaultFileMenu; /** * Starts with the last mode used with the environment, @@ -437,6 +437,49 @@ public class Base { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + /** + * Limited file menu to be used on OS X when no sketches are open. + */ + public JMenu initDefaultFileMenu() { + defaultFileMenu = new JMenu(Language.text("menu.file")); + + JMenuItem item = Toolkit.newJMenuItem(Language.text("menu.file.new"), 'N'); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + handleNew(); + } + }); + defaultFileMenu.add(item); + + item = Toolkit.newJMenuItem(Language.text("menu.file.open"), 'O'); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + handleOpenPrompt(); + } + }); + defaultFileMenu.add(item); + + item = Toolkit.newJMenuItemShift(Language.text("menu.file.sketchbook"), 'K'); + item.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + getNextMode().showSketchbookFrame(); + } + }); + defaultFileMenu.add(item); + + item = Toolkit.newJMenuItemShift(Language.text("menu.file.examples"), 'O'); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + thinkDifferentExamples(); + } + }); + defaultFileMenu.add(item); + + return defaultFileMenu; + } + + void buildCoreModes() { Mode javaMode = ModeContribution.load(this, Platform.getContentFile("modes/java"), diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 1b05083e1..c9349e855 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -404,17 +404,17 @@ public class Preferences { /** - * Check for a 3.0 sketchbook location, and if none exists, - * try to grab it from the 2.0 sketchbook location. + * Check for a 4.0 sketchbook location, and if none exists, + * try to grab it from the 3.0 sketchbook location. * @return true if a location was found and the pref didn't exist */ static protected boolean checkSketchbookPref() { - // If a 3.0 sketchbook location has never been inited + // If a 4.0 sketchbook location has never been inited if (getSketchbookPath() == null) { - String twoPath = get("sketchbook.path"); - // If they've run the 2.0 version, start with that location - if (twoPath != null) { - setSketchbookPath(twoPath); + String threePath = get("sketchbook.path.three"); //$NON-NLS-1$ + // If they've run the 3.0 version, start with that location + if (threePath != null) { + setSketchbookPath(threePath); return true; // save the sketchbook right away } // Otherwise it'll be null, and reset properly by Base @@ -424,16 +424,16 @@ public class Preferences { static public String getOldSketchbookPath() { - return get("sketchbook.path"); - } - - - static public String getSketchbookPath() { return get("sketchbook.path.three"); //$NON-NLS-1$ } + static public String getSketchbookPath() { + return get("sketchbook.path.four"); //$NON-NLS-1$ + } + + static protected void setSketchbookPath(String path) { - set("sketchbook.path.three", path); //$NON-NLS-1$ + set("sketchbook.path.four", path); //$NON-NLS-1$ } } diff --git a/app/src/processing/app/platform/DefaultPlatform.java b/app/src/processing/app/platform/DefaultPlatform.java index 58529b516..9cee2cbc4 100644 --- a/app/src/processing/app/platform/DefaultPlatform.java +++ b/app/src/processing/app/platform/DefaultPlatform.java @@ -129,7 +129,7 @@ public class DefaultPlatform { public interface CLibrary extends Library { - CLibrary INSTANCE = (CLibrary)Native.loadLibrary("c", CLibrary.class); + CLibrary INSTANCE = Native.loadLibrary("c", CLibrary.class); int setenv(String name, String value, int overwrite); String getenv(String name); int unsetenv(String name); diff --git a/app/src/processing/app/platform/LinuxPlatform.java b/app/src/processing/app/platform/LinuxPlatform.java index 56c7859de..af6d52506 100644 --- a/app/src/processing/app/platform/LinuxPlatform.java +++ b/app/src/processing/app/platform/LinuxPlatform.java @@ -27,7 +27,6 @@ import java.awt.Desktop; import java.awt.Toolkit; import processing.app.Base; -import processing.app.Messages; import processing.app.Preferences; import processing.app.platform.DefaultPlatform; import processing.core.PApplet; diff --git a/app/src/processing/app/platform/MacPlatform.java b/app/src/processing/app/platform/MacPlatform.java index b3fd404d9..64852fb91 100644 --- a/app/src/processing/app/platform/MacPlatform.java +++ b/app/src/processing/app/platform/MacPlatform.java @@ -28,29 +28,20 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.net.URI; -import com.apple.eio.FileManager; +import javax.swing.JMenu; +import javax.swing.JMenuBar; import processing.app.Base; import processing.app.Messages; import processing.app.platform.DefaultPlatform; +import processing.app.ui.About; /** - * Platform handler for Mac OS X. + * Platform handler for macOS. */ public class MacPlatform extends DefaultPlatform { - // Removing for 2.0b8 because Quaqua doesn't have OS X 10.8 version. - /* - public void setLookAndFeel() throws Exception { - // Use the Quaqua L & F on OS X to make JFileChooser less awful - UIManager.setLookAndFeel("ch.randelshofer.quaqua.QuaquaLookAndFeel"); - // undo quaqua trying to fix the margins, since we've already - // hacked that in, bit by bit, over the years - UIManager.put("Component.visualMargin", new Insets(1, 1, 1, 1)); - } - */ - public void saveLanguage(String language) { String[] cmdarray = new String[]{ "defaults", "write", @@ -67,35 +58,42 @@ public class MacPlatform extends DefaultPlatform { public void initBase(Base base) { super.initBase(base); + + final Desktop desktop = Desktop.getDesktop(); + System.setProperty("apple.laf.useScreenMenuBar", "true"); - ThinkDifferent.init(base); - /* - try { - String name = "processing.app.macosx.ThinkDifferent"; - Class osxAdapter = ClassLoader.getSystemClassLoader().loadClass(name); - Class[] defArgs = { Base.class }; - Method registerMethod = osxAdapter.getDeclaredMethod("register", defArgs); - if (registerMethod != null) { - Object[] args = { this }; - registerMethod.invoke(osxAdapter, args); + // Set the menu bar to be used when nothing else is open. + JMenuBar defaultMenuBar = new JMenuBar(); + JMenu fileMenu = base.initDefaultFileMenu(); + defaultMenuBar.add(fileMenu); + desktop.setDefaultMenuBar(defaultMenuBar); + + desktop.setAboutHandler((event) -> { + new About(null); + }); + + desktop.setPreferencesHandler((event) -> { + base.handlePrefs(); + }); + + desktop.setOpenFileHandler((event) -> { + for (File file : event.getFiles()) { + base.handleOpen(file.getAbsolutePath()); } - } catch (NoClassDefFoundError e) { - // This will be thrown first if the OSXAdapter is loaded on a system without the EAWT - // because OSXAdapter extends ApplicationAdapter in its def - System.err.println("This version of Mac OS X does not support the Apple EAWT." + - "Application Menu handling has been disabled (" + e + ")"); + }); - } catch (ClassNotFoundException e) { - // This shouldn't be reached; if there's a problem with the OSXAdapter - // we should get the above NoClassDefFoundError first. - System.err.println("This version of Mac OS X does not support the Apple EAWT. " + - "Application Menu handling has been disabled (" + e + ")"); - } catch (Exception e) { - System.err.println("Exception while loading BaseOSX:"); - e.printStackTrace(); - } - */ + desktop.setPrintFileHandler((event) -> { + // TODO not yet implemented + }); + + desktop.setQuitHandler((event, quitResponse) -> { + if (base.handleQuit()) { + quitResponse.performQuit(); + } else { + quitResponse.cancelQuit(); + } + }); } @@ -106,30 +104,9 @@ public class MacPlatform extends DefaultPlatform { public File getDefaultSketchbookFolder() throws Exception { return new File(getDocumentsFolder(), "Processing"); - /* - // looking for /Users/blah/Documents/Processing - try { - Class clazz = Class.forName("processing.app.BaseMacOS"); - Method m = clazz.getMethod("getDocumentsFolder", new Class[] { }); - String documentsPath = (String) m.invoke(null, new Object[] { }); - sketchbookFolder = new File(documentsPath, "Processing"); - - } catch (Exception e) { - sketchbookFolder = promptSketchbookLocation(); - } - */ } -// /** -// * Moves the specified File object (which might be a file or folder) -// * to the trash. -// */ -// public boolean deleteFile(File file) throws IOException { -// return FileManager.moveToTrash(file); -// } - - public void openURL(String url) throws Exception { try { Desktop.getDesktop().browse(new URI(url)); @@ -145,64 +122,23 @@ public class MacPlatform extends DefaultPlatform { } - /* - public void openURL(String url) throws Exception { - if (PApplet.javaVersion < 1.6f) { - if (url.startsWith("http://")) { - // formerly com.apple.eio.FileManager.openURL(url); - // but due to deprecation, instead loading dynamically - try { - Class eieio = Class.forName("com.apple.eio.FileManager"); - Method openMethod = - eieio.getMethod("openURL", new Class[] { String.class }); - openMethod.invoke(null, new Object[] { url }); - } catch (Exception e) { - e.printStackTrace(); - } - } else { - // Assume this is a file instead, and just open it. - // Extension of http://dev.processing.org/bugs/show_bug.cgi?id=1010 - processing.core.PApplet.open(url); - } - } else { - try { - Class desktopClass = Class.forName("java.awt.Desktop"); - Method getMethod = desktopClass.getMethod("getDesktop"); - Object desktop = getMethod.invoke(null, new Object[] { }); - - // for Java 1.6, replacing with java.awt.Desktop.browse() - // and java.awt.Desktop.open() - if (url.startsWith("http://")) { // browse to a location - Method browseMethod = - desktopClass.getMethod("browse", new Class[] { URI.class }); - browseMethod.invoke(desktop, new Object[] { new URI(url) }); - } else { // open a file - Method openMethod = - desktopClass.getMethod("open", new Class[] { File.class }); - openMethod.invoke(desktop, new Object[] { new File(url) }); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - - public boolean openFolderAvailable() { - return true; - } - - - public void openFolder(File file) throws Exception { - //openURL(file.getAbsolutePath()); // handles char replacement, etc - processing.core.PApplet.open(file.getAbsolutePath()); - } - */ - - // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + // TODO I suspect this won't work much longer, since access to the user's + // home directory seems verboten on more recent macOS versions [fry 191008] + protected String getLibraryFolder() throws FileNotFoundException { + return System.getProperty("user.home") + "/Library"; + } + + + // see notes on getLibraryFolder() + protected String getDocumentsFolder() throws FileNotFoundException { + return System.getProperty("user.home") + "/Documents"; + } + + + /* // Some of these are supposedly constants in com.apple.eio.FileManager, // however they don't seem to link properly from Eclipse. @@ -237,4 +173,5 @@ public class MacPlatform extends DefaultPlatform { protected String getDocumentsFolder() throws FileNotFoundException { return FileManager.findFolder(kUserDomain, kDocumentsFolderType); } + */ } diff --git a/app/src/processing/app/platform/ThinkDifferent.java b/app/src/processing/app/platform/ThinkDifferent.java deleted file mode 100644 index 01c9823bc..000000000 --- a/app/src/processing/app/platform/ThinkDifferent.java +++ /dev/null @@ -1,222 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2012-2014 The Processing Foundation - Copyright (c) 2007-2012 Ben Fry and Casey Reas - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - version 2, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app.platform; - -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.Application; - -import processing.app.*; -import processing.app.ui.About; -import processing.app.ui.Toolkit; - - -/** - * Deal with issues related to thinking differently. This handles the basic - * Mac OS X menu commands (and apple events) for open, about, prefs, etc. - * - * As of 0140, this code need not be built on platforms other than OS X, - * because of the new platform structure which isolates through reflection. - * - * Rewritten for 0232 to remove deprecation issues, per the message - * here. - * (We're able to do this now because we're dropping older Java versions.) - */ -public class ThinkDifferent { - - // pseudo-singleton model; no point in making multiple instances - // of the EAWT application or our adapter - private static ThinkDifferent adapter; - // http://developer.apple.com/documentation/Java/Reference/1.4.2/appledoc/api/com/apple/eawt/Application.html - private static Application application; - - // reference to the app where the existing quit, about, prefs code is - //private Base base; - - - static protected void init(final Base base) { - if (application == null) { - application = Application.getApplication(); - } - if (adapter == null) { - adapter = new ThinkDifferent(); //base); - } - - setHandler(application, "setAboutHandler", (proxy, method, args) -> { - new About(null); - return null; - }); - - setHandler(application, "setPreferencesHandler", (proxy, method, args) -> { - base.handlePrefs(); - return null; - }); - - setHandler(application, "setOpenFileHandler", (proxy, method, args) -> { - Method m = args[0].getClass().getMethod("getFiles"); - for (File file : (List) m.invoke(args[0])) { - base.handleOpen(file.getAbsolutePath()); - } - return null; - }); - - setHandler(application, "setPrintFileHandler", (proxy, method, args) -> { - // TODO not yet implemented - return null; - }); - - 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. - JMenuBar defaultMenuBar = new JMenuBar(); - JMenu fileMenu = buildFileMenu(base); - defaultMenuBar.add(fileMenu); - // This is kind of a gross way to do this, but the alternatives? Hrm. - Base.defaultFileMenu = fileMenu; - -// if (PApplet.javaVersion <= 1.6f) { // doesn't work on Oracle's Java - try { - application.setDefaultMenuBar(defaultMenuBar); - - } catch (Exception e) { - 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. -// //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); -// Dimension screen = Toolkit.getScreenSize(); -// offscreen.setLocation(screen.width, screen.height); -// 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. - */ - static protected JMenu buildFileMenu(final Base base) { - JMenuItem item; - JMenu fileMenu = new JMenu(Language.text("menu.file")); - - item = Toolkit.newJMenuItem(Language.text("menu.file.new"), 'N'); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - base.handleNew(); - } - }); - fileMenu.add(item); - - item = Toolkit.newJMenuItem(Language.text("menu.file.open"), 'O'); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - base.handleOpenPrompt(); - } - }); - fileMenu.add(item); - - item = Toolkit.newJMenuItemShift(Language.text("menu.file.sketchbook"), 'K'); - item.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - base.getNextMode().showSketchbookFrame(); - } - }); - fileMenu.add(item); - - item = Toolkit.newJMenuItemShift(Language.text("menu.file.examples"), 'O'); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - base.thinkDifferentExamples(); - } - }); - fileMenu.add(item); - - return fileMenu; - } -} diff --git a/app/src/processing/app/platform/WindowsPlatform.java b/app/src/processing/app/platform/WindowsPlatform.java index fd29eed58..58e01747c 100644 --- a/app/src/processing/app/platform/WindowsPlatform.java +++ b/app/src/processing/app/platform/WindowsPlatform.java @@ -28,11 +28,8 @@ import java.io.UnsupportedEncodingException; import com.sun.jna.Library; import com.sun.jna.Native; -import com.sun.jna.Pointer; import com.sun.jna.platform.win32.Shell32Util; import com.sun.jna.platform.win32.ShlObj; -import com.sun.jna.win32.StdCallLibrary; -import com.sun.jna.win32.W32APIOptions; import processing.app.Base; import processing.app.Messages; @@ -563,7 +560,7 @@ public class WindowsPlatform extends DefaultPlatform { static WinLibC getLibC() { if (clib == null) { try { - clib = (WinLibC) Native.loadLibrary("msvcrt", WinLibC.class); + clib = Native.loadLibrary("msvcrt", WinLibC.class); } catch (UnsatisfiedLinkError ule) { Messages.showTrace("JNA Error", "JNA could not be loaded. Please report here:\n" + diff --git a/app/src/processing/app/syntax/JEditTextArea.java b/app/src/processing/app/syntax/JEditTextArea.java index c3e6c617c..8554078f4 100644 --- a/app/src/processing/app/syntax/JEditTextArea.java +++ b/app/src/processing/app/syntax/JEditTextArea.java @@ -1336,12 +1336,12 @@ public class JEditTextArea extends JComponent * @param startOffset The offset to apply before the text will be drawn. * @return The width of the input segment in pixels with fractional character widths considered. */ - private int getTabbedTextWidth(Segment s, FontMetrics metrics, float x, TabExpander expander, - int startOffset) { + private int getTabbedTextWidth(Segment s, FontMetrics metrics, float x, + TabExpander expander, int startOffset) { + float additionalOffset = + getPartialPixelWidth(metrics, x, expander, startOffset) * s.length(); - float additionalOffset = getPartialPixelWidth(metrics, x, expander, startOffset) * s.length(); - - return (int) Math.round( + return Math.round( Utilities.getTabbedTextWidth(s, metrics, x, expander, startOffset) + additionalOffset ); } @@ -1369,14 +1369,9 @@ public class JEditTextArea extends JComponent // See https://github.com/sampottinger/processing/issues/103 // Requires reference not object equality check if (candidateMetrics != cachedPartialPixelWidthFont) { - float withFractional = Utilities.getTabbedTextWidth​( - TEST_SEGMENT, - candidateMetrics, - x, - expander, - startOffset - ); - + float withFractional = + Utilities.getTabbedTextWidth(TEST_SEGMENT, candidateMetrics, + x, expander, startOffset); int withoutFractional = (int) withFractional; partialPixelWidth = withFractional - withoutFractional; @@ -2486,7 +2481,7 @@ public class JEditTextArea extends JComponent private void doSingleClick(MouseEvent evt, int line, int offset, int dot) { - if ((evt.getModifiers() & InputEvent.SHIFT_MASK) != 0) { + if (evt.isShiftDown()) { select(getMarkPosition(),dot); } else { setCaretPosition(dot); diff --git a/app/src/processing/app/ui/Editor.java b/app/src/processing/app/ui/Editor.java index 0e9ab769e..e71e1efeb 100644 --- a/app/src/processing/app/ui/Editor.java +++ b/app/src/processing/app/ui/Editor.java @@ -264,9 +264,8 @@ public abstract class Editor extends JFrame implements RunnerListener { textarea.setHorizontalOffset(JEditTextArea.leftHandGutter); { // Hack: add Numpad Slash as alternative shortcut for Comment/Uncomment - int modifiers = Toolkit.awtToolkit.getMenuShortcutKeyMask(); KeyStroke keyStroke = - KeyStroke.getKeyStroke(KeyEvent.VK_DIVIDE, modifiers); + KeyStroke.getKeyStroke(KeyEvent.VK_DIVIDE, Toolkit.SHORTCUT_KEY_MASK); final String ACTION_KEY = "COMMENT_UNCOMMENT_ALT"; textarea.getInputMap().put(keyStroke, ACTION_KEY); textarea.getActionMap().put(ACTION_KEY, new AbstractAction() { @@ -459,7 +458,6 @@ public abstract class Editor extends JFrame implements RunnerListener { return !sketch.isReadOnly(); } - @SuppressWarnings("unchecked") public boolean importData(TransferHandler.TransferSupport support) { int successful = 0; diff --git a/app/src/processing/app/ui/EditorButton.java b/app/src/processing/app/ui/EditorButton.java index f65f08139..538a3ddc0 100644 --- a/app/src/processing/app/ui/EditorButton.java +++ b/app/src/processing/app/ui/EditorButton.java @@ -43,7 +43,6 @@ implements MouseListener, MouseMotionListener, ActionListener { protected boolean pressed; protected boolean selected; protected boolean rollover; -// protected JLabel rolloverLabel; protected boolean shift; protected Image enabledImage; @@ -55,7 +54,6 @@ implements MouseListener, MouseMotionListener, ActionListener { protected Image gradient; protected EditorToolbar toolbar; -// protected Mode mode; public EditorButton(EditorToolbar parent, String name, String title) { @@ -128,50 +126,8 @@ implements MouseListener, MouseMotionListener, ActionListener { } -// public String toString() { -// switch (this) { -// case DISABLED: return "disabled"; -// case ENABLED: return "enabled"; -// case SELECTED: return "selected"; -// case ROLLOVER: return "rollover"; -// case PRESSED: return "pressed"; -// -//// for (State bs : State.values()) { -//// Image image = mode.loadImage(bs.getFilename(name)); -//// if (image != null) { -//// imageMap.put(bs, image); -//// } -//// } -//// -//// enabled = true; -//// //updateState(); -//// setState(State.ENABLED); -// } - - -// public void setReverse() { -// gradient = mode.makeGradient("reversed", DIM, DIM); -// } - - -// public void setGradient(Image gradient) { -// this.gradient = gradient; -// } - - -// public void setRolloverLabel(JLabel label) { -// rolloverLabel = label; -// } - - @Override - public void mouseClicked(MouseEvent e) { -// if (isEnabled()) { -// shift = e.isShiftDown(); -// actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, -// null, e.getModifiers())); -// } - } + public void mouseClicked(MouseEvent e) { } public boolean isShiftDown() { @@ -181,12 +137,17 @@ implements MouseListener, MouseMotionListener, ActionListener { @Override public void mousePressed(MouseEvent e) { - setPressed(true); - - // Need to fire here (or on mouse up) because mouseClicked() + // Using mousePressed() (or mouseReleased()) because mouseClicked() // won't be fired if the user nudges the mouse while clicking. // https://github.com/processing/processing/issues/3529 + setPressed(true); + shift = e.isShiftDown(); + + // It looks like ActionEvent expects old-style modifiers, + // so the e.getModifiers() call here may be correct. + // TODO Look into how this is getting used in Modes, + // and either update or add ignore to the deprecation [fry 191008] actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null, e.getModifiers())); } @@ -211,25 +172,6 @@ implements MouseListener, MouseMotionListener, ActionListener { } - /* - @Override - public void keyTyped(KeyEvent e) { } - - - @Override - public void keyReleased(KeyEvent e) { - updateRollover(e); - } - - - @Override - public void keyPressed(KeyEvent e) { - System.out.println(e); - updateRollover(e); - } - */ - - public String getRolloverText(InputEvent e) { if (e.isShiftDown()) { return titleShift; @@ -240,42 +182,15 @@ implements MouseListener, MouseMotionListener, ActionListener { } - /* - public void updateRollover(InputEvent e) { - if (rolloverLabel != null) { - if (e.isShiftDown()) { - rolloverLabel.setText(titleShift); - } else if (e.isAltDown()) { - rolloverLabel.setText(titleAlt); - } else { - rolloverLabel.setText(title); - } - } - } - */ - - @Override public void mouseEntered(MouseEvent e) { toolbar.setRollover(this, e); - /* - rollover = true; - updateRollover(e); - repaint(); - */ } @Override public void mouseExited(MouseEvent e) { toolbar.setRollover(null, e); - /* - rollover = false; - if (rolloverLabel != null) { - rolloverLabel.setText(""); - } - repaint(); - */ } @@ -289,11 +204,6 @@ implements MouseListener, MouseMotionListener, ActionListener { abstract public void actionPerformed(ActionEvent e); -// @Override -// public void actionPerformed(ActionEvent e) { -// // To be overridden by all subclasses -// } - @Override public Dimension getPreferredSize() { @@ -311,58 +221,4 @@ implements MouseListener, MouseMotionListener, ActionListener { public Dimension getMaximumSize() { return getPreferredSize(); } - - -// public Image getImage() { -// return imageMap.get(state); -// } -// -// -//// protected void updateState() { -//// state = ButtonState.ENABLED; -//// } -// -// -// public void setEnabled(boolean enabled) { -// this.enabled = enabled; -// if (enabled) { -// if (state == State.DISABLED) { -// setState(State.ENABLED); -// } -// } else { -// if (state == State.ENABLED) { -// setState(State.DISABLED); -// } -// } -// } -// -// -// public void setState(State state) { -// this.state = state; -// } - - -// public enum State { -// DISABLED, ENABLED, SELECTED, ROLLOVER, PRESSED; -// -// /** -// * @param name the root name -// * @return -// */ -// public String getFilename(String name) { -// final int res = Toolkit.highResDisplay() ? 2 : 1; -// return name + "-" + toString() + "-" + res + "x.png"; -// } -// -// public String toString() { -// switch (this) { -// case DISABLED: return "disabled"; -// case ENABLED: return "enabled"; -// case SELECTED: return "selected"; -// case ROLLOVER: return "rollover"; -// case PRESSED: return "pressed"; -// } -// return null; -// } -// } } \ No newline at end of file diff --git a/app/src/processing/app/ui/Toolkit.java b/app/src/processing/app/ui/Toolkit.java index 866190c6e..fc740353b 100644 --- a/app/src/processing/app/ui/Toolkit.java +++ b/app/src/processing/app/ui/Toolkit.java @@ -91,7 +91,7 @@ public class Toolkit { /** Command on Mac OS X, Ctrl on Windows and Linux */ static final int SHORTCUT_KEY_MASK = - awtToolkit.getMenuShortcutKeyMask(); + awtToolkit.getMenuShortcutKeyMaskEx(); /** Command-Option on Mac OS X, Ctrl-Alt on Windows and Linux */ static final int SHORTCUT_ALT_KEY_MASK = ActionEvent.ALT_MASK | SHORTCUT_KEY_MASK; @@ -178,8 +178,7 @@ public class Toolkit { */ static public JMenuItem newJMenuItem(String title, int what) { JMenuItem menuItem = new JMenuItem(title); - int modifiers = awtToolkit.getMenuShortcutKeyMask(); - menuItem.setAccelerator(KeyStroke.getKeyStroke(what, modifiers)); + menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_KEY_MASK)); return menuItem; } @@ -190,8 +189,7 @@ public class Toolkit { */ static public JMenuItem newJMenuItem(Action action, int what) { JMenuItem menuItem = new JMenuItem(action); - int modifiers = awtToolkit.getMenuShortcutKeyMask(); - menuItem.setAccelerator(KeyStroke.getKeyStroke(what, modifiers)); + menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_KEY_MASK)); return menuItem; } @@ -201,9 +199,7 @@ public class Toolkit { */ static public JMenuItem newJMenuItemShift(String title, int what) { JMenuItem menuItem = new JMenuItem(title); - int modifiers = awtToolkit.getMenuShortcutKeyMask(); - modifiers |= ActionEvent.SHIFT_MASK; - menuItem.setAccelerator(KeyStroke.getKeyStroke(what, modifiers)); + menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_SHIFT_KEY_MASK)); return menuItem; } @@ -213,9 +209,7 @@ public class Toolkit { */ static public JMenuItem newJMenuItemShift(Action action, int what) { JMenuItem menuItem = new JMenuItem(action); - int modifiers = awtToolkit.getMenuShortcutKeyMask(); - modifiers |= ActionEvent.SHIFT_MASK; - menuItem.setAccelerator(KeyStroke.getKeyStroke(what, modifiers)); + menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_SHIFT_KEY_MASK)); return menuItem; } @@ -235,8 +229,7 @@ public class Toolkit { static public JCheckBoxMenuItem newJCheckBoxMenuItem(String title, int what) { JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(title); - int modifiers = awtToolkit.getMenuShortcutKeyMask(); - menuItem.setAccelerator(KeyStroke.getKeyStroke(what, modifiers)); + menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_KEY_MASK)); return menuItem; } @@ -326,7 +319,7 @@ public class Toolkit { if (fmTmp == null) return; // All null menuitems; would fail. final FontMetrics fm = fmTmp; // Hack for accessing variable in comparator. - final Comparator charComparator = new Comparator() { + final Comparator charComparator = new Comparator<>() { char[] baddies = "qypgjaeiouQAEIOU".toCharArray(); public int compare(Character ch1, Character ch2) { // Discriminates against descenders for readability, per MS @@ -699,8 +692,7 @@ public class Toolkit { root.registerKeyboardAction(disposer, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); - int modifiers = awtToolkit.getMenuShortcutKeyMask(); - stroke = KeyStroke.getKeyStroke('W', modifiers); + stroke = KeyStroke.getKeyStroke('W', SHORTCUT_KEY_MASK); root.registerKeyboardAction(disposer, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); } diff --git a/build/.gitignore b/build/.gitignore index 53dbd6552..9eaaf5bbf 100644 --- a/build/.gitignore +++ b/build/.gitignore @@ -1,8 +1,6 @@ work javadoc -jre/bin-test - # Not sure what crazy collisions we would have but leaving these explicit macosx/javafx-sdk-* macosx/jdk-11.* diff --git a/core/.classpath b/core/.classpath index 8cc9f1f79..5fdcdc6df 100644 --- a/core/.classpath +++ b/core/.classpath @@ -1,14 +1,15 @@ - + - + + diff --git a/core/.settings/org.eclipse.jdt.core.prefs b/core/.settings/org.eclipse.jdt.core.prefs index 6c6ce4e4e..aedc99316 100644 --- a/core/.settings/org.eclipse.jdt.core.prefs +++ b/core/.settings/org.eclipse.jdt.core.prefs @@ -7,9 +7,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -23,6 +23,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning @@ -66,6 +67,7 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=igno org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled @@ -97,7 +99,8 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=18 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/core/apple.jar b/core/apple.jar deleted file mode 100644 index 6659a81c6..000000000 Binary files a/core/apple.jar and /dev/null differ diff --git a/core/build.xml b/core/build.xml index 13f96e135..6cd161376 100644 --- a/core/build.xml +++ b/core/build.xml @@ -18,8 +18,6 @@ - - @@ -61,7 +59,6 @@ - (); + iconImages = new ArrayList<>(); final int[] sizes = { 16, 32, 48, 64, 128, 256, 512 }; for (int sz : sizes) { @@ -1475,7 +1475,7 @@ public class PSurfaceAWT extends PSurfaceNone { public void setCursor(int kind) { // Swap the HAND cursor because MOVE doesn't seem to be available on OS X // https://github.com/processing/processing/issues/2358 - if (PApplet.platform == PConstants.MACOSX && kind == PConstants.MOVE) { + if (PApplet.platform == PConstants.MACOS && kind == PConstants.MOVE) { kind = PConstants.HAND; } canvas.setCursor(Cursor.getPredefinedCursor(kind)); diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 51e1bc928..e4208ca62 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -155,7 +155,7 @@ public class PApplet implements PConstants { String osname = System.getProperty("os.name"); if (osname.indexOf("Mac") != -1) { - platform = MACOSX; + platform = MACOS; } else if (osname.indexOf("Windows") != -1) { platform = WINDOWS; @@ -981,7 +981,7 @@ public class PApplet implements PConstants { // be called, conjuring up the demons of various rendering configurations. settings(); - if (display == SPAN && platform == MACOSX) { + if (display == SPAN && platform == MACOS) { // Make sure "Displays have separate Spaces" is unchecked // in System Preferences > Mission Control Process p = exec("defaults", "read", "com.apple.spaces", "spans-displays"); @@ -1158,7 +1158,7 @@ public class PApplet implements PConstants { * @param display the display number to check */ public int displayDensity(int display) { - if (PApplet.platform == PConstants.MACOSX) { + if (PApplet.platform == PConstants.MACOS) { // This should probably be reset each time there's a display change. // A 5-minute search didn't turn up any such event in the Java 7 API. // Also, should we use the Toolkit associated with the editor window? @@ -2696,7 +2696,7 @@ public class PApplet implements PConstants { int button = event.getButton(); // If running on Mac OS, allow ctrl-click as right mouse. - if (PApplet.platform == PConstants.MACOSX && event.getButton() == PConstants.LEFT) { + if (PApplet.platform == PConstants.MACOS && event.getButton() == PConstants.LEFT) { if (action == MouseEvent.PRESS && event.isControlDown()) { macosxLeftButtonWithCtrlPressed = true; } @@ -3037,8 +3037,8 @@ public class PApplet implements PConstants { // embedded inside an application that has its own close behavior. if (external && event.getKeyCode() == 'W' && - ((event.isMetaDown() && platform == MACOSX) || - (event.isControlDown() && platform != MACOSX))) { + ((event.isMetaDown() && platform == MACOS) || + (event.isControlDown() && platform != MACOS))) { // Can't use this native stuff b/c the native event might be NEWT // if (external && event.getNative() instanceof java.awt.event.KeyEvent && // ((java.awt.event.KeyEvent) event.getNative()).getModifiers() == @@ -3504,7 +3504,7 @@ public class PApplet implements PConstants { // in the user.dir part of the url params = new String[] { "cmd", "/c" }; - } else if (platform == MACOSX) { + } else if (platform == MACOS) { params = new String[] { "open" }; } else if (platform == LINUX) { @@ -3841,7 +3841,7 @@ public class PApplet implements PConstants { handleMethods("dispose"); } - if (platform == MACOSX) { + if (platform == MACOS) { try { final String td = "processing.core.ThinkDifferent"; final Class thinkDifferent = getClass().getClassLoader().loadClass(td); @@ -6678,7 +6678,7 @@ public class PApplet implements PConstants { (sketch.g instanceof PGraphicsOpenGL) && (platform == WINDOWS); if (hide) sketch.surface.setVisible(false); - if (platform == MACOSX && useNativeSelect != false) { + if (platform == MACOS && useNativeSelect != false) { FileDialog fileDialog = new FileDialog(parentFrame, prompt, FileDialog.LOAD); if (defaultSelection != null) { @@ -7967,7 +7967,7 @@ public class PApplet implements PConstants { // Workaround for bug in Java for OS X from Oracle (7u51) // https://github.com/processing/processing/issues/2181 - if (platform == MACOSX) { + if (platform == MACOS) { if (jarPath.contains("Contents/Java/")) { String appPath = jarPath.substring(0, jarPath.indexOf(".app") + 4); File containingFolder = new File(appPath).getParentFile(); @@ -9258,7 +9258,7 @@ public class PApplet implements PConstants { static Pattern matchPattern(String regexp) { Pattern p = null; if (matchPatterns == null) { - matchPatterns = new LinkedHashMap(16, 0.75f, true) { + matchPatterns = new LinkedHashMap<>(16, 0.75f, true) { @Override protected boolean removeEldestEntry(Map.Entry eldest) { // Limit the number of match patterns at 10 most recently used @@ -10857,7 +10857,7 @@ public class PApplet implements PConstants { } } - if (platform == MACOSX) { + if (platform == MACOS) { try { final String td = "processing.core.ThinkDifferent"; Class thinkDifferent = @@ -11077,7 +11077,7 @@ public class PApplet implements PConstants { /** Convenience method, should only be called by PSurface subclasses. */ static public void hideMenuBar() { - if (PApplet.platform == PConstants.MACOSX) { + if (PApplet.platform == PConstants.MACOS) { // Call some native code to remove the menu bar on OS X. Not necessary // on Linux and Windows, who are happy to make full screen windows. japplemenubar.JAppleMenuBar.hide(); diff --git a/core/src/processing/core/PConstants.java b/core/src/processing/core/PConstants.java index 6792ec054..a5eb0d8c7 100644 --- a/core/src/processing/core/PConstants.java +++ b/core/src/processing/core/PConstants.java @@ -80,9 +80,13 @@ public interface PConstants { static final int OTHER = 0; static final int WINDOWS = 1; - static final int MACOSX = 2; + static final int MACOS = 2; static final int LINUX = 3; + /** @deprecated Marketers gonna market, use {@link #MACOS} */ + @Deprecated + static final int MACOSX = 2; + static final String[] platformNames = { "other", "windows", "macosx", "linux" }; diff --git a/core/src/processing/core/PFont.java b/core/src/processing/core/PFont.java index 33ca7eb40..9812063af 100644 --- a/core/src/processing/core/PFont.java +++ b/core/src/processing/core/PFont.java @@ -914,7 +914,7 @@ public class PFont implements PConstants { GraphicsEnvironment.getLocalGraphicsEnvironment(); fonts = ge.getAllFonts(); - if (PApplet.platform == PConstants.MACOSX) { + if (PApplet.platform == PConstants.MACOS) { fontDifferent = new HashMap<>(); for (Font font : fonts) { // No need to use getPSName() anymore because getName() @@ -936,7 +936,7 @@ public class PFont implements PConstants { * See: issue #5481 */ static public Font findFont(String name) { - if (PApplet.platform == PConstants.MACOSX) { + if (PApplet.platform == PConstants.MACOS) { loadFonts(); Font maybe = fontDifferent.get(name); if (maybe != null) { diff --git a/core/src/processing/core/ThinkDifferent.java b/core/src/processing/core/ThinkDifferent.java index 5179bab5e..4c6de03ed 100644 --- a/core/src/processing/core/ThinkDifferent.java +++ b/core/src/processing/core/ThinkDifferent.java @@ -22,11 +22,13 @@ package processing.core; -import java.awt.*; +import java.awt.Desktop; +import java.awt.Image; +import java.awt.Taskbar; /** - * Deal with issues related to Mac OS window behavior. + * Deal with issues related to macOS application behavior. * * We have to register a quit handler to safely shut down the sketch, * otherwise OS X will just kill the sketch when a user hits Cmd-Q. @@ -37,15 +39,15 @@ import java.awt.*; * 3301. */ public class ThinkDifferent { - - private static Desktop desktop; - private static Taskbar taskbar; + static private Desktop desktop; + static private Taskbar taskbar; // True if user has tried to quit once. Prevents us from canceling the quit // call if the sketch is held up for some reason, like an exception that's // managed to put the sketch in a bad state. static boolean attemptedQuit; + /** * Initialize the sketch with the quit handler. * @@ -70,6 +72,7 @@ public class ThinkDifferent { }); } + /** * Remove the quit handler. */ @@ -77,44 +80,36 @@ public class ThinkDifferent { getDesktop().setQuitHandler(null); } + /** * Called via reflection from PSurfaceAWT and others, set the dock icon image. - * * @param image The image to provide for Processing icon. */ static public void setIconImage(Image image) { getTaskbar().setIconImage(image); } + /** * Get the taskbar where OS visual settings can be provided. - * * @return Cached taskbar singleton instance. */ static private Taskbar getTaskbar() { if (taskbar == null) { taskbar = Taskbar.getTaskbar(); } - return taskbar; } + /** * Get the desktop where OS behavior can be provided. - * * @return Cached desktop singleton instance. */ static private Desktop getDesktop() { if (desktop == null) { desktop = Desktop.getDesktop(); } - return desktop; } - - - // Instead, just use Application.getApplication() inside your app -// static public Application getApplication() { -// return desktop; -// } } diff --git a/core/src/processing/javafx/PSurfaceFX.java b/core/src/processing/javafx/PSurfaceFX.java index 19a91f164..831ef4418 100644 --- a/core/src/processing/javafx/PSurfaceFX.java +++ b/core/src/processing/javafx/PSurfaceFX.java @@ -154,7 +154,7 @@ public class PSurfaceFX implements PSurface { //addEventHandler(eventType, eventHandler); - EventHandler mouseHandler = new EventHandler() { + EventHandler mouseHandler = new EventHandler<>() { public void handle(MouseEvent e) { fxMouseEvent(e); } @@ -175,7 +175,7 @@ public class PSurfaceFX implements PSurface { } }); - EventHandler keyHandler = new EventHandler() { + EventHandler keyHandler = new EventHandler<>() { public void handle(KeyEvent e) { fxKeyEvent(e); } @@ -248,12 +248,11 @@ public class PSurfaceFX implements PSurface { // See JEP 263 float renderScale = Screen.getMainScreen().getRecommendedOutputScaleX(); - if (PApplet.platform == PConstants.MACOSX) { + if (PApplet.platform == PConstants.MACOS) { for (Screen s : Screen.getScreens()) { renderScale = Math.max(renderScale, s.getRecommendedOutputScaleX()); } } - float uiScale = Screen.getMainScreen().getRecommendedOutputScaleX(); if (sketch.pixelDensity == 2 && renderScale < 2) { sketch.pixelDensity = 1; sketch.g.pixelDensity = 1; @@ -338,7 +337,7 @@ public class PSurfaceFX implements PSurface { // Workaround for https://bugs.openjdk.java.net/browse/JDK-8136495 // https://github.com/processing/processing/issues/3823 - if ((PApplet.platform == PConstants.MACOSX || + if ((PApplet.platform == PConstants.MACOS || PApplet.platform == PConstants.LINUX) && PApplet.javaVersionName.compareTo("1.8.0_60") >= 0 && PApplet.javaVersionName.compareTo("1.8.0_72") < 0) { @@ -940,7 +939,6 @@ public class PSurfaceFX implements PSurface { } - @SuppressWarnings("deprecation") private int getKeyCode(KeyEvent fxEvent) { if (fxEvent.getEventType() == KeyEvent.KEY_TYPED) { return 0; @@ -957,7 +955,6 @@ public class PSurfaceFX implements PSurface { } - @SuppressWarnings("deprecation") private char getKeyChar(KeyEvent fxEvent) { KeyCode kc = fxEvent.getCode(); diff --git a/core/src/processing/opengl/PGL.java b/core/src/processing/opengl/PGL.java index ecfbb1715..467dd0730 100644 --- a/core/src/processing/opengl/PGL.java +++ b/core/src/processing/opengl/PGL.java @@ -165,6 +165,17 @@ public abstract class PGL { protected boolean usingFrontTex = false; protected boolean needSepFrontTex = false; + /** + * Defines if FBO Layer is allowed in the given environment. + * Using FBO can cause a fatal error during runtime for + * Intel HD Graphics 3000 chipsets (commonly used on older MacBooks) + * #4104 + * The value remains as 'true' unless set false during init. + * TODO There's already code in here to enable/disable the FBO properly, + * this should be making use of that mechanism instead. [fry 191007] + */ + protected boolean fboAllowed = true; + // ........................................................ // Texture rendering @@ -852,10 +863,12 @@ public abstract class PGL { saveFirstFrame(); } - if (!clearColor && 0 < sketch.frameCount || !sketch.isLooping()) { - enableFBOLayer(); - if (SINGLE_BUFFERED) { - createFBOLayer(); + if (fboAllowed) { + if (!clearColor && 0 < sketch.frameCount || !sketch.isLooping()) { + enableFBOLayer(); + if (SINGLE_BUFFERED) { + createFBOLayer(); + } } } } diff --git a/core/src/processing/opengl/PSurfaceJOGL.java b/core/src/processing/opengl/PSurfaceJOGL.java index a9de3f0b8..2b3896982 100644 --- a/core/src/processing/opengl/PSurfaceJOGL.java +++ b/core/src/processing/opengl/PSurfaceJOGL.java @@ -25,6 +25,7 @@ package processing.opengl; import java.awt.Component; +import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Point; @@ -35,6 +36,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.lang.reflect.Method; import java.nio.ByteBuffer; import java.util.HashMap; import java.util.Map; @@ -109,6 +111,7 @@ public class PSurfaceJOGL implements PSurface { protected boolean external = false; + public PSurfaceJOGL(PGraphics graphics) { this.graphics = graphics; this.pgl = (PJOGL) ((PGraphicsOpenGL)graphics).pgl; @@ -174,7 +177,24 @@ public class PSurfaceJOGL implements PSurface { awtDisplayDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); } - displayRect = awtDisplayDevice.getDefaultConfiguration().getBounds(); + GraphicsConfiguration config = awtDisplayDevice.getDefaultConfiguration(); + displayRect = config.getBounds(); + + /** See explanation at {@link PGL#fboAllowed} in PGL */ + if (PApplet.platform == PConstants.MACOS) { + try { + Class cglClass = Class.forName("sun.java2d.opengl.CGLGraphicsConfig"); + Method cglMethod = cglClass.getMethod("getContextCapabilities"); + Class ctcClass = Class.forName("sun.java2d.pipe.hw.ContextCapabilities"); + Method ctcMethod = ctcClass.getMethod("getAdapterId"); + Object cglInstance = cglClass.cast(config); + Object ctcInstance = cglMethod.invoke(cglInstance); + Object idInstance = ctcMethod.invoke(ctcInstance); + if (String.valueOf(idInstance).contains("Intel HD Graphics 3000")) { + pgl.fboAllowed = false; + } + } catch (Exception e) { } + } } @@ -257,7 +277,7 @@ public class PSurfaceJOGL implements PSurface { // window = GLWindow.create(displayDevice.getScreen(), pgl.getCaps()); // } - windowScaleFactor = PApplet.platform == PConstants.MACOSX ? + windowScaleFactor = PApplet.platform == PConstants.MACOS ? 1 : sketch.pixelDensity; boolean spanDisplays = sketch.sketchDisplay() == PConstants.SPAN; @@ -321,7 +341,7 @@ public class PSurfaceJOGL implements PSurface { sketch.setSize(sketchWidth, sketchHeight); float[] reqSurfacePixelScale; - if (graphics.is2X() && PApplet.platform == PConstants.MACOSX) { + if (graphics.is2X() && PApplet.platform == PConstants.MACOS) { // Retina reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; @@ -777,7 +797,7 @@ public class PSurfaceJOGL implements PSurface { return 1; } - if (PApplet.platform == PConstants.MACOSX) { + if (PApplet.platform == PConstants.MACOS) { return getCurrentPixelScale(); } @@ -900,7 +920,7 @@ public class PSurfaceJOGL implements PSurface { public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) { pgl.resetFBOLayer(); pgl.getGL(drawable); - float scale = PApplet.platform == PConstants.MACOSX ? + float scale = PApplet.platform == PConstants.MACOS ? getCurrentPixelScale() : getPixelScale(); setSize((int) (w / scale), (int) (h / scale)); } @@ -1044,7 +1064,7 @@ public class PSurfaceJOGL implements PSurface { } int scale; - if (PApplet.platform == PConstants.MACOSX) { + if (PApplet.platform == PConstants.MACOS) { scale = (int) getCurrentPixelScale(); } else { scale = (int) getPixelScale(); diff --git a/core/todo.txt b/core/todo.txt index a5d49046a..a5f4af95a 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,5 +1,10 @@ -0270 (3.5.4 or 3.6) -_ size() issues on Mojave? +1270 (4.x alpha) +X check for disabling FBO code (fixes Intel HD 3000) +X https://github.com/processing/processing/issues/4104 +X https://github.com/processing/processing/pull/5881 + + +_ size() issues on Mojave? (3.4 works, 3.5.3 does not) _ https://github.com/processing/processing/issues/5791 _ use exit event to set mouseY to 0 on macOS _ https://github.com/processing/processing/pull/5796/files @@ -7,8 +12,14 @@ _ https://github.com/processing/processing/pull/5796/files _ possible fix for precision issues with PDF _ https://github.com/processing/processing/issues/5801#issuecomment-466632459 +_ simple rotateZ() fix +_ https://github.com/processing/processing/pull/5821 +_ https://github.com/processing/processing/issues/5770 + high-ish +_ Update isAccessible() in Table to use JDK 11 reflection methods +_ https://github.com/processing/processing4/issues/3 _ add separator option to loadTable() _ https://github.com/processing/processing/issues/5068 _ make setting the window icon automatic, based on files in local dirs diff --git a/java/.classpath b/java/.classpath index ed2b536c4..b1548185a 100644 --- a/java/.classpath +++ b/java/.classpath @@ -2,11 +2,16 @@ + + + + + + + - - @@ -20,8 +25,5 @@ - - - diff --git a/java/.settings/org.eclipse.jdt.core.prefs b/java/.settings/org.eclipse.jdt.core.prefs index a698e5967..cd8d089a1 100644 --- a/java/.settings/org.eclipse.jdt.core.prefs +++ b/java/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,15 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=11 diff --git a/java/build.xml b/java/build.xml index a46aa4e9d..a942695f7 100644 --- a/java/build.xml +++ b/java/build.xml @@ -54,13 +54,13 @@ + - - + diff --git a/java/mode/jdi.jar b/java/mode/jdi.jar deleted file mode 100755 index df9d0b598..000000000 Binary files a/java/mode/jdi.jar and /dev/null differ diff --git a/java/mode/jdimodel.jar b/java/mode/jdimodel.jar deleted file mode 100755 index 6ecf23739..000000000 Binary files a/java/mode/jdimodel.jar and /dev/null differ diff --git a/java/src/processing/mode/java/Commander.java b/java/src/processing/mode/java/Commander.java index 8cb7c1c47..2a329180c 100644 --- a/java/src/processing/mode/java/Commander.java +++ b/java/src/processing/mode/java/Commander.java @@ -3,7 +3,7 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2012-15 The Processing Foundation + Copyright (c) 2012-19 The Processing Foundation Copyright (c) 2008-12 Ben Fry and Casey Reas This program is free software; you can redistribute it and/or modify @@ -42,8 +42,6 @@ import processing.mode.java.runner.Runner; /** * Class to handle running Processing from the command line. - * - * @author fry */ public class Commander implements RunnerListener { static final String helpArg = "--help"; @@ -65,7 +63,6 @@ public class Commander implements RunnerListener { static final int BUILD = 1; static final int RUN = 2; static final int PRESENT = 3; -// static final int EXPORT_APPLET = 4; static final int EXPORT = 4; Sketch sketch; @@ -74,19 +71,6 @@ public class Commander implements RunnerListener { PrintStream systemErr; - static public void main(String[] args) { - // 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 - Platform.init(); - // make sure a full JDK is installed - //Base.initRequirements(); - - // launch command line handler - new Commander(args); - } - - public Commander(String[] args) { String sketchPath = null; File sketchFolder = null; @@ -152,7 +136,6 @@ public class Commander implements RunnerListener { embedJava = false; } else if (arg.startsWith(platformArg)) { -// complainAndQuit("The --platform option has been removed from Processing 2.1.", false); String platformStr = arg.substring(platformArg.length()); platform = Platform.getIndex(platformStr); if (platform == -1) { @@ -160,17 +143,6 @@ public class Commander implements RunnerListener { "'windows', 'macosx', or 'linux'.", true); } - } else if (arg.startsWith(bitsArg)) { - complainAndQuit("The --bits option has been removed.", false); -// String bitsStr = arg.substring(bitsArg.length()); -// if (bitsStr.equals("32")) { -// platformBits = 32; -// } else if (bitsStr.equals("64")) { -// platformBits = 64; -// } else { -// complainAndQuit("Bits should be either 32 or 64, not " + bitsStr, true); -// } - } else if (arg.startsWith(sketchArg)) { sketchPath = arg.substring(sketchArg.length()); sketchFolder = new File(sketchPath); @@ -199,13 +171,6 @@ public class Commander implements RunnerListener { } String[] sketchArgs = PApplet.subset(args, argOffset); -// if ((outputPath == null) && -// (task == PREPROCESS || task == BUILD || -// task == RUN || task == PRESENT)) { -// complainAndQuit("An output path must be specified when using " + -// preprocArg + ", " + buildArg + ", " + -// runArg + ", or " + presentArg + "."); -// } if (task == HELP) { printCommandLine(systemOut); System.exit(0); @@ -256,8 +221,6 @@ public class Commander implements RunnerListener { boolean success = false; -// JavaMode javaMode = -// new JavaMode(null, Base.getContentFile("modes/java")); JavaMode javaMode = (JavaMode) ModeContribution.load(null, Platform.getContentFile("modes/java"), "processing.mode.java.JavaMode").getMode(); @@ -389,9 +352,6 @@ public class Commander implements RunnerListener { out.println("--no-java Do not embed Java. Use at your own risk!"); out.println("--platform Specify the platform (export to application only)."); out.println(" Should be one of 'windows', 'macosx', or 'linux'."); -// out.println("--bits Must be specified if libraries are used that are"); -// out.println(" 32- or 64-bit specific such as the OpenGL library."); -// out.println(" Otherwise specify 0 or leave it out."); out.println(); out.println("The --build, --run, --present, or --export must be the final parameter"); @@ -406,22 +366,31 @@ public class Commander implements RunnerListener { @Override - public void startIndeterminate() { - } + public void startIndeterminate() { } @Override - public void stopIndeterminate() { - } + public void stopIndeterminate() { } @Override - public void statusHalt() { - } + public void statusHalt() { } @Override public boolean isHalted() { return false; } + + + static public void main(String[] args) { + // 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 + Platform.init(); + + // launch command line handler + new Commander(args); + } } diff --git a/java/src/processing/mode/java/Compiler.java b/java/src/processing/mode/java/Compiler.java index 9bc4baa9e..dac5f5bdc 100644 --- a/java/src/processing/mode/java/Compiler.java +++ b/java/src/processing/mode/java/Compiler.java @@ -31,9 +31,6 @@ import java.io.*; import java.lang.reflect.Method; import java.util.HashMap; -//import org.eclipse.jdt.core.compiler.batch.BatchCompiler; -//import org.eclipse.jdt.core.compiler.CompilationProgress; - public class Compiler { diff --git a/java/src/processing/mode/java/JavaBuild.java b/java/src/processing/mode/java/JavaBuild.java index 5c3e79016..ac7571720 100644 --- a/java/src/processing/mode/java/JavaBuild.java +++ b/java/src/processing/mode/java/JavaBuild.java @@ -24,7 +24,6 @@ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA package processing.mode.java; import java.io.*; -import java.nio.charset.StandardCharsets; import java.util.*; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -230,20 +229,12 @@ public class JavaBuild { outputFolder.mkdirs(); // Base.openFolder(outputFolder); final File java = new File(outputFolder, sketch.getName() + ".java"); - final PrintWriter stream = new PrintWriter(new FileWriter(java, StandardCharsets.UTF_8)); + final PrintWriter stream = PApplet.createWriter(java); try { - result = preprocessor.write( - stream, - bigCode.toString(), - codeFolderPackages - ); + result = preprocessor.write(stream, bigCode.toString(), codeFolderPackages); } finally { stream.close(); } - } catch (FileNotFoundException fnfe) { - fnfe.printStackTrace(); - String msg = "Build folder disappeared or could not be written"; - throw new SketchException(msg); } catch (SketchException pe) { // RunnerExceptions are caught here and re-thrown, so that they don't // get lost in the more general "Exception" handler below. @@ -581,7 +572,7 @@ public class JavaBuild { if (Library.hasMultipleArch(platform, importedLibraries)) { // Don't try to export 32-bit on macOS, because it doesn't exist. - if (platform != PConstants.MACOSX) { + if (platform != PConstants.MACOS) { // export the 32-bit version folder = new File(sketch.getFolder(), "application." + platformName + "32"); if (!exportApplication(folder, platform, "32", embedJava && (bits == 32) && ("x86".equals(arch) || "i386".equals(arch)))) { @@ -656,7 +647,7 @@ public class JavaBuild { File dotAppFolder = null; String jvmRuntime = ""; String jdkPath = null; - if (exportPlatform == PConstants.MACOSX) { + if (exportPlatform == PConstants.MACOS) { dotAppFolder = new File(destFolder, sketch.getName() + ".app"); File contentsOrig = new File(Platform.getJavaHome(), "../../../.."); @@ -759,10 +750,10 @@ public class JavaBuild { // the folder inside the .app package, while Linux and Windows will have a // 'data' folder next to 'lib'. if (sketch.hasDataFolder()) { - if (exportPlatform == PConstants.MACOSX) { - Util.copyDir(sketch.getDataFolder(), new File(jarFolder, "data")); + if (exportPlatform == PConstants.MACOS) { + Util.copyDir(sketch.getDataFolder(), new File(jarFolder, "data")); } else { - Util.copyDir(sketch.getDataFolder(), new File(destFolder, "data")); + Util.copyDir(sketch.getDataFolder(), new File(destFolder, "data")); } } @@ -819,7 +810,7 @@ public class JavaBuild { /// create platform-specific CLASSPATH based on included jars String exportClassPath = null; - if (exportPlatform == PConstants.MACOSX) { + if (exportPlatform == PConstants.MACOS) { exportClassPath = "$JAVAROOT/" + jarList.join(":$JAVAROOT/"); } else if (exportPlatform == PConstants.WINDOWS) { exportClassPath = jarList.join(","); @@ -853,7 +844,7 @@ public class JavaBuild { /// macosx: write out Info.plist (template for classpath, etc) - if (exportPlatform == PConstants.MACOSX) { + if (exportPlatform == PConstants.MACOS) { StringBuilder runOptionsXML = new StringBuilder(); for (String opt : runOptions) { runOptionsXML.append(" "); diff --git a/java/src/processing/mode/java/JavaEditor.java b/java/src/processing/mode/java/JavaEditor.java index 61fd15144..ec8923112 100644 --- a/java/src/processing/mode/java/JavaEditor.java +++ b/java/src/processing/mode/java/JavaEditor.java @@ -1,3 +1,26 @@ +/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ + +/* +Part of the Processing project - http://processing.org + +Copyright (c) 2012-19 The Processing Foundation +Copyright (c) 2004-12 Ben Fry and Casey Reas +Copyright (c) 2001-04 Massachusetts Institute of Technology + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software Foundation, +Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + package processing.mode.java; import java.awt.*; @@ -1098,7 +1121,7 @@ public class JavaEditor extends Editor { if (!tweak) { runtime = jmode.handleLaunch(sketch, listener, present); } else { - runtime = jmode.handleTweak(sketch, listener); + runtime = jmode.handleTweak(sketch, listener, JavaEditor.this); } } } diff --git a/java/src/processing/mode/java/JavaInputHandler.java b/java/src/processing/mode/java/JavaInputHandler.java index 0c02a4418..7d83d9047 100644 --- a/java/src/processing/mode/java/JavaInputHandler.java +++ b/java/src/processing/mode/java/JavaInputHandler.java @@ -3,7 +3,7 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2012-15 The Processing Foundation + Copyright (c) 2012-19 The Processing Foundation Copyright (c) 2004-12 Ben Fry and Casey Reas Copyright (c) 2001-04 Massachusetts Institute of Technology @@ -24,15 +24,15 @@ package processing.mode.java; +import java.awt.event.KeyEvent; +import java.util.Arrays; + import processing.app.Preferences; import processing.app.Sketch; -import processing.app.syntax.*; +import processing.app.syntax.JEditTextArea; +import processing.app.syntax.PdeInputHandler; import processing.app.ui.Editor; -import java.awt.*; -import java.awt.event.*; -import java.util.Arrays; - /** * Filters key events for tab expansion/indent/etc. This is very old code @@ -41,9 +41,9 @@ import java.util.Arrays; */ public class JavaInputHandler extends PdeInputHandler { - /** ctrl-alt on windows and linux, cmd-alt on mac os x */ - static final int CTRL_ALT = ActionEvent.ALT_MASK | - Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); +// /** ctrl-alt on windows and linux, cmd-alt on mac os x */ +// static final int CTRL_ALT = ActionEvent.ALT_MASK | +// Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); public JavaInputHandler(Editor editor) { @@ -66,7 +66,8 @@ public class JavaInputHandler extends PdeInputHandler { Sketch sketch = editor.getSketch(); JEditTextArea textarea = editor.getTextArea(); - if ((event.getModifiers() & InputEvent.META_MASK) != 0) { + if (event.isMetaDown()) { + //if ((event.getModifiers() & InputEvent.META_MASK) != 0) { //event.consume(); // does nothing return false; } @@ -76,8 +77,8 @@ public class JavaInputHandler extends PdeInputHandler { sketch.setModified(true); } - if ((code == KeyEvent.VK_UP) && - ((event.getModifiers() & InputEvent.CTRL_MASK) != 0)) { + if ((code == KeyEvent.VK_UP) && event.isControlDown()) { + //((event.getModifiers() & InputEvent.CTRL_MASK) != 0)) { // back up to the last empty line char contents[] = textarea.getText().toCharArray(); //int origIndex = textarea.getCaretPosition() - 1; @@ -104,7 +105,8 @@ public class JavaInputHandler extends PdeInputHandler { // if the first char, index will be -2 if (index < 0) index = 0; - if ((event.getModifiers() & InputEvent.SHIFT_MASK) != 0) { + //if ((event.getModifiers() & InputEvent.SHIFT_MASK) != 0) { + if (event.isShiftDown()) { textarea.setSelectionStart(caretIndex); textarea.setSelectionEnd(index); } else { @@ -113,8 +115,8 @@ public class JavaInputHandler extends PdeInputHandler { event.consume(); // return true; - } else if ((code == KeyEvent.VK_DOWN) && - ((event.getModifiers() & InputEvent.CTRL_MASK) != 0)) { + } else if ((code == KeyEvent.VK_DOWN) && event.isControlDown()) { + //((event.getModifiers() & InputEvent.CTRL_MASK) != 0)) { char contents[] = textarea.getText().toCharArray(); int caretIndex = textarea.getCaretPosition(); @@ -136,7 +138,8 @@ public class JavaInputHandler extends PdeInputHandler { index++; } - if ((event.getModifiers() & InputEvent.SHIFT_MASK) != 0) { + //if ((event.getModifiers() & InputEvent.SHIFT_MASK) != 0) { + if (event.isShiftDown()) { textarea.setSelectionStart(caretIndex); textarea.setSelectionEnd(index); } else { @@ -146,7 +149,8 @@ public class JavaInputHandler extends PdeInputHandler { // return true; } else if (c == 9) { - if ((event.getModifiers() & InputEvent.SHIFT_MASK) != 0) { + //if ((event.getModifiers() & InputEvent.SHIFT_MASK) != 0) { + if (event.isShiftDown()) { // if shift is down, the user always expects an outdent // http://code.google.com/p/processing/issues/detail?id=458 editor.handleOutdent(); @@ -317,7 +321,8 @@ public class JavaInputHandler extends PdeInputHandler { public boolean handleTyped(KeyEvent event) { char c = event.getKeyChar(); - if ((event.getModifiers() & InputEvent.CTRL_MASK) != 0) { + //if ((event.getModifiers() & InputEvent.CTRL_MASK) != 0) { + if (event.isControlDown()) { // TODO true on typed? [fry 191007] // on linux, ctrl-comma (prefs) being passed through to the editor if (c == KeyEvent.VK_COMMA) { event.consume(); diff --git a/java/src/processing/mode/java/JavaMode.java b/java/src/processing/mode/java/JavaMode.java index c201dd7ca..38b9dddb1 100644 --- a/java/src/processing/mode/java/JavaMode.java +++ b/java/src/processing/mode/java/JavaMode.java @@ -4,7 +4,7 @@ Part of the Processing project - http://processing.org Copyright (c) 2010-11 Ben Fry and Casey Reas - Copyright (c) 2012-15 The Processing Foundation + Copyright (c) 2012-19 The Processing Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 @@ -37,6 +37,7 @@ import processing.app.*; import processing.app.ui.Editor; import processing.app.ui.EditorException; import processing.app.ui.EditorState; + import processing.mode.java.runner.Runner; import processing.mode.java.tweak.SketchParser; @@ -140,10 +141,8 @@ public class JavaMode extends Mode { /** Start a sketch in tweak mode */ public Runner handleTweak(Sketch sketch, - RunnerListener listener) throws SketchException { -// final boolean present) throws SketchException { - final JavaEditor editor = (JavaEditor) listener; - + RunnerListener listener, + JavaEditor editor) throws SketchException { // first try to build the unmodified code JavaBuild build = new JavaBuild(sketch); // String appletClassName = build.build(false); diff --git a/java/src/processing/mode/java/JavaToolbar.java b/java/src/processing/mode/java/JavaToolbar.java index db178be1d..3d7d0dbb3 100644 --- a/java/src/processing/mode/java/JavaToolbar.java +++ b/java/src/processing/mode/java/JavaToolbar.java @@ -21,7 +21,6 @@ package processing.mode.java; import java.awt.event.ActionEvent; -import java.awt.event.InputEvent; import java.util.ArrayList; import java.util.List; @@ -131,7 +130,7 @@ public class JavaToolbar extends EditorToolbar { @Override public void handleRun(int modifiers) { - boolean shift = (modifiers & InputEvent.SHIFT_MASK) != 0; + boolean shift = (modifiers & ActionEvent.SHIFT_MASK) != 0; if (shift) { jeditor.handlePresent(); } else { diff --git a/java/src/processing/mode/java/pdex/CompletionGenerator.java b/java/src/processing/mode/java/pdex/CompletionGenerator.java index 67ad94419..1a9bf0009 100644 --- a/java/src/processing/mode/java/pdex/CompletionGenerator.java +++ b/java/src/processing/mode/java/pdex/CompletionGenerator.java @@ -1790,7 +1790,7 @@ public class CompletionGenerator { // Now parse the expression into an ASTNode object ASTNode nearestNode; - ASTParser parser = ASTParser.newParser(AST.JLS8); + ASTParser parser = ASTParser.newParser(AST.JLS11); parser.setKind(ASTParser.K_EXPRESSION); parser.setSource(phrase.toCharArray()); ASTNode testnode = parser.createAST(null); diff --git a/java/src/processing/mode/java/pdex/util/ProblemFactory.java b/java/src/processing/mode/java/pdex/util/ProblemFactory.java index ea7ee2806..222232ffa 100644 --- a/java/src/processing/mode/java/pdex/util/ProblemFactory.java +++ b/java/src/processing/mode/java/pdex/util/ProblemFactory.java @@ -8,8 +8,6 @@ import processing.app.Problem; import processing.app.ui.Editor; import processing.mode.java.preproc.issue.PdePreprocessIssue; -import java.util.List; - /** * Factory which helps create {Problem}s during preprocessing. diff --git a/java/src/processing/mode/java/pdex/util/RuntimePathBuilder.java b/java/src/processing/mode/java/pdex/util/RuntimePathBuilder.java index f3bc609e0..368fe7405 100644 --- a/java/src/processing/mode/java/pdex/util/RuntimePathBuilder.java +++ b/java/src/processing/mode/java/pdex/util/RuntimePathBuilder.java @@ -20,22 +20,31 @@ along with this program; if not, write to the Free Software Foundation, Inc. package processing.mode.java.pdex.util; -import com.google.classpath.ClassPathFactory; -import processing.app.*; -import processing.mode.java.JavaMode; -import processing.mode.java.pdex.ImportStatement; -import processing.mode.java.pdex.PreprocessedSketch; - import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.nio.file.Paths; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; import java.util.stream.Stream; +import com.google.classpath.ClassPathFactory; + +import processing.app.Library; +import processing.app.Messages; +import processing.app.Sketch; +import processing.app.SketchException; +import processing.app.Util; +import processing.mode.java.JavaMode; +import processing.mode.java.pdex.ImportStatement; +import processing.mode.java.pdex.PreprocessedSketch; + /** * Builder which generates runtime paths using a series of caches. diff --git a/java/src/processing/mode/java/preproc/PdeParseTreeListener.java b/java/src/processing/mode/java/preproc/PdeParseTreeListener.java index c156e73b0..8dd58d23b 100644 --- a/java/src/processing/mode/java/preproc/PdeParseTreeListener.java +++ b/java/src/processing/mode/java/preproc/PdeParseTreeListener.java @@ -51,7 +51,7 @@ public class PdeParseTreeListener extends ProcessingBaseListener { private static final String FULLSCREEN_METHOD_NAME = "fullScreen"; private final int tabSize; - private int headerOffset; +// private int headerOffset; private String sketchName; private boolean isTesting; @@ -633,21 +633,21 @@ public class PdeParseTreeListener extends ProcessingBaseListener { edits.add(CodeEditOperationUtil.createInsertBefore(location, text, rewriter)); } - /** - * Insert text before a location in code. - * - * @param locationToken Character offset from start. - * @param locationOffset - * @param text Text to add. - */ - private void createInsertBefore(int locationToken, int locationOffset, String text) { - edits.add(CodeEditOperationUtil.createInsertBefore( - locationToken, - locationOffset, - text, - rewriter - )); - } +// /** +// * Insert text before a location in code. +// * +// * @param locationToken Character offset from start. +// * @param locationOffset +// * @param text Text to add. +// */ +// private void createInsertBefore(int locationToken, int locationOffset, String text) { +// edits.add(CodeEditOperationUtil.createInsertBefore( +// locationToken, +// locationOffset, +// text, +// rewriter +// )); +// } /** * Insert text after a location in code. diff --git a/java/src/processing/mode/java/runner/Runner.java b/java/src/processing/mode/java/runner/Runner.java index b19d6c030..04897afa4 100644 --- a/java/src/processing/mode/java/runner/Runner.java +++ b/java/src/processing/mode/java/runner/Runner.java @@ -662,10 +662,8 @@ public class Runner implements MessageConsumer { protected Connector findConnector(String connectorName) { -// List connectors = -// com.sun.jdi.Bootstrap.virtualMachineManager().allConnectors(); List connectors = - org.eclipse.jdi.Bootstrap.virtualMachineManager().allConnectors(); + com.sun.jdi.Bootstrap.virtualMachineManager().allConnectors(); // // debug: code to list available connectors // Iterator iter2 = connectors.iterator(); diff --git a/java/src/processing/mode/java/tweak/Handle.java b/java/src/processing/mode/java/tweak/Handle.java index 049397ae8..72dfa5ed3 100644 --- a/java/src/processing/mode/java/tweak/Handle.java +++ b/java/src/processing/mode/java/tweak/Handle.java @@ -23,6 +23,7 @@ package processing.mode.java.tweak; import java.awt.Graphics2D; import java.awt.geom.AffineTransform; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.Comparator; import java.util.Locale; @@ -171,7 +172,7 @@ public class Handle { } else if ("float".equals(type)) { BigDecimal bd = new BigDecimal(value.floatValue()); - bd = bd.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); + bd = bd.setScale(decimalPlaces, RoundingMode.HALF_UP); newValue = bd.floatValue(); strNewValue = String.format(Locale.US, textFormat, newValue.floatValue()); } diff --git a/todo.txt b/todo.txt index 0a779e299..1d72125fa 100755 --- a/todo.txt +++ b/todo.txt @@ -1,10 +1,34 @@ -0270 (3.5.4 or 3.6) +1270 (4.x alpha) X use ctrl-page up/down for tabs on Windows X https://github.com/processing/processing/issues/5794 X fix potential highlighting issue that wasn't selecting portions of text X update AppBundler to use newer SDK, recompile X edit build.xml files and appbundler to preserve more attributes +after the JDK 11 update +X use a new pref for the sketchbook folder location for 4.x +X finish porting ThinkDifferent to use Desktop APIs +X http://openjdk.java.net/jeps/272 +X also roll it into MacPlatform, since less platform-specific code needed +_ Implement reliable getLibraryFolder() and getDocumentsFolder() methods in MacPlatform +_ https://github.com/processing/processing4/issues/9 + +major updates for JDK 11 et al +X https://github.com/processing/processing4/pull/1 +_ go through the comment w/ the various bugs that can be closed +_ remove jdk.hash from build.xml +_ need to make sure the downloader isn't relying on it +_ clean up naming for build/macosx/jdk-0u1.tgz and build/macosx/jdk-11.0.1+13/ +_ fix "WARNING: Illegal reflective access by processing.app.ui.Toolkit to field sun.awt.CGraphicsDevice.scale" warning on startup + +contribs +X tweak mode not working +X https://github.com/processing/processing/issues/5805 +X https://github.com/processing/processing/pull/5909 + +_ selecting a sketch in the Sketch menu no longer opens its window +_ https://github.com/processing/processing/issues/5882 + _ windows anti-malware leaves browser stuck at 100% _ https://github.com/processing/processing/issues/5893 @@ -13,8 +37,9 @@ _ https://github.com/processing/processing/issues/5482 _ https://github.com/processing/processing/issues/5916 _ https://github.com/processing/processing/issues/5823 -fork issues -_ processing-sam/build/macosx/jdk-0u1_macosx_64.tgz +quick fixes +_ rename-variable menu allows Java identifiers +_ https://github.com/processing/processing/pull/5906 from Casey _ Issue with https and downloading the binaries, +Checksums?