Revision c7627153
Added by Andreas Kohlbecker about 7 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItem.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.component.registration; |
10 | 10 |
|
11 |
import static eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles.STYLE_LABEL_NOWRAP;
|
|
11 |
import static eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles.LABEL_NOWRAP; |
|
12 | 12 |
|
13 | 13 |
import org.joda.time.DateTime; |
14 | 14 |
import org.joda.time.format.ISODateTimeFormat; |
15 | 15 |
|
16 | 16 |
import com.vaadin.server.ExternalResource; |
17 | 17 |
import com.vaadin.server.FontAwesome; |
18 |
import com.vaadin.server.Resource; |
|
18 | 19 |
import com.vaadin.shared.ui.label.ContentMode; |
19 | 20 |
import com.vaadin.ui.Alignment; |
20 | 21 |
import com.vaadin.ui.Button; |
... | ... | |
25 | 26 |
import com.vaadin.ui.themes.ValoTheme; |
26 | 27 |
|
27 | 28 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
29 |
import eu.etaxonomy.cdm.vaadin.event.EntityEventType; |
|
30 |
import eu.etaxonomy.cdm.vaadin.event.ReferenceEvent; |
|
28 | 31 |
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent; |
29 | 32 |
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet; |
30 | 33 |
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationDTO; |
... | ... | |
62 | 65 |
private Link identifierLink = new Link(); |
63 | 66 |
private Label citationSummaryLabel = new Label(); |
64 | 67 |
private Button blockedByButton = new Button(FontAwesome.WARNING); |
65 |
private Button messageButton = new Button(FontAwesome.COMMENT);
|
|
68 |
private Button messageButton; |
|
66 | 69 |
private Button openButton = new Button(FontAwesome.COGS); |
67 | 70 |
private Label createdLabel = new Label(); |
68 | 71 |
private Label publishedLabel = new Label(); |
... | ... | |
94 | 97 |
setWidth(100, Unit.PERCENTAGE); |
95 | 98 |
addStyleName("registration-list-item"); |
96 | 99 |
|
97 |
typeStateLabel.setStyleName(STYLE_LABEL_NOWRAP);
|
|
100 |
typeStateLabel.setStyleName(LABEL_NOWRAP); |
|
98 | 101 |
typeStateLabel.setVisible(false); |
99 | 102 |
addComponent(typeStateLabel, 0, 0); |
100 | 103 |
setComponentAlignment(typeStateLabel, Alignment.TOP_LEFT); |
... | ... | |
104 | 107 |
setComponentAlignment(identifierLink, Alignment.TOP_CENTER); |
105 | 108 |
setColumnExpandRatio(1, 1.0f); |
106 | 109 |
|
110 |
messageButton = new Button(FontAwesome.COMMENT); |
|
107 | 111 |
CssLayout buttonGroup = new CssLayout(blockedByButton, messageButton, openButton); |
108 | 112 |
blockedByButton.setStyleName(ValoTheme.BUTTON_TINY); |
109 | 113 |
blockedByButton.setEnabled(false); |
110 | 114 |
messageButton.setStyleName(ValoTheme.BUTTON_TINY); |
111 | 115 |
messageButton.setEnabled(false); |
116 |
|
|
112 | 117 |
openButton.setStyleName(ValoTheme.BUTTON_TINY); |
113 | 118 |
openButton.addStyleName(ValoTheme.BUTTON_PRIMARY); |
114 | 119 |
openButton.setVisible(false); |
... | ... | |
120 | 125 |
citationSummaryLabel.setContentMode(ContentMode.HTML); |
121 | 126 |
addComponent(citationSummaryLabel, 0, 1, 1, 3); |
122 | 127 |
|
123 |
createdLabel.setStyleName(STYLE_LABEL_NOWRAP);
|
|
128 |
createdLabel.setStyleName(LABEL_NOWRAP); |
|
124 | 129 |
createdLabel.setContentMode(ContentMode.HTML); |
125 | 130 |
createdLabel.setWidthUndefined(); |
126 | 131 |
addComponent(createdLabel, 2, 1); |
127 | 132 |
setComponentAlignment(createdLabel, Alignment.BOTTOM_RIGHT); |
128 | 133 |
|
129 |
publishedLabel.setStyleName(STYLE_LABEL_NOWRAP);
|
|
134 |
publishedLabel.setStyleName(LABEL_NOWRAP); |
|
130 | 135 |
publishedLabel.setContentMode(ContentMode.HTML); |
131 | 136 |
publishedLabel.setWidthUndefined(); |
132 | 137 |
publishedLabel.setVisible(false); |
133 | 138 |
addComponent(publishedLabel, 2, 2); |
134 | 139 |
setComponentAlignment(publishedLabel, Alignment.BOTTOM_RIGHT); |
135 | 140 |
|
136 |
releasedLabel.setStyleName(STYLE_LABEL_NOWRAP);
|
|
141 |
releasedLabel.setStyleName(LABEL_NOWRAP); |
|
137 | 142 |
releasedLabel.setContentMode(ContentMode.HTML); |
138 | 143 |
releasedLabel.setWidthUndefined(); |
139 | 144 |
releasedLabel.setVisible(false); |
... | ... | |
144 | 149 |
|
145 | 150 |
public void setItem(RegistrationDTO regDto, AbstractView<?> parentView){ |
146 | 151 |
this.parentView = parentView; |
147 |
updateUI(regDto.getCitationString(), regDto.getCreated(), regDto.getDatePublished(), regDto.getMessages().size(), regDto); |
|
152 |
|
|
153 |
NavigationEvent openButtonEvent = new NavigationEvent( |
|
154 |
RegistrationWorkflowViewBean.NAME, |
|
155 |
RegistrationWorkflowViewBean.ACTION_EDIT, |
|
156 |
Integer.toString(regDto.getId()) |
|
157 |
); |
|
158 |
|
|
159 |
updateUI(regDto.getCitationString(), regDto.getCreated(), regDto.getDatePublished(), regDto.getMessages().size(), |
|
160 |
openButtonEvent, null, regDto); |
|
148 | 161 |
} |
149 | 162 |
|
150 | 163 |
public void setWorkingSet(RegistrationWorkingSet workingSet, AbstractView<?> parentView){ |
151 | 164 |
this.parentView = parentView; |
152 |
updateUI(workingSet.getCitation(), workingSet.getCreated(), null, workingSet.messagesCount(), null); |
|
165 |
ReferenceEvent openButtonEvent; |
|
166 |
if(workingSet.getCitationId() != null){ |
|
167 |
openButtonEvent = new ReferenceEvent(EntityEventType.EDIT, workingSet.getCitationId()); |
|
168 |
} else { |
|
169 |
openButtonEvent = new ReferenceEvent(EntityEventType.ADD); |
|
170 |
} |
|
171 |
updateUI(workingSet.getCitation(), workingSet.getCreated(), null, workingSet.messagesCount(), |
|
172 |
openButtonEvent, FontAwesome.EDIT, null); |
|
153 | 173 |
} |
154 | 174 |
|
155 | 175 |
|
156 | 176 |
/** |
157 | 177 |
* |
158 | 178 |
*/ |
159 |
private void updateUI(String citationString, DateTime created, TimePeriod datePublished, int messagesCount, RegistrationDTO regDto) { |
|
179 |
private void updateUI(String citationString, DateTime created, TimePeriod datePublished, int messagesCount, |
|
180 |
Object openButtonEvent, Resource openButtonIcon, RegistrationDTO regDto) { |
|
160 | 181 |
|
161 | 182 |
StringBuffer labelMarkup = new StringBuffer(); |
162 | 183 |
DateTime registrationDate = null; |
163 | 184 |
|
164 | 185 |
if(messagesCount > 0){ |
165 | 186 |
getMessageButton().setEnabled(true); |
166 |
getMessageButton().addStyleName(ValoTheme.BUTTON_FRIENDLY);
|
|
187 |
// getMessageButton().addStyleName(RegistrationStyles.STYLE_FRIENDLY_FOREGROUND);
|
|
167 | 188 |
getMessageButton().addClickListener(e -> { |
168 | 189 |
ShowDetailsEvent detailsEvent; |
169 | 190 |
if(regDto != null){ |
... | ... | |
182 | 203 |
publishEvent(detailsEvent); |
183 | 204 |
} |
184 | 205 |
); |
206 |
getMessageButton().setCaption("<span class=\"" + RegistrationStyles.BUTTON_BADGE +"\"> " + messagesCount + "</span>"); |
|
207 |
getMessageButton().setCaptionAsHtml(true); |
|
185 | 208 |
} |
186 | 209 |
|
187 | 210 |
labelMarkup.append(citationString); |
211 |
|
|
212 |
if(openButtonEvent != null){ |
|
213 |
// Buttons |
|
214 |
getOpenButton().setVisible(true); |
|
215 |
getOpenButton().addClickListener(e -> publishEvent(openButtonEvent)); |
|
216 |
} |
|
217 |
|
|
218 |
if(openButtonIcon != null){ |
|
219 |
getOpenButton().setIcon(openButtonIcon); |
|
220 |
} |
|
221 |
|
|
188 | 222 |
if(regDto != null){ |
189 | 223 |
labelMarkup.append("</br>").append(regDto.getSummary()); |
190 | 224 |
|
... | ... | |
195 | 229 |
getIdentifierLink().setVisible(true); |
196 | 230 |
getIdentifierLink().setCaption(regDto.getIdentifier()); |
197 | 231 |
|
198 |
// Buttons |
|
199 |
getOpenButton().setVisible(true); |
|
200 |
getOpenButton().addClickListener(e -> publishEvent(new NavigationEvent( |
|
201 |
RegistrationWorkflowViewBean.NAME, |
|
202 |
RegistrationWorkflowViewBean.ACTION_EDIT, |
|
203 |
Integer.toString(regDto.getId()) |
|
204 |
))); |
|
205 |
|
|
206 | 232 |
registrationDate = regDto.getRegistrationDate(); |
207 | 233 |
} |
208 | 234 |
|
235 |
|
|
209 | 236 |
getCitationSummaryLabel().setValue(labelMarkup.toString()); |
210 | 237 |
updateDateLabels(created, datePublished, registrationDate); |
211 | 238 |
} |
Also available in: Unified diff
ref #6169 message count indicator, edit reference button and impoved layout