Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
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 | de99e0b | 2015-10-23 18:54:06 -0700 | [diff] [blame] | 19 | import org.onosproject.net.DeviceId; |
| 20 | import org.onosproject.net.HostId; |
Simon Hunt | 5c1a938 | 2016-06-01 19:35:35 -0700 | [diff] [blame] | 21 | import org.onosproject.net.link.LinkEvent; |
Simon Hunt | 0af1ec3 | 2015-07-24 12:17:55 -0700 | [diff] [blame] | 22 | import org.onosproject.ui.topo.PropertyPanel; |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 23 | import org.slf4j.Logger; |
| 24 | import org.slf4j.LoggerFactory; |
| 25 | |
Simon Hunt | 5c1a938 | 2016-06-01 19:35:35 -0700 | [diff] [blame] | 26 | import java.util.Map; |
| 27 | |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 28 | /** |
| 29 | * Represents user interface topology view overlay. |
| 30 | */ |
| 31 | public class UiTopoOverlay { |
| 32 | |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 33 | /** |
| 34 | * Logger for this overlay. |
| 35 | */ |
| 36 | protected final Logger log = LoggerFactory.getLogger(getClass()); |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 37 | |
| 38 | private final String id; |
| 39 | |
Simon Hunt | d2862c3 | 2015-08-24 17:41:51 -0700 | [diff] [blame] | 40 | private boolean isActive = false; |
| 41 | |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 42 | /** |
| 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 Hunt | d2862c3 | 2015-08-24 17:41:51 -0700 | [diff] [blame] | 71 | isActive = true; |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Callback invoked when this overlay is deactivated. |
| 76 | */ |
| 77 | public void deactivate() { |
Simon Hunt | d2862c3 | 2015-08-24 17:41:51 -0700 | [diff] [blame] | 78 | 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 Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Callback invoked to destroy this instance by cleaning up any |
| 92 | * internal state ready for garbage collection. |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 93 | * This default implementation holds no state and does nothing. |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 94 | */ |
| 95 | public void destroy() { |
| 96 | } |
Simon Hunt | 0af1ec3 | 2015-07-24 12:17:55 -0700 | [diff] [blame] | 97 | |
| 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 Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 106 | |
| 107 | /** |
| 108 | * Callback to modify the contents of the details panel for |
| 109 | * a selected device. |
| 110 | * This default implementation does nothing. |
| 111 | * |
Simon Hunt | 5c1a938 | 2016-06-01 19:35:35 -0700 | [diff] [blame] | 112 | * @param pp property panel model of summary data |
Ray Milkey | e3026a4 | 2015-10-27 10:39:42 -0700 | [diff] [blame] | 113 | * @param deviceId device id |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 114 | */ |
Simon Hunt | de99e0b | 2015-10-23 18:54:06 -0700 | [diff] [blame] | 115 | public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) { |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 116 | } |
| 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 Hunt | 5c1a938 | 2016-06-01 19:35:35 -0700 | [diff] [blame] | 123 | * @param pp property panel model of summary data |
Ray Milkey | e3026a4 | 2015-10-27 10:39:42 -0700 | [diff] [blame] | 124 | * @param hostId host id |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 125 | */ |
Simon Hunt | de99e0b | 2015-10-23 18:54:06 -0700 | [diff] [blame] | 126 | public void modifyHostDetails(PropertyPanel pp, HostId hostId) { |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 127 | } |
Simon Hunt | 5c1a938 | 2016-06-01 19:35:35 -0700 | [diff] [blame] | 128 | |
| 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 Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 148 | } |