Fix problem for characters with same name
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / descriptiveDataSet / matrix / handler / CreateTaxonDescriptionHandler.java
index ea0304f9066fe565967955a4eea749f0d2810707..7f4a2eff1efcad235d2c277e52af4c7129e0ad19 100644 (file)
@@ -22,9 +22,10 @@ import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
 import eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO;
 import eu.etaxonomy.cdm.model.common.MarkerType;
 import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
 import eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO;
 import eu.etaxonomy.cdm.model.common.MarkerType;
 import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
 import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrixPart;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrixPart;
 import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.store.StoreUtil;
 
 /**
  * @author pplitzner
 
 /**
  * @author pplitzner
@@ -36,10 +37,14 @@ public abstract class CreateTaxonDescriptionHandler {
     @Execute
     public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, UISynchronize sync) {
         CharacterMatrixPart matrixPart = (CharacterMatrixPart) activePart.getObject();
     @Execute
     public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, UISynchronize sync) {
         CharacterMatrixPart matrixPart = (CharacterMatrixPart) activePart.getObject();
+        if(StoreUtil.promptCheckIsDirty(matrixPart)){
+            return;
+        }
         DescriptiveDataSet descriptiveDataSet = matrixPart.getDescriptiveDataSet();
         DescriptiveDataSet descriptiveDataSet = matrixPart.getDescriptiveDataSet();
-        TaxonNode node = (TaxonNode) matrixPart.getSelection().getFirstElement();
+        TaxonNodeDto node = (TaxonNodeDto) matrixPart.getSelection().getFirstElement();
         TaxonRowWrapperDTO taxonRowWrapperDTO = CdmStore.getService(IDescriptiveDataSetService.class)
                 .createTaxonDescription(descriptiveDataSet.getUuid(), node.getUuid(), getMarkerType(), getMarkerFlag());
         TaxonRowWrapperDTO taxonRowWrapperDTO = CdmStore.getService(IDescriptiveDataSetService.class)
                 .createTaxonDescription(descriptiveDataSet.getUuid(), node.getUuid(), getMarkerType(), getMarkerFlag());
+        matrixPart.getMatrix().getCdmEntitiySession().load(taxonRowWrapperDTO.getDescription(), true);
         matrixPart.getMatrix().getDescriptions().add(taxonRowWrapperDTO);
     }
 
         matrixPart.getMatrix().getDescriptions().add(taxonRowWrapperDTO);
     }
 
@@ -54,7 +59,7 @@ public abstract class CreateTaxonDescriptionHandler {
         boolean canExecute = false;
         IStructuredSelection selection = ((CharacterMatrixPart)activePart.getObject()).getSelection();
         canExecute = selection.size()==1
         boolean canExecute = false;
         IStructuredSelection selection = ((CharacterMatrixPart)activePart.getObject()).getSelection();
         canExecute = selection.size()==1
-                && selection.getFirstElement() instanceof TaxonNode;
+                && selection.getFirstElement() instanceof TaxonNodeDto;
         menuItem.setVisible(canExecute);
         return canExecute;
     }
         menuItem.setVisible(canExecute);
         return canExecute;
     }