fix #6846 improving AbstractPageView layout
authorAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Mon, 24 Jul 2017 08:08:03 +0000 (10:08 +0200)
committerAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Mon, 24 Jul 2017 08:10:13 +0000 (10:10 +0200)
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationStateLabel.java
src/main/java/eu/etaxonomy/cdm/vaadin/view/AbstractPageView.java
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListViewBean.java
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowView.java
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowViewBean.java
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/StartRegistrationViewBean.java
src/main/webapp/VAADIN/themes/edit-valo/edit-valo.scss

index 501f748120a3768e59586bd9124d7212794a74ec..83eb6d3407a6cee17e66ff697c8db9db2d8be984 100644 (file)
@@ -35,6 +35,7 @@ public class RegistrationStateLabel extends Label {
 
        setValue(StringUtils.capitalize((status.name().toLowerCase())));
        addStyleName("status-" + status.name());
+       setWidth("90px");
        return this;
    }
 
index 07995ae3d29c53a4780bf9499918ac404fef738b..3a0b40d8a136dac6e2209d4c9d0ddd75b38075cf 100644 (file)
@@ -8,9 +8,14 @@
 */
 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;
@@ -27,7 +32,9 @@ import eu.etaxonomy.vaadin.mvp.AbstractView;
  */
 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;
 
@@ -36,7 +43,7 @@ public abstract class AbstractPageView<P extends AbstractPresenter> extends Abst
      *
      */
     public AbstractPageView() {
-        layout = new CssLayout();
+        layout = new VerticalLayout();
         layout.setSizeFull();
 
         header = new Label();
@@ -51,16 +58,33 @@ public abstract class AbstractPageView<P extends AbstractPresenter> extends Abst
     }
 
     /**
-     * 
+     *
      */
     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
      *
index b40379b3b03d275c5c5e1b3545e24fb6418df72b..39424f11de0a828de1499de3422787ec60e259ee 100644 (file)
@@ -56,13 +56,15 @@ public class ListViewBean extends AbstractPageView<ListPresenter> implements Lis
 
     @Override
     protected void initContent() {
+        getLayout().setId(NAME);
         toolBar = new CssLayout();
         toolBar.setWidth(100, Unit.PERCENTAGE);
-        // toolBar.addComponent();
-        getLayout().addComponent(toolBar);
+        addContentComponent(toolBar, null);
 
-        buildList();
-        getLayout().addComponent(listContainer);
+        listContainer = new CssLayout();
+        listContainer.setId("registration-list");
+        listContainer.setWidth(100, Unit.PERCENTAGE);
+        addContentComponent(listContainer, 1f);
 
     }
 
@@ -76,12 +78,6 @@ public class ListViewBean extends AbstractPageView<ListPresenter> implements Lis
         return "This is the list of all your registrations in progress.";
     }
 
-    private void buildList() {
-        listContainer = new CssLayout();
-        listContainer.setId("registration-list");
-        listContainer.setWidth(100, Unit.PERCENTAGE);
-    }
-
 
     /**
      * {@inheritDoc}
index 4192784ffbd14d035280d3aa9b9814063957ada7..b2116eef58aa2827d68306141a677a0872685194 100644 (file)
@@ -13,8 +13,8 @@ import java.util.UUID;
 
 import org.vaadin.viritin.fields.LazyComboBox;
 
+import com.vaadin.ui.AbstractLayout;
 import com.vaadin.ui.Button;
-import com.vaadin.ui.CssLayout;
 
 import eu.etaxonomy.cdm.model.name.TaxonName;
 import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction;
@@ -33,7 +33,7 @@ public interface RegistrationWorkflowView extends ApplicationView{
     public static final String ACTION_EDIT = "edit";
 
 
-    CssLayout getWorkflow();
+    AbstractLayout getWorkflow();
 
 
     /**
index 928f5fb5d948ce37e67c133810a8336acaa2068e..acd8507a6969a834db2a4c91585cae4482032a8b 100644 (file)
@@ -22,6 +22,7 @@ import com.vaadin.server.FontAwesome;
 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;
@@ -69,9 +70,6 @@ import eu.etaxonomy.cdm.vaadin.view.AbstractPageView;
 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;
@@ -82,8 +80,6 @@ public class RegistrationWorkflowViewBean extends AbstractPageView<RegistrationW
 
     public RegistrationType regType = null;
 
-    private CssLayout workflow;
-
     private List<CssLayout> registrations = new ArrayList<>();
 
     private String headerText = "-- empty --";
@@ -97,24 +93,29 @@ public class RegistrationWorkflowViewBean extends AbstractPageView<RegistrationW
 
     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}
      */
@@ -132,27 +133,22 @@ public class RegistrationWorkflowViewBean extends AbstractPageView<RegistrationW
      */
     @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);
+
     }
 
     /**
@@ -202,16 +198,18 @@ public class RegistrationWorkflowViewBean extends AbstractPageView<RegistrationW
     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");
 
@@ -235,13 +233,14 @@ public class RegistrationWorkflowViewBean extends AbstractPageView<RegistrationW
 
         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;
     }
 
@@ -513,8 +512,8 @@ public class RegistrationWorkflowViewBean extends AbstractPageView<RegistrationW
      * {@inheritDoc}
      */
     @Override
-    public CssLayout getWorkflow() {
-        return workflow;
+    public AbstractLayout getWorkflow() {
+        return getLayout();
     }
 
     /**
@@ -572,5 +571,4 @@ public class RegistrationWorkflowViewBean extends AbstractPageView<RegistrationW
     }
 
 
-
 }
index 6a6c713f13af3d115929e0e4af03799c068913ec..1adeef6ed0dc58640f9833008994929795253192 100644 (file)
@@ -64,44 +64,14 @@ public class StartRegistrationViewBean extends AbstractPageView<StartRegistratio
         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);
@@ -177,10 +147,40 @@ public class StartRegistrationViewBean extends AbstractPageView<StartRegistratio
         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}
index 5f816a6ad76c9a9be5e272c4237cde7fad68bde6..ec7d58b6557298153401aa647ee6eb7880774c6d 100644 (file)
@@ -167,12 +167,20 @@ $status-ready-color: adjust-color($plain-red, $hue: 180deg);
       }
     }
 
-
     // ===== workflow ==== // 
-
-    #workflow-container {
-        text-align: center;
-        margin-top: $v-unit-size;
+    
+    #workflow {
+        .registration-list {
+                .v-gridlayout-slot {
+                    border-bottom: valo-border($border: $v-border, $color: $v-background-color, $strength: 1.4);
+                }
+                .v-panel-content {
+                    padding-left: round($v-unit-size / 4);
+                }
+            }
+         .v-gridlayout-registration-list-item {
+            padding: 0 round($v-unit-size / 4);
+         }
     }
     
     $workflow-icon-size: 110px;
@@ -231,6 +239,8 @@ $status-ready-color: adjust-color($plain-red, $hue: 180deg);
             }
         }
     }
+    
+   // --------------------------------------------------- //
 
     #workingset {
             padding: round($v-unit-size / 2);