Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/CompilationUnitEditor.java

Issue 11186051: Auto-save for the Dart Editor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 2 nits. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698