Project

General

Profile

« Previous | Next » 

Revision 84724c61

Added by Andreas Kohlbecker over 6 years ago

fix #6846 improving AbstractPageView layout

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationStateLabel.java
35 35

  
36 36
       setValue(StringUtils.capitalize((status.name().toLowerCase())));
37 37
       addStyleName("status-" + status.name());
38
       setWidth("90px");
38 39
       return this;
39 40
   }
40 41

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/AbstractPageView.java
8 8
*/
9 9
package eu.etaxonomy.cdm.vaadin.view;
10 10

  
11
import java.util.ArrayList;
12
import java.util.List;
13

  
11 14
import com.vaadin.shared.ui.label.ContentMode;
12
import com.vaadin.ui.CssLayout;
15
import com.vaadin.ui.AbstractLayout;
16
import com.vaadin.ui.Component;
13 17
import com.vaadin.ui.Label;
18
import com.vaadin.ui.VerticalLayout;
14 19
import com.vaadin.ui.themes.ValoTheme;
15 20

  
16 21
import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
......
27 32
 */
28 33
public abstract class AbstractPageView<P extends AbstractPresenter> extends AbstractView<P>  {
29 34

  
30
    private CssLayout layout;
35
    private VerticalLayout layout;
36

  
37
    private List<Component> contentComponents = new ArrayList<>();
31 38

  
32 39
    private Label header;
33 40

  
......
36 43
     *
37 44
     */
38 45
    public AbstractPageView() {
39
        layout = new CssLayout();
46
        layout = new VerticalLayout();
40 47
        layout.setSizeFull();
41 48

  
42 49
        header = new Label();
......
51 58
    }
52 59

  
53 60
    /**
54
     * 
61
     *
55 62
     */
56 63
    public void updateHeader() {
57 64
        header.setValue("<div id=\"header\">" + getHeaderText() + "</div><div id=\"subheader\">" + getSubHeaderText() + "</div>");
58 65
    }
59 66

  
60
    protected CssLayout getLayout() {
67
    protected AbstractLayout getLayout() {
61 68
        return layout;
62 69
    }
63 70

  
71
    protected void removeContentComponents(){
72
        for(Component c : contentComponents){
73
            layout.removeComponent(c);
74
        }
75

  
76
    }
77

  
78
    protected void addContentComponent(Component component, Float expandRatio){
79
        contentComponents.add(component);
80
        layout.addComponent(component);
81
        if(expandRatio != null){
82
            layout.setExpandRatio(component, expandRatio);
83
        }
84
    }
85

  
86

  
87

  
64 88
    /**
65 89
     * Provides the sub header text
66 90
     *
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListViewBean.java
56 56

  
57 57
    @Override
58 58
    protected void initContent() {
59
        getLayout().setId(NAME);
59 60
        toolBar = new CssLayout();
60 61
        toolBar.setWidth(100, Unit.PERCENTAGE);
61
        // toolBar.addComponent();
62
        getLayout().addComponent(toolBar);
62
        addContentComponent(toolBar, null);
63 63

  
64
        buildList();
65
        getLayout().addComponent(listContainer);
64
        listContainer = new CssLayout();
65
        listContainer.setId("registration-list");
66
        listContainer.setWidth(100, Unit.PERCENTAGE);
67
        addContentComponent(listContainer, 1f);
66 68

  
67 69
    }
68 70

  
......
76 78
        return "This is the list of all your registrations in progress.";
77 79
    }
78 80

  
79
    private void buildList() {
80
        listContainer = new CssLayout();
81
        listContainer.setId("registration-list");
82
        listContainer.setWidth(100, Unit.PERCENTAGE);
83
    }
84

  
85 81

  
86 82
    /**
87 83
     * {@inheritDoc}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowView.java
13 13

  
14 14
import org.vaadin.viritin.fields.LazyComboBox;
15 15

  
16
import com.vaadin.ui.AbstractLayout;
16 17
import com.vaadin.ui.Button;
17
import com.vaadin.ui.CssLayout;
18 18

  
19 19
import eu.etaxonomy.cdm.model.name.TaxonName;
20 20
import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction;
......
33 33
    public static final String ACTION_EDIT = "edit";
34 34

  
35 35

  
36
    CssLayout getWorkflow();
36
    AbstractLayout getWorkflow();
37 37

  
38 38

  
39 39
    /**
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowViewBean.java
22 22
import com.vaadin.server.GenericFontIcon;
23 23
import com.vaadin.server.Page;
24 24
import com.vaadin.spring.annotation.SpringView;
25
import com.vaadin.ui.AbstractLayout;
25 26
import com.vaadin.ui.Alignment;
26 27
import com.vaadin.ui.Button;
27 28
import com.vaadin.ui.Component;
......
69 70
public class RegistrationWorkflowViewBean extends AbstractPageView<RegistrationWorkflowPresenter>
70 71
    implements RegistrationWorkflowView, View, AccessRestrictedView {
71 72

  
72

  
73
    public static final String DOM_ID_WORKFLOW = "workflow-container";
74

  
75 73
    public static final String DOM_ID_WORKINGSET = "workingset";
76 74

  
77 75
    private static final long serialVersionUID = -213040114015958970L;
......
82 80

  
83 81
    public RegistrationType regType = null;
84 82

  
85
    private CssLayout workflow;
86

  
87 83
    private List<CssLayout> registrations = new ArrayList<>();
88 84

  
89 85
    private String headerText = "-- empty --";
......
97 93

  
98 94
    private LazyComboBox<TaxonName> existingNameCombobox;
99 95

  
100
    // private Button addExistingNameRegistrationButton;
101

  
102 96
    private GridLayout registrationsGrid;
103 97

  
104 98
    private Button addExistingNameButton;
105 99

  
100
    private RegistrationItem workingsetHeader;
101

  
102
    private Panel registrationListPanel;
103

  
106 104
    public RegistrationWorkflowViewBean() {
107 105
        super();
108 106
    }
109 107

  
108

  
109
    /**
110
     * {@inheritDoc}
111
     */
110 112
    @Override
111 113
    protected void initContent() {
112
        workflow = new CssLayout();
113
        workflow.setSizeFull();
114
        workflow.setId(DOM_ID_WORKFLOW);
115
        getLayout().addComponent(workflow);
114
        getLayout().setId(NAME);
115
        // all content is added in createRegistrationsList()
116 116
    }
117 117

  
118

  
118 119
    /**
119 120
     * {@inheritDoc}
120 121
     */
......
132 133
     */
133 134
    @Override
134 135
    public void setWorkingset(RegistrationWorkingSet workingset) {
136
        if(workingsetHeader != null){
137
            getLayout().removeComponent(workingsetHeader);
138
            getLayout().removeComponent(registrationListPanel);
139
        }
135 140

  
136
        CssLayout registration = new CssLayout();
137
        registration.setId(DOM_ID_WORKINGSET);
138
        registration.setWidth(100, Unit.PERCENTAGE);
139

  
140
        Panel registrationListPanel = createRegistrationsList(workingset);
141
        registrationListPanel = createRegistrationsList(workingset);
141 142
        registrationListPanel.setStyleName("registration-list");
142 143
        registrationListPanel.setCaption("Registrations");
143 144

  
144

  
145
        // registration.addComponent(createWorkflowTabSheet(workingset, null));
146
        RegistrationItem registrationItem = new RegistrationItem(workingset, this);
145
        workingsetHeader = new RegistrationItem(workingset, this);
147 146
        if(UserHelper.fromSession().userIsRegistrationCurator() || UserHelper.fromSession().userIsAdmin()){
148
            registrationItem.getSubmitterLabel().setVisible(true);
149
        };
150
        registration.addComponent(registrationItem);
151
        registration.addComponent(registrationListPanel);
152

  
153
        registrations.add(registration);
154
        workflow.removeAllComponents();
155
        workflow.addComponent(registration);
147
            workingsetHeader.getSubmitterLabel().setVisible(true);
148
        }
149
        addContentComponent(workingsetHeader, null);
150
        addContentComponent(registrationListPanel, 1.0f);
151

  
156 152
    }
157 153

  
158 154
    /**
......
202 198
    public Panel createRegistrationsList(RegistrationWorkingSet workingset) {
203 199

  
204 200
        registrationsGrid = new GridLayout(3, 1);
205
        registrationsGrid.setSizeUndefined();
206
        registrationsGrid.setColumnExpandRatio(0, 0.1f);
207
        registrationsGrid.setColumnExpandRatio(1, 0.9f);
201
        registrationsGrid.setWidth("100%");
202
        // allow vertical scrolling:
203
        registrationsGrid.setHeightUndefined();
204

  
205
        //registrationsGrid.setColumnExpandRatio(0, 0.1f);
206
        registrationsGrid.setColumnExpandRatio(1, 1f);
208 207

  
209 208
        int row = 0;
210 209
        for(RegistrationDTO dto : workingset.getRegistrationDTOs()) {
211 210
            putRegistrationListComponent(registrationsGrid, row++, dto);
212 211
        }
213 212

  
214

  
215 213
        Label addRegistrationLabel_1 = new Label("Add a new registration for a");
216 214
        Label addRegistrationLabel_2 = new Label("or an");
217 215

  
......
235 233

  
236 234
        HorizontalLayout buttonContainer = new HorizontalLayout(addRegistrationLabel_1, addNewNameRegistrationButton, addRegistrationLabel_2, addExistingNameButton, existingNameCombobox);
237 235
        buttonContainer.setSpacing(true);
238
        buttonContainer.setWidth(100, Unit.PERCENTAGE);
236
//        buttonContainer.setWidth(100, Unit.PERCENTAGE);
239 237
        buttonContainer.setComponentAlignment(addRegistrationLabel_1, Alignment.MIDDLE_LEFT);
240 238
        buttonContainer.setComponentAlignment(addRegistrationLabel_2, Alignment.MIDDLE_LEFT);
241
        registrationsGrid.addComponent(buttonContainer, 1, row, 1, row);
239
        registrationsGrid.addComponent(buttonContainer, 0, row, 2, row);
240
        registrationsGrid.setComponentAlignment(buttonContainer, Alignment.MIDDLE_RIGHT);
242 241

  
243 242
        Panel namesTypesPanel = new Panel(registrationsGrid);
244
        namesTypesPanel.setHeight("300px");
243
        namesTypesPanel.setSizeFull();
245 244
        return namesTypesPanel;
246 245
    }
247 246

  
......
513 512
     * {@inheritDoc}
514 513
     */
515 514
    @Override
516
    public CssLayout getWorkflow() {
517
        return workflow;
515
    public AbstractLayout getWorkflow() {
516
        return getLayout();
518 517
    }
519 518

  
520 519
    /**
......
572 571
    }
573 572

  
574 573

  
575

  
576 574
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/StartRegistrationViewBean.java
68 68
     * {@inheritDoc}
69 69
     */
70 70
    @Override
71
    public boolean allowAnonymousAccess() {
72
        return false;
73
    }
74

  
75
    /**
76
     * {@inheritDoc}
77
     */
78
    @Override
79
    public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() {
80
        return null;
81
    }
82

  
83
    /**
84
     * {@inheritDoc}
85
     */
86
    @Override
87
    protected String getHeaderText() {
88
        return "New Registration";
89
    }
90

  
91
    /**
92
     * {@inheritDoc}
93
     */
94
    @Override
95
    protected String getSubHeaderText() {
96
        return SUBHEADER_DEEFAULT;
97
    }
98

  
99
    /**
100
     * {@inheritDoc}
101
     */
102
    @Override
103 71
    protected void initContent() {
104 72

  
73
        getLayout().setId(NAME);
74

  
105 75
        VerticalLayout vlayout = new VerticalLayout();
106 76
        vlayout.setSpacing(true);
107 77
        vlayout.setMargin(true);
......
177 147
        vlayout.setComponentAlignment(publicationLayout, Alignment.TOP_CENTER);
178 148
        vlayout.setComponentAlignment(continueButton, Alignment.TOP_CENTER);
179 149

  
180
        getLayout().addComponent(vlayout);
150
        addContentComponent(vlayout, 1f);
151
    }
152

  
153
    /**
154
     * {@inheritDoc}
155
     */
156
    @Override
157
    public boolean allowAnonymousAccess() {
158
        return false;
181 159
    }
182 160

  
161
    /**
162
     * {@inheritDoc}
163
     */
164
    @Override
165
    public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() {
166
        return null;
167
    }
183 168

  
169
    /**
170
     * {@inheritDoc}
171
     */
172
    @Override
173
    protected String getHeaderText() {
174
        return "New Registration";
175
    }
176

  
177
    /**
178
     * {@inheritDoc}
179
     */
180
    @Override
181
    protected String getSubHeaderText() {
182
        return SUBHEADER_DEEFAULT;
183
    }
184 184

  
185 185
    /**
186 186
     * {@inheritDoc}
src/main/webapp/VAADIN/themes/edit-valo/edit-valo.scss
167 167
      }
168 168
    }
169 169

  
170

  
171 170
    // ===== workflow ==== // 
172

  
173
    #workflow-container {
174
        text-align: center;
175
        margin-top: $v-unit-size;
171
    
172
    #workflow {
173
        .registration-list {
174
                .v-gridlayout-slot {
175
                    border-bottom: valo-border($border: $v-border, $color: $v-background-color, $strength: 1.4);
176
                }
177
                .v-panel-content {
178
                    padding-left: round($v-unit-size / 4);
179
                }
180
            }
181
         .v-gridlayout-registration-list-item {
182
            padding: 0 round($v-unit-size / 4);
183
         }
176 184
    }
177 185
    
178 186
    $workflow-icon-size: 110px;
......
231 239
            }
232 240
        }
233 241
    }
242
    
243
   // --------------------------------------------------- //
234 244

  
235 245
    #workingset {
236 246
            padding: round($v-unit-size / 2);

Also available in: Unified diff