Project

General

Profile

« Previous | Next » 

Revision 664d0a00

Added by Andreas Kohlbecker about 7 years ago

ref #6169 visualization of RegistrationWorkingSets in the workflow view

View differences:

src/main/java/eu/etaxonomy/cdm/mock/RegistrationStatus.java
15 15
    READY, //The record has passed the validation by the curator and is ready for publication.
16 16
    PUBLISHED, //The name or typification has finally been published.
17 17
    REJECTED //The registration has been rejected, the process is aborted and the record is preserved.
18

  
18 19
}
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/AccordionWorkflow.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
import com.vaadin.ui.Accordion;
12
import com.vaadin.ui.Component;
13

  
14
/**
15
 * @author a.kohlbecker
16
 * @since Mar 27, 2017
17
 *
18
 */
19
public class AccordionWorkflow extends Accordion {
20

  
21
    private static final long serialVersionUID = -3279853764419918649L;
22

  
23
    public AccordionWorkflow() {
24
        super();
25
        init();
26
    }
27

  
28
    public AccordionWorkflow(Component... components) {
29
        super(components);
30
        init();
31
    }
32

  
33
    /**
34
     *
35
     */
36
    private void init() {
37
        setTabCaptionsAsHtml(true);
38
    }
39
}
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItem.java
79 79
    public void init() {
80 80

  
81 81
        setWidth(100, Unit.PERCENTAGE);
82
        addStyleName("registration-item");
82
        addStyleName("registration-list-item");
83 83

  
84 84
        typeStateLabel.setStyleName(STYLE_LABEL_NOWRAP);
85 85
        addComponent(typeStateLabel, 0, 0);
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/WorkflowBulletItem.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
import com.vaadin.ui.Button.ClickListener;
12

  
13
import eu.etaxonomy.cdm.vaadin.design.registration.WorkflowItemDesign;
14

  
15
/**
16
 * @author a.kohlbecker
17
 * @since Mar 10, 2017
18
 *
19
 */
20
public class WorkflowBulletItem extends WorkflowItemDesign {
21

  
22
    private static final long serialVersionUID = -6825656185698773467L;
23

  
24
    /**
25
     *
26
     */
27
    public WorkflowBulletItem(int stepIndex, String caption, ClickListener listener) {
28
        this.stepIndex.setCaption(Integer.toString(stepIndex));
29
        this.caption.setValue(caption);
30
        if(listener != null){
31
            this.stepIndex.addClickListener(listener);
32
        }
33
    }
34

  
35
    @Override
36
    public void setCaption(String text){
37
        this.caption.setValue(text);
38
    }
39

  
40
}
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/WorkflowItem.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
import com.vaadin.ui.Button.ClickListener;
12

  
13
import eu.etaxonomy.cdm.vaadin.design.registration.WorkflowItemDesign;
14

  
15
/**
16
 * @author a.kohlbecker
17
 * @since Mar 10, 2017
18
 *
19
 */
20
public class WorkflowItem extends WorkflowItemDesign {
21

  
22
    private static final long serialVersionUID = -6825656185698773467L;
23

  
24
    /**
25
     *
26
     */
27
    public WorkflowItem(int stepIndex, String caption, ClickListener listener) {
28
        this.stepIndex.setCaption(Integer.toString(stepIndex));
29
        this.caption.setValue(caption);
30
        if(listener != null){
31
            this.stepIndex.addClickListener(listener);
32
        }
33
    }
34

  
35
    @Override
36
    public void setCaption(String text){
37
        this.caption.setValue(text);
38
    }
39

  
40
}
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/WorkflowSteps.java
25 25
        // TODO Auto-generated constructor stub
26 26
    }
27 27

  
28
    public void appendWorkflowItem(WorkflowItem item){
28
    public void appendWorkflowItem(WorkflowBulletItem item){
29 29
        this.steps.addComponent(item);
30 30
    }
31 31

  
32 32
    public void appendNewWorkflowItem(int stepIndex, String caption, ClickListener listener){
33
        this.steps.addComponent(new WorkflowItem(stepIndex, caption, listener));
33
        this.steps.addComponent(new WorkflowBulletItem(stepIndex, caption, listener));
34 34
    }
35 35

  
36 36
}
src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/RegistrationWorkingSet.java
14 14
import java.util.Set;
15 15

  
16 16
import eu.etaxonomy.cdm.mock.Registration;
17
import eu.etaxonomy.cdm.mock.RegistrationStatus;
17 18
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
18 19
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationDTO;
19 20
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationValidationException;
......
106 107
        return regs;
107 108
    }
108 109

  
110
    /**
111
     * Calculates the total count of messages in the registrations contained
112
     * in the working set.
113
     *
114
     * @return
115
     */
116
    public int messagesCount() {
117
        int messagesCount = 0;
118
        for(RegistrationDTO dto : getRegistrationDTOs()) {
119
            messagesCount = messagesCount + dto.getMessages().size();
120
        }
121
        return messagesCount;
122
    }
123

  
124
    /**
125
     * Finds the lowest status in the registrations contained
126
     * in the working set.
127
     *
128
     * @return
129
     */
130
    public RegistrationStatus lowestStatus() {
131
        RegistrationStatus status = RegistrationStatus.REJECTED;
132
        for(RegistrationDTO dto : getRegistrationDTOs()) {
133
            if(dto.getStatus().compareTo(status) < 0){
134
                status = dto.getStatus();
135
            }
136
        }
137
        return status;
138
    }
139

  
140

  
109 141
    /**
110 142
     * @return the registrations
111 143
     */
......
127 159
        return citation;
128 160
    }
129 161

  
130

  
131

  
132

  
133 162
}
src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/WorkflowStep.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.model.registration;
10

  
11
import org.apache.commons.lang.StringEscapeUtils;
12

  
13
import eu.etaxonomy.cdm.mock.RegistrationStatus;
14

  
15
/**
16
 * @author a.kohlbecker
17
 * @since Mar 28, 2017
18
 *
19
 */
20
public enum WorkflowStep {
21

  
22
    PUBLICATION_DETAILS(0, "Publication"),
23
    NAMES_N_TYPES(1, "Names & Types"),
24
    CURATION(2, "Curation"),
25
    AWAITING_PUBLICATION(3, "Awaiting publication"),
26
    PUBLISHED(3, "Awaiting publication"),
27
    REJECTED(3, "Rejected");
28

  
29
    private String representation;
30
    private int stepIndex = -1;
31

  
32
    private WorkflowStep(int stepIndex, String representation){
33
        this.stepIndex = stepIndex;
34
        this.representation = representation;
35
    }
36

  
37
    /**
38
     * @return the representation
39
     */
40
    public String getRepresentation() {
41
        return representation;
42
    }
43

  
44
    /**
45
     * @return the stepIndex
46
     */
47
    public int getStepIndex() {
48
        return stepIndex;
49
    }
50

  
51
    public String getHtml(){
52
        return StringEscapeUtils.escapeHtml(getRepresentation());
53
    }
54

  
55
    public static WorkflowStep from(RegistrationStatus status, boolean citationDetailsReady) {
56
        if(!citationDetailsReady){
57
            return PUBLICATION_DETAILS;
58
        } else {
59
            switch(status) {
60
            case CURATION:
61
                return CURATION;
62
            case PUBLISHED:
63
                return PUBLISHED;
64
            case REJECTED:
65
                return REJECTED;
66
            case PREPARATION:
67
                return PUBLICATION_DETAILS;
68
            case READY:
69
                return AWAITING_PUBLICATION;
70
            default:
71
                /* this should never happen */
72
                return null;
73
            }
74
        }
75
    }
76
}
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/registration/RegistrationWorkflowPresenter.java
75 75
            getView().setHeaderText("Registration for " + workingset.getCitation());
76 76
        }
77 77
        if(workingset != null){
78
            // getView().getTitle().setValue("Workflow for a " + registrationType().name());
79
            for(Registration reg : workingset.getRegistrations()){
80
                getView().makeWorflow(RegistrationType.from(reg));
81
            }
78
            getView().setWorkingset(workingset);
79
            //TODO add Blocking registrations to view
82 80
        }
83 81
    }
84 82

  
src/main/java/eu/etaxonomy/cdm/vaadin/ui/RegistrationUI.java
90 90
        //navigate to initial view
91 91
        eventBus.publishEvent(new NavigationEvent(DashBoardView.NAME));
92 92

  
93
        //TODO the branding should be read from a properties file in .cdmLibrary/{instance-name}/cdm-vaadin.properties
94
        //  See CdmUtils for appropriate methods to access this folder
95 93
        String brand = "phycobank";
96

  
94
        //TODO create annotation:
95
        // @Styles(files={""}, branding="brand")
96
        //
97
        // the branding can either be specified or can be read from a properties file in .cdmLibrary/{instance-name}/cdm-vaadin.properties
98
        //  See CdmUtils for appropriate methods to access this folder
97 99
        // the 'vaadin://' protocol refers to the VAADIN folder
98 100
        Resource registryCssFile = new ExternalResource("vaadin://branding/" + brand + "/css/branding.css");
99 101
        Page.getCurrent().getStyles().add(registryCssFile);
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowView.java
12 12

  
13 13
import com.vaadin.ui.CssLayout;
14 14

  
15
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationType;
15
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
16
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationDTO;
16 17
import eu.etaxonomy.vaadin.mvp.ApplicationView;
17 18

  
18 19
/**
......
42 43
     */
43 44
    void openReferenceEditor(UUID referenceUuid);
44 45

  
45
    public void makeWorflow(RegistrationType type);
46

  
47

  
48 46
    /**
49 47
     * @param subheaderText
50 48
     */
......
55 53
     */
56 54
    void setHeaderText(String subheaderText);
57 55

  
56
    /**
57
     * @param workingset
58
     */
59
    void setWorkingset(RegistrationWorkingSet workingset);
60

  
61
    void addBlockingRegistration(RegistrationDTO blocking);
62

  
58 63

  
59 64

  
60 65
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowViewBean.java
8 8
*/
9 9
package eu.etaxonomy.cdm.vaadin.view.registration;
10 10

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

  
13 15
import org.springframework.beans.factory.annotation.Autowired;
14 16

  
15 17
import com.vaadin.navigator.View;
16 18
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
19
import com.vaadin.server.FontAwesome;
20
import com.vaadin.server.GenericFontIcon;
17 21
import com.vaadin.spring.annotation.SpringView;
22
import com.vaadin.ui.Alignment;
23
import com.vaadin.ui.Button;
24
import com.vaadin.ui.Component;
18 25
import com.vaadin.ui.CssLayout;
26
import com.vaadin.ui.GridLayout;
27
import com.vaadin.ui.Label;
28
import com.vaadin.ui.themes.ValoTheme;
19 29

  
30
import eu.etaxonomy.cdm.mock.RegistrationStatus;
20 31
import eu.etaxonomy.cdm.vaadin.component.registration.WorkflowSteps;
21 32
import eu.etaxonomy.cdm.vaadin.event.EntityEventType;
22 33
import eu.etaxonomy.cdm.vaadin.event.ReferenceEvent;
23 34
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEvent;
24 35
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent;
36
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
37
import eu.etaxonomy.cdm.vaadin.model.registration.WorkflowStep;
38
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationDTO;
25 39
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationType;
26 40
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationWorkflowPresenter;
27 41
import eu.etaxonomy.cdm.vaadin.view.AbstractPageView;
......
50 64

  
51 65
    public RegistrationType regType = null;
52 66

  
53
    CssLayout workflow;
67
    private CssLayout workflow;
68

  
69
    private List<CssLayout> registrations = new ArrayList<>();
54 70

  
55 71
    private String headerText = "-- empty --";
56 72
    private String subheaderText = SUBHEADER_DEEFAULT;
57 73

  
74

  
58 75
    public RegistrationWorkflowViewBean() {
59 76
        super();
60 77

  
......
85 102
        }
86 103
    }
87 104

  
105
    /**
106
     * {@inheritDoc}
107
     */
108
    @Override
109
    public void setWorkingset(RegistrationWorkingSet workingset) {
110

  
111
        CssLayout registration = new CssLayout();
112
        registration.setWidth(100, Unit.PERCENTAGE);
113
        registration.addComponent(createRegistrationCaption(workingset));
114
        registrations.add(registration);
115
        workflow.addComponent(registration);
116

  
117
    }
118

  
119
    /**
120
     * @param workingset
121
     * @return
122
     */
123
    private Component createRegistrationCaption(RegistrationWorkingSet workingset) {
124
        String citation = workingset.getCitation();
125
        int messagesCount = workingset.messagesCount();
126
        RegistrationStatus status = workingset.lowestStatus();
127

  
128
        return createRegistrationCaption(citation, status, messagesCount);
129
    }
130

  
131
    /**
132
     * @param workingset
133
     * @return
134
     */
135
    private Component createRegistrationCaption(RegistrationDTO regitrationDto) {
136
        String citation = regitrationDto.getCitation();
137
        int messagesCount = regitrationDto.getMessages().size();
138
        RegistrationStatus status = regitrationDto.getStatus();
139

  
140
        return createRegistrationCaption(citation, status, messagesCount);
141
    }
142

  
143
    /**
144
     * @param workingset
145
     * @return
146
     */
147
    private Component createRegistrationCaption(String citation, RegistrationStatus status, int messagesCount){
148

  
149
        GridLayout grid = new GridLayout(2, 1);
150
        grid.addStyleName("registration-workflow-item");
151
        grid.setWidth(100, Unit.PERCENTAGE);
152
        Label citationLabel = new Label(citation);
153
        grid.addComponent(citationLabel, 0, 0);
154
        grid.setColumnExpandRatio(0, 1.0f);
155

  
156
        CssLayout iconContainer = new CssLayout();
157
        iconContainer.setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
158
        if(messagesCount > 0){
159
            Button messagesButton = new Button(FontAwesome.COMMENT);
160
            messagesButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
161
            iconContainer.addComponent(messagesButton);
162
        }
163

  
164
        WorkflowStep step = WorkflowStep.from(status, citation != null && !citation.isEmpty());
165
        Label statusIndicator = new Label(WorkflowStep.from(status, citation != null && !citation.isEmpty()).getHtml());
166
        statusIndicator.setCaptionAsHtml(true);
167
        statusIndicator.setStyleName("workflow-step label-nowrap");
168
        statusIndicator.setIcon(new GenericFontIcon("IcoMoon", 0xe900)); // triangle-right
169
        CssLayout statusWrap = new CssLayout(statusIndicator);
170
        statusWrap.setStyleName("workflow-step-wrap bg-status-" + status.name());
171
        iconContainer.addComponent(statusWrap);
172

  
173
        grid.addComponent(iconContainer, 1, 0);
174
        grid.setComponentAlignment(iconContainer, Alignment.TOP_RIGHT);
175

  
176
        return grid;
177
    }
178

  
179
    /**
180
     * {@inheritDoc}
181
     */
88 182
    @Override
89
    public void makeWorflow(RegistrationType type){
90
        switch (type) {
91
        case NAME:
92
            addNameWorkflow();
93
            break;
94
        case TYPIFICATION:
95
            addTypificationWorkflow();
96
            break;
97
        default:
98
            break;
183
    public void addBlockingRegistration(RegistrationDTO blocking) {
184
        if(registrations == null) {
185
            throw new RuntimeException("A Workingset must be present prior adding blocking registrations.");
99 186
        }
187
        // add the blocking registration
188

  
100 189
    }
101 190

  
102 191
    /**
103 192
    *
104 193
    */
105
   private void addNameWorkflow() {
194
   private void addBulletWorkflowName() {
106 195
       WorkflowSteps steps = new WorkflowSteps();
107 196
       steps.appendNewWorkflowItem(1, "Publication details including the publisher.",
108 197
               e -> eventBus.publishEvent(new ReferenceEvent(EntityEventType.EDIT)));
......
116 205
   /**
117 206
   *
118 207
   */
119
  private void addTypificationWorkflow() {
208
  private void addBulletWorkflowTypification() {
120 209
      WorkflowSteps steps = new WorkflowSteps();
121 210
      steps.appendNewWorkflowItem(1, "Publication details including the publisher.",
122 211
              e -> eventBus.publishEvent(new ReferenceEvent(EntityEventType.EDIT)));
src/main/webapp/VAADIN/fonts/icomoon.svg
1
<?xml version="1.0" standalone="no"?>
2
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
<svg xmlns="http://www.w3.org/2000/svg">
4
<metadata>Generated by IcoMoon</metadata>
5
<defs>
6
<font id="icomoon" horiz-adv-x="1024">
7
<font-face units-per-em="1024" ascent="960" descent="-64" />
8
<missing-glyph horiz-adv-x="1024" />
9
<glyph unicode="&#x20;" horiz-adv-x="512" d="" />
10
<glyph unicode="&#xe900;" glyph-name="icon-triangle-right" horiz-adv-x="208" d="M0.033 959.853l203.717-511.79-203.684-511.919z" />
11
</font></defs></svg>
src/main/webapp/VAADIN/fonts/test.txt
1
Hello
src/main/webapp/VAADIN/themes/edit-valo/edit-valo.scss
51 51

  
52 52
@import "../valo/valo.scss";
53 53

  
54

  
55
// ========================================== //
56

  
57
// import custom font icons TODO rename font
58
@include v-font(IcoMoon, "../../../../../fonts/icomoon");
59

  
60
.IcoMoon {
61
   font-family: IcoMoon;
62
   font-style: normal;
63
   font-weight: normal;
64
   -webkit-font-smoothing: antialiased;
65
   -moz-osx-font-smoothing: grayscale;
66
   display: inline-block;
67
   text-align: center;
68
}
69

  
54 70
// ========================================== //
55 71
// Status colors for the redistration
56 72
// 
......
205 221

  
206 222
    // --------------------------------------------------- //
207 223
    
208
    .registration-item {
224
    .registration-list-item {
209 225
        border-top: valo-border($border: $v-border, $color: $v-background-color, $strength: 0.7);
210 226
        padding-top: 4px; // avoid button group to overlap with border
211 227
    }
228

  
229
   .registration-workflow-item {
230
       border: valo-border($border: $v-border, $color: $v-background-color, $strength: 0.7);
231
    }
232

  
233
    // tab element being part of a process ----------- //
234
    .workflow-step-wrap {
235
        padding-right: 10px;
236
        height: $v-font-size * 3;
237
        background-color: scale-color(lighten($v-app-background-color, 20%), $saturation: -20%);
238
        @include box-shadow(inset 0 0 5px $v-app-background-color);
239
    }
240
    .workflow-step {
241
        line-height: $v-font-size * 3;
242
    }
243
    .v-caption-workflow-step {
244
        vertical-align: top;
245
        padding: 0;
246
         .v-icon {
247
            line-height: $v-font-size * 3;
248
            font-size: $v-font-size * 3.5;
249
            padding-right: 10px;
250
            color: $v-background-color;
251
        }
252
  
253
    }
254

  
255
    // ----------------------------------------------- //
256
    .status-REJECTED {
257
        color: $status-rejected-color;
258
    }
259
    .status-CURATION {
260
        color: $status-curation-color;
261
    }
262
    .status-PREPARATION {
263
        color: $status-preparation-color;
264
    }
265
    .status-PUBLISHED {
266
        color: $status-published-color;
267
    }
268
    .status-READY {
269
        color: $status-ready-color;
270
    }
271

  
272
    .bg-status-REJECTED {
273
        background-color: $status-rejected-color;
274
    }
275
    .bg-status-CURATION {
276
        background-color: $status-curation-color;
277
    }
278
    .bg-status-PREPARATION {
279
        background-color: $status-preparation-color;
280
    }
281
    .bg-status-PUBLISHED {
282
        background-color: $status-published-color;
283
    }
284
    .bg-status-READY {
285
        background-color: $status-ready-color;
286
    }
287
    // ----------------------------------------------- //
212 288
    
213 289
    #registration-list {
214 290
        /* --- for the css layout --- */
......
252 328
                color: $status-ready-color;
253 329
            }
254 330
        }
255
        // for RegistrationItems
256
        .v-caption-status-REJECTED {
257
            color: $status-rejected-color;
258
        }
259
        .v-caption-status-CURATION {
260
            color: $status-curation-color;
261
        }
262
        .v-caption-status-PREPARATION {
263
            color: $status-preparation-color;
264
        }
265
        .v-caption-status-PUBLISHED {
266
            color: $status-published-color;
267
        }
268
        .v-caption-status-READY {
269
            color: $status-ready-color;
270
        }
271 331
    }
272 332

  
273 333

  

Also available in: Unified diff