@@ -1362,31 +1362,35 @@ private File moveLikeSketchFolder(File pdeFile, String baseName) throws IOExcept
13621362
13631363
13641364 /**
1365- * Handling pde:// URLs
1366- * @param location everything after pde://
1365+ * Handler for pde:// protocol URIs
1366+ * @param schemeUri the full URI, including pde://
13671367 */
1368- public void handleLocation (String location ) {
1369- // if it leads with a slash, then it's a file url
1370- if (location .charAt (0 ) == '/' ) {
1371- handleOpen (location ); // it's a full path to a file
1372- } else {
1373- // turn it into an https url
1374- final String url = "https://" + location ;
1375- if (location .toLowerCase ().endsWith (".pdez" ) ||
1376- location .toLowerCase ().endsWith (".pdex" )) {
1377- String extension = location .substring (location .length () - 5 );
1378- try {
1379- File tempFile = File .createTempFile ("scheme" , extension );
1380- if (PApplet .saveStream (tempFile , Util .createInput (url ))) {
1381- handleOpen (tempFile .getAbsolutePath ());
1382- } else {
1383- System .err .println ("Could not open " + tempFile );
1368+ public Editor handleScheme (String schemeUri ) {
1369+ String location = schemeUri .substring (6 );
1370+ if (location .length () > 0 ) {
1371+ // if it leads with a slash, then it's a file url
1372+ if (location .charAt (0 ) == '/' ) {
1373+ handleOpen (location ); // it's a full path to a file
1374+ } else {
1375+ // turn it into an https url
1376+ final String url = "https://" + location ;
1377+ if (location .toLowerCase ().endsWith (".pdez" ) ||
1378+ location .toLowerCase ().endsWith (".pdex" )) {
1379+ String extension = location .substring (location .length () - 5 );
1380+ try {
1381+ File tempFile = File .createTempFile ("scheme" , extension );
1382+ if (PApplet .saveStream (tempFile , Util .createInput (url ))) {
1383+ return handleOpen (tempFile .getAbsolutePath ());
1384+ } else {
1385+ System .err .println ("Could not open " + tempFile );
1386+ }
1387+ } catch (IOException e ) {
1388+ e .printStackTrace ();
13841389 }
1385- } catch (IOException e ) {
1386- e .printStackTrace ();
13871390 }
13881391 }
13891392 }
1393+ return null ;
13901394 }
13911395
13921396
@@ -1395,6 +1399,10 @@ public void handleLocation(String location) {
13951399 * Note that the user may have selected/double-clicked any .pde in a sketch.
13961400 */
13971401 public Editor handleOpen (String path ) {
1402+ if (path .startsWith ("pde://" )) {
1403+ return handleScheme (path );
1404+ }
1405+
13981406 if (path .endsWith (SKETCH_BUNDLE_EXT )) {
13991407 return openSketchBundle (path );
14001408
0 commit comments