blob: f2896e1f736f57bfc7b2048d72ba45c8449e59ed [file] [log] [blame]
<?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:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo"
doubleClickEnabled="true"
doubleClick="itemrenderer1_doubleClickHandler(event)"
autoDrawBackground="true"
useHandCursor="true"
buttonMode="true"
height="22"
>
<fx:Metadata>
[HostComponent("spark.components.List")]
</fx:Metadata>
<fx:Script>
<![CDATA[
import com.flexcapacitor.model.IProject;
import com.flexcapacitor.model.DocumentData;
import spark.components.List;
import spark.components.supportClasses.ListBase;
/**
*
* */
override public function set data(value:Object):void {
super.data = value;
var project:IProject = value ? IProject(value) : null;
if (project && labelDisplay) {
labelDisplay.text = project.name;
}
}
protected function dataChangeHandler():void {
//this.data = textInput.text;
//dispatch the data update event
var list:ListBase = this.owner as ListBase;
var project:IProject = IProject(data);
project.name = textInput.text;
list.dataProvider.itemUpdated(project, "name", project.name, textInput.text);
currentState = "normal";
project.checkProjectHasChanged();
}
protected function itemrenderer1_doubleClickHandler(event:MouseEvent):void {
currentState = "edit";
textInput.text = labelDisplay.text;
}
override protected function getCurrentRendererState():String {
// if in edit state don't change unless
if (currentState=="edit") return "edit";
return super.getCurrentRendererState();
}
protected function textInput_focusOutHandler(event:FocusEvent):void {
dataChangeHandler();
currentState = "normal";
}
]]>
</fx:Script>
<s:states>
<s:State name="normal" />
<s:State name="hovered" />
<s:State name="selected" />
<s:State name="disabled" />
<s:State name="edit" enterState="textInput.setFocus()"/>
</s:states>
<!--<s:Rect height="100%" width="100%">
<s:fill>
<s:SolidColor color="0xEEFFFF"
alpha="0"
alpha.hovered="0.1"
alpha.selected="0.4" />
</s:fill>
</s:Rect>-->
<s:BitmapImage id="icon"
source="{data &amp;&amp; DocumentData(data).isOpen ? Radii8LibraryAssets.openFolder : Radii8LibraryAssets.projectIcon}"
top="4"
left="5"
>
</s:BitmapImage>
<s:BitmapImage id="saveIcon"
source="{Radii8LibraryAssets.save}"
right="5"
top="2"
visible="{data &amp;&amp; (DocumentData(data).saveInProgress || DocumentData(data).openInProgress)}"
>
</s:BitmapImage>
<s:Label id="labelDisplay"
height="100%"
width="100%"
left="20"
top="3"
verticalAlign="middle"
itemCreationPolicy="immediate"
paddingLeft="5"
includeIn="hovered, normal, selected"/>
<s:Label id="isChangedLabel2"
bottom="0"
left="0"
text=" "
height="100%"
width="4"
backgroundColor="#989898"
backgroundAlpha="1"
visible="{data &amp;&amp; DocumentData(data).isChanged}"/>
<s:TextInput id="textInput"
left="20"
includeIn="edit"
focusAlpha="0"
enter="dataChangeHandler()"
focusOut="textInput_focusOutHandler(event)"
width="100%" height="100%"/>
</s:ItemRenderer>