Project

General

Profile

Revision 76910e45

ID76910e455a4844d2adca9de09a3a2dab5b458f74
Parent 03afd801
Child 06c249eb

Added by Andreas Kohlbecker over 2 years ago

ref #6169 RegistrationItemButtonGroups: making names and typeDesignations clickable

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItemEditButtonGroup.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.component.registration;
10

  
11
import java.util.ArrayList;
12
import java.util.List;
13

  
14
import com.vaadin.server.FontAwesome;
15
import com.vaadin.ui.Button;
16
import com.vaadin.ui.Label;
17
import com.vaadin.ui.themes.ValoTheme;
18

  
19
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationDTO;
20
import eu.etaxonomy.vaadin.component.CompositeStyledComponent;
21

  
22
/**
23
 * @author a.kohlbecker
24
 * @since May 19, 2017
25
 *
26
 */
27
public class RegistrationItemEditButtonGroup extends CompositeStyledComponent {
28

  
29

  
30
    private static final long serialVersionUID = -5059163772392864050L;
31

  
32
    public static final String STYLE_NAMES = "edit-button-group " + ValoTheme.LAYOUT_COMPONENT_GROUP;
33

  
34
    /**
35
     * Either the id of the name in the Registration or the id of the typifying name
36
     * of the first type designation.
37
     */
38
    private Integer nameId = null;
39

  
40
    private Button nameButton = null;
41

  
42
    private List<Button> typeDesignationButtons = new ArrayList<>();
43

  
44
    private List<Label> labels = new ArrayList<>();
45

  
46

  
47

  
48
    public RegistrationItemEditButtonGroup(RegistrationDTO regDto){
49

  
50
        setWidth(100, Unit.PERCENTAGE);
51

  
52
        if(regDto.getName() != null){
53
            nameButton = new Button(regDto.getName().getLabel());
54
            addComponent(nameButton);
55
        } else {
56
            // no name in the registration! we only show the typified name as label
57
            addComponent(new Label(regDto.getTypifiedName().getLabel()));
58
        }
59
        regDto.getTypeDesignations().keySet().iterator().forEachRemaining(key -> {
60
            Label label = new Label(key   + ":");
61
            label.setWidthUndefined();
62
            addComponent(label);
63
            labels.add(label);
64

  
65
            regDto.getTypeDesignations().get(key).forEach(value -> {
66
            Button tdButton = new Button(value.getLabel());
67
            addComponent(tdButton);
68
            typeDesignationButtons.add(tdButton);
69
            }) ;
70
        });
71
        Button addTypeDesignationButton = new Button(FontAwesome.PLUS);
72
        addComponent(addTypeDesignationButton);
73

  
74
        iterator().forEachRemaining(c -> addStyledComponent(c));
75
        addDefaultStyles();
76

  
77
    }
78

  
79
    public Button getNameButton() {
80
        return nameButton;
81
    }
82

  
83
    /**
84
     * {@inheritDoc}
85
     */
86
    @Override
87
    protected void addDefaultStyles() {
88
        addStyleName(STYLE_NAMES);
89
    }
90

  
91
}
src/main/java/eu/etaxonomy/cdm/vaadin/util/converter/TypeDesignationConverter.java
13 13
import java.util.Collections;
14 14
import java.util.Comparator;
15 15
import java.util.HashMap;
16
import java.util.LinkedHashMap;
16 17
import java.util.LinkedList;
17 18
import java.util.List;
18 19
import java.util.Map;
......
24 25
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
25 26
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
26 27
import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase;
28
import eu.etaxonomy.cdm.vaadin.view.registration.IdAndString;
29
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationValidationException;
27 30

  
28 31
/**
29 32
 * Converts a collection of TypeDesignations, which should belong to the
......
41 44
    private final String separator = ", ";
42 45

  
43 46
    private Collection<TypeDesignationBase> typeDesignations;
44
    private Map<TypeDesignationStatusBase<?>, Collection<String>> orderedStrings;
47
    private Map<TypeDesignationStatusBase<?>, Collection<IdAndString>> orderedStringsByType;
48
    private LinkedHashMap<String, Collection<IdAndString>> orderedRepresentations = new LinkedHashMap<>();
49
    private IdAndString typifiedName;
45 50

  
46 51
    private String finalString = null;
47 52

  
48
    private String typifiedNameCache = null;
53

  
49 54

  
50 55
    /**
51 56
     * @param taxonNameBase
57
     * @throws RegistrationValidationException
52 58
     *
53 59
     */
54
    public TypeDesignationConverter(Collection<TypeDesignationBase> typeDesignations, TaxonNameBase taxonNameBase) {
60
    public TypeDesignationConverter(Collection<TypeDesignationBase> typeDesignations) throws RegistrationValidationException {
55 61
        this.typeDesignations = typeDesignations;
56
        orderedStrings = new HashMap<>(typeDesignations.size());
57
        if(taxonNameBase != null){
58
            this.typifiedNameCache = taxonNameBase.getTitleCache();
59
        }
60
    }
61

  
62
    private void putString(TypeDesignationStatusBase<?> status, String string){
63
        // the cdm orderd term bases are ordered invers, fixing this for here
64
        if(status == null){
65
            status = SpecimenTypeDesignationStatus.TYPE();
66
        }
67
        if(!orderedStrings.containsKey(status)){
68
            orderedStrings.put(status, new ArrayList<String>());
69
        }
70
        orderedStrings.get(status).add(string);
62
        orderedStringsByType = new HashMap<>();
63
        typeDesignations.forEach(td -> putString(td.getTypeStatus(), new IdAndString(td.getId(), stringify(td))));
64
        orderedRepresentations = buildOrderedRepresentations();
65
        this.typifiedName = findTypifiedName();
71 66
    }
72 67

  
68
    private LinkedHashMap buildOrderedRepresentations(){
73 69

  
74
    public TypeDesignationConverter buildString(){
75

  
76
        typeDesignations.forEach(td -> putString(td.getTypeStatus(), stringify(td)));
77

  
78
        StringBuilder sb = new StringBuilder();
79

  
80
        if(typifiedNameCache != null){
81
            sb.append(typifiedNameCache).append(": ");
82
        }
83
        List<TypeDesignationStatusBase<?>> keyList = new LinkedList<>(orderedStrings.keySet());
70
        List<TypeDesignationStatusBase<?>> keyList = new LinkedList<>(orderedStringsByType.keySet());
84 71

  
85 72
        Collections.sort(keyList, new Comparator<TypeDesignationStatusBase>() {
86 73
            @Override
......
90 77
            }
91 78
        });
92 79

  
80
        keyList.forEach(key -> orderedRepresentations.put(getTypeDesignationStytusLabel(key), orderedStringsByType.get(key)));
81
        return orderedRepresentations;
82
    }
83

  
84
    public TypeDesignationConverter buildString(){
85

  
86
        StringBuilder sb = new StringBuilder();
87

  
88
        if(getTypifiedNameCache() != null){
89
            sb.append(getTypifiedNameCache()).append(": ");
90
        }
91

  
92
        List<String> keyList = new LinkedList<>(orderedRepresentations.keySet());
93

  
94

  
93 95
        keyList.forEach(key -> {
94
            if(key.equals( SpecimenTypeDesignationStatus.TYPE())){
95
                sb.append("Type");
96
            } else {
97
                sb.append(key.getPreferredRepresentation(Language.DEFAULT()));
98
            }
99
            sb.append(": ");
100
            orderedStrings.get(key).forEach(str -> {
101
                sb.append(str);
96
            sb.append(key).append(": ");
97
            orderedRepresentations.get(key).forEach(isAndString -> {
98
                sb.append(isAndString.getLabel());
102 99
                if(sb.length() > 0){
103 100
                    sb.append(separator);
104 101
                }
......
109 106
        return this;
110 107
    }
111 108

  
109
    public Map<String, Collection<IdAndString>> getOrderedTypeDesignationRepresentations() {
110
        return orderedRepresentations;
111
    }
112

  
113
    /**
114
     * FIXME use the validation framework validators and to store the validation problems!!!
115
     *
116
     * @return
117
     * @throws RegistrationValidationException
118
     */
119
    private IdAndString findTypifiedName() throws RegistrationValidationException {
120

  
121
        List<String> problems = new ArrayList<>();
122

  
123
        TaxonNameBase<?,?> typifiedName = null;
124

  
125
        for(TypeDesignationBase<?> typeDesignation : typeDesignations){
126
            typeDesignation.getTypifiedNames();
127
            if(typeDesignation.getTypifiedNames().isEmpty()){
128

  
129
                //TODO instead throw RegistrationValidationException()
130
                problems.add("Missing typifiedName in " + typeDesignation.toString());
131
                continue;
132
            }
133
            if(typeDesignation.getTypifiedNames().size() > 1){
134
              //TODO instead throw RegistrationValidationException()
135
                problems.add("Multiple typifiedName in " + typeDesignation.toString());
136
                continue;
137
            }
138
            if(typifiedName == null){
139
                // remember
140
                typifiedName = typeDesignation.getTypifiedNames().iterator().next();
141
            } else {
142
                // compare
143
                TaxonNameBase<?,?> otherTypifiedName = typeDesignation.getTypifiedNames().iterator().next();
144
                if(typifiedName.getId() != otherTypifiedName.getId()){
145
                  //TODO instead throw RegistrationValidationException()
146
                    problems.add("Multiple typifiedName in " + typeDesignation.toString());
147
                }
148
            }
149

  
150
        }
151
        if(!problems.isEmpty()){
152
            // FIXME use the validation framework
153
            throw new RegistrationValidationException("Inconsistent type designations", problems);
154
        }
155

  
156
        if(typifiedName != null){
157
            return new IdAndString(typifiedName.getId(), typifiedName.getTitleCache());
158
        }
159
        return null;
160
    }
161

  
162

  
163
    /**
164
     * @return the title cache of the typifying name or <code>null</code>
165
     */
166
    public String getTypifiedNameCache() {
167
        if(typifiedName != null){
168
            return typifiedName.getLabel();
169
        }
170
        return null;
171
    }
172

  
173
    /**
174
     * @return the title cache of the typifying name or <code>null</code>
175
     */
176
    public IdAndString getTypifiedName() {
177

  
178
       return typifiedName;
179

  
180
    }
181

  
182
    /**
183
     * @param key
184
     * @return
185
     */
186
    protected String getTypeDesignationStytusLabel(TypeDesignationStatusBase<?> key) {
187
        String typeLable;
188
        if(key.equals( SpecimenTypeDesignationStatus.TYPE())){
189
            typeLable = "Type";
190
        } else {
191
            typeLable = key.getPreferredRepresentation(Language.DEFAULT()).getLabel();
192
        }
193
        return typeLable;
194
    }
195

  
112 196
    /**
113 197
     * @param td
114 198
     * @return
......
161 245

  
162 246
        if(td.getTypeSpecimen() != null){
163 247
            String nameTitleCache = td.getTypeSpecimen().getTitleCache();
164
            if(typifiedNameCache != null){
165
                nameTitleCache = nameTitleCache.replace(typifiedNameCache, "");
248
            if(getTypifiedNameCache() != null){
249
                nameTitleCache = nameTitleCache.replace(getTypifiedNameCache(), "");
166 250
            }
167 251
            sb.append(nameTitleCache);
168 252
        }
......
180 264
        return sb.toString();
181 265
    }
182 266

  
267
    private void putString(TypeDesignationStatusBase<?> status, IdAndString idAndString){
268
        // the cdm orderd term bases are ordered invers, fixing this for here
269
        if(status == null){
270
            status = SpecimenTypeDesignationStatus.TYPE();
271
        }
272
        if(!orderedStringsByType.containsKey(status)){
273
            orderedStringsByType.put(status, new ArrayList<IdAndString>());
274
        }
275
        orderedStringsByType.get(status).add(idAndString);
276
    }
277

  
183 278
    public String print(){
184 279
        return finalString;
185 280
    }
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/IdAndString.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
public class IdAndString {
12
    int id;
13
    String label;
14

  
15
    public IdAndString(int id, String label) {
16
        this.id = id;
17
        this.label = label;
18
    }
19

  
20
    public int getId() {
21
        return id;
22
    }
23

  
24
    public String getLabel() {
25
        return label;
26
    }
27
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationDTO.java
9 9
package eu.etaxonomy.cdm.vaadin.view.registration;
10 10

  
11 11
import java.util.ArrayList;
12
import java.util.Collection;
12 13
import java.util.HashSet;
13 14
import java.util.List;
15
import java.util.Map;
14 16
import java.util.Set;
15 17
import java.util.UUID;
16 18

  
......
21 23
import eu.etaxonomy.cdm.model.common.TimePeriod;
22 24
import eu.etaxonomy.cdm.model.name.Registration;
23 25
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
24
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
25 26
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
26 27
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
27 28
import eu.etaxonomy.cdm.model.reference.IReference;
......
41 42

  
42 43
    private String submitterUserName = null;
43 44

  
45
    private IdAndString name = null;
46

  
47
    private TypeDesignationConverter typeDesignationConverter;
48

  
44 49
    private Registration reg;
45 50

  
46 51
    private List<String> messages = new ArrayList<>();
47 52

  
48 53
    private Set<eu.etaxonomy.cdm.model.name.Registration> blockedBy = new HashSet<>();
49 54

  
50
    private TaxonNameBase<?, ?> typifiedName;
51 55

  
52 56
    /**
53 57
     * @param reg
54 58
     * @param typifiedName should be provided in for Registrations for TypeDesignations
59
     * @throws RegistrationValidationException
55 60
     */
56 61
    public RegistrationDTO(Registration reg) {
57 62

  
......
66 71
        if(hasName(reg)){
67 72
            citation = reg.getName().getNomenclaturalReference();
68 73
            citationDetail = reg.getName().getNomenclaturalMicroReference();
74
            name = new IdAndString(reg.getName().getId(), reg.getName().getTitleCache());
69 75
        }
70 76
        if(hasTypifications(reg)){
71
            try {
72
                typifiedName = findTypifiedName();
73
            } catch (RegistrationValidationException e) {
74
                messages.add("Validation errors: " + e.getMessage());
75
            }
76 77
            if(!reg.getTypeDesignations().isEmpty()){
77
                if(citation == null) {
78
                    TypeDesignationBase first = reg.getTypeDesignations().iterator().next();
79
                    citation = first.getCitation();
80
                    citationDetail = first.getCitationMicroReference();
78
                for(TypeDesignationBase td : reg.getTypeDesignations()){
79
                    if(citation == null) {
80
                        citation = td.getCitation();
81
                        citationDetail = td.getCitationMicroReference();
82
                    }
81 83
                }
82 84
            }
83 85
        }
......
91 93
        case NAME_AND_TYPIFICATION:
92 94
        case TYPIFICATION:
93 95
        default:
94
            summary = new TypeDesignationConverter(reg.getTypeDesignations(), typifiedName).buildString().print();
96
            try {
97
                typeDesignationConverter = new TypeDesignationConverter(reg.getTypeDesignations());
98
                summary = typeDesignationConverter.buildString().print();
99
            } catch (RegistrationValidationException e) {
100
                messages.add("Validation errors: " + e.getMessage());
101
            }
95 102
            break;
96 103
        }
97 104

  
......
116 123
        return reg.getName() != null;
117 124
    }
118 125

  
119
    /**
120
     * FIXME use the validation framework validators and to store the validation problems!!!
121
     *
122
     * @return
123
     * @throws RegistrationValidationException
124
     */
125
    private TaxonNameBase<?,?> findTypifiedName() throws RegistrationValidationException {
126

  
127
        List<String> problems = new ArrayList<>();
128

  
129
        TaxonNameBase<?,?> typifiedName = null;
130

  
131
        for(TypeDesignationBase<?> typeDesignation : reg.getTypeDesignations()){
132
            typeDesignation.getTypifiedNames();
133
            if(typeDesignation.getTypifiedNames().isEmpty()){
134

  
135
                //TODO instead throw RegistrationValidationException()
136
                problems.add("Missing typifiedName in " + typeDesignation.toString());
137
                continue;
138
            }
139
            if(typeDesignation.getTypifiedNames().size() > 1){
140
              //TODO instead throw RegistrationValidationException()
141
                problems.add("Multiple typifiedName in " + typeDesignation.toString());
142
                continue;
143
            }
144
            if(typifiedName == null){
145
                // remember
146
                typifiedName = typeDesignation.getTypifiedNames().iterator().next();
147
            } else {
148
                // compare
149
                TaxonNameBase<?,?> otherTypifiedName = typeDesignation.getTypifiedNames().iterator().next();
150
                if(typifiedName.getId() != otherTypifiedName.getId()){
151
                  //TODO instead throw RegistrationValidationException()
152
                    problems.add("Multiple typifiedName in " + typeDesignation.toString());
153
                }
154
            }
155

  
156
        }
157
        if(!problems.isEmpty()){
158
            // FIXME use the validation framework
159
            throw new RegistrationValidationException("Inconsistent Registration entity. " + reg.toString(), problems);
160
        }
161

  
162
        return typifiedName;
163
    }
164 126

  
165 127
    /**
166 128
     * Provides access to the Registration entity this DTO has been build from.
......
259 221
        return citation == null ? null : citation.getId();
260 222
    }
261 223

  
224
    public IdAndString getTypifiedName() {
225
        return typeDesignationConverter != null ? typeDesignationConverter.getTypifiedName() : null;
226
    }
227

  
228
    public IdAndString getName() {
229
        return name;
230
    }
231

  
232
    public Map<String, Collection<IdAndString>> getTypeDesignations() {
233
        return typeDesignationConverter != null ? typeDesignationConverter.getOrderedTypeDesignationRepresentations() : null;
234
    }
235

  
262 236
    /**
263 237
     * @return the citationString
264 238
     */
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowViewBean.java
26 26
import com.vaadin.ui.Component;
27 27
import com.vaadin.ui.CssLayout;
28 28
import com.vaadin.ui.GridLayout;
29
import com.vaadin.ui.Label;
30 29
import com.vaadin.ui.Notification;
31 30
import com.vaadin.ui.Panel;
32 31
import com.vaadin.ui.TabSheet;
......
34 33
import com.vaadin.ui.themes.ValoTheme;
35 34

  
36 35
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItem;
36
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemEditButtonGroup;
37 37
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles;
38 38
import eu.etaxonomy.cdm.vaadin.component.registration.TypeStateLabel;
39 39
import eu.etaxonomy.cdm.vaadin.component.registration.WorkflowSteps;
......
194 194
        GridLayout namesTypesList = new GridLayout(3, workingset.getRegistrationDTOs().size());
195 195
        int row = 0;
196 196
        for(RegistrationDTO dto : workingset.getRegistrationDTOs()) {
197

  
198
            CssLayout buttonGroup = new CssLayout();
199
            buttonGroup.setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
200

  
201
            Button messageButton = new Button(FontAwesome.COMMENT);
202
            messageButton.setStyleName(ValoTheme.BUTTON_TINY); //  + " " + RegistrationStyles.STYLE_FRIENDLY_FOREGROUND);
203
            if(dto.getMessages().isEmpty()){
204
                messageButton.setEnabled(false);
205
            } else {
206
                messageButton.addClickListener(e -> eventBus.publishEvent(
207
                        new ShowDetailsEvent<RegistrationDTO, Integer>(
208
                            e,
209
                            RegistrationDTO.class,
210
                            dto.getId(),
211
                            "messages"
212
                            )
213
                        )
214
                    );
215
            }
216
            messageButton.setCaption("<span class=\"" + RegistrationStyles.BUTTON_BADGE +"\"> " + dto.getMessages().size() + "</span>");
217
            messageButton.setCaptionAsHtml(true);
218
            buttonGroup.addComponent(messageButton);
219

  
220
            if(UserHelper.userIsRegistrationCurator() || UserHelper.userIsAdmin()) {
221
            Button editButton = new Button(FontAwesome.EDIT);
222
            editButton.setStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_PRIMARY);
223
            editButton.addClickListener(e -> getEventBus().publishEvent(new RegistrationEditorAction(
224
                AbstractEditorAction.Type.EDIT,
225
                dto.getId()
226
                )));
227
            buttonGroup.addComponent(editButton);
228
            }
229

  
230
            namesTypesList.addComponent(new TypeStateLabel().update(dto.getRegistrationType(), dto.getStatus()), 0, row);
231
            namesTypesList.addComponent(new Label(dto.getSummary()), 1, row);
232
            namesTypesList.addComponent(buttonGroup, 2, row);
233
            namesTypesList.setComponentAlignment(buttonGroup, Alignment.TOP_RIGHT);
234
            row++;
197
            registrationListComponent(namesTypesList, row++, dto);
235 198
        }
199

  
236 200
        namesTypesList.setSizeUndefined();
237 201
        namesTypesList.setWidth(100, Unit.PERCENTAGE);
238 202
        namesTypesList.setColumnExpandRatio(0, 0.1f);
......
242 206
        return namesTypesPanel;
243 207
    }
244 208

  
209
    /**
210
     * @param namesTypesList
211
     * @param row
212
     * @param dto
213
     */
214
    protected void registrationListComponent(GridLayout namesTypesList, int row, RegistrationDTO dto) {
215
        CssLayout buttonGroup = new CssLayout();
216
        buttonGroup.setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
217

  
218
        Button messageButton = new Button(FontAwesome.COMMENT);
219
        messageButton.setStyleName(ValoTheme.BUTTON_TINY); //  + " " + RegistrationStyles.STYLE_FRIENDLY_FOREGROUND);
220
        if(dto.getMessages().isEmpty()){
221
            messageButton.setEnabled(false);
222
        } else {
223
            messageButton.addClickListener(e -> eventBus.publishEvent(
224
                    new ShowDetailsEvent<RegistrationDTO, Integer>(
225
                        e,
226
                        RegistrationDTO.class,
227
                        dto.getId(),
228
                        "messages"
229
                        )
230
                    )
231
                );
232
        }
233
        messageButton.setCaption("<span class=\"" + RegistrationStyles.BUTTON_BADGE +"\"> " + dto.getMessages().size() + "</span>");
234
        messageButton.setCaptionAsHtml(true);
235
        buttonGroup.addComponent(messageButton);
236

  
237
        if(UserHelper.userIsRegistrationCurator() || UserHelper.userIsAdmin()) {
238
        Button editButton = new Button(FontAwesome.EDIT);
239
        editButton.setStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_PRIMARY);
240
        editButton.addClickListener(e -> getEventBus().publishEvent(new RegistrationEditorAction(
241
            AbstractEditorAction.Type.EDIT,
242
            dto.getId()
243
            )));
244
        buttonGroup.addComponent(editButton);
245
        }
246

  
247
        TypeStateLabel typeStateLabel = new TypeStateLabel().update(dto.getRegistrationType(), dto.getStatus());
248
        namesTypesList.addComponent(typeStateLabel, 0, row);
249
        namesTypesList.setComponentAlignment(typeStateLabel, Alignment.MIDDLE_LEFT);
250

  
251
        RegistrationItemEditButtonGroup editButtonGroup = new RegistrationItemEditButtonGroup(dto);
252
        // editButtonGroup.setStyleName(ValoTheme.BUTTON_TINY);
253
        namesTypesList.addComponent(editButtonGroup, 1, row);
254
        namesTypesList.addComponent(buttonGroup, 2, row);
255
        namesTypesList.setComponentAlignment(buttonGroup, Alignment.MIDDLE_LEFT);
256
    }
257

  
245 258

  
246 259
    /**
247 260
    *
src/main/java/eu/etaxonomy/vaadin/component/CompositeCustomField.java
25 25
 * @author a.kohlbecker
26 26
 * @since May 12, 2017
27 27
 *
28
 * IMPORTANT see also {@link CompositeStyledComponent} which has almost the same functionality.
29
 *
28 30
 */
29 31
@SuppressWarnings("serial")
30 32
public abstract class CompositeCustomField<T> extends CustomField<T> implements NestedFieldGroup {
src/main/java/eu/etaxonomy/vaadin/component/CompositeStyledComponent.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.vaadin.component;
10

  
11
import java.util.ArrayList;
12
import java.util.Arrays;
13
import java.util.List;
14

  
15
import com.vaadin.ui.Component;
16
import com.vaadin.ui.CssLayout;
17

  
18
/**
19
 * @author a.kohlbecker
20
 * @since May 22, 2017
21
 *
22
 * IMPORTANT see also {@link CompositeCustomField} which has almost the same functionality.
23
 *
24
 */
25
@SuppressWarnings("serial")
26
public abstract class CompositeStyledComponent extends CssLayout {
27

  
28
    //-------
29
    private List<Component> styledComponents = new ArrayList<>();
30

  
31
    protected List<Component> getStyledComponents() {
32
        if(styledComponents == null){
33
            styledComponents = new ArrayList<>();
34
        }
35
        return styledComponents;
36
    }
37

  
38
    @Override
39
    public void setStyleName(String style) {
40
        super.setStyleName(style);
41
        getStyledComponents().forEach(c -> c.setStyleName(style));
42
        addDefaultStyles();
43
    }
44

  
45
    @Override
46
    public void addStyleName(String style) {
47
        super.addStyleName(style);
48
        getStyledComponents().forEach(c -> c.addStyleName(style));
49
    }
50

  
51
    protected void applyCurrentStyleNames(Component newSubComponent){
52
        newSubComponent.setStyleName(getStyleName());
53
    }
54

  
55
    /**
56
     * Implementations preferably call this method in the constructor
57
     *
58
     * @param component
59
     * @return
60
     */
61
    protected boolean addStyledComponent(Component component){
62
        applyCurrentStyleNames(component);
63
        return styledComponents.add(component);
64
    }
65

  
66
    /**
67
     * Implementations preferably call this method in the constructor
68
     *
69
     * @param component
70
     * @return
71
     */
72
    protected boolean addStyledComponents(Component ... component){
73
        List<Component> componentList = Arrays.asList(component);
74
        componentList.forEach(c -> applyCurrentStyleNames(c));
75
        return styledComponents.addAll(componentList);
76
    }
77

  
78
    /**
79
     * Implementations can may apply default styles to components added to <code>StyledComponents</code>
80
     * to prevent these styles from being overwritten when setStyleName() id called on the composite field.
81
     */
82
    protected abstract void addDefaultStyles();
83
    //--------
84

  
85
}
src/main/webapp/VAADIN/themes/edit-valo/edit-valo.scss
237 237
            .registration-list, .registration-list-item {
238 238
                margin-top: round($v-unit-size / 2);
239 239
            }
240
        
241
            .registration-list {
242
                .v-gridlayout-slot {
243
                    border-bottom: valo-border($border: $v-border, $color: $v-background-color, $strength: 1.4);
244
                }
245
            }
240 246
    }
241 247

  
242 248
    // --------------------------------------------------- //
......
399 405
                color: $status-ready-color;
400 406
            }
401 407
        }
408

  
409
    }
410
    
411
    // ---------------- custom components ----------------------- //
412
    
413
    .edit-button-group {
414
        margin-top: round($v-unit-size/10);
415
        .v-button {
416
            padding: 0 round($v-unit-size/4);
417
            // margin: 0 round($v-unit-size/4);
418
        }
402 419
    }
420
    
403 421

  
404 422

  
405 423
}
src/test/java/eu/etaxonomy/cdm/vaadin/util/converter/TypeDesignationConverterTest.java
28 28
import eu.etaxonomy.cdm.model.reference.Reference;
29 29
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
30 30
import eu.etaxonomy.cdm.vaadin.CdmVaadinBaseTest;
31
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationValidationException;
31 32

  
32 33
/**
33 34
 * @author a.kohlbecker
......
38 39

  
39 40

  
40 41
    @Test
41
    public void test1(){
42
    public void test1() throws RegistrationValidationException{
42 43

  
43 44
        NameTypeDesignation ntd = NameTypeDesignation.NewInstance();
44 45
        TaxonNameBase typeName = TaxonNameFactory.NewBacterialInstance(Rank.SPECIES());
......
58 59
        tds.add(ntd);
59 60
        tds.add(std);
60 61

  
61
        String result = new TypeDesignationConverter(tds, null).buildString().print();
62
        String result = new TypeDesignationConverter(tds).buildString().print();
62 63
        Logger.getLogger(this.getClass()).debug(result);
63 64
        assertNotNull(result);
64 65
    }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)