Revision ad7201d3
Added by Andreas Müller over 3 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
1 | 9 |
package eu.etaxonomy.taxeditor.editor.view.derivate; |
2 | 10 |
|
3 | 11 |
import java.util.ArrayList; |
... | ... | |
93 | 101 |
|
94 | 102 |
/** |
95 | 103 |
* Displays the derivate hierarchy of the specimen specified in the editor input. |
96 |
* |
|
97 | 104 |
*/ |
98 | 105 |
public class DerivateView implements IPartContentHasFactualData, IConversationEnabled, |
99 |
ICdmEntitySessionEnabled, IDirtyMarkable, IPostOperationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IPartContentHasMedia, |
|
106 |
ICdmEntitySessionEnabled<SpecimenOrObservationBase<?>>, IDirtyMarkable, IPostOperationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IPartContentHasMedia,
|
|
100 | 107 |
IContextListener, IE4SavablePart, ICollapsableExpandable { |
101 | 108 |
|
102 | 109 |
private static final String SPECIMEN_EDITOR = Messages.DerivateView_SPECIMEN_EDITOR; |
... | ... | |
181 | 188 |
public DerivateView() { |
182 | 189 |
} |
183 | 190 |
|
184 |
/** |
|
185 |
* {@inheritDoc} |
|
186 |
*/ |
|
187 | 191 |
public void init(DerivateViewEditorInput editorInput){ |
188 | 192 |
this.derivateToRootEntityMap = new HashMap<>(); |
189 | 193 |
this.rootElements = new HashSet<>(); |
... | ... | |
292 | 296 |
} |
293 | 297 |
} |
294 | 298 |
|
295 |
|
|
296 | 299 |
public void updateRootEntities(List<SpecimenOrObservationBase> derivates) { |
297 | 300 |
if(derivates!=null){ |
298 | 301 |
eventBroker.post(WorkbenchEventConstants.CURRENT_ACTIVE_EDITOR, null); |
299 | 302 |
this.derivateToRootEntityMap = new HashMap<>(); |
300 | 303 |
this.rootElements = new HashSet<>(); |
301 |
for (SpecimenOrObservationBase derivate : derivates) { |
|
304 |
for (SpecimenOrObservationBase<?> derivate : derivates) {
|
|
302 | 305 |
|
303 | 306 |
if(derivate instanceof FieldUnit){ |
304 | 307 |
derivateToRootEntityMap.put(derivate, derivate); |
... | ... | |
320 | 323 |
labelProvider.updateLabelCache(rootElements); |
321 | 324 |
viewer.setInput(rootElements); |
322 | 325 |
viewer.setComparator(new ViewerComparator() { |
323 |
@Override |
|
324 |
@SuppressWarnings("unchecked") |
|
325 |
public int compare(Viewer testViewer, Object e1, Object e2) { |
|
326 |
if (((TreeNode)e1).getValue() instanceof SpecimenOrObservationBase){ |
|
327 |
return ((SpecimenOrObservationBase)((TreeNode)e1).getValue()).getTitleCache().compareTo(((SpecimenOrObservationBase)((TreeNode)e2).getValue()).getTitleCache()); |
|
328 |
}else{ |
|
329 |
return e1.toString().compareTo(e2.toString()); |
|
330 |
} |
|
331 |
//return (((SpecimenOrObservationBase) e1).getTitleCache()).compareTo(((SpecimenOrObservationBase) e2).getTitleCache()); |
|
326 |
@Override |
|
327 |
public int compare(Viewer testViewer, Object e1, Object e2) { |
|
328 |
if (((TreeNode)e1).getValue() instanceof SpecimenOrObservationBase){ |
|
329 |
return ((SpecimenOrObservationBase)((TreeNode)e1).getValue()).getTitleCache().compareTo(((SpecimenOrObservationBase)((TreeNode)e2).getValue()).getTitleCache()); |
|
330 |
}else{ |
|
331 |
return e1.toString().compareTo(e2.toString()); |
|
332 |
} |
|
333 |
//return (((SpecimenOrObservationBase) e1).getTitleCache()).compareTo(((SpecimenOrObservationBase) e2).getTitleCache()); |
|
332 | 334 |
} |
333 | 335 |
}); |
334 | 336 |
|
... | ... | |
513 | 515 |
obj = ((TreeNode)obj).getValue(); |
514 | 516 |
} |
515 | 517 |
rootElements.remove(obj); |
516 |
Object o = this.derivateToRootEntityMap.remove(obj);
|
|
518 |
this.derivateToRootEntityMap.remove(obj); |
|
517 | 519 |
viewer.setInput(rootElements); |
518 | 520 |
} |
519 | 521 |
|
... | ... | |
594 | 596 |
else if(selection != null){ |
595 | 597 |
Object selectedElement = selection.getFirstElement(); |
596 | 598 |
if(selectedElement instanceof TaxonNodeDto){ |
597 |
TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).load(((TaxonNodeDto)selectedElement).getTaxonUuid()); |
|
599 |
TaxonBase<?> taxonBase = CdmStore.getService(ITaxonService.class).load(((TaxonNodeDto)selectedElement).getTaxonUuid());
|
|
598 | 600 |
if(HibernateProxyHelper.isInstanceOf(taxonBase, Taxon.class)){ |
599 | 601 |
selectedTaxon = HibernateProxyHelper.deproxy(taxonBase, Taxon.class); |
600 | 602 |
} |
... | ... | |
609 | 611 |
if(selectedTaxon!=null){ |
610 | 612 |
Collection<SpecimenOrObservationBase> fieldUnits = CdmStore.getService(IOccurrenceService.class).listFieldUnitsByAssociatedTaxon(selectedTaxon, null, null); |
611 | 613 |
Collection<UUID> uuids = new HashSet<>(); |
612 |
for (SpecimenOrObservationBase specimenOrObservationBase : fieldUnits) { |
|
614 |
for (SpecimenOrObservationBase<?> specimenOrObservationBase : fieldUnits) {
|
|
613 | 615 |
uuids.add(specimenOrObservationBase.getUuid()); |
614 | 616 |
} |
615 | 617 |
checkWarnThreshold(uuids); |
... | ... | |
634 | 636 |
return viewer; |
635 | 637 |
} |
636 | 638 |
|
637 |
/** |
|
638 |
* {@inheritDoc} |
|
639 |
*/ |
|
640 | 639 |
@Override |
641 | 640 |
public List<SpecimenOrObservationBase<?>> getRootEntities() { |
642 | 641 |
return new ArrayList<>(rootElements); |
... | ... | |
658 | 657 |
return listenToSelectionChange; |
659 | 658 |
} |
660 | 659 |
|
661 |
/** |
|
662 |
* {@inheritDoc} |
|
663 |
*/ |
|
664 | 660 |
@Override |
665 | 661 |
public void contextAboutToStop(IMemento memento, IProgressMonitor monitor) { |
666 | 662 |
} |
667 | 663 |
|
668 |
/** |
|
669 |
* {@inheritDoc} |
|
670 |
*/ |
|
671 | 664 |
@Override |
672 | 665 |
public void contextStop(IMemento memento, IProgressMonitor monitor) { |
673 | 666 |
//close view when workbench closes |
... | ... | |
678 | 671 |
//nothing |
679 | 672 |
} |
680 | 673 |
} |
681 |
|
|
682 |
/** |
|
683 |
* {@inheritDoc} |
|
684 |
*/ |
|
674 |
|
|
685 | 675 |
@Override |
686 | 676 |
public void contextStart(IMemento memento, IProgressMonitor monitor) { |
687 | 677 |
} |
688 | 678 |
|
689 |
/** |
|
690 |
* {@inheritDoc} |
|
691 |
*/ |
|
692 | 679 |
@Override |
693 | 680 |
public void contextRefresh(IProgressMonitor monitor) { |
694 | 681 |
} |
695 | 682 |
|
696 |
/** |
|
697 |
* {@inheritDoc} |
|
698 |
*/ |
|
699 | 683 |
@Override |
700 | 684 |
public void workbenchShutdown(IMemento memento, IProgressMonitor monitor) { |
701 | 685 |
} |
702 | 686 |
|
703 |
|
|
704 | 687 |
@Override |
705 | 688 |
public boolean isDirty() { |
706 | 689 |
return dirty.isDirty(); |
... | ... | |
715 | 698 |
public void expand() { |
716 | 699 |
viewer.expandAll(); |
717 | 700 |
} |
718 |
|
|
719 |
} |
|
701 |
} |
Also available in: Unified diff
cleanup and generics for ICdmEntitySessionEnabled