Revision 0b44c814
Added by Andreas Kohlbecker about 7 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/component/phycobank/RegistrationWorkflowComponent.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.phycobank; |
|
10 |
|
|
11 |
import com.vaadin.ui.Button; |
|
12 |
import com.vaadin.ui.CssLayout; |
|
13 |
import com.vaadin.ui.Label; |
|
14 |
|
|
15 |
import eu.etaxonomy.cdm.vaadin.design.phycobank.RegistrationWorkflowDesign; |
|
16 |
|
|
17 |
/** |
|
18 |
* @author a.kohlbecker |
|
19 |
* @since Mar 3, 2017 |
|
20 |
* |
|
21 |
*/ |
|
22 |
public class RegistrationWorkflowComponent extends RegistrationWorkflowDesign { |
|
23 |
|
|
24 |
private static final long serialVersionUID = 7196791015737342650L; |
|
25 |
|
|
26 |
/** |
|
27 |
* @return the title |
|
28 |
*/ |
|
29 |
public Label getTitle() { |
|
30 |
return title; |
|
31 |
} |
|
32 |
|
|
33 |
/** |
|
34 |
* @return the workflow |
|
35 |
*/ |
|
36 |
public CssLayout getWorkflow() { |
|
37 |
return workflow; |
|
38 |
} |
|
39 |
|
|
40 |
/** |
|
41 |
* @return the stepIndex |
|
42 |
*/ |
|
43 |
public Button getStepIndex() { |
|
44 |
return stepIndex; |
|
45 |
} |
|
46 |
|
|
47 |
/** |
|
48 |
* @return the caption |
|
49 |
*/ |
|
50 |
|
|
51 |
public Label getCaptionLabel() { |
|
52 |
return caption; |
|
53 |
} |
|
54 |
|
|
55 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/design/phycobank/RegistrationWorkflowDesign.java | ||
---|---|---|
28 | 28 |
public RegistrationWorkflowDesign() { |
29 | 29 |
Design.read(this); |
30 | 30 |
} |
31 |
|
|
32 |
|
|
31 | 33 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/event/phycobank/RegistrationStartEvent.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.event.phycobank; |
|
10 |
|
|
11 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.RegistrationType; |
|
12 |
|
|
13 |
/** |
|
14 |
* @author a.kohlbecker |
|
15 |
* @since Mar 3, 2017 |
|
16 |
* |
|
17 |
*/ |
|
18 |
public class RegistrationStartEvent { |
|
19 |
|
|
20 |
private RegistrationType type; |
|
21 |
|
|
22 |
RegistrationStartEvent(RegistrationType type){ |
|
23 |
this.type = type; |
|
24 |
} |
|
25 |
|
|
26 |
/** |
|
27 |
* @return the type |
|
28 |
*/ |
|
29 |
public RegistrationType getType() { |
|
30 |
return type; |
|
31 |
} |
|
32 |
|
|
33 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/phycobank/RegistrationWorkflowPresenter.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.presenter.phycobank; |
|
10 |
|
|
11 |
import org.springframework.context.event.EventListener; |
|
12 |
|
|
13 |
import com.vaadin.spring.annotation.SpringComponent; |
|
14 |
import com.vaadin.spring.annotation.ViewScope; |
|
15 |
|
|
16 |
import eu.etaxonomy.cdm.vaadin.event.phycobank.RegistrationStartEvent; |
|
17 |
import eu.etaxonomy.cdm.vaadin.view.phycobank.RegistrationWorkflowView; |
|
18 |
import eu.etaxonomy.vaadin.mvp.AbstractPresenter; |
|
19 |
|
|
20 |
/** |
|
21 |
* @author a.kohlbecker |
|
22 |
* @since Mar 3, 2017 |
|
23 |
* |
|
24 |
*/ |
|
25 |
@SpringComponent |
|
26 |
@ViewScope |
|
27 |
public class RegistrationWorkflowPresenter extends AbstractPresenter<RegistrationWorkflowView> { |
|
28 |
|
|
29 |
private RegistrationType registrationType = null; |
|
30 |
|
|
31 |
/** |
|
32 |
* |
|
33 |
*/ |
|
34 |
public RegistrationWorkflowPresenter() { |
|
35 |
} |
|
36 |
|
|
37 |
@EventListener |
|
38 |
protected void onRegistrationStartEvent(RegistrationStartEvent e){ |
|
39 |
this.registrationType = e.getType(); |
|
40 |
getView().getTitle().setValue(getView().getTitle().getValue() + " " + registrationType.name()); |
|
41 |
|
|
42 |
} |
|
43 |
|
|
44 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/phycobank/DashBoardView.java | ||
---|---|---|
37 | 37 |
public DashBoardView() { |
38 | 38 |
Responsive.makeResponsive(dashboard); |
39 | 39 |
buttonNew.addClickListener(e -> eventBus.publishEvent(new NavigationEvent(StartRegistrationView.NAME))); |
40 |
buttonContinue.addClickListener(e -> eventBus.publishEvent(new NavigationEvent(RegistrationWorkflowView.NAME))); |
|
41 |
buttonList.addClickListener(e -> eventBus.publishEvent(new NavigationEvent(RegistrationWorkflowView.NAME))); |
|
40 |
buttonContinue.addClickListener(e -> eventBus.publishEvent(new NavigationEvent(RegistrationWorkflowViewBean.NAME)));
|
|
41 |
buttonList.addClickListener(e -> eventBus.publishEvent(new NavigationEvent(RegistrationWorkflowViewBean.NAME)));
|
|
42 | 42 |
} |
43 | 43 |
|
44 | 44 |
/** |
src/main/java/eu/etaxonomy/cdm/vaadin/view/phycobank/RegistrationWorkflowView.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.view.phycobank; |
|
10 |
|
|
11 |
import com.vaadin.ui.Button; |
|
12 |
import com.vaadin.ui.CssLayout; |
|
13 |
import com.vaadin.ui.Label; |
|
14 |
|
|
15 |
import eu.etaxonomy.vaadin.mvp.ApplicationView; |
|
16 |
|
|
17 |
/** |
|
18 |
* @author a.kohlbecker |
|
19 |
* @since Mar 3, 2017 |
|
20 |
* |
|
21 |
*/ |
|
22 |
public interface RegistrationWorkflowView extends ApplicationView{ |
|
23 |
|
|
24 |
Label getCaptionLabel(); |
|
25 |
|
|
26 |
Button getStepIndex(); |
|
27 |
|
|
28 |
CssLayout getWorkflow(); |
|
29 |
|
|
30 |
Label getTitle(); |
|
31 |
|
|
32 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/phycobank/RegistrationWorkflowViewBean.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.phycobank; |
10 | 10 |
|
11 |
import org.springframework.beans.factory.annotation.Autowired; |
|
12 |
|
|
11 | 13 |
import com.vaadin.navigator.View; |
12 | 14 |
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; |
13 | 15 |
import com.vaadin.spring.annotation.SpringView; |
16 |
import com.vaadin.ui.Button; |
|
17 |
import com.vaadin.ui.CssLayout; |
|
18 |
import com.vaadin.ui.Label; |
|
14 | 19 |
|
15 |
import eu.etaxonomy.cdm.vaadin.design.phycobank.RegistrationWorkflowDesign;
|
|
20 |
import eu.etaxonomy.cdm.vaadin.component.phycobank.RegistrationWorkflowComponent;
|
|
16 | 21 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.RegistrationType; |
22 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.RegistrationWorkflowPresenter; |
|
23 |
import eu.etaxonomy.vaadin.mvp.AbstractView; |
|
17 | 24 |
|
18 | 25 |
/** |
19 | 26 |
* @author a.kohlbecker |
20 | 27 |
* @since Mar 2, 2017 |
21 | 28 |
* |
22 | 29 |
*/ |
23 |
@SpringView(name=RegistrationWorkflowView.NAME) |
|
24 |
public class RegistrationWorkflowView extends RegistrationWorkflowDesign implements View { |
|
30 |
@SpringView(name=RegistrationWorkflowViewBean.NAME) |
|
31 |
public class RegistrationWorkflowViewBean extends AbstractView<RegistrationWorkflowPresenter> |
|
32 |
implements RegistrationWorkflowView, View { |
|
25 | 33 |
|
26 | 34 |
private static final long serialVersionUID = -213040114015958970L; |
27 | 35 |
|
28 | 36 |
public static final String NAME = "workflow"; |
29 | 37 |
|
30 |
RegistrationType regType = null; |
|
38 |
public RegistrationType regType = null; |
|
39 |
|
|
40 |
RegistrationWorkflowComponent design; |
|
41 |
|
|
42 |
public RegistrationWorkflowViewBean() { |
|
43 |
design = new RegistrationWorkflowComponent(); |
|
44 |
setCompositionRoot(design); |
|
45 |
} |
|
31 | 46 |
|
32 | 47 |
/** |
33 | 48 |
* {@inheritDoc} |
... | ... | |
38 | 53 |
String[] params = event.getParameters().split("/"); |
39 | 54 |
if(params.length > 0){ |
40 | 55 |
regType = RegistrationType.valueOf(params[0]); |
41 |
title.setValue(title.getValue() + " " + regType.name() + " ...");
|
|
56 |
design.getTitle().setValue(design.getTitle().getValue() + " " + regType.name() + " ...");
|
|
42 | 57 |
} |
43 | 58 |
} |
44 | 59 |
|
45 | 60 |
} |
46 | 61 |
|
62 |
/** |
|
63 |
* {@inheritDoc} |
|
64 |
*/ |
|
65 |
@Autowired |
|
66 |
@Override |
|
67 |
protected void injectPresenter(RegistrationWorkflowPresenter presenter) { |
|
68 |
setPresenter(presenter); |
|
69 |
} |
|
70 |
|
|
71 |
/* ------- RegistrationWorkflowView implementation ------- */ |
|
72 |
|
|
73 |
/** |
|
74 |
* @return the title |
|
75 |
*/ |
|
76 |
@Override |
|
77 |
public Label getTitle() { |
|
78 |
return design.getTitle(); |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* @return the workflow |
|
83 |
*/ |
|
84 |
@Override |
|
85 |
public CssLayout getWorkflow() { |
|
86 |
return design.getWorkflow(); |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* @return the stepIndex |
|
91 |
*/ |
|
92 |
@Override |
|
93 |
public Button getStepIndex() { |
|
94 |
return design.getStepIndex(); |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* @return the caption |
|
99 |
*/ |
|
100 |
|
|
101 |
@Override |
|
102 |
public Label getCaptionLabel() { |
|
103 |
return design.getCaptionLabel(); |
|
104 |
} |
|
47 | 105 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/phycobank/StartRegistrationView.java | ||
---|---|---|
35 | 35 |
ApplicationEventPublisher eventBus; |
36 | 36 |
|
37 | 37 |
public StartRegistrationView() { |
38 |
buttonName.addClickListener(e -> eventBus.publishEvent(new NavigationEvent(RegistrationWorkflowView.NAME+ "/" + RegistrationType.name))); |
|
38 |
buttonName.addClickListener(e -> eventBus.publishEvent(new NavigationEvent(RegistrationWorkflowViewBean.NAME+ "/" + RegistrationType.name)));
|
|
39 | 39 |
} |
40 | 40 |
|
41 | 41 |
/** |
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractView.java | ||
---|---|---|
5 | 5 |
import javax.annotation.PostConstruct; |
6 | 6 |
|
7 | 7 |
import org.springframework.beans.BeansException; |
8 |
import org.springframework.beans.factory.annotation.Autowired; |
|
8 | 9 |
import org.springframework.context.ApplicationContext; |
9 | 10 |
import org.springframework.context.ApplicationContextAware; |
11 |
import org.springframework.context.ApplicationEventPublisher; |
|
10 | 12 |
|
11 | 13 |
import com.vaadin.ui.CustomComponent; |
12 | 14 |
|
13 | 15 |
/** |
14 | 16 |
* AbstractView is the base class of all MVP views. It takes care of finding |
15 | 17 |
* appropriate presenter component for the view. |
16 |
*
|
|
18 |
* |
|
17 | 19 |
* @param |
18 | 20 |
* <P> |
19 | 21 |
* type of the presenter this view uses. |
20 |
*
|
|
22 |
* |
|
21 | 23 |
* @author Peter / Vaadin |
22 | 24 |
*/ |
23 | 25 |
public abstract class AbstractView<P extends AbstractPresenter> extends CustomComponent |
... | ... | |
27 | 29 |
|
28 | 30 |
private ApplicationContext applicationContext; |
29 | 31 |
|
32 |
@Autowired |
|
33 |
ApplicationEventPublisher eventBus; |
|
34 |
|
|
30 | 35 |
@PostConstruct |
31 | 36 |
protected final void init() { |
32 | 37 |
Logger.getLogger(getClass().getSimpleName()).info("View init"); |
Also available in: Unified diff
ref #6169 using mvp for the RegistrationWorkflowView