Project

General

Profile

Revision 4c82bcaa

ID4c82bcaa8894ba8c539a7ce6eabd0b1b9adbc431
Parent 8343ec26
Child 7cef91f1

Added by Alexander Oppermann almost 6 years ago

Migrating Vaadin into separate Project

  • implementing mvp pattern
  • creating an app structure
  • visual editing via visual designer possible

View differences:

.gitattributes
5 5
src/main/java/eu/etaxonomy/cdm/vaadin/CdmAppInitializer.java.bkp -text
6 6
src/main/java/eu/etaxonomy/cdm/vaadin/container/CdmSQLContainer.java -text
7 7
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/AuthenticationPresenter.java -text
8
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/DistributionSelectionPresenter.java -text
9
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/DistributionTablePresenter.java -text
8 10
src/main/java/eu/etaxonomy/cdm/vaadin/servlet/CdmVaadinConversationalServlet.java -text
9 11
src/main/java/eu/etaxonomy/cdm/vaadin/ui/AbstractAuthenticatedUI.java -text
10 12
src/main/java/eu/etaxonomy/cdm/vaadin/ui/CheckUI.java -text
13
src/main/java/eu/etaxonomy/cdm/vaadin/ui/DbStatusUI.java -text
11 14
src/main/java/eu/etaxonomy/cdm/vaadin/util/CdmSpringContextHelper.java -text
12 15
src/main/java/eu/etaxonomy/cdm/vaadin/view/AuthenticationView.java -text
13 16
src/main/java/eu/etaxonomy/cdm/vaadin/view/IAuthenticationComponent.java -text
17
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionSelectionView.java -text
18
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionTableView.java -text
19
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/IDistributionSelectionComponent.java -text
20
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/IDistributionTableComponent.java -text
14 21
src/main/resources/log4j.properties -text
15 22
src/main/webapp/META-INF/MANIFEST.MF -text
16 23
src/main/webapp/META-INF/context.xml -text
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/DistributionSelectionPresenter.java
1
package eu.etaxonomy.cdm.vaadin.presenter.dbstatus;
2

  
3
import java.util.Arrays;
4
import java.util.List;
5

  
6
import eu.etaxonomy.cdm.api.service.IClassificationService;
7
import eu.etaxonomy.cdm.api.service.IVocabularyService;
8
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
9
import eu.etaxonomy.cdm.model.common.TermType;
10
import eu.etaxonomy.cdm.model.common.TermVocabulary;
11
import eu.etaxonomy.cdm.model.taxon.Classification;
12
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper;
13
import eu.etaxonomy.cdm.vaadin.view.dbstatus.DistributionSelectionView;
14
import eu.etaxonomy.cdm.vaadin.view.dbstatus.IDistributionSelectionComponent;
15

  
16
public class DistributionSelectionPresenter implements IDistributionSelectionComponent.DistributionSelectionComponentListener {
17

  
18
	DistributionSelectionView view;
19
	
20
	public DistributionSelectionPresenter(DistributionSelectionView dsv) {
21
		this.view = dsv;
22
		view.addListener(this);
23
		view.dataBinding();
24
	}
25
	
26
	@Override
27
	public void buttonClick(Classification classification, TermVocabulary<DefinedTermBase> term) {
28
		// TODO retrieve classification.UUID and term.UUID and save this in the vaadinSession
29
		// TODO move on the final table and load it
30
	}
31

  
32
	@Override
33
	public List<Classification> getClassificationList() {
34
		IClassificationService classificationService = (IClassificationService)CdmSpringContextHelper.newInstance().getBean("classificationServiceImpl");
35
		//TODO replace the list by UUID and TITLECACHE 
36
		//classificationService.getUuidAndTitleCache();
37
		List<Classification> classificationList = classificationService.listClassifications(null, null, null, NODE_INIT_STRATEGY());
38
		return classificationList;
39
	}
40

  
41
	@Override
42
	public List<TermVocabulary<DefinedTermBase>> getNamedAreaList() {
43
		
44
		IVocabularyService vocabularyService = (IVocabularyService)CdmSpringContextHelper.newInstance().getBean("vocabularyServiceImpl");
45
		List<TermVocabulary<DefinedTermBase>> termList = vocabularyService.findByTermType(TermType.NamedArea);
46
		return termList;
47
	}
48

  
49
	 private List<String> NODE_INIT_STRATEGY(){
50
	        return Arrays.asList(new String[]{
51
	            "taxon.sec",
52
	            "taxon.name",
53
	            "classification"
54
	    });}
55
}
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/DistributionTablePresenter.java
1
package eu.etaxonomy.cdm.vaadin.presenter.dbstatus;
2

  
3
import eu.etaxonomy.cdm.vaadin.view.dbstatus.IDistributionTableComponent;
4

  
5

  
6
public class DistributionTablePresenter implements IDistributionTableComponent.DistributionTableComponentListener{
7

  
8
}
src/main/java/eu/etaxonomy/cdm/vaadin/ui/DbStatusUI.java
1
package eu.etaxonomy.cdm.vaadin.ui;
2

  
3
import javax.servlet.annotation.WebServlet;
4

  
5
import com.vaadin.annotations.Theme;
6
import com.vaadin.annotations.VaadinServletConfiguration;
7
import com.vaadin.navigator.Navigator;
8
import com.vaadin.navigator.View;
9
import com.vaadin.server.VaadinRequest;
10
import com.vaadin.ui.UI;
11

  
12
import eu.etaxonomy.cdm.vaadin.presenter.dbstatus.DistributionSelectionPresenter;
13
import eu.etaxonomy.cdm.vaadin.servlet.CdmVaadinConversationalServlet;
14
import eu.etaxonomy.cdm.vaadin.view.dbstatus.DistributionSelectionView;
15

  
16
@Theme("mytheme")
17
@SuppressWarnings("serial")
18
public class DbStatusUI extends AbstractAuthenticatedUI{
19

  
20
	//    @WebServlet(value = "/*", asyncSupported = true, initParams = {
21
	//			@WebInitParam(name="org.atmosphere.cpr.asyncSupport", value="org.atmosphere.container.Jetty9AsyncSupportWithWebSocket")
22
	//	})
23

  
24
	private static final String FIRST_VIEW = "selection";
25
	
26
	@WebServlet(value = {"/app/dbstatus/*", "/VAADIN/*"}, asyncSupported = true)
27
	@VaadinServletConfiguration(productionMode = false, ui = DbStatusUI.class, widgetset = "eu.etaxonomy.cdm.vaadin.AppWidgetSet")
28
	public static class Servlet extends CdmVaadinConversationalServlet {
29
	}
30

  
31

  
32
	@Override
33
	protected void doInit() {
34
		DistributionSelectionView dsv = new DistributionSelectionView();
35
		new DistributionSelectionPresenter(dsv);
36
		UI.getCurrent().getNavigator().addView("selection", dsv);
37
	}
38

  
39
	@Override
40
	public String getFirstViewName() {
41
		return FIRST_VIEW;
42
	}
43

  
44

  
45
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionSelectionView.java
1
package eu.etaxonomy.cdm.vaadin.view.dbstatus;
2

  
3
import java.util.List;
4

  
5
import javax.annotation.PostConstruct;
6

  
7
import com.vaadin.annotations.AutoGenerated;
8
import com.vaadin.data.Container;
9
import com.vaadin.data.util.IndexedContainer;
10
import com.vaadin.event.ShortcutAction.KeyCode;
11
import com.vaadin.navigator.View;
12
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
13
import com.vaadin.ui.Accordion;
14
import com.vaadin.ui.Alignment;
15
import com.vaadin.ui.Button;
16
import com.vaadin.ui.Button.ClickEvent;
17
import com.vaadin.ui.Button.ClickListener;
18
import com.vaadin.ui.CustomComponent;
19
import com.vaadin.ui.Label;
20
import com.vaadin.ui.OptionGroup;
21
import com.vaadin.ui.Panel;
22
import com.vaadin.ui.VerticalLayout;
23

  
24
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
25
import eu.etaxonomy.cdm.model.common.TermVocabulary;
26
import eu.etaxonomy.cdm.model.taxon.Classification;
27

  
28
public class DistributionSelectionView extends CustomComponent implements IDistributionSelectionComponent, View, ClickListener{
29

  
30
	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
31

  
32
	/**
33
	 * 
34
	 */
35
	private static final long serialVersionUID = 1L;
36
	@AutoGenerated
37
	private VerticalLayout mainLayout;
38
	@AutoGenerated
39
	private Panel panel_1;
40
	@AutoGenerated
41
	private VerticalLayout verticalLayout_2;
42
	@AutoGenerated
43
	private Button button_proceed;
44
	@AutoGenerated
45
	private Accordion accordion;
46
	@AutoGenerated
47
	private OptionGroup distributionSelection;
48
	@AutoGenerated
49
	private OptionGroup classificationSelection;
50
	@AutoGenerated
51
	private Label label_1;
52
	private DistributionSelectionComponentListener distListener;
53
	/**
54
	 * The constructor should first build the main layout, set the
55
	 * composition root and then do any custom initialization.
56
	 *
57
	 * The constructor will not be automatically regenerated by the
58
	 * visual editor.
59
	 */
60
	public DistributionSelectionView(){
61
		buildMainLayout();
62
		setCompositionRoot(mainLayout);
63
		
64
		button_proceed.addClickListener(this);
65
		button_proceed.setClickShortcut(KeyCode.ENTER, null);
66
	}
67
	
68
	
69
	@Override
70
	public void addListener(DistributionSelectionComponentListener listener) {
71
		distListener = listener;
72
	}
73
	
74
	@Override
75
	public void buttonClick(ClickEvent event) {
76
		if(classificationSelection != null && distributionSelection != null){
77
			Classification classification = (Classification) classificationSelection.getValue();
78
			TermVocabulary<DefinedTermBase> term = (TermVocabulary<DefinedTermBase>)distributionSelection.getValue();
79
			distListener.buttonClick(classification, term);
80
		}
81
	}
82
	
83
	public void dataBinding(){
84
		List<Classification> classificationList = distListener.getClassificationList();
85
		List<TermVocabulary<DefinedTermBase>> namedAreaList = distListener.getNamedAreaList();
86
		Container c = new IndexedContainer(classificationList);
87
		classificationSelection.setContainerDataSource(c);
88
		Container d = new IndexedContainer(namedAreaList);
89
		distributionSelection.setContainerDataSource(d);
90
	}
91
	
92
	@Override
93
	public void enter(ViewChangeEvent event) {
94
	}
95

  
96
	@AutoGenerated
97
	private VerticalLayout buildMainLayout() {
98
		// common part: create layout
99
		mainLayout = new VerticalLayout();
100
		mainLayout.setImmediate(false);
101
		mainLayout.setWidth("100%");
102
		mainLayout.setHeight("100%");
103
		mainLayout.setMargin(false);
104
		
105
		// top-level component properties
106
		setWidth("100.0%");
107
		setHeight("100.0%");
108
		
109
		// panel_1
110
		panel_1 = buildPanel_1();
111
		mainLayout.addComponent(panel_1);
112
		mainLayout.setComponentAlignment(panel_1, new Alignment(48));
113
		
114
		return mainLayout;
115
	}
116

  
117
	@AutoGenerated
118
	private Panel buildPanel_1() {
119
		// common part: create layout
120
		panel_1 = new Panel();
121
		panel_1.setImmediate(false);
122
		panel_1.setWidth("-1px");
123
		panel_1.setHeight("-1px");
124
		
125
		// verticalLayout_2
126
		verticalLayout_2 = buildVerticalLayout_2();
127
		panel_1.setContent(verticalLayout_2);
128
		
129
		return panel_1;
130
	}
131

  
132
	@AutoGenerated
133
	private VerticalLayout buildVerticalLayout_2() {
134
		// common part: create layout
135
		verticalLayout_2 = new VerticalLayout();
136
		verticalLayout_2.setImmediate(false);
137
		verticalLayout_2.setWidth("-1px");
138
		verticalLayout_2.setHeight("-1px");
139
		verticalLayout_2.setMargin(true);
140
		verticalLayout_2.setSpacing(true);
141
		
142
		// label_1
143
		label_1 = new Label();
144
		label_1.setImmediate(false);
145
		label_1.setWidth("213px");
146
		label_1.setHeight("-1px");
147
		label_1.setValue("Please choose a Classification and a distribution area to proceed.");
148
		verticalLayout_2.addComponent(label_1);
149
		
150
		// accordion
151
		accordion = buildAccordion();
152
		verticalLayout_2.addComponent(accordion);
153
		verticalLayout_2.setComponentAlignment(accordion, new Alignment(48));
154
		
155
		// button_1
156
		button_proceed = new Button();
157
		button_proceed.setCaption("Proceed");
158
		button_proceed.setImmediate(true);
159
		button_proceed.setWidth("-1px");
160
		button_proceed.setHeight("-1px");
161
		verticalLayout_2.addComponent(button_proceed);
162
		verticalLayout_2.setComponentAlignment(button_proceed, new Alignment(10));
163
		
164
		return verticalLayout_2;
165
	}
166

  
167
	@AutoGenerated
168
	private Accordion buildAccordion() {
169
		// common part: create layout
170
		accordion = new Accordion();
171
		accordion.setImmediate(true);
172
		accordion.setWidth("-1px");
173
		accordion.setHeight("-1px");
174
		
175
		// classificationSelection
176
		classificationSelection = new OptionGroup();
177
		classificationSelection.setImmediate(false);
178
		classificationSelection.setWidth("-1px");
179
		classificationSelection.setHeight("-1px");
180
		accordion.addTab(classificationSelection, "Classifcation", null);
181
		
182
		// distributionSelection
183
		distributionSelection = new OptionGroup();
184
		distributionSelection.setImmediate(false);
185
		distributionSelection.setWidth("-1px");
186
		distributionSelection.setHeight("-1px");
187
		accordion.addTab(distributionSelection, "Distribution Area", null);
188
		
189
		return accordion;
190
	}
191

  
192
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionTableView.java
1
package eu.etaxonomy.cdm.vaadin.view.dbstatus;
2

  
3
import com.vaadin.annotations.AutoGenerated;
4
import com.vaadin.ui.AbsoluteLayout;
5
import com.vaadin.ui.CustomComponent;
6
import com.vaadin.ui.Table;
7

  
8
public class DistributionTableView extends CustomComponent{
9

  
10
	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
11

  
12
	@AutoGenerated
13
	private AbsoluteLayout mainLayout;
14
	@AutoGenerated
15
	private Table table_1;
16
	/**
17
	 * The constructor should first build the main layout, set the
18
	 * composition root and then do any custom initialization.
19
	 *
20
	 * The constructor will not be automatically regenerated by the
21
	 * visual editor.
22
	 */
23
	public DistributionTableView() {
24
		buildMainLayout();
25
		setCompositionRoot(mainLayout);
26

  
27
		// TODO add user code here
28
	}
29

  
30
	@AutoGenerated
31
	private AbsoluteLayout buildMainLayout() {
32
		// common part: create layout
33
		mainLayout = new AbsoluteLayout();
34
		mainLayout.setImmediate(false);
35
		mainLayout.setWidth("100%");
36
		mainLayout.setHeight("100%");
37
		
38
		// top-level component properties
39
		setWidth("100.0%");
40
		setHeight("100.0%");
41
		
42
		// table_1
43
		table_1 = new Table();
44
		table_1.setImmediate(false);
45
		table_1.setWidth("100.0%");
46
		table_1.setHeight("100.0%");
47
		mainLayout.addComponent(table_1, "top:0.0px;right:0.0px;");
48
		
49
		return mainLayout;
50
	}
51

  
52
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/IDistributionSelectionComponent.java
1
package eu.etaxonomy.cdm.vaadin.view.dbstatus;
2

  
3
import java.util.List;
4

  
5
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
6
import eu.etaxonomy.cdm.model.common.TermVocabulary;
7
import eu.etaxonomy.cdm.model.taxon.Classification;
8

  
9
public interface IDistributionSelectionComponent {
10
	public interface DistributionSelectionComponentListener{
11
		void buttonClick(Classification classification, TermVocabulary<DefinedTermBase> term);
12
		
13
		List<Classification> getClassificationList();
14
		
15
		List<TermVocabulary<DefinedTermBase>> getNamedAreaList();
16
		
17
	}
18
	public void addListener(DistributionSelectionComponentListener listener);
19
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/IDistributionTableComponent.java
1
package eu.etaxonomy.cdm.vaadin.view.dbstatus;
2

  
3
public interface IDistributionTableComponent {
4

  
5
	public interface DistributionTableComponentListener{
6
		
7
	}
8
	public void addListener(DistributionTableComponentListener listener);
9
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)