Changeset 2572
- Timestamp:
- 02/13/13 08:49:29 (11 years ago)
- Location:
- ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/browser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/browser/infoPage.mxml
r2278 r2572 23 23 height="100%" 24 24 width="100%" 25 styleName="borderStyles"> 25 styleName="borderStyles" 26 change="infoViewStack_changeHandler(event)" 27 > 26 28 27 29 <browser:xmlBrowsePanel id="viewPanel" … … 29 31 cmdComponent="{cmdComponent}" 30 32 itemDescription="{_itemDescription}"/> 33 31 34 <browser:xmlPanel id="xmlPanel" 32 35 label="xml" 33 36 cmdComponent="{cmdComponent}"/> 37 34 38 <browser:CommentsPanel id="commentsPanel" 35 39 label="{commentsLabel}" … … 46 50 47 51 import mx.events.FlexEvent; 52 import mx.events.IndexChangedEvent; 53 import mx.messaging.SubscriptionInfo; 48 54 49 55 [Bindable] … … 54 60 infoViewStack.selectedChild = viewPanel; 55 61 } else if(startupPanel == Config.BROWSER_PANEL_XML) { 56 infoViewStack.selectedChild = xmlPanel;62 //infoViewStack.selectedChild = xmlPanel; 57 63 } else if(startupPanel == Config.BROWSER_PANEL_COMMENTS) { 58 64 infoViewStack.selectedChild = commentsPanel; … … 77 83 } 78 84 85 protected function infoViewStack_changeHandler(event:IndexChangedEvent):void 86 { 87 xmlPanel.updateCmdComponentText(); 88 } 89 79 90 ]]> 80 91 </mx:Script> -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/browser/xmlPanel.mxml
r1730 r2572 3 3 xmlns:comp="clarin.cmdi.componentregistry.common.components.*"> 4 4 5 <mx:XML id="cmdComponent"/>6 5 <comp:ScrollableTextArea id="infoTextArea" 7 6 styleName="xmlTextArea" 8 7 editable="false" 9 text="{cmdComponent}"10 8 width="100%" 11 9 height="100%" … … 13 11 paddingTop="5" 14 12 /> 13 14 <mx:Script> 15 <!-- 16 The code below assures lazy loading of the component XML into the scrollable text area. 17 Large component specifications can cause the application to hang or even crash the browser, 18 see <https://trac.clarin.eu/ticket/268> 19 --> 20 <![CDATA[ 21 import mx.containers.ViewStack; 22 import mx.core.Application; 23 private var componentXML:XML; 24 private var MAX_XML_LENGTH:int = 10000; 25 26 public function set cmdComponent(xml:XML):void { 27 if(this.componentXML != xml){ 28 this.componentXML = xml; 29 updateCmdComponentText(); 30 } 31 } 32 33 public function updateCmdComponentText():void { 34 // Only forward the XML to the text area if the XML panel is the selected view 35 if(isSelectedView()){ 36 var xmlText:String = componentXML.toXMLString(); 37 if(xmlText.length > MAX_XML_LENGTH + 3){ 38 // XML too lengthy, truncate (otherwise we run into performance issues) 39 infoTextArea.text = xmlText.substr(0, MAX_XML_LENGTH) + "...\n\nSpecification too large to display. Download XML to see the entire specification."; 40 } else{ 41 infoTextArea.text = xmlText; 42 } 43 } 44 } 45 46 private function isSelectedView():Boolean 47 { 48 var obj:DisplayObject = this; 49 // Whole chain until application root should be visible 50 while (obj && obj !== Application.application) 51 { 52 // Special case: viewstack - this item should be the selected item 53 if(obj.parent is ViewStack){ 54 return ViewStack(obj.parent).selectedChild == obj; 55 } 56 57 obj = obj.parent; 58 } 59 return true; 60 } 61 ]]> 62 </mx:Script> 15 63 </mx:VBox>
Note: See TracChangeset
for help on using the changeset viewer.