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.vaadin.component;
|
10
|
|
11
|
import com.vaadin.data.Container;
|
12
|
import com.vaadin.data.fieldgroup.FieldGroup;
|
13
|
import com.vaadin.server.FontAwesome;
|
14
|
import com.vaadin.ui.Button;
|
15
|
import com.vaadin.ui.Component;
|
16
|
import com.vaadin.ui.CssLayout;
|
17
|
import com.vaadin.ui.ListSelect;
|
18
|
import com.vaadin.ui.themes.ValoTheme;
|
19
|
|
20
|
/**
|
21
|
* @author a.kohlbecker
|
22
|
* @since May 24, 2017
|
23
|
*
|
24
|
*/
|
25
|
public class RelatedEntityListSelect<V extends Object> extends CompositeCustomField<V> {
|
26
|
|
27
|
private static final long serialVersionUID = 6277565876657520311L;
|
28
|
|
29
|
public static final String PRIMARY_STYLE = "v-related-entity-list-select";
|
30
|
|
31
|
private Class<V> type;
|
32
|
|
33
|
private CssLayout container = new CssLayout();
|
34
|
|
35
|
private ListSelect select;
|
36
|
|
37
|
private Button newButton = new Button(FontAwesome.PLUS);
|
38
|
private Button editButton = new Button(FontAwesome.EDIT);
|
39
|
|
40
|
public RelatedEntityListSelect(String caption, Class<V> type, Container dataSource){
|
41
|
this.type = type;
|
42
|
select = new ListSelect(caption, dataSource);
|
43
|
addStyledComponents(select, newButton, editButton);
|
44
|
addSizedComponent(select);
|
45
|
}
|
46
|
|
47
|
/**
|
48
|
* {@inheritDoc}
|
49
|
*/
|
50
|
@Override
|
51
|
protected Component initContent() {
|
52
|
container.addComponents(select, newButton, editButton);
|
53
|
setPrimaryStyleName(PRIMARY_STYLE);
|
54
|
addDefaultStyles();
|
55
|
return container;
|
56
|
}
|
57
|
|
58
|
/**
|
59
|
* {@inheritDoc}
|
60
|
*/
|
61
|
@Override
|
62
|
public Class<? extends V> getType() {
|
63
|
return type;
|
64
|
}
|
65
|
|
66
|
/**
|
67
|
* {@inheritDoc}
|
68
|
*/
|
69
|
@Override
|
70
|
protected void addDefaultStyles() {
|
71
|
container.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
|
72
|
}
|
73
|
|
74
|
/**
|
75
|
* {@inheritDoc}
|
76
|
*/
|
77
|
@Override
|
78
|
public FieldGroup getFieldGroup() {
|
79
|
return null;
|
80
|
}
|
81
|
|
82
|
/**
|
83
|
* @return the select
|
84
|
*/
|
85
|
public ListSelect getSelect() {
|
86
|
return select;
|
87
|
}
|
88
|
|
89
|
/**
|
90
|
* @return the newButton
|
91
|
*/
|
92
|
public Button getNewButton() {
|
93
|
return newButton;
|
94
|
}
|
95
|
|
96
|
/**
|
97
|
* @return the editButton
|
98
|
*/
|
99
|
public Button getEditButton() {
|
100
|
return editButton;
|
101
|
}
|
102
|
|
103
|
|
104
|
|
105
|
|
106
|
|
107
|
}
|