Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Copyright
2009 SAP AG. All rights reserved.SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries. Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company.All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty. 2009-11-03
Introduction
This tutorial assumes that you have at least some knowledge of Cascading Style Sheet (CSS), ActionScript 3.0, and MXML, the XML-based markup language introduced by Adobe Flex. The concentration of the tutorial is creating a custom property sheet for those who do not want to use the default property sheet. We will include Flex controls in the property sheet so that all of the properties and styles of the custom component can be exposed. We will also use a sample CSS definition to style the property sheet to look more like the Xcelsius color scheme. Download the source code for the custom component so that you could see what properties and styles it has. You will need to reference the names of the properties/styles inside the property sheet source code. For demonstration purposes, only the basic controls for the layout of custom property sheet are mentioned. Please see the CustomPropSheetHorizon talSlider sample source code for a more advanced layout.
Tutorial 4 - Creating a custom property sheet Task 2: Designing the layout for the property sheet
Viewstack: id=viewstack1, creationPolicy=all, left=0, right=0, y=45, height=100%, width=100%, minWidth=268, minHeight=350 Canvas: id=general, label=General, minWidth=268, minHeight=350, width=100%, height=100% Label: text=Title, x=23, y=24, width=119 HRule: y=28, height=10, right=28, left=59 TextInput: id=titleEditor, change=proxy.setProperty('title', titleEditor.text), y=52, right=69, left=37 Label: text=Value, x=23, y=116, width=119 HRule: y=118, height=10, right=28, left=66 TextInput: id=valueEditor, change=proxy.seProperty('value', Number(valueEditor.text)), y=144, right=69, left=37 Button: click=initiateBind('value'), icon=@Embed('resources/bind to cell.png'), y=143, right=37, width=24 Canvas: id=appearance, label=Appearance, minWidth=268, minHeight=350, width=100%, height=100% Label: text=Text, x=23, y=23, text=Text, width=119 HRule: y=28, height=10, right=28, left=56 CheckBox: id=showTitleEditor, label=Show Title, change=proxy.setProperty('showTitle', showTitleEditor.selected), selected=true, x=43, y=54 ComboBox: id=titleFontFamilyEditor, dataProvider={_fontNames}, change=proxy.setStyle('titleFontFamily', titleFontFamilyEditor.value), x=94, y=79, width=129 ComboBox: id=titleFontSizeEditor, dataProvider={_fontSizes}, change=proxy.setStyle('titleFontSize', titleFontSizeEditor.value), x=231 y=79 width=55 Label: text=Color, x=23, y=136, width=119 HRule: y=141, height=10, right=28, left=62 Label: text=Title Color, x=43, y=169, text=Title Color:, width=116 ColorPicker: id=titleColorEditor, change=proxy.setStyle('titleFontColor', uint(titleColorEditor.selectedColor)), x=137, y=169
TabBar: dataProvider=viewstack1
Tutorial 4 - Creating a custom property sheet Task 2: Designing the layout for the property sheet
3. After laying out the controls, switch to Source mode, you should have the following code: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="ab solute" applicationComplete="init();"> <mx:ViewStack id="viewstack1" creationPolicy="all" left="0" right="0" y="45" height="100%" width="100%" minWidth="268" minHeight="350"> <mx:Canvas id="general" label="General" min Width="268" minHeight="350" width="100%" height="100%"> <mx:Label x="23" y="24" text="Title" width="119"/> <mx:HRule y="28" height="10" right="28" left="59"/> <mx:TextInput id="titleEditor" y="52" right="69" left="37" change="proxy.setProperty('ti tle',titleEditor.text)"/> <mx:Label x="23" y="116" text="Value" width="119"/> <mx:HRule y="118" height="10" right="28" left="66"/> <mx:TextInput id="valueEditor" y="144" right="69" left="37" change="proxy.setProperty('value', Number(valueEditor.text))"/> <mx:Button y="143" right="37" width="24" click="initiateBind('value');" icon="@Embed('re sources/bind to cell.png')"/> </mx:Canvas> <mx:Canvas id="appearance" label="Appearance" minWidth="268" minHeight="350" width="100%" height="100%"> <mx:Label x="23" y="23" text="Text" width="119"/> <mx:HRule y="28" height="10" right="28" left="56"/> <mx:CheckBox id="showTitleEditor" x="43" y="54" label="Show Title" change="proxy.setProper ty('showTitle', showTitleEditor.selected)" select ed="true"/> <mx:ComboBox id="titleFontFamilyEditor" dataProvider="{_fontNames}" x="94" y="79" width="129" change="proxy.setStyle('titleFontFamily', titleFont FamilyEditor.value)" /> <mx:ComboBox id="titleFontSizeEditor" dataProvider="{_fontSizes}" x="231" y="79" width="55" change="proxy.setStyle('titleFontSize', titleFont
SizeEditor.value)" /> <mx:Label x="23" y="136" text="Color" width="119"/> <mx:HRule y="141" height="10" right="28" left="62"/> <mx:Label x="43" y="169" text="Title Col or:" width="116"/> <mx:ColorPicker id="titleColorEditor" x="137" y="169" change="proxy.setStyle('titleFontCol or', uint(titleColorEditor.selectedColor))" /> </mx:Canvas> </mx:ViewStack> <mx:TabBar x="0" y="0" dataProvider="viewstack1"> </mx:TabBar> </mx:Application>
Tutorial 4 - Creating a custom property sheet Task 4: Handling communication between property sheet and the component
import xcelsius.binding.BindingDirection; import xcelsius.binding.tableMaps.input.In putBindings; import xcelsius.binding.tableMaps.output.Out putBindings; import xcelsius.propertySheets.impl.Proper
Tutorial 4 - Creating a custom property sheet Task 4: Handling communication between property sheet and the component
tySheetExternalProxy; import xcelsius.propertySheets.inter faces.PropertySheetFunctionNamesSDK; [Bindable] private var _fontNames:Array = []; [Bindable] protected var _fontSizes:Array = new Ar ray("8", "9", "10", "11", "12", "14", "16", "18", "20", "22"); protected var proxy:PropertySheetExternal Proxy = new PropertySheetExternalProxy(); protected var propertyToBind:String; protected var currentBindingID:String; _fontNames will contain system fonts that the user can choose from. _fontSizes is the list of selectable font sizes.
Both of these variables need to be bindable since we bind them to the data providers of the combo boxes on the "Appearance" tab. Variable proxy is the Xcelsius proxy that enables communication between the property sheet and the custom component. The package xcel sius.propertySheets.impl.PropertySheetExternalProxy for the proxy is the implementation of the interface xcelsius.proper tySheets.interfaces.IPropertySheetProxy, which are both included in the xcelsiusframework.swc. Variable propertyToBind stores the name of the property that the user is binding, and currentBindingID stores the current binding id (null if there's no binding) for the property.
Tutorial 4 - Creating a custom property sheet Task 4: Handling communication between property sheet and the component
implemented here. Lastly, it makes a call to initValues method that initializes the property sheet on load with default property/style values. protected function init():void { proxy.addCallback(PropertySheetFunction NamesSDK.RESPONSE_BINDING_ID, this.continueBind); proxy.callContainer(PropertySheetFunction NamesSDK.INIT_COMPLETE_FUNCTION); var allFonts:Array = Font.enumerate Fonts(true); allFonts.sortOn("fontName", Array.CASEIN SENSITIVE); var numFonts:int = allFonts.length; for (var i:int=0; i<numFonts; i++) { var font:Font = allFonts[i]; _fontNames.push(font.fontName); } initValues(); }
Tutorial 4 - Creating a custom property sheet Task 4: Handling communication between property sheet and the component
Values != null ? propertyValues.length : 0); for (var i:int=0; i < propertyVal uesLength; i++) { var propertyObject:Object = property Values[i]; var propertyName:String = propertyOb ject.name; var propertyValue:* = propertyOb ject.value; var bindingText:String = ""; switch (propertyName) { case "title": titleEditor.text = String(propertyValue); break; case "value": bindingText = getPropertyBind DisplayName(propertyName); if (bindingText != null) { valueEditor.enabled = false; valueEditor.text = bind ingText; } else { valueEditor.text = prop ertyValue; } break; case "showTitle": showTitleEditor.selected = Boolean(propertyValue); break; default: break; } } // Process the array of values for the custom component styles. var styleValues:Array = proxy.get Styles(["titleFontFamily", "titleFontColor", "titleFont Size"]); var styleValuesLength:int = (styleValues != null ? styleValues.length : 0);
10
Tutorial 4 - Creating a custom property sheet Task 4: Handling communication between property sheet and the component
for (var j:int=0; j < styleValuesLength; j++) { var styleObject:Object = styleVal ues[j]; var styleName:String = styleOb ject.name; var styleValue:* = styleObject.value; var bindingTextStyle:String = ""; switch (styleName) { case "titleFontColor": titleColorEditor.selectedCol or = uint(styleValue); break; case "titleFontFamily": titleFontFamilyEditor.selecte dIndex = _fontNames.indexOf(styleValue); break; case "titleFontSize": titleFontSizeEditor.selecte dIndex = _fontSizes.indexOf(styleValue); var index:int; index = _fontSizes.index Of(styleValue.toString()); if (index != -1) { titleFontSizeEditor.se lectedIndex = index; } else if (!isNaN(styleValue)) { titleFontSizeEditor.text = styleValue.toString(); } else { titleFontSizeEditor.se lectedIndex = -1; } break; default: break; } } }
11
Tutorial 4 - Creating a custom property sheet Task 4: Handling communication between property sheet and the component
12
Tutorial 4 - Creating a custom property sheet Task 4: Handling communication between property sheet and the component
13
Tutorial 4 - Creating a custom property sheet Task 4: Handling communication between property sheet and the component
{ valueEditor.enabled = true; propertyValues = proxy.get Properties([propertyName]); propertyObject = propertyVal ues[0]; valueEditor.text = property Object.value; proxy.setProperty(property Name, propertyObject.value); return; } valueEditor.enabled = false; valueEditor.text = proxy.getBind ingDisplayName(bindingID); proxy.bind("value", null, bindingID, BindingDirection.BOTH, InputBindings.SINGLE TON, OutputBindings.SINGLETON); break; default: break; } } Save and build.
14