http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/renderers/ItemRendererButton.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/renderers/ItemRendererButton.mxml b/Radii8Library/src/com/flexcapacitor/views/renderers/ItemRendererButton.mxml new file mode 100644 index 0000000..cb37c38 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/renderers/ItemRendererButton.mxml @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/halo" + autoDrawBackground="true" + useHandCursor="true" + buttonMode="true" + height="22" + > + + <fx:Metadata> + [HostComponent("spark.components.List")] + </fx:Metadata> + + <fx:Script> + <![CDATA[ + import spark.components.List; + + + [Bindable] + public var iconSource:Object; + ]]> + </fx:Script> + + <s:states> + <s:State name="normal" /> + <s:State name="hovered" /> + <s:State name="selected" /> + <s:State name="disabled" /> + </s:states> + + <!--<s:Rect height="100%" width="100%"> + <s:fill> + <s:SolidColor color="0xEEFFFF" + alpha="0" + alpha.hovered="0.1" + alpha.selected="0.4" /> + </s:fill> + </s:Rect>--> + + <s:BitmapImage id="icon" + source="{iconSource}" + verticalCenter="0" + left="5" + > + </s:BitmapImage> + + + + <s:Label id="labelDisplay" + height="100%" + width="100%" + left="20" + top="3" + verticalAlign="middle" + itemCreationPolicy="immediate" + paddingLeft="5" + paddingRight="5" + includeIn="hovered, normal, selected, disabled"/> + +</s:ItemRenderer>
http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/renderers/LayersRenderer.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/renderers/LayersRenderer.mxml b/Radii8Library/src/com/flexcapacitor/views/renderers/LayersRenderer.mxml new file mode 100644 index 0000000..146b2a1 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/renderers/LayersRenderer.mxml @@ -0,0 +1,227 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<s:MXTreeItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + width="100%" + height="18" + autoDrawBackground="false" + creationComplete="creationCompleteHandler(event)" + > + <fx:Script> + <![CDATA[ + import com.flexcapacitor.controller.Radiate; + import com.flexcapacitor.utils.DisplayObjectUtils; + import com.flexcapacitor.utils.supportClasses.ComponentDescription; + + import mx.controls.Tree; + import mx.core.IVisualElement; + import mx.events.FlexEvent; + + import spark.components.Application; + + override public function set data(value:Object):void { + super.data = value; + + var item:ComponentDescription = value as ComponentDescription; + var path:String; + + if (item) { + if (item.icon) { + + if (item.icon!=iconImage.source) { + iconImage.source = item.icon; + } + } + else { + if (item.instance is Application) { + path = "assets/images/components/BorderContainer.png"; + } + else { + path = "assets/images/components/" + item.name + ".png"; + } + + if (path!=iconImage.source) { + iconImage.source = path; + } + } + + labelDisplay.text = treeListData.label; + + if (item.instance && item.instance.visible) { + visibleGroup.visible = true; + } + else { + visibleGroup.visible = false; + } + } + + if (treeListData && treeListData.hasChildren) { + disclosureGroup.visible = true; + } + else { + disclosureGroup.visible = false; + } + } + + protected function iconImage_ioErrorHandler(event:IOErrorEvent):void { + iconImage.source = "assets/images/components/BorderContainer.png"; + //Radiate.log.info("LayersRenderer: "+event.text); + } + + protected function visibleGroupClicked():void { + var item:ComponentDescription = data as ComponentDescription; + var visible:Boolean = !item.instance.visible; + + item.instance.visible = visible; + item.visible = visible; + visibleGroup.visible = visible; + + var rootApplicationDescription:ComponentDescription = Tree(owner).dataProvider.getItemAt(0) as ComponentDescription; + var visibility:Boolean = DisplayObjectUtils.getGreatestVisibility(IVisualElement(item.instance), rootApplicationDescription); + + DisplayObjectUtils.setVisibilityFlag(item, item.visible); + + //parentVisibleGroup.visible = !visibility; + + } + + protected function creationCompleteHandler(event:FlexEvent):void { + + if (_visibleButtonGroup) { + _visibleButtonGroup.addEventListener(MouseEvent.MOUSE_DOWN, visibleButtonGroup_mouseDownHandler); + _visibleButtonGroup.addEventListener(MouseEvent.CLICK, visibleButtonGroup_clickHandler); + } + } + + /** + * @private + * Handle special behavior when mouse down on the visible icon + */ + protected function visibleButtonGroup_mouseDownHandler(event:MouseEvent):void { + // stops selection of row + // however we still handle action in the click event + event.stopPropagation(); + } + + /** + * @private + * Handle special behavior when clicking on the visible icon + */ + protected function visibleButtonGroup_clickHandler(event:MouseEvent):void { + visibleGroupClicked(); + } + + ]]> + </fx:Script> + + <s:states> + <s:State name="normal"/> + <s:State name="selected"/> + </s:states> + + <s:Group width="100%" height="100%" left="0" right="2"> + <s:Rect width="100%" height="100%" alpha="1"> + <s:fill> + <s:SolidColor color="#f6f6f6"/> + </s:fill> + </s:Rect> + </s:Group> + + <s:HGroup left="0" + right="0" + gap="2" + verticalCenter="0" + verticalAlign="middle"> + + <s:Spacer width="0"/> + + <!--- visible --> + <s:Group id="_visibleButtonGroup" > + <!--- visible image --> + <s:BitmapImage id="visibleGroup" + contentLoader="{Radiate.contentCache}" + source="{Radii8LibraryAssets.visible}" + left="0" + verticalCenter="0" + height="14"/> + + <!--- fade out visible image if parent is not visible --> + <s:Rect id="parentVisibleGroup" width="16" height="16" alpha="0.3" + visible="{!ComponentDescription(data).parentVisible && ComponentDescription(data).visible}"> + <s:fill> + <s:SolidColor color="#666666"/> + </s:fill> + </s:Rect> + + </s:Group> + + <!--- divider --> + <s:Rect width="1" height="100%" + visible="true" + includeInLayout="true" + left="20" + > + <s:fill> + <s:SolidColor color="#d4d4d4"/> + </s:fill> + </s:Rect> + + <!--- lock --> + <s:Group includeInLayout="false" visible="false"> + <s:Rect width="16" height="16" alpha=".1"> + <s:fill> + <s:SolidColor color="#666666"/> + </s:fill> + </s:Rect> + </s:Group> + + <!--- divider --> + <s:Rect width="1" height="100%" visible="false" includeInLayout="false"> + <s:fill> + <s:SolidColor color="#d4d4d4"/> + </s:fill> + </s:Rect> + + <s:Rect id="indentationSpacer" + width="{treeListData.indent}" + height="20" + alpha="0.1"> + <s:fill> + <s:SolidColor color="0xFFFFFF" /> + </s:fill> + </s:Rect> + + <s:Group id="disclosureGroup"> + <s:BitmapImage source="{treeListData.disclosureIcon}" + height="16" + visible="{treeListData.hasChildren}" /> + </s:Group> + <s:BitmapImage id="iconImage" + source="{treeListData.icon}" + contentLoader="{Radiate.contentCache}" + ioError="iconImage_ioErrorHandler(event)" + width="16" height="16"/> + <s:Label id="labelDisplay" + fontSize="10" + paddingLeft="3" + typographicCase="lowercaseToSmallCaps"/> + </s:HGroup> +</s:MXTreeItemRenderer> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/renderers/NumberRenderer.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/renderers/NumberRenderer.mxml b/Radii8Library/src/com/flexcapacitor/views/renderers/NumberRenderer.mxml new file mode 100644 index 0000000..31b3798 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/renderers/NumberRenderer.mxml @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<r:PropertiesGridRendererBase xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + xmlns:c="com.flexcapacitor.components.*" + xmlns:r="com.flexcapacitor.views.renderers.*" + + clipAndEnableScrolling="true"> + + <fx:Script> + <![CDATA[ + import com.flexcapacitor.skins.ClearButton; + + + /** + * Format numeric stepper + * Trim down to 2 decimal places. + * */ + public function formatNumericStepper(value:Number):String { + + return String(int(value*100)/100); + } + ]]> + </fx:Script> + + <r:layout> + <s:HorizontalLayout /> + </r:layout> + + <s:NumericStepper id="numericStepper" + width="100%" + valueFormatFunction="formatNumericStepper" + change="setTargetValue()"/> + <s:Button id="clearStyleButton" + skinClass="com.flexcapacitor.skins.ClearButton" + click="setTargetValue(true)" + right="0" + verticalCenter="0" + /> +</r:PropertiesGridRendererBase> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/renderers/PropertiesGridRendererBase.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/renderers/PropertiesGridRendererBase.mxml b/Radii8Library/src/com/flexcapacitor/views/renderers/PropertiesGridRendererBase.mxml new file mode 100644 index 0000000..1a092da --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/renderers/PropertiesGridRendererBase.mxml @@ -0,0 +1,527 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + + clipAndEnableScrolling="true"> + + <fx:Script> + <![CDATA[ + import com.flexcapacitor.components.ColorChooser; + import com.flexcapacitor.controller.Radiate; + import com.flexcapacitor.model.AccessorMetaData; + import com.flexcapacitor.model.MetaData; + import com.flexcapacitor.model.StyleMetaData; + + import mx.collections.ArrayCollection; + + import spark.components.Button; + import spark.components.ComboBox; + import spark.components.DropDownList; + import spark.components.NumericStepper; + import spark.components.RadioButton; + import spark.components.RadioButtonGroup; + import spark.components.TextArea; + import spark.components.supportClasses.DropDownListBase; + + + /** + * Group radio buttons, usually boolean true and false values, are part of. + * */ + public var booleanGroup:RadioButtonGroup; + + /** + * Boolean true radio button value + * */ + public var booleanEnabledRadioButton:RadioButton; + + /** + * Boolean false radio button value + * */ + public var booleanDisabledRadioButton:RadioButton; + + /** + * Color chooser component + * */ + public var colorChooser:ColorChooser; + + /** + * Numeric stepper value + * */ + public var numericStepper:NumericStepper; + + /** + * Combobox of choices + * */ + public var formatCombobox:ComboBox; + + /** + * Drop down list of choices + * */ + public var formatDropDownList:DropDownList; + + /** + * Text area for text values + * */ + public var targetValueText:TextArea; + + /** + * Flag indicating if setting properties + * */ + public var settingProperties:Boolean; + + /** + * Clear style button + * */ + public var clearStyleButton:Button; + + /** + * Label field of combobox, drop down list or list + * */ + public var labelField:String; + + /** + * Label function of combobox, drop down list or list + * */ + public var labelFunction:Function; + + + [Bindable] + public var labelWidth:int = 80; + + /** + * Option to show clear button if style + * */ + public var showClearButton:Boolean = true; + + /** + * If true the value to apply to the target is a field of the selected item + * */ + public var valueIsField:Boolean; + + /** + * If true then the selected item is selected by the value of the target + * */ + public var fieldIsValue:Boolean; + + /** + * Collection of choices for combobox, drop down list or list + * */ + [Bindable] + public var formatsCollection:ArrayCollection; + + /** + * Set data + * */ + override public function set data(value:Object):void { + super.data = value; + + if (data is AccessorMetaData) { + updateSubComponentsValue(); + } + else if (data is StyleMetaData) { + updateSubComponentsValue(); + } + else if (data is XML) { + updateSubComponentsValueXML(); + } + } + + + /** + * Set the property to the new value + * */ + public function setTargetValue(clearStyle:Boolean = false):void { + var item:XML = data as XML; + var target:Object = Radiate.getInstance().target; // does not support multiple targets yet + var actualValue:*; + var isStyle:int; + var styleIsColor:Boolean; + var valueSuccessfullyApplied:Boolean; + var propertyObject:MetaData; + var type:String; + var enumeration:Array; + var format:String; + var inherit:Boolean; + var property:String; + var value:String; + var nodename:String; + var access:String; + var textValue:String; + + if (item) { + nodename = item.name(); + + if (nodename=="metadata") { + isStyle = 1; + propertyObject = new StyleMetaData(item, target); + } + else if (nodename=="accessor") { + propertyObject = new AccessorMetaData(item, target); + } + else { + propertyObject = new MetaData(item, target); + } + + + } + else if (data) { + propertyObject = data as MetaData; + } + + if (propertyObject is AccessorMetaData) { + access = AccessorMetaData(propertyObject).access; + } + else if (propertyObject is StyleMetaData) { + isStyle = 1; + } + + // since we try to capture values for history + // ReferenceError: Error #1077: Illegal read of write-only property cacheHeuristic on application. + if (access=="writeonly") { + return; + } + + + // property or style was not found + if (!propertyObject) { + return; + } + + value = String(propertyObject.value); + textValue = propertyObject.textValue; + property = propertyObject.name; + type = propertyObject.type; + format = propertyObject.format; + enumeration = propertyObject.enumeration; + + /* + var type:Type = Type.forInstance(target); + var metadataItems:Array = type.metadata; + var b:Array = type.getMetadata("Style"); + var metadata:Metadata = Metadata(metadataItems[0]); + var hasFormat:Boolean = metadata.hasArgumentWithKey("type"); + var o:MetadataArgument = metadata.getArgument("type"); + var xc:XML = MetadataUtils.getFromObject(target);*/ + + + // dynamic way to set property or style in data grid + if (type=="Boolean" && booleanGroup) { + if (isStyle) { + actualValue = booleanGroup.selection==null ? undefined : booleanGroup.selection==booleanEnabledRadioButton; + } + else { + actualValue = booleanGroup.selection==booleanEnabledRadioButton; + } + } + // let SetAction convert 0xFF, #ff and red, ReD + else if (format=="Color") { + actualValue = colorChooser.selectedColor; + } + else if (type=="Number") { + actualValue = numericStepper.value; + + if (property.indexOf("lpha")!=-1) {//round down to two places + actualValue = int(actualValue*100)/100; + } + } + else if (type=="String" && enumeration && enumeration.length>0) { + + if (formatDropDownList) { + if (valueIsField && labelField) { + actualValue = formatDropDownList.selectedItem[labelField]; + } + else { + actualValue = formatDropDownList.selectedItem; + } + } + else if (formatCombobox) { + if (valueIsField && labelField) { + actualValue = formatCombobox.selectedItem[labelField]; + } + else { + actualValue = formatCombobox.selectedItem; + } + } + } + else { + actualValue = Radiate.getTypedValue(targetValueText.text, type); + } + + // do not auto update if setting properties + settingProperties = true; + + if (isStyle) { + if (clearStyle) { + valueSuccessfullyApplied = Radiate.clearStyle(target, property); + } + else { + valueSuccessfullyApplied = Radiate.setStyle(target, property, actualValue); + } + } + else { + valueSuccessfullyApplied = Radiate.setProperty(target, property, actualValue); + } + + settingProperties = false; + } + + /** + * Get the value from the datagrid and + * show the correct sub component and + * set it's value. + * Depricated. Use non-XML data objects + * */ + public function updateSubComponentsValueXML():void { + var item:XML = data as XML; + var target:Object = Radiate.getInstance().target; + var actualValue:*; + var isStyle:Boolean; + var type:String; + var enumeration:Array; + var format:String; + var propertyObject:MetaData; + var property:String; + var value:String; + var nodename:String; + + if (!target) return; + + if (settingProperties) return; + + if (item) { + nodename = item.name(); + + if (nodename=="metadata") { + isStyle = true; + propertyObject = new StyleMetaData(item, target); + } + else if (nodename=="accessor") { + propertyObject = new AccessorMetaData(item, target); + } + else { + propertyObject = new MetaData(item, target); + } + + // property or style not found! + if (!propertyObject) { + return; + } + + value = String(propertyObject.value); + property = propertyObject.name; + type = propertyObject.type; + format = propertyObject.format; + enumeration = propertyObject.enumeration; + + + if (type=="Boolean") { + booleanEnabledRadioButton.selected = false; + booleanDisabledRadioButton.selected = false; + + if (value=="true") { + booleanEnabledRadioButton.selected = true; + } + else if (value=="false") { + booleanDisabledRadioButton.selected = true; + } + + clearStyleButton.visible = isStyle; + } + else if (format=="Color") { + colorChooser.selectedColor = value; + clearStyleButton.visible = isStyle; + } + else if (enumeration && enumeration.length>0) { + if (!formatsCollection) formatsCollection = new ArrayCollection(); + formatsCollection.source = enumeration; + formatCombobox.selectedItem = propertyObject.value; + clearStyleButton.visible = isStyle; + } + else if (type=="Number") { + numericStepper.value = propertyObject.value; + + if (!isNaN(propertyObject.minValue)) { + numericStepper.minimum = propertyObject.minValue; + } + else { + numericStepper.minimum = Number(int.MIN_VALUE); + } + if (!isNaN(propertyObject.maxValue)) { + numericStepper.maximum = propertyObject.maxValue; + } + else { + numericStepper.maximum = Number(int.MAX_VALUE); + } + + if (property.indexOf("lpha")!=-1) { + numericStepper.stepSize = .1; + + if (isNaN(propertyObject.minValue)) { + numericStepper.minimum = 0; + } + if (isNaN(propertyObject.maxValue)) { + numericStepper.maximum = 1; + } + } + else { + numericStepper.stepSize = 1; + } + + clearStyleButton.visible = isStyle; + } + else { + actualValue = Radiate.getTypedValue(targetValueText.text, type); + targetValueText.text= propertyObject.value; + clearStyleButton.visible = isStyle; + } + + + Radiate.getInstance().dispatchPropertySelectedEvent(property, propertyObject); + } + + } + + /** + * Get the value from the target and + * show the correct inspector with the correct target value. + * */ + public function updateSubComponentsValue():void { + var target:Object = Radiate.getInstance().target; + var propertyObject:MetaData = data as MetaData; + var isStyle:Boolean = propertyObject is StyleMetaData; + var actualValue:*; + var type:String; + var enumeration:Array; + var format:String; + var property:String; + var value:String; + var nodename:String; + + //if (!target) return; + + if (settingProperties) return; + + if (data) { + + value = String(propertyObject.value); + value = propertyObject.textValue; + property = propertyObject.name; + type = propertyObject.type; + format = propertyObject.format; + enumeration = propertyObject.enumeration; + + if (showClearButton && isStyle) { + clearStyleButton.visible = isStyle; + } + else { + clearStyleButton.visible = false; + } + + if (type=="Boolean") { + booleanEnabledRadioButton.selected = false; + booleanDisabledRadioButton.selected = false; + + if (value=="true") { + booleanEnabledRadioButton.selected = true; + } + else if (value=="false") { + booleanDisabledRadioButton.selected = true; + } + + } + else if (format=="Color") { + colorChooser.selectedColor = value; + } + else if ((enumeration && enumeration.length>0) || formatCombobox || formatDropDownList) { + + var dropDownListBase:DropDownListBase = formatCombobox ? formatCombobox : formatDropDownList; + + if (!formatsCollection) formatsCollection = new ArrayCollection(); + formatsCollection.source = enumeration; + + if (labelField) dropDownListBase.labelField = labelField; + + if (labelFunction!=null) dropDownListBase.labelFunction = labelFunction; + + + if (fieldIsValue && labelField) { + var length:int = enumeration.length; + //var value:Object = propertyObject.value; + + for (var i:int;i<length;i++) { + var item:Object = enumeration[i]; + if (value == item[labelField]) { + dropDownListBase.selectedItem = item; + break; + } + } + + } + else { + dropDownListBase.selectedItem = propertyObject.value; + } + } + else if (type=="Number") { + numericStepper.value = propertyObject.value; + + if (!isNaN(propertyObject.minValue)) { + numericStepper.minimum = propertyObject.minValue; + } + else { + numericStepper.minimum = Number(int.MIN_VALUE); + } + if (!isNaN(propertyObject.maxValue)) { + numericStepper.maximum = propertyObject.maxValue; + } + else { + numericStepper.maximum = Number(int.MAX_VALUE); + } + + if (property.indexOf("lpha")!=-1) { + numericStepper.stepSize = .1; + + if (isNaN(propertyObject.minValue)) { + numericStepper.minimum = 0; + } + if (isNaN(propertyObject.maxValue)) { + numericStepper.maximum = 1; + } + } + else { + numericStepper.stepSize = 1; + } + + } + else { + actualValue = Radiate.getTypedValue(targetValueText.text, type); + targetValueText.text = propertyObject.value; + } + + + Radiate.getInstance().dispatchPropertySelectedEvent(property, propertyObject); + } + + } + ]]> + </fx:Script> + +</s:GridItemRenderer> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/renderers/PropertiesGridValuesRenderer.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/renderers/PropertiesGridValuesRenderer.mxml b/Radii8Library/src/com/flexcapacitor/views/renderers/PropertiesGridValuesRenderer.mxml new file mode 100644 index 0000000..813436d --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/renderers/PropertiesGridValuesRenderer.mxml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + + clipAndEnableScrolling="true" + minHeight="14"> + + <s:Label id="labelDisplay" + verticalCenter="1" left="0" right="0" top="0" bottom="0" + fontSize="12" + paddingTop="3" + paddingBottom="3" + paddingLeft="3" + paddingRight="3" + textAlign="start" + verticalAlign="middle" + maxDisplayedLines="1" + showTruncationTip="true" /> + +</s:GridItemRenderer> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/renderers/TextRenderer.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/renderers/TextRenderer.mxml b/Radii8Library/src/com/flexcapacitor/views/renderers/TextRenderer.mxml new file mode 100644 index 0000000..3233f62 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/renderers/TextRenderer.mxml @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<r:PropertiesGridRendererBase xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + xmlns:c="com.flexcapacitor.components.*" + xmlns:r="com.flexcapacitor.views.renderers.*" + + clipAndEnableScrolling="true"> + + <fx:Script> + <![CDATA[ + import com.flexcapacitor.skins.ClearButton; + + import spark.events.TextOperationEvent; + import spark.skins.spark.TextAreaSkin; + + import flashx.textLayout.operations.SplitParagraphOperation; + + /** + * Prevents line breaks + * */ + protected function targetValueText_changingHandler(event:TextOperationEvent):void { + + // prevent line breaks + if (event.operation is SplitParagraphOperation) { + event.preventDefault(); + } + } + + protected function targetValueText_keyUpHandler(event:KeyboardEvent):void { + var value:String; + + if (event.keyCode==Keyboard.ENTER && !event.shiftKey) { + setTargetValue(); + event.preventDefault(); + } + else if (event.keyCode==Keyboard.ESCAPE) { + if (data is XML) { + value = String(data.@value); + } + else { + value = String(data.value); + } + targetValueText.text = value; + event.preventDefault(); + } + } + + protected function targetValueText_focusOutHandler(event:FocusEvent):void { + setTargetValue(); + //event.preventDefault(); + } + + ]]> + </fx:Script> + + <s:TextArea id="targetValueText" + width="100%" + height="100%" + borderAlpha="0.2" + skinClass="spark.skins.spark.TextAreaSkin" + keyUp="targetValueText_keyUpHandler(event)" + focusOut="targetValueText_focusOutHandler(event)" + changing="targetValueText_changingHandler(event)" + > + </s:TextArea> + + <s:Button id="clearStyleButton" + skinClass="com.flexcapacitor.skins.ClearButton" + click="setTargetValue(true)" + right="0" + verticalCenter="0"/> + +</r:PropertiesGridRendererBase> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/skins/AutoSaveToggleButton.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/skins/AutoSaveToggleButton.mxml b/Radii8Library/src/com/flexcapacitor/views/skins/AutoSaveToggleButton.mxml new file mode 100644 index 0000000..dac07da --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/skins/AutoSaveToggleButton.mxml @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:fc="http://ns.adobe.com/flashcatalyst/2009" + > + + <fx:Metadata> + [HostComponent("spark.components.ToggleButton")] + </fx:Metadata> + + <s:states> + <s:State name="up" /> + <s:State name="over" /> + <s:State name="down" /> + <s:State name="disabled" /> + <s:State name="upAndSelected" /> + <s:State name="overAndSelected" /> + <s:State name="downAndSelected" /> + <s:State name="disabledAndSelected" /> + </s:states> + + <!-- we need a hit area since bitmap image does not have a hit area? or was enabled false? --> + <s:Rect width="100%" height="100%"> + <s:fill> + <s:SolidColor alpha="0"/> + </s:fill> + </s:Rect> + + + <!-- images --> + <s:BitmapImage x="0" y="0" smooth="true" + source="{Radii8LibraryAssets.save}"/> + + <!-- images --> + <s:BitmapImage includeIn="disabled,down,over,up" + x="0" y="0" smooth="true" alpha="0.1" + source="{Radii8LibraryAssets.disconnected}"/> + <s:BitmapImage includeIn="disabledAndSelected,downAndSelected,overAndSelected,upAndSelected" + x="0" y="0" smooth="true" alpha="0.5" + source="{Radii8LibraryAssets.connected}"/> + + +</s:Skin> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/skins/LoopButton.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/skins/LoopButton.mxml b/Radii8Library/src/com/flexcapacitor/views/skins/LoopButton.mxml new file mode 100644 index 0000000..d8a06a0 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/skins/LoopButton.mxml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:fc="http://ns.adobe.com/flashcatalyst/2009" + width="14" height="15" > + + <fx:Metadata> + [HostComponent("spark.components.ToggleButton")] + </fx:Metadata> + + <s:states> + <s:State name="up" /> + <s:State name="over" /> + <s:State name="down" /> + <s:State name="disabled" /> + <s:State name="upAndSelected" /> + <s:State name="overAndSelected" /> + <s:State name="downAndSelected" /> + <s:State name="disabledAndSelected" /> + </s:states> + + <!-- background --> + <!-- shadow (down state only) --> + + <!-- label --> + <s:BitmapImage includeIn="disabled,down,over,up" x="0" y="0" smooth="true" + source="{Radii8LibraryEffectsAssets.loopOff}"/> + <s:BitmapImage includeIn="disabledAndSelected,downAndSelected,overAndSelected,upAndSelected" x="0" y="0" smooth="true" + source="{Radii8LibraryEffectsAssets.loopOn}"/> + + +</s:Skin> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/skins/OnlineToggleButton.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/skins/OnlineToggleButton.mxml b/Radii8Library/src/com/flexcapacitor/views/skins/OnlineToggleButton.mxml new file mode 100644 index 0000000..226f97c --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/skins/OnlineToggleButton.mxml @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:fc="http://ns.adobe.com/flashcatalyst/2009" + > + + <fx:Metadata> + [HostComponent("spark.components.ToggleButton")] + </fx:Metadata> + + <s:states> + <s:State name="up" /> + <s:State name="over" /> + <s:State name="down" /> + <s:State name="disabled" /> + <s:State name="upAndSelected" /> + <s:State name="overAndSelected" /> + <s:State name="downAndSelected" /> + <s:State name="disabledAndSelected" /> + </s:states> + + <!-- we need a hit area since bitmap image does not have a hit area --> + <s:Rect width="100%" height="100%"> + <s:fill> + <s:SolidColor alpha="0"/> + </s:fill> + </s:Rect> + + + <!-- images --> + <s:BitmapImage includeIn="disabled,down,over,up" + x="0" y="0" smooth="true" + source="{Radii8LibraryAssets.disconnected}"/> + <s:BitmapImage includeIn="disabledAndSelected,downAndSelected,overAndSelected,upAndSelected" + x="0" y="0" smooth="true" + source="{Radii8LibraryAssets.connected}"/> + + +</s:Skin> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/skins/OrientationButton.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/skins/OrientationButton.mxml b/Radii8Library/src/com/flexcapacitor/views/skins/OrientationButton.mxml new file mode 100644 index 0000000..43c3bca --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/skins/OrientationButton.mxml @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:fc="http://ns.adobe.com/flashcatalyst/2009" + > + + <fx:Metadata> + [HostComponent("spark.components.ToggleButton")] + </fx:Metadata> + + <s:states> + <s:State name="up" /> + <s:State name="over" /> + <s:State name="down" /> + <s:State name="disabled" /> + <s:State name="upAndSelected" /> + <s:State name="overAndSelected" /> + <s:State name="downAndSelected" /> + <s:State name="disabledAndSelected" /> + </s:states> + + <!-- background --> + <!-- shadow (down state only) --> + + <!-- label --> + <s:BitmapImage includeIn="disabled,down,over,up" + x="0" + smooth="true" + source="{Radii8LibraryAssets.landscapeMode}"/> + <s:BitmapImage includeIn="disabledAndSelected,downAndSelected,overAndSelected,upAndSelected" + x="0" + smooth="true" + verticalAlign="middle" + source="{Radii8LibraryAssets.portraitMode}" /> + + +</s:Skin> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/skins/PropertiesDataGridSkin.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/skins/PropertiesDataGridSkin.mxml b/Radii8Library/src/com/flexcapacitor/views/skins/PropertiesDataGridSkin.mxml new file mode 100644 index 0000000..bcf5c67 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/skins/PropertiesDataGridSkin.mxml @@ -0,0 +1,359 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> + +<!--- + +Added columnSeparatorAlpha alpha to 0; + +Added headerSeparatorAlpha style + +--> + + + +<!--- +The default skin class for a Spark DataGrid component. + +<p>This skin defines all of the optional DataGrid skin parts except for rowBackground +(by default, no per-row background visual element is displayed). +It defines the default value for the grid's itemRenderer property as +spark.skins.spark.DefaultGridItemRenderer, and the default value of the +columnHeaderGroup's headerRenderer property as +<code>spark.skins.spark.DefaultGridHeaderRenderer</code>.</p> + +<p>The values of the following DataGrid skin parts are defined by declarations +and can be overridden by subclasses of this class: <code>alternatingRowColors</code>, +<code>caretIndicator</code>, <code>columnSeparator</code>, <code>editorIndicator</code>, +<code>headerColumnSeparator</code>, <code>hoverIndicator</code>, +<code>rowSeparator</code>, <code>selectionIndicator</code>. All of these +declarations define DataGrid skin parts except <code>headerColumnSeparator</code> and +<code>headerRenderer</code> which are used for the values of the columnHeaderGroup's +<code>columnSeparator</code> and <code>headerRenderer</code> properties.</p> + +@see spark.components.DataGrid +@langversion 3.0 +@playerversion Flash 10 +@playerversion AIR 2.5 +@productversion Flex 4.5 +--> + +<s:SparkSkin + xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + xmlns:fb="http://ns.adobe.com/flashbuilder/2009" + alpha.disabled="0.5" minWidth="89" minHeight="84"> + + <fx:Metadata> + [HostComponent("com.flexcapacitor.controls.DataGrid")] + </fx:Metadata> + + <s:states> + <s:State name="normal" /> + <s:State name="disabled" /> + </s:states> + + <fx:Declarations> + <!--- @private --> + <fx:Component id="alternatingRowColorsBackground"> + <s:Rect implements="spark.components.gridClasses.IGridVisualElement"> + <fx:Script> + <![CDATA[ + import spark.components.DataGrid; + import spark.components.Grid; + + /** + * @private + */ + public function prepareGridVisualElement(grid:Grid, rowIndex:int, columnIndex:int):void + { + const dataGrid:DataGrid = grid.dataGrid; + if (!dataGrid) + return; + + const colors:Array = dataGrid.getStyle("alternatingRowColors"); + if (colors && (colors.length > 0)) + { + dataGrid.styleManager.getColorNames(colors); // lazily replace color names with ints + rowBackgroundFillColor.color = colors[rowIndex % colors.length]; + } + else + { + // This should be the same as bgFill.color. + rowBackgroundFillColor.color = 0xFFFFFF; + } + } + ]]> + </fx:Script> + <s:fill> + <!--- @private --> + <s:SolidColor id="rowBackgroundFillColor" color="0xFFFFFF"/> + </s:fill> + </s:Rect> + </fx:Component> + + <!--- @private --> + <fx:Component id="caretIndicator"> + <s:Rect implements="spark.components.gridClasses.IGridVisualElement"> + <fx:Script> + <![CDATA[ + import spark.components.DataGrid; + import spark.components.Grid; + + /** + * @private + */ + public function prepareGridVisualElement(grid:Grid, rowIndex:int, columnIndex:int):void + { + const dataGrid:DataGrid = grid.dataGrid; + if (!dataGrid) + return; + + const color:uint = dataGrid.getStyle("caretColor"); + caretIndicatorFill.color = color; + } + ]]> + </fx:Script> + + <s:stroke> + <!--- @private --> + <s:SolidColorStroke id="caretIndicatorFill" color="0x0167FF" weight="1"/> + </s:stroke> + </s:Rect> + </fx:Component> + + <!--- @private --> + <fx:Component id="columnSeparator"> + <s:Line> + <s:stroke> + <s:SolidColorStroke color="0xE6E6E6" weight="0" caps="square" alpha="0"/> + </s:stroke> + </s:Line> + </fx:Component> + + <!--- Defines the value of the columnSeparator property for the columnHeaderGroup. --> + <fx:Component id="headerColumnSeparator"> + <s:Line> + <s:stroke> + <s:SolidColorStroke color="0x696969" weight="1" caps="square"/> + </s:stroke> + </s:Line> + </fx:Component> + + <!--- Defines the value of the headerRenderer property for the columnHeaderGroup. + The default is spark.skins.spark.DefaultGridHeaderRenderer --> + <fx:Component id="headerRenderer"> + <s:DefaultGridHeaderRenderer /> + </fx:Component> + + <!--- @private --> + <fx:Component id="hoverIndicator"> + <s:Rect implements="spark.components.gridClasses.IGridVisualElement"> + <fx:Script> + <![CDATA[ + import spark.components.DataGrid; + import spark.components.Grid; + + /** + * @private + */ + public function prepareGridVisualElement(grid:Grid, rowIndex:int, columnIndex:int):void + { + const dataGrid:DataGrid = grid.dataGrid; + if (!dataGrid) + return; + + const color:uint = dataGrid.getStyle("rollOverColor"); + hoverIndicatorFill.color = color; + } + ]]> + </fx:Script> + + <s:fill> + <!--- @private --> + <s:SolidColor id="hoverIndicatorFill" color="0xCEDBEF"/> + </s:fill> + </s:Rect> + </fx:Component> + + <!--- @private --> + <fx:Component id="rowSeparator"> + <s:Line visible="false"> + <s:stroke> + <s:SolidColorStroke color="0xE6E6E6" weight="1" caps="square"/> + </s:stroke> + </s:Line> + </fx:Component> + + <!--- @private --> + <fx:Component id="selectionIndicator"> + <s:Rect implements="spark.components.gridClasses.IGridVisualElement"> + <fx:Script> + <![CDATA[ + import spark.components.DataGrid; + import spark.components.Grid; + + /** + * @private + */ + public function prepareGridVisualElement(grid:Grid, rowIndex:int, columnIndex:int):void + { + const dataGrid:DataGrid = grid.dataGrid; + if (!dataGrid) + return; + + const color:uint = dataGrid.getStyle("selectionColor"); + selectionIndicatorFill.color = color; + } + ]]> + </fx:Script> + + <s:fill> + <!--- @private --> + <s:SolidColor id="selectionIndicatorFill" color="0xA8C6EE"/> + </s:fill> + </s:Rect> + </fx:Component> + + <!--- @private --> + <fx:Component id="editorIndicator"> + <s:Rect> + <s:fill> + <s:SolidColor color="0xFFFFFF"/> + </s:fill> + </s:Rect> + </fx:Component> + + </fx:Declarations> + + <fx:Script fb:purpose="styling"> + <![CDATA[ + static private const exclusions:Array = ["scroller", "background", "columnHeaderGroup"]; + static private const contentFill:Array = ["bgFill"]; + + /** + * @private + */ + override public function get colorizeExclusions():Array {return exclusions;} + + /** + * @private + */ + override public function get contentItems():Array {return contentFill}; + + /** + * @private + */ + override protected function initializationComplete():void + { + useChromeColor = true; + super.initializationComplete(); + } + + /** + * @private + */ + override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void + { + if (getStyle("borderVisible") == true) + { + border.visible = true; + background.left = background.top = background.right = background.bottom = 1; + scroller.minViewportInset = 1; + } + else + { + border.visible = false; + background.left = background.top = background.right = background.bottom = 0; + scroller.minViewportInset = 0; + } + + borderStroke.color = getStyle("borderColor"); + borderStroke.alpha = getStyle("borderAlpha"); + + if (getStyle("headerSeparatorAlpha")!==undefined) { + headerSeparator.alpha = getStyle("headerSeparatorAlpha"); + } + + if (columnHeaderGroup && columnHeaderGroup.columnSeparator && + getStyle("columnSeparatorAlpha")!==undefined) { + Object(columnHeaderGroup.columnSeparator).alpha = getStyle("headerSeparatorAlpha"); + } + + super.updateDisplayList(unscaledWidth, unscaledHeight); + } + ]]> + </fx:Script> + + <!-- column header, content --> + <s:VGroup horizontalAlign="justify" gap="0" left="0" right="0" top="0" bottom="0"> + + <!--- @private --> + <s:GridColumnHeaderGroup id="columnHeaderGroup" + paddingLeft="1" paddingTop="1" paddingRight="1" minHeight="21" + columnSeparator="{headerColumnSeparator}" + headerRenderer="{headerRenderer}"/> + + <s:Group height="100%"> + + <!--- @private --> + <s:Rect id="background" left="1" right="1" top="1" bottom="1" > + <s:fill> + <!--- Defines the color of the background. The default color is 0xFFFFFF. --> + <s:SolidColor id="bgFill" color="0xFFFFFF" /> + </s:fill> + </s:Rect> + + <!-- header separator, scroller and grid --> + <s:VGroup horizontalAlign="justify" height="100%" width="100%" gap="-1"> + <!--- @private --> + <s:Line id="headerSeparator"> + <s:stroke> + <s:SolidColorStroke color="0x696969" weight="1" caps="square"/> + </s:stroke> + </s:Line> + + <!--- @private --> + <s:Scroller id="scroller" minViewportInset="1" hasFocusableChildren="false" height="100%"> + <!--- @private --> + <s:Grid id="grid" itemRenderer="spark.skins.spark.DefaultGridItemRenderer"> + <s:GridLayer name="backgroundLayer"/> + <s:GridLayer name="selectionLayer"/> + <s:GridLayer name="editorIndicatorLayer"/> + <s:GridLayer name="rendererLayer"/> + <s:GridLayer name="overlayLayer"/> + </s:Grid> + </s:Scroller> + </s:VGroup> + + </s:Group> + + </s:VGroup> + + <!-- border --> + <!--- @private --> + <s:Rect left="0" right="0" top="0" bottom="0" id="border"> + <s:stroke> + <!--- @private --> + <s:SolidColorStroke id="borderStroke" weight="1"/> + </s:stroke> + </s:Rect> + +</s:SparkSkin> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/supportClasses/LayersDataDescriptor.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/supportClasses/LayersDataDescriptor.as b/Radii8Library/src/com/flexcapacitor/views/supportClasses/LayersDataDescriptor.as new file mode 100644 index 0000000..4cd0949 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/supportClasses/LayersDataDescriptor.as @@ -0,0 +1,90 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.views.supportClasses { + import mx.controls.treeClasses.DefaultDataDescriptor; + import mx.core.IVisualElementContainer; + + import spark.components.Application; + + /** + * Describes how project data is displayed in a tree + * */ + public class LayersDataDescriptor extends DefaultDataDescriptor { + + + public function LayersDataDescriptor() { + super(); + } + + /** + * Get documents for now + * */ + /*override public function getChildren(node:Object, model:Object = null):ICollectionView { + if ("documents" in node) { + return node.documents; + } + + return null; + }*/ + + + /** + * Tests a node for termination. + * Branches are non-terminating but are not required to have any leaf nodes. + * If the node is XML, returns <code>true</code> if the node has children + * or a <code>true isBranch</code> attribute. + * If the node is an object, returns <code>true</code> if the node has a + * (possibly empty) <code>children</code> field. + * + * @param node The node object currently being evaluated. + * @param model The collection that contains the node; ignored by this class. + * + * @return <code>true</code> if this node is non-terminating. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + override public function isBranch(node:Object, model:Object = null):Boolean + { + if (node == null) + return false; + + var branch:Boolean = false; + + if (node is Object) + { + try + { + if (node.instance is IVisualElementContainer || node.instance is Application) + { + branch = true; + } + } + catch(e:Error) + { + } + } + return branch; + } + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/supportClasses/Styles.as ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/supportClasses/Styles.as b/Radii8Library/src/com/flexcapacitor/views/supportClasses/Styles.as new file mode 100644 index 0000000..b41ae9f --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/supportClasses/Styles.as @@ -0,0 +1,80 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.views.supportClasses { + + /** + * Styles for HTML elements + * */ + public class Styles { + + /** + * Constructor + * */ + public function Styles() { + + } + + public static const POSITION:String = "position"; + public static const RELATIVE:String = "relative"; + public static const ABSOLUTE:String = "absolute"; + public static const FIXED:String = "fixed"; + + public static const BLOCK:String = "block"; + public static const INLINE:String = "inline"; + public static const INLINE_BLOCK:String = "inline-block"; + + public static const MARGIN_CENTER:String = "auto auto"; + public static const MARGIN_HORIZONTAL_CENTER:String = "0 auto"; + public static const MARGIN_VERTICAL_CENTER:String = "auto 0"; + + + public static const PADDING_LEFT:String = "padding-left"; + public static const PADDING_RIGHT:String = "padding-right"; + public static const PADDING_TOP:String = "padding-top"; + public static const PADDING_BOTTOM:String = "padding-bottom"; + + + public static const MARGIN_LEFT:String = "margin-left"; + public static const MARGIN_RIGHT:String = "margin-right"; + public static const MARGIN_TOP:String = "margin-top"; + public static const MARGIN_BOTTOM:String = "margin-bottom"; + + + public var position:String; + public var display:String; + public var margin:String; + + public var paddingRight:String; + public var paddingLeft:String; + public var paddingTop:String; + public var paddingBottom:String; + + public var marginRight:String; + public var marginLeft:String; + public var marginTop:String; + public var marginBottom:String; + + public var left:String; + public var top:String; + public var right:String; + public var bottom:String; + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/windows/AnimatedPanelWindow.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/windows/AnimatedPanelWindow.mxml b/Radii8Library/src/com/flexcapacitor/views/windows/AnimatedPanelWindow.mxml new file mode 100644 index 0000000..4efebb3 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/windows/AnimatedPanelWindow.mxml @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + + creationCompleteEffect="{addedEffect}" + removedEffect="{removedEffect}" + > + + + <fx:Script> + <![CDATA[ + import com.flexcapacitor.controller.Radiate; + + import mx.core.mx_internal; + + use namespace mx_internal; + + [Bindable] + public var inProgress:Boolean; + + public var radiate:Radiate; + + public var closePanelDelay:int = 500; + + private var moveAdded:Boolean; + + public function addMoveEffect():void { + if (!moveAdded) { + //trace("added move effect"); + //setStyle("moveEffect", moveEffect); + setStyle("moveEffect", "Move"); + moveAdded = true; + } + } + ]]> + </fx:Script> + + <fx:Declarations> + + <s:Parallel id="removedEffect" target="{this}" suspendBackgroundProcessing="false"> + <s:Scale3D scaleYTo="0" duration="500" startDelay="0" disableLayout="false" + autoCenterProjection="true" autoCenterTransform="true" applyChangesPostLayout="true"/> + <s:Fade alphaFrom="1" alphaTo="0" duration="250" startDelay="50"/> + </s:Parallel> + + <s:Parallel id="addedEffect" target="{this}" suspendBackgroundProcessing="false"> + <s:Scale3D scaleYFrom="0" scaleYTo="1" duration="250" disableLayout="false" + autoCenterProjection="true" autoCenterTransform="true" applyChangesPostLayout="true"/> + <s:Fade alphaFrom="0" alphaTo="1" duration="200"/> + <!--<core:CallMethod method="addMoveEffect" startDelay="250"/>--> + </s:Parallel> + + <s:Move id="moveEffect" target="{this}" /> + + </fx:Declarations> + + + +</s:Panel> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/windows/ContactWindow.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/windows/ContactWindow.mxml b/Radii8Library/src/com/flexcapacitor/views/windows/ContactWindow.mxml new file mode 100644 index 0000000..a363162 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/windows/ContactWindow.mxml @@ -0,0 +1,427 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<windows:AnimatedPanelWindow xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + xmlns:c="com.flexcapacitor.views.windows.*" + xmlns:handlers="com.flexcapacitor.handlers.*" + xmlns:fc="com.flexcapacitor.effects.popup.*" + xmlns:windows="com.flexcapacitor.views.windows.*" + + title="Contact" + creationComplete="creationCompleteHandler(event)" + stateChangeComplete="stateChangeCompleteHandler(event)" + height.bug="450" + > + + <fx:Style> + @namespace s "library://ns.adobe.com/flex/spark"; + @namespace c "com.flexcapacitor.controls.*"; + @namespace mx "library://ns.adobe.com/flex/mx"; + @namespace handlers "com.flexcapacitor.handlers.*"; + @namespace fc "com.flexcapacitor.effects.popup.*"; + + </fx:Style> + + <fx:Script> + <![CDATA[ + import com.flexcapacitor.controller.Radiate; + import com.flexcapacitor.status.StatusManager; + + import mx.core.mx_internal; + import mx.events.FlexEvent; + import mx.events.ValidationResultEvent; + import mx.managers.PopUpManager; + import mx.rpc.events.FaultEvent; + import mx.rpc.events.ResultEvent; + import mx.validators.EmailValidator; + + use namespace mx_internal; + + public static const BUG:String = "bug"; + public static const FEATURE:String = "feature"; + + [Bindable] + public var os:String; + + [Bindable] + public var browser:String; + + [Bindable] + public var player:String; + + [Bindable] + public var manufacturer:String; + + [Bindable] + public var cpu:String; + + [Bindable] + public var isDebugger:Boolean; + + [Bindable] + public var language:String; + + [Bindable] + public var supports32bit:String; + + [Bindable] + public var supports64bit:String; + + [Bindable] + public var touchscreenType:String; + + [Bindable] + public var isDebugSWF:Boolean; + + [Bindable] + public var flexSDK:String; + + protected function getPropertiesInfo():void { + + var cap:Object = Capabilities; + os = Capabilities.os; + manufacturer = Capabilities.manufacturer; + player = Capabilities.version; + isDebugger = Capabilities.isDebugger; + language = Capabilities.language; + + // in the future we should load in the swf in question + // and get the sdk version and if its a debug swf + //flexSDK = mx_internal::Version; + isDebugSWF = false; //new Error().getStackTrace().search(/:[0-9]+]$/m) > -1; + + + if (Object(Capabilities).hasOwnProperty("cpuArchitecture")) { + cpu = Capabilities['cpuArchitecture']; + } + else { + cpu = ""; + } + + if (Object(Capabilities).hasOwnProperty("supports32BitProcesses")) { + supports32bit = Capabilities['supports32BitProcesses']; + supports64bit = Capabilities['supports64BitProcesses']; + } + else { + supports32bit = ""; + supports64bit = ""; + } + + if (Object(Capabilities).hasOwnProperty("touchscreenType")) { + touchscreenType = Capabilities['touchscreenType']; + } + else { + touchscreenType = ""; + } + + if (ExternalInterface.available) { + browser = ExternalInterface.call("eval", "navigator.userAgent"); + } + else { + browser = Capabilities.playerType; + } + } + + protected function featureRadioGroup_changeHandler(event:Event):void { + if (featureRadioButton.selected) { + currentState = FEATURE; + } + else { + currentState = BUG; + } + } + + + protected function sendButton_clickHandler():void { + var message:Object = new Object(); + var validResultEvent:ValidationResultEvent = emailValidator.validate(emailText.text); + //var validEmail:Boolean = emailValidator.validate(emailText.text); + + if (validResultEvent.results && validResultEvent.results.length!=0) { + //infoLabel.text = "Please enter a valid email before sending a message."; + infoLabel.text = validResultEvent.message; + return; + } + + if (messageTextArea.text=="" || messageTextArea.text.length<6) { + //StatusManager.show("Please enter a message."); + infoLabel.text = "Please enter a message"; + return; + } + + getPropertiesInfo(); + + message.os = os; + message.browser = browser; + message.player = player; + message.manufacturer = manufacturer; + message.cpu = cpu; + message.isDebugger = isDebugger; + message.language = language; + message.supports32bit = supports32bit; + message.supports64bit = supports64bit; + message.touchscreen = touchscreenType; + + message.email = emailText.text=="" ? emailText.prompt : emailText.text; + + if (currentState==BUG) { + message.message = bugMessageTextArea.text; + } + else if (currentState==FEATURE) { + message.message = messageTextArea.text; + } + + feedbackService.send(message); + } + + protected function feedbackService_resultHandler(event:ResultEvent):void { + var result:String = event.result as String; + //StatusManager.show("Message sent!", 3000, false, null, false, .75); + //nameText.text = ""; + //emailText.prompt = emailText.text!="" ? emailText.text : emailText.prompt; + //emailText.text = ""; + + if (currentState==BUG) { + bugMessageTextArea.text = bugText; + } + else if (currentState==FEATURE) { + messageTextArea.text = ""; + } + + if (result && result.indexOf("Mail sent")!=-1) { + playSentSuccessfulMessage(); + } + + } + + + protected function feedbackService_faultHandler(event:FaultEvent):void { + infoLabel.text = "An error occurred! Message may not have been sent. Please email [email protected]."; + //StatusManager.show("An error occurred! Message may not have been sent. \n\n" + event.fault.message); + Radiate.log.error(event.fault.message); + } + + /** + * Sets the action to deleted, the label to deleted and closes the window after a second. + * */ + public function playSentSuccessfulMessage():void { + //infoLabel.text = "Sent!"; + //action = "Sent"; + + StatusManager.show("Message sent!", 1000, false, null, false, .20); + closePopUp.startDelay = 1000; + closePopUp.play(); + } + + protected function cancelButton_clickHandler(event:MouseEvent):void { + callLater(PopUpManager.removePopUp, [this]); + } + + protected function creationCompleteHandler(event:FlexEvent):void { + radiate = Radiate.getInstance(); + + if (radiate.isUserLoggedIn) { + emailText.text = radiate.userEmail; + } + + if (currentState==BUG) { + bugMessageTextArea.text = bugText; + //helpTextArea.text = bugExampleText; + } + else { + //messageTextArea.text = bugText; + //messageTextArea.text = bugExampleText; + } + } + + protected function stateChangeCompleteHandler(event:FlexEvent):void { + + if (currentState==BUG && bugMessageTextArea.text=="") { + bugMessageTextArea.text = bugText; + addMoveEffect(); + PopUpManager.centerPopUp(this); + } + else { + PopUpManager.centerPopUp(this); + } + } + + ]]> + </fx:Script> + + <fx:Declarations> + + <fx:String id="action"></fx:String> + + <fc:ClosePopUp id="closePopUp" popUp="{this}" /> + </fx:Declarations> + + + <fx:Declarations> + <mx:EmailValidator id="emailValidator" /> + + <s:RadioButtonGroup id="featureRadioGroup" + change="featureRadioGroup_changeHandler(event)"/> + + <s:HTTPService id="feedbackService" + method="POST" + fault="feedbackService_faultHandler(event)" + result="feedbackService_resultHandler(event)" + url="http://www.radii8.com/support.php"/> + + <fx:String id="bugText"> + <![CDATA[Summary: + + +Steps to reproduce: +1. +2. +3. + +Expected Result: + + +Actual Result: + + +]]></fx:String> + + <fx:String id="bugExampleText"> +<![CDATA[Summarize the problem and list the steps to reproduce. + +Steps to reproduce: +1. Add a button to the stage +2. Set color on the button to red in the properties panel + +Expected Result: +Button text is red + +Actual Result: +Button text is blue]]></fx:String> + </fx:Declarations> + + <windows:states> + <s:State name="feature"/> + <s:State name="bug"/> + </windows:states> + + <s:VGroup left="15" + top="20" + right="20" + bottom="20" + gap="10" + > + + <s:HGroup left="0" right="0" + width="100%" + clipAndEnableScrolling="true" + paddingRight="10" + verticalAlign="middle" + > + + <s:Label text="Send as many feature request and bug reports as you like."/> + + <s:Spacer width="100%"/> + + <s:RadioButton id="featureRadioButton" + label="Feature" + group="{featureRadioGroup}" + selected="true" + /> + <s:RadioButton id="booleanDisabledRadioButton" + label="Bug" + group="{featureRadioGroup}" + /> + + </s:HGroup> + + <s:HGroup verticalAlign="middle"> + <s:Label text="Your email:"/> + + <s:TextInput id="emailText" + minWidth="250" + focusAlpha="0" + borderColor="#cccccc" + /> + </s:HGroup> + + <s:HGroup left="0" right="0" + width="100%" height="100%" + clipAndEnableScrolling="true" + paddingRight="10" + verticalAlign="middle" + > + <s:TextArea id="messageTextArea" + focusColor="#585858" + focusAlpha="0" + width="100%" height="100%" + borderColor="#cccccc" + paddingTop="8" + paddingBottom="8" + prompt="Enter your feature and click send" + includeIn="feature" + > + </s:TextArea> + + <s:TextArea id="bugMessageTextArea" + focusColor="#585858" + focusAlpha="0" + width="100%" height="100%" + borderColor="#cccccc" + paddingTop="8" + paddingBottom="8" + includeIn="bug" + > + <s:keyFocusChange> + event.preventDefault(); + event.currentTarget.insertText("\t"); + </s:keyFocusChange> + <s:prompt>Summarize the problem and list the steps to reproduce.</s:prompt> + </s:TextArea> + + <!--<s:TextArea id="helpTextArea" + focusColor="#585858" + focusAlpha="0" + width="50%" height="100%" + borderColor="#cccccc" + borderVisible="false" + paddingTop="8" + paddingBottom="8" + editable="false" + includeIn="bug" + fontStyle="italic" + color="#585858" + > + <s:text></s:text> + </s:TextArea>--> + </s:HGroup> + + <s:HGroup width="100%" horizontalAlign="right" verticalAlign="baseline"> + <s:Label id="infoLabel" text="" /> + <s:Spacer width="100%"/> + <s:Button id="cancelButton" label="Cancel" click="cancelButton_clickHandler(event)" /> + <s:Button label="Send" click="sendButton_clickHandler()" /> + </s:HGroup> + + </s:VGroup> + + +</windows:AnimatedPanelWindow> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/windows/DeleteDocumentWindow.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/windows/DeleteDocumentWindow.mxml b/Radii8Library/src/com/flexcapacitor/views/windows/DeleteDocumentWindow.mxml new file mode 100644 index 0000000..3e10603 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/windows/DeleteDocumentWindow.mxml @@ -0,0 +1,309 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<windows:AnimatedPanelWindow xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + xmlns:c="com.flexcapacitor.views.windows.*" + xmlns:handlers="com.flexcapacitor.handlers.*" + xmlns:fc="com.flexcapacitor.effects.popup.*" + xmlns:windows="com.flexcapacitor.views.windows.*" + + title.project="Delete Project" + title.document="Delete Document" + title.resource="Delete Resource" + + creationComplete="panel1_creationCompleteHandler(event)" + > + + <fx:Style> + @namespace s "library://ns.adobe.com/flex/spark"; + @namespace c "com.flexcapacitor.controls.*"; + @namespace mx "library://ns.adobe.com/flex/mx"; + @namespace handlers "com.flexcapacitor.handlers.*"; + @namespace fc "com.flexcapacitor.effects.popup.*"; + + </fx:Style> + + <fx:Script> + <![CDATA[ + import com.flexcapacitor.controller.Radiate; + import com.flexcapacitor.events.RadiateEvent; + import com.flexcapacitor.model.IDocument; + import com.flexcapacitor.model.IDocumentData; + import com.flexcapacitor.model.IProject; + + import mx.core.mx_internal; + import mx.events.FlexEvent; + import mx.managers.PopUpManager; + + use namespace mx_internal; + + public static const DOCUMENT:String = "document"; + public static const PROJECT:String = "project"; + public static const RESOURCE:String = "resource"; + + public var closeWindowDelay:int = 250; + + [Bindable] + public var documentData:IDocumentData; + + [Bindable] + public var documentName:String; + + /** + * This needs to work better. Only listen for events when deleting remote not local. + * */ + protected function deleteResource():void { + var localRemoveSuccessful:Boolean; + var isRemote:Boolean; + deleteWarningsLabel.text = ""; + radiate = Radiate.getInstance(); + + if (currentState==DOCUMENT) { + if (documentData==null) { + documentData = radiate.selectedDocument; + } + if (documentData) { + + if (documentData.id!=null) { + radiate.addEventListener(RadiateEvent.DOCUMENT_DELETED, deleteResultsHandler, false, 0, true); + isRemote = true; + } + + //radiate.addEventListener(RadiateEvent.DOCUMENT_REMOVED, deleteResultsHandler, false, 0, true); + localRemoveSuccessful = radiate.removeDocument(IDocument(documentData)); + } + } + else if (currentState==PROJECT) { + if (documentData==null) { + documentData = radiate.selectedProject; + } + + if (documentData) { + radiate.addEventListener(RadiateEvent.PROJECT_REMOVED, deleteResultsHandler, false, 0, true); + + if (documentData.id!=null) { + radiate.addEventListener(RadiateEvent.PROJECT_DELETED, deleteResultsHandler, false, 0, true); + isRemote = true; + } + + localRemoveSuccessful = radiate.removeProject(IProject(documentData)); + } + } + else if (currentState==RESOURCE) { + if (documentData==null) { + //documentData = radiate.selectedDocument; + } + if (documentData) { + + if (documentData.id!=null) { + radiate.addEventListener(RadiateEvent.DOCUMENT_DELETED, deleteResultsHandler, false, 0, true); + isRemote = true; + } + + //radiate.addEventListener(RadiateEvent.DOCUMENT_REMOVED, deleteResultsHandler, false, 0, true); + localRemoveSuccessful = radiate.removeAsset(IDocumentData(documentData)); + } + } + + + + if (isRemote) { + infoLabel.text = "Deleting..."; + inProgress = true; + } + else if (localRemoveSuccessful) { + playDeleteSuccessfulMessage(); + } + else { + playDeleteNotSuccessfulMessage(); + } + } + + /** + * Sets the action to deleted, the label to deleted and closes the window after a second. + * */ + public function playDeleteSuccessfulMessage():void { + infoLabel.text = "Deleted!"; + action = "Deleted"; + closePopUp.startDelay = closeWindowDelay; + closePopUp.play(); + } + + /** + * Display a message that the resource was not deleted. + * */ + public function playDeleteNotSuccessfulMessage():void { + infoLabel.text = "Item was not found. It may have already been deleted. "; + //action = "Deleted"; + //closePopUp.startDelay = 1000; + //closePopUp.play(); + } + + protected function deleteResultsHandler(event:RadiateEvent):void { + var data:Object = event.data; + var error:String; + var status:String = event.status; + var successful:Boolean = event.successful; + var message:String = ""; + var iDocument:IDocument = event.selectedItem as IDocument; + + inProgress = false; + + if (event.type==RadiateEvent.PROJECT_DELETED) { + radiate.removeEventListener(RadiateEvent.PROJECT_DELETED, deleteResultsHandler); + } + + if (event.type==RadiateEvent.DOCUMENT_DELETED) { + radiate.removeEventListener(RadiateEvent.DOCUMENT_DELETED, deleteResultsHandler); + } + + + + if (status=="error") { + + if (data && "error" in data) { + message += "Error. The item was not deleted. " + data.error + " "; + } + else { + message += "Error. The item was not deleted. It may have been deleted already. Resave the project. "; + } + } + else { + if (data==null && iDocument!=null && iDocument.id!=null) { + message += "Error. The item may have been deleted already. Reload or resave the project. "; + } + } + + + if (event.faultEvent) { + message += "Are you connected to the internet? "; + + if (event.faultEvent is IOErrorEvent) { + message += IOErrorEvent(event.faultEvent).text; + } + else if (event.faultEvent is SecurityErrorEvent) { + + if (SecurityErrorEvent(event.faultEvent).errorID==2048) { + + } + + message += SecurityErrorEvent(event.faultEvent).text; + } + } + + + deleteWarningsLabel.text = message; + + + if (successful) { + playDeleteSuccessfulMessage(); + } + else { + infoLabel.text = ""; + } + } + + protected function cancelButton_clickHandler(event:MouseEvent):void { + callLater(PopUpManager.removePopUp, [this]); + } + + protected function panel1_creationCompleteHandler(event:FlexEvent):void { + radiate = Radiate.getInstance(); + + if (currentState==DOCUMENT) { + if (documentData==null) { + documentData = radiate.selectedDocument; + } + } + else if (currentState==PROJECT) { + if (documentData==null) { + documentData = radiate.selectedProject; + } + } + else if (currentState==RESOURCE) { + if (documentData==null) { + //documentData = radiate.selectedProject; + } + } + + if (documentData) { + documentName = documentData.name; + } + } + + ]]> + </fx:Script> + + <fx:Declarations> + + <!--- hide about popup --> + <handlers:EventHandler targets="{cancelButton}" eventName="clickNOT"> + <fc:ClosePopUp id="closePopUp" popUp="{this}" /> + </handlers:EventHandler> + + <!--- hide about popup --> + <!--<handlers:EventHandler targets="{importButton}" eventName="click"> + <s:SetAction property="action" target="{this}" value="import"/> + <fc:ClosePopUp popUp="{this}" /> + </handlers:EventHandler>--> + + <fx:String id="action"></fx:String> + + </fx:Declarations> + + <c:states> + <s:State name="document"/> + <s:State name="project"/> + <s:State name="resource"/> + </c:states> + + <s:VGroup left="15" + top="20" + right="20" + bottom="20" + gap="10" + > + + <s:Label text="Are you sure you want to delete the project, '{documentName}'?" + fontSize="16" includeIn="project" width="100%"/> + <s:Label text="Are you sure you want to delete the document, '{documentName}'?" + fontSize="16" includeIn="document" width="100%"/> + <s:Label text="Are you sure you want to delete the resource, '{documentName}'?" + fontSize="16" includeIn="resource" width="100%"/> + + <s:Label id="deleteWarningsLabel" + x="15" y="15" + text="" + fontWeight="bold" + color="red" + width="100%"/> + + <s:HGroup width="100%" horizontalAlign="right" verticalAlign="baseline"> + <s:Label id="infoLabel" text="" /> + <s:Spacer width="100%"/> + <s:Button id="cancelButton" label="Cancel" click="cancelButton_clickHandler(event)" /> + <s:Button label="Delete" click="deleteResource()" /> + </s:HGroup> + + </s:VGroup> + + +</windows:AnimatedPanelWindow>
