aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2011-06-07 22:31:24 (EDT)
committerskaegi2011-06-07 22:35:38 (EDT)
commitd7f8b45a8314b2f1fca967183a891a8fffdced0b (patch)
treec138da09359c568936b426ca4063057b25b8a398
parent9a80dd9a22350e309f3698e0e589c6e0a402204b (diff)
parent91296fbe7553e9d72ad44764fb46cfb53cf7287f (diff)
downloadorg.eclipse.orion.client-d7f8b45a8314b2f1fca967183a891a8fffdced0b.zip
org.eclipse.orion.client-d7f8b45a8314b2f1fca967183a891a8fffdced0b.tar.gz
org.eclipse.orion.client-d7f8b45a8314b2f1fca967183a891a8fffdced0b.tar.bz2
Bug 348405 - preferences.js restructuring to support jsdoc
-rw-r--r--bundles/org.eclipse.orion.client.core/web/orion/outliner.js279
-rw-r--r--bundles/org.eclipse.orion.client.core/web/orion/preferences.js481
-rw-r--r--bundles/org.eclipse.orion.client.core/web/orion/selection.js107
-rw-r--r--bundles/org.eclipse.orion.client.editor/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.orion.client.editor/bundle.properties3
5 files changed, 478 insertions, 393 deletions
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/outliner.js b/bundles/org.eclipse.orion.client.core/web/orion/outliner.js
index 9ffa9bf..2490665 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/outliner.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/outliner.js
@@ -7,145 +7,164 @@
*
* Contributors: IBM Corporation - initial API and implementation
******************************************************************************/
- /*global eclipse:true dojo document window*/
+ /*global define window*/
+
define(['dojo', 'orion/util'], function(dojo, mUtil) {
-var eclipse = eclipse || {};
-
- /**
- * Constructs a new Outliner with the given options.
- * @name eclipse.Outliner
- * @class An Outliner provides an itemized overview of a resource and acts as a selection
- * provider on that resource.
- * @param {Object} options The options object which must specify the parent, serviceRegistry, and an optional selectionService.
- * specifying a selectionService indicates that the selection service should be notified on outline selection rather than using
- * anchor tag hrefs.
- */
-eclipse.Outliner = function(options) {
- this._init(options);
-};
-
-eclipse.Outliner.prototype = {
- _init: function(options) {
- var parent = options.parent;
- if (typeof(parent) === "string") {
- parent = dojo.byId(parent);
- }
- if (!parent) { throw "no parent"; }
- if (!options.serviceRegistry) {throw "no service registry"; }
- this._parent = parent;
- this._selectionService = options.selectionService;
- var outliner = this;
- options.serviceRegistry.getService("orion.edit.outline").then(function(service) {
- service.addEventListener("resourceChanged", function(resource) {
- outliner.render(resource);
- });
- });
+ /**
+ * Constructs a new Outliner with the given options.
+ * @name orion.outliner.Outliner
+ * @class An Outliner provides an itemized overview of a resource and acts as a selection
+ * provider on that resource.
+ * @param {Object} options The options object
+ * @param {Object} options.parent The parent DOM element to put this outliner inside
+ * @param {orion.serviceregistry.ServiceRegistry} options.serviceRegistry The service registry to
+ * use for services required by this outliner.
+ * @param {orion.selection.Selection} [options.selectionService] indicates that the
+ * selection service should be notified on outline selection rather than using anchor tag hrefs.
+ */
+ function Outliner(options) {
+ this._init(options);
+ }
- },
-
- _createLink: function(name, href, parentNode) {
- var link = dojo.create("a", null, parentNode, "last");
- // if there is no selection service, we rely on normal link following
- if (!this._selectionService) {
- link.href = href;
- } else {
- dojo.style(link, "cursor", "pointer");
- }
- dojo.addClass(link, "navlinkonpage");
- dojo.place(document.createTextNode(name), link);
- dojo.create("br", null, parentNode, "last");
- // if a selection service has been specified, we will use it for link selection.
- // Otherwise we assume following the href in the anchor tag is enough.
- if (this._selectionService) {
- var selectionService = this._selectionService;
- var url = href;
- dojo.connect(link, "onclick", link, function(event) {
- if (mUtil.openInNewWindow(event)) {
- mUtil.followLink(url, event);
- } else {
- selectionService.setSelections(url);
- }
+ Outliner.prototype = /** @lends orion.outliner.Outliner.prototype */ {
+ _init: function(options) {
+ var parent = options.parent;
+ if (typeof(parent) === "string") {
+ parent = dojo.byId(parent);
+ }
+ if (!parent) { throw "no parent"; }
+ if (!options.serviceRegistry) {throw "no service registry"; }
+ this._parent = parent;
+ this._selectionService = options.selectionService;
+ var outliner = this;
+ options.serviceRegistry.getService("orion.edit.outline").then(function(service) {
+ service.addEventListener("resourceChanged", function(resource) {
+ outliner.render(resource);
+ });
});
- }
- },
- // this is closely tied to the jslint format right now
- render: function(resource) {
- if (resource.title && resource.title.indexOf(".js") === resource.title.length - 3) {
- var items = dojo.create("div");
- var functions = resource.data.functions;
- for (var k in functions) {
- var f = functions[k];
- var pLength = f.param ? f.param.length : 0;
- var name = f.name;
- var isAnonymousFunction = false;
- if (name[0]==='"') {
- isAnonymousFunction = true;
- f.name = name = name.substring(1, name.length-1);
- // name = "<i>" + name;
- name = name;
- }
- name += "(";
- if (f.param) {
- var first = true;
- for (var l in f.param) {
- if (first) {
- first = false;
- } else {
- name += ",";
+
+ },
+
+ _createLink: function(name, href, parentNode) {
+ var link = dojo.create("a", null, parentNode, "last");
+ // if there is no selection service, we rely on normal link following
+ if (!this._selectionService) {
+ link.href = href;
+ } else {
+ dojo.style(link, "cursor", "pointer");
+ }
+ dojo.addClass(link, "navlinkonpage");
+ dojo.place(window.document.createTextNode(name), link);
+ dojo.create("br", null, parentNode, "last");
+ // if a selection service has been specified, we will use it for link selection.
+ // Otherwise we assume following the href in the anchor tag is enough.
+ if (this._selectionService) {
+ var selectionService = this._selectionService;
+ var url = href;
+ dojo.connect(link, "onclick", link, function(event) {
+ if (mUtil.openInNewWindow(event)) {
+ mUtil.followLink(url, event);
+ } else {
+ selectionService.setSelections(url);
+ }
+ });
+ }
+ },
+ // this is closely tied to the jslint format right now
+ render: function(resource) {
+ var items, name, nonHash, href;
+ if (resource.title && resource.title.indexOf(".js") === resource.title.length - 3) {
+ items = dojo.create("div");
+ var functions = resource.data.functions;
+ for (var k in functions) {
+ var f = functions[k];
+ var pLength = f.param ? f.param.length : 0;
+ name = f.name;
+ var isAnonymousFunction = false;
+ if (name[0]==='"') {
+ isAnonymousFunction = true;
+ f.name = name = name.substring(1, name.length-1);
+ // name = "<i>" + name;
+ name = name;
+ }
+ name += "(";
+ if (f.param) {
+ var first = true;
+ for (var l in f.param) {
+ if (first) {
+ first = false;
+ } else {
+ name += ",";
+ }
+ name += f.param[l];
}
- name += f.param[l];
}
+ name += ")";
+ if (isAnonymousFunction) {
+ // name += "</i>";
+ }
+ nonHash = window.location.href.split('#')[0];
+ href = nonHash + mUtil.hashFromPosition(resource.title, null, null, f.line, null, null, f.name);
+ this._createLink(name, href, items);
}
- name += ")";
- if (isAnonymousFunction) {
- // name += "</i>";
- }
- var nonHash = window.location.href.split('#')[0];
- var href = nonHash + mUtil.hashFromPosition(resource.title, null, null, f.line, null, null, f.name);
- this._createLink(name, href, items);
- }
- dojo.place(items, this._parent, "only");
- } else if (resource.title.indexOf(".html") === resource.title.length - 5) {
- var items = dojo.create("div");
- var pattern = /id=['"]\S*["']/gi; // experimental: |<head[^>]*|<body[^>]*|<script[^>]*/gi;
- var result;
- while ((result = pattern.exec(resource.contents)) !== null) {
- var start, end, name;
- start = result.index;
- name = result[0];
- if (name[0]==='<') {
- name = "&lt;" + name.substring(1) + "&gt;";
- start += 1;
- end = start + name.length;
- } else {
- start += 4;
- name = name.substring(4, name.length-1);
- end = start+name.length;
+ dojo.place(items, this._parent, "only");
+ } else if (resource.title.indexOf(".html") === resource.title.length - 5) {
+ items = dojo.create("div");
+ var pattern = /id=['"]\S*["']/gi; // experimental: |<head[^>]*|<body[^>]*|<script[^>]*/gi;
+ var result;
+ while ((result = pattern.exec(resource.contents)) !== null) {
+ var start, end;
+ start = result.index;
+ name = result[0];
+ if (name[0]==='<') {
+ name = "&lt;" + name.substring(1) + "&gt;";
+ start += 1;
+ end = start + name.length;
+ } else {
+ start += 4;
+ name = name.substring(4, name.length-1);
+ end = start+name.length;
+ }
+ nonHash = window.location.href.split('#')[0];
+ href = nonHash + mUtil.hashFromPosition(resource.title, start, end);
+ this._createLink(name, href, items);
}
- var nonHash = window.location.href.split('#')[0];
- var href = nonHash + mUtil.hashFromPosition(resource.title, start, end);
- this._createLink(name, href, items);
+ dojo.place(items, this._parent, "only");
}
- dojo.place(items, this._parent, "only");
- }
- }
-};
-
-eclipse.OutlineService = function(serviceRegistry) {
- this._serviceRegistry = serviceRegistry;
- this._serviceRegistration = serviceRegistry.registerService("orion.edit.outline", this);
-};
-
-eclipse.OutlineService.prototype = {
- // provider
- _setItems: function(resource) {
- this.resource = resource;
- this._serviceRegistration.dispatchEvent("resourceChanged", resource);
-
- }
-};
+ }
+ };
+ Outliner.prototype.constructor = Outliner;
+
+ /**
+ * Constructs a new outline service. Clients should obtain an outline service
+ * by requesting the service <tt>orion.edit.outline</tt> from the service registry.
+ * This service constructor is only intended to be used by page service registry
+ * initialization code.
+ * @name orion.outliner.OutlineService
+ * @class The outline service cannot currently be used by clients.
+ * @param {orion.serviceregistry.ServiceRegistry} serviceRegistry The service registry to
+ * use for services required by this outline service.
+ */
+ function OutlineService(serviceRegistry) {
+ this._serviceRegistry = serviceRegistry;
+ this._serviceRegistration = serviceRegistry.registerService("orion.edit.outline", this);
+ }
+
+ OutlineService.prototype = /** @lends orion.outliner.OutlineService.prototype */ {
+ // provider
+ _setItems: function(resource) {
+ this.resource = resource;
+ this._serviceRegistration.dispatchEvent("resourceChanged", resource);
+
+ }
+ };
+ OutlineService.prototype.constructor = OutlineService;
-return eclipse;
+ //return module exports
+ return {
+ Outliner: Outliner,
+ OutlineService: OutlineService
+ };
});
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 76b77ee..abb98b7 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/preferences.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/preferences.js
@@ -8,250 +8,303 @@
* Contributors: IBM Corporation - initial API and implementation
******************************************************************************/
-/*global dojo window handleGetAuthenticationError handlePutAuthenticationError console setTimeout localStorage*/
-
-/**
- * @namespace The global container for eclipse APIs.
- */
+/*global define window localStorage */
define(['dojo', 'orion/auth'], function(dojo, mAuth){
-
-var eclipse = eclipse || {};
-
-eclipse.Preferences = function(_name, _userProvider, _defaultsProvider) {
-
- var _flushPending = false;
- var _store;
- var _defaults;
-
- function _flush() {
- return _userProvider.put(_name, _store);
- }
-
- function _scheduleFlush() {
- if (_flushPending) {
- return;
- }
- _flushPending = true;
- window.setTimeout( function() {
- if (_flushPending) {
- _flushPending = false;
- _flush();
+
+ /**
+ * Constructs a new preferences instance. This constructor is not
+ * intended to be used by clients. Preferences should instead be
+ * obtained from a preference service
+ * @class A preferences object returned by the preferences service
+ * @name orion.preferences.Preferences
+ * @see orion.preferences.PreferencesService
+ */
+ function Preferences(_name, _userProvider, _defaultsProvider) {
+ this._name = _name;
+ this._userProvider = _userProvider;
+ this._defaultsProvider = _defaultsProvider;
+ this._flushPending = false;
+ this._store = null;
+ this._defaults = null;
+ }
+ Preferences.prototype = /** @lends orion.preferences.Preferences.prototype */ {
+
+ _flush: function() {
+ return this._userProvider.put(this._name, this._store);
+ },
+
+ _scheduleFlush: function() {
+ if (this._flushPending) {
+ return;
}
- },0);
- }
-
- this.keys = function() {
- var i,
- result = [];
- for (i in _store) {
- if (_store.hasOwnProperty(i) && i.charAt(0) !== '/') {
- result.push(i);
+ this._flushPending = true;
+ window.setTimeout(dojo.hitch(this, function() {
+ if (this._flushPending) {
+ this._flushPending = false;
+ this._flush();
+ }
+ }),0);
+ },
+
+ /**
+ * Returns an array of String preference keys available in this node.
+ */
+ keys: function() {
+ var i,
+ result = [];
+ for (i in this._store) {
+ if (this._store.hasOwnProperty(i) && i.charAt(0) !== '/') {
+ result.push(i);
+ }
}
- }
- for (i in _defaults) {
- if (_defaults.hasOwnProperty(i) && !_store.hasOwnProperty(i) && i.charAt(0) !== '/') {
- result.push(i);
+ for (i in this._defaults) {
+ if (this._defaults.hasOwnProperty(i) && !this._store.hasOwnProperty(i) && i.charAt(0) !== '/') {
+ result.push(i);
+ }
}
- }
- return result;
- };
-
- this.get = function(key) {
- if (key.charAt(0) === '/') {
- throw new Error("Bad character in key name: " + key);
- }
- return _store.hasOwnProperty(key) ? _store[key] : _defaults[key];
- };
-
- this.put = function(key, value) {
- if (key.charAt(0) === '/') {
- throw new Error("Bad character in key name: " + key);
- }
-
- if (_store[key] !== value) {
- _store[key] = value;
- _scheduleFlush();
- }
+ return result;
+ },
+
+ /**
+ * Returns the value of the preference with the given key
+ * @param {String} key The preference key to return
+ */
+ get: function(key) {
+ if (key.charAt(0) === '/') {
+ throw new Error("Bad character in key name: " + key);
+ }
+ return this._store.hasOwnProperty(key) ? this._store[key] : this._defaults[key];
+ },
+
+ /**
+ * Associates a new preference value with the given key,
+ * replacing any existing value.
+ * @param {String} key The preference key
+ * @param {String} value The preference value
+ */
+ put: function(key, value) {
+ if (key.charAt(0) === '/') {
+ throw new Error("Bad character in key name: " + key);
+ }
+
+ if (this._store[key] !== value) {
+ this._store[key] = value;
+ this._scheduleFlush();
+ }
+ },
+
+ /**
+ * Removes the preference with the given key. Has no
+ * effect if no such key is defined.
+ * @param {String} key The preference key to remove
+ */
+ remove: function(key) {
+ if (key.charAt(0) === '/') {
+ throw new Error("Bad character in key name: " + key);
+ }
+
+ if (this._store[key]) {
+ delete this._store[key];
+ this._scheduleFlush();
+ return true;
+ }
+ return false;
+ },
+
+ /**
+ * Removes all preferences from this preference node.
+ */
+ clear: function() {
+ var i;
+ for (i in this._store) {
+ if (this._store.hasOwnProperty(i) && i.charAt(0) !== '/') {
+ delete this._store[i];
+ }
+ }
+ this._scheduleFlush();
+ },
+
+ /**
+ * Synchronizes this preference node with its storage. Any new values
+ * in the storage area will become available to this preference object.
+ */
+ sync: function() {
+ if(this._flushPending) {
+ this._flushPending = false;
+ return this._flush();
+ }
+ return this._defaultsProvider.get(this._name).then(dojo.hitch(this, function(defaults) {
+ this._defaults = defaults;
+ return this._userProvider.get(this._name).then(dojo.hitch(this, function(store) {
+ this._store = store;
+ }));
+ }));
+ },
+ /**
+ * Flushes all preference changes in this node to its backing storage.
+ * @function
+ */
+ flush: this._flush
};
- this.remove = function(key) {
- if (key.charAt(0) === '/') {
- throw new Error("Bad character in key name: " + key);
- }
-
- if (_store[key]) {
- delete _store[key];
- _scheduleFlush();
- return true;
- }
- return false;
- };
+ function UserPreferencesProvider(location) {
+ this.location = location;
+ this._currentPromise = null;
+ }
+ UserPreferencesProvider.prototype = {
- this.clear = function() {
- var i;
- for (i in _store) {
- if (_store.hasOwnProperty(i) && i.charAt(0) !== '/') {
- delete _store[i];
+ get: function(name) {
+ if (this._currentPromise) {
+ return this._currentPromise;
}
- }
- _scheduleFlush();
- };
-
- this.sync = function() {
- if(_flushPending) {
- _flushPending = false;
- return _flush();
- }
+ var d = new dojo.Deferred();
+ var key = "/orion/preferences/user" + name;
+ var data = localStorage.getItem(key);
+ if (data !== null) {
+ window.setTimeout(function() {
+ d.resolve(JSON.parse(data));
+ },0);
+ } else {
+ this._currentPromise = d;
+ var that = this;
+ dojo.xhrGet({
+ url: this.location + name,
+ headers: {
+ "Orion-Version": "1"
+ },
+ handleAs: "json",
+ timeout: 15000,
+ load: function(jsonData, ioArgs) {
+ localStorage.setItem(key, JSON.stringify(jsonData));
+ that._currentPromise = null;
+ d.resolve(jsonData);
+ },
+ error: function(response, ioArgs) {
+ response.log=false;
+ if (ioArgs.xhr.status === 401) {
+ mAuth.handleGetAuthenticationError(this, ioArgs);
+ } else {
+ that._currentPromise = null;
+ d.resolve({});
+ }
+ },
+ failOk: true
+ });
+ }
+ return d;
+ },
- return _defaultsProvider.get(_name).then(function(defaults) {
- _defaults = defaults;
- return _userProvider.get(_name).then(function(store) {
- _store = store;
- });
- });
- };
-
- this.flush = _flush;
-};
-
-eclipse.UserPreferencesProvider = function(location) {
-
- var _currentPromise;
-
- this.get = function(name) {
- if (_currentPromise) {
- return _currentPromise;
- }
- var d = new dojo.Deferred();
- var key = "/orion/preferences/user" + name;
- var data = localStorage.getItem(key);
- if (data !== null) {
- setTimeout(function() {
- d.resolve(JSON.parse(data));
- },0);
- } else {
- _currentPromise = d;
- dojo.xhrGet({
- url: location + name,
+ put: function(name, data) {
+ var d = new dojo.Deferred();
+ var key = "/orion/preferences/user" + name;
+ var jsonData = JSON.stringify(data);
+ localStorage.setItem(key, jsonData);
+ dojo.xhrPut({
+ url: this.location + name,
+ putData: jsonData,
headers: {
"Orion-Version": "1"
},
handleAs: "json",
+ contentType: "application/json",
timeout: 15000,
load: function(jsonData, ioArgs) {
- localStorage.setItem(key, JSON.stringify(jsonData));
- _currentPromise = null;
- d.resolve(jsonData);
+ d.resolve();
},
error: function(response, ioArgs) {
- response.log=false;
if (ioArgs.xhr.status === 401) {
- mAuth.handleGetAuthenticationError(this, ioArgs);
+ mAuth.handlePutAuthenticationError(this, ioArgs);
} else {
- _currentPromise = null;
- d.resolve({});
+ d.resolve(); // consider throwing here
}
- },
- failOk: true
+ }
});
+ return d;
}
- return d;
};
- this.put = function(name, data) {
- var d = new dojo.Deferred();
- var key = "/orion/preferences/user" + name;
- var jsonData = JSON.stringify(data);
- localStorage.setItem(key, jsonData);
- dojo.xhrPut({
- url: location + name,
- putData: jsonData,
- headers: {
- "Orion-Version": "1"
- },
- handleAs: "json",
- contentType: "application/json",
- timeout: 15000,
- load: function(jsonData, ioArgs) {
- d.resolve();
- },
- error: function(response, ioArgs) {
- if (ioArgs.xhr.status === 401) {
- mAuth.handlePutAuthenticationError(this, ioArgs);
- } else {
- d.resolve(); // consider throwing here
- }
+ function DefaultPreferencesProvider(location) {
+ this.location = location;
+ this._currentPromise = null;
+ }
+ DefaultPreferencesProvider.prototype = {
+
+ get: function(name) {
+ if (this._currentPromise) {
+ return this._currentPromise;
+ }
+ var d = new dojo.Deferred();
+ var data = localStorage.getItem("/orion/preferences/default");
+ if (data !== null) {
+ window.setTimeout(function() {
+ d.resolve(JSON.parse(data)[name] || {});
+ },0);
+ } else {
+ this._currentPromise = d;
+ var that = this;
+ dojo.xhrGet({
+ url: this.location,
+ headers: {
+ "Orion-Version": "1"
+ },
+ handleAs: "json",
+ timeout: 15000,
+ load: function(jsonData, ioArgs) {
+ localStorage.setItem("/orion/preferences/default", JSON.stringify(jsonData));
+ that._currentPromise = null;
+ d.resolve(jsonData[name]|| {});
+ },
+ error: function(response, ioArgs) {
+ if (ioArgs.xhr.status === 401) {
+ mAuth.handleGetAuthenticationError(ioArgs.xhr, ioArgs);
+ } else {
+ that._currentPromise = null;
+ d.resolve({});
+ }
+ }
+ });
}
- });
- return d;
+ return d;
+ }
};
-};
-
-eclipse.DefaultPreferencesProvider = function(location) {
- var _currentPromise;
-
- this.get = function(name) {
- if (_currentPromise) {
- return _currentPromise;
- }
- var d = new dojo.Deferred();
- var data = localStorage.getItem("/orion/preferences/default");
- if (data !== null) {
- setTimeout(function() {
- d.resolve(JSON.parse(data)[name] || {});
- },0);
- } else {
- _currentPromise = d;
- dojo.xhrGet({
- url: location,
- headers: {
- "Orion-Version": "1"
- },
- handleAs: "json",
- timeout: 15000,
- load: function(jsonData, ioArgs) {
- localStorage.setItem("/orion/preferences/default", JSON.stringify(jsonData));
- _currentPromise = null;
- d.resolve(jsonData[name]|| {});
- },
- error: function(response, ioArgs) {
- if (ioArgs.xhr.status === 401) {
- mAuth.handleGetAuthenticationError(ioArgs.xhr, ioArgs);
- } else {
- _currentPromise = null;
- d.resolve({});
- }
- }
+ /**
+ * Constructs a new preference service. Clients should obtain a preference service
+ * by requesting the service <tt>orion.core.preference</tt> from the service registry.
+ * This service constructor is only intended to be used by page service registry
+ * initialization code.
+ * @class The preferences service manages a hierarchical set of preference
+ * nodes. Each node consistents of preference key/value pairs.
+ * @name orion.preferences.PreferencesService
+ * @see orion.preferences.Preferences
+ */
+ function PreferencesService(serviceRegistry, userPreferencesLocation, defaultPreferencesLocation) {
+
+ userPreferencesLocation = userPreferencesLocation || "/prefs/user";
+ defaultPreferencesLocation = defaultPreferencesLocation || "/defaults.pref";
+ this._userProvider = new UserPreferencesProvider(userPreferencesLocation);
+ this._defaultsProvider = new DefaultPreferencesProvider(defaultPreferencesLocation);
+ this._serviceRegistration = serviceRegistry.registerService("orion.core.preference", this);
+ }
+ PreferencesService.prototype = /** @lends orion.preferences.PreferencesService.prototype */ {
+
+ /**
+ * Retrieves the preferences of the given node name.
+ * @param {String} name A slash-delimited path to the preference node to return
+ */
+ getPreferences: function(name) {
+ var preferences = new Preferences(name, this._userProvider, this._defaultsProvider);
+ var promise = preferences.sync().then(function() {
+ return preferences;
});
+ return promise;
}
- return d;
+
};
-};
-
-eclipse.PreferencesService = function(serviceRegistry, userPreferencesLocation, defaultPreferencesLocation) {
-
- userPreferencesLocation = userPreferencesLocation || "/prefs/user";
- defaultPreferencesLocation = defaultPreferencesLocation || "/defaults.pref";
-
- var _userProvider = new eclipse.UserPreferencesProvider(userPreferencesLocation);
- var _defaultsProvider = new eclipse.DefaultPreferencesProvider(defaultPreferencesLocation);
-
- /**
- * Retrieves the preferences of the given node name.
- * @param {String} node Path to a preference node
- */
- this.getPreferences = function(name) {
- var preferences = new eclipse.Preferences(name, _userProvider, _defaultsProvider);
- var promise = preferences.sync().then(function() {
- return preferences;
- });
- return promise;
+ //return module exports
+ return {
+ Preferences: Preferences,
+ PreferencesService: PreferencesService
};
-
- var _serviceRegistration = serviceRegistry.registerService("orion.core.preference", this);
-};
-
-return eclipse;
});
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/selection.js b/bundles/org.eclipse.orion.client.core/web/orion/selection.js
index 4982ad2..1db5ab9 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/selection.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/selection.js
@@ -7,57 +7,68 @@
*
* Contributors: IBM Corporation - initial API and implementation
*******************************************************************************/
- /*global dojo */
+ /*global define */
-/**
- * @namespace The global container for orion APIs.
- */
-
define(["dojo"], function(dojo){
-var orion = orion || {};
-
-/**
- * Selection
- * @class Can provide one or more selections describing objects of interest. Used to
- * establish input and output relationships between components. For example, the selection
- * in one component can serve as the input of another component.
- */
-orion.Selection = function(serviceRegistry) {
- this._serviceRegistry = serviceRegistry;
- this._serviceRegistration = serviceRegistry.registerService("orion.page.selection", this);
- this._selections = [];
-};
-
-orion.Selection.prototype = {
- // consumer
- getSelection : function(onDone) {
- onDone(this._getSingleSelection());
- },
-
- getSelections: function(onDone) {
- onDone(this._selections);
- },
-
- _getSingleSelection: function() {
- if (this._selections && this._selections.length > 0) {
- return this._selections[0];
- }
- return null;
- },
-
- // provider
- setSelections: function(itemOrArray) {
- if (dojo.isArray(itemOrArray)) {
- this._selections = itemOrArray;
- } else if (itemOrArray) {
- this._selections = [itemOrArray];
- } else {
- this._selections = null;
- }
- this._serviceRegistration.dispatchEvent("selectionChanged", this._getSingleSelection(), this._selections);
+ /**
+ * Constructs a new selection service. Clients should obtain a selection service
+ * by requesting the service <tt>orion.page.selection</tt> from the service registry.
+ * This service constructor is only intended to be used by page service registry
+ * initialization code.
+ * @name orion.selection.Selection
+ * @class Can provide one or more selections describing objects of interest. Used to
+ * establish input and output relationships between components. For example, the selection
+ * in one component can serve as the input of another component.
+ */
+ function Selection(serviceRegistry) {
+ this._serviceRegistry = serviceRegistry;
+ this._serviceRegistration = serviceRegistry.registerService("orion.page.selection", this);
+ this._selections = [];
}
-};
+
+ Selection.prototype = /** @lends orion.selection.Selection.prototype */ {
+ /**
+ * Obtains the current single selection and passes it to the provided function.
+ * @param onDone The function to invoke with the selection
+ */
+ getSelection : function(onDone) {
+ //TODO this should return a promise rather than having an onDone parameter
+ onDone(this._getSingleSelection());
+ },
+
+ /**
+ * Obtains all current selections and passes them to the provided function.
+ * @param onDone The function to invoke with the selections
+ */
+ getSelections: function(onDone) {
+ onDone(this._selections);
+ },
+
+ _getSingleSelection: function() {
+ if (this._selections && this._selections.length > 0) {
+ return this._selections[0];
+ }
+ return null;
+ },
+
+ /**
+ * Sets the current selection
+ * @param itemOrArray A single selected item or an array of selected items
+ */
+ setSelections: function(itemOrArray) {
+ if (dojo.isArray(itemOrArray)) {
+ this._selections = itemOrArray;
+ } else if (itemOrArray) {
+ this._selections = [itemOrArray];
+ } else {
+ this._selections = null;
+ }
+ this._serviceRegistration.dispatchEvent("selectionChanged", this._getSingleSelection(), this._selections);
+ }
+ };
+ Selection.prototype.constructor = Selection;
-return orion;
+ //return module exports
+ return {Selection: Selection};
}); \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.editor/META-INF/MANIFEST.MF b/bundles/org.eclipse.orion.client.editor/META-INF/MANIFEST.MF
index 41e36ee..042d799 100644
--- a/bundles/org.eclipse.orion.client.editor/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.orion.client.editor/META-INF/MANIFEST.MF
@@ -1,6 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
+Bundle-Vendor: %Bundle-Vendor
Bundle-SymbolicName: org.eclipse.orion.client.editor
Bundle-Version: 0.1.0.qualifier
Bundle-Localization: bundle
diff --git a/bundles/org.eclipse.orion.client.editor/bundle.properties b/bundles/org.eclipse.orion.client.editor/bundle.properties
index 39ab72b..c0945fb 100644
--- a/bundles/org.eclipse.orion.client.editor/bundle.properties
+++ b/bundles/org.eclipse.orion.client.editor/bundle.properties
@@ -1,2 +1,3 @@
#Properties file for org.eclipse.orion.client.editor
-Bundle-Name = Orion Editor (Incubation) \ No newline at end of file
+Bundle-Name = Orion Editor (Incubation)
+Bundle-Vendor = Eclipse.org - Orion