blob: 2c96b00d35d8473b78b8db6f6cba64a4b106ba62 [file] [log] [blame]
Simon Huntcc035c52017-02-22 21:12:51 -08001/*
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
17package org.onosproject.yms.gui;
18
19import com.google.common.collect.ImmutableList;
20import org.apache.felix.scr.annotations.Activate;
21import org.apache.felix.scr.annotations.Component;
22import org.apache.felix.scr.annotations.Deactivate;
23import org.apache.felix.scr.annotations.Reference;
24import org.apache.felix.scr.annotations.ReferenceCardinality;
25import org.onosproject.ui.UiExtension;
26import org.onosproject.ui.UiExtensionService;
27import org.onosproject.ui.UiMessageHandlerFactory;
28import org.onosproject.ui.UiView;
29import org.slf4j.Logger;
30import org.slf4j.LoggerFactory;
31
32import java.util.List;
33
34import static org.onosproject.ui.UiView.Category;
35
36/**
37 * ONOS UI component for the Yang Models table view.
38 */
39@Component(immediate = true)
40public class YangModelUiComponent {
41
42 private static final ClassLoader CL =
43 YangModelUiComponent.class.getClassLoader();
44 private static final String VIEW_ID = "yangModel";
45 private static final String NAV_LABEL = "Yang Models";
46 private static final String NAV_ICON = "nav_yang";
47 private static final String HELP_URL =
48 "https://wiki.onosproject.org/display/ONOS/YANG+Models+in+ONOS";
49
50 private final Logger log = LoggerFactory.getLogger(getClass());
51
52 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
53 protected UiExtensionService uiExtensionService;
54
55 // List of application views
56 private final List<UiView> uiViews = ImmutableList.of(
57 new UiView(Category.PLATFORM, VIEW_ID, NAV_LABEL, NAV_ICON, HELP_URL)
58 );
59
60 // Factory for UI message handlers
61 private final UiMessageHandlerFactory msgHandlerFactory =
62 () -> ImmutableList.of(
63 new YangModelMessageHandler()
64 );
65
66 // Application UI Extension
67 private UiExtension extension =
68 new UiExtension.Builder(CL, uiViews)
69 .resourcePath(VIEW_ID)
70 .messageHandlerFactory(msgHandlerFactory)
71 .build();
72
73 @Activate
74 protected void activate() {
75 uiExtensionService.register(extension);
76 log.info("Started");
77 }
78
79 @Deactivate
80 protected void deactivate() {
81 uiExtensionService.unregister(extension);
82 log.info("Stopped");
83 }
84
85}