diff --git a/src/os/mainctrl.js b/src/os/mainctrl.js index 486270ee2..8fd0bb034 100644 --- a/src/os/mainctrl.js +++ b/src/os/mainctrl.js @@ -255,7 +255,7 @@ os.MainCtrl = function($scope, $element, $compile, $timeout, $injector) { os.ui.exportManager.registerPersistenceMethod(new os.file.persist.FilePersistence()); // set state manager global reference - os.ui.stateManager = os.state.StateManager.getInstance(); + os.stateManager = os.state.StateManager.getInstance(); // set up clear control os.ui.clearManager.addEntry(new os.ui.clear.ClearEntry('exclusionAreas', 'Exclusion Areas', @@ -757,7 +757,7 @@ os.MainCtrl.prototype.handleKeyEvent_ = function(event) { if (ctrlOr) { os.metrics.Metrics.getInstance().updateMetric(os.metrics.keys.Map.SAVE_STATE_KB, 1); event.preventDefault(); - os.ui.stateManager.startExport(); + os.stateManager.startExport(); os.ui.apply(this.scope); } break; diff --git a/src/os/ui/state/statemanager.js b/src/os/state/basestatemanager.js similarity index 81% rename from src/os/ui/state/statemanager.js rename to src/os/state/basestatemanager.js index c35a00fb4..baa909ac5 100644 --- a/src/os/ui/state/statemanager.js +++ b/src/os/state/basestatemanager.js @@ -1,6 +1,6 @@ +goog.provide('os.state.BaseStateManager'); +goog.provide('os.state.BaseStateManager.EventType'); goog.provide('os.state.Versions'); -goog.provide('os.ui.state.StateManager'); -goog.provide('os.ui.state.StateManager.EventType'); goog.require('goog.async.Deferred'); goog.require('goog.events.EventTarget'); @@ -19,9 +19,9 @@ goog.require('os.ui.window'); /** * Global state manager reference. Set this in each application with the app-specific manager reference. - * @type {os.ui.state.StateManager} + * @type {os.state.BaseStateManager} */ -os.ui.stateManager = null; +os.stateManager = null; @@ -31,8 +31,8 @@ os.ui.stateManager = null; * @constructor * @template T,S */ -os.ui.state.StateManager = function() { - os.ui.state.StateManager.base(this, 'constructor'); +os.state.BaseStateManager = function() { + os.state.BaseStateManager.base(this, 'constructor'); /** * Content type to use when saving state files. @@ -64,10 +64,10 @@ os.ui.state.StateManager = function() { * @type {goog.log.Logger} * @protected */ - this.log = os.ui.state.StateManager.LOGGER_; + this.log = os.state.BaseStateManager.LOGGER_; }; -goog.inherits(os.ui.state.StateManager, goog.events.EventTarget); -goog.addSingletonGetter(os.ui.state.StateManager); +goog.inherits(os.state.BaseStateManager, goog.events.EventTarget); +goog.addSingletonGetter(os.state.BaseStateManager); /** @@ -76,7 +76,7 @@ goog.addSingletonGetter(os.ui.state.StateManager); * @private * @const */ -os.ui.state.StateManager.LOGGER_ = goog.log.getLogger('os.ui.state.StateManager'); +os.state.BaseStateManager.LOGGER_ = goog.log.getLogger('os.state.BaseStateManager'); /** @@ -95,7 +95,7 @@ os.state.Versions = { * Event types * @enum {string} */ -os.ui.state.StateManager.EventType = { +os.state.BaseStateManager.EventType = { CLEAR: 'clear', DELETE: 'delete' }; @@ -105,7 +105,7 @@ os.ui.state.StateManager.EventType = { * Sets the state export version used by the application. * @param {string} version The state version string */ -os.ui.state.StateManager.prototype.setVersion = function(version) { +os.state.BaseStateManager.prototype.setVersion = function(version) { this.version_ = version; }; @@ -115,7 +115,7 @@ os.ui.state.StateManager.prototype.setVersion = function(version) { * @return {string} * @protected */ -os.ui.state.StateManager.prototype.getVersion = function() { +os.state.BaseStateManager.prototype.getVersion = function() { return this.version_; }; @@ -125,7 +125,7 @@ os.ui.state.StateManager.prototype.getVersion = function() { * @param {string} key The object key * @param {!function(new:os.IPersistable)} clazz The persistable class */ -os.ui.state.StateManager.prototype.registerPersistable = function(key, clazz) { +os.state.BaseStateManager.prototype.registerPersistable = function(key, clazz) { if (!(key in this.persistableMap_)) { this.persistableMap_[key] = clazz; } else { @@ -139,7 +139,7 @@ os.ui.state.StateManager.prototype.registerPersistable = function(key, clazz) { * @param {string} key The object key * @return {os.IPersistable} */ -os.ui.state.StateManager.prototype.getPersistable = function(key) { +os.state.BaseStateManager.prototype.getPersistable = function(key) { if (key in this.persistableMap_) { return new this.persistableMap_[key](); } @@ -154,7 +154,7 @@ os.ui.state.StateManager.prototype.getPersistable = function(key) { * @param {function(new:os.state.IState)} clazz The state class * @param {string=} opt_type The state type */ -os.ui.state.StateManager.prototype.addStateImplementation = function(version, clazz, opt_type) { +os.state.BaseStateManager.prototype.addStateImplementation = function(version, clazz, opt_type) { if (!version) { throw new Error('version cannot be empty or null!'); } @@ -187,7 +187,7 @@ os.ui.state.StateManager.prototype.addStateImplementation = function(version, cl /** * Deactivates all states in the application. */ -os.ui.state.StateManager.prototype.clearStates = function() { +os.state.BaseStateManager.prototype.clearStates = function() { // applications should extend this to actually do something, assuming they can save locally }; @@ -195,7 +195,7 @@ os.ui.state.StateManager.prototype.clearStates = function() { /** * Deletes all local states */ -os.ui.state.StateManager.prototype.deleteStates = function() { +os.state.BaseStateManager.prototype.deleteStates = function() { // applications should extend this to actually do something, assuming they can save locally }; @@ -205,7 +205,7 @@ os.ui.state.StateManager.prototype.deleteStates = function() { * @param {boolean=} opt_allVersions Whether to get all versions. * @return {!Array.} The states */ -os.ui.state.StateManager.prototype.getAvailable = function(opt_allVersions) { +os.state.BaseStateManager.prototype.getAvailable = function(opt_allVersions) { var list = []; if (!opt_allVersions) { @@ -236,7 +236,7 @@ os.ui.state.StateManager.prototype.getAvailable = function(opt_allVersions) { * @param {!os.file.File} file The state file * @param {S} options The state save options */ -os.ui.state.StateManager.prototype.addImportedState = function(file, options) { +os.state.BaseStateManager.prototype.addImportedState = function(file, options) { var url = file.getUrl(); if (url && os.file.isLocal(url)) { // local file, so store it before finishing the import @@ -253,7 +253,7 @@ os.ui.state.StateManager.prototype.addImportedState = function(file, options) { * @param {string} title The title * @return {boolean} If the title has been used */ -os.ui.state.StateManager.prototype.hasState = function(title) { +os.state.BaseStateManager.prototype.hasState = function(title) { return false; }; @@ -263,7 +263,7 @@ os.ui.state.StateManager.prototype.hasState = function(title) { * @param {!os.file.File} file The stored file * @param {S} options The save options */ -os.ui.state.StateManager.prototype.finishImport = function(file, options) { +os.state.BaseStateManager.prototype.finishImport = function(file, options) { // applications should override this function so it does something }; @@ -272,7 +272,7 @@ os.ui.state.StateManager.prototype.finishImport = function(file, options) { * Initiate the state export process. * @param {os.ex.IPersistenceMethod=} opt_method The persistence method */ -os.ui.state.StateManager.prototype.startExport = function(opt_method) { +os.state.BaseStateManager.prototype.startExport = function(opt_method) { var scopeOptions = { 'defaultMethod': opt_method }; @@ -302,7 +302,7 @@ os.ui.state.StateManager.prototype.startExport = function(opt_method) { * @param {string=} opt_tags The tags * @param {Array.=} opt_states The states to save */ -os.ui.state.StateManager.prototype.saveStates = function(method, title, opt_desc, opt_tags, opt_states) { +os.state.BaseStateManager.prototype.saveStates = function(method, title, opt_desc, opt_tags, opt_states) { var obj = this.createStateObject(method, title, opt_desc, opt_tags); var options = this.createStateOptions(method, title, obj, opt_desc, opt_tags); @@ -331,7 +331,7 @@ os.ui.state.StateManager.prototype.saveStates = function(method, title, opt_desc * @param {S} options The state save options * @protected */ -os.ui.state.StateManager.prototype.onSaveSuccess = function(options) { +os.state.BaseStateManager.prototype.onSaveSuccess = function(options) { var content = this.serializeContent(options); var stateFileName = this.getStateFileName(options); goog.asserts.assert(content != null, 'No state content to save!'); @@ -367,7 +367,7 @@ os.ui.state.StateManager.prototype.onSaveSuccess = function(options) { * @param {string} errorMsg The error message * @protected */ -os.ui.state.StateManager.prototype.onSaveError = function(errorMsg) { +os.state.BaseStateManager.prototype.onSaveError = function(errorMsg) { goog.log.error(this.log, 'Failed saving state: ' + errorMsg); }; @@ -376,7 +376,7 @@ os.ui.state.StateManager.prototype.onSaveError = function(errorMsg) { * Removes components of a state file from the application. * @param {string} id The base state id */ -os.ui.state.StateManager.prototype.removeState = function(id) { +os.state.BaseStateManager.prototype.removeState = function(id) { var list = this.getAvailable(true); for (var i = 0, n = list.length; i < n; i++) { try { @@ -395,7 +395,7 @@ os.ui.state.StateManager.prototype.removeState = function(id) { * @param {S} options The save options * @return {boolean} If the operation is supported and succeeded */ -os.ui.state.StateManager.prototype.saveLocal = function(file, options) { +os.state.BaseStateManager.prototype.saveLocal = function(file, options) { // always replace. if we got here the application should have done duplicate file detection already. var fs = os.file.FileStorage.getInstance(); fs.storeFile(file, true).addCallbacks(goog.partial(this.finishImport, file, options), this.onFileError_, this); @@ -409,7 +409,7 @@ os.ui.state.StateManager.prototype.saveLocal = function(file, options) { * @param {*} error * @private */ -os.ui.state.StateManager.prototype.onFileError_ = function(error) { +os.state.BaseStateManager.prototype.onFileError_ = function(error) { if (typeof error === 'string') { goog.log.error(this.log, 'Unable to store state file locally: ' + error); } else { @@ -423,7 +423,7 @@ os.ui.state.StateManager.prototype.onFileError_ = function(error) { * @param {T|string} obj The state * @return {!Array.} Supported states */ -os.ui.state.StateManager.prototype.analyze = goog.abstractMethod; +os.state.BaseStateManager.prototype.analyze = goog.abstractMethod; /** @@ -435,7 +435,7 @@ os.ui.state.StateManager.prototype.analyze = goog.abstractMethod; * @return {T} The save options * @protected */ -os.ui.state.StateManager.prototype.createStateObject = goog.abstractMethod; +os.state.BaseStateManager.prototype.createStateObject = goog.abstractMethod; /** @@ -448,7 +448,7 @@ os.ui.state.StateManager.prototype.createStateObject = goog.abstractMethod; * @return {S} The save options * @protected */ -os.ui.state.StateManager.prototype.createStateOptions = goog.abstractMethod; +os.state.BaseStateManager.prototype.createStateOptions = goog.abstractMethod; /** @@ -456,7 +456,7 @@ os.ui.state.StateManager.prototype.createStateOptions = goog.abstractMethod; * @param {S} options The state options * @return {?string} The file name */ -os.ui.state.StateManager.prototype.getStateFileName = goog.abstractMethod; +os.state.BaseStateManager.prototype.getStateFileName = goog.abstractMethod; /** @@ -466,7 +466,7 @@ os.ui.state.StateManager.prototype.getStateFileName = goog.abstractMethod; * @param {string} stateId The state's identifier * @param {?string=} opt_title The state's title */ -os.ui.state.StateManager.prototype.loadState = goog.abstractMethod; +os.state.BaseStateManager.prototype.loadState = goog.abstractMethod; /** @@ -474,4 +474,4 @@ os.ui.state.StateManager.prototype.loadState = goog.abstractMethod; * @param {S} options The state options * @return {?string} The serialized content */ -os.ui.state.StateManager.prototype.serializeContent = goog.abstractMethod; +os.state.BaseStateManager.prototype.serializeContent = goog.abstractMethod; diff --git a/src/os/ui/state/jsonstatemanager.js b/src/os/state/jsonstatemanager.js similarity index 76% rename from src/os/ui/state/jsonstatemanager.js rename to src/os/state/jsonstatemanager.js index 454223f69..8ccb9cee1 100644 --- a/src/os/ui/state/jsonstatemanager.js +++ b/src/os/state/jsonstatemanager.js @@ -1,34 +1,35 @@ -goog.provide('os.ui.state.JSONStateManager'); +goog.provide('os.state.JSONStateManager'); + goog.require('goog.log'); goog.require('goog.log.Logger'); goog.require('os.config'); goog.require('os.file.FileManager'); goog.require('os.file.mime.jsonstate'); goog.require('os.state'); +goog.require('os.state.BaseStateManager'); goog.require('os.state.JSONStateOptions'); goog.require('os.state.Tag'); goog.require('os.tag'); goog.require('os.ui.im.ImportManager'); -goog.require('os.ui.state.StateManager'); /** * Base JSON state manager. - * @extends {os.ui.state.StateManager., !os.state.JSONStateOptions>} + * @extends {os.state.BaseStateManager., !os.state.JSONStateOptions>} * @constructor */ -os.ui.state.JSONStateManager = function() { - os.ui.state.JSONStateManager.base(this, 'constructor'); +os.state.JSONStateManager = function() { + os.state.JSONStateManager.base(this, 'constructor'); this.contentType = 'application/json'; - this.log = os.ui.state.JSONStateManager.LOGGER_; + this.log = os.state.JSONStateManager.LOGGER_; // register the import UI var im = os.ui.im.ImportManager.getInstance(); im.registerImportDetails(os.config.getAppName('Application') + ' state files.'); im.registerImportUI(os.file.mime.jsonstate.TYPE, new os.ui.state.StateImportUI()); }; -goog.inherits(os.ui.state.JSONStateManager, os.ui.state.StateManager); +goog.inherits(os.state.JSONStateManager, os.state.BaseStateManager); /** @@ -37,13 +38,13 @@ goog.inherits(os.ui.state.JSONStateManager, os.ui.state.StateManager); * @private * @const */ -os.ui.state.JSONStateManager.LOGGER_ = goog.log.getLogger('os.ui.state.JSONStateManager'); +os.state.JSONStateManager.LOGGER_ = goog.log.getLogger('os.state.JSONStateManager'); /** * @inheritDoc */ -os.ui.state.JSONStateManager.prototype.analyze = function(obj) { +os.state.JSONStateManager.prototype.analyze = function(obj) { if (typeof obj === 'string') { var actualObject = /** @type {Object} */ (JSON.parse(obj)); if (actualObject) { @@ -82,7 +83,7 @@ os.ui.state.JSONStateManager.prototype.analyze = function(obj) { /** * @inheritDoc */ -os.ui.state.JSONStateManager.prototype.loadState = function(obj, states, stateId, opt_title) { +os.state.JSONStateManager.prototype.loadState = function(obj, states, stateId, opt_title) { if (obj && states) { if (typeof obj === 'string') { var actualObject = /** @type {Object} */ (JSON.parse(obj)); @@ -114,7 +115,7 @@ os.ui.state.JSONStateManager.prototype.loadState = function(obj, states, stateId /** * @inheritDoc */ -os.ui.state.JSONStateManager.prototype.createStateObject = function(method, title, opt_desc, opt_tags) { +os.state.JSONStateManager.prototype.createStateObject = function(method, title, opt_desc, opt_tags) { var appName = os.config.getAppName('Unknown Application'); var version = os.config.getAppVersion('Unknown Version'); var object = {}; @@ -137,7 +138,7 @@ os.ui.state.JSONStateManager.prototype.createStateObject = function(method, titl /** * @inheritDoc */ -os.ui.state.JSONStateManager.prototype.createStateOptions = function(method, title, obj, opt_desc, opt_tags) { +os.state.JSONStateManager.prototype.createStateOptions = function(method, title, obj, opt_desc, opt_tags) { var options = new os.state.JSONStateOptions(title, obj); options.description = opt_desc || null; options.method = method; @@ -151,7 +152,7 @@ os.ui.state.JSONStateManager.prototype.createStateOptions = function(method, tit /** * @inheritDoc */ -os.ui.state.JSONStateManager.prototype.serializeContent = function(options) { +os.state.JSONStateManager.prototype.serializeContent = function(options) { return options.obj ? JSON.stringify(options.obj) : null; }; @@ -159,6 +160,6 @@ os.ui.state.JSONStateManager.prototype.serializeContent = function(options) { /** * @inheritDoc */ -os.ui.state.JSONStateManager.prototype.getStateFileName = function(options) { +os.state.JSONStateManager.prototype.getStateFileName = function(options) { return options.obj ? options.obj[os.state.Tag.TITLE] + '_state.json' : null; }; diff --git a/src/os/state/statemanager.js b/src/os/state/statemanager.js index cde32aa47..b05230801 100644 --- a/src/os/state/statemanager.js +++ b/src/os/state/statemanager.js @@ -8,6 +8,7 @@ goog.require('os.data.ProviderEntry'); goog.require('os.file.FileStorage'); goog.require('os.state'); goog.require('os.state.StateDescriptor'); +goog.require('os.state.XMLStateManager'); goog.require('os.state.XMLStateOptions'); goog.require('os.state.v2.BaseFilter'); goog.require('os.state.v2.ExclusionArea'); @@ -23,13 +24,12 @@ goog.require('os.state.v4.QueryArea'); goog.require('os.state.v4.TimeState'); goog.require('os.state.v4.ViewState'); goog.require('os.ui.state.StateProvider'); -goog.require('os.ui.state.XMLStateManager'); /** * State manager. - * @extends {os.ui.state.XMLStateManager} + * @extends {os.state.XMLStateManager} * @constructor */ os.state.StateManager = function() { @@ -96,7 +96,7 @@ os.state.StateManager = function() { saveFunctions: [] }; }; -goog.inherits(os.state.StateManager, os.ui.state.XMLStateManager); +goog.inherits(os.state.StateManager, os.state.XMLStateManager); goog.addSingletonGetter(os.state.StateManager); @@ -119,7 +119,7 @@ os.state.StateManager.prototype.clearStates = function() { d.setActive(false); }); - this.dispatchEvent(os.ui.state.StateManager.EventType.CLEAR); + this.dispatchEvent(os.state.BaseStateManager.EventType.CLEAR); }; diff --git a/src/os/state/v2/layerstate.js b/src/os/state/v2/layerstate.js index 4a228173b..8a55e82f1 100644 --- a/src/os/state/v2/layerstate.js +++ b/src/os/state/v2/layerstate.js @@ -462,7 +462,7 @@ os.state.v2.LayerState.prototype.defaultConfigToXML = function(key, value, layer } } else { // classes - var persistObj = os.ui.stateManager.getPersistable(key); + var persistObj = os.stateManager.getPersistable(key); if (persistObj) { // only try this if the key is registered with the state manager try { @@ -493,7 +493,7 @@ os.state.v2.LayerState.prototype.defaultConfigToXML = function(key, value, layer */ os.state.v2.LayerState.prototype.defaultXmlToConfig = function(key, el) { var result = null; - var persistObj = os.ui.stateManager.getPersistable(key); + var persistObj = os.stateManager.getPersistable(key); var value = el.textContent; var children = goog.dom.getChildren(el); diff --git a/src/os/state/v3/layerstate.js b/src/os/state/v3/layerstate.js index 8e91c9ae4..0c6976a55 100644 --- a/src/os/state/v3/layerstate.js +++ b/src/os/state/v3/layerstate.js @@ -523,7 +523,7 @@ os.state.v3.LayerState.prototype.defaultConfigToXML = function(key, value, layer } } else { // classes - var persistObj = os.ui.stateManager.getPersistable(key); + var persistObj = os.stateManager.getPersistable(key); if (persistObj) { // only try this if the key is registered with the state manager try { @@ -554,7 +554,7 @@ os.state.v3.LayerState.prototype.defaultConfigToXML = function(key, value, layer */ os.state.v3.LayerState.prototype.defaultXmlToConfig = function(key, el) { var result = null; - var persistObj = os.ui.stateManager.getPersistable(key); + var persistObj = os.stateManager.getPersistable(key); var value = el.textContent; var children = goog.dom.getChildren(el); diff --git a/src/os/ui/state/xmlstatemanager.js b/src/os/state/xmlstatemanager.js similarity index 73% rename from src/os/ui/state/xmlstatemanager.js rename to src/os/state/xmlstatemanager.js index 63a672912..a72cad3f3 100644 --- a/src/os/ui/state/xmlstatemanager.js +++ b/src/os/state/xmlstatemanager.js @@ -1,4 +1,5 @@ -goog.provide('os.ui.state.XMLStateManager'); +goog.provide('os.state.XMLStateManager'); + goog.require('goog.dom'); goog.require('goog.dom.xml'); goog.require('goog.log'); @@ -7,38 +8,38 @@ goog.require('os.config'); goog.require('os.file.FileManager'); goog.require('os.file.mime.xmlstate'); goog.require('os.state'); +goog.require('os.state.BaseStateManager'); goog.require('os.state.Tag'); goog.require('os.state.XMLStateOptions'); goog.require('os.tag'); goog.require('os.ui.im.ImportManager'); goog.require('os.ui.state.StateImportUI'); -goog.require('os.ui.state.StateManager'); /** * XML state manager. - * @extends {os.ui.state.StateManager.} + * @extends {os.state.BaseStateManager.} * @constructor */ -os.ui.state.XMLStateManager = function() { - os.ui.state.XMLStateManager.base(this, 'constructor'); +os.state.XMLStateManager = function() { + os.state.XMLStateManager.base(this, 'constructor'); this.contentType = 'text/xml'; - this.log = os.ui.state.XMLStateManager.LOGGER_; + this.log = os.state.XMLStateManager.LOGGER_; /** * The namespace URI to use in exported state files * @type {string} * @private */ - this.nsUri_ = os.ui.state.XMLStateManager.NS_URI; + this.nsUri_ = os.state.XMLStateManager.NS_URI; // register the import UI var im = os.ui.im.ImportManager.getInstance(); im.registerImportDetails(os.config.getAppName('Application') + ' state files.'); im.registerImportUI(os.file.mime.xmlstate.TYPE, new os.ui.state.StateImportUI()); }; -goog.inherits(os.ui.state.XMLStateManager, os.ui.state.StateManager); +goog.inherits(os.state.XMLStateManager, os.state.BaseStateManager); /** @@ -47,7 +48,7 @@ goog.inherits(os.ui.state.XMLStateManager, os.ui.state.StateManager); * @private * @const */ -os.ui.state.XMLStateManager.LOGGER_ = goog.log.getLogger('os.ui.state.XMLStateManager'); +os.state.XMLStateManager.LOGGER_ = goog.log.getLogger('os.state.XMLStateManager'); /** @@ -55,24 +56,24 @@ os.ui.state.XMLStateManager.LOGGER_ = goog.log.getLogger('os.ui.state.XMLStateMa * @type {string} * @const */ -// os.ui.state.XMLStateManager.NS_URI = 'http://www.bit-sys.com/state/'; +// os.state.XMLStateManager.NS_URI = 'http://www.bit-sys.com/state/'; // TODO:STATE -> Was the namespace rename intentional? -os.ui.state.XMLStateManager.NS_URI = 'http://www.bit-sys.com/mist/state/'; +os.state.XMLStateManager.NS_URI = 'http://www.bit-sys.com/mist/state/'; /** * @inheritDoc */ -os.ui.state.XMLStateManager.prototype.setVersion = function(version) { - os.ui.state.XMLStateManager.base(this, 'setVersion', version); - this.nsUri_ = os.ui.state.XMLStateManager.NS_URI + version; +os.state.XMLStateManager.prototype.setVersion = function(version) { + os.state.XMLStateManager.base(this, 'setVersion', version); + this.nsUri_ = os.state.XMLStateManager.NS_URI + version; }; /** * @inheritDoc */ -os.ui.state.XMLStateManager.prototype.analyze = function(obj) { +os.state.XMLStateManager.prototype.analyze = function(obj) { if (typeof obj === 'string') { var doc = goog.dom.xml.loadXml(obj); if (doc) { @@ -111,7 +112,7 @@ os.ui.state.XMLStateManager.prototype.analyze = function(obj) { /** * @inheritDoc */ -os.ui.state.XMLStateManager.prototype.loadState = function(obj, states, stateId, opt_title) { +os.state.XMLStateManager.prototype.loadState = function(obj, states, stateId, opt_title) { if (obj && states) { if (typeof obj === 'string') { var doc = goog.dom.xml.loadXml(obj); @@ -143,7 +144,7 @@ os.ui.state.XMLStateManager.prototype.loadState = function(obj, states, stateId, /** * @inheritDoc */ -os.ui.state.XMLStateManager.prototype.createStateObject = function(method, title, opt_desc, opt_tags) { +os.state.XMLStateManager.prototype.createStateObject = function(method, title, opt_desc, opt_tags) { var appName = os.config.getAppName('Unknown Application'); var version = os.config.getAppVersion('Unknown Version'); var doc = goog.dom.xml.createDocument(); @@ -173,7 +174,7 @@ os.ui.state.XMLStateManager.prototype.createStateObject = function(method, title /** * @inheritDoc */ -os.ui.state.XMLStateManager.prototype.createStateOptions = function(method, title, obj, opt_desc, opt_tags) { +os.state.XMLStateManager.prototype.createStateOptions = function(method, title, obj, opt_desc, opt_tags) { var options = new os.state.XMLStateOptions(title, obj); options.description = opt_desc || null; options.method = method; @@ -185,7 +186,7 @@ os.ui.state.XMLStateManager.prototype.createStateOptions = function(method, titl /** * @inheritDoc */ -os.ui.state.XMLStateManager.prototype.serializeContent = function(options) { +os.state.XMLStateManager.prototype.serializeContent = function(options) { return options.doc ? os.xml.serialize(options.doc) : null; }; @@ -193,6 +194,6 @@ os.ui.state.XMLStateManager.prototype.serializeContent = function(options) { /** * @inheritDoc */ -os.ui.state.XMLStateManager.prototype.getStateFileName = function(options) { +os.state.XMLStateManager.prototype.getStateFileName = function(options) { return options.doc ? options.doc.querySelector(os.state.Tag.TITLE).textContent + '_state.xml' : null; }; diff --git a/src/os/ui/data/descriptorprovider.js b/src/os/ui/data/descriptorprovider.js index 04e3afdd3..ca9579207 100644 --- a/src/os/ui/data/descriptorprovider.js +++ b/src/os/ui/data/descriptorprovider.js @@ -58,6 +58,7 @@ os.ui.data.DescriptorProvider.prototype.addDescriptor = function(descriptor, opt * @param {T} descriptor The descriptor * @param {boolean=} opt_clear If data should be cleared on the descriptor * @template T + * @return {goog.Promise|undefined} This function can return a promise if it is asynchronous. */ os.ui.data.DescriptorProvider.prototype.removeDescriptor = function(descriptor, opt_clear) { var node = this.findNode(descriptor); @@ -70,6 +71,8 @@ os.ui.data.DescriptorProvider.prototype.removeDescriptor = function(descriptor, if (opt_clear) { descriptor.clearData(); } + + return undefined; }; diff --git a/src/os/ui/menu/savemenu.js b/src/os/ui/menu/savemenu.js index 18644486d..189e0c159 100644 --- a/src/os/ui/menu/savemenu.js +++ b/src/os/ui/menu/savemenu.js @@ -48,5 +48,5 @@ os.ui.menu.save.dispose = function() { * Save the application state. */ os.ui.menu.save.onSaveState = function() { - os.ui.stateManager.startExport(); + os.stateManager.startExport(); }; diff --git a/src/os/ui/state/abstractstatedescriptor.js b/src/os/ui/state/abstractstatedescriptor.js index c175504cf..02120954f 100644 --- a/src/os/ui/state/abstractstatedescriptor.js +++ b/src/os/ui/state/abstractstatedescriptor.js @@ -11,7 +11,6 @@ goog.require('os.parse.StateParserConfig'); goog.require('os.ui.file.method.UrlMethod'); goog.require('os.ui.file.ui.defaultFileNodeUIDirective'); goog.require('os.ui.state.IStateDescriptor'); -goog.require('os.ui.state.StateManager'); @@ -128,7 +127,7 @@ os.ui.state.AbstractStateDescriptor.prototype.activateState = function(opt_file) // decide whether it's a JSON file or an XML var doc = goog.json.isValid(content) ? JSON.parse(content) : goog.dom.xml.loadXml(content); - var list = os.ui.stateManager.analyze(doc); + var list = os.stateManager.analyze(doc); var loadItems = this.getLoadItems(); if (loadItems) { for (var i = 0, n = list.length; i < n; i++) { @@ -137,7 +136,7 @@ os.ui.state.AbstractStateDescriptor.prototype.activateState = function(opt_file) } } - os.ui.stateManager.loadState(doc, list, this.getId() + '-', this.getTitle()); + os.stateManager.loadState(doc, list, this.getId() + '-', this.getTitle()); } } catch (e) { this.logError('Unable to activate state: ' + e.message, e); @@ -186,10 +185,11 @@ os.ui.state.AbstractStateDescriptor.prototype.onUrlComplete_ = function(event) { var file = method.getFile(); method.dispose(); - if (file) { + var active = this.isActive(); + if (active && file) { this.activateState(file); } else { - this.logError('Unable to load state file from URL!'); + this.logError(active ? 'Unable to load state file from URL!' : 'Descriptor deactivated before file loaded.'); } }; @@ -224,7 +224,7 @@ os.ui.state.AbstractStateDescriptor.prototype.logError = function(msg, opt_e) { * @protected */ os.ui.state.AbstractStateDescriptor.prototype.deactivateState = function() { - os.ui.stateManager.removeState(this.getId() + '-'); + os.stateManager.removeState(this.getId() + '-'); }; diff --git a/src/os/ui/state/cmd/stateclearcmd.js b/src/os/ui/state/cmd/stateclearcmd.js index cc61e3b25..be8d28ea0 100644 --- a/src/os/ui/state/cmd/stateclearcmd.js +++ b/src/os/ui/state/cmd/stateclearcmd.js @@ -39,7 +39,7 @@ os.ui.state.cmd.StateClear.prototype.execute = function() { } } - os.ui.stateManager.clearStates(); + os.stateManager.clearStates(); this.state = os.command.State.SUCCESS; return true; diff --git a/src/os/ui/state/cmd/statedeletecmd.js b/src/os/ui/state/cmd/statedeletecmd.js index d55901328..32f09a886 100644 --- a/src/os/ui/state/cmd/statedeletecmd.js +++ b/src/os/ui/state/cmd/statedeletecmd.js @@ -30,7 +30,7 @@ os.ui.state.cmd.StateDelete.prototype.execute = function() { this.state = os.command.State.EXECUTING; this.lastActive_.length = 0; - os.ui.stateManager.deleteStates(); + os.stateManager.deleteStates(); this.state = os.command.State.SUCCESS; return true; diff --git a/src/os/ui/state/stateexport.js b/src/os/ui/state/stateexport.js index 7025438df..9a947ae64 100644 --- a/src/os/ui/state/stateexport.js +++ b/src/os/ui/state/stateexport.js @@ -68,7 +68,7 @@ os.ui.state.StateExportCtrl = function($scope, $element, $timeout) { /** * @type {Array.} */ - this['states'] = os.ui.stateManager.getAvailable(); + this['states'] = os.stateManager.getAvailable(); /** * @type {boolean} @@ -109,7 +109,7 @@ os.ui.state.StateExportCtrl.prototype.accept = function() { } } } - os.ui.stateManager.saveStates(method, title, description, tags, states); + os.stateManager.saveStates(method, title, description, tags, states); os.ui.state.StateExportCtrl.base(this, 'accept'); }; diff --git a/src/os/ui/state/stateimport.js b/src/os/ui/state/stateimport.js index 09a39cba4..3732c15dc 100644 --- a/src/os/ui/state/stateimport.js +++ b/src/os/ui/state/stateimport.js @@ -71,7 +71,7 @@ os.ui.state.StateImportCtrl = function($scope, $element) { /** * @type {!Array.} */ - this['states'] = os.ui.stateManager.analyze(this.rawState_); + this['states'] = os.stateManager.analyze(this.rawState_); /** * @type {boolean} @@ -139,6 +139,6 @@ os.ui.state.StateImportCtrl.prototype.accept = function() { options.tags = /** @type {?string} */ (this.scope['tags']); options.load = true; - os.ui.stateManager.addImportedState(/** @type {!os.file.File} */ (this.config_['file']), options); + os.stateManager.addImportedState(/** @type {!os.file.File} */ (this.config_['file']), options); os.ui.state.StateImportCtrl.base(this, 'accept'); }; diff --git a/src/os/ui/state/statemenu.js b/src/os/ui/state/statemenu.js index 102cfad4b..edc917c9e 100644 --- a/src/os/ui/state/statemenu.js +++ b/src/os/ui/state/statemenu.js @@ -134,7 +134,7 @@ os.ui.state.menu.onDescriptorChange_ = function(event) { os.ui.state.menu.onStateMenuEvent_ = function(event) { switch (event.type) { case os.ui.state.menu.EventType.SAVE_STATE: - os.ui.stateManager.startExport(); + os.stateManager.startExport(); break; case os.ui.state.menu.EventType.CLEAR_STATES: var cmd = new os.ui.state.cmd.StateClear(); diff --git a/src/os/ui/state/statetitle.js b/src/os/ui/state/statetitle.js index e496cf070..4f6335ca9 100644 --- a/src/os/ui/state/statetitle.js +++ b/src/os/ui/state/statetitle.js @@ -29,7 +29,7 @@ os.ui.state.stateTitleLinkFn = function(scope, element, attrs, ctrl) { // being exported to something other than the application so we don't need to check the title. var valid = true; if (scope['oldTitle'] !== val && scope['stateForm']['persister'] == null) { - valid = !os.ui.stateManager.hasState(val); + valid = !os.stateManager.hasState(val); } ctrl.$setValidity('title', valid); diff --git a/test/os/state/v4/exclusionareastate.test.js b/test/os/state/v4/exclusionareastate.test.js index f5d39fe5c..657ffb7fa 100644 --- a/test/os/state/v4/exclusionareastate.test.js +++ b/test/os/state/v4/exclusionareastate.test.js @@ -4,10 +4,10 @@ goog.require('goog.string'); goog.require('ol.Feature'); goog.require('ol.geom.Polygon'); goog.require('os.query.BaseAreaManager'); +goog.require('os.state.XMLStateManager'); goog.require('os.state.XMLStateOptions'); goog.require('os.state.v2.ExclusionArea'); // v2 state implemention works with v4 goog.require('os.test.xsd'); -goog.require('os.ui.state.XMLStateManager'); goog.require('os.xml'); @@ -31,7 +31,7 @@ describe('QueryArea XSD State Test', function() { // waiting for the xsd files to load waitsFor(function() { - return (resultSchemas && os.ui.state && os.ui.state.StateManager); + return (resultSchemas && os.ui.state && os.state.BaseStateManager); }, 'Wait for XSD(s) to load', 2 * jasmine.DEFAULT_TIMEOUT_INTERVAL); // Runs the tests. diff --git a/test/os/state/v4/filterstate.test.js b/test/os/state/v4/filterstate.test.js index 0ee1a7152..f2850040e 100644 --- a/test/os/state/v4/filterstate.test.js +++ b/test/os/state/v4/filterstate.test.js @@ -2,11 +2,11 @@ goog.require('goog.dom'); goog.require('goog.dom.xml'); goog.require('goog.string'); goog.require('os.filter.FilterEntry'); +goog.require('os.state.XMLStateManager'); goog.require('os.state.XMLStateOptions'); goog.require('os.state.v2.Filter'); // v2 state implemention works with v4 goog.require('os.test.xsd'); goog.require('os.ui.filter.ui.GroupNode'); -goog.require('os.ui.state.XMLStateManager'); goog.require('os.xml'); @@ -36,7 +36,7 @@ describe('Filter XSD State Test', function() { // waiting for the xsd files to load waitsFor(function() { - return (resultSchemas && os.ui.state && os.ui.state.StateManager); + return (resultSchemas && os.ui.state && os.state.BaseStateManager); }, 'Wait for XSD(s) to load', 2 * jasmine.DEFAULT_TIMEOUT_INTERVAL); // Runs the tests. diff --git a/test/os/state/v4/layerstate.test.js b/test/os/state/v4/layerstate.test.js index acce5f44e..da48b38de 100644 --- a/test/os/state/v4/layerstate.test.js +++ b/test/os/state/v4/layerstate.test.js @@ -1,10 +1,10 @@ goog.require('os.layer.Vector'); goog.require('os.ogc.wfs.FeatureType'); goog.require('os.state.StateManager'); +goog.require('os.state.XMLStateManager'); goog.require('os.state.XMLStateOptions'); goog.require('os.state.v4.LayerState'); goog.require('os.test.xsd'); -goog.require('os.ui.state.XMLStateManager'); goog.require('os.xml'); @@ -202,7 +202,7 @@ describe('os.state.v4.LayerState', function() { // waiting for the xsd files to load waitsFor(function() { - return (resultSchemas && os.ui.state && os.ui.state.StateManager); + return (resultSchemas && os.ui.state && os.state.BaseStateManager); }, 'Wait for XSD(s) to load', 2 * jasmine.DEFAULT_TIMEOUT_INTERVAL); // Runs the tests. diff --git a/test/os/state/v4/queryareastate.test.js b/test/os/state/v4/queryareastate.test.js index a86d7c67e..f73b4d78c 100644 --- a/test/os/state/v4/queryareastate.test.js +++ b/test/os/state/v4/queryareastate.test.js @@ -4,10 +4,10 @@ goog.require('goog.string'); goog.require('ol.Feature'); goog.require('ol.geom.Polygon'); goog.require('os.query.BaseAreaManager'); +goog.require('os.state.XMLStateManager'); goog.require('os.state.XMLStateOptions'); goog.require('os.state.v4.QueryArea'); goog.require('os.test.xsd'); -goog.require('os.ui.state.XMLStateManager'); goog.require('os.xml'); @@ -31,7 +31,7 @@ describe('QueryArea XSD State Test', function() { // waiting for the xsd files to load waitsFor(function() { - return (resultSchemas && os.ui.state && os.ui.state.StateManager); + return (resultSchemas && os.ui.state && os.state.BaseStateManager); }, 'Wait for XSD(s) to laod', 2 * jasmine.DEFAULT_TIMEOUT_INTERVAL); // Runs the tests. diff --git a/test/os/state/v4/queryentriesstate.test.js b/test/os/state/v4/queryentriesstate.test.js index 2eb73e4f5..08919a7f7 100644 --- a/test/os/state/v4/queryentriesstate.test.js +++ b/test/os/state/v4/queryentriesstate.test.js @@ -4,10 +4,10 @@ goog.require('goog.string'); goog.require('ol.Feature'); goog.require('ol.geom.Polygon'); goog.require('os.query.BaseAreaManager'); +goog.require('os.state.XMLStateManager'); goog.require('os.state.XMLStateOptions'); goog.require('os.state.v2.QueryEntries'); // v2 state implemention works with v4 goog.require('os.test.xsd'); -goog.require('os.ui.state.XMLStateManager'); goog.require('os.xml'); @@ -31,7 +31,7 @@ describe('QueryArea XSD State Test', function() { // waiting for the xsd files to load waitsFor(function() { - return (resultSchemas && os.ui.state && os.ui.state.StateManager); + return (resultSchemas && os.ui.state && os.state.BaseStateManager); }, 'Wait for XSD(s) to laod', 2 * jasmine.DEFAULT_TIMEOUT_INTERVAL); // Runs the tests. diff --git a/test/os/state/v4/timestate.test.js b/test/os/state/v4/timestate.test.js index b118d6517..7a8481966 100644 --- a/test/os/state/v4/timestate.test.js +++ b/test/os/state/v4/timestate.test.js @@ -4,7 +4,6 @@ goog.require('goog.math.RangeSet'); goog.require('goog.string'); goog.require('os.MapContainer'); goog.require('os.state.v4.TimeState'); -goog.require('os.ui.state.XMLStateManager'); describe('os.state.v4.TimeState', function() { var stateManager = null; diff --git a/test/os/state/v4/viewstate.test.js b/test/os/state/v4/viewstate.test.js index 259d7298f..206fead5b 100644 --- a/test/os/state/v4/viewstate.test.js +++ b/test/os/state/v4/viewstate.test.js @@ -3,7 +3,6 @@ goog.require('goog.dom.xml'); goog.require('goog.string'); goog.require('os.MapContainer'); goog.require('os.state.v4.ViewState'); -goog.require('os.ui.state.XMLStateManager'); describe('os.state.v4.ViewState', function() { var stateManager = null; diff --git a/test/plugin/arc/state/v4/arclayerstate.test.js b/test/plugin/arc/state/v4/arclayerstate.test.js index d691be976..2eb97476f 100644 --- a/test/plugin/arc/state/v4/arclayerstate.test.js +++ b/test/plugin/arc/state/v4/arclayerstate.test.js @@ -5,10 +5,10 @@ goog.require('os.layer.LayerType'); goog.require('os.layer.Vector'); goog.require('os.ogc.wfs.FeatureType'); goog.require('os.state.StateManager'); +goog.require('os.state.XMLStateManager'); goog.require('os.state.XMLStateOptions'); goog.require('os.state.v4.LayerState'); goog.require('os.test.xsd'); -goog.require('os.ui.state.XMLStateManager'); goog.require('os.xml'); goog.require('plugin.arc.layer.ArcFeatureLayerConfig'); goog.require('plugin.arc.layer.ArcLayerDescriptor'); diff --git a/test/plugin/basemap/v4/basemapstate.test.js b/test/plugin/basemap/v4/basemapstate.test.js index a819b868b..e7474fc11 100644 --- a/test/plugin/basemap/v4/basemapstate.test.js +++ b/test/plugin/basemap/v4/basemapstate.test.js @@ -4,9 +4,9 @@ goog.require('goog.string'); goog.require('os.layer.LayerType'); goog.require('os.ogc.wfs.FeatureType'); goog.require('os.state.StateManager'); +goog.require('os.state.XMLStateManager'); goog.require('os.state.XMLStateOptions'); goog.require('os.test.xsd'); -goog.require('os.ui.state.XMLStateManager'); goog.require('os.xml'); goog.require('plugin.basemap'); goog.require('plugin.basemap.v4.BaseMapState'); diff --git a/test/plugin/ogc/state/v4/ogclayerstate.test.js b/test/plugin/ogc/state/v4/ogclayerstate.test.js index e18dd79ac..aecd04066 100644 --- a/test/plugin/ogc/state/v4/ogclayerstate.test.js +++ b/test/plugin/ogc/state/v4/ogclayerstate.test.js @@ -4,7 +4,6 @@ goog.require('os.state.StateManager'); goog.require('os.state.XMLStateOptions'); goog.require('os.state.v4.LayerState'); goog.require('os.test.xsd'); -goog.require('os.ui.state.XMLStateManager'); goog.require('os.xml'); goog.require('plugin.arc.layer.ArcFeatureLayerConfig'); goog.require('plugin.arc.layer.ArcLayerDescriptor');