do not provide menu item change synonym to accepted taxon for homotyp. synonym of...
authorKatja Luther <k.luther@bgbm.org>
Thu, 4 Feb 2016 12:45:09 +0000 (13:45 +0100)
committerKatja Luther <k.luther@bgbm.org>
Thu, 4 Feb 2016 12:45:09 +0000 (13:45 +0100)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeSynonymToAcceptedTaxonHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/NameEditorMenuPropertyTester.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/TaxonNodeDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElement.java

index c6a9a0cd843ad506a4354b548984f49fc1f9b0be..5d5f449d254145e6c856a80a7e762fa58df015c8 100644 (file)
@@ -89,9 +89,9 @@ public class ChangeSynonymToAcceptedTaxonHandler extends AbstractHandler impleme
                TaxonNode parentNode = (TaxonNode) HibernateProxyHelper.deproxy(((TaxonEditorInput) input).getTaxonNode().getParent());
 
                List<UUID> excludeTaxa = new ArrayList<UUID>();
-               excludeTaxa.add(taxon.getUuid());
+               //excludeTaxa.add(taxon.getUuid());//there are some cases where the accepted taxon should be the parent of the new created accepted taxon
 
-               TaxonNode newParentNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event), editor.getConversationHolder(), "Select parent", excludeTaxa, null, ((TaxonEditorInput) input).getTaxonNode().getClassification());
+               TaxonNode newParentNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event), editor.getConversationHolder(), "Select parent", null, null, ((TaxonEditorInput) input).getTaxonNode().getClassification());
 
 
                if(newParentNode != null){
index 73c2f94d0eeb09e1a0c80aa04ed91d2a75adbd4c..5c7ca9a444c804c7227f318ce0a71990876edc87 100644 (file)
@@ -35,6 +35,8 @@ public class NameEditorMenuPropertyTester extends org.eclipse.core.expressions.P
        private static final String CONCEPT = "isConceptRelation";
        private static final String EMPTY_NAMES = "hasEmptyNames";
        private static final String ACCEPTED_AND_NO_HOMOTYPIC_SYNONYMS = "isAcceptedAndHasNoHomotypicSynonyms";
+       private static final String NOT_HOMOTYPIC_SYNONYM_OF_ACCEPTED = "isNotHomotypicSynonymOfAcceptedTaxon";
+       
 
        /**
         * <p>Constructor for NameEditorMenuPropertyTester.</p>
@@ -76,7 +78,10 @@ public class NameEditorMenuPropertyTester extends org.eclipse.core.expressions.P
                        }
                        else if(ACCEPTED_AND_NO_HOMOTYPIC_SYNONYMS.equals(property)){
                                return isAcceptedAndHasNoHomotypicSynonyms(selectedElement);
+                       }else if (NOT_HOMOTYPIC_SYNONYM_OF_ACCEPTED.equals(property)){
+                               return isNotHomotypicSynonymOfAcceptedTaxon(selectedElement);
                        }
+                       
                }
 
                return false;
@@ -90,6 +95,19 @@ public class NameEditorMenuPropertyTester extends org.eclipse.core.expressions.P
                }
                return false;
        }
+       
+       private boolean isNotHomotypicSynonymOfAcceptedTaxon(Object selectedElement) {
+               if (isSynonym(selectedElement)){
+                       Synonym synonym = (Synonym) selectedElement;
+                       for (Taxon taxon:synonym.getAcceptedTaxa()){
+                               if (taxon.getHomotypicGroup().equals(synonym.getHomotypicGroup())){
+                                       return false;
+                               }
+                       }
+               }
+               return true;
+       }
+
 
        /**
         * @param receiver
index 6368cdfeaa57b8723f7c2f6fab942663cf582ac8..dbe283bd139a00b7d8af8f2c6accaa200a55b966 100644 (file)
@@ -16,6 +16,7 @@ import eu.etaxonomy.cdm.api.service.IClassificationService;
 import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 import eu.etaxonomy.cdm.api.service.UpdateResult;
 import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.taxon.Classification;
 import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
@@ -52,6 +53,8 @@ public class NewTaxonNodeWizard extends AbstractNewEntityWizard<ITaxonTreeNode>{
             getConversationHolder().bind();
             ITaxonTreeNode parent = getParentTreeNode();
             Taxon taxon = taxonNodePage.getTaxon();
+            Reference sec = taxon.getSec();
+            taxon.setSec(null);
             try{
                UpdateResult result = CdmStore.getService(ITaxonNodeService.class).createNewTaxonNode(parent.getUuid(), taxon, parent.getReference(), parent.getMicroReference());
                        
@@ -64,7 +67,8 @@ public class NewTaxonNodeWizard extends AbstractNewEntityWizard<ITaxonTreeNode>{
                 }*/
                generatedTaxonNodeUuid = result.getCdmEntity().getUuid();
                TaxonNode taxonNode = CdmStore.getService(ITaxonNodeService.class).load(generatedTaxonNodeUuid);
-
+               taxonNode.getTaxon().setSec(sec);
+               CdmStore.getService(ITaxonNodeService.class).merge(taxonNode, true);
                 Set<CdmBase> affectedObjects = new HashSet<CdmBase>();
                 if (result.getUpdatedObjects().iterator().hasNext()){
                        TaxonNode parentNode = (TaxonNode)result.getUpdatedObjects().iterator().next();
index 037e7c75b273fab57cb75a446d55be2c28fe7008..043587499ddc7955ad65fd147b547c2f603a59f5 100644 (file)
@@ -145,6 +145,7 @@ public class TaxonNodeDetailElement extends AbstractCdmDetailElement<ITaxonTreeN
                         }
                     }
                 }
+               
             }
         }
     }
@@ -274,8 +275,8 @@ public class TaxonNodeDetailElement extends AbstractCdmDetailElement<ITaxonTreeN
        private void setTaxon(TaxonNameBase taxonName) {
                Reference secundum = null;
                if (getParentTreeNode() != null) {
-                       if (this.secReference != null){
-                               secundum = this.secReference;
+                       if (this.selection_SecRef.getEntity() != null){
+                               secundum = this.selection_SecRef.getEntity();
                        } /*else if (getParentTreeNode() instanceof Classification) {
                                secundum = ((Classification) getParentTreeNode())
                                                .getReference();
index 2a07ef5f8c91e187718e66a4e374071c7dbfee8f..8bb34daab95938ad6e3f9b230cee5b9692da0209 100644 (file)
@@ -8,6 +8,7 @@ import java.util.Observable;
 import java.util.Observer;
 
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
@@ -419,6 +420,10 @@ public class EntitySelectionElement<T extends CdmBase> extends
                /** {@inheritDoc} */
                @Override
                public void widgetSelected(SelectionEvent e) {
+                       if (StoreUtil.getActiveEditor().isDirty()){
+                               MessageDialog.openInformation(null,"Save changes", "You have made changes that must be saved before this query can be executed");
+                               return;
+                       }
                        WizardDialog dialog = new WizardDialog(selectionElement.getShell(),
                                        new EditFromSelectionWizard(selectionElement));
                        if (dialog.open() == IStatus.OK) {