blob: 927de45bcb1c15a33f2662aed69f052f4a5f06b3 [file] [log] [blame]
kmcpeakeb172d5f2015-12-10 11:30:43 +00001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
kmcpeakeb172d5f2015-12-10 11:30:43 +00003 *
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.faultmanagement.alarms.gui;
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;
27import org.onosproject.ui.UiView;
28import org.slf4j.Logger;
29import org.slf4j.LoggerFactory;
30
31import java.util.List;
32
33/**
34 * Skeletal ONOS UI Table-View application component.
35 */
36@Component(immediate = true)
37public class AlarmTableComponent {
38
39 private static final String VIEW_ID = "alarmTable";
40 private static final String VIEW_TEXT = "Alarms";
Simon Hunt0b41d292016-02-02 15:07:57 -080041 // note: we register the alarm icon->glyph mapping in alarmTable.js
42 private static final String ICON_ID = "nav_alarms";
kmcpeakeb172d5f2015-12-10 11:30:43 +000043
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 Hunt0b41d292016-02-02 15:07:57 -080051 new UiView(UiView.Category.OTHER, VIEW_ID, VIEW_TEXT, ICON_ID)
kmcpeakeb172d5f2015-12-10 11:30:43 +000052 );
53
54 // Factory for UI message handlers
55 private final UiMessageHandlerFactory messageHandlerFactory =
56 () -> ImmutableList.of(
57 new AlarmTableMessageHandler()
58 );
59
60 // Application UI extension
61 protected UiExtension extension =
62 new UiExtension.Builder(getClass().getClassLoader(), uiViews)
63 .resourcePath(VIEW_ID)
64 .messageHandlerFactory(messageHandlerFactory)
65 .build();
66
67 @Activate
68 protected void activate() {
69 uiExtensionService.register(extension);
70 log.info("Started");
71 }
72
73 @Deactivate
74 protected void deactivate() {
75 uiExtensionService.unregister(extension);
76 log.info("Stopped");
77 }
78
79}