*/
package eu.etaxonomy.cdm.vaadin.view;
+import java.util.ArrayList;
+import java.util.List;
+
import com.vaadin.shared.ui.label.ContentMode;
-import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.AbstractLayout;
+import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.ValoTheme;
import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
*/
public abstract class AbstractPageView<P extends AbstractPresenter> extends AbstractView<P> {
- private CssLayout layout;
+ private VerticalLayout layout;
+
+ private List<Component> contentComponents = new ArrayList<>();
private Label header;
*
*/
public AbstractPageView() {
- layout = new CssLayout();
+ layout = new VerticalLayout();
layout.setSizeFull();
header = new Label();
}
/**
- *
+ *
*/
public void updateHeader() {
header.setValue("<div id=\"header\">" + getHeaderText() + "</div><div id=\"subheader\">" + getSubHeaderText() + "</div>");
}
- protected CssLayout getLayout() {
+ protected AbstractLayout getLayout() {
return layout;
}
+ protected void removeContentComponents(){
+ for(Component c : contentComponents){
+ layout.removeComponent(c);
+ }
+
+ }
+
+ protected void addContentComponent(Component component, Float expandRatio){
+ contentComponents.add(component);
+ layout.addComponent(component);
+ if(expandRatio != null){
+ layout.setExpandRatio(component, expandRatio);
+ }
+ }
+
+
+
/**
* Provides the sub header text
*
import com.vaadin.server.GenericFontIcon;
import com.vaadin.server.Page;
import com.vaadin.spring.annotation.SpringView;
+import com.vaadin.ui.AbstractLayout;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
public class RegistrationWorkflowViewBean extends AbstractPageView<RegistrationWorkflowPresenter>
implements RegistrationWorkflowView, View, AccessRestrictedView {
-
- public static final String DOM_ID_WORKFLOW = "workflow-container";
-
public static final String DOM_ID_WORKINGSET = "workingset";
private static final long serialVersionUID = -213040114015958970L;
public RegistrationType regType = null;
- private CssLayout workflow;
-
private List<CssLayout> registrations = new ArrayList<>();
private String headerText = "-- empty --";
private LazyComboBox<TaxonName> existingNameCombobox;
- // private Button addExistingNameRegistrationButton;
-
private GridLayout registrationsGrid;
private Button addExistingNameButton;
+ private RegistrationItem workingsetHeader;
+
+ private Panel registrationListPanel;
+
public RegistrationWorkflowViewBean() {
super();
}
+
+ /**
+ * {@inheritDoc}
+ */
@Override
protected void initContent() {
- workflow = new CssLayout();
- workflow.setSizeFull();
- workflow.setId(DOM_ID_WORKFLOW);
- getLayout().addComponent(workflow);
+ getLayout().setId(NAME);
+ // all content is added in createRegistrationsList()
}
+
/**
* {@inheritDoc}
*/
*/
@Override
public void setWorkingset(RegistrationWorkingSet workingset) {
+ if(workingsetHeader != null){
+ getLayout().removeComponent(workingsetHeader);
+ getLayout().removeComponent(registrationListPanel);
+ }
- CssLayout registration = new CssLayout();
- registration.setId(DOM_ID_WORKINGSET);
- registration.setWidth(100, Unit.PERCENTAGE);
-
- Panel registrationListPanel = createRegistrationsList(workingset);
+ registrationListPanel = createRegistrationsList(workingset);
registrationListPanel.setStyleName("registration-list");
registrationListPanel.setCaption("Registrations");
-
- // registration.addComponent(createWorkflowTabSheet(workingset, null));
- RegistrationItem registrationItem = new RegistrationItem(workingset, this);
+ workingsetHeader = new RegistrationItem(workingset, this);
if(UserHelper.fromSession().userIsRegistrationCurator() || UserHelper.fromSession().userIsAdmin()){
- registrationItem.getSubmitterLabel().setVisible(true);
- };
- registration.addComponent(registrationItem);
- registration.addComponent(registrationListPanel);
-
- registrations.add(registration);
- workflow.removeAllComponents();
- workflow.addComponent(registration);
+ workingsetHeader.getSubmitterLabel().setVisible(true);
+ }
+ addContentComponent(workingsetHeader, null);
+ addContentComponent(registrationListPanel, 1.0f);
+
}
/**
public Panel createRegistrationsList(RegistrationWorkingSet workingset) {
registrationsGrid = new GridLayout(3, 1);
- registrationsGrid.setSizeUndefined();
- registrationsGrid.setColumnExpandRatio(0, 0.1f);
- registrationsGrid.setColumnExpandRatio(1, 0.9f);
+ registrationsGrid.setWidth("100%");
+ // allow vertical scrolling:
+ registrationsGrid.setHeightUndefined();
+
+ //registrationsGrid.setColumnExpandRatio(0, 0.1f);
+ registrationsGrid.setColumnExpandRatio(1, 1f);
int row = 0;
for(RegistrationDTO dto : workingset.getRegistrationDTOs()) {
putRegistrationListComponent(registrationsGrid, row++, dto);
}
-
Label addRegistrationLabel_1 = new Label("Add a new registration for a");
Label addRegistrationLabel_2 = new Label("or an");
HorizontalLayout buttonContainer = new HorizontalLayout(addRegistrationLabel_1, addNewNameRegistrationButton, addRegistrationLabel_2, addExistingNameButton, existingNameCombobox);
buttonContainer.setSpacing(true);
- buttonContainer.setWidth(100, Unit.PERCENTAGE);
+// buttonContainer.setWidth(100, Unit.PERCENTAGE);
buttonContainer.setComponentAlignment(addRegistrationLabel_1, Alignment.MIDDLE_LEFT);
buttonContainer.setComponentAlignment(addRegistrationLabel_2, Alignment.MIDDLE_LEFT);
- registrationsGrid.addComponent(buttonContainer, 1, row, 1, row);
+ registrationsGrid.addComponent(buttonContainer, 0, row, 2, row);
+ registrationsGrid.setComponentAlignment(buttonContainer, Alignment.MIDDLE_RIGHT);
Panel namesTypesPanel = new Panel(registrationsGrid);
- namesTypesPanel.setHeight("300px");
+ namesTypesPanel.setSizeFull();
return namesTypesPanel;
}
* {@inheritDoc}
*/
@Override
- public CssLayout getWorkflow() {
- return workflow;
+ public AbstractLayout getWorkflow() {
+ return getLayout();
}
/**
}
-
}
super();
}
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean allowAnonymousAccess() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getHeaderText() {
- return "New Registration";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getSubHeaderText() {
- return SUBHEADER_DEEFAULT;
- }
-
/**
* {@inheritDoc}
*/
@Override
protected void initContent() {
+ getLayout().setId(NAME);
+
VerticalLayout vlayout = new VerticalLayout();
vlayout.setSpacing(true);
vlayout.setMargin(true);
vlayout.setComponentAlignment(publicationLayout, Alignment.TOP_CENTER);
vlayout.setComponentAlignment(continueButton, Alignment.TOP_CENTER);
- getLayout().addComponent(vlayout);
+ addContentComponent(vlayout, 1f);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean allowAnonymousAccess() {
+ return false;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() {
+ return null;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getHeaderText() {
+ return "New Registration";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getSubHeaderText() {
+ return SUBHEADER_DEEFAULT;
+ }
/**
* {@inheritDoc}