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.view;
|
10
|
|
11
|
import com.vaadin.shared.ui.label.ContentMode;
|
12
|
import com.vaadin.ui.CssLayout;
|
13
|
import com.vaadin.ui.Label;
|
14
|
import com.vaadin.ui.themes.ValoTheme;
|
15
|
|
16
|
import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
|
17
|
import eu.etaxonomy.vaadin.mvp.AbstractView;
|
18
|
|
19
|
/**
|
20
|
* A Page based on a <code>CssLayout</code> expanded to full size having a header and sub-header.
|
21
|
*
|
22
|
* The whole header section is build using a single <code>Label</code> for better performance.
|
23
|
*
|
24
|
* @author a.kohlbecker
|
25
|
* @since Mar 20, 2017
|
26
|
*
|
27
|
*/
|
28
|
public abstract class AbstractPageView<P extends AbstractPresenter> extends AbstractView<P> {
|
29
|
|
30
|
private CssLayout layout;
|
31
|
|
32
|
private Label header;
|
33
|
|
34
|
|
35
|
/**
|
36
|
*
|
37
|
*/
|
38
|
public AbstractPageView() {
|
39
|
layout = new CssLayout();
|
40
|
layout.setSizeFull();
|
41
|
|
42
|
header = new Label();
|
43
|
header.setStyleName(ValoTheme.LABEL_HUGE);
|
44
|
header.setWidth(100, Unit.PERCENTAGE);
|
45
|
header.setContentMode(ContentMode.HTML);
|
46
|
updateHeader();
|
47
|
layout.addComponent(header);
|
48
|
|
49
|
setCompositionRoot(layout);
|
50
|
this.setSizeFull();
|
51
|
}
|
52
|
|
53
|
/**
|
54
|
*
|
55
|
*/
|
56
|
public void updateHeader() {
|
57
|
header.setValue("<div id=\"header\">" + getHeaderText() + "</div><div id=\"subheader\">" + getSubHeaderText() + "</div>");
|
58
|
}
|
59
|
|
60
|
protected CssLayout getLayout() {
|
61
|
return layout;
|
62
|
}
|
63
|
|
64
|
/**
|
65
|
* Provides the sub header text
|
66
|
*
|
67
|
* @return
|
68
|
*/
|
69
|
protected abstract String getHeaderText();
|
70
|
|
71
|
/**
|
72
|
* Provides the header text
|
73
|
*
|
74
|
* @return
|
75
|
*/
|
76
|
protected abstract String getSubHeaderText();
|
77
|
|
78
|
|
79
|
|
80
|
}
|