Revision 7f7b4382
Added by Patrick Plitzner over 8 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java | ||
---|---|---|
38 | 38 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
39 | 39 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
40 | 40 |
import eu.etaxonomy.cdm.api.service.molecular.ISequenceService; |
41 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
41 | 42 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
42 | 43 |
import eu.etaxonomy.cdm.model.molecular.Sequence; |
43 | 44 |
import eu.etaxonomy.cdm.model.molecular.SingleRead; |
... | ... | |
99 | 100 |
|
100 | 101 |
private Set<SingleRead> multiLinkSingleReads; |
101 | 102 |
|
102 |
private ISelection selection = null; |
|
103 |
|
|
104 |
|
|
105 | 103 |
private DerivateContentProvider contentProvider; |
106 | 104 |
|
107 | 105 |
private DerivateSearchCompositeController derivateSearchCompositeController; |
... | ... | |
124 | 122 |
*/ |
125 | 123 |
private boolean listenToSelectionChange; |
126 | 124 |
|
125 |
private Taxon selectedTaxon; |
|
126 |
|
|
127 | 127 |
/** |
128 | 128 |
* Default constructor |
129 | 129 |
*/ |
... | ... | |
403 | 403 |
return this.multiLinkSingleReads; |
404 | 404 |
} |
405 | 405 |
|
406 |
public ISelection getSelection() {
|
|
407 |
return selection;
|
|
406 |
public Object getSelectionInput() {
|
|
407 |
return selectedTaxon;
|
|
408 | 408 |
} |
409 | 409 |
|
410 | 410 |
public DerivateLabelProvider getLabelProvider() { |
... | ... | |
431 | 431 |
return true; |
432 | 432 |
} |
433 | 433 |
|
434 |
public void removeHierarchy(SpecimenOrObservationBase<?> specimenOrObservationBase) { |
|
435 |
SpecimenOrObservationBase<?> rootElement = derivateToRootEntityMap.remove(specimenOrObservationBase); |
|
436 |
rootElements.remove(rootElement); |
|
437 |
} |
|
438 |
|
|
439 | 434 |
public void addHierarchy(FieldUnit fieldUnit) { |
440 | 435 |
rootElements.add(fieldUnit); |
441 | 436 |
derivateToRootEntityMap.put(fieldUnit, fieldUnit); |
... | ... | |
461 | 456 |
public void selectionChanged(IWorkbenchPart part, ISelection selection) { |
462 | 457 |
if(listenToSelectionChange && selection instanceof IStructuredSelection){ |
463 | 458 |
Object selectedElement = ((IStructuredSelection) selection).getFirstElement(); |
464 |
if(selectedElement instanceof Taxon){ |
|
465 |
Collection<SpecimenOrObservationBase> fieldUnits = CdmStore.getService(IOccurrenceService.class).listFieldUnitsByAssociatedTaxon((Taxon) selectedElement, null, null); |
|
459 |
if(selectedElement instanceof CdmBase && ((CdmBase) selectedElement).isInstanceOf(Taxon.class)){ |
|
460 |
selectedTaxon = HibernateProxyHelper.deproxy(selectedElement, Taxon.class); |
|
461 |
Collection<SpecimenOrObservationBase> fieldUnits = CdmStore.getService(IOccurrenceService.class).listFieldUnitsByAssociatedTaxon(selectedTaxon, null, null); |
|
466 | 462 |
Collection<UUID> uuids = new HashSet<UUID>(); |
467 | 463 |
for (SpecimenOrObservationBase specimenOrObservationBase : fieldUnits) { |
468 | 464 |
uuids.add(specimenOrObservationBase.getUuid()); |
... | ... | |
504 | 500 |
listenToSelectionChange = !listenToSelectionChange; |
505 | 501 |
derivateSearchCompositeController.setEnabled(!listenToSelectionChange); |
506 | 502 |
derivateSearchCompositeController.setTaxon(null); |
503 |
if(!listenToSelectionChange){ |
|
504 |
selectedTaxon = null; |
|
505 |
} |
|
506 |
} |
|
507 |
|
|
508 |
public boolean isListenToSelectionChange(){ |
|
509 |
return listenToSelectionChange; |
|
507 | 510 |
} |
508 | 511 |
|
509 | 512 |
/** |
Also available in: Unified diff
Add dynamic context menu entry for FieldUnit creation