taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/CreateHomotypicSynonymHandler.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/CreateMisapplicationHandler.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/CreateSynonymInHomotypicalGroupHandler.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/DeleteAllEmptyNamesHandler.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/DeleteTaxonBaseHandler.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/GroupBasionymContributionItem.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/NameEditorMenuPropertyTester.java -text
name="separator1"
visible="true">
</separator>
- <menu
- label="Concept Relation">
- <visibleWhen>
- <or>
- <reference
- definitionId="isAcceptedTaxon">
- </reference>
- <reference
- definitionId="isConceptRelation">
- </reference>
- </or>
- </visibleWhen>
- <dynamic
- class="eu.etaxonomy.taxeditor.editor.name.handler.CreateConceptRelationMenu"
- id="eu.etaxonomy.taxeditor.editor.dynamicConceptRelationMenu">
- </dynamic>
- </menu>
<command
commandId="eu.etaxonomy.taxeditor.editor.name.createMisapplication"
label="Misapplication"
<reference
definitionId="isAcceptedTaxon">
</reference>
- <reference
- definitionId="isConceptRelation">
- </reference>
<reference
definitionId="isMisapplication">
</reference>
</visibleWhen>
</command>
</menu>
- <menu
- label="Change Relation Type">
- <visibleWhen>
- <reference
- definitionId="isConceptRelation">
- </reference>
- </visibleWhen>
- <dynamic
- class="eu.etaxonomy.taxeditor.editor.view.concept.handler.ChangeConceptRelationshipTypeMenu"
- id="eu.etaxonomy.taxeditor.editor.dynamicConceptRelationMenu">
- </dynamic>
- </menu>
<separator
name="taxeditor-editor.separator1"
visible="true">
</or>
</visibleWhen>
</command>
+ <command
+ commandId="eu.etaxonomy.taxeditor.editor.name.deleteAllEmptyNames"
+ label="Delete All Empty Names"
+ style="push">
+ <visibleWhen>
+ <reference
+ definitionId="hasEmptyNames">
+ </reference>
+ </visibleWhen>
+ </command>
<separator
name="taxeditor-editor.separator2"
visible="true">
id="eu.etaxonomy.taxeditor.editor.name.changeToAcceptedTaxon"
name="Change To Accepted Taxon">
</command>
- <command
- defaultHandler="eu.etaxonomy.taxeditor.editor.name.handler.ChangeToConceptRelationHandler"
- id="eu.etaxonomy.taxeditor.editor.name.changeToConceptRelation"
- name="Change To Concept Relation">
- </command>
<command
defaultHandler="eu.etaxonomy.taxeditor.editor.name.handler.ChangeToMisapplicationHandler"
id="eu.etaxonomy.taxeditor.editor.name.changeToMisapplication"
name="Change To Misapplication">
</command>
- <command
- defaultHandler="eu.etaxonomy.taxeditor.editor.view.concept.handler.ChangeConceptRelationshipTypeHandler"
- id="eu.etaxonomy.taxeditor.editor.name.changeConceptRelationshipType"
- name="Change Concept Relationship Type">
- </command>
<command
defaultHandler="eu.etaxonomy.taxeditor.editor.name.handler.SwapSynonymAndAcceptedHandler"
id="eu.etaxonomy.taxeditor.editor.name.swapSynonymAndAccepted"
id="eu.etaxonomy.taxeditor.editor.name.changeAcceptedToSynonym"
name="Change Accepted Taxon to Synonym">
</command>
+ <command
+ defaultHandler="eu.etaxonomy.taxeditor.editor.name.handler.DeleteAllEmptyNamesHandler"
+ id="eu.etaxonomy.taxeditor.editor.name.deleteAllEmptyNames"
+ name="Delete All Empty Names">
+ </command>
</extension>
<extension
point="org.eclipse.core.expressions.definitions">
<definition
id="isAcceptedTaxon">
<with
- variable="activeMenuSelection">
+ variable="selection">
<test
property="eu.etaxonomy.taxeditor.editor.name.propertyTester.isAcceptedTaxon">
</test>
<definition
id="isSynonym">
<with
- variable="activeMenuSelection">
+ variable="selection">
<test
property="eu.etaxonomy.taxeditor.editor.name.propertyTester.isSynonym">
</test>
<definition
id="isMisapplication">
<with
- variable="activeMenuSelection">
+ variable="selection">
<test
property="eu.etaxonomy.taxeditor.editor.name.propertyTester.isMisapplication">
</test>
</with>
</definition>
<definition
- id="isConceptRelation">
+ id="isTaxonBase">
<with
- variable="activeMenuSelection">
+ variable="selection">
<test
- property="eu.etaxonomy.taxeditor.editor.name.propertyTester.isConceptRelation">
+ property="eu.etaxonomy.taxeditor.editor.name.propertyTester.isTaxonBase">
</test>
</with>
</definition>
<definition
- id="isTaxonBase">
+ id="hasEmptyNames">
<with
- variable="activeMenuSelection">
+ variable="selection">
<test
- property="eu.etaxonomy.taxeditor.editor.name.propertyTester.isTaxonBase">
+ property="eu.etaxonomy.taxeditor.editor.name.propertyTester.hasEmptyNames">
</test>
</with>
</definition>
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,isConceptRelation"
+ properties="isAcceptedTaxon,isSynonym,isMisapplication,isTaxonBase,hasEmptyNames"
type="org.eclipse.jface.viewers.IStructuredSelection">
</propertyTester>
</extension>
<definition
id="isDeletable">
<with
- variable="activeMenuSelection">
+ variable="selection">
<test
property="eu.etaxonomy.taxeditor.descriptions.propertyTester.isDeletable">
</test>
<definition
id="isMedia">
<with
- variable="activeMenuSelection">
+ variable="selection">
<test
property="eu.etaxonomy.taxeditor.descriptions.propertyTester.isMedia">
</test>
<definition
id="isDescription">
<with
- variable="activeMenuSelection">
+ variable="selection">
<test
property="eu.etaxonomy.taxeditor.descriptions.propertyTester.isDescription">
</test>
<definition
id="isDescriptionElement">
<with
- variable="activeMenuSelection">
+ variable="selection">
<test
property="eu.etaxonomy.taxeditor.descriptions.propertyTester.isDescriptionElement">
</test>
<definition
id="isFeatureNodeContainer">
<with
- variable="activeMenuSelection">
+ variable="selection">
<test
property="eu.etaxonomy.taxeditor.descriptions.propertyTester.isFeatureNodeContainer">
</test>
<handler
class="eu.etaxonomy.taxeditor.editor.view.concept.handler.DeleteConceptRelationHandler"
commandId="org.eclipse.ui.edit.delete">
+ <activeWhen>
+ <with
+ variable="activePartId">
+ <equals
+ value="eu.etaxonomy.taxeditor.editor.view.concept">
+ </equals>
+ </with>
+ </activeWhen>
</handler>
</extension>
</plugin>
import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.commands.operations.UndoContext;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
for(IEditorPart editorPage : getPages()){
if(editorPage instanceof TaxonNameEditor){
if(((TaxonNameEditor) editorPage).checkForEmptyNames()){
- // abort
+ MessageDialog.openWarning(EditorUtil.getShell(), "No Name Specified", "An attempt was made to save a taxon or synonym with " +
+ "an empty name. Operation was cancelled.");
return;
}
}
import java.util.List;
import java.util.Set;
+import org.apache.commons.lang.StringUtils;
import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
*/
public boolean checkForEmptyNames() {
for(AbstractGroupedContainer container : getGroupedContainers()){
- if(container.getName() == null || container.getName().getTitleCache().equals("")){
- MessageDialog.openWarning(EditorUtil.getShell(), "No Name Specified", "An attempt was made to save a taxon or synonym with " +
- "an empty name. Operation was cancelled.");
+ if(container.getName() == null || StringUtils.isEmpty(container.getName().getTitleCache())){
return true;
}
}
return false;
}
+
+ public Set<AbstractGroupedContainer> getEmptyContainers(){
+ Set<AbstractGroupedContainer> containersWithEmptyNames = new HashSet<AbstractGroupedContainer>();
+
+ for(AbstractGroupedContainer container : getGroupedContainers()){
+ if(container.getName() == null || StringUtils.isEmpty(container.getName().getTitleCache())){
+ containersWithEmptyNames.add(container);
+ }
+ }
+
+ return containersWithEmptyNames;
+ }
+
/** {@inheritDoc} */
@Override
public void doSave(IProgressMonitor monitor) {
}
}
-
-
/**
* @param element
* @return
package eu.etaxonomy.taxeditor.editor.name.handler;
-import org.apache.log4j.Logger;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
*/
public class CreateHomotypicSynonymHandler extends AbstractHandler implements
IHandler {
- private static final Logger logger = Logger
- .getLogger(CreateHomotypicSynonymHandler.class);
/* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
editor.getUndoContext(), taxon, group, newSynonymName, editor);
EditorUtil.executeOperation(operation);
} catch (NotDefinedException e) {
- logger.warn("Command name not set");
+ EditorUtil.error(getClass(), e);
}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.editor.name.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.Page;
+import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
+import eu.etaxonomy.taxeditor.editor.name.container.AbstractGroupedContainer;
+
+/**
+ * @author n.hoffmann
+ * @created Jan 28, 2011
+ * @version 1.0
+ */
+public class DeleteAllEmptyNamesHandler extends DeleteTaxonBaseHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ TaxonNameEditor editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(Page.NAME);
+
+ for(AbstractGroupedContainer<TaxonBase> containerWithEmptyName : editor.getEmptyContainers()){
+ doExecute(event, editor, containerWithEmptyName.getData());
+ }
+
+ return null;
+ }
+
+}
*/
package eu.etaxonomy.taxeditor.editor.name.handler;
-import org.apache.log4j.Logger;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
import eu.etaxonomy.taxeditor.editor.name.operation.DeleteMisapplicationOperation;
import eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation;
-import eu.etaxonomy.taxeditor.editor.view.concept.operation.DeleteConceptRelationOperation;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
/**
* @version 1.0
*/
public class DeleteTaxonBaseHandler extends AbstractHandler implements IHandler {
- private static final Logger logger = Logger
- .getLogger(DeleteTaxonBaseHandler.class);
+
/* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
Object selectedElement = EditorUtil.getSelection(event).getFirstElement();
- AbstractPostOperation operation = null;
- String commandName = null;
-
+ doExecute(event, editor, selectedElement);
+ return null;
+ }
+
+ /**
+ * @param editor
+ * @param selectedElement
+ * @param operation
+ * @param commandName
+ */
+ protected void doExecute(ExecutionEvent event, TaxonNameEditor editor, Object selectedElement) {
+ AbstractPostOperation operation = null;
+ String commandName = null;
+
try {
commandName = event.getCommand().getName();
} catch (NotDefinedException e) {
- logger.error(e);
- throw new RuntimeException(e);
+ EditorUtil.error(getClass(), e);
}
-
// synonym
if(selectedElement instanceof Synonym){
operation = new DeleteSynonymOperation(commandName, editor.getUndoContext(), editor.getTaxon(), (Synonym) selectedElement, editor);
}
EditorUtil.executeOperation(operation);
-
- return null;
}
}
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;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.Page;
+import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
/**
* <p>NameEditorMenuPropertyTester class.</p>
* @version 1.0
*/
public class NameEditorMenuPropertyTester extends org.eclipse.core.expressions.PropertyTester {
- private static final Logger logger = Logger.getLogger(NameEditorMenuPropertyTester.class);
private static final String ACCEPTED = "isAcceptedTaxon";
private static final String SYNONYM = "isSynonym";
private static final String MISAPPLICATION = "isMisapplication";
private static final String TAXONBASE = "isTaxonBase";
private static final String CONCEPT = "isConceptRelation";
+ private static final String EMPTY_NAMES = "hasEmptyNames";
/**
* <p>Constructor for NameEditorMenuPropertyTester.</p>
public boolean test(Object receiver, String property, Object[] args,
Object expectedValue) {
- if(!(receiver instanceof IStructuredSelection)){
- return false;
+ if(receiver instanceof IStructuredSelection){
+
+ IStructuredSelection selection = (IStructuredSelection) receiver;
+
+ Object selectedElement = selection.getFirstElement();
+
+ if(ACCEPTED.equals(property)){
+ return isAccepted(selectedElement);
+ }
+ else if(SYNONYM.equals(property)){
+ return isSynonym(selectedElement);
+ }
+ else if(MISAPPLICATION.equals(property)){
+ return isMisapplication(selectedElement);
+ }
+ else if(TAXONBASE.equals(property)){
+ return isTaxonBase(selectedElement);
+ }
+ else if(CONCEPT.equals(property)){
+ return isRelatedConcept(selectedElement);
+ }
+ else if(EMPTY_NAMES.equals(property)){
+ return hasEmptyNames(receiver);
+ }
}
- IStructuredSelection selection = (IStructuredSelection) receiver;
-
- Object selectedElement = selection.getFirstElement();
+ return false;
- if(ACCEPTED.equals(property)){
- return isAccepted(selectedElement);
- }
- else if(SYNONYM.equals(property)){
- return isSynonym(selectedElement);
- }
- else if(MISAPPLICATION.equals(property)){
- return isMisapplication(selectedElement);
- }
- else if(TAXONBASE.equals(property)){
- return isTaxonBase(selectedElement);
- }
- else if(CONCEPT.equals(property)){
- return isRelatedConcept(selectedElement);
- }
- else{
- return false;
- }
+ }
+
+ /**
+ * @param receiver
+ * @return
+ */
+ private boolean hasEmptyNames(Object receiver) {
+ return ((TaxonNameEditor) EditorUtil.getActiveEditorPage(Page.NAME)).checkForEmptyNames();
}
private boolean isRelatedConcept(Object selectedElement) {
}
private boolean isAccepted(Object selectedElement) {
- return (selectedElement instanceof Taxon && ! ((Taxon) selectedElement).isRelatedConcept() && ! ((Taxon) selectedElement).isMisapplication()) ? true : false;
+ return (selectedElement instanceof Taxon && ! ((Taxon) selectedElement).isMisapplication()) ? true : false;
}
}
viewer.setSorter(new ConceptViewerSorter());
+ getSite().setSelectionProvider(viewer);
+
createMenu();
createToolbar();
TaxonNameEditor editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(
Page.NAME);
- ISelection selection = HandlerUtil.getActiveMenuSelection(event);
+ ISelection selection = HandlerUtil.getActiveSite(event).getSelectionProvider().getSelection();
Set<TaxonRelationship> relations = new HashSet<TaxonRelationship>();
*/
/** {@inheritDoc} */
public Object execute(ExecutionEvent event) throws ExecutionException {
- IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getActiveMenuSelection(event);
+ IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getActiveSite(event).getSelectionProvider().getSelection();
IWorkbenchPart part = HandlerUtil.getActivePart(event);
IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null;
List<DescriptionElementBase> descriptions = ((FeatureNodeContainer) object).getDescriptionElementsForEntireBranch();
for(DescriptionElementBase description : descriptions){
- operations.add(new DeleteDescriptionElementOperation(label, undoContext, (DescriptionElementBase) object, postOperationEnabled));
+ operations.add(new DeleteDescriptionElementOperation(label, undoContext, description, postOperationEnabled));
}
}
// Media
else if(object instanceof Media){
- TreeSelection treeSelection = (TreeSelection) HandlerUtil.getActiveMenuSelection(event);
+ TreeSelection treeSelection = (TreeSelection) selection;
TreePath[] path = treeSelection.getPathsFor(object);
import org.eclipse.ui.forms.widgets.TableWrapLayout;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
-import eu.etaxonomy.cdm.model.common.IAnnotatableEntity;
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
import eu.etaxonomy.taxeditor.forms.AbstractFormSection;
import eu.etaxonomy.taxeditor.forms.CdmFormFactory;
import eu.etaxonomy.taxeditor.forms.ICdmFormElement;
import eu.etaxonomy.taxeditor.forms.IEnableableFormElement;
import eu.etaxonomy.taxeditor.forms.ISelectableElement;
-import eu.etaxonomy.taxeditor.forms.SelectionArbitrator;
/**
* <p>Abstract AbstractCdmDetailSection class.</p>
protected AbstractCdmDetailElement<ENTITY> detailElement;
- protected SelectionArbitrator selectionArbitrator;
-
/**
* <p>Constructor for AbstractCdmDetailSection.</p>
*
@Override
public void dispose() {
if(detailElement instanceof ISelectableElement){
- formFactory.destroySelectionArbitrator(((ISelectableElement)detailElement).getSelectionArbitrator());
+ ISelectableElement selectableElement = (ISelectableElement) detailElement;
+ if(selectableElement.getSelectionArbitrator() != null){
+ formFactory.destroySelectionArbitrator(selectableElement.getSelectionArbitrator());
+ }
}
super.dispose();
}
import eu.etaxonomy.taxeditor.forms.ICdmFormElement;
import eu.etaxonomy.taxeditor.forms.IEnableableFormElement;
import eu.etaxonomy.taxeditor.forms.ISelectableElement;
-import eu.etaxonomy.taxeditor.forms.LabelElement;
import eu.etaxonomy.taxeditor.forms.NumberWithLabelElement;
import eu.etaxonomy.taxeditor.forms.SelectionArbitrator;
import eu.etaxonomy.taxeditor.forms.TextWithLabelElement;
if(eventSource == combo_rank){
getEntity().setRank(combo_rank.getSelection());
clearCheckRankWarnings();
- // TODO
-// logger.warn("Refreshing the details view at this stage may lead to 'Widget is disposed' errors. They can be ignored.");
- try{
- EditorUtil.refreshDetailsViewer();
- getParentElement().getParentElement().getParentElement().refresh();
- }catch(SWTException e){
- // ignore
- }
}
else if(eventSource == text_appendedPhrase){
getEntity().setAppendedPhrase(text_appendedPhrase.getText());
toggleable_cache.setText(getEntity().getTitleCache());
}
}
+ if(eventSource == section_name){
+ section_name.setEntity(getEntity());
+ getLayoutComposite().layout();
+ }
}
}
}
getConversationHolder().commit(true);
-// getConversationHolder().close();
return true;
}