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