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

Author: Roman Kyrylych <[email protected]>
Date:   Thu Aug 20 17:15:45 2009 +0300

gmap: Redraw link line after link locations change

Signed-off-by: Roman Kyrylych <[email protected]>

---

 uifx/src/modules/gmap/data/LinksData.as            |   19 +++++++++++-----
 uifx/src/modules/gmap/domain/Link.as               |    2 +
 uifx/src/modules/gmap/mate/LinksEM.mxml            |    4 ++-
 .../modules/gmap/view/controls/GMapLinkControl.as  |   16 +++++++-------
 .../modules/gmap/view/controls/GMapLinksControl.as |   22 +++++++++++++++++++-
 uifx/src/modules/gmap/view/controls/LinkLine.as    |   20 ++++++++++++++---
 6 files changed, 63 insertions(+), 20 deletions(-)

diff --git a/uifx/src/modules/gmap/data/LinksData.as 
b/uifx/src/modules/gmap/data/LinksData.as
index 2561383..2a70202 100644
--- a/uifx/src/modules/gmap/data/LinksData.as
+++ b/uifx/src/modules/gmap/data/LinksData.as
@@ -73,17 +73,24 @@ package modules.gmap.data
                        return null;
                }
 
-               public function addUpdateItem(item : Link) : void
+               public function addUpdateItem(item : Link) : Link
                {
                        var link : Link = this.getItemById(item.id);
 
-                       if (link == null)
+                       if (link)
                        {
-                               if(resolveLink(item))
-                                       addItem(item);
-                       }
-                       else
+                               resolveLink(item);
                                link.update(item);
+                               return link;
+                       }
+
+                       if (resolveLink(item))
+                       {
+                               addItem(item);
+                               return item;
+                       }
+
+                       return null;
                }
 
                public function addUpdateItems(items : Array) : void
diff --git a/uifx/src/modules/gmap/domain/Link.as 
b/uifx/src/modules/gmap/domain/Link.as
index 5fdd47f..de6e967 100644
--- a/uifx/src/modules/gmap/domain/Link.as
+++ b/uifx/src/modules/gmap/domain/Link.as
@@ -46,6 +46,8 @@ package modules.gmap.domain
                public function update(value : Link) : void
                {
                        this.id = value.id;
+                       this.location1 = value.location1;
+                       this.location2 = value.location2;
                        this.id1 = value.id1;
                        this.id2 = value.id2;
                        this.description = value.description;
diff --git a/uifx/src/modules/gmap/mate/LinksEM.mxml 
b/uifx/src/modules/gmap/mate/LinksEM.mxml
index 0582620..ac8dea0 100644
--- a/uifx/src/modules/gmap/mate/LinksEM.mxml
+++ b/uifx/src/modules/gmap/mate/LinksEM.mxml
@@ -48,7 +48,7 @@
                <RemoteObjectInvoker instance="{LinksService}" method="add" 
arguments="{event.link}">
                        <resultHandlers>
                                <MethodInvoker generator="{LinksData}" 
method="addUpdateItem" arguments="{resultObject}"/>
-                               <MethodInvoker generator="{CurrentLink}" 
method="update" arguments="{resultObject}"/>
+                               <MethodInvoker generator="{CurrentLink}" 
method="update" arguments="{lastReturn}"/>
                        </resultHandlers>
                </RemoteObjectInvoker>
        </EventHandlers>
@@ -56,7 +56,9 @@
        <EventHandlers type="{LinkEvent.SAVE}">
                <RemoteObjectInvoker instance="{LinksService}" method="edit" 
arguments="{event.link}">
                        <resultHandlers>
+                               <MethodInvoker generator="{CurrentLink}" 
method="update" arguments="{null}"/>
                                <MethodInvoker generator="{LinksData}" 
method="addUpdateItem" arguments="{resultObject}"/>
+                               <MethodInvoker generator="{CurrentLink}" 
method="update" arguments="{lastReturn}"/>
                        </resultHandlers>
                </RemoteObjectInvoker>
        </EventHandlers>
diff --git a/uifx/src/modules/gmap/view/controls/GMapLinkControl.as 
b/uifx/src/modules/gmap/view/controls/GMapLinkControl.as
index 27c903c..e85c11e 100644
--- a/uifx/src/modules/gmap/view/controls/GMapLinkControl.as
+++ b/uifx/src/modules/gmap/view/controls/GMapLinkControl.as
@@ -26,9 +26,9 @@ package modules.gmap.view.controls
        import com.google.maps.overlays.Polyline;

        import com.google.maps.overlays.PolylineOptions;

        import com.google.maps.styles.StrokeStyle;

-       

+

        import modules.gmap.domain.Link;

-       

+

        import mx.core.UIComponent;

 

        public class GMapLinkControl extends UIComponent

@@ -63,15 +63,15 @@ package modules.gmap.view.controls
                {

                        return _link;

                }               

-               

+

                public function set link(value:Link):void

                {

                        if(_link !== value)

                                _link = value;

-                               

+

                        reinitLine(); 

                }

-               

+

                protected function reinitLine():void

                {

                        if(_map)

@@ -80,7 +80,7 @@ package modules.gmap.view.controls
                                {

                                        var point1 : LatLng = 
LatLng.fromUrlValue(_link.location1.point);

                                        var point2 : LatLng = 
LatLng.fromUrlValue(_link.location2.point);

-               

+

                                        var options : PolylineOptions = new 
PolylineOptions({

                                                strokeStyle: new StrokeStyle({

                                                        color: 0xffffff,

@@ -88,9 +88,9 @@ package modules.gmap.view.controls
                                                        alpha: 1

                                                })

                                        });

-               

+

                                        _line = new Polyline([point1, point2], 
options);

-                                       

+

                                        _map.addOverlay(_line);

                                }

                                else

diff --git a/uifx/src/modules/gmap/view/controls/GMapLinksControl.as 
b/uifx/src/modules/gmap/view/controls/GMapLinksControl.as
index 7b85e2f..96ced53 100644
--- a/uifx/src/modules/gmap/view/controls/GMapLinksControl.as
+++ b/uifx/src/modules/gmap/view/controls/GMapLinksControl.as
@@ -29,6 +29,7 @@ package modules.gmap.view.controls
        import modules.gmap.domain.Link;
        import modules.gmap.events.LinkEvent;
 
+       import mx.controls.RichTextEditor;
        import mx.core.UIComponent;
        import mx.events.CollectionEvent;
        import mx.events.CollectionEventKind;
@@ -100,7 +101,7 @@ package modules.gmap.view.controls
                                        {
                                                marked = _lines.shift();
 
-                                               if (marked.link.id1 === 
removed.id1 && marked.link.id2 === removed.id2)
+                                               if (marked.link.id === 
removed.id)
                                                {
                                                        if (visible && _map)
                                                                
_map.removeOverlay(marked);
@@ -161,6 +162,7 @@ package modules.gmap.view.controls
                                var l : LinkLine = new LinkLine(link);
                                l.addEventListener(LinkEvent.SELECTED, 
redispatchMarkerEvent);
                                l.addEventListener(LinkEvent.ACTIVATE, 
redispatchMarkerEvent);
+                               l.addEventListener(LinkEvent.CHANGE, 
onLinkChange);
                                _lines.push(l);
 
                                if (visible)
@@ -174,5 +176,23 @@ package modules.gmap.view.controls
                {
                        dispatchEvent(event);
                }
+
+               protected function onLinkChange(event : LinkEvent) : void
+               {
+                       for (var i:int = 0; i < _lines.length; i++)
+                       {
+                               if(_lines[i].link.id == event.link.id)
+                               {
+                                       if(_map)
+                                               _map.removeOverlay(_lines[i]);
+
+                                       _lines.splice(i, 1);
+
+                                       createLine(event.link);
+
+                                       break;
+                               }
+                       }
+               }
        }
 }
diff --git a/uifx/src/modules/gmap/view/controls/LinkLine.as 
b/uifx/src/modules/gmap/view/controls/LinkLine.as
index 0262ace..aad66a2 100644
--- a/uifx/src/modules/gmap/view/controls/LinkLine.as
+++ b/uifx/src/modules/gmap/view/controls/LinkLine.as
@@ -102,11 +102,23 @@ package modules.gmap.view.controls
                        }
                }
 
-               protected function onChange(event : *) : void
+               protected function onChange(event : PropertyChangeEvent) : void
                {
-                       var options : PolylineOptions = this.getOptions();
-                       options.strokeStyle.color = chooseColor(link.state);
-                       this.setOptions(options);
+                       trace(event.property + ':' + event.oldValue + ' -> ' + 
event.newValue);
+                       switch (event.property)
+                       {
+                               case 'id1':
+                               case 'id2':
+                                       dispatchEvent(
+                                               new LinkEvent(LinkEvent.CHANGE, 
_link, true)
+                                       );
+                                       break;
+
+                               case 'state':
+                                       var options : PolylineOptions = 
this.getOptions();
+                                       options.strokeStyle.color = 
chooseColor(link.state);
+                                       this.setOptions(options);
+                       }
                }
 
                public function get link() : Link


------------------------------------------------------------------------------
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