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.ui.api.vaadin.ThemeDefinition;
37 import info.magnolia.ui.api.vaadin.WidgetsetDefinition;
38
39 import javax.inject.Inject;
40
41 import org.apache.commons.lang.StringUtils;
42
43 import com.vaadin.server.DefaultUIProvider;
44 import com.vaadin.server.UICreateEvent;
45
46
47
48
49 public class AdmincentralUIProvider extends DefaultUIProvider {
50
51 public static final String DEFAULT_WIDGETSET_NAME = "info.magnolia.ui.vaadin.gwt.MagnoliaWidgetSet";
52 public static final String DEFAULT_THEME_NAME = "admincentral";
53
54 private final WidgetsetDefinition widgetsetDefinition;
55 private final ThemeDefinition themeDefinition;
56
57 @Inject
58 public AdmincentralUIProvider(AdmincentralModule admincentralModule) {
59 this.widgetsetDefinition = admincentralModule.getWidgetset();
60 this.themeDefinition = admincentralModule.getTheme();
61 }
62
63 @Override
64 public String getWidgetset(UICreateEvent event) {
65 if (widgetsetDefinition != null) {
66 String widgetsetName = widgetsetDefinition.getName();
67 if (StringUtils.isNotBlank(widgetsetName)) {
68 return widgetsetName;
69 }
70 }
71 return DEFAULT_WIDGETSET_NAME;
72 }
73
74 @Override
75 public String getTheme(UICreateEvent event) {
76 if (themeDefinition != null) {
77 String themeName = themeDefinition.getName();
78 if (StringUtils.isNotBlank(themeName)) {
79 return themeName;
80 }
81 }
82 return DEFAULT_THEME_NAME;
83 }
84
85 }