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