blob: 6d8b214132598d2a7c79118a513bc82a229b05a2 [file] [log] [blame]
Thomas Vachuskabbf10502015-12-09 13:41:58 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Thomas Vachuskabbf10502015-12-09 13:41:58 -08003 *
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 */
16package org.onosproject.drivermatrix;
17
18import com.google.common.collect.ImmutableList;
19import org.apache.felix.scr.annotations.Activate;
20import org.apache.felix.scr.annotations.Component;
21import org.apache.felix.scr.annotations.Deactivate;
22import org.apache.felix.scr.annotations.Reference;
23import org.apache.felix.scr.annotations.ReferenceCardinality;
24import org.onosproject.ui.UiExtension;
25import org.onosproject.ui.UiExtensionService;
26import org.onosproject.ui.UiMessageHandlerFactory;
Simon Hunt22c35df2017-04-26 17:28:42 -070027import org.onosproject.ui.UiTopo2OverlayFactory;
Thomas Vachuskabbf10502015-12-09 13:41:58 -080028import org.onosproject.ui.UiView;
29import org.slf4j.Logger;
30import org.slf4j.LoggerFactory;
31
32import java.util.List;
33
34/**
Thomas Vachuska72667382016-02-22 14:27:48 -080035 * Registers driver matrix view.
Thomas Vachuskabbf10502015-12-09 13:41:58 -080036 */
37@Component(immediate = true)
Thomas Vachuska72667382016-02-22 14:27:48 -080038public class DriverViewComponent {
Thomas Vachuskabbf10502015-12-09 13:41:58 -080039
40 private static final String VIEW_ID = "driverMatrix";
41 private static final String VIEW_TEXT = "Driver Matrix";
Simon Hunt24d0c5c2016-03-03 00:05:08 -080042 private static final String NAV_ICON = "nav_drivers";
Thomas Vachuskabbf10502015-12-09 13:41:58 -080043
44 private final Logger log = LoggerFactory.getLogger(getClass());
45
46 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
47 protected UiExtensionService uiExtensionService;
48
49 // List of application views
50 private final List<UiView> uiViews = ImmutableList.of(
Simon Hunt24d0c5c2016-03-03 00:05:08 -080051 new UiView(UiView.Category.PLATFORM, VIEW_ID, VIEW_TEXT, NAV_ICON)
Thomas Vachuskabbf10502015-12-09 13:41:58 -080052 );
53
54 // Factory for UI message handlers
55 private final UiMessageHandlerFactory messageHandlerFactory =
56 () -> ImmutableList.of(
Thomas Vachuska72667382016-02-22 14:27:48 -080057 new DriverViewMessageHandler()
Thomas Vachuskabbf10502015-12-09 13:41:58 -080058 );
59
Simon Hunt22c35df2017-04-26 17:28:42 -070060 // ++++ ====================================================== ++++
61 // ++++ Temporary code for testing the topology-2 overlay code ++++
62
63 private final UiTopo2OverlayFactory t2ovFactory =
64 () -> ImmutableList.of(
65 new TesterTopo2Overlay()
66 );
67
68 // ++++ ====================================================== ++++
69
Thomas Vachuskabbf10502015-12-09 13:41:58 -080070 // Application UI extension
71 protected UiExtension extension =
72 new UiExtension.Builder(getClass().getClassLoader(), uiViews)
73 .resourcePath(VIEW_ID)
74 .messageHandlerFactory(messageHandlerFactory)
Simon Hunt22c35df2017-04-26 17:28:42 -070075 .topo2OverlayFactory(t2ovFactory) // +++ TEMP +++
Thomas Vachuskabbf10502015-12-09 13:41:58 -080076 .build();
77
78 @Activate
79 protected void activate() {
80 uiExtensionService.register(extension);
81 log.info("Started");
82 }
83
84 @Deactivate
85 protected void deactivate() {
86 uiExtensionService.unregister(extension);
87 log.info("Stopped");
88 }
89
90}