From dcec2a4500c03da32c55df33d9a3b3a9fe5e97e2 Mon Sep 17 00:00:00 2001 From: Katja Luther Date: Mon, 11 May 2015 09:04:05 +0000 Subject: [PATCH] #4855 add MoveSynonymToAnotherAcceptedTaxonHandler and some clean up of the plugin.xml especially the delete --- .gitattributes | 2 + .../OSGI-INF/l10n/plugin.properties | 10 +- .../OSGI-INF/l10n/plugin_en.properties | 141 ++++++++++++++++++ eu.etaxonomy.taxeditor.editor/plugin.xml | 141 ++++++++++-------- ...eSynonymToAnotherAcceptedTaxonHandler.java | 82 ++++++++++ .../CreateDescriptionElementOperation.java | 2 +- .../DeleteTaxonDescriptionOperation.java | 8 +- .../view/media/MediaContentProvider.java | 18 ++- 8 files changed, 336 insertions(+), 68 deletions(-) create mode 100644 eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_en.properties create mode 100644 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/MoveSynonymToAnotherAcceptedTaxonHandler.java diff --git a/.gitattributes b/.gitattributes index 1844087a1..442841d98 100644 --- a/.gitattributes +++ b/.gitattributes @@ -355,6 +355,7 @@ eu.etaxonomy.taxeditor.editor/.project -text eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF -text eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin.properties -text eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_de.properties -text +eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_en.properties -text eu.etaxonomy.taxeditor.editor/build.properties -text eu.etaxonomy.taxeditor.editor/icons/address-book-new.png -text eu.etaxonomy.taxeditor.editor/icons/camera-photo.png -text @@ -460,6 +461,7 @@ eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/h eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/DeleteAllEmptyNamesHandler.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/DeleteTaxonBaseHandler.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/GroupBasionymContributionItem.java -text +eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/MoveSynonymToAnotherAcceptedTaxonHandler.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/NameEditorMenuPropertyTester.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/RemoveBasionymHandler.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/SetBasionymHandler.java -text diff --git a/eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin.properties b/eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin.properties index e28dcac16..1c03030fc 100644 --- a/eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin.properties +++ b/eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin.properties @@ -153,4 +153,12 @@ command.name.42 = Open Taxon Editor command.name.43 = Create Field Unit command.name.44 = Deep Delete command.name.46 = Move Synonym (Homotypical Group) to another Accepted Taxon -command.label.56 = Move Synonym (Homotypical Group) to another Accepted Taxon \ No newline at end of file +command.label.56 = Move Synonym (Homotypical Group) to another Accepted Taxon +markerContentGenerator.name = Validation Problems Marker Generator +command.name.45 = Delete +command.name.47 = Delete +commandParameter.name = taxonUUID +Bundle-Name = Editor Bundle +command.name.48 = delete +command.name.49 = delete +command.name.50 = delete \ No newline at end of file diff --git a/eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_en.properties b/eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_en.properties new file mode 100644 index 000000000..65d48bae5 --- /dev/null +++ b/eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_en.properties @@ -0,0 +1,141 @@ +#Properties file for taxeditor-editor +Bundle-Vendor.0 = EDIT +Bundle-Name.0 = EDIT Taxonomic Editor - Editor Bundle +command.name.17 = Set Basionym +command.name.18 = Remove Basionym +editor.name = Multipage Taxon Editor +editor.name.0 = Taxon Name Editor +editor.name.1 = Key +editor.name.2 = Polytomous Key Graph Editor +editor.name.3 = Polytomous Key List Editor +editor.name.4 = Cdm Authority Editor +editor.name.5 = Derivate View +view.name = Factual Data +view.name.0 = Uses +view.name.1 = Media +view.name.2 = Concept Relations +view.name.3 = Concept Graph +category.name = Taxonomic Editor +command.label = Reference +command.label.0 = Name +command.label.1 = Team +command.label.2 = Person +command.label.3 = Specimen +command.label.4 = Factual Data +command.label.5 = Media +command.label.6 = Concept +command.label.7 = Concept Graph +command.label.8 = Open Parent +menu.label = New +command.label.9 = Heterotypic Synonym +command.label.10 = Homotypic Synonym +command.label.11 = Synonym In Homotypical Group +menu.label.0 = Change To +command.label.12 = Accepted Taxon +command.label.13 = Synonym +command.label.14 = Misapplication +command.label.15 = Delete +command.label.16 = Delete All Empty Names +command.label.17 = Swap Synonym With Accepted +command.label.18 = Show Details +command.label.19 = Save +command.label.20 = New Node +command.label.21 = Delete +command.label.22 = Apply Layout +command.label.23 = New Key Number +command.label.24 = New Alternative +command.label.25 = Refresh Nodes +command.label.26 = Delete +command.label.27 = New Factual Data +menu.label.1 = New +command.label.28 = Move Description to Taxon +command.label.29 = Move Elements to Taxon +command.label.30 = Delete +command.label.31 = Save +menu.label.2 = New Derivate +command.label.32 = New Use +command.label.33 = New Use Summary +command.label.34 = New Use Record +command.label.35 = Delete +command.label.36 = Save +command.label.37 = New Image Gallery +command.label.38 = New Image +command.label.39 = Move Image Up In List +command.label.40 = Move Image Down In List +command.label.41 = Delete +command.label.42 = Save +menu.label.3 = New +command.label.43 = Open Related Concept +command.label.44 = Delete +command.label.45 = Edit Authorities +extension.name = Name Commands +category.name.0 = -- Name Editor +command.name = Open Parent +command.name.0 = Create Homotypic Synonym +command.name.1 = Create Heterotypic Synonym +command.name.2 = Create Synonym In Homotypical Group +command.name.3 = Change To Synonym +command.name.4 = Change To Accepted Taxon +command.name.5 = Change To Misapplication +command.name.6 = Swap Synonym With Accepted +command.name.7 = Set Basionym / Original Combination +command.name.8 = Remove Basionym / Original Combination +command.name.9 = Delete All Empty Names +category.name.1 = -- Factual +command.name.10 = Create Description Element +command.name.11 = New Description +command.name.12 = Move Description Elements to Taxon +command.name.13 = Move Description to Taxon +category.name.2 = -- New Uses +command.name.14 = New Use +command.name.15 = New Use Summary +command.name.16 = New Use Record +category.name.3 = -- Media +command.name.19 = Move Image Down In List +command.name.20 = New Image Gallery +command.name.21 = New Image +command.name.22 = Move Image Up In List +category.name.4 = -- New Entity +command.name.23 = New Reference +command.name.24 = New Name +command.name.25 = New Team +command.name.26 = New Person +command.name.27 = New Specimen +category.name.5 = -- Polytomous Keys +command.name.28 = New Child Node +command.name.29 = New Sibling Node +command.name.30 = Refresh Node Numbering +command.name.31 = Apply Layout +category.name.6 = -- Concept Relations +command.name.32 = Create Concept Relation +command.name.33 = Open Related Concept +category.name.7 = -- Group +command.name.34 = Edit CDM Authorities +command.name.35 = Open Derivate View +scheme.description = The default key binding scheme for the Taxonomic Editor +scheme.name = Taxonomic Editor Default Key Bindingseditor.name.6 = Specimen Import Editor +editor.name.7 = Gbif Import Editor +editor.name.8 = Checklist Editor +view.name.4 = Specimen Import +view.name.5 = GBIF Specimen Import +command.label.46 = Name +command.label.47 = Reference +command.label.48 = Datasource +command.label.49 = Misapplication +command.label.50 = Use Existing Image +command.name.36 = Create Misapplication +command.name.37 = Use Existing Image +command.name.38 = Open Checklist Editor +command.name.39 = New Datasource +wizard.name = Specimen Search/Import +wizard.description = Queries data provider for specimens with specified parameters.\nNote: Query results are currently limited to 100. +command.name.40 = Validation +view.name.6 = Validation +marker.field.0 = Object Type +marker.field.1 = Object +marker.field.2 = Attribute +marker.field.3 = Problematic Value +marker.field.4 = Problem description +marker.field.5 = Validator +marker.field.6 = Entity Class +marker.field.7 = Entity Id \ No newline at end of file diff --git a/eu.etaxonomy.taxeditor.editor/plugin.xml b/eu.etaxonomy.taxeditor.editor/plugin.xml index 98e9b29db..c6a2b41c2 100644 --- a/eu.etaxonomy.taxeditor.editor/plugin.xml +++ b/eu.etaxonomy.taxeditor.editor/plugin.xml @@ -172,7 +172,7 @@ + name="%markerContentGenerator.name"> @@ -468,7 +468,7 @@ visible="true"> @@ -568,7 +568,7 @@ visible="true"> @@ -604,7 +604,7 @@ style="push"> @@ -612,7 +612,7 @@ @@ -665,7 +665,7 @@ - @@ -716,7 +716,7 @@ @@ -812,7 +812,7 @@ visible="true"> @@ -834,7 +834,7 @@ @@ -856,7 +856,7 @@ visible="true"> @@ -866,7 +866,7 @@ @@ -876,7 +876,7 @@ @@ -886,7 +886,7 @@ @@ -900,7 +900,7 @@ visible="true"> @@ -929,7 +929,7 @@ visible="true"> @@ -1019,7 +1019,7 @@ + commandId="eu.etaxonomy.taxeditor.editor.name.command.delete"> + commandId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.delete"> @@ -1046,13 +1046,16 @@ + + - - + + + commandId="eu.etaxonomy.taxeditor.editor.key.polytomous.command.delete"> @@ -1064,7 +1067,7 @@ + commandId="eu.etaxonomy.taxeditor.editor.view.concept.command.delete"> @@ -1074,25 +1077,13 @@ - - - - - - - - + commandId="eu.etaxonomy.taxeditor.editor.view.derivate.command.delete"> @@ -1185,7 +1176,7 @@ id="eu.etaxonomy.taxeditor.editor.name.swapSynonymAndAccepted" name="%command.name.6"> - --> + + - - - + + + + id="eu.etaxonomy.taxeditor.editor.use.command.delete" + name="%command.name.47"> + + + + @@ -1413,7 +1419,7 @@ name="%command.name.42"> @@ -1433,6 +1439,19 @@ id="eu.etaxonomy.taxeditor.editor.derivate.deepDelete" name="%command.name.44"> + + + + + diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/MoveSynonymToAnotherAcceptedTaxonHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/MoveSynonymToAnotherAcceptedTaxonHandler.java new file mode 100644 index 000000000..82198663a --- /dev/null +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/MoveSynonymToAnotherAcceptedTaxonHandler.java @@ -0,0 +1,82 @@ +package eu.etaxonomy.taxeditor.editor.name.handler; + +import java.util.UUID; + +import org.apache.log4j.Logger; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.common.NotDefinedException; +import org.eclipse.core.commands.operations.IUndoContext; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.handlers.HandlerUtil; + +import eu.etaxonomy.cdm.model.common.CdmBase; +import eu.etaxonomy.cdm.model.name.TaxonNameBase; +import eu.etaxonomy.cdm.model.taxon.Synonym; +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.cdm.model.taxon.TaxonNode; +import eu.etaxonomy.taxeditor.editor.EditorUtil; +import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor; +import eu.etaxonomy.taxeditor.editor.TaxonEditorInput; +import eu.etaxonomy.taxeditor.editor.name.operation.MoveSynonymToAnotherAcceptedTaxonOperation; +import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; +import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog; + +public class MoveSynonymToAnotherAcceptedTaxonHandler extends AbstractHandler implements IPostOperationEnabled { + private static final Logger logger = Logger + .getLogger(MoveSynonymToAnotherAcceptedTaxonHandler.class); + private MultiPageTaxonEditor editor; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + editor = (MultiPageTaxonEditor) HandlerUtil.getActiveEditor(event); + Shell shell = HandlerUtil.getActiveShell(event); + IEditorInput input = editor.getEditorInput(); + if (!EditorUtil.forceUserSave(editor, shell)) { + return null; + } + + if (!(input instanceof TaxonEditorInput)) { + logger.error("Editor input is not TaxonEditorInput"); + return null; + } + + // Get synonym from selection + StructuredSelection selection = (StructuredSelection) HandlerUtil.getCurrentSelection(event); + if (!(selection.getFirstElement() instanceof Synonym)) { + logger.error("Selection does not contain a Synonym"); + return null; + } + + Synonym synonym = (Synonym) selection.getFirstElement(); + TaxonNode newParentNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event), editor.getConversationHolder(), "Select new accepted taxon", null, null, null); + Taxon oldParent = ((TaxonEditorInput)input).getTaxon(); + + MoveSynonymToAnotherAcceptedTaxonOperation operation = new MoveSynonymToAnotherAcceptedTaxonOperation("Change accepted Taxon of Synonym", EditorUtil.getUndoContext(), + oldParent.getUuid(), synonym.getUuid(), newParentNode.getTaxon(), editor); + + EditorUtil.executeOperation(operation); + + + return null; + } + + @Override + public boolean postOperation(CdmBase objectAffectedByOperation) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean onComplete() { + // TODO Auto-generated method stub + return false; + } + + + +} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/CreateDescriptionElementOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/CreateDescriptionElementOperation.java index 76c4d76a9..a16125b36 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/CreateDescriptionElementOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/CreateDescriptionElementOperation.java @@ -40,7 +40,7 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; public class CreateDescriptionElementOperation extends AbstractPostTaxonOperation { /** Constant ID="eu.etaxonomy.taxeditor.editor.descripti"{trunked} */ - public static final String ID = "eu.etaxonomy.taxeditor.editor.description.createDescriptionElement"; + public static final String ID = "eu.etaxonomy.taxeditor.editor.view.descriptive.command.createDescriptionElement"; private final DescriptionBase description; private final Feature feature; diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/DeleteTaxonDescriptionOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/DeleteTaxonDescriptionOperation.java index 5324d4e40..5a6cebd41 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/DeleteTaxonDescriptionOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/DeleteTaxonDescriptionOperation.java @@ -9,6 +9,9 @@ package eu.etaxonomy.taxeditor.editor.view.descriptive.operation; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.operations.IUndoContext; import org.eclipse.core.runtime.IAdaptable; @@ -59,7 +62,10 @@ public class DeleteTaxonDescriptionOperation extends AbstractPostTaxonOperation monitor.worked(20); if (description != null){ - CdmStore.getService(IDescriptionService.class).deleteDescription(description); + List propertyPaths = new ArrayList(); + propertyPaths.add("taxon"); + TaxonDescription loadedDescription = (TaxonDescription) CdmStore.getService(IDescriptionService.class).load(description.getUuid(), propertyPaths); + CdmStore.getService(IDescriptionService.class).deleteDescription(loadedDescription); return postExecute(description); } return null; diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaContentProvider.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaContentProvider.java index 0e4a26105..cf5aa8cc7 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaContentProvider.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaContentProvider.java @@ -72,7 +72,12 @@ public class MediaContentProvider implements ITreeContentProvider{ } else if (parentElement instanceof DescriptionBase) { if (((DescriptionBase) parentElement).isImageGallery()) { - return getImages((DescriptionBase) parentElement).toArray(); + List images = getImages((DescriptionBase) parentElement); + if (images != null){ + return images.toArray(); + } + return null; + } } else if (parentElement instanceof DerivedUnit){ @@ -111,6 +116,9 @@ public class MediaContentProvider implements ITreeContentProvider{ /** {@inheritDoc} */ @Override public boolean hasChildren(Object element) { + if (getChildren(element)== null) { + return false; + } return (getChildren(element).length > 0); } @@ -139,10 +147,12 @@ public class MediaContentProvider implements ITreeContentProvider{ if(elements.size() > 1){ MessagingUtils.error(this.getClass(), "There should be one and only one description element to hold the images. Found: " + elements.size() + " InDescription ID: " + description.getUuid(), null); } + if (!elements.isEmpty()){ + DescriptionElementBase element = elements.iterator().next(); + return element.getMedia(); + } - DescriptionElementBase element = elements.iterator().next(); - - return element.getMedia(); + } return null; } -- 2.34.1