ONOS-6327: Implement details panel for host view.
ONOS-6326: Add friendly names to hosts.
- PLENTY more YakShaving:
  * some cleanup of the device view handler
  * introduce navPath field to PropertyPanel
  * introduce "-" name annotation to represent "use default"
  * (and more...)

Change-Id: I2afc0f1f29c726b90e97e492527edde2d1345ece
diff --git a/core/api/src/main/java/org/onosproject/net/config/basics/BasicHostConfig.java b/core/api/src/main/java/org/onosproject/net/config/basics/BasicHostConfig.java
index 7b870b4..1a8db33 100644
--- a/core/api/src/main/java/org/onosproject/net/config/basics/BasicHostConfig.java
+++ b/core/api/src/main/java/org/onosproject/net/config/basics/BasicHostConfig.java
@@ -31,6 +31,7 @@
 
     private static final String IPS = "ips";
     private static final String LOCATIONS = "locations";
+    private static final String DASH = "-";
 
     @Override
     public boolean isValid() {
@@ -41,6 +42,17 @@
                 GRID_Y, GRID_Y, UI_TYPE, RACK_ADDRESS, OWNER, IPS, LOCATIONS);
     }
 
+    @Override
+    public String name() {
+        // NOTE:
+        // We don't want to default to host ID if friendly name is not set;
+        // (it isn't particularly friendly, e.g. "00:00:00:00:00:01/None").
+        // We'd prefer to clear the annotation, but if we pass null, then the
+        // value won't get set (see BasicElementOperator). So, instead we will
+        // return a DASH to signify "use the default friendly name".
+        return get(NAME, DASH);
+    }
+
     /**
      * Returns the location of the host.
      *
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 05565f7..b614ef4 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
@@ -33,6 +33,7 @@
     private String title;
     private String typeId;
     private String id;
+    private String navPath;
     private List<Prop> properties = new ArrayList<>();
     private List<ButtonId> buttons = new ArrayList<>();
 
@@ -40,7 +41,7 @@
      * Constructs a property panel model with the given title and
      * type identifier (icon to display).
      *
-     * @param title title text
+     * @param title  title text
      * @param typeId type (icon) ID
      */
     public PropertyPanel(String title, String typeId) {
@@ -67,6 +68,20 @@
     }
 
     /**
+     * Adds a navigation path field to the panel data, to be included in
+     * the returned JSON data to the client. This is typically used to
+     * configure the topology view with the appropriate navigation path for
+     * a hot-link to some other view.
+     *
+     * @param navPath the navigation path
+     * @return self for chaining
+     */
+    public PropertyPanel navPath(String navPath) {
+        this.navPath = navPath;
+        return this;
+    }
+
+    /**
      * Adds an ID field to the panel data, to be included in
      * the returned JSON data to the client.
      *
@@ -81,7 +96,7 @@
     /**
      * Adds a property to the panel data.
      *
-     * @param key property key
+     * @param key   property key
      * @param value property value
      * @return self, for chaining
      */
@@ -93,7 +108,7 @@
     /**
      * Adds a property to the panel data, using a decimal formatter.
      *
-     * @param key property key
+     * @param key   property key
      * @param value property value
      * @return self, for chaining
      */
@@ -105,7 +120,7 @@
     /**
      * Adds a property to the panel data, using a decimal formatter.
      *
-     * @param key property key
+     * @param key   property key
      * @param value property value
      * @return self, for chaining
      */
@@ -119,7 +134,7 @@
      * {@link Object#toString toString()} method is used to convert the
      * value to a string.
      *
-     * @param key property key
+     * @param key   property key
      * @param value property value
      * @return self, for chaining
      */
@@ -134,8 +149,8 @@
      * value to a string, from which the characters defined in the given
      * regular expression string are stripped.
      *
-     * @param key property key
-     * @param value property value
+     * @param key     property key
+     * @param value   property value
      * @param reStrip regexp characters to strip from value string
      * @return self, for chaining
      */
@@ -174,6 +189,15 @@
     }
 
     /**
+     * Returns the navigation path.
+     *
+     * @return the navigation path
+     */
+    public String navPath() {
+        return navPath;
+    }
+
+    /**
      * Returns the internal ID.
      *
      * @return the ID
@@ -235,7 +259,7 @@
     public PropertyPanel removeProps(String... keys) {
         Set<String> forRemoval = Sets.newHashSet(keys);
         List<Prop> toKeep = new ArrayList<>();
-        for (Prop p: properties) {
+        for (Prop p : properties) {
             if (!forRemoval.contains(p.key())) {
                 toKeep.add(p);
             }
@@ -274,7 +298,7 @@
     public PropertyPanel removeButtons(ButtonId... descriptors) {
         Set<ButtonId> forRemoval = Sets.newHashSet(descriptors);
         List<ButtonId> toKeep = new ArrayList<>();
-        for (ButtonId bd: buttons) {
+        for (ButtonId bd : buttons) {
             if (!forRemoval.contains(bd)) {
                 toKeep.add(bd);
             }
@@ -306,7 +330,7 @@
         /**
          * Constructs a property data value.
          *
-         * @param key property key
+         * @param key   property key
          * @param value property value
          */
         public Prop(String key, String value) {
diff --git a/core/api/src/main/java/org/onosproject/ui/topo/TopoJson.java b/core/api/src/main/java/org/onosproject/ui/topo/TopoJson.java
index 653b0f9..13e131d 100644
--- a/core/api/src/main/java/org/onosproject/ui/topo/TopoJson.java
+++ b/core/api/src/main/java/org/onosproject/ui/topo/TopoJson.java
@@ -47,6 +47,7 @@
 
     static final String TITLE = "title";
     static final String TYPE = "type";
+    static final String NAV_PATH = "navPath";
     static final String PROP_ORDER = "propOrder";
     static final String PROPS = "props";
     static final String BUTTONS = "buttons";
@@ -63,7 +64,8 @@
     }
 
     // non-instantiable
-    private TopoJson() { }
+    private TopoJson() {
+    }
 
     /**
      * Returns a formatted message ready to send to the topology view
@@ -179,6 +181,10 @@
                 .put(TYPE, pp.typeId())
                 .put(ID, pp.id());
 
+        if (pp.navPath() != null) {
+            result.put(NAV_PATH, pp.navPath());
+        }
+
         ObjectNode pnode = objectNode();
         ArrayNode porder = arrayNode();
         for (PropertyPanel.Prop p : pp.properties()) {