Revision 4b501287
Added by Andreas Kohlbecker about 7 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/component/phycobank/RegistrationItem.java | ||
---|---|---|
13 | 13 |
|
14 | 14 |
import com.vaadin.server.ExternalResource; |
15 | 15 |
import com.vaadin.server.FontAwesome; |
16 |
import com.vaadin.shared.ui.label.ContentMode; |
|
17 |
import com.vaadin.ui.Alignment; |
|
16 | 18 |
import com.vaadin.ui.Button; |
19 |
import com.vaadin.ui.CssLayout; |
|
20 |
import com.vaadin.ui.GridLayout; |
|
17 | 21 |
import com.vaadin.ui.Label; |
18 | 22 |
import com.vaadin.ui.Link; |
23 |
import com.vaadin.ui.themes.ValoTheme; |
|
19 | 24 |
|
20 |
import eu.etaxonomy.cdm.vaadin.design.phycobank.RegistrationItemDesign; |
|
21 | 25 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.RegistrationDTO; |
22 | 26 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.RegistrationType; |
23 | 27 |
import eu.etaxonomy.cdm.vaadin.view.phycobank.RegistrationTypeConverter; |
... | ... | |
30 | 34 |
* @since Mar 17, 2017 |
31 | 35 |
* |
32 | 36 |
*/ |
33 |
public class RegistrationItem extends RegistrationItemDesign { |
|
37 |
public class RegistrationItem extends GridLayout { |
|
38 |
|
|
39 |
|
|
40 |
private static final String LABEL_CAPTION_CREATED = "Created"; |
|
41 |
|
|
42 |
private static final String LABEL_CAPTION_PUBLISHED = "Published"; |
|
43 |
|
|
44 |
private static final int GRID_ROWS = 3; |
|
45 |
|
|
46 |
private static final int GRID_COLS = 3; |
|
47 |
|
|
48 |
private static final String STYLE_LABEL_NOWRAP = "label-nowrap"; |
|
34 | 49 |
|
35 | 50 |
private static final long serialVersionUID = -211003770452173644L; |
36 | 51 |
|
... | ... | |
40 | 55 |
|
41 | 56 |
private AbstractView<?> parentView; |
42 | 57 |
|
58 |
// -------------------------------------------------- |
|
59 |
private Label typeStateLabel = new Label(); |
|
60 |
private Link identifierLink = new Link(); |
|
61 |
private Label citationSummaryLabel = new Label(); |
|
62 |
private Button blockedByButton = new Button(FontAwesome.WARNING); |
|
63 |
private Button messageButton = new Button(FontAwesome.COMMENT); |
|
64 |
private Button openButton = new Button(FontAwesome.COGS); |
|
65 |
private Label createdLabel = new Label(); |
|
66 |
private Label publishedLabel = new Label(); |
|
67 |
// -------------------------------------------------- |
|
68 |
|
|
43 | 69 |
/** |
44 | 70 |
* |
45 | 71 |
*/ |
46 | 72 |
public RegistrationItem(RegistrationDTO item, AbstractView<?> parentView) { |
47 |
super(); |
|
73 |
super(GRID_COLS, GRID_ROWS); |
|
74 |
init(); |
|
48 | 75 |
setItem(item, parentView); |
49 | 76 |
} |
50 | 77 |
|
78 |
public void init() { |
|
79 |
|
|
80 |
setId("registration-list"); |
|
81 |
setWidth(100, Unit.PERCENTAGE); |
|
82 |
addStyleName("registration-item"); |
|
83 |
|
|
84 |
typeStateLabel.setStyleName(STYLE_LABEL_NOWRAP); |
|
85 |
addComponent(typeStateLabel, 0, 0); |
|
86 |
setComponentAlignment(typeStateLabel, Alignment.MIDDLE_LEFT); |
|
87 |
|
|
88 |
addComponent(identifierLink, 1, 0); |
|
89 |
setComponentAlignment(identifierLink, Alignment.TOP_CENTER); |
|
90 |
setColumnExpandRatio(1, 1.0f); |
|
91 |
|
|
92 |
CssLayout buttonGroup = new CssLayout(blockedByButton, messageButton, openButton); |
|
93 |
blockedByButton.setStyleName(ValoTheme.BUTTON_TINY); |
|
94 |
blockedByButton.setEnabled(false); |
|
95 |
messageButton.setStyleName(ValoTheme.BUTTON_TINY); |
|
96 |
messageButton.setEnabled(false); |
|
97 |
openButton.setStyleName(ValoTheme.BUTTON_TINY); |
|
98 |
openButton.addStyleName(ValoTheme.BUTTON_PRIMARY); |
|
99 |
buttonGroup.setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); |
|
100 |
addComponent(buttonGroup, 2, 0); |
|
101 |
setComponentAlignment(buttonGroup, Alignment.TOP_RIGHT); |
|
102 |
|
|
103 |
citationSummaryLabel.setContentMode(ContentMode.HTML); |
|
104 |
addComponent(citationSummaryLabel, 0, 1, 1, 2); |
|
105 |
|
|
106 |
createdLabel.setStyleName(STYLE_LABEL_NOWRAP); |
|
107 |
createdLabel.setContentMode(ContentMode.HTML); |
|
108 |
addComponent(createdLabel, 2, 1); |
|
109 |
setComponentAlignment(createdLabel, Alignment.BOTTOM_RIGHT); |
|
110 |
|
|
111 |
publishedLabel.setStyleName(STYLE_LABEL_NOWRAP); |
|
112 |
publishedLabel.setContentMode(ContentMode.HTML); |
|
113 |
addComponent(publishedLabel, 2, 2); |
|
114 |
setComponentAlignment(publishedLabel, Alignment.BOTTOM_RIGHT); |
|
115 |
|
|
116 |
} |
|
117 |
|
|
51 | 118 |
public void setItem(RegistrationDTO item, AbstractView<?> parentView){ |
52 | 119 |
regDto = item; |
53 | 120 |
this.parentView = parentView; |
... | ... | |
60 | 127 |
*/ |
61 | 128 |
private void updateUI() { |
62 | 129 |
updateTypeStateLabel(); |
63 |
getCitationLabel().setValue(regDto.getCitationString()); |
|
64 |
getSummaryLabel().setValue(regDto.getSummary()); |
|
130 |
getCitationSummaryLabel().setValue(regDto.getCitationString() + "</br>" + regDto.getSummary()); |
|
65 | 131 |
updateIdentifierLink(); |
66 | 132 |
getOpenButton().addClickListener(e -> parentView.getEventBus().publishEvent(new NavigationEvent( |
67 | 133 |
RegistrationWorkflowViewBean.NAME, |
... | ... | |
85 | 151 |
} else { |
86 | 152 |
icon = FontAwesome.WARNING; |
87 | 153 |
} |
88 |
typeStateLabel.setIcon(icon);
|
|
89 |
typeStateLabel.setValue(StringUtils.capitalize((regDto.getStatus().name().toLowerCase()))); |
|
154 |
typeStateLabel.setContentMode(ContentMode.HTML);
|
|
155 |
typeStateLabel.setValue(icon.getHtml() + " " + StringUtils.capitalize((regDto.getStatus().name().toLowerCase())));
|
|
90 | 156 |
typeStateLabel.addStyleName("status-" + regDto.getStatus().name()); |
91 | 157 |
} |
92 | 158 |
|
... | ... | |
103 | 169 |
* |
104 | 170 |
*/ |
105 | 171 |
private void updateDateLabels() { |
106 |
getCreatedLabel().setDescription(regDto.getCreated().toString(ISODateTimeFormat.yearMonthDay()));
|
|
172 |
getCreatedLabel().setValue("<span class=\"caption\">" + LABEL_CAPTION_CREATED + "</span> " + regDto.getCreated().toString(ISODateTimeFormat.yearMonthDay()));
|
|
107 | 173 |
if(regDto.getRegistrationDate() != null){ |
108 |
getPublishedLabel().setDescription(regDto.getRegistrationDate().toString(ISODateTimeFormat.yearMonthDay()));
|
|
174 |
getPublishedLabel().setValue("<span class=\"caption\">" + LABEL_CAPTION_PUBLISHED + "</span> " + regDto.getRegistrationDate().toString(ISODateTimeFormat.yearMonthDay()));
|
|
109 | 175 |
} else { |
110 | 176 |
getPublishedLabel().setVisible(false); |
111 | 177 |
} |
112 |
|
|
113 | 178 |
} |
114 | 179 |
|
115 | 180 |
/* ====== RegistrationItemDesign Getters ====== */ |
... | ... | |
128 | 193 |
} |
129 | 194 |
|
130 | 195 |
/** |
131 |
* @return the citationLabel |
|
132 |
*/ |
|
133 |
public Label getCitationLabel() { |
|
134 |
return citationLabel; |
|
135 |
} |
|
136 |
|
|
137 |
/** |
|
138 |
* @return the summaryLabel |
|
196 |
* @return the citationSummaryLabel |
|
139 | 197 |
*/ |
140 |
public Label getSummaryLabel() { |
|
141 |
return summaryLabel;
|
|
198 |
public Label getCitationSummaryLabel() {
|
|
199 |
return citationSummaryLabel;
|
|
142 | 200 |
} |
143 | 201 |
|
144 | 202 |
/** |
Also available in: Unified diff
ref #6169 UI preformance improvement for RegistrationItems