Module: nagvis Branch: master Commit: f77d7519498acdac199d9b6deeaa9ce858572ae7 URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis/commit/?id=f77d7519498acdac199d9b6deeaa9ce858572ae7
Author: Roman Kyrylych <[email protected]> Date: Tue Aug 18 17:25:16 2009 +0300 gmap: Shared location and link activation code Signed-off-by: Roman Kyrylych <[email protected]> --- uifx/src/modules/gmap/mate/LinksEM.mxml | 2 +- uifx/src/modules/gmap/mate/LocationsEM.mxml | 2 +- uifx/src/modules/gmap/mediator/MainMD.as | 48 +++++++++++++++------------ 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/uifx/src/modules/gmap/mate/LinksEM.mxml b/uifx/src/modules/gmap/mate/LinksEM.mxml index ed9bd5c..0a7763b 100644 --- a/uifx/src/modules/gmap/mate/LinksEM.mxml +++ b/uifx/src/modules/gmap/mate/LinksEM.mxml @@ -36,7 +36,7 @@ <EventHandlers type="{LinkEvent.SELECTED}"> <MethodInvoker generator="{CurrentLink}" method="update" arguments="{event.link}"/> - <MethodInvoker generator="{MainMD}" method="selectLink" arguments="{event.link}"/> + <MethodInvoker generator="{MainMD}" method="activate" arguments="{event.link}"/> </EventHandlers> <EventHandlers type="{LinkEvent.ACTIVATE}"> diff --git a/uifx/src/modules/gmap/mate/LocationsEM.mxml b/uifx/src/modules/gmap/mate/LocationsEM.mxml index 6f42468..5170adb 100644 --- a/uifx/src/modules/gmap/mate/LocationsEM.mxml +++ b/uifx/src/modules/gmap/mate/LocationsEM.mxml @@ -47,7 +47,7 @@ <EventHandlers type="{LocationEvent.ACTIVATE}"> <DataCopier destination="data" destinationKey="settings" source="{SettingsData}" sourceKey="settings"/> - <MethodInvoker generator="{MainMD}" method="activateLocation" arguments="{[event.location, data.settings]}"/> + <MethodInvoker generator="{MainMD}" method="activate" arguments="{[event.location, data.settings]}"/> </EventHandlers> <EventHandlers type="{AddressEvent.LOCATE}"> diff --git a/uifx/src/modules/gmap/mediator/MainMD.as b/uifx/src/modules/gmap/mediator/MainMD.as index dfbd015..163cc32 100644 --- a/uifx/src/modules/gmap/mediator/MainMD.as +++ b/uifx/src/modules/gmap/mediator/MainMD.as @@ -25,6 +25,7 @@ package modules.gmap.mediator import flash.external.ExternalInterface; import flash.system.Security; + import modules.gmap.domain.Link; import modules.gmap.domain.Location; import modules.gmap.domain.Settings; import modules.gmap.domain.nagios.Host; @@ -107,14 +108,27 @@ package modules.gmap.mediator } } - public function activateLocation(location : Location, settings : Settings) : void + public function selectLink(link : Link) : void + { + _view.linksBox.setCurrentState('right-expanded'); + } + + public function gotoURL(url : String, newWindow : Boolean) : void + { + if (newWindow) + ExternalInterface.call('window.open("' + url + '")'); + else + ExternalInterface.call('window.location.assign("' + url + '")'); + } + + public function activate(element : Object, settings : Settings) : void { var slices : Array; - if (location.action == "") + if (element.action == "") slices = settings.defaultLocationAction.split(':', 2); else - slices = location.action.split(':', 2); + slices = element.action.split(':', 2); switch (slices[0]) { @@ -123,26 +137,26 @@ package modules.gmap.mediator case 'nagios': var nagiosUrl : String; - if (location.object is Host) + if (element.object is Host) { nagiosUrl = settings.hosturl; - nagiosUrl = nagiosUrl.replace(/\[host_name]/, location.object.name); + nagiosUrl = nagiosUrl.replace(/\[host_name]/, element.object.name); } - else if (location.object is HostGroup) + else if (element.object is HostGroup) { nagiosUrl = settings.hostgroupurl; - nagiosUrl = nagiosUrl.replace(/\[hostgroup_name]/, location.object.name); + nagiosUrl = nagiosUrl.replace(/\[hostgroup_name]/, element.object.name); } - else if (location.object is Service) + else if (element.object is Service) { nagiosUrl = settings.serviceurl; - nagiosUrl = nagiosUrl.replace(/\[host_name]/, location.object.host); - nagiosUrl = nagiosUrl.replace(/\[service_description]/, location.object.description); + nagiosUrl = nagiosUrl.replace(/\[host_name]/, element.object.host); + nagiosUrl = nagiosUrl.replace(/\[service_description]/, element.object.description); } - else if (location.object is ServiceGroup) + else if (element.object is ServiceGroup) { nagiosUrl = settings.servicegroupurl; - nagiosUrl = nagiosUrl.replace(/\[servicegroup_name]/, location.object.name); + nagiosUrl = nagiosUrl.replace(/\[servicegroup_name]/, element.object.name); } else return; // this should not ever happen @@ -161,17 +175,9 @@ package modules.gmap.mediator return; default: - gotoURL(location.action, settings.openLinksInNewWindow); + gotoURL(element.action, settings.openLinksInNewWindow); return; } } - - public function gotoURL(url : String, newWindow : Boolean) : void - { - if (newWindow) - ExternalInterface.call('window.open("' + url + '")'); - else - ExternalInterface.call('window.location.assign("' + url + '")'); - } } } ------------------------------------------------------------------------------ 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
