http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/DocumentData.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/DocumentData.as b/Radii8Library/src/com/flexcapacitor/model/DocumentData.as new file mode 100644 index 0000000..f8b3517 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/DocumentData.as @@ -0,0 +1,807 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + import com.flexcapacitor.controller.Radiate; + import com.flexcapacitor.services.IServiceEvent; + import com.flexcapacitor.services.IWPService; + import com.flexcapacitor.services.IWPServiceEvent; + import com.flexcapacitor.services.WPService; + import com.flexcapacitor.services.WPServiceBase; + import com.flexcapacitor.services.WPServiceEvent; + import com.flexcapacitor.utils.MXMLDocumentExporter; + + import flash.events.IEventDispatcher; + import flash.net.FileReference; + import flash.net.URLVariables; + import flash.system.ApplicationDomain; + + /** + * Event dispatched when the save results are returned. + * SaveResultsEvent + * */ + [Event(name="saveResults", type="com.flexcapacitor.model.SaveResultsEvent")] + + /** + * Event dispatched when the document data is retrieved. + * LoadResultsEvent + * */ + [Event(name="loadResults", type="com.flexcapacitor.model.LoadResultsEvent")] + + /** + * Holds document data. + * */ + [RemoteClass(alias="DocumentData")] + public class DocumentData extends DocumentMetaData implements IDocumentData { + + /** + * Constructor + * */ + public function DocumentData(target:IEventDispatcher = null) { + super(); + } + + /** + * Default class that exports the document + * */ + [Transient] + public static var internalExporter:IDocumentExporter = new MXMLDocumentExporter(); + + private var _exporter:IDocumentExporter = internalExporter; + + /** + * Exports the document to string + * */ + [Transient] + public function get exporter():IDocumentExporter { + return _exporter; + } + + /** + * @private + */ + public function set exporter(value:IDocumentExporter):void { + _exporter = value; + } + + /** + * Constant used to save locally to a shared object + * */ + [Transient] + public static const LOCAL_LOCATION:String = "local"; + + /** + * Constant used to open from internal references + * */ + [Transient] + public static const INTERNAL_LOCATION:String = "internal"; + + /** + * Constant used to save to the local file system + * */ + [Transient] + public static const FILE_LOCATION:String = "file"; + + /** + * Constant used to save to a database + * */ + [Transient] + public static const DATABASE_LOCATION:String = "database"; + + /** + * Constant used to save to the server + * */ + [Transient] + public static const REMOTE_LOCATION:String = "remote"; + + /** + * Constant used to save to the server + * */ + [Transient] + public static const ALL_LOCATIONS:String = "all"; + + /** + * Used to set the type of category used for projects on the server + * */ + [Transient] + public static const PROJECT_CATEGORY:String = "project"; + + /** + * Used to set the type of category used for documents on the server + * */ + [Transient] + public static const DOCUMENT_CATEGORY:String = "document"; + + public static var DefaultDocumentType:Object; + + private var _description:String; + + /** + * Description + * */ + public function get description():String { + return _description; + } + + /** + * @private + */ + public function set description(value:String):void { + _description = value; + } + + private var _file:FileReference; + + /** + * File reference + * */ + public function get file():FileReference { + return _file; + } + + /** + * @private + */ + public function set file(value:FileReference):void { + _file = value; + } + + + private var _source:String; + + /** + * + * */ + public function get source():String { + return _source; + } + + /** + * @inheritDoc + */ + public function set source(value:String):void { + _source = value; + } + + + private var _originalSource:String; + + /** + * + * */ + public function get originalSource():String { + return _originalSource; + } + + /** + * @inheritDoc + */ + public function set originalSource(value:String):void { + _originalSource = value; + } + + private var _assets:Array = []; + + public function get assets():Array { + return _assets; + } + + public function set assets(value:Array):void { + _assets = value; + } + + + private var _document:IDocument; + + /** + * @inheritDoc + * */ + [Transient] + public function get document():IDocument { + return _document; + } + + public function set document(value:IDocument):void { + _document = value; + } + + private var _isChanged:Boolean; + + /** + * Indicates if the document is changed + * */ + public function get isChanged():Boolean { + return _isChanged; + } + + /** + * @private + */ + [Bindable] + public function set isChanged(value:Boolean):void { + _isChanged = value; + } + + private var _saveSuccessful:Boolean; + + /** + * @inheritDoc + * */ + [Transient] + public function get saveSuccessful():Boolean { + return _saveSuccessful; + } + + public function set saveSuccessful(value:Boolean):void { + _saveSuccessful = value; + } + + + private var _saveInProgress:Boolean; + + /** + * Indicates if a save is in progress. + * */ + [Bindable] + [Transient] + public function get saveInProgress():Boolean { + return _saveInProgress; + } + + public function set saveInProgress(value:Boolean):void { + _saveInProgress = value; + } + + private var _openSuccessful:Boolean; + + /** + * Indicates if open was successful. + * */ + [Transient] + public function get openSuccessful():Boolean { + return _openSuccessful; + } + + public function set openSuccessful(value:Boolean):void { + _openSuccessful = value; + } + + private var _openInProgress:Boolean; + + /** + * Indicates if open is in progress. + * */ + [Bindable] + public function get openInProgress():Boolean { + return _openInProgress; + } + + public function set openInProgress(value:Boolean):void { + _openInProgress = value; + } + + public var firstTimeSave:Boolean; + + + private var _saveService:IWPService; + + /** + * Service that saves to WP installation + * */ + [Transient] + public function get saveService():IWPService { + return _saveService; + } + + /** + * @private + */ + public function set saveService(value:IWPService):void { + _saveService = value; + } + + /** + * Used to open document + * */ + public var openService:WPService; + + /** + * @inheritDoc + * */ + public function save(locations:String = LOCAL_LOCATION, options:Object = null):Boolean { + var saveRemote:Boolean = locations.indexOf(REMOTE_LOCATION)!=-1; + var saveLocally:Boolean = locations.indexOf(LOCAL_LOCATION)!=-1; + var form:URLVariables; + + if (saveRemote) { + //Radiate.log.info("Save"); + // we need to create service + if (saveService==null) { + var wpSaveService:WPService = new WPService(); + wpSaveService.host = host; + wpSaveService.addEventListener(WPServiceBase.RESULT, saveResultsHandler, false, 0, true); + wpSaveService.addEventListener(WPServiceBase.FAULT, saveFaultHandler, false, 0, true); + saveService = wpSaveService; + } + + saveSuccessful = false; + saveInProgress = true; + + form = toSaveFormObject(); + + // save project + saveService.save(form); + } + + if (saveLocally) { + // check if remote id is not set. + // if we can't save remotely we should still save locally + // but if we can save remotely and we need to save + // again when we have an id from the server + var result:Boolean = saveDocumentLocally() + return result; + } + + return false; + } + + /** + * Open + * */ + public function open(location:String = null):void { + var loadRemote:Boolean = location==REMOTE_LOCATION; + var loadLocally:Boolean = location==LOCAL_LOCATION; + + if (location==REMOTE_LOCATION) { + //Radiate.log.info("Open Document Remote"); + retrieve(); + } + else if (location==LOCAL_LOCATION) { + //var documentData:IDocumentData = Radiate.getInstance().getDocumentLocally(this); + //Radiate.log.info("Open Document Local"); + } + else { + //Radiate.log.info("Open Document normal"); + //source = getSource(); + } + + isOpen = true; + } + + /** + * @inheritDoc + * */ + public function close():void { + //Radiate.log.info("Close Document"); + source = getSource(); + isOpen = false; + } + + /** + * @inheritDoc + * */ + public function retrieve(local:Boolean = false):void { + var form:Object; + + // we need to create service + if (openService==null) { + openService = new WPService(); + openService.host = host; + openService.addEventListener(WPServiceBase.RESULT, openResultsHandler, false, 0, true); + openService.addEventListener(WPServiceBase.FAULT, openFaultHandler, false, 0, true); + } + + openSuccessful = false; + openInProgress = true; + + form = toLoadFormObject(); + + // open project + openService.open(id); + } + + /** + * Creates an object to send to the server + * */ + public function toSaveFormObject():URLVariables { + var object:URLVariables = new URLVariables(); + var value:String = getSource(); + object.title = name; + object.content = value; + object["custom[uid]"] = uid; + object["custom[source]"] = value; + object["custom[sponge]"] = 1; + object["custom[sandpaper]"] = 1; + object.categories = "document"; + + if (id) object.id = id; + if (status) object.status = status; + + return object; + } + + /** + * Creates an object to send to the server + * */ + public function toLoadFormObject():Object { + var object:Object = {}; + + if (id) object.id = id; + + return object; + } + + /** + * Result from save result + * */ + public function saveResultsHandler(event:IWPServiceEvent):void { + var saveResultsEvent:SaveResultsEvent = new SaveResultsEvent(SaveResultsEvent.SAVE_RESULTS); + var data:Object = event.data; + //var post:Object; + //Radiate.log.info("Save result handler on document " + name); + + saveResultsEvent.call = event.call; + saveResultsEvent.data = event.data; + saveResultsEvent.message = event.message; + saveResultsEvent.text = event.text; + + if (data && data.post) { + if (id==null) { + //Radiate.log.info("Document does not have an id. Needs to be resaved: "+ name); + id = data.post.id; + // we don't have id so we need to save again + // doing it in the sub classes because we need to + // update the source (for project) + //save(REMOTE_LOCATION); + //return; + } + + saveResultsEvent.successful = true; + saveSuccessful = true; + //Radiate.log.info("Document saved: "+ name); + + Radiate.instance.setLastSaveDate(); + } + else { + saveSuccessful = false; + //Radiate.log.info("Document not saved: "+ name); + } + + + saveInProgress = false; + + dispatchEvent(saveResultsEvent); + } + + /** + * Result from save fault + * */ + public function saveFaultHandler(event:IServiceEvent):void { + var saveResultsEvent:SaveResultsEvent = new SaveResultsEvent(SaveResultsEvent.SAVE_RESULTS); + + Radiate.log.info("Error when trying to save document: "+ name + "."); + + saveInProgress = false; + + dispatchEvent(saveResultsEvent); + } + + /** + * Result from open result + * */ + public function openResultsHandler(event:IServiceEvent):void { + var openResultsEvent:LoadResultsEvent = new LoadResultsEvent(LoadResultsEvent.LOAD_RESULTS); + var data:Object = event.data; + var post:Object; + + //Radiate.log..info("Open result handler on document " + name); + // when the post id was null then we ended up receiving the latest post + + if (data && data.post) { + post = data.post; //TODO create value object + + //source = data.post.content; + if ("source" in post.custom_fields) { + source = post.custom_fields.source; + originalSource = source; + } + else { + source = post.content; + } + + // this is because WP adds formating to the content + // there is a plugin that disables formatting that was enabled on the site but not currently + // but you have to set custom fields on the post to enable it + // this should eventually be fixed + if (source.indexOf("<p>")==0) { + source = source.substr(3); + var li:int = source.lastIndexOf("</p>"); + source = source.substr(0, li); + } + + if (source.indexOf("<br />")!=-1) { + source = source.replace(/<br \/>/g, ""); + } + + if (post.attachments && post.attachments.length>0) { + parseAttachments(post.attachments); + } + + openResultsEvent.successful = true; + openSuccessful = true; + //Radiate.log.info("Document open: "+ name); + } + else { + + if (event is WPServiceEvent) { + openResultsEvent.message = WPServiceEvent(event).message; + } + //Radiate.log.info("Document not opened: "+ name); + } + + openResultsEvent.data = data; + openResultsEvent.text = event.text; + openInProgress = false; + + isOpen = true; + dispatchEvent(openResultsEvent); + } + + /** + * Result from open fault + * */ + public function openFaultHandler(event:IServiceEvent):void { + var openResultsEvent:OpenResultsEvent = new OpenResultsEvent(SaveResultsEvent.SAVE_RESULTS); + + Radiate.log.info("Error when trying to open document: "+ name + "."); + + saveInProgress = false; + + dispatchEvent(openResultsEvent); + } + + /** + * Parses attachments + * */ + public function parseAttachments(attachments:Array):void { + var length:int; + var object:Object; + var attachment:AttachmentData; + + if (attachments && attachments.length>0) { + length = attachments.length; + + for (var i:int;i<length;i++) { + object = attachments[i]; + + if (String(object.mime_type).indexOf("image/")!=-1) { + attachment = new ImageData(); + attachment.unmarshall(object); + } + else { + attachment = new AttachmentData(); + attachment.unmarshall(object); + } + + addAsset(attachment); + } + } + } + + /** + * Add an asset + * */ + public function addAsset(asset:AttachmentData):Boolean { + var length:int = assets ? assets.length:0; + var exists:Boolean; + + for (var i:int;i<length;i++) { + if (assets[i].id==asset.id) { + exists = true; + break; + } + } + + if (!exists) { + assets.push(asset); + return true; + } + + return false; + } + + /** + * Removes an asset + * */ + public function removeAsset(asset:AttachmentData):Boolean { + var length:int = assets ? assets.length:0; + var exists:Boolean; + + for (var i:int;i<length;i++) { + if (assets[i].id==asset.id) { + exists = true; + break; + } + } + + if (exists) { + assets.splice(i, 1); + return true; + } + + return false; + } + + /** + * Get source code for document. + * If document isn't created yet get last stored source code + * + * This is overridden in Document + * TODO test this + * */ + public function getSource(target:Object = null):String { + + // if document isn't created yet get stored source code - refactor + if (!document) { + return source; + } + /*else { + return internalExporter.exportXMLString(this); + }*/ + + // you are in DocumentData + return source; + //throw new Error("GetSource not implemented. Override in sub class"); + } + + + /** + * Serialize. Export for saving to disk or server + * */ + override public function marshall(dataType:String = DOCUMENT_TYPE, representation:Boolean = false):Object { + var object:Object; + + // if string type get xml object. we will translate later + if (dataType==STRING_TYPE || dataType==XML_TYPE) { + object = super.marshall(XML_TYPE, representation); + } + + if (dataType==METADATA_TYPE) { + object = super.marshall(METADATA_TYPE, representation); + return DocumentMetaData(object); + } + else if (dataType==DOCUMENT_TYPE) { + // get default document data information + object = super.marshall(METADATA_TYPE, representation); + var documentData:DocumentData = new DocumentData(); + documentData.unmarshall(object); + documentData.source = getSource(); + + return DocumentData(documentData); + } + else if (dataType==STRING_TYPE || dataType==XML_TYPE ) { + var xml:XML = object as XML; + + // add source + if (!representation) { + //source = getSource(); + + if (source) { + //xml = XMLUtils.setItemContents(xml, "source", source); + } + } + + + if (dataType==STRING_TYPE) { + return xml.toXMLString(); + } + + return xml; + } + + return object; + } + + /** + * Deserialize document data. Import. + * */ + override public function unmarshall(data:Object):void { + super.unmarshall(data); + // this should probably be overriden by sub classes + if (data is IDocumentData) { + source = data.source; + } + else if (data is XML) { + source = data.content; + originalSource = XML(data).toXMLString(); + } + } + + /** + * Get basic project metadata + * */ + public function toMetaData():IDocumentMetaData { + return marshall(METADATA_TYPE, true) as IDocumentMetaData; + } + + /** + * Exports to XML + * */ + public function toXML(representation:Boolean = false):XML { + return marshall(XML_TYPE, representation) as XML; + } + + /** + * Exports an XML string. + * If representation is true then just returns just enough basic information to locate it. + * */ + override public function toString():String { + return marshall(STRING_TYPE, false) as String; + } + + /** + * Creates an instance of the document type + * */ + public function createInstance(data:Object = null):IDocument { + var iDocument:IDocument; + var hasDefinition:Boolean = ApplicationDomain.currentDomain.hasDefinition(className); + var DocumentType:Object = Document; + + if (hasDefinition) { + DocumentType = ApplicationDomain.currentDomain.getDefinition(className); + } + + iDocument = new DocumentType(); + + if (data) { + iDocument.unmarshall(data); + } + + + return iDocument; + } + + /** + * Save document locally + * */ + public function saveDocumentLocally():Boolean { + // for now just passing to saveDocument + var result:Boolean = Radiate.getInstance().saveDocumentLocally(this); + + + /*var result:Object = SharedObjectUtils.getSharedObject(SAVED_DATA_NAME); + var so:SharedObject; + + if (result is SharedObject) { + updateSaveDataForDocument(document); + so = SharedObject(result); + so.setProperty(SAVED_DATA_NAME, savedData); + so.flush(); + //log.info("Saved Data: " + ObjectUtil.toString(so.data)); + } + else { + log.error("Could not save data. " + ObjectUtil.toString(result)); + //return false; + } + + return true;*/ + return result; + } + } +} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/DocumentMetaData.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/DocumentMetaData.as b/Radii8Library/src/com/flexcapacitor/model/DocumentMetaData.as new file mode 100644 index 0000000..251651c --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/DocumentMetaData.as @@ -0,0 +1,348 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + import flash.events.EventDispatcher; + + /** + * Used to store the least amount of information about a document so it can be retrieved later. + * + * DocumentMetaData - stores basic data about a document and how to find it (filesystem, online id, local store) + * DocumentData - extends DocumentMetaData and adds more info about the document including source code. somewhat abstract + * ProjectData - extends DocumentData. abstract class for Project + * Project - extends ProjectData and is an instance created for use at runtime + * Document - extends DocumentData and is an instance created for use at runtime + * */ + [RemoteClass(alias="DocumentMetaData")] + public class DocumentMetaData extends EventDispatcher implements IDocumentMetaData { + + /** + * Constructor + * */ + public function DocumentMetaData() { + + } + + [Transient] + public static const METADATA_TYPE:String = "metaDataType"; + + [Transient] + public static const DOCUMENT_TYPE:String = "documentType"; + + [Transient] + public static const PROJECT_TYPE:String = "projectType"; + + [Transient] + public static const XML_TYPE:String = "XMLType"; + + [Transient] + public static const STRING_TYPE:String = "XMLStringType"; + + /** + * Name to use for node when exporting to XML + * */ + public var nodeName:String = "document"; + + private var _name:String; + + /** + * @inheritDoc + * */ + public function get name():String { + return _name; + } + + /** + * @private + * */ + public function set name(value:String):void { + _name = value; + } + + private var _contentType:String; + + /** + * @inheritDoc + * */ + public function get contentType():String { + return _contentType; + } + + /** + * @private + */ + public function set contentType(value:String):void { + _contentType = value; + } + + private var _type:String; + + /** + * @inheritDoc + * */ + public function get type():String { + return _type; + } + + /** + * @private + */ + public function set type(value:String):void { + _type = value; + } + + private var _className:String; + + /** + * @inheritDoc + * */ + public function get className():String { + return _className; + } + + public function set className(value:String):void { + _className = value; + } + + private var _uid:String; + + /** + * @inheritDoc + * */ + public function get uid():String { + return _uid; + } + + /** + * @private + * */ + public function set uid(value:String):void { + _uid = value; + } + + private var _uri:String; + + /** + * @inheritDoc + * */ + public function get uri():String { + return _uri; + } + + /** + * @private + * */ + public function set uri(value:String):void { + _uri = value; + } + + private var _host:String; + + /** + * @inheritDoc + * */ + public function get host():String { + return _host; + } + + /** + * @private + * */ + public function set host(value:String):void { + _host = value; + } + + private var _isOpen:Boolean; + + /** + * Indicates if the project is open + * */ + public function get isOpen():Boolean { + return _isOpen; + } + + /** + * @private + */ + [Bindable] + public function set isOpen(value:Boolean):void { + _isOpen = value; + } + + private var _id:String; + + /** + * @inheritDoc + * */ + public function get id():String { + return _id; + } + + /** + * @private + * */ + public function set id(value:String):void { + _id = value; + } + + private var _parentId:String; + + /** + * Parent ID + * */ + public function get parentId():String { + return _parentId; + } + + public function set parentId(value:String):void { + _parentId = value; + } + + + private var _status:String; + + /** + * @inheritDoc + * */ + public function get status():String { + return _status; + } + + /** + * @private + * */ + public function set status(value:String):void { + _status = value; + } + + private var _dateSaved:String; + + /** + * Date saved + * */ + public function get dateSaved():String { + return _dateSaved; + } + + public function set dateSaved(value:String):void { + _dateSaved = value; + } + + /** + * Returns the date + * */ + public function getTimeInHistory():String { + return new Date().time.toString(); + } + + /** + * Serialize. Export for saving to disk or server + * */ + public function marshall(objectType:String = DOCUMENT_TYPE, representation:Boolean = false):Object { + var output:Object; + + if (objectType==METADATA_TYPE) { + var metadata:DocumentMetaData = new DocumentMetaData(); + + metadata.className = className; + metadata.dateSaved = getTimeInHistory(); + metadata.host = host; + metadata.id = id; + metadata.isOpen = isOpen; + metadata.name = name; + metadata.type = type; + metadata.uid = uid; + metadata.uri = uri; + + return metadata; + } + else if (objectType==DOCUMENT_TYPE) { + var documentData:DocumentData = new DocumentData(); + + documentData.className = className; + documentData.dateSaved = getTimeInHistory(); + documentData.host = host; + documentData.id = id; + documentData.isOpen = isOpen; + documentData.name = name; + documentData.type = type; + documentData.uid = uid; + documentData.uri = uri; + + return documentData; + } + else if (objectType==STRING_TYPE || objectType==XML_TYPE ) { + var xml:XML = new XML("<" + nodeName +"/>"); // support document or project types + + xml.@className = className!=null ? className : ""; + xml.@dateSaved = getTimeInHistory(); + xml.@host = host; + xml.@id = id!=null ? id : ""; + xml.@isOpen = isOpen; + xml.@name = name; + xml.@type = type!=null ? type : ""; + xml.@uid = uid; + xml.@uri = uri!=null ? uri : ""; + + + if (objectType==STRING_TYPE) { + return xml.toXMLString(); + } + + return xml; + } + + return output; + } + + + /** + * Deserialize document data. Import. + * */ + public function unmarshall(data:Object):void { + + if (data is IDocumentMetaData || data is IDocumentData) { + className = data.className; + dateSaved = data.dateSaved; + host = data.host; + id = data.id; + isOpen = data.isOpen; // note we are repurposing this at runtime + name = data.name; + parentId = data.parentId; + type = data.type; + uid = data.uid; + uri = data.uri; + + } + else if (data is XML) { + className = data.@className=="null" ? null : data.@className; + dateSaved = data.@dateSaved; + host = data.@host; + id = data.@id=="null" ? null : data.@id; + isOpen = data.@isOpen; + name = data.@name; + parentId = data.@parentId; + type = data.@type=="null" ? null : data.@type; + uid = data.@uid; + uri = data.@uri=="null" ? null : data.@uri; + + } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/EventMetaData.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/EventMetaData.as b/Radii8Library/src/com/flexcapacitor/model/EventMetaData.as new file mode 100644 index 0000000..150cf81 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/EventMetaData.as @@ -0,0 +1,78 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + + + /** + * Contains information on style metadata + * */ + public class EventMetaData extends MetaData { + + + public function EventMetaData(item:XML = null, target:* = null) + { + if (item) unmarshall(item, target); + } + + + /** + * Import metadata XML Style node into this instance + * */ + override public function unmarshall(item:XML, target:* = null, getValue:Boolean = true):void { + super.unmarshall(item, target, getValue); + /* + var args:XMLList = item.arg; + var keyName:String; + var keyValue:String; + + + for each (var arg:XML in args) { + keyName = arg.@key; + + if (keyName=="inherit") { + inherit = keyValue=="no"; + break; + } + + }*/ + + /* + + // this shows if it's defined at all + definedInline = target && target is IStyleClient && target.getStyle(name)!==undefined; + + if (!definedInline) { + inheritedValue = target.getStyle(name); + nonInheritedValue = undefined; + value = inheritedValue; + textValue = "" + inheritedValue; + } + else { + inheritedValue = undefined; // don't know how to get this value + nonInheritedValue = target.getStyle(name); + value = nonInheritedValue; + textValue = "" + nonInheritedValue; + }*/ + + + + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/GroupOptions.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/GroupOptions.as b/Radii8Library/src/com/flexcapacitor/model/GroupOptions.as new file mode 100644 index 0000000..6727505 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/GroupOptions.as @@ -0,0 +1,31 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + + public class GroupOptions { + + public function GroupOptions(mouseEnabled:Object):void { + mouseEnabledWhereTransparent = mouseEnabled; + } + + public var mouseEnabledWhereTransparent:Boolean; + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/IDocument.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/IDocument.as b/Radii8Library/src/com/flexcapacitor/model/IDocument.as new file mode 100644 index 0000000..705e41e --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/IDocument.as @@ -0,0 +1,122 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + import com.flexcapacitor.utils.supportClasses.ComponentDescription; + + import flash.utils.Dictionary; + + import mx.collections.ArrayCollection; + import mx.core.IVisualElement; + + + /** + * Interface for document + * */ + public interface IDocument extends IDocumentData { + + /** + * ID of parent project. May support multiple projects in the future. + * */ + function set projectID(value:String):void; + function get projectID():String; + + /** + * Parent project. Some documents may not need projects. + * */ + function get project():IProject; + function set project(value:IProject):void; + + /** + * Reference to the last saved document data object + * */ + function get documentData():IDocumentData; + function set documentData(value:IDocumentData):void; + + /** + * Class type that contains this document + * */ + function get containerType():Class; + function set containerType(value:Class):void; + + /** + * Name of class type that contains this document + * */ + function get containerTypeName():String; + function set containerTypeName(value:String):void; + + /** + * Reference to the document instance. + * */ + function get instance():Object; + function set instance(value:Object):void; + + /** + * Reference to component tree + * */ + function get componentDescription():ComponentDescription; + function set componentDescription(value:ComponentDescription):void; + + /** + * Collection of history events + * */ + function get history():ArrayCollection; + function set history(value:ArrayCollection):void; + + /** + * Current history event index + * */ + function get historyIndex():int; + function set historyIndex(value:int):void; + + /** + * Index that history was at when last saved. + * */ + function get lastSavedHistoryIndex():int; + function set lastSavedHistoryIndex(value:int):void; + + /** + * Property that tells if document preview is open + * */ + function get isPreviewOpen():Boolean; + function set isPreviewOpen(value:Boolean):void; + + /** + * A dictionary of information about... + * */ + function get descriptionsDictionary():Dictionary; + function set descriptionsDictionary(value:Dictionary):void; + + /** + * Scale of the document for design view + * */ + function get scale():Number; + function set scale(value:Number):void; + + /** + * Parses the code in the source property or the passed in value if set + * */ + function parseSource(value:String = null, container:IVisualElement = null):void; + + /** + * Resets the save status after loading a document + * */ + function resetSaveStatus():void; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/IDocumentData.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/IDocumentData.as b/Radii8Library/src/com/flexcapacitor/model/IDocumentData.as new file mode 100644 index 0000000..26c1ed9 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/IDocumentData.as @@ -0,0 +1,162 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + import com.flexcapacitor.services.IWPService; + + import flash.net.FileReference; + + /** + * Interface for Document Data. This class may not be necessary. + * Was using it to store less data than IDocument but more than + * IDocumentMetaData. + * */ + public interface IDocumentData extends IDocumentMetaData { + + + /** + * Exporter that exports the document + * */ + function set exporter(value:IDocumentExporter):void; + function get exporter():IDocumentExporter; + + /** + * Original source code of the document before importing + * */ + function set originalSource(value:String):void; + function get originalSource():String; + + /** + * Source code of the document + * */ + function set source(value:String):void; + function get source():String; + + /** + * Reference to the document + * */ + function set document(value:IDocument):void; + function get document():IDocument; + + /** + * Is open + * */ + function set isOpen(value:Boolean):void; + function get isOpen():Boolean; + + /** + * An array of attachment or document data + * */ + function set assets(value:Array):void; + function get assets():Array; + + /** + * Is changed + * */ + function set isChanged(value:Boolean):void; + function get isChanged():Boolean; + + /** + * Indicates if last save was successful. Only valid immediately after call to save. + * */ + function set saveSuccessful(value:Boolean):void; + function get saveSuccessful():Boolean; + + /** + * Indicates if last open was successful. Only valid immediately after call to open. + * */ + function set openSuccessful(value:Boolean):void; + function get openSuccessful():Boolean; + + /** + * True if save is in progress. + * */ + function set saveInProgress(value:Boolean):void; + function get saveInProgress():Boolean; + + /** + * True if open is in progress. + * */ + function set openInProgress(value:Boolean):void; + function get openInProgress():Boolean; + + /** + * Reference to the save service + * */ + function set saveService(value:IWPService):void; + function get saveService():IWPService; + + /** + * Reference to physical file + * */ + function set file(value:FileReference):void; + function get file():FileReference; + + /** + * Parse assets + * */ + function parseAttachments(data:Array):void; + + /** + * Create the document + * */ + function createInstance(data:Object = null):IDocument; + + /** + * Save the document. String of locations to save to separated by comma. + * */ + function save(locations:String = null, options:Object = null):Boolean; + + /** + * Retrieve the document + * */ + function retrieve(local:Boolean = false):void; + + /** + * Open the document + * */ + function open(location:String = null):void; + + /** + * Close the document + * */ + function close():void; + + /** + * Get source of document such as MXML, HTML, etc + * */ + function getSource(target:Object = null):String; + + /** + * Translates the document to a metadata object + * */ + function toMetaData():IDocumentMetaData; + + /** + * Translates the project into an XML representation + * */ + function toXML(representation:Boolean = false):XML; + + /** + * Translates the project into a XML string + * */ + function toString():String; + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/IDocumentExporter.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/IDocumentExporter.as b/Radii8Library/src/com/flexcapacitor/model/IDocumentExporter.as new file mode 100644 index 0000000..950a61e --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/IDocumentExporter.as @@ -0,0 +1,78 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + import com.flexcapacitor.utils.supportClasses.ComponentDescription; + + + + /** + * Handles exporting to various formats + * */ + public interface IDocumentExporter { + + /** + * Is valid + * */ + function set isValid(value:Boolean):void; + function get isValid():Boolean; + + /** + * Error event + * */ + function set error(value:Error):void; + function get error():Error; + + /** + * Error message + * */ + function set errorMessage(value:String):void; + function get errorMessage():String; + + /** + * Errors + * */ + function set errors(value:Array):void; + function get errors():Array; + + /** + * Warnings + * */ + function set warnings(value:Array):void; + function get warnings():Array; + + /** + * Exports to an XML string. When reference is true it returns + * a shorter string with a URI to the document details + * */ + function export(document:IDocument, target:ComponentDescription = null, reference:Boolean = false):*; + + /** + * Export to XML. When reference is true it returns + * a shorter string with a URI to the document details + * */ + function exportXML(document:IDocument, reference:Boolean = false):XML; + + /** + * Export to JSON representation. When reference is true it returns + * a shorter string with a URI to the document details + * */ + function exportJSON(document:IDocument, reference:Boolean = false):JSON; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/IDocumentMetaData.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/IDocumentMetaData.as b/Radii8Library/src/com/flexcapacitor/model/IDocumentMetaData.as new file mode 100644 index 0000000..6382d94 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/IDocumentMetaData.as @@ -0,0 +1,99 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + + /** + * Used to store the least amount of information about a document so it can be retrieved later. + * */ + public interface IDocumentMetaData { + + /** + * Name of the document + * */ + function set name(value:String):void; + function get name():String; + + /** + * A unique ID that is used to find the document through it's various locations + * */ + function get uid():String; + function set uid(value:String):void; + + /** + * A unique URI that is used to find the document through it's various locations + * */ + function get uri():String; + function set uri(value:String):void; + + /** + * The ID of the record that this document is saved at remotely + * */ + function get id():String; + function set id(value:String):void; + + /** + * The host that the document is located at. Used with the ID property. + * */ + function get host():String; + function set host(value:String):void; + + /** + * The status that the document is in. For example, draft or publish. + * */ + function get status():String; + function set status(value:String):void; + + /** + * The type of document + * */ + function get type():String; + function set type(value:String):void; + + /** + * The content type or mime type of document. For example, "image/jpg". + * */ + function get contentType():String; + function set contentType(value:String):void; + + /** + * The class type of document + * */ + function get className():String; + function set className(value:String):void; + + /** + * The date the document was last saved. + * */ + function get dateSaved():String; + function set dateSaved(value:String):void; + + /** + * Serializes document. Export. + * */ + function marshall(type:String = "", representation:Boolean = true):Object; + + /** + * Deserializes the data. Import. + * */ + function unmarshall(data:Object):void; + } + + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/IProject.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/IProject.as b/Radii8Library/src/com/flexcapacitor/model/IProject.as new file mode 100644 index 0000000..942eee1 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/IProject.as @@ -0,0 +1,77 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + + + + /** + * Describes the interface of a project + * */ + public interface IProject extends IDocumentData { + + /** + * Project documents + * */ + function set documents(value:Array):void; + function get documents():Array; + + /** + * Project documents meta data + * */ + function set documentsMetaData(value:Array):void; + function get documentsMetaData():Array; + + /** + * Reference to the last saved project data object + * */ + function get projectData():IProjectData; + function set projectData(value:IProjectData):void; + + /** + * Import documents + * */ + function importDocumentInstances(documents:Array, overwrite:Boolean = false):void; + + /** + * Add document + * */ + function addDocument(document:IDocument, overwrite:Boolean = false):void; + + /** + * Get savable document data. If open is true then only returns open documents. + * */ + function getSavableDocumentsData(open:Boolean = false, metaData:Boolean = false):Array; + + /** + * Open the project documents from meta data + * */ + function openFromMetaData(location:String = null):void; + + /** + * Checks if project has any changes and marks isChanged to true if true + * */ + function checkProjectHasChanged():Boolean; + + /** + * Gets document by UID. + * */ + function getDocumentByUID(uid:String):IDocumentData; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/IProjectData.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/IProjectData.as b/Radii8Library/src/com/flexcapacitor/model/IProjectData.as new file mode 100644 index 0000000..38e06e0 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/IProjectData.as @@ -0,0 +1,35 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + + /** + * Defines required serializable project data properties + * */ + public interface IProjectData extends IDocumentData { + + + /** + * Array of documents that are part of this project + * */ + function set documents(value:Array):void; + function get documents():Array; + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/IProjectMetaData.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/IProjectMetaData.as b/Radii8Library/src/com/flexcapacitor/model/IProjectMetaData.as new file mode 100644 index 0000000..c772e4f --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/IProjectMetaData.as @@ -0,0 +1,28 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + + /** + * + * */ + public interface IProjectMetaData extends IDocumentMetaData { + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/ISavable.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/ISavable.as b/Radii8Library/src/com/flexcapacitor/model/ISavable.as new file mode 100644 index 0000000..847e5d8 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/ISavable.as @@ -0,0 +1,32 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + + /** + * Defines methods needed for saving a project or document or asset. + * */ + public interface ISavable { + + /** + * Method that saves the data locally or to the server. + * */ + function save(locations:String = "", options:Object = null):Boolean; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/ISavableService.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/ISavableService.as b/Radii8Library/src/com/flexcapacitor/model/ISavableService.as new file mode 100644 index 0000000..3a681b3 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/ISavableService.as @@ -0,0 +1,29 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + import com.flexcapacitor.services.IWPService; + + /** + * Interface for save service + * */ + public interface ISavableService extends IWPService { + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/ISavedData.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/ISavedData.as b/Radii8Library/src/com/flexcapacitor/model/ISavedData.as new file mode 100644 index 0000000..28bbb79 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/ISavedData.as @@ -0,0 +1,29 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + + public interface ISavedData { + + function set version(value:uint):void; + function get version():uint; + + function unmarshall(data:Object):void; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/ISettings.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/ISettings.as b/Radii8Library/src/com/flexcapacitor/model/ISettings.as new file mode 100644 index 0000000..f57881c --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/ISettings.as @@ -0,0 +1,29 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + + public interface ISettings { + + function set version(value:uint):void; + function get version():uint; + + function unmarshall(data:Object):void; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/ImageData.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/ImageData.as b/Radii8Library/src/com/flexcapacitor/model/ImageData.as new file mode 100644 index 0000000..d66f14e --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/ImageData.as @@ -0,0 +1,174 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + + +package com.flexcapacitor.model { + import flash.display.BitmapData; + import flash.utils.ByteArray; + + + /** + * Image data information + * */ + public class ImageData extends AttachmentData { + + /** + * Constructor + * */ + public function ImageData() { + + nodeName = "image"; + } + + /** + * + * */ + public var originalURL:String; + + /** + * + * */ + public var largeURL:String; + + /** + * + * */ + public var mediumURL:String; + + /** + * + * */ + public var smallURL:String; + + /** + * + * */ + public var thumbnailURL:String; + + /** + * + * */ + public var caption:String; + + /** + * Full URL to image + * */ + public var url:String; + + /** + * Width + * */ + public var width:int; + + /** + * Height + * */ + public var height:int; + + /** + * Bitmap data + * */ + public var bitmapData:BitmapData; + + /** + * Byte Array + * */ + public var byteArray:ByteArray; + + /** + * + * */ + override public function unmarshall(data:Object):void { + + if (data is ImageData) { // only added minimal support for image data atm + var image:ImageData = ImageData(data); + description = image.description; + id = image.id; + mimeType = image.mimeType; + parentId = image.parentId; + name = image.name; + url = image.url; + width = data.width; + height = data.height; + } + else if (data is Object) { + + caption = data.caption; + description = data.description; + id = data.id; + mimeType = data.mime_type; + parentId = data.parent; + name = data.title; + url = data.url; + + if (data.images) { + mediumURL = data.images.medium.url; + if (data.images["small-feature"]) { + smallURL = data.images["small-feature"].url; + } + if (data.images["post-thumbnail"]) { + //postThumbnailURL = data.images.["post-thumbnail"].url; + } + thumbnailURL = data.images.thumbnail.url; + width = data.images.full.width; + height = data.images.full.height; + } + } + } + + /** + * + * */ + override public function marshall(objectType:String = XML_TYPE, representation:Boolean = false):Object { + var object:Object = super.marshall(objectType, representation); + + + return object; + /* + if (objectType==STRING_TYPE || objectType==XML_TYPE ) { + var source:String; + var xml:XML = new XML("<" + nodeName +"/>"); // support document or project types + + xml.@className = className; + xml.@dateSaved = getTimeInHistory(); + xml.@host = host; + xml.@id = id; + xml.@name = name; + xml.@type = type; + xml.@uid = uid; + xml.@uri = uri; + + // add source + if (!representation) { + source = getSource(); + if (source) { + xml = XMLUtils.setItemContents(xml, "source", source); + } + } + + if (objectType==STRING_TYPE) { + return xml.toXMLString(); + } + + return xml; + }*/ + + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/InspectableClass.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/InspectableClass.as b/Radii8Library/src/com/flexcapacitor/model/InspectableClass.as new file mode 100644 index 0000000..0fe4f6e --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/InspectableClass.as @@ -0,0 +1,75 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + + /** + * Holds data on inspector + * */ + public class InspectableClass { + + public function InspectableClass(data:XML = null) { + + if (data) { + unmarshall(data); + } + } + + /** + * Name + * */ + public var name:String; + + /** + * Name of class + * */ + public var className:String; + + /** + * List of inspectors + * */ + public var inspectors:Array = []; + + public function unmarshall(data:XML):InspectableClass { + var inspectorsXMLList:XMLList; + var inspectorXML:XML; + var length:uint; + var inspectorArray:uint; + var inspectorData:InspectorData; + + // get list of inspectors + // create instances + // store in inspectors list + + name = data.attribute("name"); + className = data.attribute("className"); + + inspectorsXMLList = data..inspector; + length = inspectorsXMLList.length(); + + for (var i:int;i<length;i++) { + inspectorXML = inspectorsXMLList[i]; + inspectorData = new InspectorData(inspectorXML); + inspectors.push(inspectorData); + } + + return this; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/InspectorData.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/InspectorData.as b/Radii8Library/src/com/flexcapacitor/model/InspectorData.as new file mode 100644 index 0000000..feda667 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/InspectorData.as @@ -0,0 +1,111 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + import com.flexcapacitor.views.IInspector; + + import flash.system.ApplicationDomain; + + import mx.core.ClassFactory; + + /** + * Hold information and reference to inspector instance + * */ + public class InspectorData { + + /** + * Constructor obviously + * */ + public function InspectorData(data:XML = null) { + + if (data) { + unmarshall(data); + } + } + + /** + * Display name of inspector. If empty the class name is used. + * */ + public var name:String; + + /** + * Fully qualified class name + * */ + public var className:String; + + /** + * Instance of inspector + * */ + public var instance:IInspector; + + /** + * Reference to class used to create the instance + * */ + public var classType:Object; + + /** + * Defaults to set when creating the instance + * */ + public var defaults:Object; + + /** + * Icon + * */ + public var icon:Object; + + /** + * Import from XML data + * */ + public function unmarshall(data:XML):InspectorData { + name = data.attribute("name"); + className = data.attribute("className"); + //defaults = data.defaults; + + return this; + } + + /** + * Gets an instance of the inspector class or null if the definition is not found. + * */ + public function getInstance(domain:ApplicationDomain = null):IInspector { + var classFactory:ClassFactory; + var hasDefinition:Boolean; + + if (!instance) { + domain = !domain ? ApplicationDomain.currentDomain : domain; + hasDefinition = domain.hasDefinition(className); + + if (hasDefinition) { + classType = domain.getDefinition(className); + + classFactory = new ClassFactory(classType as Class); + //classFactory.properties = defaultProperties; + instance = classFactory.newInstance(); + } + else { + return null; + } + + } + + return instance; + + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/LoadResultsEvent.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/LoadResultsEvent.as b/Radii8Library/src/com/flexcapacitor/model/LoadResultsEvent.as new file mode 100644 index 0000000..8d61e20 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/LoadResultsEvent.as @@ -0,0 +1,78 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + import com.flexcapacitor.services.IWPServiceEvent; + import com.flexcapacitor.services.ServiceEvent; + + import flash.events.Event; + + /** + * Indicates if retrieve of document was successful + * */ + public class LoadResultsEvent extends ServiceEvent implements IWPServiceEvent { + + /** + * Event dispatched when the document data has been retrieved + * */ + public static const LOAD_RESULTS:String = "retrievedResults"; + + private var _call:String; + + /** + * + * */ + public function get call():String { + return _call; + } + + public function set call(value:String):void { + _call = value; + } + + private var _message:String; + + /** + * + * */ + public function get message():String { + return _message; + } + + public function set message(value:String):void { + _message = value; + } + + + public function LoadResultsEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, successful:Boolean = false) + { + super(type, bubbles, cancelable); + this.successful = successful; + } + + /** + * Indicates if retrieve was successful + * */ + public var successful:Boolean; + + override public function clone():Event { + return new LoadResultsEvent(type, bubbles, cancelable, successful); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/MetaData.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/MetaData.as b/Radii8Library/src/com/flexcapacitor/model/MetaData.as new file mode 100644 index 0000000..9cbe78b --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/MetaData.as @@ -0,0 +1,221 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + + + /** + * Contains information on metadata + * */ + public class MetaData { + + + public function MetaData(item:XML = null, target:* = null) + { + if (item) unmarshall(item, target); + + } + + /** + * Name of property, style or event + * */ + public var name:String; + + /** + * Type of data. For example, String, int, etc + * */ + public var type:String; + + /** + * Value at the time of access + * */ + public var value:*; + + /** + * Format of data. For example, Color, Number, etc + * */ + public var format:String; + + /** + * Minimum value of property + * */ + public var minValue:Number; + + /** + * Maximum value of property + * */ + public var maxValue:Number; + + /** + * Inspectable data category. For example, general, etc + * */ + public var category:String; + + /** + * Default value for inspectable panel + * */ + public var defaultValue:String; + + /** + * + * */ + public var environment:String; + + /** + * Accepted values + * */ + public var enumeration:Array; + + /** + * Theme + * */ + public var theme:String; + + /** + * Type of element in the array + * */ + public var arrayElementType:String; + + /** + * + * */ + public var arrayType:String; + + public var helpPositions:Array; + + public var bindable:Array; + + public var percentProxy:Array; + + public var skinPart:Array; + + public var verbose:Boolean; + + /** + * A string representation of the value. + * Empty string is empty string, null or undefined. + * */ + public var textValue:String = ""; + + /** + * Raw XML formatted string from describe type + * */ + public var raw:String; + + /** + * Class that defined this style + * */ + public var declaredBy:String; + + /** + * Import metadata XML node into this instance + * */ + public function unmarshall(item:XML, target:* = null, getValue:Boolean = true):void { + var args:XMLList = item.arg; + var keyName:String; + var keyValue:String; + var propertyValue:*; + + name = item.@name; + type = item.@type; + declaredBy = item.@declaredBy; + + for each (var arg:XML in args) { + keyName = arg.@key; + keyValue = String(arg.@value); + + + if (keyName=="arrayType") { + arrayType = keyValue; + continue; + } + + else if (keyName=="category") { + category = keyValue; + continue; + } + + else if (keyName=="defaultValue") { + defaultValue = keyValue; + continue; + } + + if (keyName=="enumeration") { + enumeration = keyValue.split(","); + continue; + } + + else if (keyName=="environment") { + environment = keyValue; + continue; + } + + else if (keyName=="format") { + format = keyValue; + continue; + } + + else if (keyName=="minValue") { + minValue = Number(keyValue); + continue; + } + + else if (keyName=="maxValue") { + maxValue = Number(keyValue); + continue; + } + + else if (keyName=="name") { + name = keyValue; + continue; + } + + else if (keyName=="theme") { + theme = keyValue; + continue; + } + + else if (keyName=="type") { + type = keyValue; + continue; + } + + else if (keyName=="verbose") { + verbose = keyValue=="1"; + continue; + } + } + + // ReferenceError: Error #1077: Illegal read of write-only property layoutMatrix3D on spark.components.Label. + try { + value = target && name in target ? target[name] : undefined; + } + catch (e:Error) { + + } + + textValue = value===undefined ? "": "" + value; + + if (!getValue) value = undefined; + + raw = item.toXMLString(); + + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/model/OpenResultsEvent.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/model/OpenResultsEvent.as b/Radii8Library/src/com/flexcapacitor/model/OpenResultsEvent.as new file mode 100644 index 0000000..68887ba --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/model/OpenResultsEvent.as @@ -0,0 +1,73 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package com.flexcapacitor.model { + import com.flexcapacitor.services.IWPServiceEvent; + import com.flexcapacitor.services.ServiceEvent; + + import flash.events.Event; + + /** + * Indicates if open of document was successful + * */ + public class OpenResultsEvent extends ServiceEvent implements IWPServiceEvent { + + private var _call:String; + + /** + * + * */ + public function get call():String { + return _call; + } + + public function set call(value:String):void { + _call = value; + } + + private var _message:String; + + /** + * + * */ + public function get message():String { + return _message; + } + + public function set message(value:String):void { + _message = value; + } + + + public function OpenResultsEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, successful:Boolean = false) + { + super(type, bubbles, cancelable); + this.successful = successful; + } + + /** + * Indicates if open was successful + * */ + public var successful:Boolean; + + override public function clone():Event { + return new OpenResultsEvent(type, bubbles, cancelable, successful); + } + } +} \ No newline at end of file