blob: ad1e691345a6e5b980e5d1d17b8ba1faa24b5f64 [file] [log] [blame]
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fc="com.flexcapacitor.controls.*"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:local="*"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:utils="com.flexcapacitor.utils.*"
xmlns:handlers="com.flexcapacitor.handlers.*"
xmlns:supportClasses="com.flexcapacitor.effects.supportClasses.*"
styleName="constraintStyles"
creationComplete="creationCompleteHandler(event)"
width="100%"
height="100%"
>
<!---
http://dougmccune.com/blog/source-code-license/
Any source code released on this blog, unless otherwise explicitly noted, is licensed under the MIT license:
Copyright (c) 2013 Doug McCune
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
http://dougmccune.com/blog/2008/02/21/monkey-patching-flexsprite-to-list-all-event-listeners-on-any-flex-component/
-->
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace fc "com.flexcapacitor.controls.*";
@namespace local "*";
@namespace mx "library://ns.adobe.com/flex/mx";
@namespace utils "com.flexcapacitor.utils.*";
@namespace handlers "com.flexcapacitor.handlers.*";
@namespace supportClasses "com.flexcapacitor.effects.supportClasses.*";
.constraintStyles {
fontSize:12;
}
.inputStyles {
fontSize:12;
focusAlpha : 0;
borderColor: #b8b8b8;
}
</fx:Style>
<fx:Script>
<![CDATA[
import com.flexcapacitor.controller.Radiate;
import com.flexcapacitor.events.RadiateEvent;
import mx.core.FlexSprite;
import mx.core.IVisualElement;
import mx.events.FlexEvent;
public var radiate:Radiate;
protected function creationCompleteHandler(event:FlexEvent):void {
target = null;
var radiate:Radiate = Radiate.getInstance();
radiate.addEventListener(RadiateEvent.TARGET_CHANGE, targetChangeHandler);
radiate.addEventListener(RadiateEvent.PROPERTY_CHANGED, propertyChangeHandler);
radiate.addEventListener(RadiateEvent.HISTORY_CHANGE, historyChangeHandler);
if (radiate.target) {
target = radiate.target as FlexSprite;
if (target is FlexSprite) {
showEventListeners(target as FlexSprite);
}
}
}
private var _target:FlexSprite;
private var _visualElement:IVisualElement;
public function get target():FlexSprite {
return _target;
}
[Bindable]
public function set target(value:FlexSprite):void {
if (!(value is FlexSprite)) {
_target = null;
return;
}
_target = value;
}
/**
* Get current target
* */
protected function targetChangeHandler(event:RadiateEvent):void {
target = event.selectedItem as FlexSprite;
showEventListeners(target);
}
/**
* Updates the view when a property is changed externally
* */
protected function propertyChangeHandler(event:RadiateEvent):void {
var properties:Array = event.properties;
var length:int = event.properties.length;
if (!target) return;
for (var i:int;i<length;i++) {
if (watchedProperties.indexOf(properties[i])!=-1) {
//updateView();
break;
}
}
}
protected function historyChangeHandler(event:RadiateEvent):void {
if (event.newIndex==-1 || !event.historyEventItem) return;
var properties:Array = event.historyEventItem.properties;
var length:int = properties ? properties.length : 0;
if (!target) return;
for (var i:int;i<length;i++) {
if (watchedProperties.indexOf(properties[i])!=-1) {
//updateView();
break;
}
}
}
private const watchedProperties:Array = [ "width", "height", "percentWidth", "percentHeight", "x",
"y", "top", "left", "right", "bottom", "verticalCenter",
"horizontalCenter", "baseline"]
/**
* Show event listeners on target.
* */
public function showEventListeners(sprite:FlexSprite): void {
this.sprite = sprite;
grid.dataProvider = sprite != null ? Object(sprite).eventListeners : null;
grid.selectedIndex = 0;
if (grid.dataProvider.length>0) {
selectedTracker = grid.dataProvider[0];// as ListenerTracker;
}
}
private var sprite:FlexSprite;
public function removeListener(listener:Object):void {
//public function removeListener(listener:ListenerTracker):void {
sprite.removeEventListener(listener.type, listener.listener, listener.useCapture);
grid.dataProvider = Object(sprite).eventListeners;
}
private function removeAll():void {
if (sprite) {
Object(sprite).removeAllEventListeners();
grid.dataProvider = Object(sprite).eventListeners;
}
}
[Bindable]
//private var selectedTracker:ListenerTracker;
private var selectedTracker:Object;
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout paddingRight="10"/>
</s:layout>
<s:Button label="Remove All Event Listeners" click="removeAll()" />
<mx:DataGrid id="grid"
width="100%"
minWidth="100"
minHeight="100"
change="selectedTracker = grid.selectedItem"
>
<!--change="selectedTracker = grid.selectedItem as ListenerTracker"-->
<mx:columns>
<mx:DataGridColumn dataField="type" headerText="Type" />
<mx:DataGridColumn dataField="callingClassName" headerText="Added By" />
<mx:DataGridColumn dataField="type" headerText="" width="50" >
<mx:itemRenderer>
<fx:Component>
<!--<mx:Button label="Remove" click="outerDocument.removeListener(data as mx.core.ListenerTracker)" />-->
<mx:Button label="Remove" click="outerDocument.removeListener(data)" />
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
<mx:Panel title="Details: {selectedTracker.type}"
width="100%"
height="100%"
minHeight="150"
minWidth="100"
dropShadowVisible="false"
>
<mx:Form width="100%" height="100%">
<mx:FormItem label="Type">
<mx:Label text="{selectedTracker.type}" />
</mx:FormItem>
<mx:FormItem label="Added by">
<mx:Label text="{selectedTracker.callingClassName}" />
</mx:FormItem>
<mx:FormItem label="Method">
<mx:Label text="{selectedTracker.callingMethod}" />
</mx:FormItem>
<mx:FormItem label="Line">
<mx:Label text="{selectedTracker.callingLineNumber}" />
</mx:FormItem>
<mx:FormItem label="Priority">
<mx:Label text="{selectedTracker.priority}" />
</mx:FormItem>
<mx:FormItem label="Use Capture">
<mx:Label text="{selectedTracker.useCapture}" />
</mx:FormItem>
<mx:FormItem label="Weak Reference">
<mx:Label text="{selectedTracker.useWeakReference}" />
</mx:FormItem>
<mx:FormItem label="Time Created">
<mx:Label text="{selectedTracker.timeCreated}" />
</mx:FormItem>
</mx:Form>
</mx:Panel>
</s:Group>