| Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/CompilationUnitEditor.java
|
| diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/CompilationUnitEditor.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/CompilationUnitEditor.java
|
| index b724bf5bd1b8b55d54a395936be8fa99c4f505f6..18a67beee06928e022dad3269f881248275e7c05 100644
|
| --- a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/CompilationUnitEditor.java
|
| +++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/CompilationUnitEditor.java
|
| @@ -1069,6 +1069,11 @@ public class CompilationUnitEditor extends DartEditor implements IDartReconcilin
|
| private ListenerList fReconcilingListeners = new ListenerList(ListenerList.IDENTITY);
|
|
|
| /**
|
| + * Auto-save manager
|
| + */
|
| + private AutoSaveDartEditorManager fAutoSaveManager;
|
| +
|
| + /**
|
| * Mutex for the reconciler. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=63898 for a
|
| * description of the problem.
|
| * <p>
|
| @@ -1556,6 +1561,9 @@ public class CompilationUnitEditor extends DartEditor implements IDartReconcilin
|
| fJavaEditorErrorTickUpdater.updateEditorImage(getInputDartElement());
|
| }
|
| }
|
| + if (isAutoSaveEnabled()) {
|
| + installAutoSave();
|
| + }
|
| }
|
|
|
| /*
|
| @@ -1683,6 +1691,14 @@ public class CompilationUnitEditor extends DartEditor implements IDartReconcilin
|
| uninstallTabsToSpacesConverter();
|
| installTabsToSpacesConverter();
|
| }
|
| +
|
| + if (PreferenceConstants.EDITOR_AUTO_SAVE.equals(p)) {
|
| + if (isAutoSaveEnabled()) {
|
| + installAutoSave();
|
| + } else {
|
| + uninstallAutoSave();
|
| + }
|
| + }
|
| }
|
|
|
| } finally {
|
| @@ -1690,6 +1706,12 @@ public class CompilationUnitEditor extends DartEditor implements IDartReconcilin
|
| }
|
| }
|
|
|
| + protected void installAutoSave() {
|
| + uninstallAutoSave();
|
| + fAutoSaveManager = new AutoSaveDartEditorManager(this);
|
| + addReconcileListener(fAutoSaveManager);
|
| + }
|
| +
|
| /*
|
| * @see com.google.dart.tools.ui.editor.JavaEditor#installOverrideIndicator(boolean )
|
| */
|
| @@ -1910,6 +1932,10 @@ public class CompilationUnitEditor extends DartEditor implements IDartReconcilin
|
| }
|
| }
|
|
|
| + private boolean isAutoSaveEnabled() {
|
| + return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_AUTO_SAVE);
|
| + }
|
| +
|
| private void notifyAnalysisServerAboutFileChange() {
|
| IEditorInput input = getEditorInput();
|
| if (input instanceof IFileEditorInput) {
|
| @@ -1943,4 +1969,11 @@ public class CompilationUnitEditor extends DartEditor implements IDartReconcilin
|
| }
|
| });
|
| }
|
| +
|
| + private void uninstallAutoSave() {
|
| + if (fAutoSaveManager != null) {
|
| + removeReconcileListener(fAutoSaveManager);
|
| + fAutoSaveManager = null;
|
| + }
|
| + }
|
| }
|
|
|