Project

General

Profile

Revision 6689ac7b

ID6689ac7b32f4d9c6501f5c9b21f315b2f33c73f0
Parent 8921eaba
Child 1b9d7954

Added by Alexander Oppermann almost 6 years ago

improved table component

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/DistributionSelectionPresenter.java
3 3
import java.util.Arrays;
4 4
import java.util.List;
5 5

  
6
import com.vaadin.server.VaadinSession;
7
import com.vaadin.ui.UI;
8

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

  
16 20
public class DistributionSelectionPresenter implements IDistributionSelectionComponent.DistributionSelectionComponentListener {
17 21

  
18 22
	DistributionSelectionView view;
19
	
23

  
20 24
	public DistributionSelectionPresenter(DistributionSelectionView dsv) {
21 25
		this.view = dsv;
22 26
		view.addListener(this);
23 27
		view.dataBinding();
24 28
	}
25
	
29

  
26 30
	@Override
27 31
	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
32
	    VaadinSession.getCurrent().setAttribute("classificationUUID", classification.getUuid());
33
	    VaadinSession.getCurrent().setAttribute("selectedTerm", term.getUuid());
34

  
35
	    DistributionTableView dtv = new DistributionTableView();
36
	    new DistributionTablePresenter(dtv);
37
	    UI.getCurrent().getNavigator().addView("table", dtv);
38
	    //navigate to table view
39
        UI.getCurrent().getNavigator().navigateTo("table");
30 40
	}
31 41

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

  
41 51
	@Override
42 52
	public List<TermVocabulary<DefinedTermBase>> getNamedAreaList() {
43
		
53

  
44 54
		IVocabularyService vocabularyService = (IVocabularyService)CdmSpringContextHelper.newInstance().getBean("vocabularyServiceImpl");
45 55
		List<TermVocabulary<DefinedTermBase>> termList = vocabularyService.findByTermType(TermType.NamedArea);
46 56
		return termList;
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/DistributionTablePresenter.java
23 23
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
24 24
import eu.etaxonomy.cdm.model.taxon.Taxon;
25 25
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper;
26
import eu.etaxonomy.cdm.vaadin.view.dbstatus.DistributionTableView;
26 27
import eu.etaxonomy.cdm.vaadin.view.dbstatus.IDistributionTableComponent;
27 28

  
28 29

  
29 30
public class DistributionTablePresenter implements IDistributionTableComponent.DistributionTableComponentListener{
30 31

  
31
	private IVocabularyService vocabularyService;
32
	private IDescriptionService descriptionService;
33
	private ITermService termService;
34
	
35
	public DistributionTablePresenter(){
32
	private final IVocabularyService vocabularyService;
33
	private final IDescriptionService descriptionService;
34
	private final ITermService termService;
35
	private final DistributionTableView view;
36

  
37
	public DistributionTablePresenter(DistributionTableView dtv){
38
	    this.view = dtv;
39
	    view.addListener(this);
40

  
36 41
		vocabularyService = (IVocabularyService)CdmSpringContextHelper.newInstance().getBean("vocabularyServiceImpl");
37 42
		descriptionService = (IDescriptionService)CdmSpringContextHelper.newInstance().getBean("descriptionServiceImpl");
38 43
		termService = (ITermService)CdmSpringContextHelper.newInstance().getBean("termServiceImpl");
39 44
	}
40
	
41
	
45

  
46

  
42 47
	@Override
43 48
	public ComboBox updateDistributionField(DescriptionElementBase deb,
44 49
			Distribution db,
......
47 52
		// TODO Auto-generated method stub
48 53
		return null;
49 54
	}
50
	
55

  
51 56
	@Override
52 57
	public Set<DefinedTermBase> getChosenTerms() {
53 58
		VaadinSession session = VaadinSession.getCurrent();
......
74 79
		}
75 80
		return null;
76 81
	}
77
	
82

  
78 83
	@Override
79 84
	public List<PresenceAbsenceTerm> getPresenceAbsenceTerms() {
80 85
		//TODO Better to use TermType instead of class to get the list
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionSelectionView.java
2 2

  
3 3
import java.util.List;
4 4

  
5
import javax.annotation.PostConstruct;
6

  
7 5
import com.vaadin.annotations.AutoGenerated;
8 6
import com.vaadin.data.Container;
9 7
import com.vaadin.data.util.IndexedContainer;
......
30 28
	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
31 29

  
32 30
	/**
33
	 * 
31
	 *
34 32
	 */
35 33
	private static final long serialVersionUID = 1L;
36 34
	@AutoGenerated
......
45 43
	private Accordion accordion;
46 44
	@AutoGenerated
47 45
	private OptionGroup distributionSelection;
48
	@AutoGenerated
46

  
47

  
48
    @AutoGenerated
49 49
	private OptionGroup classificationSelection;
50 50
	@AutoGenerated
51 51
	private Label label_1;
......
60 60
	public DistributionSelectionView(){
61 61
		buildMainLayout();
62 62
		setCompositionRoot(mainLayout);
63
		
63

  
64 64
		button_proceed.addClickListener(this);
65 65
		button_proceed.setClickShortcut(KeyCode.ENTER, null);
66 66
	}
67
	
68
	
67

  
68

  
69 69
	@Override
70 70
	public void addListener(DistributionSelectionComponentListener listener) {
71 71
		distListener = listener;
72 72
	}
73
	
73

  
74 74
	@Override
75 75
	public void buttonClick(ClickEvent event) {
76 76
		if(classificationSelection != null && distributionSelection != null){
......
79 79
			distListener.buttonClick(classification, term);
80 80
		}
81 81
	}
82
	
82

  
83 83
	public void dataBinding(){
84 84
		List<Classification> classificationList = distListener.getClassificationList();
85 85
		List<TermVocabulary<DefinedTermBase>> namedAreaList = distListener.getNamedAreaList();
......
88 88
		Container d = new IndexedContainer(namedAreaList);
89 89
		distributionSelection.setContainerDataSource(d);
90 90
	}
91
	
91

  
92 92
	@Override
93 93
	public void enter(ViewChangeEvent event) {
94 94
	}
......
101 101
		mainLayout.setWidth("100%");
102 102
		mainLayout.setHeight("100%");
103 103
		mainLayout.setMargin(false);
104
		
104

  
105 105
		// top-level component properties
106 106
		setWidth("100.0%");
107 107
		setHeight("100.0%");
108
		
108

  
109 109
		// panel_1
110 110
		panel_1 = buildPanel_1();
111 111
		mainLayout.addComponent(panel_1);
112 112
		mainLayout.setComponentAlignment(panel_1, new Alignment(48));
113
		
113

  
114 114
		return mainLayout;
115 115
	}
116 116

  
......
121 121
		panel_1.setImmediate(false);
122 122
		panel_1.setWidth("-1px");
123 123
		panel_1.setHeight("-1px");
124
		
124

  
125 125
		// verticalLayout_2
126 126
		verticalLayout_2 = buildVerticalLayout_2();
127 127
		panel_1.setContent(verticalLayout_2);
128
		
128

  
129 129
		return panel_1;
130 130
	}
131 131

  
......
138 138
		verticalLayout_2.setHeight("-1px");
139 139
		verticalLayout_2.setMargin(true);
140 140
		verticalLayout_2.setSpacing(true);
141
		
141

  
142 142
		// label_1
143 143
		label_1 = new Label();
144 144
		label_1.setImmediate(false);
......
146 146
		label_1.setHeight("-1px");
147 147
		label_1.setValue("Please choose a Classification and a distribution area to proceed.");
148 148
		verticalLayout_2.addComponent(label_1);
149
		
149

  
150 150
		// accordion
151 151
		accordion = buildAccordion();
152 152
		verticalLayout_2.addComponent(accordion);
153 153
		verticalLayout_2.setComponentAlignment(accordion, new Alignment(48));
154
		
154

  
155 155
		// button_1
156 156
		button_proceed = new Button();
157 157
		button_proceed.setCaption("Proceed");
......
160 160
		button_proceed.setHeight("-1px");
161 161
		verticalLayout_2.addComponent(button_proceed);
162 162
		verticalLayout_2.setComponentAlignment(button_proceed, new Alignment(10));
163
		
163

  
164 164
		return verticalLayout_2;
165 165
	}
166 166

  
......
171 171
		accordion.setImmediate(true);
172 172
		accordion.setWidth("-1px");
173 173
		accordion.setHeight("-1px");
174
		
174

  
175 175
		// classificationSelection
176 176
		classificationSelection = new OptionGroup();
177 177
		classificationSelection.setImmediate(false);
178 178
		classificationSelection.setWidth("-1px");
179 179
		classificationSelection.setHeight("-1px");
180 180
		accordion.addTab(classificationSelection, "Classifcation", null);
181
		
181

  
182 182
		// distributionSelection
183 183
		distributionSelection = new OptionGroup();
184 184
		distributionSelection.setImmediate(false);
185 185
		distributionSelection.setWidth("-1px");
186 186
		distributionSelection.setHeight("-1px");
187 187
		accordion.addTab(distributionSelection, "Distribution Area", null);
188
		
188

  
189 189
		return accordion;
190 190
	}
191 191

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

  
3 3
import com.vaadin.annotations.AutoGenerated;
4
import com.vaadin.navigator.View;
5
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
4 6
import com.vaadin.ui.AbsoluteLayout;
7
import com.vaadin.ui.Button.ClickEvent;
8
import com.vaadin.ui.Button.ClickListener;
5 9
import com.vaadin.ui.CustomComponent;
6 10
import com.vaadin.ui.Table;
7 11

  
8
public class DistributionTableView extends CustomComponent{
12
public class DistributionTableView extends CustomComponent implements IDistributionTableComponent, View, ClickListener{
9 13

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

  
12
	@AutoGenerated
16
	/**
17
     *
18
     */
19
    private static final long serialVersionUID = 1L;
20
    @AutoGenerated
13 21
	private AbsoluteLayout mainLayout;
14 22
	@AutoGenerated
15 23
	private Table table_1;
......
27 35
		// TODO add user code here
28 36
	}
29 37

  
38
	@Override
39
	public void addListener(DistributionTableComponentListener listener) {
40
	    //TODO implement this method
41
	}
42

  
30 43
	@AutoGenerated
31 44
	private AbsoluteLayout buildMainLayout() {
32 45
		// common part: create layout
......
34 47
		mainLayout.setImmediate(false);
35 48
		mainLayout.setWidth("100%");
36 49
		mainLayout.setHeight("100%");
37
		
50

  
38 51
		// top-level component properties
39 52
		setWidth("100.0%");
40 53
		setHeight("100.0%");
41
		
54

  
42 55
		// table_1
43 56
		table_1 = new Table();
44 57
		table_1.setImmediate(false);
45 58
		table_1.setWidth("100.0%");
46 59
		table_1.setHeight("100.0%");
47 60
		mainLayout.addComponent(table_1, "top:0.0px;right:0.0px;");
48
		
61

  
49 62
		return mainLayout;
50 63
	}
51 64

  
65
    /* (non-Javadoc)
66
     * @see com.vaadin.navigator.View#enter(com.vaadin.navigator.ViewChangeListener.ViewChangeEvent)
67
     */
68
    @Override
69
    public void enter(ViewChangeEvent event) {
70
        // TODO Auto-generated method stub
71

  
72
    }
73

  
74
    /* (non-Javadoc)
75
     * @see com.vaadin.ui.Button.ClickListener#buttonClick(com.vaadin.ui.Button.ClickEvent)
76
     */
77
    @Override
78
    public void buttonClick(ClickEvent event) {
79
        // TODO Auto-generated method stub
80

  
81
    }
82

  
52 83
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/IDistributionTableComponent.java
19 19
		Set<DefinedTermBase> getChosenTerms();
20 20

  
21 21
		List<PresenceAbsenceTerm> getPresenceAbsenceTerms();
22
		
22

  
23 23
		ComboBox updateDistributionField(DescriptionElementBase deb, Distribution db, BeanItemContainer<PresenceAbsenceTerm> termContainer, ComboBox box, Taxon taxon);
24
		
24

  
25 25
		HashMap<DescriptionElementBase, Distribution> getDistribution(DefinedTermBase dt, Taxon taxon);
26

  
26 27
	}
27 28
	public void addListener(DistributionTableComponentListener listener);
28 29
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)