@@ -2359,7 +2359,8 @@ protected boolean handleOpenInternal(String path) {
23592359 Base .showWarning ("Error" , "Could not create the sketch." , e );
23602360 return false ;
23612361 }
2362- if (Preferences .getBoolean ("editor.watcher" )) {
2362+ // Disabling for 3.0a4
2363+ if (false && Preferences .getBoolean ("editor.watcher" )) {
23632364 initFileChangeListener ();
23642365 }
23652366
@@ -2397,12 +2398,11 @@ public void setWatcherSave() {
23972398 private void initFileChangeListener () {
23982399 try {
23992400 WatchService watchService = FileSystems .getDefault ().newWatchService ();
2400- watcherKey = sketch
2401- .getFolder ()
2402- .toPath ()
2403- .register (watchService , StandardWatchEventKinds .ENTRY_CREATE ,
2404- StandardWatchEventKinds .ENTRY_DELETE ,
2405- StandardWatchEventKinds .ENTRY_MODIFY );
2401+ Path sp = sketch .getFolder ().toPath ();
2402+ watcherKey = sp .register (watchService ,
2403+ StandardWatchEventKinds .ENTRY_CREATE ,
2404+ StandardWatchEventKinds .ENTRY_DELETE ,
2405+ StandardWatchEventKinds .ENTRY_MODIFY );
24062406 } catch (IOException e ) {
24072407 e .printStackTrace ();
24082408 }
@@ -2460,8 +2460,9 @@ private void processFileEvents(List<WatchEvent<?>> events) {
24602460 for (WatchEvent <?> e : events ) {
24612461 boolean sketchFile = false ;
24622462 Path file = ((Path ) e .context ()).getFileName ();
2463+ System .out .println (file );
24632464 for (String s : getMode ().getExtensions ()) {
2464- //if it is a change to a file with a known extension
2465+ // if it is a change to a file with a known extension
24652466 if (file .toString ().endsWith (s )) {
24662467 sketchFile = true ;
24672468 break ;
@@ -2472,11 +2473,11 @@ private void processFileEvents(List<WatchEvent<?>> events) {
24722473 continue ;
24732474 }
24742475
2475- int response = Base
2476- .showYesNoQuestion (Editor .this ,
2477- "File Modified" ,
2478- "Your sketch has been modified externally" ,
2479- "Would you like to reload the sketch?" );
2476+ int response =
2477+ Base .showYesNoQuestion (Editor .this ,
2478+ "File Modified" ,
2479+ "Your sketch has been modified externally" ,
2480+ "Would you like to reload the sketch?" );
24802481 if (response == 0 ) {
24812482 //grab the 'main' code in case this reload tries to delete everything
24822483 File sc = sketch .getMainFile ();
@@ -2486,17 +2487,15 @@ private void processFileEvents(List<WatchEvent<?>> events) {
24862487 header .rebuild ();
24872488 } catch (Exception f ) {
24882489 if (sketch .getCodeCount () < 1 ) {
2489- Base
2490- .showWarning ("Canceling Reload" ,
2491- "You cannot delete the last code file in a sketch!" );
2490+ Base .showWarning ("Canceling Reload" ,
2491+ "You cannot delete the last code file in a sketch." );
24922492 //if they deleted the last file, re-save the SketchCode
24932493 try {
24942494 //make a blank file
24952495 sc .createNewFile ();
24962496 } catch (IOException e1 ) {
24972497 //if that didn't work, tell them it's un-recoverable
2498- Base .showError ("Reload failed" ,
2499- "The sketch contians no code files" , e1 );
2498+ Base .showError ("Reload failed" , "The sketch contains no code files" , e1 );
25002499 //don't try to reload again after the double fail
25012500 //this editor is probably trashed by this point, but a save-as might be possible
25022501 break ;
0 commit comments