Revision 6f9eb1fe
Added by Andreas Kohlbecker about 7 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/phycobank/ListViewBean.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.phycobank; |
10 | 10 |
|
11 | 11 |
import java.util.Collection; |
12 |
import java.util.Locale; |
|
13 | 12 |
|
14 | 13 |
import org.springframework.beans.factory.annotation.Autowired; |
15 | 14 |
|
... | ... | |
17 | 16 |
import com.vaadin.data.util.BeanContainer; |
18 | 17 |
import com.vaadin.data.util.GeneratedPropertyContainer; |
19 | 18 |
import com.vaadin.data.util.PropertyValueGenerator; |
20 |
import com.vaadin.data.util.converter.Converter; |
|
21 | 19 |
import com.vaadin.navigator.View; |
22 | 20 |
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; |
23 |
import com.vaadin.server.FontAwesome;
|
|
21 |
import com.vaadin.shared.ui.MarginInfo;
|
|
24 | 22 |
import com.vaadin.shared.ui.grid.HeightMode; |
25 | 23 |
import com.vaadin.spring.annotation.SpringView; |
26 | 24 |
import com.vaadin.ui.Alignment; |
... | ... | |
28 | 26 |
import com.vaadin.ui.Grid.Column; |
29 | 27 |
import com.vaadin.ui.Grid.SelectionMode; |
30 | 28 |
import com.vaadin.ui.Label; |
29 |
import com.vaadin.ui.Panel; |
|
31 | 30 |
import com.vaadin.ui.VerticalLayout; |
32 | 31 |
import com.vaadin.ui.renderers.ButtonRenderer; |
33 | 32 |
import com.vaadin.ui.renderers.DateRenderer; |
34 | 33 |
import com.vaadin.ui.renderers.HtmlRenderer; |
35 | 34 |
import com.vaadin.ui.themes.ValoTheme; |
36 | 35 |
|
36 |
import eu.etaxonomy.cdm.vaadin.component.phycobank.RegistrationItem; |
|
37 | 37 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.ListPresenter; |
38 | 38 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.RegistrationDTO; |
39 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.RegistrationType; |
|
40 | 39 |
import eu.etaxonomy.cdm.vaadin.util.JodaDateTimeConverter; |
41 | 40 |
import eu.etaxonomy.cdm.vaadin.util.UrlStringConverter; |
42 | 41 |
import eu.etaxonomy.vaadin.mvp.AbstractView; |
... | ... | |
50 | 49 |
@SpringView(name=ListViewBean.NAME) |
51 | 50 |
public class ListViewBean extends AbstractView<ListPresenter> implements ListView, View { |
52 | 51 |
|
53 |
/** |
|
54 |
* @author a.kohlbecker |
|
55 |
* @since Mar 7, 2017 |
|
56 |
* |
|
57 |
*/ |
|
58 |
protected final class RegistrationTypeConverter implements Converter<String, RegistrationType> { |
|
59 |
@Override |
|
60 |
public RegistrationType convertToModel(String value, Class<? extends RegistrationType> targetType, |
|
61 |
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { |
|
62 |
// not implemented |
|
63 |
return null; |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
public String convertToPresentation(RegistrationType value, Class<? extends String> targetType, |
|
68 |
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { |
|
69 |
if(value.equals(RegistrationType.NAME)) { |
|
70 |
return FontAwesome.TAG.getHtml(); |
|
71 |
} |
|
72 |
if(value.equals(RegistrationType.TYPIFICATION)) { |
|
73 |
return FontAwesome.TAGS.getHtml(); |
|
74 |
} |
|
75 |
return FontAwesome.WARNING.getHtml(); |
|
76 |
} |
|
77 |
|
|
78 |
@Override |
|
79 |
public Class<RegistrationType> getModelType() { |
|
80 |
return RegistrationType.class; |
|
81 |
} |
|
82 |
|
|
83 |
@Override |
|
84 |
public Class<String> getPresentationType() { |
|
85 |
return String.class; |
|
86 |
} |
|
87 |
} |
|
88 | 52 |
private static final long serialVersionUID = 3543300933072824713L; |
89 | 53 |
|
90 | 54 |
public static final String NAME = "list"; |
... | ... | |
93 | 57 |
|
94 | 58 |
private Grid grid; |
95 | 59 |
|
60 |
private Panel panel; |
|
61 |
|
|
96 | 62 |
public ListViewBean() { |
97 | 63 |
layout = new VerticalLayout(); |
98 | 64 |
layout.setSpacing(true); |
... | ... | |
109 | 75 |
layout.addComponent(hint); |
110 | 76 |
layout.setComponentAlignment(hint, Alignment.MIDDLE_CENTER); |
111 | 77 |
|
112 |
grid = buildGrid(); |
|
113 |
layout.addComponent(grid); |
|
114 |
layout.setExpandRatio(grid, 1); |
|
78 |
// grid = buildGrid(); |
|
79 |
// layout.addComponent(grid); |
|
80 |
// layout.setExpandRatio(grid, 1); |
|
81 |
|
|
82 |
buildPanel(); |
|
115 | 83 |
|
116 | 84 |
setCompositionRoot(layout); |
117 | 85 |
this.setSizeFull(); |
118 | 86 |
} |
119 | 87 |
|
88 |
/** |
|
89 |
* |
|
90 |
*/ |
|
91 |
private void buildPanel() { |
|
92 |
panel = new Panel(); |
|
93 |
panel.setSizeFull(); |
|
94 |
panel.setId("registration-list"); |
|
95 |
layout.addComponent(panel); |
|
96 |
layout.setExpandRatio(panel, 1); |
|
97 |
} |
|
98 |
|
|
120 | 99 |
private Grid buildGrid() { |
121 | 100 |
Grid grid = new Grid(); |
122 | 101 |
grid.setSizeFull(); |
... | ... | |
204 | 183 |
|
205 | 184 |
} |
206 | 185 |
|
186 |
/** |
|
187 |
* {@inheritDoc} |
|
188 |
*/ |
|
189 |
@Override |
|
190 |
public void populateList(Collection<RegistrationDTO> registrations) { |
|
191 |
VerticalLayout list = new VerticalLayout(); |
|
192 |
list.setMargin(new MarginInfo(false, true)); |
|
193 |
list.setSpacing(true); |
|
194 |
for(RegistrationDTO regDto : registrations) { |
|
195 |
|
|
196 |
list.addComponent(new RegistrationItem(regDto, this)); |
|
197 |
if(list.getComponentCount() > 10){ |
|
198 |
break; |
|
199 |
} |
|
200 |
} |
|
201 |
panel.setContent(list); |
|
202 |
|
|
203 |
} |
|
204 |
|
|
207 | 205 |
/** |
208 | 206 |
* @param registrationItems |
209 | 207 |
* @return |
... | ... | |
228 | 226 |
return gpContainer; |
229 | 227 |
} |
230 | 228 |
|
229 |
|
|
230 |
|
|
231 | 231 |
} |
Also available in: Unified diff
ref #6169 using RegistrationItem in the ListView