X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/ee06f37b0f6f6d94cd05a6ffae556660f7c4a2bc..c930e9176a5a85509c5b0230e2bff5c22a591432:/docs/source/FileProvider.html diff --git a/docs/source/FileProvider.html b/docs/source/FileProvider.html new file mode 100644 index 00000000..e0f651fe --- /dev/null +++ b/docs/source/FileProvider.html @@ -0,0 +1,76 @@ + + + The source code + + + + +
/** + * @class Ext.air.FileProvider + * @extends Ext.state.Provider + * + * An Ext state provider implementation for Adobe AIR that stores state in the application + * storage directory. + * + * @constructor + * @param {Object} config + */ +Ext.air.FileProvider = function(config){ + Ext.air.FileProvider.superclass.constructor.call(this); + + this.defaultState = { + mainWindow : { + width:780, + height:580, + x:10, + y:10 + } + }; + + Ext.apply(this, config); + this.state = this.readState(); + + var provider = this; + air.NativeApplication.nativeApplication.addEventListener('exiting', function(){ + provider.saveState(); + }); +}; + +Ext.extend(Ext.air.FileProvider, Ext.state.Provider, { +
/** + * @cfg {String} file + * The file name to use for the state file in the application storage directory + */ + file: 'extstate.data', + +
/** + * @cfg {Object} defaultState + * The default state if no state file can be found + */ + // private + readState : function(){ + var stateFile = air.File.applicationStorageDirectory.resolvePath(this.file); + if(!stateFile.exists){ + return this.defaultState || {}; + } + + var stream = new air.FileStream(); + stream.open(stateFile, air.FileMode.READ); + + var stateData = stream.readObject(); + stream.close(); + + return stateData || this.defaultState || {}; + }, + + // private + saveState : function(name, value){ + var stateFile = air.File.applicationStorageDirectory.resolvePath(this.file); + var stream = new air.FileStream(); + stream.open(stateFile, air.FileMode.WRITE); + stream.writeObject(this.state); + stream.close(); + } +});
+ + \ No newline at end of file