Enhanced layout service and hooked-in the ui topo session.
Change-Id: I357143766deb3f0d697a3e7963a53968ccdf3bc8
diff --git a/core/api/src/main/java/org/onosproject/ui/UiConnection.java b/core/api/src/main/java/org/onosproject/ui/UiConnection.java
index ebe1ef7..4fb388d 100644
--- a/core/api/src/main/java/org/onosproject/ui/UiConnection.java
+++ b/core/api/src/main/java/org/onosproject/ui/UiConnection.java
@@ -16,6 +16,7 @@
package org.onosproject.ui;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onosproject.ui.model.topo.UiTopoLayout;
/**
* Abstraction of a user interface session connection.
@@ -30,6 +31,34 @@
String userName();
/**
+ * Returns the current layout context.
+ *
+ * @return current topology layout
+ */
+ UiTopoLayout currentLayout();
+
+ /**
+ * Changes the current layout context to the specified layout.
+ *
+ * @param topoLayout new topology layout context
+ */
+ void setCurrentLayout(UiTopoLayout topoLayout);
+
+ /**
+ * Returns the current view identifier.
+ *
+ * @return current view
+ */
+ String currentView();
+
+ /**
+ * Sets the currently selected view.
+ *
+ * @param viewId view identifier
+ */
+ void setCurrentView(String viewId);
+
+ /**
* Sends the specified JSON message to the user interface client.
*
* @param message message to send
diff --git a/core/api/src/main/java/org/onosproject/ui/UiTopoLayoutService.java b/core/api/src/main/java/org/onosproject/ui/UiTopoLayoutService.java
index 989c807..0f2c273 100644
--- a/core/api/src/main/java/org/onosproject/ui/UiTopoLayoutService.java
+++ b/core/api/src/main/java/org/onosproject/ui/UiTopoLayoutService.java
@@ -26,6 +26,14 @@
public interface UiTopoLayoutService {
/**
+ * Returns the top-level root layout, which always exists and cannot
+ * be removed or associated directly with a region.
+ *
+ * @return root topology layout
+ */
+ UiTopoLayout getRootLayout();
+
+ /**
* Returns the set of available layouts.
*
* @return set of available layouts
@@ -40,15 +48,23 @@
*/
boolean addLayout(UiTopoLayout layout);
-
/**
* Returns the layout with the specified identifier.
+ *
* @param layoutId layout identifier
* @return layout or null if no such layout is found
*/
UiTopoLayout getLayout(UiTopoLayoutId layoutId);
/**
+ * Returns the set of the child layouts of the specified layout.
+ *
+ * @param layoutId layout identifier
+ * @return set of child layouts; empty set if layout has no children
+ */
+ Set<UiTopoLayout> getChildren(UiTopoLayoutId layoutId);
+
+ /**
* Removes a layout from the system.
*
* @param layout the layout to remove
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiTopoLayout.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiTopoLayout.java
index 289bb8f..8b421c0 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiTopoLayout.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiTopoLayout.java
@@ -26,16 +26,19 @@
private final UiTopoLayoutId id;
private final Region region;
+ private final UiTopoLayoutId parent;
/**
* Created a new UI topology layout.
*
* @param id layout identifier
* @param region backing region
+ * @param parent identifier of the parent layout
*/
- public UiTopoLayout(UiTopoLayoutId id, Region region) {
+ public UiTopoLayout(UiTopoLayoutId id, Region region, UiTopoLayoutId parent) {
this.id = id;
this.region = region;
+ this.parent = parent;
}
/**
@@ -56,5 +59,14 @@
return region;
}
+ /**
+ * Returns the parent layout identifier.
+ *
+ * @return parent layout identifier
+ */
+ public UiTopoLayoutId parent() {
+ return parent;
+ }
+
// TODO: additional properties pertinent to the layout
}