GUI2 Handle node additions and removals in Topology view
Change-Id: Ic16fc1325fe338e2136f1cc70febc621342be4f2
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiHost.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiHost.java
index 36375eb..5ca86e3 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiHost.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiHost.java
@@ -73,6 +73,16 @@
}
/**
+ * Returns the identifier of the region to which this device belongs.
+ * This will be null if the device does not belong to any region.
+ *
+ * @return region ID
+ */
+ public RegionId regionId() {
+ return regionId;
+ }
+
+ /**
* Sets the ID of the region to which this device belongs.
*
* @param regionId region identifier
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegion.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegion.java
index 74c8677..36629f2 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegion.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegion.java
@@ -40,6 +40,7 @@
private static final String NULL_NAME = "(root)";
private static final String NO_NAME = "???";
+ private static final String MEMO_ADDED = "added";
/**
* The identifier for the null-region. That is, a container for devices,
@@ -327,10 +328,24 @@
return true;
case REGION_ADDED_OR_UPDATED:
+ if (MEMO_ADDED.equalsIgnoreCase(event.memo()) &&
+ regionId.toString().equalsIgnoreCase(
+ ((UiRegion) event.subject()).backingRegion().toString())) {
+ return true;
+ } else {
+ return isDeviceRelevant(((UiDevice) event.subject()).id());
+ }
case REGION_REMOVED:
return isRegionRelevant(((UiRegion) event.subject()).id());
case DEVICE_ADDED_OR_UPDATED:
+ if (MEMO_ADDED.equalsIgnoreCase(event.memo()) &&
+ regionId.toString().equalsIgnoreCase(
+ ((UiDevice) event.subject()).regionId().toString())) {
+ return true;
+ } else {
+ return isDeviceRelevant(((UiDevice) event.subject()).id());
+ }
case DEVICE_REMOVED:
return isDeviceRelevant(((UiDevice) event.subject()).id());
@@ -339,6 +354,13 @@
return isLinkRelevant((UiLink) event.subject());
case HOST_ADDED_OR_UPDATED:
+ if (MEMO_ADDED.equalsIgnoreCase(event.memo()) &&
+ regionId.toString().equalsIgnoreCase(
+ ((UiHost) event.subject()).regionId().toString())) {
+ return true;
+ } else {
+ return isDeviceRelevant(((UiDevice) event.subject()).id());
+ }
case HOST_MOVED:
case HOST_REMOVED:
return isDeviceRelevant(((UiHost) event.subject()).locationDevice());