1
|
package eu.etaxonomy.vaadin.ui;
|
2
|
|
3
|
import org.springframework.beans.factory.annotation.Autowired;
|
4
|
import org.springframework.context.ApplicationEventPublisher;
|
5
|
|
6
|
import com.vaadin.annotations.Theme;
|
7
|
import com.vaadin.annotations.Viewport;
|
8
|
import com.vaadin.navigator.ViewDisplay;
|
9
|
import com.vaadin.server.Responsive;
|
10
|
import com.vaadin.server.VaadinRequest;
|
11
|
import com.vaadin.spring.annotation.SpringUI;
|
12
|
import com.vaadin.ui.Component;
|
13
|
import com.vaadin.ui.UI;
|
14
|
import com.vaadin.ui.themes.ValoTheme;
|
15
|
|
16
|
@SpringUI(path="devday")
|
17
|
@Theme("edit-valo")
|
18
|
@Viewport("width=device-width, initial-scale=1")
|
19
|
// @Push
|
20
|
// @Widgetset("eu.etaxonomy.vaadin.ui.DevDayWidgetset")
|
21
|
public class DevDayUI extends UI {
|
22
|
private static final long serialVersionUID = -6541105928485822011L;
|
23
|
|
24
|
@Autowired
|
25
|
private ViewDisplay viewDisplay;
|
26
|
|
27
|
@Autowired
|
28
|
private ApplicationEventPublisher eventBus;
|
29
|
|
30
|
/*
|
31
|
* this HACKY solution forces the bean to be instantiated, TODO do it properly
|
32
|
*/
|
33
|
// @Autowired
|
34
|
// MenuBeanDiscoveryBean bean;
|
35
|
|
36
|
@Override
|
37
|
protected void init(VaadinRequest request) {
|
38
|
addStyleName(ValoTheme.UI_WITH_MENU);
|
39
|
Responsive.makeResponsive(this);
|
40
|
|
41
|
setContent((Component) viewDisplay);
|
42
|
|
43
|
//FIXME disabled! eventBus.publishEvent(new UIInitializedEvent());
|
44
|
}
|
45
|
|
46
|
// @WebServlet(value = "/*", asyncSupported = true)
|
47
|
// @VaadinServletConfiguration(productionMode = false, ui = DevDayUI.class)
|
48
|
// public static class Servlet extends VaadinCDIServlet {
|
49
|
// private static final long serialVersionUID = 7162195880902284938L;
|
50
|
//
|
51
|
// @Override
|
52
|
// protected void writeStaticResourceResponse(HttpServletRequest request,
|
53
|
// HttpServletResponse response,
|
54
|
// URL resourceUrl) throws IOException {
|
55
|
// URLConnection connection = null;
|
56
|
// InputStream is = null;
|
57
|
// String urlStr = resourceUrl.toExternalForm();
|
58
|
//
|
59
|
// if (is == null) {
|
60
|
// // precompressed resource not available, get non compressed
|
61
|
// connection = resourceUrl.openConnection();
|
62
|
// try {
|
63
|
// is = connection.getInputStream();
|
64
|
// } catch (FileNotFoundException e) {
|
65
|
// response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
66
|
// return;
|
67
|
// }
|
68
|
// }
|
69
|
//
|
70
|
// try {
|
71
|
// int length = connection.getContentLength();
|
72
|
// if (length >= 0) {
|
73
|
// response.setContentLength(length);
|
74
|
// }
|
75
|
// } catch (Throwable e) {
|
76
|
// // This can be ignored, content length header is not required.
|
77
|
// // Need to close the input stream because of
|
78
|
// // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4257700 to
|
79
|
// // prevent it from hanging, but that is done below.
|
80
|
// }
|
81
|
//
|
82
|
// try {
|
83
|
// streamContent(response, is);
|
84
|
// } finally {
|
85
|
// is.close();
|
86
|
// }
|
87
|
// }
|
88
|
//
|
89
|
// private void streamContent(HttpServletResponse response, InputStream is)
|
90
|
// throws IOException {
|
91
|
// final OutputStream os = response.getOutputStream();
|
92
|
// final byte buffer[] = new byte[DEFAULT_BUFFER_SIZE];
|
93
|
// int bytes;
|
94
|
// while ((bytes = is.read(buffer)) >= 0) {
|
95
|
// os.write(buffer, 0, bytes);
|
96
|
// }
|
97
|
// }
|
98
|
// }
|
99
|
|
100
|
}
|