| <?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:Module 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="100%" creationComplete="compareStrings()"> |
| <fx:Script> |
| <![CDATA[ |
| import mx.collections.ArrayCollection; |
| [Bindable] |
| private var _locales:ArrayCollection = new ArrayCollection(['en-US','de-DE','ja-JP','ru-RU','zh-CN','fr-FR']); |
| |
| private function compareStrings():void { |
| if(firstTI.text != '' && secondTI.text != '') { |
| switch (sortCollator.compare(firstTI.text,secondTI.text)) { |
| case 1: |
| operatorL.text = '>'; |
| break; |
| case 0: |
| operatorL.text = '='; |
| break; |
| case -1: |
| operatorL.text = '<'; |
| break; |
| default: |
| operatorL.text = ' '; |
| } |
| } |
| } |
| ]]> |
| </fx:Script> |
| |
| <fx:Declarations> |
| <s:SortingCollator id="sortCollator" locale="{localeCB.selectedItem}"/> |
| </fx:Declarations> |
| |
| <s:Panel title="Spark Collator" width="100%" height="100%"> |
| |
| <s:layout> |
| <s:HorizontalLayout paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10" /> |
| </s:layout> |
| |
| <s:Form height="100%" width="100%"> |
| <s:Label text="Compare two strings by using SortingCollator"/> |
| <s:Spacer height="15"/> |
| |
| <s:FormItem label="Locales:" toolTip="Select a locale for the collator instance."> |
| <s:ComboBox id="localeCB" dataProvider="{_locales}" selectedIndex="5" change="compareStrings()"/> |
| </s:FormItem> |
| <s:FormItem label="Collator Options:" toolTip="Set properties for the collator instance."> |
| <s:HGroup> |
| <s:CheckBox id="ignoreCaseCB" label="ignoreCase" change="sortCollator.ignoreCase = ignoreCaseCB.selected;compareStrings()"/> |
| <s:CheckBox id="ignDiacriticsCB" label="ignoreDiacritics" change="sortCollator.ignoreDiacritics = ignDiacriticsCB.selected;compareStrings()"/> |
| <s:CheckBox id="ignSymbolsCB" label="ignoreSymbols" change="sortCollator.ignoreSymbols = ignSymbolsCB.selected;compareStrings()"/> |
| <s:CheckBox id="ignKanaTypeCB" label="ignoreKanaType" change="sortCollator.ignoreKanaType = ignKanaTypeCB.selected;compareStrings()"/> |
| <s:CheckBox id="ignCharacterWidthCB" label="ignoreCharacterWidth" change="sortCollator.ignoreCharacterWidth = ignCharacterWidthCB.selected;compareStrings()"/> |
| </s:HGroup> |
| </s:FormItem> |
| <s:FormItem label="Strings:" toolTip="Input two strings and find out their compare result."> |
| <s:HGroup> |
| <s:TextInput id="firstTI" text="coté" change="compareStrings()"/> |
| <s:Label id="operatorL" text=" " fontSize="15"/> |
| <s:TextInput id="secondTI" text="côte" change="compareStrings()"/> |
| </s:HGroup> |
| </s:FormItem> |
| </s:Form> |
| |
| </s:Panel> |
| </s:Module> |