blob: c373bd34264ea508939e0a2ff681055b68c7cf96 [file] [log] [blame]
Simon Hunte05cae42015-07-23 17:35:24 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
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 Hunta58d8942017-08-11 12:51:14 -070019import org.onosproject.net.ConnectPoint;
Simon Huntde99e0b2015-10-23 18:54:06 -070020import org.onosproject.net.DeviceId;
21import org.onosproject.net.HostId;
Simon Hunt5c1a9382016-06-01 19:35:35 -070022import org.onosproject.net.link.LinkEvent;
Simon Hunt0af1ec32015-07-24 12:17:55 -070023import org.onosproject.ui.topo.PropertyPanel;
Simon Hunte05cae42015-07-23 17:35:24 -070024import org.slf4j.Logger;
25import org.slf4j.LoggerFactory;
26
Simon Hunt5c1a9382016-06-01 19:35:35 -070027import java.util.Map;
28
Simon Hunte05cae42015-07-23 17:35:24 -070029/**
30 * Represents user interface topology view overlay.
Simon Hunt8add9ee2016-09-20 17:05:07 -070031 * <p>
32 * This base class does little more than provide a logger and an identifier.
33 * Subclasses will probably want to override some or all of the base methods
34 * to do useful things during the life-cycle of the overlay.
Simon Hunte05cae42015-07-23 17:35:24 -070035 */
36public class UiTopoOverlay {
37
Simon Huntb745ca62015-07-28 15:37:11 -070038 /**
39 * Logger for this overlay.
40 */
41 protected final Logger log = LoggerFactory.getLogger(getClass());
Simon Hunte05cae42015-07-23 17:35:24 -070042
43 private final String id;
44
Simon Huntd2862c32015-08-24 17:41:51 -070045 private boolean isActive = false;
46
Simon Hunte05cae42015-07-23 17:35:24 -070047 /**
Simon Hunt8add9ee2016-09-20 17:05:07 -070048 * Creates a new user interface topology view overlay descriptor, with
49 * the given identifier.
Simon Hunte05cae42015-07-23 17:35:24 -070050 *
51 * @param id overlay identifier
52 */
53 public UiTopoOverlay(String id) {
54 this.id = id;
55 }
56
57 /**
58 * Returns the identifier for this overlay.
59 *
60 * @return the identifier
61 */
62 public String id() {
63 return id;
64 }
65
66 /**
67 * Callback invoked to initialize this overlay, soon after creation.
68 * This default implementation does nothing.
69 */
70 public void init() {
71 }
72
73 /**
74 * Callback invoked when this overlay is activated.
75 */
76 public void activate() {
Simon Huntd2862c32015-08-24 17:41:51 -070077 isActive = true;
Simon Hunte05cae42015-07-23 17:35:24 -070078 }
79
80 /**
81 * Callback invoked when this overlay is deactivated.
82 */
83 public void deactivate() {
Simon Huntd2862c32015-08-24 17:41:51 -070084 isActive = false;
85 }
86
87 /**
88 * Returns true if this overlay is currently active.
89 *
90 * @return true if overlay active
91 */
92 public boolean isActive() {
93 return isActive;
Simon Hunte05cae42015-07-23 17:35:24 -070094 }
95
96 /**
97 * Callback invoked to destroy this instance by cleaning up any
98 * internal state ready for garbage collection.
Simon Huntb745ca62015-07-28 15:37:11 -070099 * This default implementation holds no state and does nothing.
Simon Hunte05cae42015-07-23 17:35:24 -0700100 */
101 public void destroy() {
102 }
Simon Hunt0af1ec32015-07-24 12:17:55 -0700103
104 /**
105 * Callback to modify the contents of the summary panel.
106 * This default implementation does nothing.
107 *
108 * @param pp property panel model of summary data
109 */
110 public void modifySummary(PropertyPanel pp) {
111 }
Simon Huntb745ca62015-07-28 15:37:11 -0700112
113 /**
114 * Callback to modify the contents of the details panel for
115 * a selected device.
116 * This default implementation does nothing.
117 *
Simon Hunta58d8942017-08-11 12:51:14 -0700118 * @param pp property panel model of device data
Ray Milkeye3026a42015-10-27 10:39:42 -0700119 * @param deviceId device id
Simon Huntb745ca62015-07-28 15:37:11 -0700120 */
Simon Huntde99e0b2015-10-23 18:54:06 -0700121 public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
Simon Huntb745ca62015-07-28 15:37:11 -0700122 }
123
124 /**
125 * Callback to modify the contents of the details panel for
126 * a selected host.
127 * This default implementation does nothing.
128 *
Simon Hunta58d8942017-08-11 12:51:14 -0700129 * @param pp property panel model of host data
Ray Milkeye3026a42015-10-27 10:39:42 -0700130 * @param hostId host id
Simon Huntb745ca62015-07-28 15:37:11 -0700131 */
Simon Huntde99e0b2015-10-23 18:54:06 -0700132 public void modifyHostDetails(PropertyPanel pp, HostId hostId) {
Simon Huntb745ca62015-07-28 15:37:11 -0700133 }
Simon Hunt5c1a9382016-06-01 19:35:35 -0700134
135 /**
Simon Hunta58d8942017-08-11 12:51:14 -0700136 * Callback to modify the contents of the details panel for a selected
137 * edge link. The parameters include identifiers for the host and the
138 * connect point (device and port) to which the host is connected.
139 * <p>
140 * This default implementation does nothing.
141 *
142 * @param pp property panel model of edge link data
143 * @param hostId host ID
144 * @param cp connect point
145 */
146 public void modifyEdgeLinkDetails(PropertyPanel pp,
147 HostId hostId, ConnectPoint cp) {
148 }
149
150 /**
151 * Callback to modify the contents of the details panel for a selected
152 * infrastructure link. The parameters include the two connect points
153 * at either end of the link.
154 * <p>
155 * Note that links in the topology view are (usually) "bi-directional",
156 * meaning that both {@literal A-->B} and {@literal B-->A} backing links
157 * exist. If, however, there is only one backing link, it is guaranteed
158 * to be {@literal A-->B}.
159 * <p>
160 * This default implementation does nothing.
161 *
162 * @param pp property panel model of infrastructure link data
163 * @param cpA connect point A
164 * @param cpB connect point B
165 */
166 public void modifyInfraLinkDetails(PropertyPanel pp,
167 ConnectPoint cpA, ConnectPoint cpB) {
168 }
169
170 /**
Simon Hunt5c1a9382016-06-01 19:35:35 -0700171 * Callback invoked when a link event is processed (e.g.&nbsp;link added).
172 * A subclass may override this method to return a map of property
173 * key/value pairs to be included in the JSON event back to the client,
174 * so that those additional properties are available to be displayed as
175 * link details.
176 * <p>
177 * The default implementation returns {@code null}, that is, no additional
178 * properties to be added.
179 *
180 * @param event the link event
181 * @return map of additional key/value pairs to be added to the JSON event
182 * @deprecated this is a temporary addition for Goldeneye (1.6) release,
Simon Hunta58d8942017-08-11 12:51:14 -0700183 * and is superceded by use of {@link #modifyEdgeLinkDetails} and
184 * {@link #modifyInfraLinkDetails}.
Simon Hunt5c1a9382016-06-01 19:35:35 -0700185 */
186 @Deprecated
187 public Map<String, String> additionalLinkData(LinkEvent event) {
188 return null;
189 }
Simon Hunte05cae42015-07-23 17:35:24 -0700190}