Revision aceb7b1d
Added by Cherian Mathew about 9 years ago
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 { |
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