1
|
/**
|
2
|
* Copyright (C) 2018 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.name;
|
10
|
|
11
|
import org.springframework.context.annotation.Scope;
|
12
|
|
13
|
import com.vaadin.spring.annotation.SpringComponent;
|
14
|
import com.vaadin.ui.Alignment;
|
15
|
import com.vaadin.ui.CheckBox;
|
16
|
import com.vaadin.ui.GridLayout;
|
17
|
import com.vaadin.ui.ListSelect;
|
18
|
import com.vaadin.ui.TextField;
|
19
|
|
20
|
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
|
21
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
22
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
23
|
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
|
24
|
import eu.etaxonomy.cdm.vaadin.util.converter.SetToListConverter;
|
25
|
import eu.etaxonomy.vaadin.component.ToManyRelatedEntitiesComboboxSelect;
|
26
|
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
|
27
|
import eu.etaxonomy.vaadin.event.EditorActionType;
|
28
|
import eu.etaxonomy.vaadin.mvp.AbstractCdmPopupEditor;
|
29
|
|
30
|
/**
|
31
|
* @author a.kohlbecker
|
32
|
* @since Jan 26, 2018
|
33
|
*
|
34
|
*/
|
35
|
@SpringComponent
|
36
|
@Scope("prototype")
|
37
|
public class NameTypeDesignationPopupEditor extends AbstractCdmPopupEditor<NameTypeDesignation, NameTypeDesignationPresenter>
|
38
|
implements NameTypeDesignationEditorView {
|
39
|
|
40
|
private static final int GRID_COLS = 4;
|
41
|
private static final int GRID_ROWS = 6;
|
42
|
|
43
|
private CheckBox conservedTypeField;
|
44
|
private CheckBox rejectedTypeField;
|
45
|
private CheckBox notDesignatedField;
|
46
|
|
47
|
private ToOneRelatedEntityCombobox<TaxonName> typeNameField;
|
48
|
|
49
|
private ToManyRelatedEntitiesComboboxSelect<TaxonName> typifiedNamesComboboxSelect;
|
50
|
|
51
|
private ListSelect typeStatusSelect;
|
52
|
|
53
|
private ToOneRelatedEntityCombobox<Reference> citationCombobox;
|
54
|
|
55
|
private TextField citationDetailField;
|
56
|
|
57
|
private boolean showTypeFlags = true;
|
58
|
|
59
|
|
60
|
/**
|
61
|
* @param layout
|
62
|
* @param dtoType
|
63
|
*/
|
64
|
public NameTypeDesignationPopupEditor() {
|
65
|
super(new GridLayout(GRID_COLS, GRID_ROWS), NameTypeDesignation.class);
|
66
|
}
|
67
|
|
68
|
/**
|
69
|
* {@inheritDoc}
|
70
|
*/
|
71
|
@Override
|
72
|
public String getWindowCaption() {
|
73
|
return "Name type designation editor";
|
74
|
}
|
75
|
|
76
|
/**
|
77
|
* {@inheritDoc}
|
78
|
*/
|
79
|
@Override
|
80
|
public void focusFirst() {
|
81
|
// none
|
82
|
}
|
83
|
|
84
|
/**
|
85
|
* {@inheritDoc}
|
86
|
*/
|
87
|
@Override
|
88
|
protected String getDefaultComponentStyles() {
|
89
|
return "tiny";
|
90
|
}
|
91
|
|
92
|
/**
|
93
|
* {@inheritDoc}
|
94
|
*/
|
95
|
@Override
|
96
|
protected void initContent() {
|
97
|
/*
|
98
|
conservedType : boolean
|
99
|
rejectedType : boolean
|
100
|
typeName : TaxonName
|
101
|
|
102
|
typifiedNames
|
103
|
notDesignated : boolean
|
104
|
registrations : Set<Registration>
|
105
|
typeStatus : T
|
106
|
|
107
|
citation : Reference
|
108
|
citationMicroReference : String
|
109
|
originalNameString : String
|
110
|
*/
|
111
|
|
112
|
GridLayout grid = (GridLayout)getFieldLayout();
|
113
|
// grid.setSizeFull();
|
114
|
grid.setSpacing(true);
|
115
|
grid.setColumnExpandRatio(0, 0.25f);
|
116
|
grid.setColumnExpandRatio(1, 0.25f);
|
117
|
grid.setColumnExpandRatio(2, 0.25f);
|
118
|
grid.setColumnExpandRatio(3, 0.25f);
|
119
|
|
120
|
int row = 0;
|
121
|
|
122
|
if(showTypeFlags){
|
123
|
conservedTypeField = addCheckBox("Conserved type", "conservedType", 0, row);
|
124
|
rejectedTypeField = addCheckBox("Rejected type", "rejectedType", 1, row);
|
125
|
notDesignatedField = addCheckBox("Not designated", "notDesignated", 2, row);
|
126
|
row++;
|
127
|
}
|
128
|
|
129
|
typeStatusSelect = new ListSelect("Type status");
|
130
|
typeStatusSelect.setNullSelectionAllowed(false);
|
131
|
typeStatusSelect.setRows(1);
|
132
|
typeStatusSelect.setWidth(100, Unit.PERCENTAGE);
|
133
|
addField(typeStatusSelect, "typeStatus", 0, row, 1, row);
|
134
|
grid.setComponentAlignment(typeStatusSelect, Alignment.TOP_RIGHT);
|
135
|
|
136
|
row++;
|
137
|
typeNameField = new ToOneRelatedEntityCombobox<TaxonName>("Type name", TaxonName.class);
|
138
|
addField(typeNameField, "typeName", 0, row, 3, row);
|
139
|
typeNameField.addClickListenerAddEntity(e -> getViewEventBus().publish(
|
140
|
this,
|
141
|
new TaxonNameEditorAction(EditorActionType.ADD, null, typeNameField, this))
|
142
|
);
|
143
|
typeNameField.addClickListenerEditEntity(e -> {
|
144
|
if(typeNameField.getValue() != null){
|
145
|
getViewEventBus().publish(this,
|
146
|
new TaxonNameEditorAction(
|
147
|
EditorActionType.EDIT,
|
148
|
typeNameField.getValue().getId(),
|
149
|
typeNameField,
|
150
|
this)
|
151
|
);
|
152
|
}
|
153
|
});
|
154
|
|
155
|
row++;
|
156
|
typifiedNamesComboboxSelect = new ToManyRelatedEntitiesComboboxSelect<TaxonName>(TaxonName.class, "Typified names");
|
157
|
typifiedNamesComboboxSelect.setConverter(new SetToListConverter<TaxonName>());
|
158
|
addField(typifiedNamesComboboxSelect, "typifiedNames", 0, row, 3, row);
|
159
|
typifiedNamesComboboxSelect.setReadOnly(false); // FIXME this does not help
|
160
|
|
161
|
row++;
|
162
|
citationCombobox = new ToOneRelatedEntityCombobox<Reference>("Citation", Reference.class);
|
163
|
addField(citationCombobox, "citation", 0, row, 2, row);
|
164
|
citationCombobox.setWidth(400, Unit.PIXELS);
|
165
|
citationDetailField = addTextField("Citation detail", "citationMicroReference", 3, row);
|
166
|
}
|
167
|
|
168
|
/**
|
169
|
* @return the typeNameField
|
170
|
*/
|
171
|
@Override
|
172
|
public ToOneRelatedEntityCombobox<TaxonName> getTypeNameField() {
|
173
|
return typeNameField;
|
174
|
}
|
175
|
|
176
|
/**
|
177
|
* @return the typifiedNamesComboboxSelect
|
178
|
*/
|
179
|
@Override
|
180
|
public ToManyRelatedEntitiesComboboxSelect<TaxonName> getTypifiedNamesComboboxSelect() {
|
181
|
return typifiedNamesComboboxSelect;
|
182
|
}
|
183
|
|
184
|
/**
|
185
|
* @return the typeStatusSelect
|
186
|
*/
|
187
|
@Override
|
188
|
public ListSelect getTypeStatusSelect() {
|
189
|
return typeStatusSelect;
|
190
|
}
|
191
|
|
192
|
/**
|
193
|
* @return the citationCombobox
|
194
|
*/
|
195
|
@Override
|
196
|
public ToOneRelatedEntityCombobox<Reference> getCitationCombobox() {
|
197
|
return citationCombobox;
|
198
|
}
|
199
|
|
200
|
|
201
|
/**
|
202
|
* @return the showTypeFlags
|
203
|
*/
|
204
|
@Override
|
205
|
public boolean isShowTypeFlags() {
|
206
|
return showTypeFlags;
|
207
|
}
|
208
|
|
209
|
/**
|
210
|
* @param showTypeFlags the showTypeFlags to set
|
211
|
*/
|
212
|
@Override
|
213
|
public void setShowTypeFlags(boolean showTypeFlags) {
|
214
|
this.showTypeFlags = showTypeFlags;
|
215
|
}
|
216
|
}
|