1 |
08f24060
|
Andreas Kohlbecker
|
/**
|
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 |
84724c61
|
Andreas Kohlbecker
|
import java.util.ArrayList;
|
12 |
|
|
import java.util.List;
|
13 |
|
|
|
14 |
08f24060
|
Andreas Kohlbecker
|
import com.vaadin.shared.ui.label.ContentMode;
|
15 |
84724c61
|
Andreas Kohlbecker
|
import com.vaadin.ui.AbstractLayout;
|
16 |
|
|
import com.vaadin.ui.Component;
|
17 |
08f24060
|
Andreas Kohlbecker
|
import com.vaadin.ui.Label;
|
18 |
84724c61
|
Andreas Kohlbecker
|
import com.vaadin.ui.VerticalLayout;
|
19 |
08f24060
|
Andreas Kohlbecker
|
import com.vaadin.ui.themes.ValoTheme;
|
20 |
|
|
|
21 |
|
|
import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
|
22 |
|
|
import eu.etaxonomy.vaadin.mvp.AbstractView;
|
23 |
|
|
|
24 |
|
|
/**
|
25 |
|
|
* A Page based on a <code>CssLayout</code> expanded to full size having a header and sub-header.
|
26 |
|
|
*
|
27 |
|
|
* The whole header section is build using a single <code>Label</code> for better performance.
|
28 |
|
|
*
|
29 |
|
|
* @author a.kohlbecker
|
30 |
|
|
* @since Mar 20, 2017
|
31 |
|
|
*
|
32 |
|
|
*/
|
33 |
|
|
public abstract class AbstractPageView<P extends AbstractPresenter> extends AbstractView<P> {
|
34 |
|
|
|
35 |
84724c61
|
Andreas Kohlbecker
|
private VerticalLayout layout;
|
36 |
|
|
|
37 |
|
|
private List<Component> contentComponents = new ArrayList<>();
|
38 |
08f24060
|
Andreas Kohlbecker
|
|
39 |
|
|
private Label header;
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
/**
|
43 |
|
|
*
|
44 |
|
|
*/
|
45 |
|
|
public AbstractPageView() {
|
46 |
84724c61
|
Andreas Kohlbecker
|
layout = new VerticalLayout();
|
47 |
08f24060
|
Andreas Kohlbecker
|
layout.setSizeFull();
|
48 |
|
|
|
49 |
|
|
header = new Label();
|
50 |
|
|
header.setStyleName(ValoTheme.LABEL_HUGE);
|
51 |
|
|
header.setWidth(100, Unit.PERCENTAGE);
|
52 |
|
|
header.setContentMode(ContentMode.HTML);
|
53 |
5b4537c4
|
Andreas Kohlbecker
|
updateHeader();
|
54 |
08f24060
|
Andreas Kohlbecker
|
layout.addComponent(header);
|
55 |
|
|
|
56 |
|
|
setCompositionRoot(layout);
|
57 |
|
|
this.setSizeFull();
|
58 |
|
|
}
|
59 |
|
|
|
60 |
5b4537c4
|
Andreas Kohlbecker
|
/**
|
61 |
84724c61
|
Andreas Kohlbecker
|
*
|
62 |
5b4537c4
|
Andreas Kohlbecker
|
*/
|
63 |
|
|
public void updateHeader() {
|
64 |
|
|
header.setValue("<div id=\"header\">" + getHeaderText() + "</div><div id=\"subheader\">" + getSubHeaderText() + "</div>");
|
65 |
|
|
}
|
66 |
|
|
|
67 |
84724c61
|
Andreas Kohlbecker
|
protected AbstractLayout getLayout() {
|
68 |
08f24060
|
Andreas Kohlbecker
|
return layout;
|
69 |
|
|
}
|
70 |
|
|
|
71 |
84724c61
|
Andreas Kohlbecker
|
protected void removeContentComponents(){
|
72 |
|
|
for(Component c : contentComponents){
|
73 |
|
|
layout.removeComponent(c);
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
protected void addContentComponent(Component component, Float expandRatio){
|
79 |
|
|
contentComponents.add(component);
|
80 |
|
|
layout.addComponent(component);
|
81 |
|
|
if(expandRatio != null){
|
82 |
|
|
layout.setExpandRatio(component, expandRatio);
|
83 |
|
|
}
|
84 |
|
|
}
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
08f24060
|
Andreas Kohlbecker
|
/**
|
89 |
|
|
* Provides the sub header text
|
90 |
|
|
*
|
91 |
|
|
* @return
|
92 |
|
|
*/
|
93 |
|
|
protected abstract String getHeaderText();
|
94 |
|
|
|
95 |
|
|
/**
|
96 |
|
|
* Provides the header text
|
97 |
|
|
*
|
98 |
|
|
* @return
|
99 |
|
|
*/
|
100 |
|
|
protected abstract String getSubHeaderText();
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
}
|