ONOS-2582 : fix for reselecting previously selected nodes in the topology view.
Note that this also fixes the race condition with showing selected intent.

Change-Id: Icf3cd168bca985136d3ca6c63d98aa193a476d00
diff --git a/web/gui/src/main/webapp/app/view/topo/topoSelect.js b/web/gui/src/main/webapp/app/view/topo/topoSelect.js
index 8b554fb..77010df 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoSelect.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoSelect.js
@@ -23,7 +23,7 @@
     'use strict';
 
     // injected refs
-    var $log, fs, wss, tov, tps, tts, ns;
+    var $log, fs, wss, tov, tps, tts, ns, sus;
 
     // api to topoForce
     var api;
@@ -133,6 +133,14 @@
         updateDetail();
     }
 
+    function reselect() {
+        selectOrder.forEach(function (id) {
+            var sel = d3.select('g#' + sus.safeId(id));
+            sel.classed('selected', true);
+        });
+        updateDetail();
+    }
+
     function deselectObject(id) {
         var obj = selections[id];
         if (obj) {
@@ -280,8 +288,9 @@
     .factory('TopoSelectService',
         ['$log', 'FnService', 'WebSocketService', 'TopoOverlayService',
             'TopoPanelService', 'TopoTrafficService', 'NavService',
+            'SvgUtilService',
 
-        function (_$log_, _fs_, _wss_, _tov_, _tps_, _tts_, _ns_) {
+        function (_$log_, _fs_, _wss_, _tov_, _tps_, _tts_, _ns_, _sus_) {
             $log = _$log_;
             fs = _fs_;
             wss = _wss_;
@@ -289,10 +298,13 @@
             tps = _tps_;
             tts = _tts_;
             ns = _ns_;
+            sus = _sus_;
 
             function initSelect(_api_) {
                 api = _api_;
-                setInitialState();
+                if (!selections) {
+                    setInitialState();
+                }
             }
 
             function destroySelect() { }
@@ -315,7 +327,8 @@
                 somethingSelected: somethingSelected,
 
                 clickConsumed: clickConsumed,
-                selectionContext: selectionContext
+                selectionContext: selectionContext,
+                reselect: reselect
             };
         }]);
 }());