Project

General

Profile

« Previous | Next » 

Revision ae269e4d

Added by Andreas Kohlbecker almost 7 years ago

moving registration editor into package view.registration

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/LoginPresenter.java
33 33
 * Therefore the LoginPresenter must be in <b>UIScope</b> so that the LoginPresenter
34 34
 * is available to all Views.
35 35
 * <p>
36
 * The LoginPresenter offers a <b>auto login feature for developers</b>. Tio activate the auto login
36
 * The LoginPresenter offers a <b>auto login feature for developers</b>. To activate the auto login
37 37
 * you need to provide the <code>user name</code> and <code>password</code> using the environment variables
38 38
 * <code>cdm-vaadin.login.usr</code> and <code>cdm-vaadin.login.pwd</code>, e.g.:
39 39
 * <pre>
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferenceEditorPresenter.java
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 org.hibernate.SessionFactory;
12
import org.springframework.beans.factory.annotation.Autowired;
13
import org.springframework.transaction.TransactionStatus;
14

  
15
import com.vaadin.spring.annotation.SpringComponent;
16
import com.vaadin.spring.annotation.ViewScope;
17

  
18
import eu.etaxonomy.cdm.model.reference.Reference;
19
import eu.etaxonomy.vaadin.mvp.AbstractEditorPresenter;
20

  
21
/**
22
 * @author a.kohlbecker
23
 * @since Apr 5, 2017
24
 *
25
 */
26
@SpringComponent
27
@ViewScope
28
public class ReferenceEditorPresenter extends AbstractEditorPresenter<Reference> {
29

  
30

  
31
    private static final long serialVersionUID = -7926116447719010837L;
32

  
33
    @Autowired
34
    private SessionFactory factory;
35

  
36
    /**
37
     * {@inheritDoc}
38
     */
39
    @Override
40
    protected void saveBean(Reference bean) {
41
        TransactionStatus tx = getRepo().startTransaction();
42
        Reference persistedBean = getRepo().getReferenceService().merge(bean);
43
        getRepo().getReferenceService().saveOrUpdate(persistedBean);
44
        getRepo().commitTransaction(tx);
45
    }
46

  
47
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferencePopupEditor.java
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.AbstractPopupEditor;
28

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

  
35
@SpringComponent
36
@Scope("prototype")
37
public class ReferencePopupEditor extends AbstractPopupEditor<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
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferencePopupEditorView.java
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 eu.etaxonomy.vaadin.mvp.ApplicationView;
12

  
13
/**
14
 * @author a.kohlbecker
15
 * @since Apr 6, 2017
16
 *
17
 */
18
public interface ReferencePopupEditorView extends ApplicationView<ReferenceEditorPresenter> {
19

  
20
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ReferenceEditorPresenter.java
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 org.hibernate.SessionFactory;
12
import org.springframework.beans.factory.annotation.Autowired;
13
import org.springframework.transaction.TransactionStatus;
14

  
15
import com.vaadin.spring.annotation.SpringComponent;
16
import com.vaadin.spring.annotation.ViewScope;
17

  
18
import eu.etaxonomy.cdm.model.reference.Reference;
19
import eu.etaxonomy.vaadin.mvp.AbstractEditorPresenter;
20

  
21
/**
22
 * @author a.kohlbecker
23
 * @since Apr 5, 2017
24
 *
25
 */
26
@SpringComponent
27
@ViewScope
28
public class ReferenceEditorPresenter extends AbstractEditorPresenter<Reference> {
29

  
30

  
31
    private static final long serialVersionUID = -7926116447719010837L;
32

  
33
    @Autowired
34
    private SessionFactory factory;
35

  
36
    /**
37
     * {@inheritDoc}
38
     */
39
    @Override
40
    protected void saveBean(Reference bean) {
41
        TransactionStatus tx = getRepo().startTransaction();
42
        Reference persistedBean = getRepo().getReferenceService().merge(bean);
43
        getRepo().getReferenceService().saveOrUpdate(persistedBean);
44
        getRepo().commitTransaction(tx);
45
    }
46

  
47
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ReferencePopupEditor.java
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
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.AbstractPopupEditor;
28

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

  
35
@SpringComponent
36
@Scope("prototype")
37
public class ReferencePopupEditor extends AbstractPopupEditor<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
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ReferencePopupEditorView.java
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 eu.etaxonomy.vaadin.mvp.ApplicationView;
12

  
13
/**
14
 * @author a.kohlbecker
15
 * @since Apr 6, 2017
16
 *
17
 */
18
public interface ReferencePopupEditorView extends ApplicationView<ReferenceEditorPresenter> {
19

  
20
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowPresenter.java
30 30
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
31 31
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent;
32 32
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
33
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor;
33 34
import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
34 35

  
35 36
/**

Also available in: Unified diff