GUI -- Added category to the UiView abstraction.
Change-Id: I55fff4d242e8d6b8d8ce3d25e8f9355dc0ef976a
diff --git a/core/api/src/main/java/org/onosproject/ui/UiView.java b/core/api/src/main/java/org/onosproject/ui/UiView.java
index 2f2bc0e..6e3a1a2 100644
--- a/core/api/src/main/java/org/onosproject/ui/UiView.java
+++ b/core/api/src/main/java/org/onosproject/ui/UiView.java
@@ -24,21 +24,68 @@
*/
public class UiView {
+ /**
+ * Designates navigation menu category.
+ */
+ public enum Category {
+ /**
+ * Represents platform related views.
+ */
+ PLATFORM("Platform"),
+
+ /**
+ * Represents network-control related views.
+ */
+ NETWORK("Network"),
+
+ /**
+ * Represents miscellaneous views.
+ */
+ OTHER("Other");
+
+ private final String label;
+
+ Category(String label) {
+ this.label = label;
+ }
+
+ /**
+ * Returns display label for the category.
+ *
+ * @return display label
+ */
+ public String label() {
+ return label;
+ }
+ }
+
private final String id;
private final String label;
+ private final Category category;
/**
* Creates a new user interface view descriptor.
*
- * @param id view identifier
- * @param label view label
+ * @param category view category
+ * @param id view identifier
+ * @param label view label
*/
- public UiView(String id, String label) {
+ public UiView(Category category, String id, String label) {
+ this.category = category;
this.id = id;
this.label = label;
}
/**
+ * Returns the navigation category.
+ *
+ * @return navigation category
+ */
+ public Category category() {
+ return category;
+ }
+
+ /**
* Returns the view identifier.
*
* @return view id
@@ -76,6 +123,7 @@
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
+ .add("category", category)
.add("id", id)
.add("label", label)
.toString();
diff --git a/core/api/src/main/java/org/onosproject/ui/UiViewHidden.java b/core/api/src/main/java/org/onosproject/ui/UiViewHidden.java
index e1fc855..072404e 100644
--- a/core/api/src/main/java/org/onosproject/ui/UiViewHidden.java
+++ b/core/api/src/main/java/org/onosproject/ui/UiViewHidden.java
@@ -26,10 +26,10 @@
/**
* Creates a new user interface hidden view descriptor.
*
- * @param id view identifier
+ * @param id view identifier
*/
public UiViewHidden(String id) {
- super(id, null);
+ super(Category.OTHER, id, null);
}
@Override
diff --git a/core/api/src/test/java/org/onosproject/ui/UiExtensionTest.java b/core/api/src/test/java/org/onosproject/ui/UiExtensionTest.java
index 3bd9797..efc0261 100644
--- a/core/api/src/test/java/org/onosproject/ui/UiExtensionTest.java
+++ b/core/api/src/test/java/org/onosproject/ui/UiExtensionTest.java
@@ -22,6 +22,7 @@
import static com.google.common.io.ByteStreams.toByteArray;
import static org.junit.Assert.*;
+import static org.onosproject.ui.UiView.Category.OTHER;
/**
* Tests the default user interface extension descriptor.
@@ -30,26 +31,27 @@
@Test
public void basics() throws IOException {
- UiExtension ext = new UiExtension(ImmutableList.of(new UiView("foo", "Foo View")),
+ UiExtension ext = new UiExtension(ImmutableList.of(new UiView(OTHER, "foo", "Foo View")),
null,
getClass().getClassLoader());
String css = new String(toByteArray(ext.css()));
assertTrue("incorrect css stream", css.contains("foo-css"));
String js = new String(toByteArray(ext.js()));
assertTrue("incorrect js stream", js.contains("foo-js"));
- assertEquals("incorrect views stream", "foo", ext.views().get(0).id());
+ assertEquals("incorrect view id", "foo", ext.views().get(0).id());
+ assertEquals("incorrect view category", OTHER, ext.views().get(0).category());
assertNull("incorrect handler factory", ext.messageHandlerFactory());
}
@Test
public void withPath() throws IOException {
- UiExtension ext = new UiExtension(ImmutableList.of(new UiView("foo", "Foo View")),
+ UiExtension ext = new UiExtension(ImmutableList.of(new UiView(OTHER, "foo", "Foo View")),
null, "custom", getClass().getClassLoader());
String css = new String(toByteArray(ext.css()));
assertTrue("incorrect css stream", css.contains("custom-css"));
String js = new String(toByteArray(ext.js()));
assertTrue("incorrect js stream", js.contains("custom-js"));
- assertEquals("incorrect views stream", "foo", ext.views().get(0).id());
+ assertEquals("incorrect view id", "foo", ext.views().get(0).id());
assertNull("incorrect handler factory", ext.messageHandlerFactory());
}
}
\ No newline at end of file