Skip to content

Package: DefaultMainScreenPresentationControl

DefaultMainScreenPresentationControl

nameinstructionbranchcomplexitylinemethod
DefaultMainScreenPresentationControl()
M: 15 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
afterPropertiesSet()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
destroy()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
initialize()
M: 22 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
lambda$new$0()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
onPowerOnNotification(PowerOnNotification)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * *********************************************************************************************************************
3: *
4: * blueMarine II: Semantic Media Centre
5: * http://tidalwave.it/projects/bluemarine2
6: *
7: * Copyright (C) 2015 - 2021 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/bluemarine2-src
23: * git clone https://github.com/tidalwave-it/bluemarine2-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.bluemarine2.ui.mainscreen.impl;
28:
29: import javax.annotation.Nonnull;
30: import javax.annotation.PostConstruct;
31: import javax.inject.Inject;
32: import java.util.Collection;
33: import org.springframework.beans.factory.ListableBeanFactory;
34: import it.tidalwave.util.annotation.VisibleForTesting;
35: import it.tidalwave.role.ui.Displayable;
36: import it.tidalwave.role.ui.UserAction;
37: import it.tidalwave.messagebus.annotation.ListensTo;
38: import it.tidalwave.messagebus.annotation.SimpleMessageSubscriber;
39: import it.tidalwave.bluemarine2.message.PowerOnNotification;
40: import it.tidalwave.bluemarine2.ui.commons.flowcontroller.FlowController;
41: import it.tidalwave.bluemarine2.ui.mainscreen.MainScreenPresentation;
42: import lombok.extern.slf4j.Slf4j;
43: import static java.util.Comparator.*;
44: import static java.util.stream.Collectors.*;
45:
46: /***********************************************************************************************************************
47: *
48: * The control of the {@link MainScreenPresentation}.
49: *
50: * @stereotype Control
51: *
52: * @author Fabrizio Giudici
53: *
54: **********************************************************************************************************************/
55: @SimpleMessageSubscriber @Slf4j
56: public class DefaultMainScreenPresentationControl
57: {
58: @Inject
59: private MainScreenPresentation presentation;
60:
61: @Inject
62: private FlowController flowController;
63:
64: @Inject
65: private ListableBeanFactory beanFactory;
66:
67: /*******************************************************************************************************************
68: *
69: * The action that powers off the application.
70: *
71: ******************************************************************************************************************/
72: // FIXME: this fails because flowController is not injected yet.
73: // private final UserAction powerOffAction = UserAction.of(flowController::powerOff,
74: // LocalizedDisplayable.fromBundle(getClass(), "powerOff"));
75: private final UserAction powerOffAction = UserAction.of(() -> flowController.powerOff(),
76: Displayable.fromBundle(getClass(), "powerOff"));
77:
78: /*******************************************************************************************************************
79: *
80: * Populates the Presentation with the main menu.
81: *
82: ******************************************************************************************************************/
83: @PostConstruct
84: @VisibleForTesting void initialize()
85: {
86: final Collection<UserAction> mainMenuActions = beanFactory.getBeansOfType(MainMenuItem.class)
87: .values()
88: .stream()
89: .sorted(comparing(MainMenuItem::getPriority))
90: .map(MainMenuItem::getAction)
91: .collect(toList());
92: presentation.bind(mainMenuActions, powerOffAction);
93: }
94:
95: /*******************************************************************************************************************
96: *
97: *
98: ******************************************************************************************************************/
99: @VisibleForTesting void onPowerOnNotification (@Nonnull @ListensTo final PowerOnNotification notification)
100: {
101: presentation.showUp();
102: }
103: }