Project

General

Profile

Download (5.1 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.context.annotation.Scope;
15
import org.springframework.security.core.GrantedAuthority;
16

    
17
import com.vaadin.spring.annotation.SpringComponent;
18
import com.vaadin.ui.Alignment;
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
        grid.setComponentAlignment(typeSelect, Alignment.TOP_RIGHT);
94
        row++;
95
        addSwitchableTextField("Reference cache", "titleCache", "protectedTitleCache", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE);
96
        row++;
97
        addSwitchableTextField("Abbrev. cache", "abbrevTitleCache", "protectedAbbrevTitleCache", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE);
98
        row++;
99
        titleField = addTextField("Title", "title", 0, row, GRID_COLS-1, row);
100
        titleField.setWidth(100, Unit.PERCENTAGE);
101
        row++;
102
        addTextField("NomenclaturalTitle", "abbrevTitle", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE);
103
        row++;
104
        TeamOrPersonField authorshipField = new TeamOrPersonField("Author(s)");
105
        authorshipField.setWidth(100,  Unit.PERCENTAGE);
106
        addField(authorshipField, "authorship", 0, row, 3, row);
107
        row++;
108
        addTextField("Series", "seriesPart", 0, row);
109
        addTextField("Volume", "volume", 1, row);
110
        addTextField("Pages", "pages", 2, row);
111
        addTextField("Editor", "editor", 3, row).setWidth(100, Unit.PERCENTAGE);
112
        row++;
113
        addTextField("Place published", "placePublished", 0, row, 1, row).setWidth(100, Unit.PERCENTAGE);
114
        TextField publisherField = addTextField("Publisher", "publisher", 2, row, 3, row);
115
        publisherField.setWidth(100, Unit.PERCENTAGE);
116
        TimePeriodField timePeriodField = new TimePeriodField("Date published");
117
        addField(timePeriodField, "datePublished");
118
        row++;
119
        addTextField("ISSN", "issn", 0, row);
120
        addTextField("ISBN", "isbn", 1, row);
121
        addTextField("DOI", "doi", 2, row);
122
        addTextField("Uri", "uri", 3, row);
123

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

    
127
    }
128

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

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

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

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

    
161
    /**
162
     * {@inheritDoc}
163
     */
164
    @Override
165
    public boolean allowAnonymousAccess() {
166
        return false;
167
    }
168

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

    
177

    
178

    
179
}
(2-2/3)