mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
start work on protocol handler; first on macOS
This commit is contained in:
@@ -26,6 +26,8 @@ package processing.app.platform;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Font;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
@@ -37,6 +39,7 @@ import com.sun.jna.Native;
|
||||
|
||||
import processing.app.Base;
|
||||
import processing.app.Preferences;
|
||||
import processing.app.Util;
|
||||
import processing.app.ui.Toolkit;
|
||||
import processing.awt.ShimAWT;
|
||||
import processing.core.PApplet;
|
||||
@@ -95,6 +98,37 @@ public class DefaultPlatform {
|
||||
|
||||
public void initBase(Base base) {
|
||||
this.base = base;
|
||||
|
||||
final Desktop desktop = Desktop.getDesktop();
|
||||
desktop.setOpenURIHandler((event) -> {
|
||||
// https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/net/URI.html
|
||||
URI uri = event.getURI();
|
||||
String location = uri.toString().substring(6);
|
||||
if (location.length() > 0) {
|
||||
System.out.println("location is " + location);
|
||||
// if it leads with a slash, then it's a file url
|
||||
if (location.charAt(0) == '/') {
|
||||
base.handleOpen(location); // it's a full path to a file
|
||||
} else {
|
||||
// turn it into an https url
|
||||
final String url = "https://" + location;
|
||||
if (location.toLowerCase().endsWith(".pdez") ||
|
||||
location.toLowerCase().endsWith(".pdex")) {
|
||||
String extension = location.substring(location.length() - 5);
|
||||
try {
|
||||
File tempFile = File.createTempFile("scheme", extension);
|
||||
if (PApplet.saveStream(tempFile, Util.createInput(url))) {
|
||||
base.handleOpen(tempFile.getAbsolutePath());
|
||||
} else {
|
||||
System.err.println("Could not open " + tempFile);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -571,6 +571,10 @@
|
||||
role="Viewer">
|
||||
</bundledocument>
|
||||
|
||||
<scheme value="pde">
|
||||
<!-- implements pde:// scheme for URLs -->
|
||||
</scheme>
|
||||
|
||||
<!-- !@#*&$ the @2x splash screen implementation was removed by Oracle -->
|
||||
<!-- tiffutil -cathidpicheck about.png about\@2x.png -out about.tiff -->
|
||||
<!--<option value="-splash:$APP_ROOT/Contents/Java/lib/about.png" />-->
|
||||
|
||||
@@ -3,6 +3,11 @@ X application exported to the wrong folder
|
||||
X https://github.com/processing/processing4/issues/601
|
||||
X more /tmp folder problems with Linux (may be the subdirectories?)
|
||||
_ https://github.com/processing/processing4/issues/666
|
||||
_ add a protocol handler for pdex and pdez
|
||||
_ https://github.com/processing/processing4/issues/559
|
||||
X implemented for macOS
|
||||
_ need to also warn people about running 'em
|
||||
|
||||
|
||||
python (api changes mean this is 4.2)
|
||||
X move ExportDialog to processing.app.ui (out of Java Mode) so it can be used by Jython
|
||||
@@ -31,8 +36,6 @@ _ export to IntelliJ? how tricky?
|
||||
_ just copy jars to /lib?
|
||||
_ point to binaries in /Applications/Processing.app? (no)
|
||||
|
||||
_ add a protocol handler for pdex and pdez
|
||||
_ https://github.com/processing/processing4/issues/559
|
||||
|
||||
|
||||
known issues
|
||||
|
||||
Reference in New Issue
Block a user