Simon Hunt | 22c35df | 2017-04-26 17:28:42 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Laboratory |
| 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> |
| 26 | * This base class does little more than provide a logger, an identifier, |
| 27 | * name, and glyph ID. |
| 28 | * Subclasses will probably want to override some or all of the base methods |
| 29 | * to do useful things during the life-cycle of the (topo-2) overlay. |
| 30 | */ |
| 31 | public class UiTopo2Overlay { |
| 32 | |
| 33 | private static final String DEFAULT_GLYPH_ID = "m_topo"; |
| 34 | |
| 35 | /** |
| 36 | * Logger for this overlay. |
| 37 | */ |
| 38 | protected final Logger log = LoggerFactory.getLogger(getClass()); |
| 39 | |
| 40 | private final String id; |
| 41 | private final String name; |
| 42 | |
| 43 | private boolean isActive = false; |
| 44 | |
| 45 | /** |
| 46 | * Creates a new user interface topology view overlay descriptor, with |
| 47 | * the given identifier and (human readable) name. |
| 48 | * |
| 49 | * @param id overlay identifier |
| 50 | * @param name overlay name |
| 51 | */ |
| 52 | public UiTopo2Overlay(String id, String name) { |
| 53 | this.id = id; |
| 54 | this.name = name; |
| 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 | * Returns the name for this overlay. |
| 68 | * |
| 69 | * @return the name |
| 70 | */ |
| 71 | public String name() { |
| 72 | return name; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Returns the glyph identifier to use in the toolbar. |
| 77 | * This implementation returns a default value. Subclasses may override |
| 78 | * this to provide the identity of a custom glyph. |
| 79 | * |
| 80 | * @return glyph ID |
| 81 | */ |
| 82 | public String glyphId() { |
| 83 | return DEFAULT_GLYPH_ID; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Callback invoked to initialize this overlay, soon after creation. |
| 88 | * This default implementation does nothing. |
| 89 | */ |
| 90 | public void init() { |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Callback invoked when this overlay is activated. |
| 95 | */ |
| 96 | public void activate() { |
| 97 | isActive = true; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Callback invoked when this overlay is deactivated. |
| 102 | */ |
| 103 | public void deactivate() { |
| 104 | isActive = false; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Returns true if this overlay is currently active. |
| 109 | * |
| 110 | * @return true if overlay active |
| 111 | */ |
| 112 | public boolean isActive() { |
| 113 | return isActive; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Callback invoked to destroy this instance by cleaning up any |
| 118 | * internal state ready for garbage collection. |
| 119 | * This default implementation holds no state and does nothing. |
| 120 | */ |
| 121 | public void destroy() { |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Callback invoked when the topology highlighting should be updated. |
| 126 | * It is the implementation's responsibility to update the Model |
| 127 | * Highlighter state. This implementation does nothing. |
| 128 | */ |
| 129 | public void highlightingCallback(/* ref to highlight model ? */) { |
| 130 | |
| 131 | } |
| 132 | } |