Revision aceb7b1d
Added by Cherian Mathew about 9 years ago
pom.xml | ||
---|---|---|
5 | 5 |
<groupId>eu.etaxonomy</groupId> |
6 | 6 |
<artifactId>cdm-vaadin</artifactId> |
7 | 7 |
<packaging>war</packaging> |
8 |
<version>3.5.0-SNAPSHOT</version>
|
|
8 |
<version>3.5.1-SNAPSHOT</version>
|
|
9 | 9 |
<name>Vaadin Web Application</name> |
10 | 10 |
|
11 | 11 |
<properties> |
src/main/java/eu/etaxonomy/cdm/vaadin/component/StatusComposite.java | ||
---|---|---|
43 | 43 |
import com.vaadin.ui.Table; |
44 | 44 |
import com.vaadin.ui.Table.ColumnHeaderMode; |
45 | 45 |
import com.vaadin.ui.TextField; |
46 |
import com.vaadin.ui.Tree.ExpandEvent; |
|
47 |
import com.vaadin.ui.Tree.ExpandListener; |
|
48 | 46 |
import com.vaadin.ui.TreeTable; |
49 | 47 |
import com.vaadin.ui.VerticalLayout; |
50 | 48 |
|
... | ... | |
89 | 87 |
private static final Logger logger = Logger.getLogger(StatusComposite.class); |
90 | 88 |
private StatusComponentListener listener; |
91 | 89 |
|
90 |
private Object currentClickedTaxonItemId; |
|
91 |
|
|
92 |
|
|
92 | 93 |
private static final String SELECT_FILTER = "Select filter ..."; |
93 | 94 |
private static final String SELECT_CLASSIFICATION = "Select classification ..."; |
94 | 95 |
private static final String ADD_TAXON_SYNONYM = "Add ..."; |
... | ... | |
115 | 116 |
buildMainLayout(); |
116 | 117 |
setCompositionRoot(mainLayout); |
117 | 118 |
|
118 |
searchHorizontalLayout.addLayoutClickListener(new LayoutClickListener() { |
|
119 |
|
|
120 |
@Override |
|
121 |
public void layoutClick(LayoutClickEvent event) { |
|
122 |
if (event.getChildComponent() == searchTextField && searchTextField.getValue().equals(FILTER_TAXA_INPUT)) { |
|
123 |
searchTextField.setValue(""); |
|
124 |
} |
|
125 |
} |
|
126 |
}); |
|
127 | 119 |
addUIListeners(); |
120 |
|
|
128 | 121 |
initAddComboBox(); |
129 | 122 |
initSearchTextField(); |
130 | 123 |
initClearSearchButton(); |
... | ... | |
146 | 139 |
clearSearchButton.setEnabled(enable); |
147 | 140 |
} |
148 | 141 |
|
142 |
|
|
143 |
|
|
144 |
|
|
149 | 145 |
private void initTaxaTable(int classificationId) { |
150 | 146 |
|
151 | 147 |
taxaTreeTable.setSelectable(true); |
... | ... | |
158 | 154 |
columnIds.add(LeafNodeTaxonContainer.PB_ID); |
159 | 155 |
taxaTreeTable.setColumnWidth(LeafNodeTaxonContainer.PB_ID, 25); |
160 | 156 |
|
161 |
ValueChangeListener pbListener = new ValueChangeListener() { |
|
162 |
@Override |
|
163 |
public void valueChange(ValueChangeEvent event) { |
|
164 |
boolean value = (Boolean) event.getProperty().getValue(); |
|
165 |
Notification.show("Changing Published Flag", "Implement me", Type.WARNING_MESSAGE); |
|
166 |
} |
|
167 | 157 |
|
168 |
}; |
|
169 |
taxaTreeTable.addGeneratedColumn(LeafNodeTaxonContainer.PB_ID, new BooleanCheckBoxGenerator(pbListener)); |
|
158 |
taxaTreeTable.addGeneratedColumn(LeafNodeTaxonContainer.PB_ID, new TaxonTableCheckBoxGenerator()); |
|
170 | 159 |
try { |
171 | 160 |
taxaTreeTable.setContainerDataSource(listener.loadTaxa(classificationId), columnIds); |
172 | 161 |
} catch (SQLException e) { |
... | ... | |
174 | 163 |
e.printStackTrace(); |
175 | 164 |
} |
176 | 165 |
|
177 |
taxaTreeTable.addExpandListener(new ExpandListener() { |
|
178 |
|
|
179 |
@Override |
|
180 |
public void nodeExpand(ExpandEvent event) { |
|
181 |
//listener.addChildren(event.getItemId()); |
|
182 |
} |
|
183 |
|
|
184 |
}); |
|
185 | 166 |
|
186 | 167 |
taxaTreeTable.setCellStyleGenerator(new Table.CellStyleGenerator() { |
187 | 168 |
|
... | ... | |
189 | 170 |
public String getStyle(Table source, Object itemId, Object propertyId) { |
190 | 171 |
Property hasSynProperty = source.getItem(itemId).getItemProperty(LeafNodeTaxonContainer.HAS_SYN_ID); |
191 | 172 |
if(hasSynProperty == null) { |
192 |
// this is a synonym |
|
173 |
// this is a synonym, so we activate the corresponding css class
|
|
193 | 174 |
return "synonym"; |
194 | 175 |
} |
195 | 176 |
return null; |
... | ... | |
295 | 276 |
} |
296 | 277 |
} |
297 | 278 |
|
279 |
|
|
298 | 280 |
}; |
299 |
filterTable.addGeneratedColumn(PROPERTY_SELECTED_ID, new BooleanCheckBoxGenerator(selectedListener));
|
|
281 |
filterTable.addGeneratedColumn(PROPERTY_SELECTED_ID, new CheckBoxGenerator(selectedListener)); |
|
300 | 282 |
|
301 | 283 |
} |
302 | 284 |
|
... | ... | |
320 | 302 |
} |
321 | 303 |
|
322 | 304 |
private void initClearSearchButton() { |
323 |
//ThemeResource resource = new ThemeResource("icons/32/cancel.png"); |
|
324 | 305 |
clearSearchButton.setIcon(FontAwesome.REFRESH); |
325 | 306 |
clearSearchButton.setCaption(""); |
326 | 307 |
} |
327 | 308 |
|
328 | 309 |
private void addUIListeners() { |
310 |
|
|
311 |
searchHorizontalLayout.addLayoutClickListener(new LayoutClickListener() { |
|
312 |
|
|
313 |
@Override |
|
314 |
public void layoutClick(LayoutClickEvent event) { |
|
315 |
if (event.getChildComponent() == searchTextField && searchTextField.getValue().equals(FILTER_TAXA_INPUT)) { |
|
316 |
searchTextField.setValue(""); |
|
317 |
} |
|
318 |
} |
|
319 |
}); |
|
320 |
|
|
329 | 321 |
addClassificationComboBoxListener(); |
330 | 322 |
addAddComboBoxListener(); |
331 | 323 |
addSearchTextFieldListener(); |
... | ... | |
410 | 402 |
} |
411 | 403 |
|
412 | 404 |
|
413 |
class BooleanCheckBoxGenerator implements Table.ColumnGenerator { |
|
405 |
class TaxonTableCheckBoxGenerator implements Table.ColumnGenerator { |
|
406 |
|
|
407 |
|
|
408 |
/** |
|
409 |
* Generates the cell containing an open image when boolean is true |
|
410 |
*/ |
|
411 |
@Override |
|
412 |
public Component generateCell(Table source, final Object itemId, Object columnId) { |
|
413 |
if(source.getItem(itemId) != null) { |
|
414 |
Property prop = source.getItem(itemId).getItemProperty(columnId); |
|
415 |
if(prop == null) { |
|
416 |
return null; |
|
417 |
} |
|
418 |
CheckBox cb = new CheckBox(null, prop); |
|
419 |
ValueChangeListener pbListener = new ValueChangeListener() { |
|
420 |
@Override |
|
421 |
public void valueChange(ValueChangeEvent event) { |
|
422 |
boolean value = (Boolean) event.getProperty().getValue(); |
|
423 |
listener.updatePublished(value, itemId); |
|
424 |
} |
|
425 |
}; |
|
426 |
cb.addValueChangeListener(pbListener); |
|
427 |
cb.setData(itemId); |
|
428 |
return cb; |
|
429 |
} else { |
|
430 |
return null; |
|
431 |
} |
|
432 |
|
|
433 |
} |
|
434 |
} |
|
435 |
|
|
436 |
class CheckBoxGenerator implements Table.ColumnGenerator { |
|
414 | 437 |
|
415 |
private final ValueChangeListener listener;
|
|
438 |
private final ValueChangeListener vcListener;
|
|
416 | 439 |
|
417 |
public BooleanCheckBoxGenerator(ValueChangeListener listener) {
|
|
418 |
this.listener = listener;
|
|
440 |
public CheckBoxGenerator(ValueChangeListener vcListener) {
|
|
441 |
this.vcListener = vcListener;
|
|
419 | 442 |
} |
420 | 443 |
|
421 | 444 |
/** |
422 | 445 |
* Generates the cell containing an open image when boolean is true |
423 | 446 |
*/ |
424 | 447 |
@Override |
425 |
public Component generateCell(Table source, Object itemId, Object columnId) { |
|
448 |
public Component generateCell(Table source, final Object itemId, Object columnId) {
|
|
426 | 449 |
if(source.getItem(itemId) != null) { |
427 | 450 |
Property prop = source.getItem(itemId).getItemProperty(columnId); |
428 | 451 |
if(prop == null) { |
429 | 452 |
return null; |
430 | 453 |
} |
431 | 454 |
CheckBox cb = new CheckBox(null, prop); |
432 |
cb.addValueChangeListener(listener);
|
|
455 |
cb.addValueChangeListener(vcListener);
|
|
433 | 456 |
cb.setData(itemId); |
434 | 457 |
return cb; |
435 | 458 |
} else { |
src/main/java/eu/etaxonomy/cdm/vaadin/container/LeafNodeTaxonContainer.java | ||
---|---|---|
40 | 40 |
private static final Logger logger = Logger.getLogger(LeafNodeTaxonContainer.class); |
41 | 41 |
|
42 | 42 |
public static final String ID = "Id"; |
43 |
public static final String UUID_ID = "Uuid"; |
|
43 | 44 |
public static final String NAME_ID = "Name"; |
44 | 45 |
public static final String ACCTAXON_ID = "AccTaxonId"; |
45 | 46 |
public static final String PB_ID = "Pb"; |
... | ... | |
67 | 68 |
* @throws SQLException |
68 | 69 |
*/ |
69 | 70 |
public LeafNodeTaxonContainer(int classificationId) throws SQLException { |
70 |
super(CdmQueryFactory.generateTaxonBaseQuery(ID, NAME_ID, PB_ID, UNP_ID, RANK_ID, HAS_SYN_ID)); |
|
71 |
super(CdmQueryFactory.generateTaxonBaseQuery(ID, UUID_ID,NAME_ID, PB_ID, UNP_ID, RANK_ID, HAS_SYN_ID));
|
|
71 | 72 |
this.synonymContainer = new CdmSQLContainer(CdmQueryFactory.generateSynonymofTaxonQuery(ID, NAME_ID)); |
72 | 73 |
this.classificationId = classificationId; |
73 | 74 |
taxonSynonymMap = new HashMap<Object,List<Object>>(); |
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/StatusPresenter.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.cdm.vaadin.presenter; |
11 | 11 |
|
12 | 12 |
import java.sql.SQLException; |
13 |
import java.util.UUID; |
|
13 | 14 |
|
14 | 15 |
import com.vaadin.data.util.sqlcontainer.query.generator.filter.QueryBuilder; |
15 | 16 |
|
17 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
|
18 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
19 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
16 | 20 |
import eu.etaxonomy.cdm.vaadin.container.CdmSQLContainer; |
17 | 21 |
import eu.etaxonomy.cdm.vaadin.container.LeafNodeTaxonContainer; |
18 | 22 |
import eu.etaxonomy.cdm.vaadin.util.CdmSQLStringDecorator; |
23 |
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper; |
|
19 | 24 |
import eu.etaxonomy.cdm.vaadin.view.IStatusComposite; |
20 | 25 |
import eu.etaxonomy.cdm.vaadin.view.IStatusComposite.StatusComponentListener; |
21 | 26 |
|
... | ... | |
30 | 35 |
|
31 | 36 |
private LeafNodeTaxonContainer container; |
32 | 37 |
|
33 |
|
|
38 |
private ITaxonService taxonService; |
|
34 | 39 |
|
35 | 40 |
private int totalNoOfTaxa = 0; |
36 | 41 |
|
... | ... | |
40 | 45 |
// TODO: Need to evaluate the various sql dialects and make sure that these |
41 | 46 |
// queries are compatible with all |
42 | 47 |
QueryBuilder.setStringDecorator(new CdmSQLStringDecorator()); |
48 |
|
|
49 |
initServices(); |
|
43 | 50 |
} |
44 | 51 |
|
52 |
private void initServices() { |
|
53 |
taxonService = CdmSpringContextHelper.getTaxonService(); |
|
54 |
} |
|
45 | 55 |
|
46 | 56 |
@Override |
47 | 57 |
public void removeFilters() { |
... | ... | |
119 | 129 |
} |
120 | 130 |
|
121 | 131 |
|
132 |
@Override |
|
133 |
public void updatePublished(boolean pb, Object itemId) { |
|
134 |
UUID uuid = UUID.fromString((String)container.getItem(itemId).getItemProperty(LeafNodeTaxonContainer.UUID_ID).getValue()); |
|
135 |
Taxon taxon = CdmBase.deproxy(taxonService.load(uuid), Taxon.class); |
|
136 |
boolean currentPb = taxon.isPublish(); |
|
137 |
if(currentPb != pb) { |
|
138 |
taxon.setPublish(pb); |
|
139 |
taxonService.merge(taxon); |
|
140 |
} |
|
141 |
} |
|
142 |
|
|
143 |
|
|
122 | 144 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/util/CdmQueryFactory.java | ||
---|---|---|
24 | 24 |
public class CdmQueryFactory { |
25 | 25 |
|
26 | 26 |
public static QueryDelegate generateTaxonBaseQuery(String id, |
27 |
String uuid_id, |
|
27 | 28 |
String name_id, |
28 | 29 |
String pb_id, |
29 | 30 |
String unp_id, |
... | ... | |
34 | 35 |
"INNER JOIN TaxonNameBase tnb on tb.name_id=tnb.id " + |
35 | 36 |
"INNER JOIN DefinedTermBase dtb on tnb.rank_id=dtb.id "; |
36 | 37 |
String SELECT_QUERY="SELECT tb.id as " + id + |
38 |
", tb.uuid as " + uuid_id + |
|
37 | 39 |
", tnb.titleCache as " + name_id + |
38 | 40 |
", tb.publish as " + pb_id + |
39 | 41 |
", tb.unplaced as " + unp_id + |
src/main/java/eu/etaxonomy/cdm/vaadin/util/CdmSpringContextHelper.java | ||
---|---|---|
11 | 11 |
import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool; |
12 | 12 |
import com.vaadin.server.VaadinServlet; |
13 | 13 |
|
14 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
|
14 | 15 |
import eu.etaxonomy.cdm.vaadin.container.CdmSpringConnectionPool; |
15 | 16 |
|
16 | 17 |
public class CdmSpringContextHelper { |
... | ... | |
49 | 50 |
JDBCConnectionPool connectionPool = new CdmSpringConnectionPool(bean.getConnection()); |
50 | 51 |
return connectionPool; |
51 | 52 |
} |
53 |
|
|
54 |
public static ITaxonService getTaxonService() { |
|
55 |
return (ITaxonService)CdmSpringContextHelper.newInstance().getBean("taxonServiceImpl"); |
|
56 |
} |
|
52 | 57 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/IStatusComposite.java | ||
---|---|---|
71 | 71 |
* @param parentItemId |
72 | 72 |
*/ |
73 | 73 |
public void addChildren(Object parentItemId); |
74 |
/** |
|
75 |
* @param pb |
|
76 |
* @param itemId |
|
77 |
*/ |
|
78 |
public void updatePublished(boolean pb, Object itemId); |
|
74 | 79 |
} |
75 | 80 |
|
76 | 81 |
public void setListener(StatusComponentListener listener); |
src/main/webapp/VAADIN/themes/mytheme/styles.css | ||
---|---|---|
12086 | 12086 |
display: inline-block; |
12087 | 12087 |
width: 19px; |
12088 | 12088 |
overflow: hidden; |
12089 |
} |
|
12090 |
|
|
12091 |
/** |
|
12092 |
* Custom settings below |
|
12093 |
*/ |
|
12094 |
|
|
12095 |
.mytheme .v-table-cell-content-removable { |
|
12096 |
color: green; |
|
12097 |
background-image: url("icons/32/cancel.png"); |
|
12098 |
background-repeat: no-repeat; |
|
12099 |
background-position: 5px; |
|
12100 |
text-indent: 20px; |
|
12101 |
} |
|
12102 |
|
|
12103 |
.mytheme .v-gridlayout-spacing-on { |
|
12104 |
padding-left: 2px; |
|
12105 |
padding-right: 2px; |
|
12106 |
padding-top: 2px; |
|
12107 |
padding-bottom: 2px; |
|
12108 | 12089 |
} |
Also available in: Unified diff
StatusPresenter : added method to update taxon published flag
CdmSpringContextHelper : added method to get taxon service
CdmQueryFactory, LeafNodeTaxonContainer : added uuid to taxon query select
StatusComposite, IStatusComposite : using new taxon published flag update method
styles.css : reverting back custom changes, will use the new edit theme instead