diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index ac02d714c..ae90ba51f 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -32,7 +32,6 @@ import java.awt.datatransfer.*; import java.awt.event.*; import java.awt.print.*; import java.io.*; -import java.nio.file.*; import java.util.*; import java.util.List; import java.util.Timer; @@ -2331,8 +2330,6 @@ public abstract class Editor extends JFrame implements RunnerListener { Base.showWarning("Error", "Could not create the sketch.", e); return false; } - initFileChangeListener(); - header.rebuild(); updateTitle(); // Disable untitled setting from previous document, if any @@ -2352,79 +2349,6 @@ public abstract class Editor extends JFrame implements RunnerListener { // return false; // } } - - - //true when the file is saved, before the next scan for updates - private boolean saved; - - private void initFileChangeListener() { - WatchKey key = null; - try { - WatchService watchService = FileSystems.getDefault().newWatchService(); - key = sketch.getFolder().toPath() - .register(watchService, -// StandardWatchEventKinds.ENTRY_CREATE, -// StandardWatchEventKinds.ENTRY_DELETE, - StandardWatchEventKinds.ENTRY_MODIFY); - } catch (IOException e) { - //registring the watch failed, ignore it - } - - final WatchKey finKey = key; - - if (key != null) { - //the key can now be polled for changes in the files - Thread th = new Thread(new Runnable() { - @Override - public void run() { - //polls for changes to the directory - while (true) { - try { - //check every 5s if the file has changed - Thread.sleep(5000); - } catch (InterruptedException e) { - } - List> events = finKey.pollEvents(); - processFileEvents(events); - - //if the directory was deleted, then quit the loop - if (!finKey.isValid()) { - break; - } - } - } - }); - th.start(); - } - } - - /** - * called when a file is changed - * - * @param events - * the list of events that have occured in the registered folder - * (sketch.getFolder()) - */ - private void processFileEvents(List> events) { - for (WatchEvent e : events) { - //if the file was saved, don't prompt anything - if (saved) - break; - if (e.kind().equals(StandardWatchEventKinds.ENTRY_MODIFY)) { - int response = Base - .showYesNoQuestion(Editor.this, "File Modified", - "A file has been modified externally", - "Would you like to reload the sketch?"); - if (response == 0) { - //reload the sketch - sketch.reload(); - } - } else { - //for now, do nothing - } - } - saved = false; - } /** @@ -2479,7 +2403,6 @@ public abstract class Editor extends JFrame implements RunnerListener { statusNotice("Saving..."); try { if (sketch.save()) { - saved = true; statusNotice("Done Saving."); } else { statusEmpty();