blob: b598bdd26b46fdab0c263f5ff0598e2e4213f78d [file] [log] [blame]
Simon Hunte05cae42015-07-23 17:35:24 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Simon Hunte05cae42015-07-23 17:35:24 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
Simon Hunte05cae42015-07-23 17:35:24 -070015 */
16
17package org.onosproject.ui;
18
Simon Huntde99e0b2015-10-23 18:54:06 -070019import org.onosproject.net.DeviceId;
20import org.onosproject.net.HostId;
Simon Hunt5c1a9382016-06-01 19:35:35 -070021import org.onosproject.net.link.LinkEvent;
Simon Hunt0af1ec32015-07-24 12:17:55 -070022import org.onosproject.ui.topo.PropertyPanel;
Simon Hunte05cae42015-07-23 17:35:24 -070023import org.slf4j.Logger;
24import org.slf4j.LoggerFactory;
25
Simon Hunt5c1a9382016-06-01 19:35:35 -070026import java.util.Map;
27
Simon Hunte05cae42015-07-23 17:35:24 -070028/**
29 * Represents user interface topology view overlay.
30 */
31public class UiTopoOverlay {
32
Simon Huntb745ca62015-07-28 15:37:11 -070033 /**
34 * Logger for this overlay.
35 */
36 protected final Logger log = LoggerFactory.getLogger(getClass());
Simon Hunte05cae42015-07-23 17:35:24 -070037
38 private final String id;
39
Simon Huntd2862c32015-08-24 17:41:51 -070040 private boolean isActive = false;
41
Simon Hunte05cae42015-07-23 17:35:24 -070042 /**
43 * Creates a new user interface topology view overlay descriptor.
44 *
45 * @param id overlay identifier
46 */
47 public UiTopoOverlay(String id) {
48 this.id = id;
49 }
50
51 /**
52 * Returns the identifier for this overlay.
53 *
54 * @return the identifier
55 */
56 public String id() {
57 return id;
58 }
59
60 /**
61 * Callback invoked to initialize this overlay, soon after creation.
62 * This default implementation does nothing.
63 */
64 public void init() {
65 }
66
67 /**
68 * Callback invoked when this overlay is activated.
69 */
70 public void activate() {
Simon Huntd2862c32015-08-24 17:41:51 -070071 isActive = true;
Simon Hunte05cae42015-07-23 17:35:24 -070072 }
73
74 /**
75 * Callback invoked when this overlay is deactivated.
76 */
77 public void deactivate() {
Simon Huntd2862c32015-08-24 17:41:51 -070078 isActive = false;
79 }
80
81 /**
82 * Returns true if this overlay is currently active.
83 *
84 * @return true if overlay active
85 */
86 public boolean isActive() {
87 return isActive;
Simon Hunte05cae42015-07-23 17:35:24 -070088 }
89
90 /**
91 * Callback invoked to destroy this instance by cleaning up any
92 * internal state ready for garbage collection.
Simon Huntb745ca62015-07-28 15:37:11 -070093 * This default implementation holds no state and does nothing.
Simon Hunte05cae42015-07-23 17:35:24 -070094 */
95 public void destroy() {
96 }
Simon Hunt0af1ec32015-07-24 12:17:55 -070097
98 /**
99 * Callback to modify the contents of the summary panel.
100 * This default implementation does nothing.
101 *
102 * @param pp property panel model of summary data
103 */
104 public void modifySummary(PropertyPanel pp) {
105 }
Simon Huntb745ca62015-07-28 15:37:11 -0700106
107 /**
108 * Callback to modify the contents of the details panel for
109 * a selected device.
110 * This default implementation does nothing.
111 *
Simon Hunt5c1a9382016-06-01 19:35:35 -0700112 * @param pp property panel model of summary data
Ray Milkeye3026a42015-10-27 10:39:42 -0700113 * @param deviceId device id
Simon Huntb745ca62015-07-28 15:37:11 -0700114 */
Simon Huntde99e0b2015-10-23 18:54:06 -0700115 public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
Simon Huntb745ca62015-07-28 15:37:11 -0700116 }
117
118 /**
119 * Callback to modify the contents of the details panel for
120 * a selected host.
121 * This default implementation does nothing.
122 *
Simon Hunt5c1a9382016-06-01 19:35:35 -0700123 * @param pp property panel model of summary data
Ray Milkeye3026a42015-10-27 10:39:42 -0700124 * @param hostId host id
Simon Huntb745ca62015-07-28 15:37:11 -0700125 */
Simon Huntde99e0b2015-10-23 18:54:06 -0700126 public void modifyHostDetails(PropertyPanel pp, HostId hostId) {
Simon Huntb745ca62015-07-28 15:37:11 -0700127 }
Simon Hunt5c1a9382016-06-01 19:35:35 -0700128
129 /**
130 * Callback invoked when a link event is processed (e.g. link added).
131 * A subclass may override this method to return a map of property
132 * key/value pairs to be included in the JSON event back to the client,
133 * so that those additional properties are available to be displayed as
134 * link details.
135 * <p>
136 * The default implementation returns {@code null}, that is, no additional
137 * properties to be added.
138 *
139 * @param event the link event
140 * @return map of additional key/value pairs to be added to the JSON event
141 * @deprecated this is a temporary addition for Goldeneye (1.6) release,
142 * and expected to be replaced in the Hummingbird (1.7) release
143 */
144 @Deprecated
145 public Map<String, String> additionalLinkData(LinkEvent event) {
146 return null;
147 }
Simon Hunte05cae42015-07-23 17:35:24 -0700148}