| <?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:Group 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.controls.*" |
| xmlns:handlers="com.flexcapacitor.handlers.*" |
| xmlns:collections="com.flexcapacitor.effects.collections.*" |
| xmlns:components="com.flexcapacitor.components.*" |
| implements="com.flexcapacitor.views.IInspector" |
| |
| minWidth="200" |
| minHeight="100" |
| > |
| |
| <fx:Script> |
| <![CDATA[ |
| import com.flexcapacitor.controller.Radiate; |
| import com.flexcapacitor.events.RadiateEvent; |
| import com.flexcapacitor.model.MetaData; |
| import com.flexcapacitor.utils.ClassUtils; |
| import com.flexcapacitor.utils.SyntaxHighlighter; |
| |
| /** |
| * Reference to Radiate |
| * */ |
| public var radiate:Radiate; |
| |
| public var syntaxHighlighter:SyntaxHighlighter; |
| |
| public var rawData:String; |
| |
| public var lastTarget:Object; |
| |
| public function activate():void { |
| radiate = Radiate.getInstance(); |
| |
| radiate.addEventListener(RadiateEvent.PROPERTY_SELECTED, propertySelectedHandler, false, 0, true); |
| radiate.addEventListener(RadiateEvent.OBJECT_SELECTED, objectSelectedHandler, false, 0, true); |
| radiate.addEventListener(RadiateEvent.TARGET_CHANGE, targetChangeHandler, false, 0, true); |
| |
| if (radiate.target) { |
| //target = radiate.target; |
| } |
| |
| if (radiate.target) { |
| updateObject(radiate.target); |
| } |
| } |
| |
| public function deactivate():void { |
| |
| if (radiate) { |
| radiate.removeEventListener(RadiateEvent.PROPERTY_SELECTED, propertySelectedHandler); |
| radiate.removeEventListener(RadiateEvent.OBJECT_SELECTED, objectSelectedHandler); |
| radiate.removeEventListener(RadiateEvent.TARGET_CHANGE, targetChangeHandler); |
| |
| } |
| if (mxTextArea) { |
| mxTextArea.text = ""; |
| } |
| } |
| |
| |
| public function updateObject(object:Object):void { |
| //rawData = String(object);// ObjectUtil.toString(value); |
| |
| if (lastTarget==object || object==null) return; |
| rawData = ClassUtils.getDescribeType(object); |
| mxTextArea.text = rawData; |
| mxTextAreaChangeHandler(); |
| lastTarget = object; |
| } |
| |
| protected function propertySelectedHandler(event:RadiateEvent):void { |
| var metadata:MetaData = event.selectedItem as MetaData; |
| var newData:String; |
| |
| //trace("property change event"); |
| |
| newData = metadata.raw; |
| if (rawData==newData) { |
| //trace("data hasn't changed"); |
| return; |
| } |
| |
| rawData = newData; |
| mxTextArea.text = rawData; |
| mxTextAreaChangeHandler(); |
| } |
| |
| protected function objectSelectedHandler(event:RadiateEvent):void { |
| var object:Object = event.selectedItem; |
| updateObject(object); |
| //var valueObject:Object = ObjectUtil.getClassInfo(object); |
| //var value:String = ObjectUtil.toString(valueObject); |
| |
| //trace("property change event"); |
| |
| //if (rawData==value) { |
| //trace("data hasn't changed"); |
| // return; |
| //} |
| } |
| |
| protected function targetChangeHandler(event:RadiateEvent):void { |
| updateObject(event.selectedItem); |
| } |
| |
| private function mxTextAreaChangeHandler():void { |
| //trace("change handler:" + getTimer()) |
| if (!syntaxHighlighter) { |
| syntaxHighlighter = new SyntaxHighlighter(mxTextArea); |
| syntaxHighlighter.timerInterval = 20; |
| syntaxHighlighter.cssString = SyntaxHighlighter.CRIMSON_EDITOR_CSS; |
| syntaxHighlighter.addEventListener(Event.COMPLETE, completeHandler, false, 0, true); |
| } |
| |
| // do not highlight - it's too slow and slows everything else down |
| // syntaxHighlighter.highlightCode(); |
| } |
| |
| protected function completeHandler(event:Event):void {
|
| //trace("complete event:" + getTimer());
|
| } |
| |
| |
| ]]> |
| </fx:Script> |
| |
| |
| <!--<s:TextArea id="metadataTextArea" |
| top="8" |
| focusColor="#585858" |
| width="100%" height="100%" |
| fontFamily="Courier New" |
| borderVisible="false" |
| paddingTop="8" |
| fontSize="13" |
| prompt="No metadata available. Select a property, style or event."> |
| <s:keyFocusChange> |
| event.preventDefault(); |
| event.currentTarget.insertText("\t"); |
| </s:keyFocusChange> |
| </s:TextArea>--> |
| |
| |
| |
| <mx:TextArea id="mxTextArea" |
| top="8" |
| left="2" |
| focusAlpha="0" |
| fontFamily="Monaco,Menlo,Ubuntu Mono,Consolas,source-code-pro,monospace" |
| borderVisible="false" |
| paddingTop="8" |
| fontSize="12" |
| width="100%" height="100%" |
| editable="false" |
| leading="0" |
| /> |
| |
| <s:Label id="noDataLabel" |
| top="8" |
| left="2" |
| paddingTop="8" |
| color="#484848" |
| width="100%" height="100%" |
| fontSize="13" |
| visible="{mxTextArea.text==''}" |
| text="No metadata available. Select a property, style or event."> |
| </s:Label> |
| |
| |
| </s:Group> |