*/
package eu.etaxonomy.cdm.vaadin.component.registration;
-import static eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles.STYLE_LABEL_NOWRAP;
+import static eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles.LABEL_NOWRAP;
import org.joda.time.DateTime;
import org.joda.time.format.ISODateTimeFormat;
import com.vaadin.server.ExternalResource;
import com.vaadin.server.FontAwesome;
+import com.vaadin.server.Resource;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.themes.ValoTheme;
import eu.etaxonomy.cdm.model.common.TimePeriod;
+import eu.etaxonomy.cdm.vaadin.event.EntityEventType;
+import eu.etaxonomy.cdm.vaadin.event.ReferenceEvent;
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationDTO;
private Link identifierLink = new Link();
private Label citationSummaryLabel = new Label();
private Button blockedByButton = new Button(FontAwesome.WARNING);
- private Button messageButton = new Button(FontAwesome.COMMENT);
+ private Button messageButton;
private Button openButton = new Button(FontAwesome.COGS);
private Label createdLabel = new Label();
private Label publishedLabel = new Label();
setWidth(100, Unit.PERCENTAGE);
addStyleName("registration-list-item");
- typeStateLabel.setStyleName(STYLE_LABEL_NOWRAP);
+ typeStateLabel.setStyleName(LABEL_NOWRAP);
typeStateLabel.setVisible(false);
addComponent(typeStateLabel, 0, 0);
setComponentAlignment(typeStateLabel, Alignment.TOP_LEFT);
setComponentAlignment(identifierLink, Alignment.TOP_CENTER);
setColumnExpandRatio(1, 1.0f);
+ messageButton = new Button(FontAwesome.COMMENT);
CssLayout buttonGroup = new CssLayout(blockedByButton, messageButton, openButton);
blockedByButton.setStyleName(ValoTheme.BUTTON_TINY);
blockedByButton.setEnabled(false);
messageButton.setStyleName(ValoTheme.BUTTON_TINY);
messageButton.setEnabled(false);
+
openButton.setStyleName(ValoTheme.BUTTON_TINY);
openButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
openButton.setVisible(false);
citationSummaryLabel.setContentMode(ContentMode.HTML);
addComponent(citationSummaryLabel, 0, 1, 1, 3);
- createdLabel.setStyleName(STYLE_LABEL_NOWRAP);
+ createdLabel.setStyleName(LABEL_NOWRAP);
createdLabel.setContentMode(ContentMode.HTML);
createdLabel.setWidthUndefined();
addComponent(createdLabel, 2, 1);
setComponentAlignment(createdLabel, Alignment.BOTTOM_RIGHT);
- publishedLabel.setStyleName(STYLE_LABEL_NOWRAP);
+ publishedLabel.setStyleName(LABEL_NOWRAP);
publishedLabel.setContentMode(ContentMode.HTML);
publishedLabel.setWidthUndefined();
publishedLabel.setVisible(false);
addComponent(publishedLabel, 2, 2);
setComponentAlignment(publishedLabel, Alignment.BOTTOM_RIGHT);
- releasedLabel.setStyleName(STYLE_LABEL_NOWRAP);
+ releasedLabel.setStyleName(LABEL_NOWRAP);
releasedLabel.setContentMode(ContentMode.HTML);
releasedLabel.setWidthUndefined();
releasedLabel.setVisible(false);
public void setItem(RegistrationDTO regDto, AbstractView<?> parentView){
this.parentView = parentView;
- updateUI(regDto.getCitationString(), regDto.getCreated(), regDto.getDatePublished(), regDto.getMessages().size(), regDto);
+
+ NavigationEvent openButtonEvent = new NavigationEvent(
+ RegistrationWorkflowViewBean.NAME,
+ RegistrationWorkflowViewBean.ACTION_EDIT,
+ Integer.toString(regDto.getId())
+ );
+
+ updateUI(regDto.getCitationString(), regDto.getCreated(), regDto.getDatePublished(), regDto.getMessages().size(),
+ openButtonEvent, null, regDto);
}
public void setWorkingSet(RegistrationWorkingSet workingSet, AbstractView<?> parentView){
this.parentView = parentView;
- updateUI(workingSet.getCitation(), workingSet.getCreated(), null, workingSet.messagesCount(), null);
+ ReferenceEvent openButtonEvent;
+ if(workingSet.getCitationId() != null){
+ openButtonEvent = new ReferenceEvent(EntityEventType.EDIT, workingSet.getCitationId());
+ } else {
+ openButtonEvent = new ReferenceEvent(EntityEventType.ADD);
+ }
+ updateUI(workingSet.getCitation(), workingSet.getCreated(), null, workingSet.messagesCount(),
+ openButtonEvent, FontAwesome.EDIT, null);
}
/**
*
*/
- private void updateUI(String citationString, DateTime created, TimePeriod datePublished, int messagesCount, RegistrationDTO regDto) {
+ private void updateUI(String citationString, DateTime created, TimePeriod datePublished, int messagesCount,
+ Object openButtonEvent, Resource openButtonIcon, RegistrationDTO regDto) {
StringBuffer labelMarkup = new StringBuffer();
DateTime registrationDate = null;
if(messagesCount > 0){
getMessageButton().setEnabled(true);
- getMessageButton().addStyleName(ValoTheme.BUTTON_FRIENDLY);
+ // getMessageButton().addStyleName(RegistrationStyles.STYLE_FRIENDLY_FOREGROUND);
getMessageButton().addClickListener(e -> {
ShowDetailsEvent detailsEvent;
if(regDto != null){
publishEvent(detailsEvent);
}
);
+ getMessageButton().setCaption("<span class=\"" + RegistrationStyles.BUTTON_BADGE +"\"> " + messagesCount + "</span>");
+ getMessageButton().setCaptionAsHtml(true);
}
labelMarkup.append(citationString);
+
+ if(openButtonEvent != null){
+ // Buttons
+ getOpenButton().setVisible(true);
+ getOpenButton().addClickListener(e -> publishEvent(openButtonEvent));
+ }
+
+ if(openButtonIcon != null){
+ getOpenButton().setIcon(openButtonIcon);
+ }
+
if(regDto != null){
labelMarkup.append("</br>").append(regDto.getSummary());
getIdentifierLink().setVisible(true);
getIdentifierLink().setCaption(regDto.getIdentifier());
- // Buttons
- getOpenButton().setVisible(true);
- getOpenButton().addClickListener(e -> publishEvent(new NavigationEvent(
- RegistrationWorkflowViewBean.NAME,
- RegistrationWorkflowViewBean.ACTION_EDIT,
- Integer.toString(regDto.getId())
- )));
-
registrationDate = regDto.getRegistrationDate();
}
+
getCitationSummaryLabel().setValue(labelMarkup.toString());
updateDateLabels(created, datePublished, registrationDate);
}
import com.vaadin.server.GenericFontIcon;
import com.vaadin.server.Page;
import com.vaadin.spring.annotation.SpringView;
+import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.themes.ValoTheme;
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItem;
+import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles;
import eu.etaxonomy.cdm.vaadin.component.registration.TypeStateLabel;
import eu.etaxonomy.cdm.vaadin.component.registration.WorkflowSteps;
import eu.etaxonomy.cdm.vaadin.event.EntityEventType;
import eu.etaxonomy.cdm.vaadin.event.ReferenceEvent;
+import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEvent;
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent;
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
implements RegistrationWorkflowView, View {
- public static final String CSS_CLASS_WORKFLOW = "workflow-container";
+ public static final String DOM_ID_WORKFLOW = "workflow-container";
+
+ public static final String DOM_ID_WORKINGSET = "workingset";
public static final String SUBHEADER_DEEFAULT = "Advance step by step through the registration workflow.";
workflow = new CssLayout();
workflow.setSizeFull();
- workflow.setId(CSS_CLASS_WORKFLOW);
+ workflow.setId(DOM_ID_WORKFLOW);
getLayout().addComponent(workflow);
}
public void setWorkingset(RegistrationWorkingSet workingset) {
CssLayout registration = new CssLayout();
+ registration.setId(DOM_ID_WORKINGSET);
registration.setWidth(100, Unit.PERCENTAGE);
Panel namesTypesPanel = createNamesAndTypesList(workingset);
+ namesTypesPanel.setStyleName("names-types-list");
namesTypesPanel.setCaption("Names & Types");
+
registration.addComponent(createWorkflowTabSheet(workingset, null));
registration.addComponent(new RegistrationItem(workingset, this));
registration.addComponent(namesTypesPanel);
*/
public Panel createNamesAndTypesList(RegistrationWorkingSet workingset) {
// prepare name and type list
- GridLayout namesTypesList = new GridLayout(4, workingset.getRegistrationDTOs().size());
+ GridLayout namesTypesList = new GridLayout(3, workingset.getRegistrationDTOs().size());
int row = 0;
for(RegistrationDTO dto : workingset.getRegistrationDTOs()) {
- Button commentButton = new Button(FontAwesome.COMMENT);
- commentButton.setStyleName(ValoTheme.BUTTON_BORDERLESS);
+
+ Button messageButton = new Button(FontAwesome.COMMENT);
+ messageButton.setStyleName(ValoTheme.BUTTON_TINY); // + " " + RegistrationStyles.STYLE_FRIENDLY_FOREGROUND);
+ if(dto.getMessages().isEmpty()){
+ messageButton.setEnabled(false);
+ } else {
+ messageButton.addClickListener(e -> eventBus.publishEvent(
+ new ShowDetailsEvent<RegistrationDTO, Integer>(
+ e,
+ RegistrationDTO.class,
+ dto.getId(),
+ "messages"
+ )
+ )
+ );
+ }
+ messageButton.setCaption("<span class=\"" + RegistrationStyles.BUTTON_BADGE +"\"> " + dto.getMessages().size() + "</span>");
+ messageButton.setCaptionAsHtml(true);
+
Button editButton = new Button(FontAwesome.EDIT);
- editButton.setStyleName(ValoTheme.BUTTON_BORDERLESS);
+ editButton.setStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_PRIMARY);
namesTypesList.addComponent(new TypeStateLabel().update(dto.getRegistrationType(), dto.getStatus()), 0, row);
namesTypesList.addComponent(new Label(dto.getSummary()), 1, row);
- namesTypesList.addComponent(commentButton, 2, row);
- namesTypesList.addComponent(editButton, 3, row);
+ CssLayout buttonGroup = new CssLayout();
+ buttonGroup.setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
+ buttonGroup.addComponent(messageButton);
+ buttonGroup.addComponent(editButton);
+ namesTypesList.addComponent(buttonGroup, 2, row);
+ namesTypesList.setComponentAlignment(buttonGroup, Alignment.TOP_RIGHT);
row++;
}
namesTypesList.setSizeUndefined();
+ namesTypesList.setWidth(100, Unit.PERCENTAGE);
+ namesTypesList.setColumnExpandRatio(0, 0.1f);
+ namesTypesList.setColumnExpandRatio(1, 0.9f);
Panel namesTypesPanel = new Panel(namesTypesList);
namesTypesPanel.setHeight("300px");
return namesTypesPanel;