ONOS-1479 -- GUI - augmenting topology view for extensibility:
- Added id field to property panel, as well as overloaded constructors.
- Added modify*Details() methods to UiTopoOverlay.
- Cleaned up use of string constants.
- Reworked RequestDetails in Topo view msg handler (and base).
- Fixed bug in topo UI where selected host title click caused exception on server.
Change-Id: Ib2a3cf60fae8ad8cda77a3b6933ee758262e6f3c
diff --git a/core/api/src/main/java/org/onosproject/ui/JsonUtils.java b/core/api/src/main/java/org/onosproject/ui/JsonUtils.java
index 9d3054f..2ebb554 100644
--- a/core/api/src/main/java/org/onosproject/ui/JsonUtils.java
+++ b/core/api/src/main/java/org/onosproject/ui/JsonUtils.java
@@ -38,9 +38,7 @@
* @param sid sequence ID
* @param payload event payload
* @return the object node representation
- * @deprecated in Cardinal Release
*/
- @Deprecated
public static ObjectNode envelope(String type, long sid, ObjectNode payload) {
ObjectNode event = MAPPER.createObjectNode();
event.put("event", type);
diff --git a/core/api/src/main/java/org/onosproject/ui/UiTopoOverlay.java b/core/api/src/main/java/org/onosproject/ui/UiTopoOverlay.java
index a36d510..4c6d5d1 100644
--- a/core/api/src/main/java/org/onosproject/ui/UiTopoOverlay.java
+++ b/core/api/src/main/java/org/onosproject/ui/UiTopoOverlay.java
@@ -26,7 +26,10 @@
*/
public class UiTopoOverlay {
- private final Logger log = LoggerFactory.getLogger(getClass());
+ /**
+ * Logger for this overlay.
+ */
+ protected final Logger log = LoggerFactory.getLogger(getClass());
private final String id;
@@ -72,7 +75,7 @@
/**
* Callback invoked to destroy this instance by cleaning up any
* internal state ready for garbage collection.
- * This default implementation does nothing.
+ * This default implementation holds no state and does nothing.
*/
public void destroy() {
}
@@ -85,4 +88,24 @@
*/
public void modifySummary(PropertyPanel pp) {
}
+
+ /**
+ * Callback to modify the contents of the details panel for
+ * a selected device.
+ * This default implementation does nothing.
+ *
+ * @param pp property panel model of summary data
+ */
+ public void modifyDeviceDetails(PropertyPanel pp) {
+ }
+
+ /**
+ * Callback to modify the contents of the details panel for
+ * a selected host.
+ * This default implementation does nothing.
+ *
+ * @param pp property panel model of summary data
+ */
+ public void modifyHostDetails(PropertyPanel pp) {
+ }
}
diff --git a/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java b/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java
index 30b4ce7..88dad9a 100644
--- a/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java
+++ b/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java
@@ -19,6 +19,7 @@
import com.google.common.collect.Sets;
+import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -30,6 +31,7 @@
private String title;
private String typeId;
+ private String id;
private List<Prop> properties = new ArrayList<>();
/**
@@ -56,6 +58,19 @@
}
/**
+ * Adds an ID field to the panel data, to be included in
+ * the returned JSON data to the client.
+ *
+ * @param id the identifier
+ * @return self, for chaining
+ */
+ public PropertyPanel id(String id) {
+ this.id = id;
+ return this;
+ }
+
+
+ /**
* Returns the title text.
*
* @return title text
@@ -74,6 +89,15 @@
}
/**
+ * Returns the internal ID.
+ *
+ * @return the ID
+ */
+ public String id() {
+ return id;
+ }
+
+ /**
* Returns the list of properties to be displayed.
*
* @return the property list
@@ -137,6 +161,8 @@
// ====================
+ private static final DecimalFormat DF0 = new DecimalFormat("#,###");
+
/**
* Simple data carrier for a property, composed of a key/value pair.
*/
@@ -156,6 +182,26 @@
}
/**
+ * Constructs a property data value.
+ * @param key property key
+ * @param value property value
+ */
+ public Prop(String key, int value) {
+ this.key = key;
+ this.value = DF0.format(value);
+ }
+
+ /**
+ * Constructs a property data value.
+ * @param key property key
+ * @param value property value
+ */
+ public Prop(String key, long value) {
+ this.key = key;
+ this.value = DF0.format(value);
+ }
+
+ /**
* Returns the property's key.
*
* @return the key