import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
import eu.etaxonomy.taxeditor.model.DataChangeBridge;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.store.CdmStore;
TaxonNode taxonNode = CdmStore.getService(ITaxonNodeService.class).load(taxonNodeUuid, null);
if(taxonNode == null){
- EditorUtil.warningDialog("Not yet implemented", TaxonEditorInput.class, "Selected element is not type TaxonBase.");
+ MessagingUtils.warningDialog("Not yet implemented", TaxonEditorInput.class, "Selected element is not type TaxonBase.");
return null;
}
TaxonEditorInput input = null;
TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).find(taxonBaseUuid);
- if(taxonBase.isOrphaned()) {
- EditorUtil.warningDialog("Orphaned Taxon", TaxonEditorInput.class, "This is an orphaned taxon i.e. a taxon that is not connected to a classification and not having any taxonomic relationships. Editing of orphaned taxon is currently not supported.");
+ if (taxonBase != null){
+ if(taxonBase.isOrphaned()) {
+ MessagingUtils.warningDialog("Orphaned Taxon", TaxonEditorInput.class, "This is an orphaned taxon i.e. a taxon that is not connected to a classification and not having any taxonomic relationships. Editing of orphaned taxon is currently not supported.");
+ }
+ else if(taxonBase.isInstanceOf(Taxon.class)){
+ Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class);
+
+ if (taxon.getTaxonNodes().size() == 0 && taxon.isMisapplication()){
+ // TODO get accepted taxon
+ MessagingUtils.info("trying to open Mispplied Name ");
+
+ Set<Taxon> acceptedTaxa = new HashSet<Taxon>();
+ Set<TaxonRelationship> relations = taxon.getRelationsFromThisTaxon();
+ for(TaxonRelationship relation : relations){
+ if(relation.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
+ acceptedTaxa.add(relation.getToTaxon());
+ }
+ }
+ input = getInputForMultipleTaxa(conversation, acceptedTaxa);
+
+ }else{
+ input = getInputForMultipleNodes(conversation, taxon.getTaxonNodes());
+ }
+ }else if(taxonBase instanceof Synonym){
+ Synonym synonym = (Synonym) taxonBase;
+
+ Set<Taxon> taxa = synonym.getAcceptedTaxa();
+ input = getInputForMultipleTaxa(conversation, taxa);
+ }
+ if (input != null){
+ input.setInitiallySelectedTaxonBase(taxonBase);
+ }
}
- else if(taxonBase.isInstanceOf(Taxon.class)){
- Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class);
-
- if (taxon.isMisapplication()){
- // TODO get accepted taxon
- EditorUtil.info("trying to open Mispplied Name ");
-
- Set<Taxon> acceptedTaxa = new HashSet<Taxon>();
- Set<TaxonRelationship> relations = taxon.getRelationsFromThisTaxon();
- for(TaxonRelationship relation : relations){
- if(relation.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
- acceptedTaxa.add(relation.getToTaxon());
- }
- }
- input = getInputForMultipleTaxa(conversation, acceptedTaxa);
-
- }else{
- input = getInputForMultipleNodes(conversation, taxon.getTaxonNodes());
- }
- }else if(taxonBase instanceof Synonym){
- Synonym synonym = (Synonym) taxonBase;
-
- Set<Taxon> taxa = synonym.getAcceptedTaxa();
- input = getInputForMultipleTaxa(conversation, taxa);
- }
-
- input.setInitiallySelectedTaxonBase(taxonBase);
+
return input;
}
}
}else if(taxonNodes.size() == 0){
// this is an undesired state
- EditorUtil.warningDialog("Incorrect state", TaxonEditorInput.class, "The accepted taxon is not part of any classification. This should not have happened.");
+ MessagingUtils.warningDialog("Incorrect state", TaxonEditorInput.class, "The accepted taxon is not part of any classification. This should not have happened.");
}
return null;
}
return getInputForMultipleNodes(conversation, taxonNodes);
}else if(taxa.size() == 0){
// this is an undesired state
- EditorUtil.warningDialog("Incorrect state", TaxonEditorInput.class, "Trying to open accepted taxon for a synonym or misapplication but" +
+ MessagingUtils.warningDialog("Incorrect state", TaxonEditorInput.class, "Trying to open accepted taxon for a synonym or misapplication but" +
" no accepted taxa are present. This should not have happened.");
}
return null;