blob: 4cd4df0e31293df879c4bbb552de98d9cdbb84ca [file] [log] [blame]
Simon Hunt84f4c2a2015-09-23 17:52:45 -07001#set( $symbol_pound = '#' )
2#set( $symbol_dollar = '$' )
3#set( $symbol_escape = '\' )
4/*
5 * Copyright 2014,2015 Open Networking Laboratory
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19package ${package};
20
21import com.google.common.collect.ImmutableList;
22import org.apache.felix.scr.annotations.Activate;
23import org.apache.felix.scr.annotations.Component;
24import org.apache.felix.scr.annotations.Deactivate;
25import org.apache.felix.scr.annotations.Reference;
26import org.apache.felix.scr.annotations.ReferenceCardinality;
27import org.onosproject.ui.UiExtension;
28import org.onosproject.ui.UiExtensionService;
29import org.onosproject.ui.UiMessageHandlerFactory;
30import org.onosproject.ui.UiView;
31import org.slf4j.Logger;
32import org.slf4j.LoggerFactory;
33
34import java.util.List;
35
36/**
37 * Skeletal ONOS UI Table-View application component.
38 */
39@Component(immediate = true)
Thomas Vachuska2b0fc462015-09-28 12:04:06 -070040public class AppUiTableComponent {
Simon Hunt84f4c2a2015-09-23 17:52:45 -070041
42 private final Logger log = LoggerFactory.getLogger(getClass());
43
44 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
45 protected UiExtensionService uiExtensionService;
46
47 // List of application views
48 private final List<UiView> uiViews = ImmutableList.of(
49 new UiView(UiView.Category.OTHER, "sampleTable", "Sample Table")
50 );
51
52 // Factory for UI message handlers
53 private final UiMessageHandlerFactory messageHandlerFactory =
54 () -> ImmutableList.of(
Thomas Vachuska2b0fc462015-09-28 12:04:06 -070055 new AppUiTableMessageHandler()
Simon Hunt84f4c2a2015-09-23 17:52:45 -070056 );
57
58 // Application UI extension
59 protected UiExtension extension =
60 new UiExtension.Builder(getClass().getClassLoader(), uiViews)
Thomas Vachuska2b0fc462015-09-28 12:04:06 -070061 .resourcePath("sampleTable")
Simon Hunt84f4c2a2015-09-23 17:52:45 -070062 .messageHandlerFactory(messageHandlerFactory)
63 .build();
64
65 @Activate
66 protected void activate() {
67 uiExtensionService.register(extension);
68 log.info("Started");
69 }
70
71 @Deactivate
72 protected void deactivate() {
73 uiExtensionService.unregister(extension);
74 log.info("Stopped");
75 }
76
77}