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.beans.factory.annotation.Qualifier;
|
13
|
|
14
|
import com.flowingcode.vaadin.addons.errorwindow.WindowErrorHandler;
|
15
|
import com.vaadin.annotations.Theme;
|
16
|
import com.vaadin.annotations.Title;
|
17
|
import com.vaadin.annotations.Viewport;
|
18
|
import com.vaadin.annotations.Widgetset;
|
19
|
import com.vaadin.navigator.ViewDisplay;
|
20
|
import com.vaadin.server.FontAwesome;
|
21
|
import com.vaadin.server.VaadinRequest;
|
22
|
import com.vaadin.server.VaadinSession;
|
23
|
import com.vaadin.spring.annotation.SpringUI;
|
24
|
import com.vaadin.ui.Label;
|
25
|
import com.vaadin.ui.themes.ValoTheme;
|
26
|
|
27
|
import eu.etaxonomy.cdm.database.PermissionDeniedException;
|
28
|
import eu.etaxonomy.cdm.vaadin.debug.EntityCacheDebugger;
|
29
|
import eu.etaxonomy.cdm.vaadin.event.error.DelegatingErrorHandler;
|
30
|
import eu.etaxonomy.cdm.vaadin.event.error.ErrorTypeErrorHandlerWrapper;
|
31
|
import eu.etaxonomy.cdm.vaadin.event.error.PermissionDeniedErrorHandler;
|
32
|
import eu.etaxonomy.cdm.vaadin.toolbar.Toolbar;
|
33
|
import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditor;
|
34
|
import eu.etaxonomy.cdm.vaadin.view.registration.DashBoardView;
|
35
|
import eu.etaxonomy.cdm.vaadin.view.registration.ListView;
|
36
|
import eu.etaxonomy.cdm.vaadin.view.registration.ListViewBean;
|
37
|
import eu.etaxonomy.cdm.vaadin.view.registration.StartRegistrationViewBean;
|
38
|
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor;
|
39
|
import eu.etaxonomy.vaadin.ui.MainMenu;
|
40
|
import eu.etaxonomy.vaadin.ui.view.ToolbarDisplay;
|
41
|
|
42
|
/**
|
43
|
* @author a.kohlbecker
|
44
|
* @since Feb 24, 2017
|
45
|
*
|
46
|
*/
|
47
|
@Theme("edit-valo")
|
48
|
@Title("Registration")
|
49
|
@SpringUI(path="registration")
|
50
|
@Viewport("width=device-width, initial-scale=1")
|
51
|
@Widgetset("eu.etaxonomy.cdm.vaadin.AppWidgetSet")
|
52
|
// @PreserveOnRefresh
|
53
|
// @Push
|
54
|
public class RegistrationUI extends AbstractUI implements PopupEditorDefaultStatusMessageSource {
|
55
|
|
56
|
private static final long serialVersionUID = -8626236111335323691L;
|
57
|
|
58
|
@Autowired
|
59
|
@Qualifier("viewAreaBean")
|
60
|
private ViewDisplay viewDisplay;
|
61
|
|
62
|
//---- pull into abstract super class ? ---------
|
63
|
|
64
|
@Autowired
|
65
|
private MainMenu mainMenu;
|
66
|
|
67
|
@Autowired
|
68
|
@Qualifier("registrationToolbar")
|
69
|
private Toolbar toolbar;
|
70
|
|
71
|
@Autowired(required = false)
|
72
|
EntityCacheDebugger entityCacheDebugger = null;
|
73
|
|
74
|
//---------------------------------------------
|
75
|
|
76
|
public static final String BRAND_NAME = "phycobank";
|
77
|
|
78
|
public static final String INITIAL_VIEW = DashBoardView.NAME;
|
79
|
|
80
|
|
81
|
//---------------------------------------------
|
82
|
|
83
|
public RegistrationUI() {
|
84
|
|
85
|
}
|
86
|
|
87
|
@Override
|
88
|
protected void init(VaadinRequest request) {
|
89
|
|
90
|
super.init(request);
|
91
|
|
92
|
if(entityCacheDebugger != null){
|
93
|
addShortcutListener(entityCacheDebugger.getShortcutListener());
|
94
|
}
|
95
|
//navigate to initial view
|
96
|
// String state = pageFragmentAsState();
|
97
|
|
98
|
|
99
|
// if(state == null){
|
100
|
// // the case when state != null is handled in the UI base class
|
101
|
// eventBus.publishEvent(new NavigationEvent(INITIAL_VIEW));
|
102
|
// }
|
103
|
}
|
104
|
|
105
|
@Override
|
106
|
protected ViewDisplay getViewDisplay() {
|
107
|
return viewDisplay;
|
108
|
}
|
109
|
|
110
|
@Override
|
111
|
protected void initContent() {
|
112
|
Label phycoBankLogo = new Label("PhycoBank");
|
113
|
phycoBankLogo.addStyleName("phycobank-green");
|
114
|
phycoBankLogo.addStyleName(ValoTheme.LABEL_HUGE);
|
115
|
mainMenu.addMenuComponent(phycoBankLogo);
|
116
|
|
117
|
mainMenu.addMenuItem("New", FontAwesome.EDIT, StartRegistrationViewBean.NAME );
|
118
|
mainMenu.addMenuItem("Continue", FontAwesome.ARROW_RIGHT, ListViewBean.NAME + "/" + ListView.Mode.inProgress.name());
|
119
|
mainMenu.addMenuItem("List", FontAwesome.TASKS, ListViewBean.NAME + "/" + ListView.Mode.all.name());
|
120
|
|
121
|
if(ToolbarDisplay.class.isAssignableFrom(getViewDisplay().getClass())){
|
122
|
((ToolbarDisplay)getViewDisplay()).setToolbar(toolbar);
|
123
|
}
|
124
|
}
|
125
|
|
126
|
@Override
|
127
|
protected void registerErrorHandlers() {
|
128
|
DelegatingErrorHandler delegatingErrorHander = new DelegatingErrorHandler();
|
129
|
WindowErrorHandler errorHandler = new WindowErrorHandler(this, RegistrationUIDefaults.ERROR_CONTACT_MESSAGE_LINE + "</br></br>"
|
130
|
+ "<i>To help analyzing the problem please describe your actions that lead to this error and provide the error details from below in your email. "
|
131
|
+ "You also might want to add a sreenshot of the browser page in error.</i>");
|
132
|
delegatingErrorHander.registerHandler(new ErrorTypeErrorHandlerWrapper<PermissionDeniedException>(PermissionDeniedException.class, new PermissionDeniedErrorHandler(this)));
|
133
|
delegatingErrorHander.registerHandler(new ErrorTypeErrorHandlerWrapper<Exception>(Exception.class, errorHandler));
|
134
|
setErrorHandler(delegatingErrorHander);
|
135
|
VaadinSession.getCurrent().setErrorHandler(delegatingErrorHander);
|
136
|
}
|
137
|
|
138
|
@Override
|
139
|
public <T extends AbstractPopupEditor> String defaultStatusMarkup(Class<T> popupEditorClass){
|
140
|
if(popupEditorClass.equals(TaxonNamePopupEditor.class)){
|
141
|
return "<strong>Check if this name already occurs in the <a href=\"https://www.phycobank.org/index-search\" target=\"index-search\">PhycoBank Index</a> (The link will open in a new window.)</strong>";
|
142
|
}
|
143
|
return null;
|
144
|
}
|
145
|
|
146
|
}
|