Project

General

Profile

Download (4.53 KB) Statistics
| Branch: | Tag: | Revision:
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.TimePeriodField;
24
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor;
25

    
26
/**
27
 * @author a.kohlbecker
28
 * @since Apr 4, 2017
29
 *
30
 */
31

    
32
@SpringComponent
33
@Scope("prototype")
34
public class ReferencePopupEditor extends AbstractPopupEditor<Reference, ReferenceEditorPresenter> implements ReferencePopupEditorView {
35

    
36
    private static final long serialVersionUID = -4347633563800758815L;
37

    
38
    private TextField titleField;
39

    
40
    private final static int GRID_COLS = 4;
41

    
42
    private final static int GRID_ROWS = 9;
43

    
44
    /**
45
     * @param layout
46
     * @param dtoType
47
     */
48
    public ReferencePopupEditor() {
49
        super(new GridLayout(GRID_COLS, GRID_ROWS), Reference.class);
50
        GridLayout grid = (GridLayout)getFieldLayout();
51
        grid.setSpacing(true);
52
        grid.setMargin(true);
53

    
54
        /*
55
        "type",
56
        "uri",
57
        "abbrevTitleCache",
58
        "protectedAbbrevTitleCache",
59
        "nomenclaturallyRelevant",
60
        "authorship",
61
        "referenceAbstract",
62
        "title",
63
        "abbrevTitle",
64
        "editor",
65
        "volume",
66
        "pages",
67
        "edition",
68
        "isbn",
69
        "issn",
70
        "doi",
71
        "seriesPart",
72
        "datePublished",
73
        "publisher",
74
        "placePublished",
75
        "institution",
76
        "school",
77
        "organization",
78
        "inReference"
79
         */
80
        int row = 0;
81
        ListSelect typeSelect = new ListSelect("Reference type", Arrays.asList(ReferenceType.values()));
82
        typeSelect.setNullSelectionAllowed(false);
83
        typeSelect.setRows(1);
84
        addField(typeSelect, "type", 3, row);
85
        row++;
86
        addTextField("Reference cache", "titleCache", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE);
87
        row++;
88
        addTextField("Abbrev. cache", "abbrevTitleCache", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE);
89
        row++;
90
        titleField = addTextField("Title", "title", 0, row, GRID_COLS-1, row);
91
        titleField.setRequired(true);
92
        titleField.setWidth(100, Unit.PERCENTAGE);
93
        row++;
94
        addTextField("NomenclaturalTitle", "abbrevTitle", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE);
95
        row++;
96
        // addTextField("Author(s)", "authorship", 0, 4, 1, 4)).setRequired(true);
97
        addTextField("Editor", "editor", 2, row, 3, row).setWidth(100, Unit.PERCENTAGE);
98
        row++;
99
        addTextField("Series", "seriesPart", 0, row);
100
        addTextField("Volume", "volume", 1, row);
101
        addTextField("Pages", "pages", 2, row);
102
        row++;
103
        addTextField("Place published", "placePublished", 0, row, 1, row).setWidth(100, Unit.PERCENTAGE);
104
        TextField publisherField = addTextField("Publisher", "publisher", 2, row, 3, row);
105
        publisherField.setRequired(true);
106
        publisherField.setWidth(100, Unit.PERCENTAGE);
107
        TimePeriodField timePeriodField = new TimePeriodField("Date published");
108
        addField(timePeriodField, "datePublished");
109
        row++;
110
        // TODO implement a TimePeriod component
111
        addTextField("ISSN", "issn", 0, row);
112
        addTextField("ISBN", "isbn", 1, row);
113
        addTextField("DOI", "doi", 2, row);
114
        addTextField("Uri", "uri", 3, row);
115
    }
116

    
117
    /**
118
     * {@inheritDoc}
119
     */
120
    @Override
121
    public String getWindowCaption() {
122
        return "Reference editor";
123
    }
124

    
125
    /**
126
     * {@inheritDoc}
127
     */
128
    @Override
129
    protected String getDefaultComponentStyles() {
130
        return "tiny";
131
    }
132

    
133
    /**
134
     * {@inheritDoc}
135
     */
136
    @Override
137
    public void focusFirst() {
138
        titleField.focus();
139
    }
140

    
141
    /**
142
     * {@inheritDoc}
143
     */
144
    @Override
145
    public boolean isResizable() {
146
        return false;
147
    }
148

    
149
    /**
150
     * {@inheritDoc}
151
     */
152
    @Autowired
153
    @Override
154
    protected void injectPresenter(ReferenceEditorPresenter presenter) {
155
        setPresenter(presenter);
156
    }
157

    
158

    
159

    
160
}
(6-6/17)