aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogdan Gheorghe2013-04-24 14:47:14 (EDT)
committerSilenio Quarti2013-04-24 15:01:21 (EDT)
commit8322e8b9e81139217de98fd6c63b858b55968c0d (patch)
treea1ff69febea6029a029208c6d0f59158e99fc6ca
parentceb1f40aea06dd4c97cc34d765cdfefa4e8bb63f (diff)
downloadorg.eclipse.orion.client-8322e8b9e81139217de98fd6c63b858b55968c0d.zip
org.eclipse.orion.client-8322e8b9e81139217de98fd6c63b858b55968c0d.tar.gz
org.eclipse.orion.client-8322e8b9e81139217de98fd6c63b858b55968c0d.tar.bz2
Bug 369885 - Auto-save feature in editor
-rw-r--r--bundles/org.eclipse.orion.client.core/web/orion/preferences.js16
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/edit/editorPreferences.js64
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/edit/setup.js28
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/globalCommands.js2
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/settings/nls/root/messages.js8
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/widgets/input/Checkbox.js66
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/widgets/input/LabeledCheckbox.js76
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/widgets/settings/EditorSettings.js119
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/widgets/settings/SettingsContainer.js41
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/widgets/themes/ThemePreferences.js3
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/widgets/themes/editor/MiniThemeChooser.js33
11 files changed, 388 insertions, 68 deletions
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/preferences.js b/bundles/org.eclipse.orion.client.core/web/orion/preferences.js
index 2374f39..d36b1b0 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/preferences.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/preferences.js
@@ -388,9 +388,21 @@ define(['require', 'orion/Deferred', 'orion/xhr'], function(require, Deferred, x
PreferencesService.prototype = /** @lends orion.preferences.PreferencesService.prototype */ {
- listenForChangedSettings: function( callback ){
+ listenForChangedSettings: function(key, optScope, callback ){
+ if (!optScope || typeof(optScope) !== "number" || optScope > 7 || optScope < 1) { //$NON-NLS-0$
+ callback = optScope;
+ optScope = PreferencesService.DEFAULT_SCOPE | PreferencesService.LOCAL_SCOPE | PreferencesService.USER_SCOPE;
+ }
+
+ //TODO: only have one window listener that dispatches callbacks
window.addEventListener("storage", callback, false); //$NON-NLS-0$
- return "/orion/preferences/local/themes"; //$NON-NLS-0$
+ if ((PreferencesService.USER_SCOPE & optScope) !== 0 ) {
+ return "/orion/preferences/user" + key; //$NON-NLS-0$
+ } else if ((PreferencesService.LOCAL_SCOPE & optScope) !== 0) {
+ return "/orion/preferences/local" + key; //$NON-NLS-0$
+ }
+
+ return "/orion/preferences/default" + key; //$NON-NLS-0$
},
/**
diff --git a/bundles/org.eclipse.orion.client.ui/web/edit/editorPreferences.js b/bundles/org.eclipse.orion.client.ui/web/edit/editorPreferences.js
new file mode 100644
index 0000000..e028c14
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.ui/web/edit/editorPreferences.js
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * @license
+ * Copyright (c) 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
+ * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ******************************************************************************/
+/*global define*/
+
+define([], function() {
+
+ function EditorPreferences(preferences, callback) {
+ this._preferences = preferences;
+ this._callback = callback;
+ if (callback) {
+ var storageKey = preferences.listenForChangedSettings("/editor/settings", function (e) { //$NON-NLS-0$
+ if (e.key === storageKey) {
+ callback();
+ }
+ }.bind(this));
+ }
+ }
+
+ EditorPreferences.prototype = /** @lends edit.EditorPreferences.prototype */ {
+ _initialize: function(prefs) {
+ var settings = prefs.get("editorSettings");
+ if (!settings) {
+ prefs.put("editorSettings",
+ {
+ autoSaveEnabled:false,
+ autoSaveTimeout:520,
+ autoLoadEnabled:false
+ });
+ }
+ },
+ getPrefs: function(callback) {
+ this._preferences.getPreferences("/editor/settings").then(function(prefs) {
+ this._initialize(prefs);
+ prefs = prefs.get("editorSettings");
+ if (typeof prefs === "string") { //$NON-NLS-0$
+ prefs = JSON.parse(prefs);
+ }
+ callback(prefs);
+ }.bind(this));
+ },
+ setPrefs: function(object, callback) {
+ this._preferences.getPreferences("/editor/settings").then(function(prefs) {
+ prefs.put("editorSettings", object);
+ if (callback) {
+ callback(object);
+ }
+ if (this._callback) {
+ this._callback(object);
+ }
+ }.bind(this));
+ }
+ };
+
+ return {EditorPreferences : EditorPreferences};
+});
+ \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.ui/web/edit/setup.js b/bundles/org.eclipse.orion.client.ui/web/edit/setup.js
index 32518ff..d6d66c8 100644
--- a/bundles/org.eclipse.orion.client.ui/web/edit/setup.js
+++ b/bundles/org.eclipse.orion.client.ui/web/edit/setup.js
@@ -18,11 +18,11 @@ define(['i18n!orion/edit/nls/messages', 'require', 'orion/Deferred', 'orion/webu
'orion/editor/textView', 'orion/editor/textModel',
'orion/editor/projectionTextModel', 'orion/keyBinding','orion/searchAndReplace/textSearcher',
'orion/edit/dispatcher', 'orion/contentTypes', 'orion/PageUtil', 'orion/highlight', 'orion/i18nUtil', 'orion/edit/syntaxmodel',
- 'orion/widgets/themes/ThemePreferences', 'orion/widgets/themes/editor/ThemeData', 'orion/widgets/themes/editor/MiniThemeChooser'],
+ 'orion/widgets/themes/ThemePreferences', 'orion/widgets/themes/editor/ThemeData', 'orion/widgets/themes/editor/MiniThemeChooser', 'edit/editorPreferences'],
function(messages, require, Deferred, lib, mSelection, mStatus, mProgress, mDialogs, mCommandRegistry, mFavorites, mExtensionCommands,
mFileClient, mOperationsClient, mSearchClient, mGlobalCommands, mOutliner, mProblems, mContentAssist, mEditorCommands, mEditorFeatures, mEditor,
mSyntaxchecker, mTextView, mTextModel, mProjectionTextModel, mKeyBinding, mSearcher,
- mDispatcher, mContentTypes, PageUtil, Highlight, i18nUtil, SyntaxModelWirer, mThemePreferences, mThemeData, mThemeChooser) {
+ mDispatcher, mContentTypes, PageUtil, Highlight, i18nUtil, SyntaxModelWirer, mThemePreferences, mThemeData, mThemeChooser, mEditorPreferences) {
var exports = exports || {};
@@ -60,6 +60,19 @@ exports.setUpEditor = function(serviceRegistry, preferences, isReadOnly){
var syntaxModelWirer = new SyntaxModelWirer(serviceRegistry);
var fileClient = new mFileClient.FileClient(serviceRegistry);
var searcher = new mSearchClient.Searcher({serviceRegistry: serviceRegistry, commandService: commandRegistry, fileService: fileClient});
+ var editor;
+ var editorPreferences;
+ var updateSettings = function(prefs) {
+ editor.setAutoSaveTimeout(prefs.autoSaveEnabled ? prefs.autoSaveTimeout : -1);
+ };
+ var updateEditorSettings = function (prefs) {
+ if (!prefs) {
+ editorPreferences.getPrefs(updateSettings);
+ } else {
+ updateSettings(prefs);
+ }
+ };
+ editorPreferences = new mEditorPreferences.EditorPreferences (preferences, updateEditorSettings);
var textViewFactory = function() {
var textView = new mTextView.TextView({
@@ -147,7 +160,7 @@ exports.setUpEditor = function(serviceRegistry, preferences, isReadOnly){
var themePreferences = new mThemePreferences.ThemePreferences(preferences, new mThemeData.ThemeData());
themePreferences.apply();
- var chooser = new mThemeChooser.MiniThemeChooser( themePreferences );
+ var chooser = new mThemeChooser.MiniThemeChooser( themePreferences, editorPreferences);
mGlobalCommands.addSettings( chooser );
mGlobalCommands.setPageTarget({task: "Coding", name: name, target: metadata, //$NON-NLS-0$
@@ -170,7 +183,6 @@ exports.setUpEditor = function(serviceRegistry, preferences, isReadOnly){
}
// Contents
editor.setInput(fileURI, null, contents);
- editor.setAutoSaveTimeout(1000);
editor.showSelection(input.start, input.end, input.line, input.offset, input.length);
commandRegistry.processURL(window.location.href);
});
@@ -472,7 +484,7 @@ exports.setUpEditor = function(serviceRegistry, preferences, isReadOnly){
};
var annotationFactory = new mEditorFeatures.AnnotationFactory();
- var editor = new mEditor.Editor({
+ editor = new mEditor.Editor({
textViewFactory: textViewFactory,
undoStackFactory: new mEditorCommands.UndoCommandFactory(serviceRegistry, commandRegistry, "pageActions"), //$NON-NLS-0$
textDNDFactory: new mEditorFeatures.TextDNDFactory(),
@@ -485,6 +497,11 @@ exports.setUpEditor = function(serviceRegistry, preferences, isReadOnly){
domNode: editorDomNode
});
+ // Editor Settings
+ updateEditorSettings();
+
+
+
// Establishing dependencies on registered services
serviceRegistry.getService("orion.core.marker").addEventListener("problemsChanged", function(event) { //$NON-NLS-1$ //$NON-NLS-0$
editor.showProblems(event.problems);
@@ -504,7 +521,6 @@ exports.setUpEditor = function(serviceRegistry, preferences, isReadOnly){
window.addEventListener("hashchange", function() {inputManager.hashChanged(editor);}, false); //$NON-NLS-0$
inputManager.setInput(window.location.hash, editor);
-
mGlobalCommands.generateBanner("orion-editor", serviceRegistry, commandRegistry, preferences, searcher, editor, editor, escHandler); //$NON-NLS-0$
// Put the make favorite command in our toolbar."
commandRegistry.registerCommandContribution("pageActions", "orion.makeFavorite", 2); //$NON-NLS-1$ //$NON-NLS-0$
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/globalCommands.js b/bundles/org.eclipse.orion.client.ui/web/orion/globalCommands.js
index 543eb31..ae8fa51 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/globalCommands.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/globalCommands.js
@@ -522,7 +522,7 @@ define(['i18n!orion/nls/messages', 'require', 'orion/commonHTMLFragments', 'orio
CLICKED = true;
var TAB_HEIGHT = 24;
- var PANEL_HEIGHT = 150;
+ var PANEL_HEIGHT = 200;
var PANEL_WIDTH = 150;
var BORDER_RADIUS = '3px'; //$NON-NLS-0$
var COLOR = '#555'; //$NON-NLS-0$
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/settings/nls/root/messages.js b/bundles/org.eclipse.orion.client.ui/web/orion/settings/nls/root/messages.js
index 3943208..8e6b356 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/settings/nls/root/messages.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/settings/nls/root/messages.js
@@ -117,5 +117,11 @@ define({
"Do you wish to enable the Key Storage?" : "Do you wish to enable the Key Storage?",
"general": "General",
"validation": "Validation",
- "Deleted git credentials for ${0}" : "Deleted git credentials for ${0}"
+ "Deleted git credentials for ${0}" : "Deleted git credentials for ${0}",
+ "File Management" : "File Management",
+ "Autosave" : "Save",
+ "Autosave Enabled" : "Autosave Enabled",
+ "Save interval" : "Save interval (ms)",
+ "Autoload" : "Load",
+ "Autoload Enabled" : "Autoload Enabled"
});
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/input/Checkbox.js b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/input/Checkbox.js
new file mode 100644
index 0000000..db3b417
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/input/Checkbox.js
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * @license
+ * Copyright (c) 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
+ * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
+ *
+ * Contributors: Anton McConville - IBM Corporation - initial API and implementation
+ ******************************************************************************/
+/*global window console define*/
+/*jslint browser:true*/
+
+define(['orion/objects', 'orion/webui/littlelib'], function(objects, lib) {
+
+ function Checkbox(options, node) {
+ objects.mixin(this, options);
+ this.node = node || document.createElement('div');
+ this.node.innerHTML = this.templateString;
+ this.myfield = lib.$('.setting-control', this.node); //$NON-NLS-0$
+ }
+ objects.mixin(Checkbox.prototype, {
+ templateString: '' + //$NON-NLS-0$
+ '<label>' + //$NON-NLS-0$
+ '<input class="setting-control settingsCheckbox" type="checkbox"/>' + //$NON-NLS-0$
+ '</label>', //$NON-NLS-0$
+
+ show: function(){
+ this.myfield.addEventListener('change', this.change.bind(this)); //$NON-NLS-0$
+ this.postCreate();
+ },
+
+ destroy: function() {
+ if (this.node) {
+ lib.empty(this.node);
+ this.node = null;
+ this.myfield = null;
+ }
+ },
+
+ setStorageItem: function(){
+
+ },
+
+ isChecked : function(){
+ return this.myfield.checked;
+ },
+
+ setChecked : function(value){
+ this.myfield.checked = value;
+ },
+
+ change: function(){
+ var value = this.myfield.value;
+ },
+
+ postCreate: function(){
+ this.myfield.style.width = '20px';
+
+ if( this.editmode && this.editmode === 'readonly' ){ //$NON-NLS-0$
+ this.myfield.setAttribute("disabled", "disabled"); //$NON-NLS-1$ //$NON-NLS-0$
+ }
+ }
+ });
+ return Checkbox;
+}); \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/input/LabeledCheckbox.js b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/input/LabeledCheckbox.js
index b13ff9b..1b75345 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/input/LabeledCheckbox.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/input/LabeledCheckbox.js
@@ -1,70 +1,44 @@
/*******************************************************************************
* @license
- * Copyright (c) 2012 IBM Corporation and others.
+ * Copyright (c) 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0
* (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
* License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
*
- * Contributors: Anton McConville - IBM Corporation - initial API and implementation
+ * Contributors: IBM Corporation - initial API and implementation
******************************************************************************/
-/*global window console define*/
+/*global orion window console define localStorage*/
/*jslint browser:true*/
-define(['orion/objects', 'orion/webui/littlelib'], function(objects, lib) {
+define(['orion/objects', 'orion/webui/littlelib', 'orion/widgets/input/Checkbox'], function(objects, lib, Checkbox) {
- function LabeledCheckbox(options, node) {
- objects.mixin(this, options);
- this.node = node || document.createElement('div');
+ /**
+ * This is just an orion/widgets/input/Select with a label.
+ */
+ function LabeledCheckbox( params, node ){
+ Checkbox.apply(this, arguments);
+ this.mylabel = lib.$(".setting-label", this.node); //$NON-NLS-0$
}
- objects.mixin(LabeledCheckbox.prototype, {
+ objects.mixin(LabeledCheckbox.prototype, Checkbox.prototype, {
templateString: '' + //$NON-NLS-0$
- '<label>' + //$NON-NLS-0$
- '<span class="setting-label"></span>' + //$NON-NLS-2$ //$NON-NLS-0$
- '<input class="setting-control settingsCheckbox" type="checkbox"/>' + //$NON-NLS-0$
- '</label>', //$NON-NLS-0$
-
- show: function(){
- this.node.innerHTML = this.templateString;
- this.mylabel = lib.$('.setting-label', this.node); //$NON-NLS-0$
- this.myfield = lib.$('.setting-control', this.node); //$NON-NLS-0$
- this.myfield.addEventListener('change', this.change.bind(this)); //$NON-NLS-0$
- this.postCreate();
- },
+ '<label>' + //$NON-NLS-0$
+ '<span class="setting-label"></span>' + //$NON-NLS-2$ //$NON-NLS-0$
+ '<input class="setting-control settingsCheckbox" type="checkbox"/>' + //$NON-NLS-0$
+ '</label>', //$NON-NLS-0$
+
+ postCreate: function() {
+ Checkbox.prototype.postCreate.call(this);
+ this.mylabel.textContent = this.fieldlabel + ':'; //$NON-NLS-0$
+ },
destroy: function() {
- if (this.node) {
- lib.empty(this.node);
- this.node = null;
+ Checkbox.prototype.destroy.call(this);
+ if (this.mylabel) {
this.mylabel = null;
- this.myfield = null;
}
- },
+ }
+ });
- setStorageItem: function(){
-
- },
-
- isChecked : function(){
- return this.myfield.checked;
- },
-
- setChecked : function(value){
- this.myfield.checked = value;
- },
-
- change: function(){
- var value = this.myfield.value;
- },
-
- postCreate: function(){
- this.mylabel.textContent = this.fieldlabel + ':'; //$NON-NLS-0$
- this.myfield.style.width = '20px';
-
- if( this.editmode && this.editmode === 'readonly' ){ //$NON-NLS-0$
- this.myfield.setAttribute("disabled", "disabled"); //$NON-NLS-1$ //$NON-NLS-0$
- }
- }
- });
- return LabeledCheckbox;
+ return LabeledCheckbox;
}); \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/settings/EditorSettings.js b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/settings/EditorSettings.js
new file mode 100644
index 0000000..7019e46
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/settings/EditorSettings.js
@@ -0,0 +1,119 @@
+/*globals define*/
+
+define("orion/widgets/settings/EditorSettings", //$NON-NLS-0$
+[
+ 'require', //$NON-NLS-0$
+ 'orion/util', //$NON-NLS-0$
+ 'orion/objects', //$NON-NLS-0$
+ 'orion/webui/littlelib', //$NON-NLS-0$
+ 'i18n!orion/settings/nls/messages', //$NON-NLS-0$
+ 'orion/widgets/input/LabeledTextfield', 'orion/widgets/input/LabeledCheckbox', //$NON-NLS-0$ //$NON-NLS-1$
+ 'orion/widgets/settings/Subsection', //$NON-NLS-0$
+ 'orion/commands'//$NON-NLS-0$
+], function(require, util, objects, lib, messages,LabeledTextfield, LabeledCheckbox, Subsection, commands) {
+
+ function EditorSettings(options, node) {
+ objects.mixin(this, options);
+ this.node = node;
+ this._editorPref = options.preferences; //$NON-NLS-0$
+ }
+ objects.mixin( EditorSettings.prototype, {
+ // TODO these should be real Orion sections, not fake DIVs
+ templateString: '' + //$NON-NLS-0$
+ '<div>' + //$NON-NLS-0$
+ '<div class="sectionWrapper toolComposite">' + //$NON-NLS-0$
+ '<div class="sectionAnchor sectionTitle layoutLeft">${File Management}</div>' + //$NON-NLS-0$
+ '<div id="editorCommands" class="layoutRight sectionActions"></div>' + //$NON-NLS-0$
+ '</div>' + //$NON-NLS-0$
+ '<div class="sections">' + //$NON-NLS-0$
+
+ '</div>' + //$NON-NLS-0$
+ '<div></div>' + //$NON-NLS-0$
+
+ '</div>', //$NON-NLS-0$
+ createElements: function() {
+ this.node.innerHTML = this.templateString;
+ lib.processTextNodes(this.node, messages);
+ this.sections = lib.$('.sections', this.node); //$NON-NLS-0$
+ this.createSections();
+ },
+ createSections: function(){
+ /* - autossave ----------------------------------------------------- */
+ this.autoSaveFields = [
+ new LabeledCheckbox( {fieldlabel:messages['Autosave Enabled']}),
+ new LabeledTextfield( {fieldlabel:messages['Save interval']})
+ ];
+ var autoSaveSubsection = new Subsection( {sectionName: messages['Autosave'], parentNode: this.sections, children: this.autoSaveFields} );
+ autoSaveSubsection.show();
+
+
+ /* - autoload ---------------------------------------------------- */
+ this.autoLoadFields = [
+ new LabeledCheckbox( {fieldlabel:messages['Autoload Enabled']}) //$NON-NLS-0$
+ ];
+ var autoLoadSubsection = new Subsection( {sectionName:messages['Autoload'], parentNode: this.sections, children: this.autoLoadFields } );
+ autoLoadSubsection.show();
+
+ var updateCommand = new commands.Command({
+ name: messages["Update"],
+ tooltip: messages["Update Editor Settings"],
+ id: "orion.updateeditorsettings", //$NON-NLS-0$
+ callback: function(data){
+ this.update(data.items);
+ }.bind(this)
+ });
+
+
+ this.commandService.addCommand(updateCommand);
+ this.commandService.registerCommandContribution('editorSettingCommand', "orion.updateeditorsettings", 1); //$NON-NLS-1$ //$NON-NLS-0$
+ this.commandService.renderCommands('editorSettingCommand', lib.node( 'editorCommands' ), this, this, "button"); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+
+ },
+ valueChanged: function() {
+ var currentPrefs = {
+ autoSaveEnabled: this.autoSaveFields[0].isChecked(),
+ autoSaveTimeout: this.autoSaveFields[1].getValue()
+ };
+ for (var prop in currentPrefs) {
+ if (currentPrefs.hasOwnProperty(prop)) {
+ if (currentPrefs[prop] !== this.oldPrefs[prop]) {
+ return currentPrefs;
+ }
+ }
+ }
+ return undefined;
+ },
+ update: function() {
+ var messageService = this.registry.getService("orion.page.message"); //$NON-NLS-0$
+
+ var checked = this.autoSaveFields[0].isChecked();
+ var timeOut = this.autoSaveFields[1].getValue();
+ var currentPrefs = this.valueChanged();
+ if (currentPrefs) {
+ if (!isNaN(parseFloat(timeOut)) && isFinite(timeOut)) {
+ this._editorPref.setPrefs(currentPrefs, function (){
+ messageService.setProgressResult( {Message:"Editor preferences updated",Severity:"Normal"} );
+ });
+ } else {
+ messageService.setProgressResult( {Message:"Invalid save interval.",Severity:"Error"} );
+ this.autoSaveFields[1].setValue(this.oldAutoInterval);
+ }
+ }
+ },
+ show: function() {
+ this.createElements();
+ this._editorPref.getPrefs(function (editorPrefs) {
+ this.oldPrefs = editorPrefs;
+ this.autoSaveFields[0].setChecked(editorPrefs.autoSaveEnabled);
+ this.autoSaveFields[1].setValue(editorPrefs.autoSaveTimeout);
+ }.bind(this));
+ },
+ destroy: function() {
+ if (this.node) {
+ this.node = null;
+ }
+ }
+ });
+
+ return EditorSettings;
+}); \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/settings/SettingsContainer.js b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/settings/SettingsContainer.js
index 75eefcb..ee1a6b2 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/settings/SettingsContainer.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/settings/SettingsContainer.js
@@ -23,9 +23,12 @@ define(['i18n!orion/settings/nls/messages', 'require', 'orion/globalCommands',
'orion/widgets/themes/container/ThemeData',
'orion/widgets/settings/SplitSelectionLayout',
'orion/widgets/plugin/PluginList',
- 'orion/widgets/settings/UserSettings'
+ 'orion/widgets/settings/UserSettings',
+ 'orion/widgets/settings/EditorSettings',
+ 'edit/editorPreferences'
], function(messages, require, mGlobalCommands, PageUtil, lib, objects, URITemplate,
- ThemeBuilder, SettingsList, mThemePreferences, editorThemeData, containerThemeData, SplitSelectionLayout, PluginList, UserSettings) {
+ ThemeBuilder, SettingsList, mThemePreferences, editorThemeData, containerThemeData, SplitSelectionLayout, PluginList, UserSettings,
+ EditorSettings, mEditorPreferences) {
/**
* @param {Object} options
@@ -52,6 +55,11 @@ define(['i18n!orion/settings/nls/messages', 'require', 'orion/globalCommands',
show: this.showEditorThemeBuilder
},
{
+ id: "editorSettings", //$NON-NLS-0$
+ textContent: 'Editor Settings', // messages["Themes"],
+ show: this.showEditorSettings
+ },
+ {
id: "plugins", //$NON-NLS-0$
textContent: messages["Plugins"],
show: this.showPlugins
@@ -162,6 +170,35 @@ define(['i18n!orion/settings/nls/messages', 'require', 'orion/globalCommands',
this.editorThemeWidget.renderData( themeNode, 'INITIALIZE' );
},
+ showEditorSettings: function(id){
+
+ this.selectCategory(id);
+
+ lib.empty(this.table);
+
+ if (this.editorSettingWidget) {
+ this.editorSettingWidget.destroy();
+ }
+
+ this.updateToolbar(id);
+
+ var editorSettingsNode = document.createElement('div'); //$NON-NLS-0$
+ this.table.appendChild(editorSettingsNode);
+
+ var editorPreferences = new mEditorPreferences.EditorPreferences (this.preferences);
+
+ this.editorSettings = new EditorSettings({
+ registry: this.registry,
+ preferences: editorPreferences,
+ statusService: this.preferencesStatusService,
+ dialogService: this.preferenceDialogService,
+ commandService: this.commandService,
+ userClient: this.userClient
+ }, editorSettingsNode);
+
+ this.editorSettings.show();
+ },
+
showUserSettings: function(id){
this.selectCategory(id);
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/themes/ThemePreferences.js b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/themes/ThemePreferences.js
index 02785e4..889cd6a 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/themes/ThemePreferences.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/themes/ThemePreferences.js
@@ -15,7 +15,8 @@ define([], function() {
function ThemePreferences(preferences, themeData) {
this._preferences = preferences;
this._themeData = themeData;
- var storageKey = preferences.listenForChangedSettings(function(e) {
+ var themeInfo = themeData.getThemeStorageInfo();
+ var storageKey = preferences.listenForChangedSettings(themeInfo.storage, 2, function(e) {
if (e.key === storageKey) {
this.apply();
}
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/themes/editor/MiniThemeChooser.js b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/themes/editor/MiniThemeChooser.js
index 8f6bb4c..11fe56d 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/themes/editor/MiniThemeChooser.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/themes/editor/MiniThemeChooser.js
@@ -11,11 +11,12 @@
/*global orion window console define localStorage*/
/*jslint browser:true*/
-define(['i18n!orion/settings/nls/messages', 'orion/widgets/input/Select'],
- function(messages, Select ) {
+define(['i18n!orion/settings/nls/messages', 'orion/widgets/input/Select', 'orion/widgets/input/Checkbox'],
+ function(messages, Select, Checkbox) {
- function MiniThemeChooser(preferences){
+ function MiniThemeChooser(preferences, editorPrefs){
this.preferences = preferences;
+ this.editorPreferences = editorPrefs;
}
MiniThemeChooser.prototype.template = '<div id="themeContainer">' +
@@ -27,6 +28,10 @@ define(['i18n!orion/settings/nls/messages', 'orion/widgets/input/Select'],
'<span class="settingsPanelLabel">Font Size:</span>' +
'<div id="fontsizepicker"></div>' +
'</div>' +
+ '<div id="autoSavecontainer">' +
+ '<span class="settingsPanelLabel">AutoSave:</span>' +
+ '<div id="autosavecheck"></div>' +
+ '</div>' +
'</div>';
function isDescendant(parent, child) {
@@ -71,8 +76,9 @@ define(['i18n!orion/settings/nls/messages', 'orion/widgets/input/Select'],
node.innerHTML = this.template;
this.preferences.getTheme(function(themeStyles) {
this.addFontSizePicker(themeStyles);
- this.addThemePicker(themeStyles);
+ this.addThemePicker(themeStyles);
}.bind(this));
+ this.addAutoSave();
}
MiniThemeChooser.prototype.appendTo = appendTo;
@@ -140,6 +146,25 @@ define(['i18n!orion/settings/nls/messages', 'orion/widgets/input/Select'],
MiniThemeChooser.prototype.addThemePicker = addThemePicker;
+ function addAutoSave(){
+ var check = document.getElementById( 'autosavecheck' ); //$NON-NLS-0$
+ this.autoSaveCheck = new Checkbox({}, check); //$NON-NLS-0$
+
+ this.editorPreferences.getPrefs(function (editorPrefs) {
+ this.editorPrefs = editorPrefs;
+ this.autoSaveCheck.setChecked(editorPrefs.autoSaveEnabled);
+ }.bind(this));
+
+
+ this.autoSaveCheck.myfield.addEventListener('change', function () { //$NON-NLS-0$
+ this.editorPrefs.autoSaveEnabled = this.autoSaveCheck.myfield.checked;
+ this.editorPreferences.setPrefs(this.editorPrefs);
+ }.bind(this));
+ this.autoSaveCheck.show();
+ }
+
+ MiniThemeChooser.prototype.addAutoSave = addAutoSave;
+
function destroy(){}
MiniThemeChooser.prototype.destroy = destroy;