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

Author: Roman Kyrylych <[email protected]>
Date:   Thu Aug 20 13:41:51 2009 +0300

gmap: Added id to Link

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

---

 share/netmap/Link.php                      |    7 +++++--
 share/netmap/LinkService.php               |   16 ++++++++--------
 uifx/src/modules/gmap/data/LinksData.as    |   12 ++++++------
 uifx/src/modules/gmap/domain/Link.as       |    3 +++
 uifx/src/modules/gmap/mate/LinksEM.mxml    |    2 +-
 uifx/src/modules/gmap/view/DialogLink.mxml |    5 +++--
 6 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/share/netmap/Link.php b/share/netmap/Link.php
index e28a222..dd92154 100644
--- a/share/netmap/Link.php
+++ b/share/netmap/Link.php
@@ -28,6 +28,7 @@ class Link
        const STATE_WARNING = 2;
        const STATE_ERROR = 3;
 
+       public $id;
        public $id1;
        public $id2;
        public $description;
@@ -35,9 +36,10 @@ class Link
        public $object;
        public $state;
 
-       public function __construct($id1 = "", $id2 = "", $description = "",
+       public function __construct($id = '', $id1 = "", $id2 = "", 
$description = "",
                $action = "", $object = null, $state = self::STATE_UNKNOWN)
        {
+               $this->id = $id;
                $this->id1 = $id1;
                $this->id2 = $id2;
                $this->description = $description;
@@ -79,13 +81,14 @@ class Link
                        }
                }
 
-               return new Link((string)$node['id1'], (string)$node['id2'],
+               return new Link((string)$node['id'], (string)$node['id1'], 
(string)$node['id2'],
                        (string)$node['description'], (string)$node['action'], 
$object);
        }
 
        public function toXML($parent)
        {
                $node = $parent->addChild('link');
+               $node->addAttribute('id', $this->id);
                $node->addAttribute('id1', $this->id1);
                $node->addAttribute('id2', $this->id2);
                @$node->addAttribute('description', $this->description);
diff --git a/share/netmap/LinkService.php b/share/netmap/LinkService.php
index a09f510..56d8484 100644
--- a/share/netmap/LinkService.php
+++ b/share/netmap/LinkService.php
@@ -85,6 +85,7 @@ class LinkService
                if (($xml = @simplexml_load_file('links.xml')) === FALSE)
                        throw new Exception('Could not read links.xml');
 
+               $link->id = uniqid('', true);
                self::updateState($link);
                $node = $link->toXML($xml);
 
@@ -94,12 +95,12 @@ class LinkService
                        throw new Exception('Could not write links.xml');
     }
 
-       private function removeNode(&$xml, $id1, $id2)
+       private function removeNode(&$xml, $id)
        {
                $index = 0;
                foreach ($xml->link as $node)
                {
-                       if ($node['id1'] == $id1 && $node['id2'] == $id2)
+                       if ($node['id'] == $id)
                        {
                                // Note: unset($node) won't work thus the need 
for $index
                                unset($xml->link[$index]);
@@ -123,7 +124,7 @@ class LinkService
 
                self::updateState($link);
 
-               self::removeNode($xml, $link->id1, $link->id2);
+               self::removeNode($xml, $link->id);
 
                $link->toXML($xml);
 
@@ -134,19 +135,18 @@ class LinkService
     }
 
        /**
-        * @param  string $id1
-        * @param  string $id2
+        * @param  string $id
         * @return string
         */
-       public function remove($id1, $id2)
+       public function remove($id)
        {
                if (($xml = @simplexml_load_file('links.xml')) === FALSE)
                        throw new Exception('Could not read links.xml');
 
-               self::removeNode($xml, $id1, $id2);
+               self::removeNode($xml, $id);
 
                if (file_put_contents('links.xml', $xml->asXML()) !== FALSE)
-                       return true;
+                       return $id;
                else
                        throw new Exception('Could not write links.xml');
     }
diff --git a/uifx/src/modules/gmap/data/LinksData.as 
b/uifx/src/modules/gmap/data/LinksData.as
index 5facae6..a065587 100644
--- a/uifx/src/modules/gmap/data/LinksData.as
+++ b/uifx/src/modules/gmap/data/LinksData.as
@@ -53,10 +53,10 @@ package modules.gmap.data
                        link.location2 = _locations.getItemById(link.id2);
                }
 
-               public function getItemByIds(id1 : String, id2 : String) : Link
+               public function getItemById(id : String) : Link
                {
                        for each(var link : Link in this)
-                               if (link.id1 == id1 && link.id2 == id2)
+                               if (link.id == id)
                                        return link;
 
                        return null;
@@ -64,8 +64,8 @@ package modules.gmap.data
 
                public function addUpdateItem(item : Link) : void
                {
-                       trace(item.id1);
-                       var link : Link = this.getItemByIds(item.id1, item.id2);
+                       trace(item.id);
+                       var link : Link = this.getItemById(item.id);
 
                        if (link == null)
                        {
@@ -82,9 +82,9 @@ package modules.gmap.data
                                this.addUpdateItem(link);
                }
 
-               public function removeItemByIds(id1 : String, id2 : String) : 
void
+               public function removeItemById(id : String) : void
                {
-                       removeItemAt(getItemIndex(getItemByIds(id1, id2)));
+                       removeItemAt(getItemIndex(getItemById(id)));
                }
 
                public function virginize() : void
diff --git a/uifx/src/modules/gmap/domain/Link.as 
b/uifx/src/modules/gmap/domain/Link.as
index 729b3bb..5fdd47f 100644
--- a/uifx/src/modules/gmap/domain/Link.as
+++ b/uifx/src/modules/gmap/domain/Link.as
@@ -30,6 +30,8 @@ package modules.gmap.domain
                public static const STATE_WARNING : Number = 2;
                public static const STATE_ERROR : Number = 3;
 
+               public var id : String;
+
                public var id1 : String;
                public var location1 : Location;
 
@@ -43,6 +45,7 @@ package modules.gmap.domain
 
                public function update(value : Link) : void
                {
+                       this.id = value.id;
                        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 621356f..0582620 100644
--- a/uifx/src/modules/gmap/mate/LinksEM.mxml
+++ b/uifx/src/modules/gmap/mate/LinksEM.mxml
@@ -64,7 +64,7 @@
        <EventHandlers type="{LinkEvent.DELETE}">
                <RemoteObjectInvoker instance="{LinksService}" method="remove" 
arguments="{[event.link.id1, event.link.id2]}">
                        <resultHandlers>
-                               <MethodInvoker generator="{LinksData}" 
method="removeItemByIds" arguments="{[event.link.id1, event.link.id2]}"/>
+                               <MethodInvoker generator="{LinksData}" 
method="removeItemById" arguments="{resultObject}"/>
                                <EventAnnouncer generator="{LinkEvent}" 
constructorArguments="{LinkEvent.SELECTED}" />
                        </resultHandlers>
                </RemoteObjectInvoker>
diff --git a/uifx/src/modules/gmap/view/DialogLink.mxml 
b/uifx/src/modules/gmap/view/DialogLink.mxml
index a9fe8e4..959d464 100644
--- a/uifx/src/modules/gmap/view/DialogLink.mxml
+++ b/uifx/src/modules/gmap/view/DialogLink.mxml
@@ -73,7 +73,7 @@
                                                lnkLocation2.selectedItem = 
link.location2;
                                                lnkDescription.text = 
link.description;
 
-                                               if (link.id1 && link.id1.length 
> 0 && link.id2 && link.id2.length > 0)
+                                               if (link.id && link.id.length)
                                                {
                                                        addButton.visible = 
false;
                                                        saveButton.visible = 
true;
@@ -168,6 +168,7 @@
                        {
                                var ul : Link = new Link();
 
+                               ul.id = (_link)? _link.id : '';
                                ul.id1 = (_link)? _link.id1 : 
lnkLocation1.selectedItem.id;
                                ul.id2 = (_link)? _link.id2 : 
lnkLocation2.selectedItem.id;
                                ul.location1 = (_link)? _link.location1 : 
lnkLocation1.selectedItem as Location;
@@ -206,7 +207,7 @@
 
                        private function onSaveClicked() : void
                        {
-                               if (_link && _link.id1 && _link.id1.length > 0 
&& _link.id2 && _link.id2.length > 0)
+                               if (_link && _link.id && _link.id.length > 0)
                                {
                                        dispatchEvent(new 
LinkEvent(LinkEvent.SAVE, getUpdatedLink()));
                                }


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