Module: nagvis Branch: master Commit: d599ebc72dcf8dae023f1fe2f16b0ce3798a003f URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis/commit/?id=d599ebc72dcf8dae023f1fe2f16b0ce3798a003f
Author: unknown <[email protected]> Date: Fri Jul 31 15:23:14 2009 +0300 gmap: Make 'Associate with' section of LocationBox to actually work Signed-off-by: unknown <[email protected]> --- uifx/src/modules/gmap/DialogLocation.mxml | 62 +++++++++++++++++++++++------ uifx/src/modules/gmap/GMapModule.as | 16 ++++--- 2 files changed, 59 insertions(+), 19 deletions(-) diff --git a/uifx/src/modules/gmap/DialogLocation.mxml b/uifx/src/modules/gmap/DialogLocation.mxml index 42563b8..35612c7 100644 --- a/uifx/src/modules/gmap/DialogLocation.mxml +++ b/uifx/src/modules/gmap/DialogLocation.mxml @@ -30,18 +30,19 @@ </mx:Metadata> <mx:Script> <![CDATA[ - import mx.events.MenuEvent; - import mx.collections.ArrayCollection; import mx.controls.Alert; import com.google.maps.LatLng; + import mx.collections.ArrayCollection; + import mx.events.MenuEvent; + [Bindable] public var locID : String; - public var hosts : ArrayCollection = new ArrayCollection() - public var hostgroups : ArrayCollection = new ArrayCollection() - public var services : ArrayCollection = new ArrayCollection(); - public var servicegroups : ArrayCollection = new ArrayCollection(); + public var hosts : ArrayCollection = new ArrayCollection; + public var hostgroups : ArrayCollection = new ArrayCollection; + public var services : ArrayCollection = new ArrayCollection; + public var servicegroups : ArrayCollection = new ArrayCollection; [Bindable] public var objects : ArrayCollection = hostgroups; @@ -51,7 +52,6 @@ locNObject.flowBox.setStyle("borderStyle", "solid"); locNObject.flowBox.setStyle("borderColor", "#000000"); locNObject.flowBox.setStyle("cornerRadius", "3"); - this.onObjectTypeChange(); } public function update(location : Location) : void @@ -64,6 +64,39 @@ locLng.text = LatLng.fromUrlValue(location.point).lng().toString(); locAddress.text = location.address; locDescription.text = location.description; + + if (location.object is Host) + { + locNObjectType.selectedIndex = 0; + onObjectTypeChange(); + // Note: onObjectTypeChange is called because Flex does not do this when setting selectedIndex manually + // though documentation says it should + locNObject.selectedItem = location.object; + } + else if (location.object is Service) + { + locNObjectType.selectedIndex = 1; + onObjectTypeChange(); + // Note: onObjectTypeChange is called because Flex does not do this when setting selectedIndex manually + // though documentation says it should + locNObject.selectedItem = location.object; + } + else if (location.object is HostGroup) + { + locNObjectType.selectedIndex = 2; + onObjectTypeChange(); + // Note: onObjectTypeChange is called because Flex does not do this when setting selectedIndex manually + // though documentation says it should + locNObject.selectedItem = location.object; + } + else if (location.object is ServiceGroup) + { + locNObjectType.selectedIndex = 3; + onObjectTypeChange(); + // Note: onObjectTypeChange is called because Flex does not do this when setting selectedIndex manually + // though documentation says it should + locNObject.selectedItem = location.object; + } } else { @@ -73,6 +106,11 @@ locLng.text = ""; locAddress.text = ""; locDescription.text = ""; + locNObjectType.selectedIndex = 2; + onObjectTypeChange(); + // Note: onObjectTypeChange is called because Flex does not do this when setting selectedIndex manually + // though documentation says it should + locNObject.selectedItem = null; } } @@ -88,17 +126,17 @@ public function hostLabelFunction(item : Object) : String { - return item.name + ' ' + item.address + ' ' + item.alias; + return item.name + ' / ' + item.address + ' (' + item.alias + ')'; } public function serviceLabelFunction(item : Object) : String { - return item.description + ' ' + item.host; + return item.description + ' on ' + item.host; } public function groupLabelFunction(item : Object) : String { - return item.name + ' ' + item.alias; + return item.name + ' (' + item.alias + ')'; } private function onObjectTypeChange() : void @@ -166,7 +204,7 @@ </mx:HBox> <mx:HBox width="100%"> <mx:Spacer/> - <mx:ComboBox id="locNObjectType" selectedIndex="2" width="100%" change="onObjectTypeChange()"> + <mx:ComboBox id="locNObjectType" width="100%" change="onObjectTypeChange()"> <mx:ArrayCollection> <mx:String>Host</mx:String> <mx:String>Service</mx:String> @@ -185,7 +223,7 @@ <mx:Spacer/> <hc:AdvancedAutoComplete id="locNObject" width="100%" dataProvider="{objects}" selectedItemStyleName="underline" labelFunction="groupLabelFunction" - matchType="anyPart" allowMultipleSelection="false" + matchType="anyPart" allowMultipleSelection="false" showRemoveIcon="true" actionsMenuDataProvider="{autoCompleteMenu}" itemClick="objectItemClick(event)" browserFields="{['name', 'alias']}" /> diff --git a/uifx/src/modules/gmap/GMapModule.as b/uifx/src/modules/gmap/GMapModule.as index 75a483a..33a66f5 100644 --- a/uifx/src/modules/gmap/GMapModule.as +++ b/uifx/src/modules/gmap/GMapModule.as @@ -47,10 +47,10 @@ private var viewpoints : ArrayCollection; private var locations : LocationsCollection = new LocationsCollection; private var foundLocations : LocationsCollection = new LocationsCollection; private var links : ArrayCollection; -private var hosts : ArrayCollection; -private var hostgroups : ArrayCollection; -private var services : ArrayCollection = new ArrayCollection(); -private var servicegroups : ArrayCollection = new ArrayCollection(); +private var hosts : ArrayCollection = new ArrayCollection; +private var hostgroups : ArrayCollection = new ArrayCollection; +private var services : ArrayCollection = new ArrayCollection; +private var servicegroups : ArrayCollection = new ArrayCollection; private var locationsView : LocationsView; private var foundLocationsView : FoundLocationsView; @@ -352,9 +352,10 @@ next_host: if (locationsView && locationsView.selectedLocation) locationBox.update(locationsView.selectedLocation); + else if(foundLocationsView && foundLocationsView.selectedLocation) + locationBox.update(foundLocationsView.selectedLocation); else - if(foundLocationsView && foundLocationsView.selectedLocation) - locationBox.update(foundLocationsView.selectedLocation); + locationBox.update(null); } private function onHideLocationBox() : void @@ -374,7 +375,8 @@ private function onSaveLocation() : void { rLocations.edit(locationBox.locID, (new LatLng(parseFloat(locationBox.locLat.text), parseFloat(locationBox.locLng.text)).toUrlValue(16)), - locationBox.locName.text, locationBox.locAddress.text, locationBox.locDescription.text); + locationBox.locName.text, locationBox.locAddress.text, locationBox.locDescription.text, + locationBox.locNObject.selectedItem); } else { ------------------------------------------------------------------------------ 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
