1
|
/**
|
2
|
* Copyright (C) 2017 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.vaadin.ui;
|
10
|
|
11
|
import org.springframework.beans.factory.annotation.Autowired;
|
12
|
import org.springframework.context.ApplicationEventPublisher;
|
13
|
|
14
|
import com.vaadin.annotations.Theme;
|
15
|
import com.vaadin.annotations.Title;
|
16
|
import com.vaadin.annotations.Viewport;
|
17
|
import com.vaadin.annotations.Widgetset;
|
18
|
import com.vaadin.navigator.ViewDisplay;
|
19
|
import com.vaadin.server.ExternalResource;
|
20
|
import com.vaadin.server.FontAwesome;
|
21
|
import com.vaadin.server.Page;
|
22
|
import com.vaadin.server.Resource;
|
23
|
import com.vaadin.server.Responsive;
|
24
|
import com.vaadin.server.VaadinRequest;
|
25
|
import com.vaadin.spring.annotation.SpringUI;
|
26
|
import com.vaadin.spring.navigator.SpringViewProvider;
|
27
|
import com.vaadin.ui.Component;
|
28
|
import com.vaadin.ui.Label;
|
29
|
import com.vaadin.ui.UI;
|
30
|
import com.vaadin.ui.themes.ValoTheme;
|
31
|
|
32
|
import eu.etaxonomy.cdm.vaadin.view.LoginViewBean;
|
33
|
import eu.etaxonomy.cdm.vaadin.view.registration.DashBoardView;
|
34
|
import eu.etaxonomy.cdm.vaadin.view.registration.ListViewBean;
|
35
|
import eu.etaxonomy.cdm.vaadin.view.registration.StartRegistrationView;
|
36
|
import eu.etaxonomy.vaadin.ui.MainMenu;
|
37
|
import eu.etaxonomy.vaadin.ui.UIInitializedEvent;
|
38
|
import eu.etaxonomy.vaadin.ui.navigation.NavigationEvent;
|
39
|
|
40
|
/**
|
41
|
* @author a.kohlbecker
|
42
|
* @since Feb 24, 2017
|
43
|
*
|
44
|
*/
|
45
|
@Theme("edit-valo")
|
46
|
@Title("Registration")
|
47
|
@SpringUI(path="registration")
|
48
|
@Viewport("width=device-width, initial-scale=1")
|
49
|
@Widgetset("eu.etaxonomy.cdm.vaadin.AppWidgetSet")
|
50
|
// @PreserveOnRefresh
|
51
|
// @Push
|
52
|
public class RegistrationUI extends UI {
|
53
|
|
54
|
private static final long serialVersionUID = -8626236111335323691L;
|
55
|
|
56
|
@Autowired
|
57
|
private ViewDisplay viewDisplay;
|
58
|
|
59
|
//---- pull into abstract super class ? ---------
|
60
|
@Autowired
|
61
|
SpringViewProvider viewProvider;
|
62
|
|
63
|
protected void configureAccessDeniedView() {
|
64
|
viewProvider.setAccessDeniedViewClass(LoginViewBean.class);
|
65
|
}
|
66
|
//---------------------------------------------
|
67
|
|
68
|
//private final String INITIAL_VIEW = "workflow/edit/100002";
|
69
|
public static final String INITIAL_VIEW = DashBoardView.NAME;
|
70
|
|
71
|
/*
|
72
|
* this HACKY solution forces the bean to be instantiated, TODO do it properly
|
73
|
*/
|
74
|
// @Autowired
|
75
|
// MenuBeanDiscoveryBean bean;
|
76
|
|
77
|
@Autowired
|
78
|
private MainMenu mainMenu;
|
79
|
|
80
|
@Autowired
|
81
|
ApplicationEventPublisher eventBus;
|
82
|
|
83
|
public RegistrationUI() {
|
84
|
|
85
|
}
|
86
|
|
87
|
@Override
|
88
|
protected void init(VaadinRequest request) {
|
89
|
|
90
|
configureAccessDeniedView();
|
91
|
|
92
|
addStyleName(ValoTheme.UI_WITH_MENU);
|
93
|
Responsive.makeResponsive(this);
|
94
|
|
95
|
setContent((Component) viewDisplay);
|
96
|
Label phycoBankLogo = new Label("PhycoBank");
|
97
|
phycoBankLogo.addStyleName("phycobank-green");
|
98
|
phycoBankLogo.addStyleName(ValoTheme.LABEL_HUGE);
|
99
|
mainMenu.addMenuComponent(phycoBankLogo);
|
100
|
|
101
|
mainMenu.addMenuItem("New", FontAwesome.EDIT, StartRegistrationView.NAME );
|
102
|
mainMenu.addMenuItem("Continue", FontAwesome.ARROW_RIGHT, ListViewBean.NAME + "/" + ListViewBean.OPTION_IN_PROGRESS);
|
103
|
mainMenu.addMenuItem("List", FontAwesome.TASKS, ListViewBean.NAME + "/" + ListViewBean.OPTION_ALL);
|
104
|
|
105
|
eventBus.publishEvent(new UIInitializedEvent());
|
106
|
|
107
|
//navigate to initial view
|
108
|
eventBus.publishEvent(new NavigationEvent(INITIAL_VIEW));
|
109
|
|
110
|
String brand = "phycobank";
|
111
|
//TODO create annotation:
|
112
|
// @Styles(files={""}, branding="brand")
|
113
|
//
|
114
|
// the branding can either be specified or can be read from a properties file in .cdmLibrary/{instance-name}/cdm-vaadin.properties
|
115
|
// See CdmUtils for appropriate methods to access this folder
|
116
|
// the 'vaadin://' protocol refers to the VAADIN folder
|
117
|
Resource registryCssFile = new ExternalResource("vaadin://branding/" + brand + "/css/branding.css");
|
118
|
Page.getCurrent().getStyles().add(registryCssFile);
|
119
|
}
|
120
|
}
|