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. |
Simon Hunt | 8add9ee | 2016-09-20 17:05:07 -0700 | [diff] [blame] | 30 | * <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 Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 34 | */ |
| 35 | public class UiTopoOverlay { |
| 36 | |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 37 | /** |
| 38 | * Logger for this overlay. |
| 39 | */ |
| 40 | protected final Logger log = LoggerFactory.getLogger(getClass()); |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 41 | |
| 42 | private final String id; |
| 43 | |
Simon Hunt | d2862c3 | 2015-08-24 17:41:51 -0700 | [diff] [blame] | 44 | private boolean isActive = false; |
| 45 | |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 46 | /** |
Simon Hunt | 8add9ee | 2016-09-20 17:05:07 -0700 | [diff] [blame] | 47 | * Creates a new user interface topology view overlay descriptor, with |
| 48 | * the given identifier. |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 49 | * |
| 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 Hunt | d2862c3 | 2015-08-24 17:41:51 -0700 | [diff] [blame] | 76 | isActive = true; |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Callback invoked when this overlay is deactivated. |
| 81 | */ |
| 82 | public void deactivate() { |
Simon Hunt | d2862c3 | 2015-08-24 17:41:51 -0700 | [diff] [blame] | 83 | 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 Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Callback invoked to destroy this instance by cleaning up any |
| 97 | * internal state ready for garbage collection. |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 98 | * This default implementation holds no state and does nothing. |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 99 | */ |
| 100 | public void destroy() { |
| 101 | } |
Simon Hunt | 0af1ec3 | 2015-07-24 12:17:55 -0700 | [diff] [blame] | 102 | |
| 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 Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 111 | |
| 112 | /** |
| 113 | * Callback to modify the contents of the details panel for |
| 114 | * a selected device. |
| 115 | * This default implementation does nothing. |
| 116 | * |
Simon Hunt | 5c1a938 | 2016-06-01 19:35:35 -0700 | [diff] [blame] | 117 | * @param pp property panel model of summary data |
Ray Milkey | e3026a4 | 2015-10-27 10:39:42 -0700 | [diff] [blame] | 118 | * @param deviceId device id |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 119 | */ |
Simon Hunt | de99e0b | 2015-10-23 18:54:06 -0700 | [diff] [blame] | 120 | public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) { |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 121 | } |
| 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 Hunt | 5c1a938 | 2016-06-01 19:35:35 -0700 | [diff] [blame] | 128 | * @param pp property panel model of summary data |
Ray Milkey | e3026a4 | 2015-10-27 10:39:42 -0700 | [diff] [blame] | 129 | * @param hostId host id |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 130 | */ |
Simon Hunt | de99e0b | 2015-10-23 18:54:06 -0700 | [diff] [blame] | 131 | public void modifyHostDetails(PropertyPanel pp, HostId hostId) { |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 132 | } |
Simon Hunt | 5c1a938 | 2016-06-01 19:35:35 -0700 | [diff] [blame] | 133 | |
| 134 | /** |
| 135 | * Callback invoked when a link event is processed (e.g. 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 Hunt | 8add9ee | 2016-09-20 17:05:07 -0700 | [diff] [blame] | 147 | * and expected to be replaced in the Ibis (1.8) release |
Simon Hunt | 5c1a938 | 2016-06-01 19:35:35 -0700 | [diff] [blame] | 148 | */ |
| 149 | @Deprecated |
| 150 | public Map<String, String> additionalLinkData(LinkEvent event) { |
| 151 | return null; |
| 152 | } |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 153 | } |