X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/blobdiff_plain/b04ed1c348548b60ece8c5b597fbf2b770a3f964..1694322e0ab56c6b68ba5b5b4fffbe3660220b08:/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java index 6a295e64e..b331b88f5 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java @@ -34,6 +34,7 @@ import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; 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; @@ -90,7 +91,7 @@ public class TaxonEditorInput implements IEditorInput, IConversationEnabled, IPe 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; } @@ -109,36 +110,40 @@ public class TaxonEditorInput implements IEditorInput, IConversationEnabled, IPe 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 acceptedTaxa = new HashSet(); + Set 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 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 acceptedTaxa = new HashSet(); - Set 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 taxa = synonym.getAcceptedTaxa(); - input = getInputForMultipleTaxa(conversation, taxa); - } - - input.setInitiallySelectedTaxonBase(taxonBase); + return input; } @@ -154,7 +159,7 @@ public class TaxonEditorInput implements IEditorInput, IConversationEnabled, IPe } }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; } @@ -172,7 +177,7 @@ public class TaxonEditorInput implements IEditorInput, IConversationEnabled, IPe 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;