Revision 1b3f0d8c
Added by Andreas Kohlbecker about 5 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/component/BadgeButton.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2019 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; |
|
10 |
|
|
11 |
import com.vaadin.server.Resource; |
|
12 |
import com.vaadin.ui.Button; |
|
13 |
|
|
14 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles; |
|
15 |
|
|
16 |
/** |
|
17 |
* A button with badge. The caption of the Button is shown inside the badge. |
|
18 |
* |
|
19 |
* @author a.kohlbecker |
|
20 |
* @since Feb 7, 2019 |
|
21 |
* |
|
22 |
*/ |
|
23 |
public class BadgeButton extends Button { |
|
24 |
|
|
25 |
private static final long serialVersionUID = -6408645355930129935L; |
|
26 |
|
|
27 |
String badgeCaption = null; |
|
28 |
|
|
29 |
|
|
30 |
/** |
|
31 |
* |
|
32 |
*/ |
|
33 |
public BadgeButton() { |
|
34 |
super(); |
|
35 |
setCaptionAsHtml(true); |
|
36 |
} |
|
37 |
|
|
38 |
/** |
|
39 |
* @param icon |
|
40 |
*/ |
|
41 |
public BadgeButton(Resource icon) { |
|
42 |
super(icon); |
|
43 |
} |
|
44 |
|
|
45 |
/** |
|
46 |
* @param caption |
|
47 |
* @param listener |
|
48 |
*/ |
|
49 |
public BadgeButton(String caption, ClickListener listener) { |
|
50 |
super(caption, listener); |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* @param caption |
|
55 |
* @param icon |
|
56 |
*/ |
|
57 |
public BadgeButton(String caption, Resource icon) { |
|
58 |
super(caption, icon); |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* @param caption |
|
63 |
*/ |
|
64 |
public BadgeButton(String caption) { |
|
65 |
super(caption); |
|
66 |
} |
|
67 |
|
|
68 |
@Override |
|
69 |
public String getCaption() { |
|
70 |
return badgeCaption; |
|
71 |
} |
|
72 |
|
|
73 |
@Override |
|
74 |
public void setCaption(String caption) { |
|
75 |
setCaptionAsHtml(true); |
|
76 |
super.setCaption("<span class=\"" + RegistrationStyles.BUTTON_BADGE +"\"> " + caption + "</span>"); |
|
77 |
} |
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItem.java | ||
---|---|---|
43 | 43 |
import eu.etaxonomy.cdm.model.reference.Reference; |
44 | 44 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD; |
45 | 45 |
import eu.etaxonomy.cdm.service.UserHelperAccess; |
46 |
import eu.etaxonomy.cdm.vaadin.component.BadgeButton; |
|
46 | 47 |
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction; |
47 | 48 |
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent; |
48 | 49 |
import eu.etaxonomy.cdm.vaadin.permission.PermissionDebugUtils; |
... | ... | |
88 | 89 |
private RegistrationStatusLabel stateLabel = new RegistrationStatusLabel(); |
89 | 90 |
private Link identifierLink = new Link(); |
90 | 91 |
private Label citationSummaryLabel = new Label(); |
91 |
private Button blockedByButton = new Button(FontAwesome.WARNING);
|
|
92 |
private Button validationProblemsButton; |
|
92 |
private Button blockedByButton = new Button(FontAwesome.BAN);
|
|
93 |
private BadgeButton validationProblemsButton;
|
|
93 | 94 |
private Button openButton = new Button(FontAwesome.COGS); |
94 | 95 |
private Label submitterLabel = new Label(); |
95 | 96 |
private Label createdLabel = new Label(); |
... | ... | |
144 | 145 |
setComponentAlignment(identifierLink, Alignment.TOP_CENTER); |
145 | 146 |
setColumnExpandRatio(1, 1.0f); |
146 | 147 |
|
147 |
validationProblemsButton = new Button(FontAwesome.COMMENT);
|
|
148 |
validationProblemsButton = new BadgeButton(FontAwesome.WARNING);
|
|
148 | 149 |
CssLayout buttonGroup = new CssLayout(blockedByButton, validationProblemsButton, openButton); |
149 | 150 |
blockedByButton.setStyleName(ValoTheme.BUTTON_TINY); |
150 | 151 |
blockedByButton.setEnabled(false); |
... | ... | |
250 | 251 |
StringBuffer labelMarkup = new StringBuffer(); |
251 | 252 |
DateTime registrationDate = null; |
252 | 253 |
|
253 |
if(validationProblemsCount > 0){ |
|
254 |
if(validationProblemsCount + 1 > 0){
|
|
254 | 255 |
getValidationProblemsButton().setEnabled(true); |
255 | 256 |
// getMessageButton().addStyleName(RegistrationStyles.STYLE_FRIENDLY_FOREGROUND); |
256 | 257 |
getValidationProblemsButton().addClickListener(e -> { |
... | ... | |
271 | 272 |
publishEvent(detailsEvent); |
272 | 273 |
} |
273 | 274 |
); |
274 |
getValidationProblemsButton().setCaption("<span class=\"" + RegistrationStyles.BUTTON_BADGE +"\"> " + validationProblemsCount + "</span>"); |
|
275 |
getValidationProblemsButton().setCaptionAsHtml(true); |
|
275 |
getValidationProblemsButton().setCaption(Integer.toString(validationProblemsCount + 1)); |
|
276 | 276 |
} |
277 | 277 |
|
278 | 278 |
if(regDto != null && regDto.isBlocked()){ |
... | ... | |
396 | 396 |
/** |
397 | 397 |
* @return the validationProblemsButton |
398 | 398 |
*/ |
399 |
public Button getValidationProblemsButton() { |
|
399 |
public BadgeButton getValidationProblemsButton() {
|
|
400 | 400 |
return validationProblemsButton; |
401 | 401 |
} |
402 | 402 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItemButtons.java | ||
---|---|---|
13 | 13 |
import com.vaadin.ui.CssLayout; |
14 | 14 |
import com.vaadin.ui.themes.ValoTheme; |
15 | 15 |
|
16 |
import eu.etaxonomy.cdm.vaadin.component.BadgeButton; |
|
17 |
|
|
16 | 18 |
/** |
17 | 19 |
* @author a.kohlbecker |
18 | 20 |
* @since Feb 27, 2018 |
... | ... | |
25 | 27 |
|
26 | 28 |
Button blockingRegistrationButton; |
27 | 29 |
|
28 |
Button validationProblemsButton; |
|
30 |
BadgeButton validationProblemsButton;
|
|
29 | 31 |
|
30 | 32 |
public RegistrationItemButtons() { |
31 | 33 |
|
... | ... | |
34 | 36 |
blockingRegistrationButton = new Button(FontAwesome.BAN); |
35 | 37 |
blockingRegistrationButton.setEnabled(false); |
36 | 38 |
|
37 |
validationProblemsButton = new Button(FontAwesome.WARNING); |
|
39 |
validationProblemsButton = new BadgeButton(FontAwesome.WARNING);
|
|
38 | 40 |
validationProblemsButton.setEnabled(false); |
39 | 41 |
|
40 | 42 |
addComponents(blockingRegistrationButton, validationProblemsButton); |
... | ... | |
50 | 52 |
/** |
51 | 53 |
* @return the validationProblemsButton |
52 | 54 |
*/ |
53 |
public Button getValidationProblemsButton() { |
|
55 |
public BadgeButton getValidationProblemsButton() {
|
|
54 | 56 |
return validationProblemsButton; |
55 | 57 |
} |
56 | 58 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListViewBean.java | ||
---|---|---|
198 | 198 |
RegistrationItem item = new RegistrationItem(regDto, this, null); |
199 | 199 |
item.getSubmitterLabel().setVisible(isCurator); |
200 | 200 |
item.setWidth(100, Unit.PERCENTAGE); |
201 |
// TODO move addClickListener into RegistrationItem.updateUI where the clicklistener for the ValidationProblemsButton is set also? |
|
201 | 202 |
item.getBlockedByButton().addClickListener(e -> getViewEventBus().publish( |
202 | 203 |
this, |
203 | 204 |
new ShowDetailsEvent<Registration, UUID>( |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorksetViewBean.java | ||
---|---|---|
57 | 57 |
import eu.etaxonomy.cdm.ref.EntityReference; |
58 | 58 |
import eu.etaxonomy.cdm.ref.TypedEntityReference; |
59 | 59 |
import eu.etaxonomy.cdm.service.UserHelperAccess; |
60 |
import eu.etaxonomy.cdm.vaadin.component.BadgeButton; |
|
60 | 61 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItem; |
61 | 62 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemButtons; |
62 | 63 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemNameAndTypeButtons; |
... | ... | |
64 | 65 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemsPanel; |
65 | 66 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStatusFieldInstantiator; |
66 | 67 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStatusLabel; |
67 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles; |
|
68 | 68 |
import eu.etaxonomy.cdm.vaadin.event.EditorActionContext; |
69 | 69 |
import eu.etaxonomy.cdm.vaadin.event.RegistrationEditorAction; |
70 | 70 |
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent; |
... | ... | |
406 | 406 |
)); |
407 | 407 |
} |
408 | 408 |
|
409 |
Button validationProblemsButton = regItemButtons.getValidationProblemsButton(); |
|
409 |
BadgeButton validationProblemsButton = regItemButtons.getValidationProblemsButton();
|
|
410 | 410 |
validationProblemsButton.setStyleName(ValoTheme.BUTTON_TINY); // + " " + RegistrationStyles.STYLE_FRIENDLY_FOREGROUND); |
411 | 411 |
|
412 | 412 |
if(!dto.getValidationProblems().isEmpty()){ |
... | ... | |
421 | 421 |
) |
422 | 422 |
); |
423 | 423 |
} |
424 |
validationProblemsButton.setCaption("<span class=\"" + RegistrationStyles.BUTTON_BADGE +"\"> " + dto.getValidationProblems().size() + "</span>"); |
|
425 |
validationProblemsButton.setCaptionAsHtml(true); |
|
424 |
validationProblemsButton.setCaption(Integer.toString(dto.getValidationProblems().size())); |
|
426 | 425 |
|
427 | 426 |
Component statusComponent; |
428 | 427 |
if(statusFieldInstantiator != null){ |
Also available in: Unified diff
fix #8072 introducing component BadgeButton and harmonizing the blocking registration and validation problem buttons