aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo')
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/AbstractHighlight.java74
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLink.java42
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLinkMap.java30
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLink.java103
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLinkMap.java89
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/ButtonId.java69
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/DeviceHighlight.java32
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Highlights.java189
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/HostHighlight.java32
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/LinkHighlight.java146
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Mod.java65
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeBadge.java220
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeHighlight.java53
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java251
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java370
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoConstants.java131
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoElementType.java24
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoJson.java182
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoUtils.java158
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/package-info.java21
20 files changed, 0 insertions, 2281 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/AbstractHighlight.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/AbstractHighlight.java
deleted file mode 100644
index d30ba2f6..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/AbstractHighlight.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Partial implementation of the highlighting to apply to topology
- * view elements.
- */
-public abstract class AbstractHighlight {
- private final TopoElementType type;
- private final String elementId;
- private boolean keepSubdued = false;
-
- /**
- * Constructs the highlight.
- *
- * @param type highlight element type
- * @param elementId element identifier
- */
- public AbstractHighlight(TopoElementType type, String elementId) {
- this.type = checkNotNull(type);
- this.elementId = checkNotNull(elementId);
- }
-
- /**
- * Sets a flag to tell the renderer to keep this element subdued.
- */
- public void keepSubdued() {
- keepSubdued = true;
- }
-
- /**
- * Returns the element type.
- *
- * @return element type
- */
- public TopoElementType type() {
- return type;
- }
-
- /**
- * Returns the element identifier.
- *
- * @return element identifier
- */
- public String elementId() {
- return elementId;
- }
-
- /**
- * Returns the subdued flag.
- *
- * @return subdued flag
- */
- public boolean subdued() {
- return keepSubdued;
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLink.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLink.java
deleted file mode 100644
index a40383b8..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLink.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-
-/**
- * A simple concrete implementation of a {@link BiLink}.
- * Note that this implementation does not generate any link highlights.
- */
-public class BaseLink extends BiLink {
-
- /**
- * Constructs a base link for the given key and initial link.
- *
- * @param key canonical key for this base link
- * @param link first link
- */
- public BaseLink(LinkKey key, Link link) {
- super(key, link);
- }
-
- @Override
- public LinkHighlight highlight(Enum<?> type) {
- return null;
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLinkMap.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLinkMap.java
deleted file mode 100644
index cc2cf4af..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLinkMap.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-
-/**
- * Collection of {@link BaseLink}s.
- */
-public class BaseLinkMap extends BiLinkMap<BaseLink> {
- @Override
- public BaseLink create(LinkKey key, Link link) {
- return new BaseLink(key, link);
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLink.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLink.java
deleted file mode 100644
index 1217faae..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLink.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Representation of a link and its inverse, as a partial implementation.
- * <p>
- * Subclasses will decide how to generate the link highlighting (coloring
- * and labeling) for the topology view.
- */
-public abstract class BiLink {
-
- private final LinkKey key;
- private final Link one;
- private Link two;
-
- /**
- * Constructs a bi-link for the given key and initial link. It is expected
- * that the caller will have used {@link TopoUtils#canonicalLinkKey(Link)}
- * to generate the key.
- *
- * @param key canonical key for this bi-link
- * @param link first link
- */
- public BiLink(LinkKey key, Link link) {
- this.key = checkNotNull(key);
- this.one = checkNotNull(link);
- }
-
- /**
- * Sets the second link for this bi-link.
- *
- * @param link second link
- */
- public void setOther(Link link) {
- this.two = checkNotNull(link);
- }
-
- /**
- * Returns the link identifier in the form expected on the Topology View
- * in the web client.
- *
- * @return link identifier
- */
- public String linkId() {
- return TopoUtils.compactLinkString(one);
- }
-
- /**
- * Returns the key for this bi-link.
- *
- * @return the key
- */
- public LinkKey key() {
- return key;
- }
-
- /**
- * Returns the first link in this bi-link.
- *
- * @return the first link
- */
- public Link one() {
- return one;
- }
-
- /**
- * Returns the second link in this bi-link.
- *
- * @return the second link
- */
- public Link two() {
- return two;
- }
-
- /**
- * Returns the link highlighting to use, based on this bi-link's current
- * state.
- *
- * @param type optional highlighting type parameter
- * @return link highlighting model
- */
- public abstract LinkHighlight highlight(Enum<?> type);
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLinkMap.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLinkMap.java
deleted file mode 100644
index 9a42e107..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLinkMap.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Represents a collection of {@link BiLink} concrete classes. These maps
- * are used to collate a set of unidirectional {@link Link}s into a smaller
- * set of bi-directional {@link BiLink} derivatives.
- * <p>
- * @param <B> the type of bi-link subclass
- */
-public abstract class BiLinkMap<B extends BiLink> {
-
- private final Map<LinkKey, B> map = new HashMap<>();
-
- /**
- * Creates a new instance of a bi-link. Concrete subclasses should
- * instantiate and return the appropriate bi-link subclass.
- *
- * @param key the link key
- * @param link the initial link
- * @return a new instance
- */
- protected abstract B create(LinkKey key, Link link);
-
- /**
- * Adds the given link to our collection, returning the corresponding
- * bi-link (creating one if needed necessary).
- *
- * @param link the link to add to the collection
- * @return the corresponding bi-link wrapper
- */
- public B add(Link link) {
- LinkKey key = TopoUtils.canonicalLinkKey(checkNotNull(link));
- B blink = map.get(key);
- if (blink == null) {
- // no bi-link yet exists for this link
- blink = create(key, link);
- map.put(key, blink);
- } else {
- // we have a bi-link for this link.
- if (!blink.one().equals(link)) {
- blink.setOther(link);
- }
- }
- return blink;
- }
-
- /**
- * Returns the bi-link instances in the collection.
- *
- * @return the bi-links in this map
- */
- public Collection<B> biLinks() {
- return map.values();
- }
-
- /**
- * Returns the number of bi-links in the collection.
- *
- * @return number of bi-links
- */
- public int size() {
- return map.size();
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/ButtonId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/ButtonId.java
deleted file mode 100644
index 05b7317d..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/ButtonId.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Designates the identity of a button on the topology view panels.
- */
-public class ButtonId {
-
- private final String id;
-
- /**
- * Creates a button ID with the given identifier.
- *
- * @param id identifier for the button
- */
- public ButtonId(String id) {
- this.id = id;
- }
-
- /**
- * Returns the identifier for this button.
- *
- * @return identifier
- */
- public String id() {
- return id;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("id", id()).toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- ButtonId that = (ButtonId) o;
- return id.equals(that.id);
- }
-
- @Override
- public int hashCode() {
- return id.hashCode();
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/DeviceHighlight.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/DeviceHighlight.java
deleted file mode 100644
index 0cc15475..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/DeviceHighlight.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-/**
- * Denotes the highlighting to be applied to a device.
- */
-public class DeviceHighlight extends NodeHighlight {
-
- /**
- * Constructs a device highlight entity.
- *
- * @param deviceId the device identifier
- */
- public DeviceHighlight(String deviceId) {
- super(TopoElementType.DEVICE, deviceId);
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Highlights.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Highlights.java
deleted file mode 100644
index 12d3b629..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Highlights.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Encapsulates highlights to be applied to the topology view, such as
- * highlighting links, displaying link labels, perhaps even decorating
- * nodes with badges, etc.
- */
-public class Highlights {
-
- private static final String EMPTY = "";
- private static final String MIN = "min";
- private static final String MAX = "max";
-
- /**
- * A notion of amount.
- */
- public enum Amount {
- ZERO(EMPTY),
- MINIMALLY(MIN),
- MAXIMALLY(MAX);
-
- private final String s;
- Amount(String str) {
- s = str;
- }
-
- @Override
- public String toString() {
- return s;
- }
- }
-
- private final Map<String, DeviceHighlight> devices = new HashMap<>();
- private final Map<String, HostHighlight> hosts = new HashMap<>();
- private final Map<String, LinkHighlight> links = new HashMap<>();
-
- private Amount subdueLevel = Amount.ZERO;
-
-
- /**
- * Adds highlighting information for a device.
- *
- * @param dh device highlight
- * @return self, for chaining
- */
- public Highlights add(DeviceHighlight dh) {
- devices.put(dh.elementId(), dh);
- return this;
- }
-
- /**
- * Adds highlighting information for a host.
- *
- * @param hh host highlight
- * @return self, for chaining
- */
- public Highlights add(HostHighlight hh) {
- hosts.put(hh.elementId(), hh);
- return this;
- }
-
- /**
- * Adds highlighting information for a link.
- *
- * @param lh link highlight
- * @return self, for chaining
- */
- public Highlights add(LinkHighlight lh) {
- links.put(lh.elementId(), lh);
- return this;
- }
-
- /**
- * Marks the amount by which all other elements (devices, hosts, links)
- * not explicitly referenced here will be "subdued" visually.
- *
- * @param amount amount to subdue other elements
- * @return self, for chaining
- */
- public Highlights subdueAllElse(Amount amount) {
- subdueLevel = checkNotNull(amount);
- return this;
- }
-
- /**
- * Returns the collection of device highlights.
- *
- * @return device highlights
- */
- public Collection<DeviceHighlight> devices() {
- return Collections.unmodifiableCollection(devices.values());
- }
-
- /**
- * Returns the collection of host highlights.
- *
- * @return host highlights
- */
- public Collection<HostHighlight> hosts() {
- return Collections.unmodifiableCollection(hosts.values());
- }
-
- /**
- * Returns the collection of link highlights.
- *
- * @return link highlights
- */
- public Collection<LinkHighlight> links() {
- return Collections.unmodifiableCollection(links.values());
- }
-
- /**
- * Returns the amount by which all other elements not explicitly
- * referenced here should be "subdued".
- *
- * @return amount to subdue other elements
- */
- public Amount subdueLevel() {
- return subdueLevel;
- }
-
- /**
- * Returns the node highlight (device or host) for the given element
- * identifier, or null if no match.
- *
- * @param id element identifier
- * @return corresponding node highlight
- */
- public NodeHighlight getNode(String id) {
- NodeHighlight nh = devices.get(id);
- return nh != null ? nh : hosts.get(id);
- }
-
- /**
- * Returns the device highlight for the given device identifier,
- * or null if no match.
- *
- * @param id device identifier
- * @return corresponding device highlight
- */
- public DeviceHighlight getDevice(String id) {
- return devices.get(id);
- }
-
- /**
- * Returns the host highlight for the given host identifier,
- * or null if no match.
- *
- * @param id host identifier
- * @return corresponding host highlight
- */
- public HostHighlight getHost(String id) {
- return hosts.get(id);
- }
-
- /**
- * Returns the link highlight for the given link identifier,
- * or null if no match.
- *
- * @param id link identifier
- * @return corresponding link highlight
- */
- public LinkHighlight getLink(String id) {
- return links.get(id);
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/HostHighlight.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/HostHighlight.java
deleted file mode 100644
index 48959496..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/HostHighlight.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-/**
- * Denotes the highlighting to apply to a host.
- */
-public class HostHighlight extends NodeHighlight {
-
- public HostHighlight(String hostId) {
- super(TopoElementType.HOST, hostId);
- }
-
- // TODO: implement host highlighting:
- // - visual highlight
- // - badging
-
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/LinkHighlight.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/LinkHighlight.java
deleted file mode 100644
index a734c6b7..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/LinkHighlight.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-import java.util.Collections;
-import java.util.Set;
-import java.util.TreeSet;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Denotes the highlighting to be applied to a link.
- * {@link Flavor} is a closed set of NO-, PRIMARY-, or SECONDARY- highlighting.
- * {@link Mod} is an open ended set of additional modifications (CSS classes)
- * that may also be applied.
- * Note that {@link #MOD_OPTICAL} and {@link #MOD_ANIMATED} are pre-defined mods.
- * Label text may be set, which will also be displayed on the link.
- */
-public class LinkHighlight extends AbstractHighlight {
-
- private static final String PLAIN = "plain";
- private static final String PRIMARY = "primary";
- private static final String SECONDARY = "secondary";
- private static final String EMPTY = "";
- private static final String SPACE = " ";
-
- private final Flavor flavor;
- private final Set<Mod> mods = new TreeSet<>();
- private String label = EMPTY;
-
- /**
- * Constructs a link highlight entity.
- *
- * @param linkId the link identifier
- * @param flavor the highlight flavor
- */
- public LinkHighlight(String linkId, Flavor flavor) {
- super(TopoElementType.LINK, linkId);
- this.flavor = checkNotNull(flavor);
- }
-
- /**
- * Adds a highlighting modification to this link highlight.
- *
- * @param mod mod to be added
- * @return self, for chaining
- */
- public LinkHighlight addMod(Mod mod) {
- mods.add(checkNotNull(mod));
- return this;
- }
-
- /**
- * Adds a label to be displayed on the link.
- *
- * @param label the label text
- * @return self, for chaining
- */
- public LinkHighlight setLabel(String label) {
- this.label = label == null ? EMPTY : label;
- return this;
- }
-
- /**
- * Returns the highlight flavor.
- *
- * @return highlight flavor
- */
- public Flavor flavor() {
- return flavor;
- }
-
- /**
- * Returns the highlight modifications.
- *
- * @return highlight modifications
- */
- public Set<Mod> mods() {
- return Collections.unmodifiableSet(mods);
- }
-
- /**
- * Generates the CSS classes string from the {@link #flavor} and
- * any optional {@link #mods}.
- *
- * @return CSS classes string
- */
- public String cssClasses() {
- StringBuilder sb = new StringBuilder(flavor.toString());
- mods.forEach(m -> sb.append(SPACE).append(m));
- return sb.toString();
- }
-
- /**
- * Returns the label text.
- *
- * @return label text
- */
- public String label() {
- return label;
- }
-
- /**
- * Link highlighting flavor.
- */
- public enum Flavor {
- NO_HIGHLIGHT(PLAIN),
- PRIMARY_HIGHLIGHT(PRIMARY),
- SECONDARY_HIGHLIGHT(SECONDARY);
-
- private String cssName;
-
- Flavor(String s) {
- cssName = s;
- }
-
- @Override
- public String toString() {
- return cssName;
- }
- }
-
- /**
- * Denotes a link to be tagged as an optical link.
- */
- public static final Mod MOD_OPTICAL = new Mod("optical");
-
- /**
- * Denotes a link to be tagged with animated traffic ("marching ants").
- */
- public static final Mod MOD_ANIMATED = new Mod("animated");
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Mod.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Mod.java
deleted file mode 100644
index b11ddecd..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Mod.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Highlighting modification.
- * <p>
- * Note that (for link highlights) this translates to a CSS class name
- * that is applied to the link in the Topology UI.
- */
-public final class Mod implements Comparable<Mod> {
- private final String modId;
-
- /**
- * Constructs a mod with the given identifier.
- *
- * @param modId modification identifier
- */
- public Mod(String modId) {
- this.modId = checkNotNull(modId);
- }
-
- @Override
- public String toString() {
- return modId;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- Mod mod = (Mod) o;
- return modId.equals(mod.modId);
- }
-
- @Override
- public int hashCode() {
- return modId.hashCode();
- }
-
- @Override
- public int compareTo(Mod o) {
- return this.modId.compareTo(o.modId);
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeBadge.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeBadge.java
deleted file mode 100644
index 4edb6712..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeBadge.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-/**
- * Designates a badge to be applied to a node in the topology view.
- */
-public final class NodeBadge {
-
- private static final String EMPTY = "";
-
- /** Designates the badge status. */
- public enum Status {
- INFO("i"),
- WARN("w"),
- ERROR("e");
-
- private String code;
-
- Status(String code) {
- this.code = code;
- }
-
- @Override
- public String toString() {
- return "{" + code + "}";
- }
-
- /* Returns the status code in string form. */
- public String code() {
- return code;
- }
- }
-
- private final Status status;
- private final boolean isGlyph;
- private final String text;
- private final String message;
-
- // only instantiated through static methods.
- private NodeBadge(Status status, boolean isGlyph, String text, String message) {
- this.status = status == null ? Status.INFO : status;
- this.isGlyph = isGlyph;
- this.text = text;
- this.message = message;
- }
-
- @Override
- public String toString() {
- return "{Badge " + status +
- " (" + text + ")" +
- (isGlyph ? "*G " : " ") +
- "\"" + message + "\"}";
- }
-
- /**
- * Returns the badge status.
- *
- * @return badge status
- */
- public Status status() {
- return status;
- }
-
- /**
- * Returns true if the text for this badge designates a glyph ID.
- *
- * @return true if badge uses glyph
- */
- public boolean isGlyph() {
- return isGlyph;
- }
-
- /**
- * Returns the text for the badge.
- * Note that if {@link #isGlyph} is true, the text is a glyph ID, otherwise
- * the text is displayed verbatim in the badge.
- *
- * @return text for badge
- */
- public String text() {
- return text;
- }
-
- /**
- * Returns the message associated with the badge.
- *
- * @return associated message
- */
- public String message() {
- return message;
- }
-
- private static String nonNull(String s) {
- return s == null ? EMPTY : s;
- }
-
- /**
- * Returns an arbitrary text badge, with default status.
- *
- * @param txt the text
- * @return node badge to display text
- */
- public static NodeBadge text(String txt) {
- // TODO: consider length constraint on txt (3 chars?)
- return new NodeBadge(Status.INFO, false, nonNull(txt), null);
- }
-
- /**
- * Returns a glyph badge, with default status.
- *
- * @param gid the glyph ID
- * @return node badge to display glyph
- */
- public static NodeBadge glyph(String gid) {
- return new NodeBadge(Status.INFO, true, nonNull(gid), null);
- }
-
- /**
- * Returns a numeric badge, with default status.
- *
- * @param n the number
- * @return node badge to display a number
- */
- public static NodeBadge number(int n) {
- // TODO: consider constraints, e.g. 1 <= n <= 999
- return new NodeBadge(Status.INFO, false, Integer.toString(n), null);
- }
-
- /**
- * Returns an arbitrary text badge, with the given status.
- *
- * @param s the status
- * @param txt the text
- * @return node badge to display text
- */
- public static NodeBadge text(Status s, String txt) {
- // TODO: consider length constraint on txt (3 chars?)
- return new NodeBadge(s, false, nonNull(txt), null);
- }
-
- /**
- * Returns a glyph badge, with the given status.
- *
- * @param s the status
- * @param gid the glyph ID
- * @return node badge to display glyph
- */
- public static NodeBadge glyph(Status s, String gid) {
- return new NodeBadge(s, true, nonNull(gid), null);
- }
-
-
- /**
- * Returns a numeric badge, with the given status and optional message.
- *
- * @param s the status
- * @param n the number
- * @return node badge to display a number
- */
- public static NodeBadge number(Status s, int n) {
- // TODO: consider constraints, e.g. 1 <= n <= 999
- return new NodeBadge(s, false, Integer.toString(n), null);
- }
-
- /**
- * Returns an arbitrary text badge, with the given status and optional
- * message.
- *
- * @param s the status
- * @param txt the text
- * @param msg the optional message
- * @return node badge to display text
- */
- public static NodeBadge text(Status s, String txt, String msg) {
- // TODO: consider length constraint on txt (3 chars?)
- return new NodeBadge(s, false, nonNull(txt), msg);
- }
-
- /**
- * Returns a glyph badge, with the given status and optional message.
- *
- * @param s the status
- * @param gid the glyph ID
- * @param msg the optional message
- * @return node badge to display glyph
- */
- public static NodeBadge glyph(Status s, String gid, String msg) {
- return new NodeBadge(s, true, nonNull(gid), msg);
- }
-
-
- /**
- * Returns a numeric badge, with the given status and optional message.
- *
- * @param s the status
- * @param n the number
- * @param msg the optional message
- * @return node badge to display a number
- */
- public static NodeBadge number(Status s, int n, String msg) {
- // TODO: consider constraints, e.g. 1 <= n <= 999
- return new NodeBadge(s, false, Integer.toString(n), msg);
- }
-
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeHighlight.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeHighlight.java
deleted file mode 100644
index 69235089..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeHighlight.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-/**
- * Parent class of {@link DeviceHighlight} and {@link HostHighlight}.
- */
-public abstract class NodeHighlight extends AbstractHighlight {
-
- private NodeBadge badge;
-
- /**
- * Constructs a node highlight entity.
- *
- * @param type element type
- * @param elementId element identifier
- */
- public NodeHighlight(TopoElementType type, String elementId) {
- super(type, elementId);
- }
-
- /**
- * Sets the badge for this node.
- *
- * @param badge badge to apply
- */
- public void setBadge(NodeBadge badge) {
- this.badge = badge;
- }
-
- /**
- * Returns the badge for this node, if any.
- *
- * @return badge, or null
- */
- public NodeBadge badge() {
- return badge;
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java
deleted file mode 100644
index 4aed9038..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.onosproject.net.Device;
-import org.onosproject.net.Element;
-import org.onosproject.net.Host;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.host.HostService;
-import org.onosproject.ui.JsonUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static org.onosproject.net.DeviceId.deviceId;
-import static org.onosproject.net.HostId.hostId;
-
-/**
- * Encapsulates a selection of devices and/or hosts from the topology view.
- */
-public class NodeSelection {
-
- private static final Logger log =
- LoggerFactory.getLogger(NodeSelection.class);
-
- private static final String IDS = "ids";
- private static final String HOVER = "hover";
-
- private final DeviceService deviceService;
- private final HostService hostService;
-
- private final Set<String> ids;
- private final String hover;
-
- private final Set<Device> devices = new HashSet<>();
- private final Set<Host> hosts = new HashSet<>();
- private Element hovered;
-
- /**
- * Creates a node selection entity, from the given payload, using the
- * supplied device and host services. Note that if a device or host was
- * hovered over by the mouse, it is available via {@link #hovered()}.
- *
- * @param payload message payload
- * @param deviceService device service
- * @param hostService host service
- */
- public NodeSelection(ObjectNode payload,
- DeviceService deviceService,
- HostService hostService) {
- this.deviceService = deviceService;
- this.hostService = hostService;
-
- ids = extractIds(payload);
- hover = extractHover(payload);
-
- // start by extracting the hovered element if any
- if (isNullOrEmpty(hover)) {
- hovered = null;
- } else {
- setHoveredElement();
- }
-
- // now go find the devices and hosts that are in the selection list
- Set<String> unmatched = findDevices(ids);
- unmatched = findHosts(unmatched);
- if (unmatched.size() > 0) {
- log.debug("Skipping unmatched IDs {}", unmatched);
- }
-
- }
-
- /**
- * Returns a view of the selected devices (hover not included).
- *
- * @return selected devices
- */
- public Set<Device> devices() {
- return Collections.unmodifiableSet(devices);
- }
-
- /**
- * Returns a view of the selected devices, including the hovered device
- * if there was one.
- *
- * @return selected (plus hovered) devices
- */
- public Set<Device> devicesWithHover() {
- Set<Device> withHover;
- if (hovered != null && hovered instanceof Device) {
- withHover = new HashSet<>(devices);
- withHover.add((Device) hovered);
- } else {
- withHover = devices;
- }
- return Collections.unmodifiableSet(withHover);
- }
-
- /**
- * Returns a view of the selected hosts (hover not included).
- *
- * @return selected hosts
- */
- public Set<Host> hosts() {
- return Collections.unmodifiableSet(hosts);
- }
-
- /**
- * Returns a view of the selected hosts, including the hovered host
- * if thee was one.
- *
- * @return selected (plus hovered) hosts
- */
- public Set<Host> hostsWithHover() {
- Set<Host> withHover;
- if (hovered != null && hovered instanceof Host) {
- withHover = new HashSet<>(hosts);
- withHover.add((Host) hovered);
- } else {
- withHover = hosts;
- }
- return Collections.unmodifiableSet(withHover);
- }
-
- /**
- * Returns the element (host or device) over which the mouse was hovering,
- * or null.
- *
- * @return element hovered over
- */
- public Element hovered() {
- return hovered;
- }
-
- /**
- * Returns true if nothing is selected.
- *
- * @return true if nothing selected
- */
- public boolean none() {
- return devices().size() == 0 && hosts().size() == 0;
- }
-
- @Override
- public String toString() {
- return "NodeSelection{" +
- "ids=" + ids +
- ", hover='" + hover + '\'' +
- ", #devices=" + devices.size() +
- ", #hosts=" + hosts.size() +
- '}';
- }
-
- // == helper methods
-
- private Set<String> extractIds(ObjectNode payload) {
- ArrayNode array = (ArrayNode) payload.path(IDS);
- if (array == null || array.size() == 0) {
- return Collections.emptySet();
- }
-
- Set<String> ids = new HashSet<>();
- for (JsonNode node : array) {
- ids.add(node.asText());
- }
- return ids;
- }
-
- private String extractHover(ObjectNode payload) {
- return JsonUtils.string(payload, HOVER);
- }
-
- private void setHoveredElement() {
- Set<String> unmatched;
- unmatched = new HashSet<>();
- unmatched.add(hover);
- unmatched = findDevices(unmatched);
- if (devices.size() == 1) {
- hovered = devices.iterator().next();
- devices.clear();
- } else {
- unmatched = findHosts(unmatched);
- if (hosts.size() == 1) {
- hovered = hosts.iterator().next();
- hosts.clear();
- } else {
- hovered = null;
- log.debug("Skipping unmatched HOVER {}", unmatched);
- }
- }
- }
-
- private Set<String> findDevices(Set<String> ids) {
- Set<String> unmatched = new HashSet<>();
- Device device;
-
- for (String id : ids) {
- try {
- device = deviceService.getDevice(deviceId(id));
- if (device != null) {
- devices.add(device);
- } else {
- unmatched.add(id);
- }
- } catch (Exception e) {
- unmatched.add(id);
- }
- }
- return unmatched;
- }
-
- private Set<String> findHosts(Set<String> ids) {
- Set<String> unmatched = new HashSet<>();
- Host host;
-
- for (String id : ids) {
- try {
- host = hostService.getHost(hostId(id));
- if (host != null) {
- hosts.add(host);
- } else {
- unmatched.add(id);
- }
- } catch (Exception e) {
- unmatched.add(id);
- }
- }
- return unmatched;
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java
deleted file mode 100644
index c75eccf9..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-import com.google.common.collect.Sets;
-
-import java.text.NumberFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Models a panel displayed on the Topology View.
- */
-public class PropertyPanel {
-
- private static final NumberFormat NF = NumberFormat.getInstance();
-
- private String title;
- private String typeId;
- private String id;
- private List<Prop> properties = new ArrayList<>();
- private List<ButtonId> buttons = new ArrayList<>();
-
- /**
- * Constructs a property panel model with the given title and
- * type identifier (icon to display).
- *
- * @param title title text
- * @param typeId type (icon) ID
- */
- public PropertyPanel(String title, String typeId) {
- this.title = title;
- this.typeId = typeId;
- }
-
- /**
- * Returns a number formatter to use for formatting integer and long
- * property values.
- * <p>
- * This default implementation uses a formatter for the default
- * locale. For example:
- * <pre>
- * Locale.ENGLISH : 1000 -&gt; "1,000"
- * Locale.FRENCH : 1000 -&gt; "1 000"
- * Locale.GERMAN : 1000 -&gt; "1.000"
- * </pre>
- *
- * @return the number formatter
- */
- protected NumberFormat formatter() {
- return NF;
- }
-
- /**
- * 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;
- }
-
- /**
- * Adds a property to the panel data.
- *
- * @param key property key
- * @param value property value
- * @return self, for chaining
- */
- public PropertyPanel addProp(String key, String value) {
- properties.add(new Prop(key, value));
- return this;
- }
-
- /**
- * Adds a property to the panel data, using a decimal formatter.
- *
- * @param key property key
- * @param value property value
- * @return self, for chaining
- */
- public PropertyPanel addProp(String key, int value) {
- properties.add(new Prop(key, formatter().format(value)));
- return this;
- }
-
- /**
- * Adds a property to the panel data, using a decimal formatter.
- *
- * @param key property key
- * @param value property value
- * @return self, for chaining
- */
- public PropertyPanel addProp(String key, long value) {
- properties.add(new Prop(key, formatter().format(value)));
- return this;
- }
-
- /**
- * Adds a property to the panel data. Note that the value's
- * {@link Object#toString toString()} method is used to convert the
- * value to a string.
- *
- * @param key property key
- * @param value property value
- * @return self, for chaining
- */
- public PropertyPanel addProp(String key, Object value) {
- properties.add(new Prop(key, value.toString()));
- return this;
- }
-
- /**
- * Adds a property to the panel data. Note that the value's
- * {@link Object#toString toString()} method is used to convert the
- * 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 reStrip regexp characters to strip from value string
- * @return self, for chaining
- */
- public PropertyPanel addProp(String key, Object value, String reStrip) {
- String val = value.toString().replaceAll(reStrip, "");
- properties.add(new Prop(key, val));
- return this;
- }
-
- /**
- * Adds a separator to the panel data.
- *
- * @return self, for chaining
- */
- public PropertyPanel addSeparator() {
- properties.add(new Separator());
- return this;
- }
-
- /**
- * Returns the title text.
- *
- * @return title text
- */
- public String title() {
- return title;
- }
-
- /**
- * Returns the type identifier.
- *
- * @return type identifier
- */
- public String typeId() {
- return typeId;
- }
-
- /**
- * Returns the internal ID.
- *
- * @return the ID
- */
- public String id() {
- return id;
- }
-
- /**
- * Returns the list of properties to be displayed.
- *
- * @return the property list
- */
- // TODO: consider protecting this?
- public List<Prop> properties() {
- return properties;
- }
-
- /**
- * Returns the list of button descriptors.
- *
- * @return the button list
- */
- // TODO: consider protecting this?
- public List<ButtonId> buttons() {
- return buttons;
- }
-
- // == MUTATORS
-
- /**
- * Sets the title text.
- *
- * @param title title text
- * @return self, for chaining
- */
- public PropertyPanel title(String title) {
- this.title = title;
- return this;
- }
-
- /**
- * Sets the type identifier (icon ID).
- *
- * @param typeId type identifier
- * @return self, for chaining
- */
- public PropertyPanel typeId(String typeId) {
- this.typeId = typeId;
- return this;
- }
-
- /**
- * Removes properties with the given keys from the list.
- *
- * @param keys keys of properties to remove
- * @return self, for chaining
- */
- public PropertyPanel removeProps(String... keys) {
- Set<String> forRemoval = Sets.newHashSet(keys);
- List<Prop> toKeep = new ArrayList<>();
- for (Prop p: properties) {
- if (!forRemoval.contains(p.key())) {
- toKeep.add(p);
- }
- }
- properties = toKeep;
- return this;
- }
-
- /**
- * Removes all currently defined properties.
- *
- * @return self, for chaining
- */
- public PropertyPanel removeAllProps() {
- properties.clear();
- return this;
- }
-
- /**
- * Adds the given button descriptor to the panel data.
- *
- * @param button button descriptor
- * @return self, for chaining
- */
- public PropertyPanel addButton(ButtonId button) {
- buttons.add(button);
- return this;
- }
-
- /**
- * Removes buttons with the given descriptors from the list.
- *
- * @param descriptors descriptors to remove
- * @return self, for chaining
- */
- public PropertyPanel removeButtons(ButtonId... descriptors) {
- Set<ButtonId> forRemoval = Sets.newHashSet(descriptors);
- List<ButtonId> toKeep = new ArrayList<>();
- for (ButtonId bd: buttons) {
- if (!forRemoval.contains(bd)) {
- toKeep.add(bd);
- }
- }
- buttons = toKeep;
- return this;
- }
-
- /**
- * Removes all currently defined buttons.
- *
- * @return self, for chaining
- */
- public PropertyPanel removeAllButtons() {
- buttons.clear();
- return this;
- }
-
- // ====================
-
-
- /**
- * Simple data carrier for a property, composed of a key/value pair.
- */
- public static class Prop {
- private final String key;
- private final String value;
-
- /**
- * Constructs a property data value.
- *
- * @param key property key
- * @param value property value
- */
- public Prop(String key, String value) {
- this.key = key;
- this.value = value;
- }
-
- /**
- * Returns the property's key.
- *
- * @return the key
- */
- public String key() {
- return key;
- }
-
- /**
- * Returns the property's value.
- *
- * @return the value
- */
- public String value() {
- return value;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- Prop prop = (Prop) o;
- return key.equals(prop.key) && value.equals(prop.value);
- }
-
- @Override
- public int hashCode() {
- int result = key.hashCode();
- result = 31 * result + value.hashCode();
- return result;
- }
-
- @Override
- public String toString() {
- return "{" + key + " -> " + value + "}";
- }
- }
-
- /**
- * Auxiliary class representing a separator property.
- */
- public static class Separator extends Prop {
- public Separator() {
- super("-", "");
- }
- }
-
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoConstants.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoConstants.java
deleted file mode 100644
index e2034fa7..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoConstants.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-/**
- * Defines string constants used in the Topology View of the ONOS GUI.
- * <p>
- * See also:
- * <ul>
- * <li> https://wiki.onosproject.org/display/ONOS/UI+Service+-+GlyphService </li>
- * </ul>
- */
-public final class TopoConstants {
-
- /**
- * Defines constants for standard glyph identifiers.
- */
- public static final class Glyphs {
- public static final String UNKNOWN = "unknown";
- public static final String BIRD = "bird";
- public static final String QUERY = "query";
- public static final String NODE = "node";
- public static final String SWITCH = "switch";
- public static final String ROADM = "roadm";
- public static final String ENDSTATION = "endstation";
- public static final String ROUTER = "router";
- public static final String BGP_SPEAKER = "bgpSpeaker";
- public static final String MICROWAVE = "microwave";
- public static final String CHAIN = "chain";
- public static final String CROWN = "crown";
- public static final String LOCK = "lock";
- public static final String TOPO = "topo";
- public static final String REFRESH = "refresh";
- public static final String GARBAGE = "garbage";
- public static final String FLOW_TABLE = "flowTable";
- public static final String PORT_TABLE = "portTable";
- public static final String GROUP_TABLE = "groupTable";
- public static final String SUMMARY = "summary";
- public static final String DETAILS = "details";
- public static final String PORTS = "ports";
- public static final String MAP = "map";
- public static final String CYCLE_LABELS = "cycleLabels";
- public static final String OBLIQUE = "oblique";
- public static final String FILTERS = "filters";
- public static final String RESET_ZOOM = "resetZoom";
- public static final String RELATED_INTENTS = "relatedIntents";
- public static final String NEXT_INTENT = "nextIntent";
- public static final String PREV_INTENT = "prevIntent";
- public static final String INTENT_TRAFFIC = "intentTraffic";
- public static final String ALL_TRAFFIC = "allTraffic";
- public static final String FLOWS = "flows";
- public static final String EQ_MASTER = "eqMaster";
- public static final String UI_ATTACHED = "uiAttached";
- public static final String CHECK_MARK = "checkMark";
- public static final String X_MARK = "xMark";
- public static final String TRIANGLE_UP = "triangleUp";
- public static final String TRIANGLE_DOWN = "triangleDown";
- public static final String PLUS = "plus";
- public static final String MINUS = "minus";
- public static final String PLAY = "play";
- public static final String STOP = "stop";
- public static final String CLOUD = "cloud";
- }
-
- /**
- * Defines constants for property names on the default summary and
- * details panels.
- */
- public static final class Properties {
- public static final String SEPARATOR = "-";
-
- // summary panel
- public static final String DEVICES = "Devices";
- public static final String LINKS = "Links";
- public static final String HOSTS = "Hosts";
- public static final String TOPOLOGY_SSCS = "Topology SCCs";
- public static final String INTENTS = "Intents";
- public static final String TUNNELS = "Tunnels";
- public static final String FLOWS = "Flows";
- public static final String VERSION = "Version";
-
- // device details
- public static final String URI = "URI";
- public static final String VENDOR = "Vendor";
- public static final String HW_VERSION = "H/W Version";
- public static final String SW_VERSION = "S/W Version";
- public static final String SERIAL_NUMBER = "Serial Number";
- public static final String PROTOCOL = "Protocol";
- public static final String LATITUDE = "Latitude";
- public static final String LONGITUDE = "Longitude";
- public static final String PORTS = "Ports";
-
- // host details
- public static final String MAC = "MAC";
- public static final String IP = "IP";
- public static final String VLAN = "VLAN";
- }
-
- /**
- * Defines identities of core buttons that appear on the topology
- * details panel.
- */
- public static final class CoreButtons {
- public static final ButtonId SHOW_DEVICE_VIEW =
- new ButtonId("showDeviceView");
-
- public static final ButtonId SHOW_FLOW_VIEW =
- new ButtonId("showFlowView");
-
- public static final ButtonId SHOW_PORT_VIEW =
- new ButtonId("showPortView");
-
- public static final ButtonId SHOW_GROUP_VIEW =
- new ButtonId("showGroupView");
- }
-
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoElementType.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoElementType.java
deleted file mode 100644
index 39947440..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoElementType.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-/**
- * The topology element types to which a highlight can be applied.
- */
-public enum TopoElementType {
- DEVICE, HOST, LINK
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoJson.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoJson.java
deleted file mode 100644
index efe69f5f..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoJson.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-import static org.onosproject.ui.JsonUtils.envelope;
-
-/**
- * JSON utilities for the Topology View.
- */
-public final class TopoJson {
- // package-private for unit test access
- static final String SHOW_HIGHLIGHTS = "showHighlights";
-
- static final String DEVICES = "devices";
- static final String HOSTS = "hosts";
- static final String LINKS = "links";
- static final String SUBDUE = "subdue";
-
- static final String ID = "id";
- static final String LABEL = "label";
- static final String CSS = "css";
- static final String BADGE = "badge";
- static final String STATUS = "status";
- static final String TXT = "txt";
- static final String GID = "gid";
- static final String MSG = "msg";
-
- static final String TITLE = "title";
- static final String TYPE = "type";
- static final String PROP_ORDER = "propOrder";
- static final String PROPS = "props";
- static final String BUTTONS = "buttons";
-
-
- private static final ObjectMapper MAPPER = new ObjectMapper();
-
- private static ObjectNode objectNode() {
- return MAPPER.createObjectNode();
- }
-
- private static ArrayNode arrayNode() {
- return MAPPER.createArrayNode();
- }
-
- // non-instantiable
- private TopoJson() { }
-
- /**
- * Returns a formatted message ready to send to the topology view
- * to render highlights.
- *
- * @param highlights highlights model to transform
- * @return fully formatted "show highlights" message
- */
- public static ObjectNode highlightsMessage(Highlights highlights) {
- return envelope(SHOW_HIGHLIGHTS, json(highlights));
- }
-
- /**
- * Transforms the given highlights model into a JSON message payload.
- *
- * @param highlights the model to transform
- * @return JSON payload
- */
- public static ObjectNode json(Highlights highlights) {
- ObjectNode payload = objectNode();
-
- ArrayNode devices = arrayNode();
- ArrayNode hosts = arrayNode();
- ArrayNode links = arrayNode();
-
- payload.set(DEVICES, devices);
- payload.set(HOSTS, hosts);
- payload.set(LINKS, links);
-
- highlights.devices().forEach(dh -> devices.add(json(dh)));
- highlights.hosts().forEach(hh -> hosts.add(json(hh)));
- highlights.links().forEach(lh -> links.add(json(lh)));
-
- Highlights.Amount toSubdue = highlights.subdueLevel();
- if (!toSubdue.equals(Highlights.Amount.ZERO)) {
- payload.put(SUBDUE, toSubdue.toString());
- }
- return payload;
- }
-
- private static ObjectNode json(NodeBadge b) {
- ObjectNode n = objectNode()
- .put(STATUS, b.status().code())
- .put(b.isGlyph() ? GID : TXT, b.text());
- if (b.message() != null) {
- n.put(MSG, b.message());
- }
- return n;
- }
-
- private static ObjectNode json(DeviceHighlight dh) {
- ObjectNode n = objectNode()
- .put(ID, dh.elementId());
- if (dh.subdued()) {
- n.put(SUBDUE, true);
- }
- NodeBadge badge = dh.badge();
- if (badge != null) {
- n.set(BADGE, json(badge));
- }
- return n;
- }
-
- private static ObjectNode json(HostHighlight hh) {
- ObjectNode n = objectNode()
- .put(ID, hh.elementId());
- if (hh.subdued()) {
- n.put(SUBDUE, true);
- }
- NodeBadge badge = hh.badge();
- if (badge != null) {
- n.set(BADGE, json(badge));
- }
- return n;
- }
-
- private static ObjectNode json(LinkHighlight lh) {
- ObjectNode n = objectNode()
- .put(ID, lh.elementId())
- .put(LABEL, lh.label())
- .put(CSS, lh.cssClasses());
- if (lh.subdued()) {
- n.put(SUBDUE, true);
- }
- return n;
- }
-
- /**
- * Translates the given property panel into JSON, for returning
- * to the client.
- *
- * @param pp the property panel model
- * @return JSON payload
- */
- public static ObjectNode json(PropertyPanel pp) {
- ObjectNode result = objectNode()
- .put(TITLE, pp.title())
- .put(TYPE, pp.typeId())
- .put(ID, pp.id());
-
- ObjectNode pnode = objectNode();
- ArrayNode porder = arrayNode();
- for (PropertyPanel.Prop p : pp.properties()) {
- porder.add(p.key());
- pnode.put(p.key(), p.value());
- }
- result.set(PROP_ORDER, porder);
- result.set(PROPS, pnode);
-
- ArrayNode buttons = arrayNode();
- for (ButtonId b : pp.buttons()) {
- buttons.add(b.id());
- }
- result.set(BUTTONS, buttons);
- return result;
- }
-
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoUtils.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoUtils.java
deleted file mode 100644
index b38a7f7d..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoUtils.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.topo;
-
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-
-import java.text.DecimalFormat;
-
-import static org.onosproject.net.LinkKey.linkKey;
-
-/**
- * Utility methods for helping out with formatting data for the Topology View
- * in the web client.
- */
-public final class TopoUtils {
-
- // explicit decision made to not 'javadoc' these self explanatory constants
- public static final double KILO = 1024;
- public static final double MEGA = 1024 * KILO;
- public static final double GIGA = 1024 * MEGA;
-
- public static final String GBITS_UNIT = "Gb";
- public static final String MBITS_UNIT = "Mb";
- public static final String KBITS_UNIT = "Kb";
- public static final String BITS_UNIT = "b";
- public static final String GBYTES_UNIT = "GB";
- public static final String MBYTES_UNIT = "MB";
- public static final String KBYTES_UNIT = "KB";
- public static final String BYTES_UNIT = "B";
-
-
- private static final DecimalFormat DF2 = new DecimalFormat("#,###.##");
-
- private static final String COMPACT = "%s/%s-%s/%s";
- private static final String EMPTY = "";
- private static final String SPACE = " ";
- private static final String PER_SEC = "ps";
- private static final String FLOW = "flow";
- private static final String FLOWS = "flows";
-
- // non-instantiable
- private TopoUtils() { }
-
- /**
- * Returns a compact identity for the given link, in the form
- * used to identify links in the Topology View on the client.
- *
- * @param link link
- * @return compact link identity
- */
- public static String compactLinkString(Link link) {
- return String.format(COMPACT, link.src().elementId(), link.src().port(),
- link.dst().elementId(), link.dst().port());
- }
-
- /**
- * Produces a canonical link key, that is, one that will match both a link
- * and its inverse.
- *
- * @param link the link
- * @return canonical key
- */
- public static LinkKey canonicalLinkKey(Link link) {
- String sn = link.src().elementId().toString();
- String dn = link.dst().elementId().toString();
- return sn.compareTo(dn) < 0 ?
- linkKey(link.src(), link.dst()) : linkKey(link.dst(), link.src());
- }
-
- /**
- * Returns human readable count of bytes, to be displayed as a label.
- *
- * @param bytes number of bytes
- * @return formatted byte count
- */
- public static String formatBytes(long bytes) {
- String unit;
- double value;
- if (bytes > GIGA) {
- value = bytes / GIGA;
- unit = GBYTES_UNIT;
- } else if (bytes > MEGA) {
- value = bytes / MEGA;
- unit = MBYTES_UNIT;
- } else if (bytes > KILO) {
- value = bytes / KILO;
- unit = KBYTES_UNIT;
- } else {
- value = bytes;
- unit = BYTES_UNIT;
- }
- return DF2.format(value) + SPACE + unit;
- }
-
- /**
- * Returns human readable bit rate, to be displayed as a label.
- *
- * @param bytes bytes per second
- * @return formatted bits per second
- */
- public static String formatBitRate(long bytes) {
- String unit;
- double value;
-
- //Convert to bits
- long bits = bytes * 8;
- if (bits > GIGA) {
- value = bits / GIGA;
- unit = GBITS_UNIT;
-
- // NOTE: temporary hack to clip rate at 10.0 Gbps
- // Added for the CORD Fabric demo at ONS 2015
- // TODO: provide a more elegant solution to this issue
- if (value > 10.0) {
- value = 10.0;
- }
-
- } else if (bits > MEGA) {
- value = bits / MEGA;
- unit = MBITS_UNIT;
- } else if (bits > KILO) {
- value = bits / KILO;
- unit = KBITS_UNIT;
- } else {
- value = bits;
- unit = BITS_UNIT;
- }
- return DF2.format(value) + SPACE + unit + PER_SEC;
- }
-
- /**
- * Returns human readable flow count, to be displayed as a label.
- *
- * @param flows number of flows
- * @return formatted flow count
- */
- public static String formatFlows(long flows) {
- if (flows < 1) {
- return EMPTY;
- }
- return String.valueOf(flows) + SPACE + (flows > 1 ? FLOWS : FLOW);
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/package-info.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/package-info.java
deleted file mode 100644
index 85ac7fea..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Mechanism for dynamically extending topology view with information and
- * behaviour overlays.
- */
-package org.onosproject.ui.topo; \ No newline at end of file