Project

General

Profile

« Previous | Next » 

Revision c7627153

Added by Andreas Kohlbecker about 7 years ago

ref #6169 message count indicator, edit reference button and impoved layout

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/ButtonFactory.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.vaadin.component.registration;
10

  
11
/**
12
 * @author a.kohlbecker
13
 * @since Apr 3, 2017
14
 *
15
 */
16
public class ButtonFactory {
17

  
18
}
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
    }
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationStyles.java
15 15
 */
16 16
public class RegistrationStyles {
17 17

  
18
    public static final String STYLE_LABEL_NOWRAP = "label-nowrap";
18
    public static final String LABEL_NOWRAP = "label-nowrap";
19

  
20
    public static final String FRIENDLY_FOREGROUND = "friendly-foreground";
21

  
22
    public static final String BUTTON_BADGE = "button-badge";
23

  
19 24

  
20 25
}
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/TypeStateLabel.java
9 9
package eu.etaxonomy.cdm.vaadin.component.registration;
10 10

  
11 11

  
12
import static eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles.STYLE_LABEL_NOWRAP;
12
import static eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles.LABEL_NOWRAP;
13 13

  
14 14
import org.apache.commons.lang.StringUtils;
15 15

  
......
37 37
     *
38 38
     */
39 39
    public TypeStateLabel() {
40
        setStyleName(STYLE_LABEL_NOWRAP);
40
        setStyleName(LABEL_NOWRAP);
41 41
    }
42 42

  
43 43
    /**
src/main/java/eu/etaxonomy/cdm/vaadin/event/AbstractEntityEvent.java
18 18

  
19 19
    private EntityEventType eventType;
20 20

  
21
    public AbstractEntityEvent(EntityEventType eventType) {
21
    private Integer entityId = null;
22

  
23
    public AbstractEntityEvent(EntityEventType eventType, Integer entityId) {
22 24
        this.eventType = eventType;
23 25
        if(eventType == null){
24 26
            throw new NullPointerException();
25 27
        }
28
        this.setEntityId(entityId);
29
    }
30

  
31
    public AbstractEntityEvent(EntityEventType eventType) {
32
        this(eventType, null);
26 33
    }
27 34

  
28 35
    public EntityEventType getEventType() {
......
39 46
        return eventType.equals(EntityEventType.REMOVE);
40 47
    }
41 48

  
49
    /**
50
     * @return the entityId
51
     */
52
    public Integer getEntityId() {
53
        return entityId;
54
    }
55

  
56
    /**
57
     * @param entityId the entityId to set
58
     */
59
    private void setEntityId(Integer entityId) {
60
        this.entityId = entityId;
61
    }
62

  
42 63
}
src/main/java/eu/etaxonomy/cdm/vaadin/event/ReferenceEvent.java
15 15
 */
16 16
public class ReferenceEvent extends AbstractEntityEvent {
17 17

  
18

  
18
    /**
19
     * @param eventType
20
     */
19 21
    public ReferenceEvent(EntityEventType eventType) {
20 22
        super(eventType);
21 23
    }
22 24

  
25
    /**
26
     * @param eventType
27
     * @param entityId
28
     */
29
    public ReferenceEvent(EntityEventType eventType, Integer entityId) {
30
        super(eventType, entityId);
31
    }
32

  
33

  
34

  
35

  
23 36
}
src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/RegistrationWorkingSet.java
30 30

  
31 31
    private List<RegistrationDTO> registrationDTOs = new ArrayList<>();
32 32

  
33
    private int citationId = -1;
33
    private Integer citationId = null;
34 34

  
35 35
    private DateTime created = null;
36 36

  
......
74 74
            problems = new ArrayList<>();
75 75
        }
76 76
        for(RegistrationDTO regDto : candidates){
77
                if(citationId == -1){
77
                if(citationId == null){
78 78
                    citationId = regDto.getCitationID();
79 79
                    citation = regDto.getCitation();
80 80
                } else {
......
155 155
    /**
156 156
     * @return the citationId
157 157
     */
158
    public int getCitationId() {
158
    public Integer getCitationId() {
159 159
        return citationId;
160 160
    }
161 161

  
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/registration/RegistrationWorkflowPresenter.java
95 95
    }
96 96

  
97 97
    @EventListener(classes=ShowDetailsEvent.class, condition = "#event.entityType == T(eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet)")
98
    public void onShowDetailsEvent(ShowDetailsEvent<?,?> event) { // WARNING don't use more specific generic type arguments
98
    public void onShowRegistrationWorkingSetMessages(ShowDetailsEvent<?,?> event) { // WARNING don't use more specific generic type arguments
99 99
        List<String> messages = new ArrayList<>();
100 100
        for(RegistrationDTO dto : workingset.getRegistrationDTOs()){
101 101
            dto.getMessages().forEach(m -> messages.add(dto.getSummary() + ": " + m));
......
105 105
        }
106 106
    }
107 107

  
108
    @EventListener(classes=ShowDetailsEvent.class, condition = "#event.entityType == T(eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationDTO)")
109
    public void onShowRegistrationMessages(ShowDetailsEvent<?,?> event) { // WARNING don't use more specific generic type arguments
110
        RegistrationDTO regDto = serviceMock.loadDtoById((Integer)event.getIdentifier());
111
        if(event.getProperty().equals("messages")){
112
            getView().openDetailsPopup("Messages", regDto.getMessages());
113
        }
114
    }
115

  
108 116
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowViewBean.java
20 20
import com.vaadin.server.GenericFontIcon;
21 21
import com.vaadin.server.Page;
22 22
import com.vaadin.spring.annotation.SpringView;
23
import com.vaadin.ui.Alignment;
23 24
import com.vaadin.ui.Button;
24 25
import com.vaadin.ui.Component;
25 26
import com.vaadin.ui.CssLayout;
......
32 33
import com.vaadin.ui.themes.ValoTheme;
33 34

  
34 35
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItem;
36
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles;
35 37
import eu.etaxonomy.cdm.vaadin.component.registration.TypeStateLabel;
36 38
import eu.etaxonomy.cdm.vaadin.component.registration.WorkflowSteps;
37 39
import eu.etaxonomy.cdm.vaadin.event.EntityEventType;
38 40
import eu.etaxonomy.cdm.vaadin.event.ReferenceEvent;
41
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
39 42
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEvent;
40 43
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent;
41 44
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
......
55 58
    implements RegistrationWorkflowView, View {
56 59

  
57 60

  
58
    public static final String CSS_CLASS_WORKFLOW = "workflow-container";
61
    public static final String DOM_ID_WORKFLOW = "workflow-container";
62

  
63
    public static final String DOM_ID_WORKINGSET = "workingset";
59 64

  
60 65
    public static final String SUBHEADER_DEEFAULT = "Advance step by step through the registration workflow.";
61 66

  
......
82 87

  
83 88
        workflow = new CssLayout();
84 89
        workflow.setSizeFull();
85
        workflow.setId(CSS_CLASS_WORKFLOW);
90
        workflow.setId(DOM_ID_WORKFLOW);
86 91
        getLayout().addComponent(workflow);
87 92
    }
88 93

  
......
114 119
    public void setWorkingset(RegistrationWorkingSet workingset) {
115 120

  
116 121
        CssLayout registration = new CssLayout();
122
        registration.setId(DOM_ID_WORKINGSET);
117 123
        registration.setWidth(100, Unit.PERCENTAGE);
118 124

  
119 125
        Panel namesTypesPanel = createNamesAndTypesList(workingset);
126
        namesTypesPanel.setStyleName("names-types-list");
120 127
        namesTypesPanel.setCaption("Names & Types");
121 128

  
129

  
122 130
        registration.addComponent(createWorkflowTabSheet(workingset, null));
123 131
        registration.addComponent(new RegistrationItem(workingset, this));
124 132
        registration.addComponent(namesTypesPanel);
......
174 182
     */
175 183
    public Panel createNamesAndTypesList(RegistrationWorkingSet workingset) {
176 184
        // prepare name and type list
177
        GridLayout namesTypesList = new GridLayout(4, workingset.getRegistrationDTOs().size());
185
        GridLayout namesTypesList = new GridLayout(3, workingset.getRegistrationDTOs().size());
178 186
        int row = 0;
179 187
        for(RegistrationDTO dto : workingset.getRegistrationDTOs()) {
180
            Button commentButton = new Button(FontAwesome.COMMENT);
181
            commentButton.setStyleName(ValoTheme.BUTTON_BORDERLESS);
188

  
189
            Button messageButton = new Button(FontAwesome.COMMENT);
190
            messageButton.setStyleName(ValoTheme.BUTTON_TINY); //  + " " + RegistrationStyles.STYLE_FRIENDLY_FOREGROUND);
191
            if(dto.getMessages().isEmpty()){
192
                messageButton.setEnabled(false);
193
            } else {
194
                messageButton.addClickListener(e -> eventBus.publishEvent(
195
                        new ShowDetailsEvent<RegistrationDTO, Integer>(
196
                            e,
197
                            RegistrationDTO.class,
198
                            dto.getId(),
199
                            "messages"
200
                            )
201
                        )
202
                    );
203
            }
204
            messageButton.setCaption("<span class=\"" + RegistrationStyles.BUTTON_BADGE +"\"> " + dto.getMessages().size() + "</span>");
205
            messageButton.setCaptionAsHtml(true);
206

  
182 207
            Button editButton = new Button(FontAwesome.EDIT);
183
            editButton.setStyleName(ValoTheme.BUTTON_BORDERLESS);
208
            editButton.setStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_PRIMARY);
184 209

  
185 210
            namesTypesList.addComponent(new TypeStateLabel().update(dto.getRegistrationType(), dto.getStatus()), 0, row);
186 211
            namesTypesList.addComponent(new Label(dto.getSummary()), 1, row);
187
            namesTypesList.addComponent(commentButton, 2, row);
188
            namesTypesList.addComponent(editButton, 3, row);
212
            CssLayout buttonGroup = new CssLayout();
213
            buttonGroup.setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
214
            buttonGroup.addComponent(messageButton);
215
            buttonGroup.addComponent(editButton);
216
            namesTypesList.addComponent(buttonGroup, 2, row);
217
            namesTypesList.setComponentAlignment(buttonGroup, Alignment.TOP_RIGHT);
189 218
            row++;
190 219
        }
191 220
        namesTypesList.setSizeUndefined();
221
        namesTypesList.setWidth(100, Unit.PERCENTAGE);
222
        namesTypesList.setColumnExpandRatio(0, 0.1f);
223
        namesTypesList.setColumnExpandRatio(1, 0.9f);
192 224
        Panel namesTypesPanel = new Panel(namesTypesList);
193 225
        namesTypesPanel.setHeight("300px");
194 226
        return namesTypesPanel;
src/main/webapp/VAADIN/themes/edit-valo/edit-valo.scss
132 132
           display : inline;
133 133
        }
134 134
    }
135

  
136
   .friendly-foreground {
137
        color: $v-friendly-color;
138
    }
135 139
   
140
   .v-button .button-badge {
141
         @include valo-badge-style($states: inactive, $background-color: lighten($v-background-color, 10%), $active-color: $v-focus-color);
142
    } 
136 143
   
137 144
   .dashboard-actions {
138 145
      margin: 0 10%;
......
220 227
        }
221 228
    }
222 229

  
230
    #workingset {
231
            padding: round($v-unit-size / 2);
232
            .names-types-list, .registration-list-item {
233
                margin-top: round($v-unit-size / 2);
234
            }
235
    }
236

  
223 237
    // --------------------------------------------------- //
224 238
    
225 239
    .registration-list-item {

Also available in: Unified diff