Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 3 | * |
| 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 Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | package org.onosproject.ui; |
| 18 | |
Simon Hunt | a58d894 | 2017-08-11 12:51:14 -0700 | [diff] [blame] | 19 | import org.onosproject.net.ConnectPoint; |
Simon Hunt | de99e0b | 2015-10-23 18:54:06 -0700 | [diff] [blame] | 20 | import org.onosproject.net.DeviceId; |
| 21 | import org.onosproject.net.HostId; |
Simon Hunt | 5c1a938 | 2016-06-01 19:35:35 -0700 | [diff] [blame] | 22 | import org.onosproject.net.link.LinkEvent; |
Simon Hunt | 0af1ec3 | 2015-07-24 12:17:55 -0700 | [diff] [blame] | 23 | import org.onosproject.ui.topo.PropertyPanel; |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 24 | import org.slf4j.Logger; |
| 25 | import org.slf4j.LoggerFactory; |
| 26 | |
Simon Hunt | 5c1a938 | 2016-06-01 19:35:35 -0700 | [diff] [blame] | 27 | import java.util.Map; |
| 28 | |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 29 | /** |
| 30 | * Represents user interface topology view overlay. |
Simon Hunt | 8add9ee | 2016-09-20 17:05:07 -0700 | [diff] [blame] | 31 | * <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 Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 35 | */ |
| 36 | public class UiTopoOverlay { |
| 37 | |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 38 | /** |
| 39 | * Logger for this overlay. |
| 40 | */ |
| 41 | protected final Logger log = LoggerFactory.getLogger(getClass()); |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 42 | |
| 43 | private final String id; |
| 44 | |
Simon Hunt | d2862c3 | 2015-08-24 17:41:51 -0700 | [diff] [blame] | 45 | private boolean isActive = false; |
| 46 | |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 47 | /** |
Simon Hunt | 8add9ee | 2016-09-20 17:05:07 -0700 | [diff] [blame] | 48 | * Creates a new user interface topology view overlay descriptor, with |
| 49 | * the given identifier. |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 50 | * |
| 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 Hunt | d2862c3 | 2015-08-24 17:41:51 -0700 | [diff] [blame] | 77 | isActive = true; |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Callback invoked when this overlay is deactivated. |
| 82 | */ |
| 83 | public void deactivate() { |
Simon Hunt | d2862c3 | 2015-08-24 17:41:51 -0700 | [diff] [blame] | 84 | 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 Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Callback invoked to destroy this instance by cleaning up any |
| 98 | * internal state ready for garbage collection. |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 99 | * This default implementation holds no state and does nothing. |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 100 | */ |
| 101 | public void destroy() { |
| 102 | } |
Simon Hunt | 0af1ec3 | 2015-07-24 12:17:55 -0700 | [diff] [blame] | 103 | |
| 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 Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 112 | |
| 113 | /** |
| 114 | * Callback to modify the contents of the details panel for |
| 115 | * a selected device. |
| 116 | * This default implementation does nothing. |
| 117 | * |
Simon Hunt | a58d894 | 2017-08-11 12:51:14 -0700 | [diff] [blame] | 118 | * @param pp property panel model of device data |
Ray Milkey | e3026a4 | 2015-10-27 10:39:42 -0700 | [diff] [blame] | 119 | * @param deviceId device id |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 120 | */ |
Simon Hunt | de99e0b | 2015-10-23 18:54:06 -0700 | [diff] [blame] | 121 | public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) { |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 122 | } |
| 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 Hunt | a58d894 | 2017-08-11 12:51:14 -0700 | [diff] [blame] | 129 | * @param pp property panel model of host data |
Ray Milkey | e3026a4 | 2015-10-27 10:39:42 -0700 | [diff] [blame] | 130 | * @param hostId host id |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 131 | */ |
Simon Hunt | de99e0b | 2015-10-23 18:54:06 -0700 | [diff] [blame] | 132 | public void modifyHostDetails(PropertyPanel pp, HostId hostId) { |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 133 | } |
Simon Hunt | 5c1a938 | 2016-06-01 19:35:35 -0700 | [diff] [blame] | 134 | |
| 135 | /** |
Simon Hunt | a58d894 | 2017-08-11 12:51:14 -0700 | [diff] [blame] | 136 | * 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 Hunt | 5c1a938 | 2016-06-01 19:35:35 -0700 | [diff] [blame] | 171 | * Callback invoked when a link event is processed (e.g. 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 Hunt | a58d894 | 2017-08-11 12:51:14 -0700 | [diff] [blame] | 183 | * and is superceded by use of {@link #modifyEdgeLinkDetails} and |
| 184 | * {@link #modifyInfraLinkDetails}. |
Simon Hunt | 5c1a938 | 2016-06-01 19:35:35 -0700 | [diff] [blame] | 185 | */ |
| 186 | @Deprecated |
| 187 | public Map<String, String> additionalLinkData(LinkEvent event) { |
| 188 | return null; |
| 189 | } |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 190 | } |