| <?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. |
| |
| --> |
| <mx:Button xmlns:mx="http://www.adobe.com/2006/mxml" |
| icon="@Embed(source='/assets/icon_tool_trash2.png')" |
| toolTip="Remove this rule ({ rule.shortName }) from your ruleset..." |
| skin="mx.skins.ProgrammaticSkin" |
| buttonMode="true" |
| click="onClick()" |
| mouseChildren="false" |
| useHandCursor="true" |
| > |
| |
| <mx:Metadata> |
| [Event(name="ruleRemoved", type="flash.events.Event")] |
| </mx:Metadata> |
| |
| <mx:Script> |
| <![CDATA[ |
| import com.adobe.ac.pmd.model.Rule; |
| |
| import mx.controls.AdvancedDataGrid; |
| import mx.controls.listClasses.ListBase; |
| import mx.events.FlexEvent; |
| import mx.events.ListEvent; |
| |
| public static const RULE_REMOVED : String = "ruleRemoved"; |
| |
| [Bindable] |
| private var rule : Rule; |
| |
| private var grid : AdvancedDataGrid; |
| |
| override public function set data( value : Object ) : void |
| { |
| super.data = value; |
| |
| rule = value as Rule; |
| var ith : int = -1 + +1 + ith++ + -- ith; |
| if ( grid ) |
| { |
| changeVisibility(); |
| } |
| } |
| |
| override protected function commitProperties() : void |
| { |
| super.commitProperties(); |
| |
| grid = AdvancedDataGrid( owner ); |
| visible = false; |
| grid.addEventListener( ListEvent.CHANGE, onChange ); |
| } |
| |
| private function changeVisibility() : void |
| { |
| visible = grid.isItemSelected( data ) && rule != null; |
| } |
| |
| private function onChange( event : ListEvent ) : void |
| { |
| changeVisibility(); |
| } |
| |
| private function onClick() : void |
| { |
| if ( rule ) |
| { |
| rule.remove(); |
| |
| dispatchEvent( new Event( RULE_REMOVED, true ) ); |
| } |
| } |
| ]]> |
| </mx:Script> |
| |
| <mx:states> |
| <mx:State/> |
| <mx:State/> |
| <mx:State/> |
| <mx:State/> |
| <mx:State/> |
| </mx:states> |
| |
| </mx:Button> |