Module: nagvis
Branch: master
Commit: 878f12c3ef9d03de32cc8dff245184a19b08effa
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis/commit/?id=878f12c3ef9d03de32cc8dff245184a19b08effa

Author: Andriy Skuratov <[email protected]>
Date:   Wed Aug 12 17:45:10 2009 +0300

Fixed the UI logic setting Nagios objects.

---

 uifx/src/modules/gmap/mate/NagiosEM.mxml       |    8 ++--
 uifx/src/modules/gmap/view/DialogLocation.mxml |   64 ++++++++++++++++++------
 2 files changed, 52 insertions(+), 20 deletions(-)

diff --git a/uifx/src/modules/gmap/mate/NagiosEM.mxml 
b/uifx/src/modules/gmap/mate/NagiosEM.mxml
index dfcb12d..60c6c5d 100644
--- a/uifx/src/modules/gmap/mate/NagiosEM.mxml
+++ b/uifx/src/modules/gmap/mate/NagiosEM.mxml
@@ -26,7 +26,7 @@
        </EventHandlers>

        

        <EventHandlers type="{NagiosObjectEvent.LOAD_ALL_HOSTS_ONCE}">

-               <RemoteObjectInvoker instance="{NagiosService}" 
method="getHosts">

+               <RemoteObjectInvoker instance="{NagiosService}" 
method="getHosts" showBusyCursor="true">

                        <resultHandlers>

                                <DataCopier source="result" 
destination="{HostsData}" destinationKey="source"/>

                        </resultHandlers>

@@ -41,7 +41,7 @@
        </EventHandlers>

        

        <EventHandlers type="{NagiosObjectEvent.LOAD_ALL_SERVICES_ONCE}">

-               <RemoteObjectInvoker instance="{NagiosService}" 
method="getServices">

+               <RemoteObjectInvoker instance="{NagiosService}" 
method="getServices" showBusyCursor="true">

                        <resultHandlers>

                                <DataCopier source="result" 
destination="{ServicesData}" destinationKey="source"/>

                        </resultHandlers>

@@ -56,7 +56,7 @@
        </EventHandlers>

        

        <EventHandlers type="{NagiosObjectEvent.LOAD_ALL_HOSTGROUPS_ONCE}">

-               <RemoteObjectInvoker instance="{NagiosService}" 
method="getHostGroups">

+               <RemoteObjectInvoker instance="{NagiosService}" 
method="getHostGroups" showBusyCursor="true">

                        <resultHandlers>

                                <DataCopier source="result" 
destination="{HostGroupsData}" destinationKey="source"/>

                        </resultHandlers>

@@ -71,7 +71,7 @@
        </EventHandlers>

        

        <EventHandlers type="{NagiosObjectEvent.LOAD_ALL_SERVICEGROUPS_ONCE}">

-               <RemoteObjectInvoker instance="{NagiosService}" 
method="getServiceGroups">

+               <RemoteObjectInvoker instance="{NagiosService}" 
method="getServiceGroups" showBusyCursor="true">

                        <resultHandlers>

                                <DataCopier source="result" 
destination="{ServiceGroupsData}" destinationKey="source"/>

                        </resultHandlers>

diff --git a/uifx/src/modules/gmap/view/DialogLocation.mxml 
b/uifx/src/modules/gmap/view/DialogLocation.mxml
index e356ddd..5bc90d3 100644
--- a/uifx/src/modules/gmap/view/DialogLocation.mxml
+++ b/uifx/src/modules/gmap/view/DialogLocation.mxml
@@ -84,28 +84,33 @@
                                                 */
                                                if (location.object is 
HostGroup)
                                                {
-                                                       
locNObjectType.selectedIndex = 2;
+                                                       
locNObjectType.selectedIndex = 3;
                                                        onObjectTypeChange();
                                                        locNObject.selectedItem 
= location.object;
                                                }
                                                else if (location.object is 
ServiceGroup)
                                                {
-                                                       
locNObjectType.selectedIndex = 3;
+                                                       
locNObjectType.selectedIndex = 4;
                                                        onObjectTypeChange();
                                                        locNObject.selectedItem 
= location.object;
                                                }
                                                else if (location.object is 
Host)
                                                {
-                                                       
locNObjectType.selectedIndex = 0;
+                                                       
locNObjectType.selectedIndex = 1;
                                                        onObjectTypeChange();
                                                        locNObject.selectedItem 
= location.object;
                                                }
                                                else if (location.object is 
Service)
                                                {
-                                                       
locNObjectType.selectedIndex = 1;
+                                                       
locNObjectType.selectedIndex = 2;
                                                        onObjectTypeChange();
                                                        locNObject.selectedItem 
= location.object;
                                                }
+                                               else
+                                               {
+                                                       
locNObjectType.selectedIndex = 0;
+                                                       onObjectTypeChange();
+                                               }
                                        }
                                        else
                                        {
@@ -114,7 +119,7 @@
                                                locLng.text = "";
                                                locAddress.text = "";
                                                locDescription.text = "";
-                                               locNObjectType.selectedIndex = 
2;
+                                               locNObjectType.selectedIndex = 
0;
                                                onObjectTypeChange();
                                        }
                                }
@@ -171,25 +176,35 @@
                        private function onObjectTypeChange() : void
                        {
                                locNObject.removeAll();
+                               locNObject.textInput.text = '';
 
                                switch(locNObjectType.selectedIndex)
                                {
                                        case 0:
+                                               locNObject.textInput.enabled = 
false;
+                                               locNObject.dataProvider = null;
+                                               locNObject.browserFields = null;
+                                               locNObject.labelFunction = null;
+                                       case 1:
+                                               locNObject.textInput.enabled = 
true;
                                                locNObject.dataProvider = hosts;
                                                locNObject.browserFields = 
["name", "address", "alias"];
                                                locNObject.labelFunction = 
hostLabelFunction;
                                                break;
-                                       case 1:
+                                       case 2:
+                                               locNObject.textInput.enabled = 
true;
                                                locNObject.dataProvider = 
services;
                                                locNObject.browserFields = 
["host", "description"];
                                                locNObject.labelFunction = 
serviceLabelFunction;
                                                break;
-                                       case 2:
+                                       case 3:
+                                               locNObject.textInput.enabled = 
true;
                                                locNObject.dataProvider = 
hostgroups;
                                                locNObject.browserFields = 
["name", "alias"];
                                                locNObject.labelFunction = 
groupLabelFunction;
                                                break;
-                                       case 3:
+                                       case 4:
+                                               locNObject.textInput.enabled = 
true;
                                                locNObject.dataProvider = 
servicegroups;
                                                locNObject.browserFields = 
["name", "alias"];
                                                locNObject.labelFunction = 
groupLabelFunction;
@@ -201,16 +216,16 @@
                        {
                                switch(locNObjectType.selectedIndex)
                                {
-                                       case 0:
+                                       case 1:
                                                dispatchEvent(new 
NagiosObjectEvent(NagiosObjectEvent.NEED_ALL_HOSTS));
                                                break;
-                                       case 1:
+                                       case 2:
                                                dispatchEvent(new 
NagiosObjectEvent(NagiosObjectEvent.NEED_ALL_SERVICES));
                                                break;
-                                       case 2:
+                                       case 3:
                                                dispatchEvent(new 
NagiosObjectEvent(NagiosObjectEvent.NEED_ALL_HOSTGROUPS));
                                                break;
-                                       case 3:
+                                       case 4:
                                                dispatchEvent(new 
NagiosObjectEvent(NagiosObjectEvent.NEED_ALL_SERVICEGROUPS));
                                                break;
                                }
@@ -220,11 +235,11 @@
                        {                       
                                switch(locAction.selectedIndex)
                                {
-                                       case 2:
+                                       case 3:
                                                locActionMaps.visible = true; 
                                                locActionURL.visible = false;
                                                break;
-                                       case 3:
+                                       case 4:
                                                locActionMaps.visible = false; 
                                                locActionURL.visible = true;
                                                break;
@@ -236,6 +251,7 @@
        </mx:Script>
        <mx:Script>
                <![CDATA[
+                       import mx.events.CollectionEvent;
                        
                        /***
                         * Code concerning Nagios object autocomlete
@@ -253,11 +269,26 @@
                                switch (String(event.it...@data))
                                {
                                        case "browse":
-                                               loadNagiosData();
-                                               locNObject.showBrowser();
+                                               
+                                               
if(locNObject.dataProvider.length == 0)
+                                               {
+                                                       
locNObject.dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE, 
openBrowser);       
+                                                       loadNagiosData();
+                                               }
+                                               else
+                                               {
+                                                       
locNObject.showBrowser();
+                                               }
+                                               
                                                break;
                                }
                        }
+                       
+                       private function openBrowser(event:*):void
+                       {
+                               
locNObject.dataProvider.removeEventListener(CollectionEvent.COLLECTION_CHANGE, 
openBrowser);
+                               locNObject.showBrowser();
+                       }
 
                        public function hostLabelFunction(item : Object) : 
String
                        {
@@ -322,6 +353,7 @@
                                                <mx:Spacer/>
                                                <mx:ComboBox 
id="locNObjectType" width="100%" change="onObjectTypeChange()">
                                                        <mx:ArrayCollection>
+                                                               
<mx:String>Unset</mx:String>
                                                                
<mx:String>Host</mx:String>
                                                                
<mx:String>Service</mx:String>
                                                                <mx:String>Host 
Group</mx:String>


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to