commandId="eu.etaxonomy.taxeditor.editor.name.changeAcceptedToSynonym"
label="Change Accepted Taxon to Synonym"
style="push">
- <visibleWhen>
+ <visibleWhen
+ checkEnabled="true">
<reference
- definitionId="isAcceptedTaxon">
+ definitionId="isAcceptedAndHasNoHomotypicSynonyms">
</reference>
</visibleWhen>
</command>
</test>
</with>
</definition>
+ <definition
+ id="isAcceptedAndHasNoHomotypicSynonyms">
+ <with
+ variable="selection">
+ <test
+ property="eu.etaxonomy.taxeditor.editor.name.propertyTester.isAcceptedAndHasNoHomotypicSynonyms">
+ </test>
+ </with>
+ </definition>
</extension>
<extension
point="org.eclipse.core.expressions.propertyTesters">
class="eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester"
id="eu.etaxonomy.taxeditor.editor.name.propertyTester"
namespace="eu.etaxonomy.taxeditor.editor.name.propertyTester"
- properties="isAcceptedTaxon,isSynonym,isMisapplication,isTaxonBase,hasEmptyNames"
+ properties="isAcceptedTaxon,isSynonym,isMisapplication,isTaxonBase,hasEmptyNames,isAcceptedAndHasNoHomotypicSynonyms"
type="org.eclipse.jface.viewers.IStructuredSelection">
</propertyTester>
<propertyTester
package eu.etaxonomy.taxeditor.editor.name.handler;
-import org.apache.log4j.Logger;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IEditorPart;
import eu.etaxonomy.cdm.model.taxon.Synonym;
import eu.etaxonomy.cdm.model.taxon.Taxon;
private static final String TAXONBASE = "isTaxonBase";
private static final String CONCEPT = "isConceptRelation";
private static final String EMPTY_NAMES = "hasEmptyNames";
+ private static final String ACCEPTED_AND_NO_HOMOTYPIC_SYNONYMS = "isAcceptedAndHasNoHomotypicSynonyms";
/**
* <p>Constructor for NameEditorMenuPropertyTester.</p>
else if(EMPTY_NAMES.equals(property)){
return hasEmptyNames(receiver);
}
+ else if(ACCEPTED_AND_NO_HOMOTYPIC_SYNONYMS.equals(property)){
+ return isAcceptedAndHasNoHomotypicSynonyms(selectedElement);
+ }
}
return false;
}
+ private boolean isAcceptedAndHasNoHomotypicSynonyms(Object selectedElement) {
+ if (isAccepted(selectedElement)){
+ Taxon taxon = (Taxon) selectedElement;
+ return taxon.getSynonymsInGroup(taxon.getHomotypicGroup()).isEmpty();
+ }
+ return false;
+ }
+
/**
* @param receiver
* @return