Project

General

Profile

« Previous | Next » 

Revision 1746c51d

Added by Alexander Oppermann over 9 years ago

finalize vaadin app to seperate to prepare the next step for separating vaadin from cdmlib-remote

View differences:

.gitattributes
3 3
/pom.xml -text
4 4
src/main/java/eu/etaxonomy/cdm/vaadin/AppWidgetSet.gwt.xml -text
5 5
src/main/java/eu/etaxonomy/cdm/vaadin/CdmAppInitializer.java.bkp -text
6
src/main/java/eu/etaxonomy/cdm/vaadin/component/HorizontalToolbar.java -text
6 7
src/main/java/eu/etaxonomy/cdm/vaadin/container/CdmSQLContainer.java -text
8
src/main/java/eu/etaxonomy/cdm/vaadin/model/BeanItemContainerExample.java -text
9
src/main/java/eu/etaxonomy/cdm/vaadin/model/CdmTaxonTableCollection.java -text
10
src/main/java/eu/etaxonomy/cdm/vaadin/model/DbTableDTO.java -text
11
src/main/java/eu/etaxonomy/cdm/vaadin/model/DbTableDTOS.java -text
12
src/main/java/eu/etaxonomy/cdm/vaadin/model/DistributionDTO.java -text
13
src/main/java/eu/etaxonomy/cdm/vaadin/model/LazyLoadedContainer.java -text
14
src/main/java/eu/etaxonomy/cdm/vaadin/model/StatusDTO.java -text
7 15
src/main/java/eu/etaxonomy/cdm/vaadin/model/User.java -text
8 16
src/main/java/eu/etaxonomy/cdm/vaadin/model/Users.java -text
17
src/main/java/eu/etaxonomy/cdm/vaadin/model/taxonDTO.java -text
9 18
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/AuthenticationPresenter.java -text
10 19
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/DistributionSelectionPresenter.java -text
11 20
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/DistributionTablePresenter.java -text
src/main/java/eu/etaxonomy/cdm/vaadin/component/HorizontalToolbar.java
1
package eu.etaxonomy.cdm.vaadin.component;
2

  
3
import java.io.Serializable;
4

  
5
import org.springframework.security.core.Authentication;
6
import org.springframework.security.core.context.SecurityContext;
7
import org.springframework.security.core.context.SecurityContextHolder;
8

  
9
import com.vaadin.server.ThemeResource;
10
import com.vaadin.server.VaadinSession;
11
import com.vaadin.ui.Alignment;
12
import com.vaadin.ui.Button;
13
import com.vaadin.ui.Button.ClickEvent;
14
import com.vaadin.ui.Button.ClickListener;
15
import com.vaadin.ui.HorizontalLayout;
16
import com.vaadin.ui.Image;
17
import com.vaadin.ui.Label;
18
import com.vaadin.ui.UI;
19

  
20
public class HorizontalToolbar extends HorizontalLayout implements Serializable{
21

  
22

  
23
	/**
24
	 * automatically generated ID
25
	 */
26
	private static final long serialVersionUID = 5344340511582993289L;
27
	
28
	
29
	private final Button editButton = new Button("Edit");
30
	
31
	private final Button saveButton = new Button("Save");
32

  
33
	private final Button detailButton = new Button("Detail");
34
	
35
	private final Button logoutButton= new Button("Logout");
36

  
37
	private Authentication authentication;
38
//	private ExcelExporter exporter = new ExcelExporter();
39

  
40
	public HorizontalToolbar() {
41
		authentication = (Authentication) VaadinSession.getCurrent().getAttribute("authentication");
42
		init();
43
	}
44
	
45
    public void init() {
46
		if(authentication != null && authentication.isAuthenticated()){
47
			setMargin(true);
48
			setSpacing(true);
49
			setStyleName("toolbar");
50
			setWidth("100%");
51
			setHeight("75px");
52

  
53
			addComponent(editButton);
54
			addComponent(saveButton);
55
			addComponent(detailButton);
56
//			addComponent(exporter);
57

  
58
//			exporter.setCaption("Export");
59
//			exporter.setIcon(new ThemeResource("icons/32/document-xsl.png"));
60

  
61
			saveButton.setIcon(new ThemeResource("icons/32/document-save.png"));
62
			editButton.setIcon(new ThemeResource("icons/32/document-edit.png"));
63
			detailButton.setIcon(new ThemeResource("icons/32/document-txt.png"));
64
			logoutButton.setIcon(new ThemeResource("icons/32/cancel.png"));
65

  
66
			//		SecurityContext context = (SecurityContext)VaadinService.getCurrentRequest().getWrappedSession().getAttribute("context"); 
67
			SecurityContext context = SecurityContextHolder.getContext();
68
			Label loginName = new Label(authentication.getName().toString());
69
			loginName.setIcon(new ThemeResource("icons/32/user.png"));
70

  
71
			HorizontalLayout rightLayout = new HorizontalLayout(); 
72
			Image image = new Image(null, new ThemeResource("icons/32/vseparator1.png"));
73
			rightLayout.addComponent(logoutButton);
74
			rightLayout.addComponent(image);
75
			rightLayout.addComponent(loginName);
76

  
77
			addComponent(rightLayout);
78
			setComponentAlignment(rightLayout, Alignment.MIDDLE_RIGHT);
79
			setExpandRatio(rightLayout, 1);
80

  
81
			logoutButton.addClickListener(new ClickListener() {
82

  
83
				/**
84
				 *  automatically generated ID
85
				 */
86
				private static final long serialVersionUID = 8380401487511285303L;
87

  
88
				public void buttonClick(ClickEvent event) {
89
					
90
					authentication.setAuthenticated(false);
91
					UI.getCurrent().getNavigator().navigateTo("abstractAuthenticatedUI");
92
				}
93
			});
94
		}
95
    }
96
	
97
	public Button getEditButton() {
98
		return editButton;
99
	}
100
	
101
	public Button getSaveButton() {
102
		return saveButton;
103
	}
104
	
105
	public Button getDetailButton() {
106
		return detailButton;
107
	}
108
}
src/main/java/eu/etaxonomy/cdm/vaadin/model/BeanItemContainerExample.java
1
package eu.etaxonomy.cdm.vaadin.model;
2

  
3
import java.io.Serializable;
4
import java.util.ArrayList;
5

  
6
import com.vaadin.data.Property;
7
import com.vaadin.data.Property.ValueChangeEvent;
8
import com.vaadin.data.util.BeanItem;
9
import com.vaadin.data.util.BeanItemContainer;
10
import com.vaadin.ui.Button;
11
import com.vaadin.ui.Button.ClickEvent;
12
import com.vaadin.ui.Button.ClickListener;
13
import com.vaadin.ui.CustomComponent;
14
import com.vaadin.ui.Form;
15
import com.vaadin.ui.HorizontalLayout;
16
import com.vaadin.ui.Label;
17
import com.vaadin.ui.Table;
18
import com.vaadin.ui.TextField;
19
import com.vaadin.ui.VerticalLayout;
20

  
21
public class BeanItemContainerExample extends CustomComponent  {
22
    private static final long serialVersionUID = -6235574698344484522L;
23

  
24
    public void init (String context) {
25
        VerticalLayout layout = new VerticalLayout();
26

  
27
        if ("basic".equals(context))
28
            basic(layout);
29
        else if ("addall".equals(context))
30
            addall(layout);
31
        else if ("dualbinding".equals(context))
32
            dualbinding(layout);
33
        else if ("beanupdate".equals(context))
34
            beanupdate(layout);
35
        else if ("nestedbean".equals(context))
36
            nestedbean(layout);
37
        else
38
            layout.addComponent(new Label("Invalid context: " + context));
39
        
40
        setCompositionRoot(layout);
41
    }
42
    
43
    // BEGIN-EXAMPLE: datamodel.container.beanitemcontainer.basic
44
    // Here is a bean
45
    public class Bean implements Serializable {
46
        private static final long serialVersionUID = -1520923107014804137L;
47

  
48
        String name;
49
        double energy; // Energy content in kJ/100g
50
        
51
        public Bean(String name, double energy) {
52
            this.name   = name;
53
            this.energy = energy;
54
        }
55
        
56
        public String getName() {
57
            return name;
58
        }
59
        
60
        public void setName(String name) {
61
            this.name = name;
62
        }
63
        
64
        public double getEnergy() {
65
            return energy;
66
        }
67
        
68
        public void setEnergy(double energy) {
69
            this.energy = energy;
70
        }
71
    }
72
    
73
    void basic(VerticalLayout layout) {
74
        // Create a container for such beans
75
        BeanItemContainer<Bean> beans =
76
            new BeanItemContainer<Bean>(Bean.class);
77
        
78
        // Add some beans to it
79
        beans.addBean(new Bean("Mung bean",   1452.0));
80
        beans.addBean(new Bean("Chickpea",    686.0));
81
        beans.addBean(new Bean("Lentil",      1477.0));
82
        beans.addBean(new Bean("Common bean", 129.0));
83
        beans.addBean(new Bean("Soybean",     1866.0));
84

  
85
        // Bind a table to it
86
        Table table = new Table("Beans of All Sorts", beans);
87
        layout.addComponent(table);
88
        // END-EXAMPLE: datamodel.container.beanitemcontainer.basic
89
        
90
        table.setPageLength(beans.size());
91
        table.setVisibleColumns(new Object[]{"name", "energy"});
92
    }
93
    
94
    void addall(VerticalLayout layout) {
95
        // BEGIN-EXAMPLE: datamodel.container.beanitemcontainer.addall
96
        // Have a collection with some beans
97
        ArrayList<Bean> beanlist = new ArrayList<Bean>();
98
        beanlist.add(new Bean("Mung bean",   1452.0));
99
        beanlist.add(new Bean("Chickpea",    686.0));
100
        beanlist.add(new Bean("Lentil",      1477.0));
101
        beanlist.add(new Bean("Common bean", 129.0));
102
        beanlist.add(new Bean("Soybean",     1866.0));
103
        
104
        // Create a container for the beans
105
        final BeanItemContainer<Bean> beans =
106
            new BeanItemContainer<Bean>(Bean.class);
107
        
108
        // Add them all
109
        beans.addAll(beanlist);
110

  
111
        // Bind a table to the container
112
        Table table = new Table("Beans of All Sorts", beans);
113
        layout.addComponent(table);
114
        
115
        // Have a button to empty and create some new items
116
        Button recreate = new Button("Recreate");
117
        recreate.addListener(new ClickListener() {
118
            private static final long serialVersionUID = 6823630748713272361L;
119

  
120
            @Override
121
            public void buttonClick(ClickEvent event) {
122
                beans.removeAllItems();
123

  
124
                ArrayList<Bean> beanlist = new ArrayList<Bean>();
125
                beanlist.add(new Bean("Space bean",   42.0));
126
                beanlist.add(new Bean("Moon bean",    388.0));
127
                
128
                beans.addAll(beanlist);
129
            }
130
        });
131
        layout.addComponent(recreate);
132
        // END-EXAMPLE: datamodel.container.beanitemcontainer.addall
133
        
134
        table.setPageLength(beans.size());
135
        table.setVisibleColumns(new Object[]{"name", "energy"});
136
    }
137
    
138
    public static final String dualbindingDescription =
139
        "<h1>Binding a bean both to a Table and a Form</h1>"+
140
        "<p>Editing the <b>BeanItem</b> in the form fires value change events, "+
141
        "which are communicated to the other components bound to the same data source, in this case the <b>Table</b>.</p>";
142

  
143
    @SuppressWarnings("unchecked")
144
    void dualbinding(VerticalLayout vlayout) {
145
        // BEGIN-EXAMPLE: datamodel.container.beanitemcontainer.dualbinding
146
        // Create a container for beans
147
        final BeanItemContainer<Bean> beans =
148
            new BeanItemContainer<Bean>(Bean.class);
149
        
150
        // Add some beans to it
151
        beans.addBean(new Bean("Mung bean",   1452.0));
152
        beans.addBean(new Bean("Chickpea",    686.0));
153
        beans.addBean(new Bean("Lentil",      1477.0));
154
        beans.addBean(new Bean("Common bean", 129.0));
155
        beans.addBean(new Bean("Soybean",     1866.0));
156

  
157
        // A layout for the table and form
158
        HorizontalLayout layout = new HorizontalLayout();
159

  
160
        // Bind a table to it
161
        final Table table = new Table("Beans of All Sorts", beans);
162
        table.setVisibleColumns(new Object[]{"name", "energy"});
163
        table.setPageLength(7);
164
        layout.addComponent(table);
165
        
166
        // Create a form for editing a selected or new item.
167
        // It is invisible until actually used.
168
        final Form form = new Form();
169
        form.setCaption("Edit Item");
170
        form.setVisible(false);
171
        layout.addComponent(form);
172
        
173
        // When the user selects an item, show it in the form
174
        table.addListener(new Property.ValueChangeListener() {
175
            private static final long serialVersionUID = 1162945655606583495L;
176

  
177
            public void valueChange(ValueChangeEvent event) {
178
                // Close the form if the item is deselected
179
                if (event.getProperty().getValue() == null) {
180
                    form.setVisible(false);
181
                    return;
182
                }
183

  
184
                // Bind the form to the selected item
185
                form.setItemDataSource(beans.getItem(table.getValue()));
186
                form.setVisible(true);
187
            }
188
        });
189
        table.setSelectable(true);
190
        table.setImmediate(true);
191

  
192
        // Creates a new bean for editing in the form before adding
193
        // it to the table. Adding is handled after committing
194
        // the form.
195
        final Button newBean = new Button("New Bean");
196
        newBean.addListener(new Button.ClickListener() {
197
            private static final long serialVersionUID = -7340189561756261036L;
198

  
199
            public void buttonClick(ClickEvent event) {
200
                // Create a new bean and bind it to the form
201
                Bean bean = new Bean(null, 0.0);
202
                BeanItem<Bean> item = new BeanItem<Bean>(bean);
203
                form.setItemDataSource(item);
204

  
205
                // Make the form a bit nicer
206
                form.setVisibleItemProperties(
207
                        new Object[]{"name", "energy"});
208
                ((TextField)form.getField("name"))
209
                        .setNullRepresentation("");
210
                
211
                table.select(null);
212
                table.setEnabled(false);
213
                newBean.setEnabled(false);
214
                form.setVisible(true);
215
            }
216
        });
217

  
218
        // When OK button is clicked, commit the form to the bean
219
        Button submit = new Button("OK");
220
        submit.addListener(new Button.ClickListener() {
221
            private static final long serialVersionUID = 6823630748713272361L;
222

  
223
            public void buttonClick(ClickEvent event) {
224
                form.commit();
225
                form.setVisible(false); // and close it
226
                
227
                // New items have to be added to the container
228
                if (table.getValue() == null) {
229
                    BeanItem<Bean> item =
230
                        (BeanItem<Bean>) form.getItemDataSource();
231

  
232
                    // This creates a new BeanItem
233
                    beans.addBean(item.getBean());
234
                    
235
                    table.setEnabled(true);
236
                    newBean.setEnabled(true);
237
                }
238
            }
239
        });
240
        form.getFooter().addComponent(submit);
241

  
242
        Button cancel = new Button("Cancel");
243
        cancel.addListener(new Button.ClickListener() {
244
            private static final long serialVersionUID = -1749148888766063606L;
245

  
246
            public void buttonClick(ClickEvent event) {
247
                form.discard(); // Not really necessary
248
                form.setVisible(false); // and close it
249
                table.setEnabled(true);
250
                newBean.setEnabled(true);
251
            }
252
        });
253
        form.getFooter().addComponent(cancel);
254
        // END-EXAMPLE: datamodel.container.beanitemcontainer.dualbinding
255

  
256
        layout.setSpacing(true);
257
        vlayout.addComponent(layout);
258
        vlayout.addComponent(newBean);
259
    }
260

  
261
    void beanupdate(VerticalLayout vlayout) {
262
        // BEGIN-EXAMPLE: datamodel.container.beanitemcontainer.beanupdate
263
        // Create a container for beans
264
        final BeanItemContainer<Bean> beans =
265
            new BeanItemContainer<Bean>(Bean.class);
266
    }
267

  
268
    // BEGIN-EXAMPLE: datamodel.container.beanitemcontainer.nestedbean
269
    /** Bean to be nested */
270
    public class EqCoord implements Serializable {
271
        private static final long serialVersionUID = -3020840929725381667L;
272

  
273
        double rightAscension; /* In angle hours */
274
        double declination;    /* In degrees     */
275
        
276
        public EqCoord(double ra, double decl) {
277
            this.rightAscension = ra;
278
            this.declination    = decl;
279
        }
280
        
281
        public double getRightAscension() {
282
            return rightAscension;
283
        }
284
        public void setRightAscension(double rightAscension) {
285
            this.rightAscension = rightAscension;
286
        }
287

  
288
        public double getDeclination() {
289
            return declination;
290
        }
291
        public void setDeclination(double declination) {
292
            this.declination = declination;
293
        }
294
    }
295

  
296
    /** Bean containing a nested bean */
297
    public class Star implements Serializable {
298
        private static final long serialVersionUID = -312738461368736290L;
299

  
300
        String  name;
301
        EqCoord equatorial; /* Nested bean */
302
        
303
        public Star(String name, EqCoord equatorial) {
304
            this.name       = name;
305
            this.equatorial = equatorial;
306
        }
307
        
308
        public String getName() {
309
            return name;
310
        }
311
        public void setName(String name) {
312
            this.name = name;
313
        }
314

  
315
        /** Access to the nested bean. */
316
        public EqCoord getEquatorial() {
317
            return equatorial;
318
        }
319
        public void setEquatorial(EqCoord equatorial) {
320
            this.equatorial = equatorial;
321
        }
322
    }
323
    
324
    void nestedbean(VerticalLayout layout) {
325
        // Create a container for beans
326
        final BeanItemContainer<Star> stars =
327
            new BeanItemContainer<Star>(Star.class);
328
        
329
        // Declare the nested properties to be used in the container
330
        stars.addNestedContainerProperty("equatorial.rightAscension");
331
        stars.addNestedContainerProperty("equatorial.declination");
332
        
333
        // Add some items
334
        stars.addBean(new Star("Sirius",  new EqCoord(6.75, 16.71611)));
335
        stars.addBean(new Star("Polaris", new EqCoord(2.52, 89.26417)));
336
        
337
        // Put them in a table
338
        Table table = new Table("Stars", stars);
339
        table.setColumnHeader("equatorial.rightAscension", "RA");
340
        table.setColumnHeader("equatorial.declination",    "Decl");
341
        table.setPageLength(table.size());
342
        
343
        // Have to set explicitly to hide the "equatorial" property
344
        table.setVisibleColumns(new Object[]{"name",
345
            "equatorial.rightAscension", "equatorial.declination"});
346
        
347
        layout.addComponent(table);
348
    }        
349
    // END-EXAMPLE: datamodel.container.beanitemcontainer.nestedbean
350
}
src/main/java/eu/etaxonomy/cdm/vaadin/model/CdmTaxonTableCollection.java
1
package eu.etaxonomy.cdm.vaadin.model;
2

  
3
import java.util.Collection;
4
import java.util.UUID;
5

  
6
import eu.etaxonomy.cdm.model.common.CdmBase;
7
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
8
import eu.etaxonomy.cdm.model.description.Distribution;
9
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
10
import eu.etaxonomy.cdm.model.name.Rank;
11
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
12
import eu.etaxonomy.cdm.model.taxon.Taxon;
13

  
14
public class CdmTaxonTableCollection{
15
	
16

  
17
    private Taxon taxon;
18

  
19
    private Collection<DescriptionElementBase> listTaxonDescription;
20

  
21
    
22
	private String fullTitleCache;
23
	
24
	private Rank rank;
25

  
26
    
27
    public CdmTaxonTableCollection(Taxon taxon, Collection<DescriptionElementBase> listTaxonDescription){
28
    	this.taxon = CdmBase.deproxy(taxon, Taxon.class);
29
    	this.listTaxonDescription = listTaxonDescription;
30
    }
31
    
32
    public CdmTaxonTableCollection(Taxon taxon){
33
    	this.taxon = CdmBase.deproxy(taxon, Taxon.class);
34
    }
35
    
36
    //----Getter - Setter - methods ----//
37
    /**
38
     * 
39
     * @return
40
     */
41
    public String getFullTitleCache() {
42
    	TaxonNameBase name = taxon.getName();
43
    	name = CdmBase.deproxy(name, TaxonNameBase.class);
44
    	if(name ==  null){
45
    		return "-";
46
    	}
47
		return name.getFullTitleCache();
48
    }
49
    /**
50
     * 
51
     * @param fullTitleCache
52
     */
53
    public void setFullTitleCache(String fullTitleCache) {
54
    	taxon.getName().setFullTitleCache(fullTitleCache, true);
55
    	taxon.setTitleCache(fullTitleCache, true);
56
    }
57
    /**
58
     * 
59
     * @return
60
     */
61
    public Taxon getTaxon() {
62
		return taxon;
63
	}
64
    
65
    public void setTaxon(Taxon taxon){
66
    	this.taxon = taxon;
67
    }
68

  
69
    
70
    
71
    /**
72
     * Returns the taxonomic {@link Rank rank} of <i>this</i> taxon name.
73
     *
74
     * @see 	Rank
75
     */
76
    public String getRank(){
77
    	rank = taxon.getName().getRank();
78
    	if(rank == null){
79
    		return "-";
80
    	}
81
    	return rank.toString();
82
    }
83
    
84
    public UUID getUUID(){
85
    	return taxon.getUuid();
86
    }
87

  
88
    /**
89
     * @see  #getRank()
90
     */
91
    public void setRank(Rank rank){
92
    	taxon.getName().setRank(rank);
93
    }
94
    /**
95
     * 
96
     * @return
97
     */
98
    public PresenceAbsenceTerm getDistributionStatus(String distribution){
99
    	Distribution db = getDistribution(distribution);
100
    	if(db != null){
101
    		return db.getStatus();
102
    	}
103
		return null;
104
    }
105
    
106
//    public ComboBox getDistributionComboBox(){
107
//		if(getDistributionStatus() != null && termList != null){
108
//			BeanItemContainer<PresenceAbsenceTermBase> container = new BeanItemContainer<PresenceAbsenceTermBase>(PresenceAbsenceTermBase.class);
109
//			container.addAll(termList);
110
//			final ComboBox box = new ComboBox();
111
//			box.setContainerDataSource(container);
112
//			box.setImmediate(true);
113
////			setValueChangeListener(box);
114
//			if(getDistributionStatus() != null){
115
//				box.setValue(getDistributionStatus());
116
//			}
117
//			return box;
118
//		}else{
119
//			return null;
120
//		}
121
//    }
122
    
123
    
124
    
125
//    private void setValueChangeListener(final ComboBox box){
126
//    	box.addValueChangeListener(new ValueChangeListener() {
127
//			private static final long serialVersionUID = 1L;
128
//			@Override
129
//			public void valueChange(ValueChangeEvent event) {
130
//				logger.info("Value Change: "+ box.getValue());
131
//				setDistributionStatus((PresenceAbsenceTermBase<?>)box.getValue());
132
//			}
133
//    	});
134
//    }
135
    
136
    /**
137
     * 
138
     * @param status
139
     */
140
    public void setDistributionStatus(String distribution, PresenceAbsenceTerm status){
141
    	Distribution db = getDistribution(distribution);
142
    	if(db != null){
143
    		db.setStatus(status);
144
//    		DescriptionServiceImpl desc = new DescriptionServiceImpl();
145
//    		desc.saveDescriptionElement(db);
146
//    		descriptionService.saveDescriptionElement(db);
147
    	}
148
    }
149
    /**
150
     * 
151
     * @return
152
     */
153
    public Distribution getDistribution(String distribution){
154
    	if(listTaxonDescription != null){
155
    		for(DescriptionElementBase deb : listTaxonDescription){
156
    			if(deb instanceof Distribution){
157
    				//FIXME HOW TO IMPLEMENT A FILTER ???
158
    				Distribution db =  (Distribution)deb;
159
    				if(db.getArea().getTitleCache().equalsIgnoreCase(distribution)){
160
    					return db;
161
    				}
162
    			}
163
    		}
164
    	}
165
    	return null;
166
    }
167
    
168
    
169
    //----------- Detail View ------------------//
170
    
171
    /**
172
     * 
173
     * @return
174
     */
175
    public String getTaxonNameCache(){
176
		return taxon.getName().getTitleCache();
177
	}
178
    
179
    public void setTaxonNameCache(String titlecache){
180
    	taxon.getName().setTitleCache(titlecache, true);
181
    }
182
	/**
183
	 * 
184
	 * @return
185
	 */
186
	public String getNomenclaturalCode(){
187
		return taxon.getName().getNomenclaturalCode().getTitleCache();
188
	}
189
	/**
190
	 * 
191
	 * @return
192
	 */
193
	public String getSecundum(){
194
		return taxon.getSec().toString();
195
	}
196
    
197
    
198
}
src/main/java/eu/etaxonomy/cdm/vaadin/model/DbTableDTO.java
1
package eu.etaxonomy.cdm.vaadin.model;
2

  
3
import java.io.Serializable;
4
import java.util.Collection;
5
import java.util.List;
6
import java.util.Map;
7
import java.util.UUID;
8

  
9
import eu.etaxonomy.cdm.model.common.CdmBase;
10
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
11
import eu.etaxonomy.cdm.model.description.Distribution;
12
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
13
import eu.etaxonomy.cdm.model.name.Rank;
14
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
15
import eu.etaxonomy.cdm.model.taxon.Taxon;
16

  
17

  
18
public class DbTableDTO implements Serializable {
19

  
20
	private static final long serialVersionUID = 1L;
21

  
22
	private Taxon taxon;
23

  
24
	public Taxon getTaxon() {
25
		return taxon;
26
	}
27

  
28
	public void setTaxon(Taxon taxon) {
29
		this.taxon = taxon;
30
	}
31
	private Rank rank;
32

  
33
	private DistributionDTO dDTO;
34

  
35
	
36

  
37
	public DbTableDTO(Taxon taxon){
38
		this.taxon = CdmBase.deproxy(taxon, Taxon.class);
39
	}
40

  
41
	//----Getter - Setter - methods ----//
42
	
43
	public DistributionDTO getdDTO() {
44
		return dDTO;
45
	}
46

  
47
	public void setdDTO(DistributionDTO dDTO) {
48
		this.dDTO = dDTO;
49
	}
50

  
51
	/**
52
	 * 
53
	 * @return
54
	 */
55
	public String getFullTitleCache() {
56
		TaxonNameBase name = taxon.getName();
57
		name = CdmBase.deproxy(name, TaxonNameBase.class);
58
		if(name ==  null){
59
			return "-";
60
		}
61
		return name.getFullTitleCache();
62
	}
63
	/**
64
	 * 
65
	 * @param fullTitleCache
66
	 */
67
	public void setFullTitleCache(String fullTitleCache) {
68
		taxon.getName().setFullTitleCache(fullTitleCache, true);
69
		taxon.setTitleCache(fullTitleCache, true);
70
	}
71

  
72
	/**
73
	 * Returns the taxonomic {@link Rank rank} of <i>this</i> taxon name.
74
	 *
75
	 * @see 	Rank
76
	 */
77
	public String getRank(){
78
		rank = taxon.getName().getRank();
79
		if(rank == null){
80
			return "-";
81
		}
82
		return rank.toString();
83
	}
84

  
85
	public UUID getUUID(){
86
		return taxon.getUuid();
87
	}
88

  
89
	/**
90
	 * @see  #getRank()
91
	 */
92
	public void setRank(Rank rank){
93
		taxon.getName().setRank(rank);
94
	}
95
	/**
96
	 * 
97
	 * @return
98
	 */
99

  
100

  
101

  
102

  
103
	//----------- Detail View ------------------//
104

  
105
	/**
106
	 * 
107
	 * @return
108
	 */
109
	public String getTaxonNameCache(){
110
		return taxon.getName().getTitleCache();
111
	}
112

  
113
	public void setTaxonNameCache(String titlecache){
114
		taxon.getName().setTitleCache(titlecache, true);
115
	}
116
	/**
117
	 * 
118
	 * @return
119
	 */
120
	public String getNomenclaturalCode(){
121
		return taxon.getName().getNomenclaturalCode().getTitleCache();
122
	}
123
	/**
124
	 * 
125
	 * @return
126
	 */
127
	public String getSecundum(){
128
		return taxon.getSec().toString();
129
	}
130

  
131
}
src/main/java/eu/etaxonomy/cdm/vaadin/model/DbTableDTOS.java
1
package eu.etaxonomy.cdm.vaadin.model;
2

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

  
6
public class DbTableDTOS{
7

  
8
	private List<DbTableDTO> listDTO = new ArrayList<DbTableDTO>();
9
	
10
	public DbTableDTOS(){
11
	}
12
	
13
	public void add(DbTableDTO dto){
14
		listDTO.add(dto);
15
	}
16
	
17
	public List<DbTableDTO> getList(){
18
		return listDTO;
19
	}
20
}
src/main/java/eu/etaxonomy/cdm/vaadin/model/DistributionDTO.java
1
package eu.etaxonomy.cdm.vaadin.model;
2

  
3
import java.io.Serializable;
4

  
5
public class DistributionDTO implements Serializable {
6
	
7
	private static final long serialVersionUID = 1L;
8
	private String name;
9
	private String status;
10
	
11
	public DistributionDTO(String name, String status){
12
		this.name = name;
13
		this.status = status;
14
	}
15

  
16
	public String getName() {
17
		return name;
18
	}
19

  
20
	public void setName(String name) {
21
		this.name = name;
22
	}
23
	
24
	public String getStatus() {
25
		return status;
26
	}
27

  
28
	public void setStatus(String status) {
29
		this.status = status;
30
	}
31
}
src/main/java/eu/etaxonomy/cdm/vaadin/model/LazyLoadedContainer.java
1
package eu.etaxonomy.cdm.vaadin.model;
2

  
3
import java.io.Serializable;
4
import java.util.List;
5

  
6
import com.vaadin.data.util.BeanContainer;
7
import com.vaadin.data.util.BeanItem;
8

  
9
import eu.etaxonomy.cdm.model.common.CdmBase;
10
import eu.etaxonomy.cdm.model.taxon.Taxon;
11
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
12
import eu.etaxonomy.cdm.vaadin.view.dbstatus.IDistributionTableComponent;
13

  
14
public class LazyLoadedContainer extends BeanContainer implements Serializable, IDistributionTableComponent {
15

  
16
	/** autogenerated **/
17
	private static final long serialVersionUID = 1L;
18

  
19
	DistributionTableComponentListener listener;
20

  
21
	
22
	public LazyLoadedContainer(Class type) throws IllegalArgumentException {
23
		super(type);
24
	}
25
//	
26
//	public LazyLoadedContainer(Class type, IClassificationService classificationService, ITaxonNodeService taxonNodeService, IDescriptionService descriptionService) throws IllegalArgumentException {
27
//		super(type);
28
//		this.classificationService = classificationService;
29
//		this.taxonNodeService = taxonNodeService;
30
//		this.descriptionService = descriptionService;
31
//		
32
//	}
33
	
34
	@Override
35
	public int size(){
36
		return listener.getSizeOfClassification();
37
	}
38
	
39
	@Override
40
	public BeanItem getItem(Object itemId){
41
		TaxonNode taxonNode = ((TaxonNode) itemId);
42
		CdmBase.deproxy(taxonNode, TaxonNode.class);
43
		Taxon taxon = (Taxon)taxonNode.getTaxon();
44
		CdmBase.deproxy(taxon, Taxon.class);
45
		CdmTaxonTableCollection cttc = new CdmTaxonTableCollection(taxon);
46
		return new BeanItem(cttc);
47
	}
48
	
49
	@Override
50
	public List getItemIds(int startIndex, int numberOfIds){
51
		int endIndex = startIndex + numberOfIds;
52
		List<TaxonNode> listAllNodesForClassification = listener.getAllNodes(startIndex, endIndex);
53
		return listAllNodesForClassification;
54
	}
55

  
56

  
57

  
58
	@Override
59
	public void addListener(DistributionTableComponentListener listener) {
60
		this.listener = listener;
61
	}
62

  
63
	
64

  
65
}
src/main/java/eu/etaxonomy/cdm/vaadin/model/StatusDTO.java
1
package eu.etaxonomy.cdm.vaadin.model;
2

  
3
import java.io.Serializable;
4

  
5
public class StatusDTO implements Serializable {
6
	
7
	private static final long serialVersionUID = 1L;
8
	private String status;
9
	
10
	public StatusDTO(String status){
11
		this.status = status;
12
	}
13

  
14
	public String getStatus() {
15
		return status;
16
	}
17

  
18
	public void setStatus(String status) {
19
		status = status;
20
	}
21
}
src/main/java/eu/etaxonomy/cdm/vaadin/model/User.java
24 24
	public void addProp(String column, String value) {
25 25
		prop.put(column, value);
26 26
	}
27
	
28
	public String getName(){
29
		return name;
30
	}
27 31

  
28 32
	public Collection<String> getPropertyId() {
29 33
		List<String> propertyId = new ArrayList<String>();
......
54 58
        return null;
55 59
    }
56 60

  
61
    public Object getItemProperty(Object propertyId) {
62
        String item = propertyId.toString();
63
        for (Map.Entry<String, String> entry : prop.entrySet()) {
64
            if(item.equalsIgnoreCase(entry.getKey())) {
65
                return entry.getValue();
66
            }
67
        }
68
        return null;
69
    }
57 70
    /**
58 71
     * @param itemId
59 72
     * @param propertyId
......
62 75
        if(prop.containsKey(propertyId) && prop.containsValue(itemId)){
63 76
            for (Map.Entry<String, String> entry : prop.entrySet()) {
64 77
                if(propertyId.toString().equalsIgnoreCase(entry.getKey())) {
65
                    return entry.getKey();
78
                    return entry.getValue();
66 79
                }
67 80
            }
68 81
        }
src/main/java/eu/etaxonomy/cdm/vaadin/model/Users.java
19 19
	public Users() {
20 20

  
21 21
		User user1 = new User("first user");
22
		user1.addProp("taxon", "Marmorta marmorta");
22 23
		user1.addProp("p1", "val_b_1");
23 24
		user1.addProp("p2", "val_b_2");
24 25

  
25 26
		User user2 = new User("second_user");
27
		user2.addProp("taxon", "Moose");
26 28
		user2.addProp("p1", "val_a_1");
27 29
		user2.addProp("p2", "val_a_2");
28 30

  
......
33 35

  
34 36
	@Override
35 37
	public Item getItem(Object itemId) {
36
		String tool = "string";
37
		String bar = "foo";
38
		return null;
38
		Item item = (Item) itemId;
39
		return item;
39 40
	}
40 41

  
41 42
	@Override
......
58 59

  
59 60
	@Override
60 61
	public Property getContainerProperty(Object itemId, Object propertyId) {
61
		// TODO Auto-generated method stub
62
	    ObjectProperty<String> property = new ObjectProperty<String>((String)itemId);
62
		ObjectProperty<String> property = null;
63
		for(User user:users){
64
			Object itemProperty = user.getItemProperty(propertyId);
65
			property = new ObjectProperty<String>((String)itemProperty);
66
		}
63 67
		return property;
64 68
	}
65 69

  
src/main/java/eu/etaxonomy/cdm/vaadin/model/taxonDTO.java
1
package eu.etaxonomy.cdm.vaadin.model;
2

  
3
import java.io.Serializable;
4

  
5
import eu.etaxonomy.cdm.model.taxon.Taxon;
6

  
7
public class taxonDTO implements Serializable {
8
	
9
	private String taxon;
10
	private DistributionDTO distribution;
11
	
12
	public taxonDTO(String taxon, DistributionDTO distribution){
13
		this.taxon = taxon;
14
		this.distribution = distribution;
15
	}
16

  
17
	public String getTaxon() {
18
		return taxon;
19
	}
20

  
21
	public void setTaxon(String taxon) {
22
		this.taxon = taxon;
23
	}
24

  
25
	public DistributionDTO getDistribution() {
26
		return distribution;
27
	}
28

  
29
	public void setDistribution(DistributionDTO distribution) {
30
		this.distribution = distribution;
31
	}
32

  
33
}
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/DistributionTablePresenter.java
14 14
import eu.etaxonomy.cdm.api.service.IClassificationService;
15 15
import eu.etaxonomy.cdm.api.service.IDescriptionService;
16 16
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
17
import eu.etaxonomy.cdm.api.service.ITaxonService;
17 18
import eu.etaxonomy.cdm.api.service.ITermService;
18 19
import eu.etaxonomy.cdm.api.service.IVocabularyService;
19 20
import eu.etaxonomy.cdm.model.common.CdmBase;
......
26 27
import eu.etaxonomy.cdm.model.taxon.Classification;
27 28
import eu.etaxonomy.cdm.model.taxon.Taxon;
28 29
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
30
import eu.etaxonomy.cdm.vaadin.model.CdmTaxonTableCollection;
29 31
import eu.etaxonomy.cdm.vaadin.model.DbTableDTO;
30 32
import eu.etaxonomy.cdm.vaadin.model.DbTableDTOS;
31
import eu.etaxonomy.cdm.vaadin.model.DistributionDTO;
32 33
import eu.etaxonomy.cdm.vaadin.model.LazyLoadedContainer;
33 34
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper;
34 35
import eu.etaxonomy.cdm.vaadin.view.dbstatus.DistributionTableView;
......
37 38

  
38 39
public class DistributionTablePresenter implements IDistributionTableComponent.DistributionTableComponentListener{
39 40

  
41

  
40 42
	private final IClassificationService classificationService;
41 43
	private final IVocabularyService vocabularyService;
42 44
	private final IDescriptionService descriptionService;
43 45
	private final ITaxonNodeService taxonNodeService;
44 46
	private final ITermService termService;
45 47
	private final DistributionTableView view;
48
	private ITaxonService taxonService;
46 49

  
47 50
	public DistributionTablePresenter(DistributionTableView dtv){
48 51
	    this.view = dtv;
49 52
	    view.addListener(this);
50
	    view.dataBinding();
53
	    taxonService = (ITaxonService)CdmSpringContextHelper.newInstance().getBean("taxonServiceImpl");
51 54
	    classificationService = (IClassificationService)CdmSpringContextHelper.newInstance().getBean("classificationServiceImpl");
52 55
	    taxonNodeService = (ITaxonNodeService)CdmSpringContextHelper.newInstance().getBean("taxonNodeServiceImpl");
53 56
		vocabularyService = (IVocabularyService)CdmSpringContextHelper.newInstance().getBean("vocabularyServiceImpl");
54 57
		descriptionService = (IDescriptionService)CdmSpringContextHelper.newInstance().getBean("descriptionServiceImpl");
55 58
		termService = (ITermService)CdmSpringContextHelper.newInstance().getBean("termServiceImpl");
59
		view.dataBinding();
56 60
	}
57 61

  
58 62

  
......
91 95
		}
92 96
		return map;
93 97
	}
94

  
98
	@Override
99
	public List<DescriptionElementBase> listDescriptionElementsForTaxon(Taxon taxon, Set<Feature> setFeature){
100
		return descriptionService.listDescriptionElementsForTaxon(taxon, setFeature, null, null, null, DESCRIPTION_INIT_STRATEGY);
101
	}
95 102
	
96 103
	@Override
97 104
	public List<Distribution> getDistribution(Taxon taxon) {
......
101 108
		
102 109
	}
103 110
	
104
	
111
	@Override
105 112
	public List<TaxonNode> getAllNodes(int start, int end){
106
		Classification classification = loadClassification();
113
		Classification classification = getChosenClassification();
107 114
		List<TaxonNode> nodesForClassification = taxonNodeService.listAllNodesForClassification(classification, start, end);
108 115
		return nodesForClassification;
109 116
	}
110 117

  
111 118

  
112

  
113
	private Classification loadClassification() {
119
	@Override
120
	public Classification getChosenClassification() {
114 121
		VaadinSession session = VaadinSession.getCurrent();
115 122
		UUID classificationUUID = (UUID) session.getAttribute("classificationUUID");
116 123
		Classification classification = classificationService.load(classificationUUID);
......
119 126
	
120 127
	@Override
121 128
	public int getSizeOfClassification(){
122
		Classification classification = loadClassification();
129
		Classification classification = getChosenClassification();
123 130
		return taxonNodeService.countAllNodesForClassification(classification);
124 131
	}
125 132
	
......
147 154
		return items;
148 155
	}
149 156
	
150
	void nestedContainer(){
151
		BeanItemContainer<DbTableDTO> container = new BeanItemContainer<DbTableDTO>(DbTableDTO.class);
157
	
158
	
159
	@Override
160
	public LazyLoadedContainer getLazyLoadedContainer(){
161
		LazyLoadedContainer lz = new LazyLoadedContainer(CdmTaxonTableCollection.class);
162
	    lz.addListener(this);
163
		return lz;
152 164
		
153 165
	}
154 166
	
......
173 185
    });
174 186

  
175 187

  
188
	@Override
189
	public IClassificationService getClassificationService() {
190
		return classificationService;
191
	}
192

  
193

  
194
	@Override
195
	public IVocabularyService getVocabularyService() {
196
		return vocabularyService;
197
	}
198

  
199

  
200
	@Override
201
	public IDescriptionService getDescriptionService() {
202
		return descriptionService;
203
	}
204

  
205

  
206
	@Override
207
	public ITaxonNodeService getTaxonNodeService() {
208
		return taxonNodeService;
209
	}
210

  
211

  
212
	@Override
213
	public ITermService getTermService() {
214
		return termService;
215
	}
216
	
176 217
	@Override
177 218
	public LazyLoadedContainer getTableContainer() {
178 219
		// TODO Auto-generated method stub
......
181 222

  
182 223

  
183 224

  
225
	@Override
226
	public ITaxonService getTaxonService() {
227
		return taxonService;
228
	}
229

  
230

  
184 231
}
src/main/java/eu/etaxonomy/cdm/vaadin/ui/DbStatusUI.java
3 3
import javax.servlet.annotation.WebServlet;
4 4

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

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

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

  
......
23 23

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

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

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

  
3
import java.util.ArrayList;
4
import java.util.Arrays;
5
import java.util.HashMap;
6
import java.util.HashSet;
7
import java.util.List;
8
import java.util.Map;
9
import java.util.Set;
10
import java.util.SortedSet;
11

  
3 12
import com.vaadin.annotations.AutoGenerated;
4
import com.vaadin.data.Container;
13
import com.vaadin.data.Property.ValueChangeListener;
5 14
import com.vaadin.data.util.BeanItemContainer;
6
import com.vaadin.data.util.IndexedContainer;
7 15
import com.vaadin.navigator.View;
8 16
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
9 17
import com.vaadin.ui.AbsoluteLayout;
10 18
import com.vaadin.ui.Button.ClickEvent;
11 19
import com.vaadin.ui.Button.ClickListener;
12
import com.vaadin.ui.Component;
20
import com.vaadin.ui.Table.ColumnGenerator;
21
import com.vaadin.ui.ComboBox;
13 22
import com.vaadin.ui.CustomComponent;
14
import com.vaadin.ui.Field;
23
import com.vaadin.ui.Label;
24
import com.vaadin.ui.Notification;
15 25
import com.vaadin.ui.Table;
16
import com.vaadin.ui.TableFieldFactory;
17 26

  
27
import eu.etaxonomy.cdm.model.common.CdmBase;
18 28
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
19
import eu.etaxonomy.cdm.vaadin.model.DistributionDTO;
20
import eu.etaxonomy.cdm.vaadin.model.Users;
21
import eu.etaxonomy.cdm.vaadin.model.taxonDTO;
29
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
30
import eu.etaxonomy.cdm.model.description.Distribution;
31
import eu.etaxonomy.cdm.model.description.Feature;
32
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
33
import eu.etaxonomy.cdm.model.description.TaxonDescription;
34
import eu.etaxonomy.cdm.model.location.NamedArea;
35
import eu.etaxonomy.cdm.model.taxon.Taxon;
36
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
37
import eu.etaxonomy.cdm.vaadin.component.HorizontalToolbar;
38
import eu.etaxonomy.cdm.vaadin.model.LazyLoadedContainer;
22 39

  
23 40
public class DistributionTableView extends CustomComponent implements IDistributionTableComponent, View, ClickListener{
24 41

  
......
35 52
	
36 53
	private DistributionTableComponentListener listener;
37 54
	
55
	ArrayList<String> columnList;
56
	ArrayList<String> headerList;
57
	
38 58
	/**
39 59
	 * The constructor should first build the main layout, set the
40 60
	 * composition root and then do any custom initialization.
......
48 68
		
49 69
		
50 70
	}
51

  
52
	
53
	public void dataBinding(){
54
//		LazyLoadedContainer container = new LazyLoadedContainer(DbTableDTO.class);
55
		BeanItemContainer<taxonDTO> taxonContainer = new BeanItemContainer<taxonDTO>(taxonDTO.class);
56
		taxonContainer.addNestedContainerProperty("distribution.name");
57
		taxonContainer.addNestedContainerProperty("distribution.status");
58
		BeanItemContainer<DistributionDTO> distContainer = new BeanItemContainer<DistributionDTO>(DistributionDTO.class);
59
		for(int i = 0; i<100; i++){
60
			distContainer.addBean(new DistributionDTO("Area"+i, "Status"+i));
61
		}
62
		for(int i = 0; i<100; i++){
63
			taxonContainer.addBean(new taxonDTO("taxon"+i, new DistributionDTO("Area"+i, "Status"+i)));
64
		}
65

  
66
		Users user = new Users();
67
		
68
		table_1.setContainerDataSource(user);
69
		
70
//		container.addNestedContainerProperty("dDTO.status");
71
	}
72 71
	
73 72
	@Override
74 73
	public void addListener(DistributionTableComponentListener listener) {
......
86 85
		// top-level component properties
87 86
		setWidth("100.0%");
88 87
		setHeight("100.0%");
89

  
88
		//Horizontal Toolbar
89
		HorizontalToolbar bar = new HorizontalToolbar();
90
		mainLayout.addComponent(bar, "top:0.0px;right:0.0px;");
91
		
90 92
		// table_1
91 93
		table_1 = new Table();
92 94
		table_1.setImmediate(false);
93 95
		table_1.setWidth("100.0%");
94 96
		table_1.setHeight("100.0%");
95
		mainLayout.addComponent(table_1, "top:0.0px;right:0.0px;");
97
		mainLayout.addComponent(table_1, "top:100px;right:0.0px;");
96 98

  
97 99
		return mainLayout;
98 100
	}
......
115 117

  
116 118
    }
117 119

  
120
    
121
	public void dataBinding(){
122

  
123
//		container.addNestedContainerProperty("dDTO.status");
124
		final LazyLoadedContainer container = listener.getLazyLoadedContainer();
125
		Set<DefinedTermBase> chosenTerms = listener.getChosenTerms();
126
		generateDsitributionColumn(chosenTerms);
127
		
128
		table_1.setContainerDataSource(container);
129
		table_1.setColumnReorderingAllowed(true);
130
		table_1.setSortEnabled(false);
131
//		setVisibleColumns(columns);
132
		Object[] visibleColumns = columnList.toArray();
133
		table_1.setVisibleColumns(visibleColumns);
134
		table_1.setColumnHeaders(headerList.toArray(new String[headerList.size()]));//new String[]{"Taxon", "Rang"});// ,"Deutschland"
135
		table_1.setColumnCollapsingAllowed(true);
136
		table_1.setSelectable(true);
137
//		table_1.setSizeUndefined();
138
//		setSizeFull();
139
		table_1.setPageLength(20);
140
		table_1.setFooterVisible(true);
141
		table_1.setColumnFooter("fullTitleCache", "Total amount of Taxa displayed: " + container.size());
142

  
143
		table_1.setCacheRate(10);
144
	}
145
    
146
    
147
    void generateDsitributionColumn(Set<DefinedTermBase> terms){
148
		columnList = new ArrayList<String>(Arrays.asList(new String[]{"fullTitleCache","rank"}));
149
		headerList = new ArrayList<String>(Arrays.asList(new String[]{"Taxon","Rang"}));
150
		for(final DefinedTermBase dt : terms){
151
			columnList.add(dt.getTitleCache());
152
			headerList.add(dt.getTitleCache());
153
//			container.addContainerProperty(dt.getTitleCache(), String.class, null);
154
			
155
			table_1.addContainerProperty(dt.getTitleCache(), String.class, null);
156
			try{
157
				table_1.addGeneratedColumn(dt.getTitleCache(), new ColumnGenerator() {
158
					public Object generateCell(Table source, Object itemId, Object columnId) {
159
						Label tf = new Label();
160
						ComboBox box = null;
161
						if(itemId instanceof TaxonNode){
162
							TaxonNode tn = CdmBase.deproxy((TaxonNode) itemId, TaxonNode.class);
163
							Taxon taxon = CdmBase.deproxy(tn.getTaxon(), Taxon.class);
164
							taxon = (Taxon) listener.getTaxonService().load(taxon.getUuid());
165
							HashMap<DescriptionElementBase, Distribution> map = getDistribution(taxon);
166
							
167
							List<PresenceAbsenceTerm> listTerm = listener.getPresenceAbsenceTerms();
168
							BeanItemContainer<PresenceAbsenceTerm> termContainer = new BeanItemContainer<PresenceAbsenceTerm>(PresenceAbsenceTerm.class);
169
							termContainer.addAll(listTerm);
170
							box = new ComboBox("Occurrence Status: ", termContainer);
171
							box.setImmediate(true);
172
							
173
							if(map != null){
174
								/** update field **/
175
								DescriptionElementBase deb = null; 
176
								Distribution db = null;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff