Project

General

Profile

Download (5.24 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.common.TeamOrPersonField;
26
import eu.etaxonomy.cdm.vaadin.component.common.TimePeriodField;
27
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView;
28
import eu.etaxonomy.vaadin.mvp.AbstractCdmPopupEditor;
29

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

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

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

    
42
    private TextField titleField;
43

    
44
    private final static int GRID_COLS = 4;
45

    
46
    private final static int GRID_ROWS = 10;
47

    
48
    /**
49
     * @param layout
50
     * @param dtoType
51
     */
52
    public ReferencePopupEditor() {
53
        super(new GridLayout(GRID_COLS, GRID_ROWS), Reference.class);
54
    }
55

    
56
    @Override
57
    protected void initContent() {
58
        GridLayout grid = (GridLayout)getFieldLayout();
59
        grid.setSpacing(true);
60
        grid.setMargin(true);
61

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

    
123
//        titleField.setRequired(true);
124
//        publisherField.setRequired(true);
125

    
126
    }
127

    
128
    /**
129
     * {@inheritDoc}
130
     */
131
    @Override
132
    public String getWindowCaption() {
133
        return "Reference editor";
134
    }
135

    
136
    /**
137
     * {@inheritDoc}
138
     */
139
    @Override
140
    protected String getDefaultComponentStyles() {
141
        return "tiny";
142
    }
143

    
144
    /**
145
     * {@inheritDoc}
146
     */
147
    @Override
148
    public void focusFirst() {
149
        titleField.focus();
150
    }
151

    
152
    /**
153
     * {@inheritDoc}
154
     */
155
    @Override
156
    public boolean isResizable() {
157
        return false;
158
    }
159

    
160
    /**
161
     * {@inheritDoc}
162
     */
163
    @Autowired
164
    @Override
165
    protected void injectPresenter(ReferenceEditorPresenter presenter) {
166
        setPresenter(presenter);
167
    }
168

    
169
    /**
170
     * {@inheritDoc}
171
     */
172
    @Override
173
    public boolean allowAnonymousAccess() {
174
        return false;
175
    }
176

    
177
    /**
178
     * {@inheritDoc}
179
     */
180
    @Override
181
    public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() {
182
        return null;
183
    }
184

    
185

    
186

    
187
}
(2-2/3)