blob: 0d37685b7fcfae91117dc662c13b3acc827cef5d [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.
Simon Hunt8add9ee2016-09-20 17:05:07 -070030 * <p>
31 * This base class does little more than provide a logger and an identifier.
32 * Subclasses will probably want to override some or all of the base methods
33 * to do useful things during the life-cycle of the overlay.
Simon Hunte05cae42015-07-23 17:35:24 -070034 */
35public class UiTopoOverlay {
36
Simon Huntb745ca62015-07-28 15:37:11 -070037 /**
38 * Logger for this overlay.
39 */
40 protected final Logger log = LoggerFactory.getLogger(getClass());
Simon Hunte05cae42015-07-23 17:35:24 -070041
42 private final String id;
43
Simon Huntd2862c32015-08-24 17:41:51 -070044 private boolean isActive = false;
45
Simon Hunte05cae42015-07-23 17:35:24 -070046 /**
Simon Hunt8add9ee2016-09-20 17:05:07 -070047 * Creates a new user interface topology view overlay descriptor, with
48 * the given identifier.
Simon Hunte05cae42015-07-23 17:35:24 -070049 *
50 * @param id overlay identifier
51 */
52 public UiTopoOverlay(String id) {
53 this.id = id;
54 }
55
56 /**
57 * Returns the identifier for this overlay.
58 *
59 * @return the identifier
60 */
61 public String id() {
62 return id;
63 }
64
65 /**
66 * Callback invoked to initialize this overlay, soon after creation.
67 * This default implementation does nothing.
68 */
69 public void init() {
70 }
71
72 /**
73 * Callback invoked when this overlay is activated.
74 */
75 public void activate() {
Simon Huntd2862c32015-08-24 17:41:51 -070076 isActive = true;
Simon Hunte05cae42015-07-23 17:35:24 -070077 }
78
79 /**
80 * Callback invoked when this overlay is deactivated.
81 */
82 public void deactivate() {
Simon Huntd2862c32015-08-24 17:41:51 -070083 isActive = false;
84 }
85
86 /**
87 * Returns true if this overlay is currently active.
88 *
89 * @return true if overlay active
90 */
91 public boolean isActive() {
92 return isActive;
Simon Hunte05cae42015-07-23 17:35:24 -070093 }
94
95 /**
96 * Callback invoked to destroy this instance by cleaning up any
97 * internal state ready for garbage collection.
Simon Huntb745ca62015-07-28 15:37:11 -070098 * This default implementation holds no state and does nothing.
Simon Hunte05cae42015-07-23 17:35:24 -070099 */
100 public void destroy() {
101 }
Simon Hunt0af1ec32015-07-24 12:17:55 -0700102
103 /**
104 * Callback to modify the contents of the summary panel.
105 * This default implementation does nothing.
106 *
107 * @param pp property panel model of summary data
108 */
109 public void modifySummary(PropertyPanel pp) {
110 }
Simon Huntb745ca62015-07-28 15:37:11 -0700111
112 /**
113 * Callback to modify the contents of the details panel for
114 * a selected device.
115 * This default implementation does nothing.
116 *
Simon Hunt5c1a9382016-06-01 19:35:35 -0700117 * @param pp property panel model of summary data
Ray Milkeye3026a42015-10-27 10:39:42 -0700118 * @param deviceId device id
Simon Huntb745ca62015-07-28 15:37:11 -0700119 */
Simon Huntde99e0b2015-10-23 18:54:06 -0700120 public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
Simon Huntb745ca62015-07-28 15:37:11 -0700121 }
122
123 /**
124 * Callback to modify the contents of the details panel for
125 * a selected host.
126 * This default implementation does nothing.
127 *
Simon Hunt5c1a9382016-06-01 19:35:35 -0700128 * @param pp property panel model of summary data
Ray Milkeye3026a42015-10-27 10:39:42 -0700129 * @param hostId host id
Simon Huntb745ca62015-07-28 15:37:11 -0700130 */
Simon Huntde99e0b2015-10-23 18:54:06 -0700131 public void modifyHostDetails(PropertyPanel pp, HostId hostId) {
Simon Huntb745ca62015-07-28 15:37:11 -0700132 }
Simon Hunt5c1a9382016-06-01 19:35:35 -0700133
134 /**
135 * Callback invoked when a link event is processed (e.g.&nbsp;link added).
136 * A subclass may override this method to return a map of property
137 * key/value pairs to be included in the JSON event back to the client,
138 * so that those additional properties are available to be displayed as
139 * link details.
140 * <p>
141 * The default implementation returns {@code null}, that is, no additional
142 * properties to be added.
143 *
144 * @param event the link event
145 * @return map of additional key/value pairs to be added to the JSON event
146 * @deprecated this is a temporary addition for Goldeneye (1.6) release,
Simon Hunt8add9ee2016-09-20 17:05:07 -0700147 * and expected to be replaced in the Ibis (1.8) release
Simon Hunt5c1a9382016-06-01 19:35:35 -0700148 */
149 @Deprecated
150 public Map<String, String> additionalLinkData(LinkEvent event) {
151 return null;
152 }
Simon Hunte05cae42015-07-23 17:35:24 -0700153}