Project

General

Profile

Download (4.98 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.reference;
10

    
11
import java.util.Arrays;
12
import java.util.Collection;
13

    
14
import org.springframework.beans.factory.annotation.Autowired;
15
import org.springframework.context.annotation.Scope;
16
import org.springframework.security.core.GrantedAuthority;
17

    
18
import com.vaadin.spring.annotation.SpringComponent;
19
import com.vaadin.ui.GridLayout;
20
import com.vaadin.ui.ListSelect;
21
import com.vaadin.ui.TextField;
22

    
23
import eu.etaxonomy.cdm.model.reference.Reference;
24
import eu.etaxonomy.cdm.model.reference.ReferenceType;
25
import eu.etaxonomy.cdm.vaadin.component.TimePeriodField;
26
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView;
27
import eu.etaxonomy.vaadin.mvp.AbstractCdmPopupEditor;
28

    
29
/**
30
 * @author a.kohlbecker
31
 * @since Apr 4, 2017
32
 *
33
 */
34

    
35
@SpringComponent
36
@Scope("prototype")
37
public class ReferencePopupEditor extends AbstractCdmPopupEditor<Reference, ReferenceEditorPresenter> implements ReferencePopupEditorView, AccessRestrictedView {
38

    
39
    private static final long serialVersionUID = -4347633563800758815L;
40

    
41
    private TextField titleField;
42

    
43
    private final static int GRID_COLS = 4;
44

    
45
    private final static int GRID_ROWS = 9;
46

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

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

    
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
     * {@inheritDoc}
164
     */
165
    @Override
166
    public boolean allowAnonymousAccess() {
167
        return false;
168
    }
169

    
170
    /**
171
     * {@inheritDoc}
172
     */
173
    @Override
174
    public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() {
175
        return null;
176
    }
177

    
178

    
179

    
180
}
(2-2/3)