1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.ui.admincentral;
35
36 import info.magnolia.context.Context;
37 import info.magnolia.event.EventBus;
38 import info.magnolia.objectfactory.Components;
39 import info.magnolia.ui.admincentral.shellapp.ShellAppController;
40 import info.magnolia.ui.admincentral.shellapp.applauncher.AppLauncherShellApp;
41 import info.magnolia.ui.admincentral.shellapp.favorites.FavoritesShellApp;
42 import info.magnolia.ui.admincentral.shellapp.pulse.PulseShellApp;
43 import info.magnolia.ui.admincentral.sticker.StickerView;
44 import info.magnolia.ui.admincentral.usermenu.UserMenuPresenter;
45 import info.magnolia.ui.api.app.AppController;
46 import info.magnolia.ui.api.app.launcherlayout.AppLauncherLayoutManager;
47 import info.magnolia.ui.api.event.AdmincentralEventBus;
48 import info.magnolia.ui.api.location.DefaultLocation;
49 import info.magnolia.ui.api.location.Location;
50 import info.magnolia.ui.api.location.LocationController;
51 import info.magnolia.ui.api.location.LocationHistoryHandler;
52 import info.magnolia.ui.api.shell.Shell;
53 import info.magnolia.ui.api.view.View;
54 import info.magnolia.ui.framework.app.DefaultLocationHistoryMapper;
55 import info.magnolia.ui.framework.message.MessagesManager;
56 import info.magnolia.ui.framework.shell.ShellImpl;
57
58 import javax.inject.Inject;
59 import javax.inject.Named;
60
61 import com.vaadin.ui.UI;
62
63
64
65
66 public class AdmincentralPresenter {
67
68 private final ShellImpl shell;
69
70 @Inject
71 public AdmincentralPresenter(final Shell shell, @Named(AdmincentralEventBus.NAME) final EventBus eventBus, final AppLauncherLayoutManager appLauncherLayoutManager, final LocationController locationController, final AppController appController, final ShellAppController shellAppController, MessagesManager messagesManager, UserMenuPresenter userMenu, StickerView stickerView, Context context) {
72 this.shell = (ShellImpl) shell;
73
74 shell.setUserMenu(userMenu.start());
75 shell.setStickerView(stickerView);
76
77 shellAppController.setViewport(this.shell.getShellAppViewport());
78 shellAppController.addShellApp("applauncher", AppLauncherShellApp.class);
79 shellAppController.addShellApp("pulse", PulseShellApp.class);
80 shellAppController.addShellApp("favorite", FavoritesShellApp.class);
81
82 appController.setViewport(this.shell.getAppViewport());
83
84 DefaultLocationHistoryMapper locationHistoryMapper = new DefaultLocationHistoryMapper(appLauncherLayoutManager, context);
85 LocationHistoryHandler locationHistoryHandler = new LocationHistoryHandler(locationHistoryMapper, shell);
86 locationHistoryHandler.register(locationController, eventBus, new DefaultLocation(Location.LOCATION_TYPE_SHELL_APP, "applauncher", "", ""));
87
88
89
90 UI.getCurrent().setErrorHandler(new AdmincentralErrorHandler(messagesManager));
91 }
92
93
94
95
96 @Deprecated
97 public AdmincentralPresenter(final Shell shell, @Named(AdmincentralEventBus.NAME) final EventBus eventBus, final AppLauncherLayoutManager appLauncherLayoutManager, final LocationController locationController, final AppController appController, final ShellAppController shellAppController, MessagesManager messagesManager, UserMenuPresenter userMenu, Context context) {
98 this(shell, eventBus, appLauncherLayoutManager, locationController, appController, shellAppController, messagesManager, userMenu, Components.getComponent(StickerView.class), context);
99 }
100
101 public View start() {
102 return shell::getMagnoliaShell;
103 }
104 }