Revision 1a3e979c
Added by Alexander Oppermann about 8 years ago
.gitattributes | ||
---|---|---|
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 | 6 |
src/main/java/eu/etaxonomy/cdm/vaadin/component/ConceptRelationshipComposite.java -text |
7 |
src/main/java/eu/etaxonomy/cdm/vaadin/component/ConfigWindow.java -text |
|
8 |
src/main/java/eu/etaxonomy/cdm/vaadin/component/DetailWindow.java -text |
|
7 | 9 |
src/main/java/eu/etaxonomy/cdm/vaadin/component/EditConceptRelationshipComposite.java -text |
8 | 10 |
src/main/java/eu/etaxonomy/cdm/vaadin/component/HorizontalToolbar.java -text |
9 | 11 |
src/main/java/eu/etaxonomy/cdm/vaadin/component/NewTaxonBaseComposite.java -text |
... | ... | |
29 | 31 |
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/StatusPresenter.java -text |
30 | 32 |
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/DistributionSelectionPresenter.java -text |
31 | 33 |
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/DistributionTablePresenter.java -text |
34 |
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/settings/SettingsPresenter.java -text |
|
32 | 35 |
src/main/java/eu/etaxonomy/cdm/vaadin/servlet/CdmVaadinConversationalServlet.java -text |
33 | 36 |
src/main/java/eu/etaxonomy/cdm/vaadin/session/CdmChangeEvent.java -text |
34 | 37 |
src/main/java/eu/etaxonomy/cdm/vaadin/session/CdmDataChangeService.java -text |
... | ... | |
114 | 117 |
src/main/webapp/VAADIN/themes/macosx/icons/32/ok.png -text |
115 | 118 |
src/main/webapp/VAADIN/themes/macosx/icons/32/reload.png -text |
116 | 119 |
src/main/webapp/VAADIN/themes/macosx/icons/32/settings.png -text |
120 |
src/main/webapp/VAADIN/themes/macosx/icons/32/settings_1.png -text |
|
117 | 121 |
src/main/webapp/VAADIN/themes/macosx/icons/32/top-left.png -text |
118 | 122 |
src/main/webapp/VAADIN/themes/macosx/icons/32/top-right.png -text |
119 | 123 |
src/main/webapp/VAADIN/themes/macosx/icons/32/trash-full.png -text |
src/main/java/eu/etaxonomy/cdm/vaadin/component/ConfigWindow.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2015 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.cdm.vaadin.component; |
|
11 |
|
|
12 |
import com.vaadin.annotations.AutoGenerated; |
|
13 |
import com.vaadin.data.Container; |
|
14 |
import com.vaadin.ui.AbsoluteLayout; |
|
15 |
import com.vaadin.ui.Button; |
|
16 |
import com.vaadin.ui.ComboBox; |
|
17 |
import com.vaadin.ui.CustomComponent; |
|
18 |
import com.vaadin.ui.Label; |
|
19 |
import com.vaadin.ui.TwinColSelect; |
|
20 |
import com.vaadin.ui.Window; |
|
21 |
|
|
22 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|
23 |
import eu.etaxonomy.cdm.vaadin.presenter.dbstatus.settings.SettingsPresenter; |
|
24 |
|
|
25 |
/** |
|
26 |
* @author alex |
|
27 |
* @date 22.04.2015 |
|
28 |
* |
|
29 |
*/ |
|
30 |
public class ConfigWindow extends CustomComponent { |
|
31 |
|
|
32 |
/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */ |
|
33 |
|
|
34 |
@AutoGenerated |
|
35 |
private AbsoluteLayout mainLayout; |
|
36 |
@AutoGenerated |
|
37 |
private Label label_4; |
|
38 |
@AutoGenerated |
|
39 |
private TwinColSelect distStatusSelect; |
|
40 |
@AutoGenerated |
|
41 |
private Label label_3; |
|
42 |
@AutoGenerated |
|
43 |
private Label label_2; |
|
44 |
@AutoGenerated |
|
45 |
private ComboBox distAreaBox; |
|
46 |
@AutoGenerated |
|
47 |
private ComboBox classificationBox; |
|
48 |
@AutoGenerated |
|
49 |
private Button okButton; |
|
50 |
@AutoGenerated |
|
51 |
private Button cancelButton; |
|
52 |
@AutoGenerated |
|
53 |
private Label label_1; |
|
54 |
private final SettingsPresenter presenter; |
|
55 |
/** |
|
56 |
* The constructor should first build the main layout, set the |
|
57 |
* composition root and then do any custom initialization. |
|
58 |
* |
|
59 |
* The constructor will not be automatically regenerated by the |
|
60 |
* visual editor. |
|
61 |
*/ |
|
62 |
public ConfigWindow() { |
|
63 |
buildMainLayout(); |
|
64 |
// setCompositionRoot(mainLayout); |
|
65 |
presenter = new SettingsPresenter(); |
|
66 |
init(); |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* |
|
71 |
*/ |
|
72 |
private void init() { |
|
73 |
Container classificationContainer = presenter.getClassificationContainer(); |
|
74 |
Container distributionContainer = presenter.getDistributionContainer(); |
|
75 |
TermVocabulary chosenArea = presenter.getChosenArea(); |
|
76 |
classificationBox.setContainerDataSource(classificationContainer); |
|
77 |
classificationBox.setValue(presenter.getChosenClassification()); |
|
78 |
distAreaBox.setContainerDataSource(distributionContainer); |
|
79 |
distAreaBox.setValue(chosenArea); |
|
80 |
distStatusSelect.setContainerDataSource(presenter.getDistributionStatusContainer()); |
|
81 |
} |
|
82 |
|
|
83 |
public Window createWindow(){ |
|
84 |
Window window = new Window(); |
|
85 |
window.setModal(true); |
|
86 |
window.setHeight("600px"); |
|
87 |
window.setWidth("500px"); |
|
88 |
window.setCaption("Settings"); |
|
89 |
window.setContent(mainLayout); |
|
90 |
return window; |
|
91 |
} |
|
92 |
|
|
93 |
@AutoGenerated |
|
94 |
private AbsoluteLayout buildMainLayout() { |
|
95 |
// common part: create layout |
|
96 |
mainLayout = new AbsoluteLayout(); |
|
97 |
mainLayout.setImmediate(false); |
|
98 |
mainLayout.setWidth("100%"); |
|
99 |
mainLayout.setHeight("100%"); |
|
100 |
|
|
101 |
// top-level component properties |
|
102 |
setWidth("100.0%"); |
|
103 |
setHeight("100.0%"); |
|
104 |
|
|
105 |
// label_1 |
|
106 |
label_1 = new Label(); |
|
107 |
label_1.setImmediate(false); |
|
108 |
label_1.setWidth("100.0%"); |
|
109 |
label_1.setHeight("40px"); |
|
110 |
label_1.setValue("This is a description box for my settings"); |
|
111 |
mainLayout.addComponent(label_1, "top:0.0px;left:0.0px;"); |
|
112 |
|
|
113 |
// cancelButton |
|
114 |
cancelButton = new Button(); |
|
115 |
cancelButton.setCaption("Cancel"); |
|
116 |
cancelButton.setImmediate(true); |
|
117 |
cancelButton.setWidth("-1px"); |
|
118 |
cancelButton.setHeight("-1px"); |
|
119 |
mainLayout.addComponent(cancelButton, "top:380.0px;left:273.0px;"); |
|
120 |
|
|
121 |
// okButton |
|
122 |
okButton = new Button(); |
|
123 |
okButton.setCaption("OK"); |
|
124 |
okButton.setImmediate(true); |
|
125 |
okButton.setWidth("67px"); |
|
126 |
okButton.setHeight("-1px"); |
|
127 |
mainLayout.addComponent(okButton, "top:380.0px;left:364.0px;"); |
|
128 |
|
|
129 |
// classificationBox |
|
130 |
classificationBox = new ComboBox(); |
|
131 |
classificationBox.setImmediate(false); |
|
132 |
classificationBox.setWidth("-1px"); |
|
133 |
classificationBox.setHeight("-1px"); |
|
134 |
mainLayout.addComponent(classificationBox, "top:97.0px;left:258.0px;"); |
|
135 |
|
|
136 |
// distAreaBox |
|
137 |
distAreaBox = new ComboBox(); |
|
138 |
distAreaBox.setImmediate(false); |
|
139 |
distAreaBox.setWidth("-1px"); |
|
140 |
distAreaBox.setHeight("-1px"); |
|
141 |
mainLayout.addComponent(distAreaBox, "top:141.0px;left:258.0px;"); |
|
142 |
|
|
143 |
// label_2 |
|
144 |
label_2 = new Label(); |
|
145 |
label_2.setImmediate(false); |
|
146 |
label_2.setWidth("-1px"); |
|
147 |
label_2.setHeight("-1px"); |
|
148 |
label_2.setValue("Classification:"); |
|
149 |
mainLayout.addComponent(label_2, "top:97.0px;left:24.0px;"); |
|
150 |
|
|
151 |
// label_3 |
|
152 |
label_3 = new Label(); |
|
153 |
label_3.setImmediate(false); |
|
154 |
label_3.setWidth("-1px"); |
|
155 |
label_3.setHeight("-1px"); |
|
156 |
label_3.setValue("Distribution Area:"); |
|
157 |
mainLayout.addComponent(label_3, "top:141.0px;left:24.0px;"); |
|
158 |
|
|
159 |
// distStatusSelect |
|
160 |
distStatusSelect = new TwinColSelect(); |
|
161 |
distStatusSelect.setImmediate(false); |
|
162 |
distStatusSelect.setWidth("-1px"); |
|
163 |
distStatusSelect.setHeight("-1px"); |
|
164 |
mainLayout.addComponent(distStatusSelect, "top:188.0px;left:152.0px;"); |
|
165 |
|
|
166 |
// label_4 |
|
167 |
label_4 = new Label(); |
|
168 |
label_4.setImmediate(false); |
|
169 |
label_4.setWidth("-1px"); |
|
170 |
label_4.setHeight("-1px"); |
|
171 |
label_4.setValue("Distribution Status:"); |
|
172 |
mainLayout.addComponent(label_4, "top:202.0px;left:20.0px;"); |
|
173 |
|
|
174 |
return mainLayout; |
|
175 |
} |
|
176 |
|
|
177 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/component/DetailWindow.java | ||
---|---|---|
1 |
package eu.etaxonomy.cdm.vaadin.component; |
|
2 |
import java.util.Collection; |
|
3 |
|
|
4 |
import org.springframework.context.annotation.Scope; |
|
5 |
|
|
6 |
import com.vaadin.event.ShortcutAction.KeyCode; |
|
7 |
import com.vaadin.event.ShortcutAction.ModifierKey; |
|
8 |
import com.vaadin.ui.CustomComponent; |
|
9 |
import com.vaadin.ui.Tree; |
|
10 |
import com.vaadin.ui.Window; |
|
11 |
|
|
12 |
import eu.etaxonomy.cdm.model.common.Language; |
|
13 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
|
14 |
import eu.etaxonomy.cdm.model.description.CommonTaxonName; |
|
15 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
|
16 |
import eu.etaxonomy.cdm.model.description.Distribution; |
|
17 |
import eu.etaxonomy.cdm.model.description.StateData; |
|
18 |
import eu.etaxonomy.cdm.model.description.TextData; |
|
19 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
20 |
|
|
21 |
|
|
22 |
@Scope("prototype") |
|
23 |
public class DetailWindow extends CustomComponent{ |
|
24 |
|
|
25 |
|
|
26 |
private final Collection<DescriptionElementBase> listDescriptions; |
|
27 |
private final Taxon taxon; |
|
28 |
|
|
29 |
public DetailWindow(Taxon taxon, Collection<DescriptionElementBase> listDescriptions) { |
|
30 |
this.taxon = taxon; |
|
31 |
this.listDescriptions = listDescriptions; |
|
32 |
|
|
33 |
} |
|
34 |
|
|
35 |
public Window createWindow(){ |
|
36 |
Window window = new Window(); |
|
37 |
window.setHeightUndefined(); |
|
38 |
// window.setHeight("600px"); |
|
39 |
// window.setWidth("400px"); |
|
40 |
window.setCaption(taxon.getName().getTitleCache()); |
|
41 |
window.setCloseShortcut(KeyCode.W, ModifierKey.CTRL); |
|
42 |
window.setContent(constructDescriptionTree(taxon)); |
|
43 |
return window; |
|
44 |
} |
|
45 |
|
|
46 |
private Tree constructDescriptionTree(Taxon taxon){ |
|
47 |
Tree tree = new Tree(); |
|
48 |
tree.setSizeUndefined(); |
|
49 |
String parent = "Descriptive Data"; |
|
50 |
tree.setValue(parent); |
|
51 |
initDescriptionTree(tree, listDescriptions, parent); |
|
52 |
return tree; |
|
53 |
} |
|
54 |
|
|
55 |
private void initDescriptionTree(Tree tree, Collection<DescriptionElementBase>listDescriptions, Object parent) { |
|
56 |
//TODO: sorting List |
|
57 |
for (DescriptionElementBase deb : listDescriptions){ |
|
58 |
tree.addItem(deb.getFeature()); |
|
59 |
tree.setItemCaption(deb.getFeature(), deb.getFeature().getTitleCache()); |
|
60 |
tree.setParent(deb.getFeature(), parent); |
|
61 |
tree.setChildrenAllowed(deb.getFeature(), true); |
|
62 |
|
|
63 |
if(deb instanceof CategoricalData){ |
|
64 |
CategoricalData cd = (CategoricalData) deb; |
|
65 |
if(cd.getStatesOnly().size() <= 1){ |
|
66 |
for(StateData st : cd.getStateData()){ |
|
67 |
tree.addItem(st); |
|
68 |
tree.setItemCaption(st, st.getState().getTitleCache()); |
|
69 |
tree.setParent(st, deb.getFeature()); |
|
70 |
tree.setChildrenAllowed(st, false); |
|
71 |
} |
|
72 |
}else{ |
|
73 |
//TODO: implement recursion |
|
74 |
} |
|
75 |
}else if(deb instanceof TextData){ |
|
76 |
TextData td = (TextData) deb; |
|
77 |
tree.addItem(td); |
|
78 |
tree.setItemCaption(td, td.getText(Language.GERMAN())); |
|
79 |
tree.setParent(td, deb.getFeature()); |
|
80 |
tree.setChildrenAllowed(td, false); |
|
81 |
}else if(deb instanceof CommonTaxonName){ |
|
82 |
CommonTaxonName td = (CommonTaxonName) deb; |
|
83 |
tree.addItem(td); |
|
84 |
tree.setItemCaption(td, td.getName()); |
|
85 |
tree.setParent(td, deb.getFeature()); |
|
86 |
tree.setChildrenAllowed(td, false); |
|
87 |
}else if(deb instanceof Distribution){ |
|
88 |
Distribution db = (Distribution) deb; |
|
89 |
|
|
90 |
tree.addItem(db.toString()); |
|
91 |
tree.setParent(db.toString(), deb.getFeature()); |
|
92 |
tree.setChildrenAllowed(db.toString(), true); |
|
93 |
|
|
94 |
tree.addItem(db.getStatus().toString()); |
|
95 |
tree.setParent(db.getStatus().toString(), db.toString()); |
|
96 |
tree.setChildrenAllowed(db.getStatus().toString(), false); |
|
97 |
} |
|
98 |
tree.expandItemsRecursively(parent); |
|
99 |
} |
|
100 |
|
|
101 |
} |
|
102 |
|
|
103 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/component/HorizontalToolbar.java | ||
---|---|---|
24 | 24 |
* automatically generated ID |
25 | 25 |
*/ |
26 | 26 |
private static final long serialVersionUID = 5344340511582993289L; |
27 |
|
|
28 |
|
|
27 |
|
|
28 |
|
|
29 | 29 |
private final Button editButton = new Button("Edit"); |
30 |
|
|
30 |
|
|
31 | 31 |
private final Button saveButton = new Button("Save"); |
32 | 32 |
|
33 | 33 |
private final Button detailButton = new Button("Detail"); |
34 |
|
|
34 |
|
|
35 |
private final Button settingsButton = new Button("Settings"); |
|
36 |
|
|
35 | 37 |
private final Button logoutButton= new Button("Logout"); |
36 | 38 |
|
37 |
private Authentication authentication; |
|
39 |
private final Authentication authentication;
|
|
38 | 40 |
// private ExcelExporter exporter = new ExcelExporter(); |
39 | 41 |
|
40 | 42 |
public HorizontalToolbar() { |
41 | 43 |
authentication = (Authentication) VaadinSession.getCurrent().getAttribute("authentication"); |
42 | 44 |
init(); |
43 | 45 |
} |
44 |
|
|
46 |
|
|
45 | 47 |
public void init() { |
46 | 48 |
if(authentication != null && authentication.isAuthenticated()){ |
47 | 49 |
setMargin(true); |
... | ... | |
50 | 52 |
setWidth("100%"); |
51 | 53 |
setHeight("75px"); |
52 | 54 |
|
53 |
addComponent(editButton); |
|
55 |
// addComponent(editButton);
|
|
54 | 56 |
addComponent(saveButton); |
55 | 57 |
addComponent(detailButton); |
56 | 58 |
// addComponent(exporter); |
... | ... | |
61 | 63 |
saveButton.setIcon(new ThemeResource("icons/32/document-save.png")); |
62 | 64 |
editButton.setIcon(new ThemeResource("icons/32/document-edit.png")); |
63 | 65 |
detailButton.setIcon(new ThemeResource("icons/32/document-txt.png")); |
66 |
settingsButton.setIcon(new ThemeResource("icons/32/settings_1.png")); |
|
64 | 67 |
logoutButton.setIcon(new ThemeResource("icons/32/cancel.png")); |
65 | 68 |
|
66 |
// SecurityContext context = (SecurityContext)VaadinService.getCurrentRequest().getWrappedSession().getAttribute("context");
|
|
69 |
// SecurityContext context = (SecurityContext)VaadinService.getCurrentRequest().getWrappedSession().getAttribute("context"); |
|
67 | 70 |
SecurityContext context = SecurityContextHolder.getContext(); |
68 | 71 |
Label loginName = new Label(authentication.getName().toString()); |
69 | 72 |
loginName.setIcon(new ThemeResource("icons/32/user.png")); |
70 | 73 |
|
71 |
HorizontalLayout rightLayout = new HorizontalLayout();
|
|
74 |
HorizontalLayout rightLayout = new HorizontalLayout(); |
|
72 | 75 |
Image image = new Image(null, new ThemeResource("icons/32/vseparator1.png")); |
76 |
rightLayout.addComponent(settingsButton); |
|
73 | 77 |
rightLayout.addComponent(logoutButton); |
74 | 78 |
rightLayout.addComponent(image); |
75 | 79 |
rightLayout.addComponent(loginName); |
... | ... | |
85 | 89 |
*/ |
86 | 90 |
private static final long serialVersionUID = 8380401487511285303L; |
87 | 91 |
|
88 |
public void buttonClick(ClickEvent event) { |
|
89 |
|
|
92 |
@Override |
|
93 |
public void buttonClick(ClickEvent event) { |
|
94 |
|
|
90 | 95 |
authentication.setAuthenticated(false); |
91 | 96 |
UI.getCurrent().getNavigator().navigateTo("abstractAuthenticatedUI"); |
92 | 97 |
} |
93 | 98 |
}); |
94 | 99 |
} |
95 | 100 |
} |
96 |
|
|
101 |
|
|
102 |
public Button getSettingsButton(){ |
|
103 |
return settingsButton; |
|
104 |
} |
|
105 |
|
|
97 | 106 |
public Button getEditButton() { |
98 | 107 |
return editButton; |
99 | 108 |
} |
100 |
|
|
109 |
|
|
101 | 110 |
public Button getSaveButton() { |
102 | 111 |
return saveButton; |
103 | 112 |
} |
104 |
|
|
113 |
|
|
105 | 114 |
public Button getDetailButton() { |
106 | 115 |
return detailButton; |
107 | 116 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/DistributionTablePresenter.java | ||
---|---|---|
3 | 3 |
import java.sql.SQLException; |
4 | 4 |
import java.util.ArrayList; |
5 | 5 |
import java.util.Arrays; |
6 |
import java.util.Collection; |
|
7 | 6 |
import java.util.Collections; |
7 |
import java.util.Comparator; |
|
8 | 8 |
import java.util.HashMap; |
9 | 9 |
import java.util.HashSet; |
10 | 10 |
import java.util.List; |
11 | 11 |
import java.util.Set; |
12 |
import java.util.SortedSet; |
|
12 | 13 |
import java.util.UUID; |
13 | 14 |
|
15 |
import com.vaadin.data.Container; |
|
14 | 16 |
import com.vaadin.data.util.BeanItemContainer; |
15 | 17 |
import com.vaadin.server.VaadinSession; |
16 |
import com.vaadin.ui.ComboBox; |
|
17 | 18 |
|
18 | 19 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
19 | 20 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
... | ... | |
23 | 24 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
24 | 25 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
25 | 26 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
27 |
import eu.etaxonomy.cdm.model.common.Language; |
|
28 |
import eu.etaxonomy.cdm.model.common.Representation; |
|
26 | 29 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
27 | 30 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
28 | 31 |
import eu.etaxonomy.cdm.model.description.Distribution; |
29 | 32 |
import eu.etaxonomy.cdm.model.description.Feature; |
30 | 33 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm; |
34 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
|
35 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
|
31 | 36 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
32 | 37 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
33 | 38 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
34 | 39 |
import eu.etaxonomy.cdm.vaadin.container.CdmSQLContainer; |
35 |
import eu.etaxonomy.cdm.vaadin.model.CdmTaxonTableCollection; |
|
36 |
import eu.etaxonomy.cdm.vaadin.model.DbTableDTO; |
|
37 |
import eu.etaxonomy.cdm.vaadin.model.DbTableDTOS; |
|
38 | 40 |
import eu.etaxonomy.cdm.vaadin.model.LazyLoadedContainer; |
39 | 41 |
import eu.etaxonomy.cdm.vaadin.util.CdmQueryFactory; |
40 | 42 |
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper; |
... | ... | |
67 | 69 |
|
68 | 70 |
|
69 | 71 |
@Override |
70 |
public ComboBox updateDistributionField(DescriptionElementBase deb, |
|
71 |
Distribution db, |
|
72 |
BeanItemContainer<PresenceAbsenceTerm> termContainer, ComboBox box, |
|
73 |
Taxon taxon) { |
|
74 |
// TODO Auto-generated method stub |
|
75 |
return null; |
|
72 |
public int updateDistributionField(String distributionArea, Object comboValue, Taxon taxon) { |
|
73 |
Set<DefinedTermBase> chosenTerms = getChosenTerms(); |
|
74 |
NamedArea nArea = null; |
|
75 |
for(DefinedTermBase dt:chosenTerms){ |
|
76 |
if(dt.getTitleCache().equalsIgnoreCase(distributionArea)){ |
|
77 |
nArea = (NamedArea) dt; |
|
78 |
break; |
|
79 |
} |
|
80 |
} |
|
81 |
List<Distribution> distribution = getDistribution(taxon); |
|
82 |
Distribution db = null; |
|
83 |
for(Distribution dist : distribution){ |
|
84 |
if(dist.getArea().equals(nArea)){ |
|
85 |
db = dist; |
|
86 |
break; |
|
87 |
} |
|
88 |
} |
|
89 |
if(comboValue == null){//delete descriptionElementBase |
|
90 |
getDescriptionService().deleteDescriptionElement(db);//descriptionElementbase |
|
91 |
getTaxonService().saveOrUpdate(taxon); |
|
92 |
return 1; |
|
93 |
}else{ |
|
94 |
db.setStatus((PresenceAbsenceTerm)comboValue); |
|
95 |
getDescriptionService().saveDescriptionElement(db);//descriptionElementbase? |
|
96 |
return 0; |
|
97 |
} |
|
76 | 98 |
} |
77 | 99 |
|
78 | 100 |
@Override |
... | ... | |
85 | 107 |
} |
86 | 108 |
|
87 | 109 |
|
88 |
public List<String> getTermList() { |
|
89 |
VaadinSession session = VaadinSession.getCurrent(); |
|
90 |
UUID termUUID = (UUID) session.getAttribute("selectedTerm"); |
|
91 |
TermVocabulary<DefinedTermBase> term = vocabularyService.load(termUUID); |
|
92 |
term = CdmBase.deproxy(term, TermVocabulary.class); |
|
93 |
Set<DefinedTermBase> terms = term.getTerms(); |
|
110 |
@Override |
|
111 |
public List<String> getAbbreviatedTermList() { |
|
112 |
SortedSet<DefinedTermBase> terms = getTermSet(); |
|
94 | 113 |
List<String> list = new ArrayList<String>(); |
95 | 114 |
for(DefinedTermBase dtb: terms){ |
96 |
list.add(dtb.getTitleCache()); |
|
115 |
for(Representation r : dtb.getRepresentations()){ |
|
116 |
list.add(r.getAbbreviatedLabel()); |
|
117 |
} |
|
97 | 118 |
} |
98 |
Collections.sort(list); |
|
119 |
// Collections.sort(list);
|
|
99 | 120 |
return list; |
100 | 121 |
} |
101 | 122 |
|
123 |
@Override |
|
124 |
public List<String> getTermList() { |
|
125 |
SortedSet<DefinedTermBase> terms = getTermSet(); |
|
126 |
List<String> list = new ArrayList<String>(); |
|
127 |
for(DefinedTermBase dtb: terms){ |
|
128 |
list.add(dtb.getTitleCache()); |
|
129 |
} |
|
130 |
// Collections.sort(list); |
|
131 |
return list; |
|
132 |
} |
|
133 |
|
|
134 |
|
|
135 |
private SortedSet<DefinedTermBase> getTermSet(){ |
|
136 |
VaadinSession session = VaadinSession.getCurrent(); |
|
137 |
UUID termUUID = (UUID) session.getAttribute("selectedTerm"); |
|
138 |
TermVocabulary<DefinedTermBase> term = vocabularyService.load(termUUID); |
|
139 |
term = CdmBase.deproxy(term, TermVocabulary.class); |
|
140 |
return term.getTermsOrderedByLabels(Language.DEFAULT()); |
|
141 |
} |
|
142 |
|
|
102 | 143 |
@Override |
103 | 144 |
public HashMap<DescriptionElementBase, Distribution> getDistribution(DefinedTermBase dt, Taxon taxon) { |
104 | 145 |
Set<Feature> setFeature = new HashSet<Feature>(Arrays.asList(Feature.DISTRIBUTION())); |
... | ... | |
118 | 159 |
} |
119 | 160 |
@Override |
120 | 161 |
public List<DescriptionElementBase> listDescriptionElementsForTaxon(Taxon taxon, Set<Feature> setFeature){ |
121 |
return descriptionService.listDescriptionElementsForTaxon(taxon, setFeature, null, null, null, DESCRIPTION_INIT_STRATEGY); |
|
162 |
List<DescriptionElementBase> listDescriptionElementsForTaxon = descriptionService.listDescriptionElementsForTaxon(taxon, setFeature, null, null, null, DESCRIPTION_INIT_STRATEGY); |
|
163 |
sort(listDescriptionElementsForTaxon); |
|
164 |
return listDescriptionElementsForTaxon; |
|
122 | 165 |
} |
123 | 166 |
|
124 | 167 |
@Override |
... | ... | |
151 | 194 |
return taxonNodeService.countAllNodesForClassification(classification); |
152 | 195 |
} |
153 | 196 |
|
154 |
@Override |
|
155 |
public DbTableDTOS getDataList(int start, int end){ |
|
156 |
List<TaxonNode> nodes = getAllNodes(start, end); |
|
157 |
DbTableDTOS items = new DbTableDTOS(); |
|
158 |
for(TaxonNode tn: nodes){ |
|
159 |
Taxon taxon = tn.getTaxon(); |
|
160 |
DbTableDTO dbTableDTO = new DbTableDTO(taxon); |
|
161 |
|
|
162 |
Set<DefinedTermBase> terms = getChosenTerms(); |
|
163 |
List<Distribution> distribution = getDistribution(taxon); |
|
164 |
for(DefinedTermBase dt: terms){ |
|
165 |
for(Distribution db : distribution){ |
|
166 |
if(dt.getTitleCache().equalsIgnoreCase(db.getArea().getTitleCache())){ |
|
167 |
// DistributionDTO distributionDTO = new DistributionDTO(db.getStatus().getTitleCache()); |
|
168 |
// dbTableDTO.setdDTO(distributionDTO); |
|
169 |
} |
|
170 |
|
|
171 |
} |
|
172 |
} |
|
173 |
items.add(dbTableDTO); |
|
174 |
} |
|
175 |
return items; |
|
176 |
} |
|
177 | 197 |
|
178 | 198 |
@Override |
179 | 199 |
public CdmSQLContainer getSQLContainer() throws SQLException{ |
... | ... | |
185 | 205 |
} |
186 | 206 |
|
187 | 207 |
@Override |
188 |
public LazyLoadedContainer getLazyLoadedContainer(){ |
|
189 |
LazyLoadedContainer lz = new LazyLoadedContainer(CdmTaxonTableCollection.class); |
|
190 |
lz.addListener(this); |
|
191 |
return lz; |
|
208 |
public void createDistributionField(final Taxon taxon, Object comboboxValue, String area) { |
|
209 |
Set<DefinedTermBase> chosenTerms = getChosenTerms(); |
|
210 |
NamedArea nArea = null; |
|
211 |
for(DefinedTermBase dt:chosenTerms){ |
|
212 |
if(dt.getTitleCache().equalsIgnoreCase(area)){ |
|
213 |
nArea = (NamedArea) dt; |
|
214 |
break; |
|
215 |
} |
|
216 |
} |
|
217 |
Distribution db = Distribution.NewInstance(nArea, (PresenceAbsenceTerm) comboboxValue); |
|
218 |
Set<TaxonDescription> descriptions = taxon.getDescriptions(); |
|
219 |
if (descriptions != null) { |
|
220 |
for (TaxonDescription desc : descriptions) { |
|
221 |
// add to first taxon description |
|
222 |
desc.addElement(db); |
|
223 |
getDescriptionService().saveOrUpdate(desc); |
|
224 |
break; |
|
225 |
} |
|
226 |
} else {// there are no TaxonDescription yet. |
|
227 |
TaxonDescription td = TaxonDescription.NewInstance(taxon); |
|
228 |
td.addElement(db); |
|
229 |
taxon.addDescription(td); |
|
230 |
getTaxonService().saveOrUpdate(taxon); |
|
231 |
} |
|
232 |
} |
|
192 | 233 |
|
234 |
|
|
235 |
@Override |
|
236 |
public Container getPresenceAbsenceContainer(){ |
|
237 |
BeanItemContainer<PresenceAbsenceTerm> termContainer = new BeanItemContainer<PresenceAbsenceTerm>(PresenceAbsenceTerm.class); |
|
238 |
termContainer.addAll(getPresenceAbsenceTerms()); |
|
239 |
return termContainer; |
|
193 | 240 |
} |
194 | 241 |
|
195 | 242 |
|
... | ... | |
210 | 257 |
"elements.media", |
211 | 258 |
"elements.multilanguageText", |
212 | 259 |
"multilanguageText", |
213 |
"stateData.$" |
|
260 |
"stateData.$", |
|
261 |
"annotations", |
|
262 |
"markers", |
|
263 |
"sources.citation.authorship", |
|
264 |
"sources.nameUsedInSource", |
|
265 |
"multilanguageText", |
|
266 |
"media", |
|
267 |
"name.$", |
|
268 |
"name.rank.representations", |
|
269 |
"name.status.type.representations", |
|
270 |
"taxon2.name" |
|
214 | 271 |
}); |
215 | 272 |
|
216 | 273 |
|
... | ... | |
257 | 314 |
} |
258 | 315 |
|
259 | 316 |
|
317 |
/**Helper Methods*/ |
|
318 |
|
|
319 |
private void sort(List<DescriptionElementBase> list){ |
|
320 |
Collections.sort(list, new Comparator<DescriptionElementBase>() { |
|
321 |
|
|
322 |
@Override |
|
323 |
public int compare(DescriptionElementBase o1, DescriptionElementBase o2) { |
|
324 |
String feature1 = o1.getFeature().getTitleCache(); |
|
325 |
String feature2 = o2.getFeature().getTitleCache(); |
|
326 |
if(feature1 !=null && feature2 !=null){ |
|
327 |
return feature1.compareTo(feature2); |
|
328 |
}else{ |
|
329 |
return 0; |
|
330 |
|
|
331 |
} |
|
332 |
} |
|
333 |
}); |
|
334 |
|
|
335 |
} |
|
260 | 336 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/settings/SettingsPresenter.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2015 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.cdm.vaadin.presenter.dbstatus.settings; |
|
11 |
|
|
12 |
import java.util.Arrays; |
|
13 |
import java.util.List; |
|
14 |
import java.util.UUID; |
|
15 |
|
|
16 |
import com.vaadin.data.Container; |
|
17 |
import com.vaadin.data.util.IndexedContainer; |
|
18 |
import com.vaadin.server.VaadinSession; |
|
19 |
|
|
20 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
|
21 |
import eu.etaxonomy.cdm.api.service.ITermService; |
|
22 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
|
23 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|
24 |
import eu.etaxonomy.cdm.model.common.TermType; |
|
25 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|
26 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
|
27 |
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper; |
|
28 |
|
|
29 |
/** |
|
30 |
* @author alex |
|
31 |
* @date 22.04.2015 |
|
32 |
* |
|
33 |
*/ |
|
34 |
public class SettingsPresenter { |
|
35 |
|
|
36 |
private Container classificationContainer; |
|
37 |
private Container distributionContainer; |
|
38 |
private Container distributionStatusContainer; |
|
39 |
private IVocabularyService vocabularyService; |
|
40 |
private ITermService termService; |
|
41 |
private IClassificationService classificationService; |
|
42 |
private UUID clUUID; |
|
43 |
private UUID termUUID; |
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
public SettingsPresenter(){ |
|
48 |
init(); |
|
49 |
|
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* |
|
54 |
*/ |
|
55 |
private void init() { |
|
56 |
clUUID = UUID.fromString(VaadinSession.getCurrent().getAttribute("classificationUUID").toString()); |
|
57 |
termUUID = UUID.fromString(VaadinSession.getCurrent().getAttribute("selectedTerm").toString()); |
|
58 |
classificationContainer = new IndexedContainer(getClassificationList()); |
|
59 |
distributionContainer = new IndexedContainer(getNamedAreaList()); |
|
60 |
distributionStatusContainer = new IndexedContainer(getPresenceAbsenceVocabulary()); |
|
61 |
} |
|
62 |
|
|
63 |
public Classification getChosenClassification(){ |
|
64 |
return classificationService.load(clUUID); |
|
65 |
} |
|
66 |
|
|
67 |
public TermVocabulary getChosenArea(){ |
|
68 |
return vocabularyService.load(termUUID); |
|
69 |
} |
|
70 |
|
|
71 |
public Container getClassificationContainer() { |
|
72 |
return classificationContainer; |
|
73 |
} |
|
74 |
public void setClassificationContainer(Container classificationContainer) { |
|
75 |
this.classificationContainer = classificationContainer; |
|
76 |
} |
|
77 |
public Container getDistributionContainer() { |
|
78 |
return distributionContainer; |
|
79 |
} |
|
80 |
public void setDistributionContainer(Container distributionContainer) { |
|
81 |
this.distributionContainer = distributionContainer; |
|
82 |
} |
|
83 |
public Container getDistributionStatusContainer() { |
|
84 |
return distributionStatusContainer; |
|
85 |
} |
|
86 |
public void setDistributionStatusContainer(Container distributionStatusContainer) { |
|
87 |
this.distributionStatusContainer = distributionStatusContainer; |
|
88 |
} |
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
private List<Classification> getClassificationList() { |
|
93 |
classificationService = CdmSpringContextHelper.getClassificationService(); |
|
94 |
List<Classification> classificationList = classificationService.listClassifications(null, null, null, NODE_INIT_STRATEGY()); |
|
95 |
return classificationList; |
|
96 |
} |
|
97 |
|
|
98 |
|
|
99 |
private List<TermVocabulary<DefinedTermBase>> getNamedAreaList() { |
|
100 |
|
|
101 |
vocabularyService = CdmSpringContextHelper.getVocabularyService(); |
|
102 |
List<TermVocabulary<DefinedTermBase>> termList = vocabularyService.findByTermType(TermType.NamedArea); |
|
103 |
return termList; |
|
104 |
} |
|
105 |
private List<DefinedTermBase<?>> getPresenceAbsenceVocabulary(){ |
|
106 |
termService = CdmSpringContextHelper.getTermService(); |
|
107 |
return termService.listByTermType(TermType.PresenceAbsenceTerm, null, null, null, DESCRIPTION_INIT_STRATEGY); |
|
108 |
} |
|
109 |
|
|
110 |
private List<String> NODE_INIT_STRATEGY(){ |
|
111 |
return Arrays.asList(new String[]{ |
|
112 |
"taxon.sec", |
|
113 |
"taxon.name", |
|
114 |
"classification" |
|
115 |
});} |
|
116 |
|
|
117 |
protected static final List<String> DESCRIPTION_INIT_STRATEGY = Arrays.asList(new String []{ |
|
118 |
"$", |
|
119 |
"elements.*", |
|
120 |
"elements.sources.citation.authorship.$", |
|
121 |
"elements.sources.nameUsedInSource.originalNameString", |
|
122 |
"elements.area.level", |
|
123 |
"elements.modifyingText", |
|
124 |
"elements.states.*", |
|
125 |
"elements.media", |
|
126 |
"elements.multilanguageText", |
|
127 |
"multilanguageText", |
|
128 |
"stateData.$", |
|
129 |
"annotations", |
|
130 |
"markers", |
|
131 |
"sources.citation.authorship", |
|
132 |
"sources.nameUsedInSource", |
|
133 |
"multilanguageText", |
|
134 |
"media", |
|
135 |
"name.$", |
|
136 |
"name.rank.representations", |
|
137 |
"name.status.type.representations", |
|
138 |
"taxon2.name" |
|
139 |
}); |
|
140 |
|
|
141 |
|
|
142 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/util/CdmQueryFactory.java | ||
---|---|---|
66 | 66 |
String SELECT_QUERY= |
67 | 67 |
"SELECT tb.DTYPE," + |
68 | 68 |
"tb.id, " + |
69 |
"tb.uuid, " + |
|
69 | 70 |
"tn.classification_id, " + |
70 | 71 |
"tb.titleCache AS Taxon, " + |
71 |
"dtb2.titleCache AS Rank, " + |
|
72 |
"deb.DTYPE," + |
|
73 |
"deb.id, " + |
|
74 |
"deb.area_id, "+ |
|
75 |
"dtb.vocabulary_id, " + |
|
76 |
"dtb1.vocabulary_id, "; |
|
72 |
"dtb2.titleCache AS Rank, "; |
|
73 |
|
|
77 | 74 |
int count = termList.size(); |
78 | 75 |
for(String term : termList){ |
79 | 76 |
if(count == 1){ |
... | ... | |
87 | 84 |
} |
88 | 85 |
SELECT_QUERY= SELECT_QUERY + FROM_QUERY + GROUP_BY; |
89 | 86 |
String COUNT_QUERY = "SELECT count(DISTINCT tb.id)" + FROM_QUERY; |
90 |
String CONTAINS_QUERY = "SELECT * FROM TaxonNode tn WHERE tn.id = ?"; |
|
87 |
// String CONTAINS_QUERY = "SELECT * FROM TaxonNode tn WHERE tn.id = ?"; |
|
88 |
String CONTAINS_QUERY = "SELECT * FROM TaxonBase tb WHERE tb.uuid = ?"; |
|
91 | 89 |
|
92 | 90 |
return generateQueryDelegate(SELECT_QUERY, COUNT_QUERY, CONTAINS_QUERY); |
93 | 91 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionTableView.java | ||
---|---|---|
3 | 3 |
import java.sql.SQLException; |
4 | 4 |
import java.util.ArrayList; |
5 | 5 |
import java.util.Arrays; |
6 |
import java.util.HashMap; |
|
7 | 6 |
import java.util.HashSet; |
8 | 7 |
import java.util.List; |
9 |
import java.util.Map; |
|
10 |
import java.util.Set; |
|
8 |
import java.util.UUID; |
|
11 | 9 |
|
12 | 10 |
import com.vaadin.annotations.AutoGenerated; |
13 | 11 |
import com.vaadin.data.Container; |
12 |
import com.vaadin.data.Item; |
|
14 | 13 |
import com.vaadin.data.Property; |
14 |
import com.vaadin.data.Property.ValueChangeEvent; |
|
15 | 15 |
import com.vaadin.data.Property.ValueChangeListener; |
16 |
import com.vaadin.data.util.BeanItemContainer; |
|
16 |
import com.vaadin.event.ItemClickEvent; |
|
17 |
import com.vaadin.event.ItemClickEvent.ItemClickListener; |
|
17 | 18 |
import com.vaadin.event.ShortcutAction.KeyCode; |
18 | 19 |
import com.vaadin.event.ShortcutAction.ModifierKey; |
19 | 20 |
import com.vaadin.navigator.View; |
... | ... | |
24 | 25 |
import com.vaadin.ui.Button.ClickEvent; |
25 | 26 |
import com.vaadin.ui.Button.ClickListener; |
26 | 27 |
import com.vaadin.ui.ComboBox; |
28 |
import com.vaadin.ui.Component; |
|
27 | 29 |
import com.vaadin.ui.CustomComponent; |
28 |
import com.vaadin.ui.DefaultFieldFactory; |
|
29 | 30 |
import com.vaadin.ui.Field; |
30 |
import com.vaadin.ui.Label; |
|
31 | 31 |
import com.vaadin.ui.Notification; |
32 |
import com.vaadin.ui.PopupView; |
|
33 |
import com.vaadin.ui.PopupView.PopupVisibilityEvent; |
|
34 |
import com.vaadin.ui.PopupView.PopupVisibilityListener; |
|
32 | 35 |
import com.vaadin.ui.Table; |
33 | 36 |
import com.vaadin.ui.Table.ColumnGenerator; |
37 |
import com.vaadin.ui.Window; |
|
34 | 38 |
|
35 | 39 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
36 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
37 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|
38 | 40 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
39 |
import eu.etaxonomy.cdm.model.description.Distribution; |
|
40 | 41 |
import eu.etaxonomy.cdm.model.description.Feature; |
41 | 42 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm; |
42 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
|
43 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
|
44 | 43 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
45 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
44 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
45 |
import eu.etaxonomy.cdm.vaadin.component.ConfigWindow; |
|
46 |
import eu.etaxonomy.cdm.vaadin.component.DetailWindow; |
|
46 | 47 |
import eu.etaxonomy.cdm.vaadin.component.HorizontalToolbar; |
47 | 48 |
import eu.etaxonomy.cdm.vaadin.container.CdmSQLContainer; |
48 | 49 |
|
49 |
public class DistributionTableView extends CustomComponent implements IDistributionTableComponent, View{ |
|
50 |
public class DistributionTableView<E> extends CustomComponent implements IDistributionTableComponent, View{
|
|
50 | 51 |
|
51 |
/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */ |
|
52 |
|
|
53 |
/** |
|
54 |
* |
|
55 |
*/ |
|
56 | 52 |
private static final long serialVersionUID = 1L; |
57 | 53 |
@AutoGenerated |
58 | 54 |
private AbsoluteLayout mainLayout; |
59 | 55 |
@AutoGenerated |
60 |
private Table table_1;
|
|
61 |
|
|
56 |
private Table table; |
|
57 |
|
|
62 | 58 |
private Taxon currentTaxon; |
63 |
|
|
59 |
|
|
60 |
private ArrayList<Object> propertyList = new ArrayList<Object>(); |
|
61 |
|
|
64 | 62 |
private DistributionTableComponentListener listener; |
65 |
|
|
66 |
ArrayList<String> columnList; |
|
63 |
|
|
64 |
protected List<Field> fields = new ArrayList<Field>(); |
|
65 |
|
|
66 |
List<String> columnList; |
|
67 | 67 |
ArrayList<String> headerList; |
68 | 68 |
private HorizontalToolbar toolbar; |
69 |
|
|
69 |
|
|
70 | 70 |
/** |
71 | 71 |
* The constructor should first build the main layout, set the |
72 | 72 |
* composition root and then do any custom initialization. |
... | ... | |
78 | 78 |
buildMainLayout(); |
79 | 79 |
setCompositionRoot(mainLayout); |
80 | 80 |
createEditClickListener(); |
81 |
|
|
81 |
|
|
82 | 82 |
} |
83 |
|
|
83 |
|
|
84 | 84 |
@Override |
85 | 85 |
public void addListener(DistributionTableComponentListener listener) { |
86 | 86 |
this.listener = listener; |
... | ... | |
100 | 100 |
//Horizontal Toolbar |
101 | 101 |
toolbar = new HorizontalToolbar(); |
102 | 102 |
mainLayout.addComponent(toolbar, "top:0.0px;right:0.0px;"); |
103 |
|
|
103 |
|
|
104 | 104 |
// table_1 |
105 |
table_1 = new Table();
|
|
106 |
table_1.setImmediate(false);
|
|
107 |
table_1.setWidth("100.0%");
|
|
108 |
table_1.setHeight("100.0%");
|
|
109 |
mainLayout.addComponent(table_1, "top:75px;right:0.0px;");
|
|
105 |
table = new Table(); |
|
106 |
table.setImmediate(false); |
|
107 |
table.setWidth("100.0%"); |
|
108 |
table.setHeight("100.0%"); |
|
109 |
mainLayout.addComponent(table, "top:75px;right:0.0px;"); |
|
110 | 110 |
|
111 | 111 |
return mainLayout; |
112 | 112 |
} |
... | ... | |
121 | 121 |
} |
122 | 122 |
|
123 | 123 |
|
124 |
|
|
125 |
public void dataBinding() throws SQLException{ |
|
126 | 124 |
|
127 |
// container.addNestedContainerProperty("dDTO.status"); |
|
128 |
// final LazyLoadedContainer container = listener.getLazyLoadedContainer(); |
|
129 |
// Set<DefinedTermBase> chosenTerms = listener.getChosenTerms(); |
|
130 |
// generateDsitributionColumn(chosenTerms); |
|
131 |
|
|
125 |
public void dataBinding() throws SQLException{ |
|
132 | 126 |
CdmSQLContainer container = listener.getSQLContainer(); |
133 |
|
|
134 |
table_1.setContainerDataSource(container); |
|
135 |
table_1.setColumnReorderingAllowed(true); |
|
136 |
table_1.setSortEnabled(true); |
|
137 |
// setVisibleColumns(columns); |
|
138 |
// Object[] visibleColumns = columnList.toArray(); |
|
139 |
// table_1.setVisibleColumns(visibleColumns); |
|
140 |
// table_1.setColumnHeaders(headerList.toArray(new String[headerList.size()]));//new String[]{"Taxon", "Rang"});// ,"Deutschland" |
|
141 |
|
|
142 |
table_1.setColumnCollapsingAllowed(true); |
|
143 |
table_1.setSelectable(true); |
|
144 |
// table_1.setSizeUndefined(); |
|
145 |
// setSizeFull(); |
|
146 |
table_1.setPageLength(20); |
|
147 |
table_1.setFooterVisible(true); |
|
148 |
table_1.setColumnFooter("Taxon", "Total amount of Taxa displayed: " + container.size()); |
|
149 |
|
|
150 |
table_1.setCacheRate(10); |
|
151 |
} |
|
152 |
|
|
153 |
|
|
154 |
void generateDsitributionColumn(Set<DefinedTermBase> terms){ |
|
155 |
columnList = new ArrayList<String>(Arrays.asList(new String[]{"fullTitleCache","rank"})); |
|
127 |
|
|
128 |
table.setContainerDataSource(container); |
|
129 |
table.setColumnReorderingAllowed(true); |
|
130 |
table.setSortEnabled(true); |
|
131 |
|
|
132 |
columnList = new ArrayList<String>(Arrays.asList(new String[]{"Taxon","Rank"})); |
|
133 |
columnList.addAll(listener.getTermList()); |
|
134 |
Object[] visibleColumns = columnList.toArray(); |
|
135 |
table.setVisibleColumns(visibleColumns); |
|
136 |
|
|
156 | 137 |
headerList = new ArrayList<String>(Arrays.asList(new String[]{"Taxon","Rang"})); |
157 |
for(final DefinedTermBase dt : terms){ |
|
158 |
columnList.add(dt.getTitleCache()); |
|
159 |
headerList.add(dt.getTitleCache()); |
|
160 |
// container.addContainerProperty(dt.getTitleCache(), String.class, null); |
|
161 |
|
|
162 |
table_1.addContainerProperty(dt.getTitleCache(), String.class, null); |
|
163 |
try{ |
|
164 |
table_1.addGeneratedColumn(dt.getTitleCache(), new ColumnGenerator() { |
|
165 |
public Object generateCell(Table source, Object itemId, Object columnId) { |
|
166 |
Label tf = new Label(); |
|
167 |
ComboBox box = null; |
|
168 |
if(itemId instanceof TaxonNode){ |
|
169 |
TaxonNode tn = CdmBase.deproxy((TaxonNode) itemId, TaxonNode.class); |
|
170 |
Taxon taxon = CdmBase.deproxy(tn.getTaxon(), Taxon.class); |
|
171 |
taxon = (Taxon) listener.getTaxonService().load(taxon.getUuid()); |
|
172 |
HashMap<DescriptionElementBase, Distribution> map = getDistribution(taxon); |
|
173 |
|
|
174 |
List<PresenceAbsenceTerm> listTerm = listener.getPresenceAbsenceTerms(); |
|
175 |
BeanItemContainer<PresenceAbsenceTerm> termContainer = new BeanItemContainer<PresenceAbsenceTerm>(PresenceAbsenceTerm.class); |
|
176 |
termContainer.addAll(listTerm); |
|
177 |
box = new ComboBox("Occurrence Status: ", termContainer); |
|
178 |
box.setImmediate(true); |
|
179 |
|
|
180 |
if(map != null){ |
|
181 |
/** update field **/ |
|
182 |
DescriptionElementBase deb = null; |
|
183 |
Distribution db = null; |
|
184 |
for(Map.Entry<DescriptionElementBase, Distribution> entry : map.entrySet()){ |
|
185 |
deb = entry.getKey(); |
|
186 |
db = entry.getValue(); |
|
187 |
} |
|
188 |
if(table_1.isEditable()){ |
|
189 |
box = updateDistributionField(deb, db, termContainer, box, taxon); |
|
190 |
}else{ |
|
191 |
if(db.getStatus() != null){ |
|
192 |
tf.setValue(db.getStatus().toString()); |
|
193 |
}else{ |
|
194 |
//FIXME: case for delete? |
|
195 |
Notification.show("Possible Error for " +taxon.getTitleCache() + " for Distribution: " + db.getArea().getTitleCache(), Notification.Type.TRAY_NOTIFICATION); |
|
196 |
tf.setValue("-"); |
|
197 |
} |
|
198 |
} |
|
199 |
}else{ |
|
200 |
/** create distribution if it does not exist and set the status **/ |
|
201 |
if(table_1.isEditable()){ |
|
202 |
box = createDistributionField(taxon, termContainer, box); |
|
203 |
}else{ |
|
204 |
tf.setValue("-"); |
|
205 |
} |
|
206 |
} |
|
207 |
|
|
208 |
} |
|
209 |
|
|
210 |
if(table_1.isEditable()){ |
|
211 |
return box; |
|
212 |
}else{ |
|
213 |
return tf; |
|
214 |
} |
|
215 |
} |
|
138 |
headerList.addAll(listener.getAbbreviatedTermList()); |
|
139 |
// table.setColumnHeaders(headerList.toArray(new String[headerList.size()]));//new String[]{"Taxon", "Rang"});// ,"Deutschland" |
|
216 | 140 |
|
217 |
private ComboBox createDistributionField( |
|
218 |
final Taxon taxon, |
|
219 |
BeanItemContainer<PresenceAbsenceTerm> termContainer,ComboBox box) { |
|
220 |
final ComboBox box2 = box; |
|
221 |
box.addValueChangeListener(new ValueChangeListener() { |
|
222 |
|
|
223 |
@Override |
|
224 |
public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { |
|
225 |
NamedArea area = (NamedArea) dt; |
|
226 |
Distribution db = Distribution.NewInstance(area, (PresenceAbsenceTerm) box2.getValue()); |
|
227 |
Set<TaxonDescription> descriptions = taxon.getDescriptions(); |
|
228 |
if (descriptions != null) { |
|
229 |
for (TaxonDescription desc : descriptions) { |
|
230 |
// add to first taxon description |
|
231 |
desc.addElement(db); |
|
232 |
listener.getDescriptionService().saveOrUpdate(desc); |
|
233 |
break; |
|
234 |
} |
|
235 |
} else {// there are no TaxonDescription yet. |
|
236 |
TaxonDescription td = TaxonDescription.NewInstance(taxon); |
|
237 |
td.addElement(db); |
|
238 |
taxon.addDescription(td); |
|
239 |
listener.getTaxonService().saveOrUpdate(taxon); |
|
240 |
} |
|
241 |
} |
|
242 |
|
|
243 |
}); |
|
244 |
|
|
245 |
|
|
246 |
return box; |
|
247 |
} |
|
141 |
table.setColumnCollapsingAllowed(true); |
|
142 |
table.setSelectable(true); |
|
143 |
table.setPageLength(20); |
|
144 |
table.setFooterVisible(true); |
|
145 |
table.setColumnFooter("Taxon", "Total amount of Taxa displayed: " + container.size()); |
|
146 |
|
|
147 |
table.setCacheRate(20); |
|
148 |
} |
|
149 |
|
|
150 |
|
|
151 |
private void createEditClickListener(){ |
|
152 |
Button detailButton = toolbar.getDetailButton(); |
|
153 |
detailButton.setCaption("Detail View"); |
|
154 |
detailButton.addClickListener(new ClickListener() { |
|
248 | 155 |
|
249 |
private HashMap<DescriptionElementBase, Distribution> getDistribution(Taxon taxon){ |
|
250 |
Set<Feature> setFeature = new HashSet<Feature>(Arrays.asList(Feature.DISTRIBUTION())); |
|
251 |
List<DescriptionElementBase> listTaxonDescription = listener.listDescriptionElementsForTaxon(taxon, setFeature); |
|
252 |
for(DescriptionElementBase deb : listTaxonDescription){ |
|
253 |
if(deb instanceof Distribution){ |
|
254 |
Distribution db = (Distribution)deb; |
|
255 |
String titleCache = dt.getTitleCache(); |
|
256 |
if(db.getArea().getTitleCache().equalsIgnoreCase(titleCache)){ |
|
257 |
HashMap<DescriptionElementBase, Distribution> map = new HashMap<DescriptionElementBase, Distribution>(); |
|
258 |
map.put(deb, db); |
|
259 |
return map; |
|
260 |
} |
|
261 |
} |
|
262 |
} |
|
263 |
return null; |
|
264 |
} |
|
265 |
|
|
266 |
private ComboBox updateDistributionField(DescriptionElementBase deb, Distribution db, BeanItemContainer<PresenceAbsenceTerm> termContainer, ComboBox box, Taxon taxon) { |
|
267 |
final Distribution db2 = db; |
|
268 |
final DescriptionElementBase deb2 = deb; |
|
269 |
box.setValue(db.getStatus()); |
|
270 |
final ComboBox box2 = box; |
|
271 |
final Taxon taxon2 = taxon; |
|
272 |
box.addValueChangeListener(new ValueChangeListener() { |
|
273 |
|
|
274 |
private static final long serialVersionUID = 1L; |
|
275 |
|
|
276 |
@Override |
|
277 |
public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { |
|
278 |
if(box2.getValue() == null){//delete descriptionElementBase |
|
279 |
listener.getDescriptionService().deleteDescriptionElement(deb2); |
|
280 |
listener.getTaxonService().saveOrUpdate(taxon2); |
|
281 |
Notification.show("Delete Status", Notification.Type.TRAY_NOTIFICATION); |
|
282 |
}else{ |
|
283 |
db2.setStatus((PresenceAbsenceTerm)box2.getValue()); |
|
284 |
listener.getDescriptionService().saveDescriptionElement(deb2); |
|
285 |
Notification.show("DescriptionService wrote", Notification.Type.TRAY_NOTIFICATION); |
|
286 |
} |
|
287 |
} |
|
288 |
}); |
|
289 |
return box; |
|
290 |
} |
|
291 |
}); |
|
292 |
}catch(IllegalArgumentException e){ |
|
293 |
e.printStackTrace(); |
|
294 |
} |
|
295 |
} |
|
296 |
} |
|
297 |
|
|
298 |
private DefaultFieldFactory createDefaulfielFactory() { |
|
299 |
DefaultFieldFactory fieldFactory = new DefaultFieldFactory() { |
|
300 |
private static final long serialVersionUID = 1L; |
|
301 | 156 |
@Override |
302 |
public Field createField(Container container, Object itemId, |
|
303 |
Object propertyId, com.vaadin.ui.Component uiContext) { |
|
304 |
Property containerProperty = container.getContainerProperty(itemId, propertyId); |
|
305 |
if("fullTitleCache".equals(propertyId)){ |
|
306 |
return null; |
|
157 |
public void buttonClick(ClickEvent event) { |
|
158 |
try{ |
|
159 |
HashSet<Feature> featureSet = new HashSet<Feature>(Arrays.asList(Feature.DESCRIPTION(), Feature.DISTRIBUTION())); |
|
160 |
if(currentTaxon != null){ |
|
161 |
List<DescriptionElementBase> listDescriptions = listener.listDescriptionElementsForTaxon(currentTaxon, null); |
|
162 |
DetailWindow dw = new DetailWindow(currentTaxon, listDescriptions); |
|
163 |
Window window = dw.createWindow(); |
|
164 |
getUI().addWindow(window); |
|
165 |
}else{ |
|
166 |
Notification.show("Please select a Taxon.", Notification.Type.HUMANIZED_MESSAGE); |
|
307 | 167 |
} |
308 |
if("rank".equals(propertyId)){
|
|
309 |
return null;
|
|
168 |
}catch(Exception e){
|
|
169 |
Notification.show("Unexpected Error, \n\n Please log in again!", Notification.Type.WARNING_MESSAGE);
|
|
310 | 170 |
} |
311 |
// if("Berlin".equals(propertyId)){ |
|
312 |
// List<PresenceAbsenceTermBase> listTerm = termService.list(PresenceAbsenceTermBase.class, null, null, null, DESCRIPTION_INIT_STRATEGY); |
|
313 |
// BeanItemContainer<PresenceAbsenceTermBase> termContainer = new BeanItemContainer<PresenceAbsenceTermBase>(PresenceAbsenceTermBase.class); |
|
314 |
// termContainer.addAll(listTerm); |
|
315 |
// final ComboBox box = new ComboBox("Occurrence Status: ", termContainer); |
|
316 |
// Item item = container.getItem(itemId); |
|
317 |
// box.setValue(item); |
|
318 |
// toolbar.getSaveButton().setCaption("Save Data *"); |
|
319 |
// return box; |
|
320 |
// } |
|
321 |
return super.createField(container, itemId, propertyId, uiContext); |
|
322 | 171 |
} |
323 |
}; |
|
324 |
return fieldFactory; |
|
325 |
} |
|
326 |
|
|
172 |
}); |
|
327 | 173 |
|
328 |
private void createEditClickListener(){ |
|
329 |
// Button detailButton = toolbar.getDetailButton(); |
|
330 |
// detailButton.setCaption("Detail View"); |
|
331 |
// detailButton.addClickListener(new ClickListener() { |
|
332 |
// |
|
333 |
// @Override |
|
334 |
// public void buttonClick(ClickEvent event) { |
|
335 |
// try{ |
|
336 |
// if(currentTaxon != null){ |
|
337 |
// List<DescriptionElementBase> listDescriptions = descriptionService.listDescriptionElementsForTaxon(currentTaxon, null, null, null, null, DESCRIPTION_INIT_STRATEGY); |
|
338 |
// DetailWindow dw = new DetailWindow(currentTaxon, listDescriptions); |
|
339 |
// Window window = dw.createWindow(); |
|
340 |
// getUI().addWindow(window); |
|
341 |
// }else{ |
|
342 |
// Notification.show("Please select a Taxon.", Notification.Type.HUMANIZED_MESSAGE); |
|
343 |
// } |
|
344 |
// }catch(Exception e){ |
|
345 |
// Notification.show("Unexpected Error, \n\n Please log in again!", Notification.Type.WARNING_MESSAGE); |
|
346 |
// logger.info(e); |
|
347 |
// authenticationController.logout(); |
|
348 |
// } |
|
349 |
// } |
|
350 |
// }); |
|
174 |
Button settingsButton = toolbar.getSettingsButton(); |
|
175 |
settingsButton.addClickListener(new ClickListener() { |
|
351 | 176 |
|
177 |
@Override |
|
178 |
public void buttonClick(ClickEvent event) { |
|
179 |
ConfigWindow cw = new ConfigWindow(); |
|
180 |
Window window = cw.createWindow(); |
|
181 |
getUI().addWindow(window); |
|
182 |
} |
|
183 |
}); |
|
352 | 184 |
|
353 | 185 |
Button saveButton = toolbar.getSaveButton(); |
354 | 186 |
saveButton.setClickShortcut(KeyCode.S, ModifierKey.CTRL); |
... | ... | |
364 | 196 |
}catch(Exception stateException){ |
365 | 197 |
//TODO create Table without DTO |
366 | 198 |
} |
199 |
if(propertyList != null){ |
|
200 |
for(Object propertyId:propertyList){ |
|
201 |
table.removeGeneratedColumn(propertyId); |
|
202 |
} |
|
203 |
redrawTable(); |
|
204 |
} |
|
367 | 205 |
Notification.show("Data saved", Notification.Type.HUMANIZED_MESSAGE); |
368 |
table_1.setEditable(false); |
|
206 |
propertyList = null; |
|
207 |
propertyList = new ArrayList<Object>(); |
|
208 |
table.setEditable(false); |
|
369 | 209 |
toolbar.getSaveButton().setCaption("Save Data"); |
370 | 210 |
} |
371 | 211 |
}); |
372 | 212 |
|
373 |
Button editButton = toolbar.getEditButton(); |
|
374 |
editButton.setClickShortcut(KeyCode.E, ModifierKey.CTRL); |
|
375 |
editButton.setDescription("Shortcut: CTRL+e"); |
|
376 |
editButton.addClickListener(new ClickListener() { |
|
377 |
private static final long serialVersionUID = 1L; |
|
378 | 213 |
|
379 |
@Override |
|
380 |
public void buttonClick(ClickEvent event) { |
|
381 |
if(table_1.isEditable() == false){ |
|
382 |
table_1.setEditable(true); |
|
383 |
// taxonTable.removeGeneratedColumn("Berlin"); |
|
384 |
// taxonTable.refreshRowCache(); |
|
385 |
}else{ |
|
386 |
table_1.setEditable(false); |
|
387 |
table_1.refreshRowCache(); |
|
388 |
} |
|
389 |
} |
|
390 |
}); |
|
214 |
//FIXME: Due lack of time needs to be properly done |
|
391 | 215 |
|
392 |
//FIXME with new SQL CONTAINER |
|
393 |
// table_1.addItemClickListener(new ItemClickListener() { |
|
394 |
// |
|
216 |
// Button editButton = toolbar.getEditButton(); |
|
217 |
// editButton.setClickShortcut(KeyCode.E, ModifierKey.CTRL); |
|
218 |
// editButton.setDescription("Shortcut: CTRL+e"); |
|
219 |
// editButton.addClickListener(new ClickListener() { |
|
220 |
// private static final long serialVersionUID = 1L; |
|
395 | 221 |
// @Override |
396 |
// public void itemClick(ItemClickEvent event) { |
|
397 |
// Object taxonbean = ((BeanItem<?>)event.getItem()).getBean(); |
|
398 |
// if(taxonbean instanceof CdmTaxonTableCollection){ |
|
399 |
// CdmTaxonTableCollection red = (CdmTaxonTableCollection) taxonbean; |
|
400 |
// currentTaxon = red.getTaxon(); |
|
401 |
// } |
|
222 |
// public void buttonClick(ClickEvent event) { |
|
223 |
// // if(table.isEditable() == false){ |
|
224 |
// // table.setEditable(true); |
|
225 |
// for(Object prop:table.getContainerPropertyIds()){ |
|
226 |
// if(!prop.equals("Taxon")&&!prop.equals("Rank")){ |
|
227 |
// table.addGeneratedColumn(prop, createTableColumnGenerator()); |
|
228 |
// } |
|
229 |
// } |
|
230 |
//// }//else{ |
|
231 |
//// table.setEditable(false); |
|
232 |
//// table.refreshRowCache(); |
|
233 |
//// } |
|
402 | 234 |
// } |
403 | 235 |
// }); |
236 |
|
|
237 |
/**Double Click listener for Table*/ |
|
238 |
table.addItemClickListener(new ItemClickListener() { |
|
239 |
private static final long serialVersionUID = 1L; |
|
240 |
|
|
241 |
@Override |
|
242 |
public void itemClick(ItemClickEvent event) { |
|
243 |
TaxonBase taxonBase = loadTaxonFromSelection(event); |
|
244 |
currentTaxon = (Taxon)taxonBase; |
|
245 |
if(event.isDoubleClick()){ |
|
246 |
if(!(event.getPropertyId().toString().equalsIgnoreCase("Taxon")) && !(event.getPropertyId().toString().equalsIgnoreCase("Rank"))){ |
|
247 |
if(!table.removeGeneratedColumn(event.getPropertyId())){ |
|
248 |
table.addGeneratedColumn(event.getPropertyId(), createTableColumnGenerator()); |
|
249 |
propertyList.add(event.getPropertyId()); |
|
250 |
}else{ |
|
251 |
table.removeGeneratedColumn(event.getPropertyId()); |
|
252 |
propertyList.remove(event.getPropertyId()); |
|
253 |
redrawTable(); |
|
254 |
} |
|
255 |
} |
|
256 |
} |
|
257 |
} |
|
258 |
}); |
|
259 |
} |
|
260 |
|
|
261 |
private TaxonBase loadTaxonFromSelection(ItemClickEvent event) { |
|
262 |
Item item = event.getItem(); |
|
263 |
Property itemProperty = item.getItemProperty("uuid"); |
|
264 |
UUID uuid = UUID.fromString(itemProperty.getValue().toString()); |
|
265 |
TaxonBase taxonBase = listener.getTaxonService().load(uuid); |
|
266 |
return taxonBase; |
|
267 |
} |
|
268 |
|
|
269 |
private String refreshValue(ComboBox box, Object value){ |
|
270 |
if(box.getValue() == null){ |
|
271 |
if(value != null){ |
|
272 |
return value.toString(); |
|
273 |
}else{ |
|
274 |
return "click me for new Distribution Status"; |
|
275 |
} |
|
276 |
}else{ |
|
277 |
return box.getValue().toString(); |
|
278 |
} |
|
404 | 279 |
} |
405 | 280 |
|
281 |
private ColumnGenerator createTableColumnGenerator(){ |
|
282 |
|
|
283 |
ColumnGenerator generator = new ColumnGenerator() { |
|
284 |
|
|
285 |
private static final long serialVersionUID = 1L; |
|
286 |
|
|
287 |
@Override |
|
288 |
public Object generateCell(Table source, Object itemId, Object columnId) { |
|
289 |
Property containerProperty = source.getContainerProperty(itemId, columnId); |
|
290 |
Object item = itemId; |
|
291 |
final Object value = containerProperty.getValue(); |
|
292 |
Container containerDataSource = source.getContainerDataSource(); |
|
293 |
final UUID uuid = UUID.fromString(table.getItem(itemId).getItemProperty("uuid").getValue().toString()); |
|
294 |
final ComboBox box = new ComboBox("Occurrence Status: ", listener.getPresenceAbsenceContainer()); |
|
295 |
final String area = columnId.toString(); |
|
296 |
box.setImmediate(true); |
|
297 |
box.addValueChangeListener(new ValueChangeListener() { |
|
298 |
@Override |
|
299 |
public void valueChange(ValueChangeEvent event) { |
|
300 |
Taxon taxon = (Taxon)listener.getTaxonService().load(uuid); |
|
301 |
if(value==null){ |
|
302 |
listener.createDistributionField(taxon, box.getValue(), area); |
|
303 |
Notification.show("Create Status", Notification.Type.TRAY_NOTIFICATION); |
|
304 |
}else{ |
|
305 |
int result = listener.updateDistributionField(area, box.getValue(), taxon); |
|
306 |
if(result == 1){ |
|
307 |
Notification.show("Delete Status", Notification.Type.TRAY_NOTIFICATION); |
|
308 |
}else if(result == 0){ |
|
309 |
Notification.show("DescriptionService wrote", Notification.Type.TRAY_NOTIFICATION); |
|
310 |
} |
|
311 |
} |
|
312 |
} |
|
313 |
}); |
|
314 |
final PopupView popup = new PopupView(new PopupView.Content() { |
|
315 |
private static final long serialVersionUID = 1L; |
|
316 |
@Override |
|
317 |
public String getMinimizedValueAsHTML() { |
|
318 |
return refreshValue(box, value); |
|
319 |
} |
|
320 |
@Override |
|
321 |
public Component getPopupComponent() { |
|
322 |
//FIXME: find a better solution |
|
323 |
box.setValue(compareObjectToPAT(value)); |
|
324 |
box.setBuffered(true); |
|
325 |
return box; |
|
326 |
} |
|
327 |
}); |
|
328 |
popup.addPopupVisibilityListener(new PopupVisibilityListener() { |
|
329 |
|
|
330 |
@Override |
|
331 |
public void popupVisibilityChange(PopupVisibilityEvent event) { |
|
332 |
|
|
333 |
} |
|
334 |
}); |
|
335 |
popup.setHideOnMouseOut(true); |
|
336 |
return popup; |
|
337 |
} |
|
338 |
}; |
|
339 |
return generator; |
|
340 |
} |
|
341 |
|
|
342 |
private PresenceAbsenceTerm compareObjectToPAT(Object object){ |
|
343 |
List<PresenceAbsenceTerm> presenceAbsenceTerms = listener.getPresenceAbsenceTerms(); |
|
344 |
for(PresenceAbsenceTerm term:presenceAbsenceTerms){ |
|
345 |
if(term.getTitleCache().equals(object)){ |
|
346 |
return term; |
|
347 |
} |
|
348 |
} |
|
349 |
return null; |
|
350 |
} |
|
351 |
|
|
352 |
private void redrawTable(){ |
|
353 |
try { |
|
354 |
CdmSQLContainer sqlContainer = listener.getSQLContainer(); |
|
355 |
sqlContainer.refresh(); |
|
356 |
table.setContainerDataSource(sqlContainer); |
|
357 |
table.setVisibleColumns(columnList.toArray()); |
|
358 |
} catch (SQLException e) { |
|
359 |
e.printStackTrace(); |
|
360 |
} |
|
361 |
} |
|
362 |
|
|
363 |
|
|
406 | 364 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/IDistributionTableComponent.java | ||
---|---|---|
5 | 5 |
import java.util.List; |
6 | 6 |
import java.util.Set; |
7 | 7 |
|
8 |
import com.vaadin.data.util.BeanItemContainer; |
|
9 |
import com.vaadin.ui.ComboBox; |
|
8 |
import com.vaadin.data.Container; |
|
10 | 9 |
|
11 | 10 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
12 | 11 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
... | ... | |
23 | 22 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
Also available in: Unified diff
*added new config window
*added settings icon
*removed edit button from toolbar
*added double click listener
*added sql container and changed query
*added popupView for better editing
*saving back works properly