<?xml version="1.0" encoding="utf-8"?>
<!--
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  - JaDOrT: JASMINe Deployment Orchestration Tool
  - Copyright (C) 2008-2009 Bull S.A.S.
  - Copyright (C) 2008-2009 France Telecom R&D
  - Contact: jasmine@ow2.org
  -
  - This library is free software; you can redistribute it and/or
  - modify it under the terms of the GNU Lesser General Public
  - License as published by the Free Software Foundation; either
  - version 2.1 of the License, or any later version.
  -
  - This library is distributed in the hope that it will be useful,
  - but WITHOUT ANY WARRANTY; without even the implied warranty of
  - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  - Lesser General Public License for more details.
  -
  - You should have received a copy of the GNU Lesser General Public
  - License along with this library; if not, write to the Free Software
  - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  - USA
  -
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  - $Id: SelectVMImageForServer.mxml 3560 2009-04-24 09:23:44Z alitokmen $
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
           horizontalScrollPolicy="off"
           width="100%"
           height="100%"
           creationComplete="registerEventHandlers()">

    <mx:Script>
        <![CDATA[

            import mx.states.*;
            import mx.controls.*;
            import mx.managers.*;
            import mx.events.*;
            import flash.events.*;
            import flash.net.*;
            import org.ow2.jasmine.jadort.client.flex.model.*;
            import org.ow2.jasmine.jadort.client.flex.event.*
            import com.adobe.cairngorm.control.CairngormEventDispatcher;
            import mx.core.UIComponent;

            [Bindable]
            public var model : JadortModelLocator = JadortModelLocator.getInstance();

            [Bindable]
            public var titleText : String = null;

            private function registerEventHandlers() : void {
                CairngormEventDispatcher.getInstance().addEventListener(
                    ProgressStateEvent.EVENT_PROGRESS_STATE, updateSelectVMImageForServerTitle);

                // Initial refresh of the title text
                updateSelectVMImageForServerTitle(null);
            }

            private function updateSelectVMImageForServerTitle(evt : ProgressStateEvent) : void {
                if (model == null || model.selectedServer == null) {
                    titleText = "Loading servers list, please wait...";
                } else {
                    titleText = "Select the VM image to deploy on the server \"" + model.selectedServer.name + "\":";
                }
            }

        ]]>
    </mx:Script>
    
    <mx:Grid x="0" y="0" width="100%" height="100%">
        <mx:GridRow width="100%" height="30">
            <mx:GridItem width="100%" height="100%">
                <mx:Label width="100%" color="blue" height="100%" fontSize="11" text="{titleText}" />
            </mx:GridItem>
        </mx:GridRow>
        <mx:GridRow width="100%" height="100%">
            <mx:GridItem width="100%" height="100%">
                <mx:DataGrid id="dg" width="100%" rowCount="{model.selectedGroup.vmImages.length}" dataProvider="{model.selectedGroup.vmImages}">
                    <mx:columns>
                        <mx:DataGridColumn dataField="name" headerText="VM Image name" />
                        <mx:DataGridColumn width="125" sortable="false" dataField="name" headerText="Action" editable="true"
                            itemRenderer="org.ow2.jasmine.jadort.client.flex.view.SelectVMImageActionOperationRender" />
                    </mx:columns>
                </mx:DataGrid>
            </mx:GridItem>
        </mx:GridRow>
    </mx:Grid>
</mx:Canvas>
