Revision c226920a
Added by Fabian Reimeier almost 6 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/component/distributionStatus/AreaAndTaxonSettingsConfigWindow.java | ||
---|---|---|
59 | 59 |
/** |
60 | 60 |
* |
61 | 61 |
* @author pplitzner |
62 |
* A Configuration window for choosing distribution areas and taxa to work with. |
|
62 | 63 |
* |
63 | 64 |
*/ |
64 | 65 |
public class AreaAndTaxonSettingsConfigWindow |
65 | 66 |
extends SettingsDialogWindowBase<AreaAndTaxonSettingsPresenter> |
66 | 67 |
implements ValueChangeListener, ClickListener, ExpandListener{ |
67 | 68 |
|
69 |
/** |
|
70 |
* |
|
71 |
*/ |
|
68 | 72 |
private static final long serialVersionUID = 1439411115014088780L; |
69 | 73 |
private ComboBox classificationBox; |
70 | 74 |
private TextField taxonFilter; |
... | ... | |
85 | 89 |
super(); |
86 | 90 |
this.distributionTableView = distributionTableView; |
87 | 91 |
} |
88 |
|
|
92 |
|
|
93 |
/** |
|
94 |
* |
|
95 |
* {@inheritDoc} |
|
96 |
*/ |
|
89 | 97 |
@Override |
90 | 98 |
protected void init() { |
91 | 99 |
//init classification |
... | ... | |
137 | 145 |
updateButtons(); |
138 | 146 |
} |
139 | 147 |
|
148 |
/** |
|
149 |
* |
|
150 |
* {@inheritDoc} |
|
151 |
*/ |
|
140 | 152 |
@Override |
141 | 153 |
protected AbstractLayout buildMainLayout() { |
142 | 154 |
|
... | ... | |
230 | 242 |
return leftAndRightContainer; |
231 | 243 |
} |
232 | 244 |
|
245 |
/** |
|
246 |
* |
|
247 |
* {@inheritDoc} |
|
248 |
*/ |
|
233 | 249 |
@Override |
234 | 250 |
public void valueChange(ValueChangeEvent event) { |
235 | 251 |
Property<?> property = event.getProperty(); |
... | ... | |
271 | 287 |
updateButtons(); |
272 | 288 |
} |
273 | 289 |
|
290 |
/** |
|
291 |
* |
|
292 |
* {@inheritDoc} |
|
293 |
*/ |
|
274 | 294 |
@Override |
275 | 295 |
protected boolean isValid() { |
276 | 296 |
return classificationBox.getValue()!=null && distAreaBox.getValue()!=null; |
277 | 297 |
} |
278 | 298 |
|
299 |
/** |
|
300 |
* |
|
301 |
* {@inheritDoc} |
|
302 |
*/ |
|
279 | 303 |
@Override |
280 | 304 |
public void buttonClick(ClickEvent event) { |
281 | 305 |
Object source = event.getSource(); |
... | ... | |
305 | 329 |
} |
306 | 330 |
} |
307 | 331 |
|
332 |
/** |
|
333 |
* |
|
334 |
* {@inheritDoc} |
|
335 |
*/ |
|
308 | 336 |
@Override |
309 | 337 |
public void nodeExpand(ExpandEvent event) { |
310 | 338 |
UuidAndTitleCache<TaxonNode> parent = (UuidAndTitleCache<TaxonNode>) event.getItemId(); |
311 | 339 |
((TaxonNodeContainer) taxonTree.getContainerDataSource()).addChildItems(parent); |
312 | 340 |
} |
313 | 341 |
|
342 |
/** |
|
343 |
* Starts a {@link TreeUpdater} thread to populate the {@link #taxonTree} with taxa of the classification specified by the given {@code rootNode}. |
|
344 |
* @param rootNode The root node of the classification whose taxa should be shown in the {@link #taxonTree}. |
|
345 |
*/ |
|
314 | 346 |
private void showClassificationTaxa(TaxonNode rootNode) { |
315 | 347 |
final Collection<UuidAndTitleCache<TaxonNode>> children = CdmSpringContextHelper.getTaxonNodeService().listChildNodesAsUuidAndTitleCache(rootNode); |
316 | 348 |
// Enable polling and set frequency to 0.5 seconds |
... | ... | |
318 | 350 |
taxonTree.setEnabled(false); |
319 | 351 |
taxonTree.removeAllItems(); |
320 | 352 |
Notification.show(Messages.getLocalizedString(Messages.AreaAndTaxonSettingsConfigWindow_LOADING_TAXA)); |
321 |
|
|
322 | 353 |
new TreeUpdater(children).start(); |
323 | 354 |
} |
324 | 355 |
|
356 |
/** |
|
357 |
* Returns the {@link UuidAndTitleCache} object of the classification specified by the given {@link RowId} of the {@link CdmSQLContainer} used in the {@link #classificationBox}. |
|
358 |
* @param classificationSelection |
|
359 |
* @return {@link UuidAndTitleCache} object of the given classification specified by {@code classificationSelection} |
|
360 |
*/ |
|
325 | 361 |
private UuidAndTitleCache<TaxonNode> getUuidAndTitleCacheFromRowId(Object classificationSelection) { |
326 | 362 |
String uuidString = (String) classificationBox.getContainerProperty(classificationSelection, "uuid").getValue(); //$NON-NLS-1$ |
327 | 363 |
Property<Integer> rootNodeContainerProperty = null; |
... | ... | |
350 | 386 |
return new AreaAndTaxonSettingsPresenter(); |
351 | 387 |
} |
352 | 388 |
|
389 |
/** |
|
390 |
* Thread to populate {@link AreaAndTaxonSettingsConfigWindow#taxonTree}. |
|
391 |
* |
|
392 |
*/ |
|
353 | 393 |
private class TreeUpdater extends Thread{ |
354 |
|
|
394 |
|
|
395 |
/** |
|
396 |
* The taxa to show. |
|
397 |
*/ |
|
355 | 398 |
private Collection<UuidAndTitleCache<TaxonNode>> children; |
356 | 399 |
|
357 |
|
|
400 |
/** |
|
401 |
* Creates a thread to show the given collection of taxa in {@link AreaAndTaxonSettingsConfigWindow#taxonTree}. |
|
402 |
* @param children {@link UuidAndTitleCache} of the taxa to show. |
|
403 |
*/ |
|
358 | 404 |
public TreeUpdater(Collection<UuidAndTitleCache<TaxonNode>> children) { |
359 | 405 |
this.children = children; |
360 | 406 |
} |
361 | 407 |
|
408 |
/** |
|
409 |
* |
|
410 |
* {@inheritDoc} |
|
411 |
*/ |
|
362 | 412 |
@Override |
363 | 413 |
public void run() { |
364 | 414 |
UI.getCurrent().access(new Runnable() { |
415 |
/** |
|
416 |
* |
|
417 |
* {@inheritDoc} |
|
418 |
*/ |
|
365 | 419 |
@Override |
366 | 420 |
public void run() { |
367 | 421 |
taxonTree.setContainerDataSource(new TaxonNodeContainer(children)); |
Also available in: Unified diff
Documentation and refactoring