Simon Hunt | 22c35df | 2017-04-26 17:28:42 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Simon Hunt | 22c35df | 2017-04-26 17:28:42 -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. |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | package org.onosproject.ui; |
| 19 | |
| 20 | import org.slf4j.Logger; |
| 21 | import org.slf4j.LoggerFactory; |
| 22 | |
| 23 | /** |
| 24 | * Represents a user interface topology-2 view overlay. |
| 25 | * <p> |
Simon Hunt | 6cc8645 | 2017-04-27 17:46:22 -0700 | [diff] [blame] | 26 | * This base class does little more than provide a logger and an identifier. |
| 27 | * <p> |
| 28 | * Subclasses will want to override some or all of the base methods |
Simon Hunt | 22c35df | 2017-04-26 17:28:42 -0700 | [diff] [blame] | 29 | * to do useful things during the life-cycle of the (topo-2) overlay. |
| 30 | */ |
| 31 | public class UiTopo2Overlay { |
| 32 | |
Simon Hunt | 22c35df | 2017-04-26 17:28:42 -0700 | [diff] [blame] | 33 | protected final Logger log = LoggerFactory.getLogger(getClass()); |
| 34 | |
| 35 | private final String id; |
Simon Hunt | 22c35df | 2017-04-26 17:28:42 -0700 | [diff] [blame] | 36 | |
| 37 | private boolean isActive = false; |
| 38 | |
| 39 | /** |
Simon Hunt | 6cc8645 | 2017-04-27 17:46:22 -0700 | [diff] [blame] | 40 | * Creates a new user interface topology view overlay descriptor with |
| 41 | * the given identifier. |
Simon Hunt | 22c35df | 2017-04-26 17:28:42 -0700 | [diff] [blame] | 42 | * |
| 43 | * @param id overlay identifier |
Simon Hunt | 22c35df | 2017-04-26 17:28:42 -0700 | [diff] [blame] | 44 | */ |
Simon Hunt | 6cc8645 | 2017-04-27 17:46:22 -0700 | [diff] [blame] | 45 | public UiTopo2Overlay(String id) { |
Simon Hunt | 22c35df | 2017-04-26 17:28:42 -0700 | [diff] [blame] | 46 | this.id = id; |
Simon Hunt | 22c35df | 2017-04-26 17:28:42 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Returns the identifier for this overlay. |
| 51 | * |
| 52 | * @return the identifier |
| 53 | */ |
| 54 | public String id() { |
| 55 | return id; |
| 56 | } |
| 57 | |
Simon Hunt | 6cc8645 | 2017-04-27 17:46:22 -0700 | [diff] [blame] | 58 | @Override |
| 59 | public String toString() { |
| 60 | return "UiTopo2Overlay{id=\"" + id + |
| 61 | "\", class=\"" + getClass().getSimpleName() + "\"}"; |
Simon Hunt | 22c35df | 2017-04-26 17:28:42 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Callback invoked to initialize this overlay, soon after creation. |
| 66 | * This default implementation does nothing. |
Simon Hunt | 6cc8645 | 2017-04-27 17:46:22 -0700 | [diff] [blame] | 67 | * Subclasses may choose to override this to set some initial state. |
Simon Hunt | 22c35df | 2017-04-26 17:28:42 -0700 | [diff] [blame] | 68 | */ |
| 69 | public void init() { |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Callback invoked when this overlay is activated. |
| 74 | */ |
| 75 | public void activate() { |
| 76 | isActive = true; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Callback invoked when this overlay is deactivated. |
| 81 | */ |
| 82 | public void deactivate() { |
| 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; |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Callback invoked to destroy this instance by cleaning up any |
| 97 | * internal state ready for garbage collection. |
| 98 | * This default implementation holds no state and does nothing. |
| 99 | */ |
| 100 | public void destroy() { |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Callback invoked when the topology highlighting should be updated. |
| 105 | * It is the implementation's responsibility to update the Model |
| 106 | * Highlighter state. This implementation does nothing. |
| 107 | */ |
| 108 | public void highlightingCallback(/* ref to highlight model ? */) { |
| 109 | |
| 110 | } |
| 111 | } |