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.cdm.vaadin.view.registration;
|
10
|
|
11
|
import java.util.Arrays;
|
12
|
|
13
|
import org.springframework.beans.factory.annotation.Autowired;
|
14
|
import org.springframework.context.annotation.Scope;
|
15
|
|
16
|
import com.vaadin.spring.annotation.SpringComponent;
|
17
|
import com.vaadin.ui.GridLayout;
|
18
|
import com.vaadin.ui.ListSelect;
|
19
|
import com.vaadin.ui.TextField;
|
20
|
|
21
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
22
|
import eu.etaxonomy.cdm.model.reference.ReferenceType;
|
23
|
import eu.etaxonomy.cdm.vaadin.component.SelectFieldFactory;
|
24
|
import eu.etaxonomy.cdm.vaadin.component.TimePeriodField;
|
25
|
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor;
|
26
|
|
27
|
/**
|
28
|
* @author a.kohlbecker
|
29
|
* @since Apr 4, 2017
|
30
|
*
|
31
|
*/
|
32
|
|
33
|
@SpringComponent
|
34
|
@Scope("prototype")
|
35
|
public class ReferencePopupEditor extends AbstractPopupEditor<Reference, ReferenceEditorPresenter> implements ReferencePopupEditorView {
|
36
|
|
37
|
private static final long serialVersionUID = -4347633563800758815L;
|
38
|
|
39
|
private TextField titleField;
|
40
|
|
41
|
private final static int GRID_COLS = 4;
|
42
|
|
43
|
private final static int GRID_ROWS = 9;
|
44
|
|
45
|
@Autowired
|
46
|
private SelectFieldFactory selectFactory;
|
47
|
|
48
|
/**
|
49
|
* @param layout
|
50
|
* @param dtoType
|
51
|
*/
|
52
|
public ReferencePopupEditor() {
|
53
|
super(new GridLayout(GRID_COLS, GRID_ROWS), Reference.class);
|
54
|
GridLayout grid = (GridLayout)getFieldLayout();
|
55
|
grid.setSpacing(true);
|
56
|
grid.setMargin(true);
|
57
|
|
58
|
/*
|
59
|
"type",
|
60
|
"uri",
|
61
|
"abbrevTitleCache",
|
62
|
"protectedAbbrevTitleCache",
|
63
|
"nomenclaturallyRelevant",
|
64
|
"authorship",
|
65
|
"referenceAbstract",
|
66
|
"title",
|
67
|
"abbrevTitle",
|
68
|
"editor",
|
69
|
"volume",
|
70
|
"pages",
|
71
|
"edition",
|
72
|
"isbn",
|
73
|
"issn",
|
74
|
"doi",
|
75
|
"seriesPart",
|
76
|
"datePublished",
|
77
|
"publisher",
|
78
|
"placePublished",
|
79
|
"institution",
|
80
|
"school",
|
81
|
"organization",
|
82
|
"inReference"
|
83
|
*/
|
84
|
int row = 0;
|
85
|
ListSelect typeSelect = new ListSelect("Reference type", Arrays.asList(ReferenceType.values()));
|
86
|
typeSelect.setNullSelectionAllowed(false);
|
87
|
typeSelect.setRows(1);
|
88
|
addField(typeSelect, "type", 3, row);
|
89
|
row++;
|
90
|
addTextField("Reference cache", "titleCache", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE);
|
91
|
row++;
|
92
|
addTextField("Abbrev. cache", "abbrevTitleCache", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE);
|
93
|
row++;
|
94
|
titleField = addTextField("Title", "title", 0, row, GRID_COLS-1, row);
|
95
|
titleField.setRequired(true);
|
96
|
titleField.setWidth(100, Unit.PERCENTAGE);
|
97
|
row++;
|
98
|
addTextField("NomenclaturalTitle", "abbrevTitle", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE);
|
99
|
row++;
|
100
|
// addTextField("Author(s)", "authorship", 0, 4, 1, 4)).setRequired(true);
|
101
|
addTextField("Editor", "editor", 2, row, 3, row).setWidth(100, Unit.PERCENTAGE);
|
102
|
row++;
|
103
|
addTextField("Series", "seriesPart", 0, row);
|
104
|
addTextField("Volume", "volume", 1, row);
|
105
|
addTextField("Pages", "pages", 2, row);
|
106
|
row++;
|
107
|
addTextField("Place published", "placePublished", 0, row, 1, row).setWidth(100, Unit.PERCENTAGE);
|
108
|
TextField publisherField = addTextField("Publisher", "publisher", 2, row, 3, row);
|
109
|
publisherField.setRequired(true);
|
110
|
publisherField.setWidth(100, Unit.PERCENTAGE);
|
111
|
TimePeriodField timePeriodField = new TimePeriodField("Date published");
|
112
|
addField(timePeriodField, "datePublished");
|
113
|
row++;
|
114
|
// TODO implement a TimePeriod component
|
115
|
addTextField("ISSN", "issn", 0, row);
|
116
|
addTextField("ISBN", "isbn", 1, row);
|
117
|
addTextField("DOI", "doi", 2, row);
|
118
|
addTextField("Uri", "uri", 3, row);
|
119
|
}
|
120
|
|
121
|
/**
|
122
|
* {@inheritDoc}
|
123
|
*/
|
124
|
@Override
|
125
|
public String getWindowCaption() {
|
126
|
return "Reference editor";
|
127
|
}
|
128
|
|
129
|
/**
|
130
|
* {@inheritDoc}
|
131
|
*/
|
132
|
@Override
|
133
|
protected String getDefaultComponentStyles() {
|
134
|
return "tiny";
|
135
|
}
|
136
|
|
137
|
/**
|
138
|
* {@inheritDoc}
|
139
|
*/
|
140
|
@Override
|
141
|
public void focusFirst() {
|
142
|
titleField.focus();
|
143
|
}
|
144
|
|
145
|
/**
|
146
|
* {@inheritDoc}
|
147
|
*/
|
148
|
@Override
|
149
|
public boolean isResizable() {
|
150
|
return false;
|
151
|
}
|
152
|
|
153
|
/**
|
154
|
* {@inheritDoc}
|
155
|
*/
|
156
|
@Autowired
|
157
|
@Override
|
158
|
protected void injectPresenter(ReferenceEditorPresenter presenter) {
|
159
|
setPresenter(presenter);
|
160
|
}
|
161
|
|
162
|
|
163
|
|
164
|
}
|