ref #8785: add menu item for remove desc and remember this desc and remove while...
authorKatja Luther <k.luther@bgbm.org>
Thu, 7 May 2020 09:44:39 +0000 (11:44 +0200)
committerKatja Luther <k.luther@bgbm.org>
Thu, 7 May 2020 09:44:39 +0000 (11:44 +0200)
eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin.properties
eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_de.properties
eu.etaxonomy.taxeditor.editor/fragment.e4xmi
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/handler/DeleteDescriptiveDataSetHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixBottomToolbar.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixPart.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/handler/DeleteDescriptionHandler.java [new file with mode: 0755]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/Messages.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/messages.properties
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/messages_de.properties

index b7d8e4b836bd256565c89285a8d9b859de22fa8f..92166feb6f87d2f304a87ac4f1e31bb8c92d9536 100755 (executable)
@@ -260,3 +260,12 @@ command.commandname.22 = Create Invalid Designation
 handledmenuitem.label.22 = Invalid Designation\r
 command.commandname.23 = Change to Invalid Designation\r
 command.commandname.61 = Change to Pro Parte Synonym
+\r
+handledmenuitem.label.23 = Add Feature\r
+handledmenuitem.label.24 = Add Child Feature\r
+handledmenuitem.label.25 = Paste\r
+handledmenuitem.label.26 = Copy\r
+handledmenuitem.label.27 = Delete\r
+handledmenuitem.label.28 = Delete Description\r
+partdescriptor.label.6 = Distribution Editor\r
+command.commandname.24 = Delete description\r
index b3a9bde94315598e4713bb8f947fbdbe5a042fcb..f9fc3376772f6e73a0315545df993eb2da2cf732 100644 (file)
@@ -260,3 +260,12 @@ command.commandname.22 = Erstelle Invalid Designation
 handledmenuitem.label.22 = Invalid Designation
 command.commandname.23 = Ändere zu Invalid Designation
 command.commandname.61 = Ändere zu Pro Parte Synonym
+
+handledmenuitem.label.23 = Feature hinzufügen
+handledmenuitem.label.24 = Kind Feature hinzufügen
+handledmenuitem.label.25 = Einfügen
+handledmenuitem.label.26 = Kopieren
+handledmenuitem.label.27 = Löschen
+handledmenuitem.label.28 = Beschreibung löschen
+partdescriptor.label.6 = Distribution Editor
+command.commandname.24 = Beschreibung löschen
index c59302c13b2e68e198abe4448497573be3d4f439..dae294c314154a45e366d916d5387bf940436813 100644 (file)
       <tags>nonRestore</tags>
       <handlers xmi:id="_A6uWsO5jEeiy4-dyP0ltdA" elementId="eu.etaxonomy.taxeditor.editor.handler.3" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.descriptiveDataSet.character.handler.AddFeatureToCharacterTreeHandler" command="_wujDAO5iEeiy4-dyP0ltdA"/>
       <menus xsi:type="menu:PopupMenu" xmi:id="_46lOIO5TEeiy4-dyP0ltdA" elementId="eu.etaxonomy.taxeditor.editor.popupmenu.characterEditor">
-        <children xsi:type="menu:HandledMenuItem" xmi:id="_T5PhEO5hEeiy4-dyP0ltdA" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.addfeature" label="Add Feature" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/add.gif" command="_wujDAO5iEeiy4-dyP0ltdA"/>
-        <children xsi:type="menu:HandledMenuItem" xmi:id="_eDsYUO5gEeiy4-dyP0ltdA" elementId="eu.etaxonomy.taxeditor.editor.charactereditor.handledmenuitem.addchildfeature" label="Add Child Feature" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/add.gif" command="_a7aYwO5gEeiy4-dyP0ltdA"/>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_T5PhEO5hEeiy4-dyP0ltdA" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.addfeature" label="%handledmenuitem.label.23" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/add.gif" command="_wujDAO5iEeiy4-dyP0ltdA"/>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_eDsYUO5gEeiy4-dyP0ltdA" elementId="eu.etaxonomy.taxeditor.editor.charactereditor.handledmenuitem.addchildfeature" label="%handledmenuitem.label.24" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/add.gif" command="_a7aYwO5gEeiy4-dyP0ltdA"/>
         <children xsi:type="menu:MenuSeparator" xmi:id="_tTotQO5gEeiy4-dyP0ltdA" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.27"/>
-        <children xsi:type="menu:HandledMenuItem" xmi:id="_QquMEO5gEeiy4-dyP0ltdA" elementId="eu.etaxonomy.taxeditor.editor.charactereditor.handledmenuitem.paste" label="Paste" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/paste_edit.png" command="_Y2mBUO5gEeiy4-dyP0ltdA"/>
-        <children xsi:type="menu:HandledMenuItem" xmi:id="_RNTUsO5gEeiy4-dyP0ltdA" elementId="eu.etaxonomy.taxeditor.editor.charactereditor.handledmenuitem.copy" label="Copy" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/copy_edit.png" command="_YMab4O5gEeiy4-dyP0ltdA"/>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_QquMEO5gEeiy4-dyP0ltdA" elementId="eu.etaxonomy.taxeditor.editor.charactereditor.handledmenuitem.paste" label="%handledmenuitem.label.25" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/paste_edit.png" command="_Y2mBUO5gEeiy4-dyP0ltdA"/>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_RNTUsO5gEeiy4-dyP0ltdA" elementId="eu.etaxonomy.taxeditor.editor.charactereditor.handledmenuitem.copy" label="%handledmenuitem.label.26" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/copy_edit.png" command="_YMab4O5gEeiy4-dyP0ltdA"/>
         <children xsi:type="menu:MenuSeparator" xmi:id="_uNg7kO5gEeiy4-dyP0ltdA" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.28"/>
-        <children xsi:type="menu:HandledMenuItem" xmi:id="_F--RgO5UEeiy4-dyP0ltdA" elementId="eu.etaxonomy.taxeditor.editor.charactereditor.handledmenuitem.delete" label="Delete" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/delete.gif" command="_oBEz8GhvEee3K4uKJljEYg"/>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_F--RgO5UEeiy4-dyP0ltdA" elementId="eu.etaxonomy.taxeditor.editor.charactereditor.handledmenuitem.delete" label="%handledmenuitem.label.27" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/delete.gif" command="_oBEz8GhvEee3K4uKJljEYg"/>
       </menus>
     </elements>
     <elements xsi:type="basic:PartDescriptor" xmi:id="_7GbckIDLEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4" label="%view.name.1" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.editor/icons/camera-photo.png" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4">
       <menus xsi:type="menu:PopupMenu" xmi:id="__10yYLKREeikjKoOnLFm2w" elementId="eu.etaxonomy.taxeditor.editor.popupmenu.charactermatrix">
         <children xsi:type="menu:HandledMenuItem" xmi:id="_AyHbgLKSEeikjKoOnLFm2w" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.createdefaultdescription" label="%handledmenuitem.label.19" command="_ZHC3oLKVEeikjKoOnLFm2w"/>
         <children xsi:type="menu:HandledMenuItem" xmi:id="_DYlHcLKSEeikjKoOnLFm2w" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.createliteraturedescription" label="%handledmenuitem.label.20" command="_fkPkkLKVEeikjKoOnLFm2w"/>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="__SlnwI97EeqyUKRuXQ8miw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.deletedescription" label="%handledmenuitem.label.28" command="_MYd44I98EeqyUKRuXQ8miw"/>
       </menus>
     </elements>
     <elements xsi:type="basic:PartDescriptor" xmi:id="_XcQMEN8mEee9zP45RW4C3A" elementId="eu.etaxonomy.taxeditor.editor.descriptiveDataSet.DescriptiveDataSetNavigator" label="%partdescriptor.label.5" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.descriptiveDataSet.DescriptiveDataSetNavigator">
       </menus>
       <toolbar xmi:id="_gz3CkPycEeeOqKfc2I-67A" elementId="eu.etaxonomy.taxeditor.editor.toolbar.2"/>
     </elements>
-    <elements xsi:type="basic:PartDescriptor" xmi:id="_KnkUEPemEeiZEKOlcMbiPw" elementId="eu.etaxonomy.taxeditor.editor.view.checklist.e4.DistributionEditorPart" label="Distribution Editor" allowMultiple="true" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.checklist.e4.DistributionEditorPart"/>
+    <elements xsi:type="basic:PartDescriptor" xmi:id="_KnkUEPemEeiZEKOlcMbiPw" elementId="eu.etaxonomy.taxeditor.editor.view.checklist.e4.DistributionEditorPart" label="%partdescriptor.label.6" allowMultiple="true" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.checklist.e4.DistributionEditorPart"/>
   </fragments>
   <fragments xsi:type="fragment:StringModelFragment" xmi:id="__mwtMDVpEee_b7RlBzTDRw" featurename="commands" parentElementId="xpath:/">
     <elements xsi:type="commands:Command" xmi:id="_BjF3ADVqEee_b7RlBzTDRw" elementId="eu.etaxonomy.taxeditor.editor.command.specimeneditor.create_field_unit" commandName="%command.commandname.1"/>
     <elements xsi:type="commands:Command" xmi:id="_tuB4AL9KEemCian_vXpNsA" elementId="eu.etaxonomy.taxeditor.editor.name.swapSynonymAndAcceptedSetNameInSource" commandName="%command.name.611"/>
     <elements xsi:type="commands:Command" xmi:id="_yknsIL9NEemCian_vXpNsA" elementId="eu.etaxonomy.taxeditor.editor.view.descriptive.e4.handler.MoveDescriptionToOtherTaxonHandlerSetNameInSource" commandName="%command.name.131"/>
     <elements xsi:type="commands:Command" xmi:id="__8WFwL9OEemCian_vXpNsA" elementId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.moveDescriptionElementsSetNameInSource" commandName="%command.name.132"/>
+    <elements xsi:type="commands:Command" xmi:id="_MYd44I98EeqyUKRuXQ8miw" elementId="eu.etaxonomy.taxeditor.editor.command.deletedescription" commandName="%command.commandname.24"/>
   </fragments>
   <fragments xsi:type="fragment:StringModelFragment" xmi:id="_pZmusEalEeeXMc6kSYO7Xg" featurename="children" parentElementId="eu.etaxonomy.taxeditor.menu.showView" positionInList="after:eu.etaxonomy.taxeditor.workbench.menuseparator.navigation">
     <elements xsi:type="menu:HandledMenuItem" xmi:id="_FPIHQKNwEeebGZ23ERGMGw" elementId="eu.etaxonomy.taxeditor.editor.showViewMenu.conceptGraph" label="%view.name.3" iconURI="" tooltip="%view.name.3" command="_WPjpoDSnEeek0dKsFNy--Q">
     <elements xsi:type="commands:Handler" xmi:id="_ihC9kJMnEeeR4YRjNqCKeA" elementId="eu.etaxonomy.taxeditor.editor.view.derivate.handler.OpenDerivativeEditorForTaxonNode" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.derivate.handler.OpenDerivativeEditorForTaxonNode" command="_z5Zb4E3kEeivZbtHG8C6kA"/>
     <elements xsi:type="commands:Handler" xmi:id="_SL3mQJMkEeeR4YRjNqCKeA" elementId="eu.etaxonomy.taxeditor.editor.handler.defaultHandler.DefaultOpenSpecimenEditorForTypeSpecimenHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.handler.defaultHandler.DefaultOpenSpecimenEditorForTypeSpecimenHandler" command="_2Bn-EJMjEeeR4YRjNqCKeA"/>
     <elements xsi:type="commands:Handler" xmi:id="_KxUSAE3pEeivZbtHG8C6kA" elementId="eu.etaxonomy.taxeditor.editor.view.derivate.handler.OpenDerivativeEditorForDescriptionElement" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.derivate.handler.OpenDerivativeEditorForDescriptionElement" command="_j2cfsJMmEeeR4YRjNqCKeA"/>
+    <elements xsi:type="commands:Handler" xmi:id="_0bRjII9_EeqyUKRuXQ8miw" elementId="eu.etaxonomy.taxeditor.editor.handler.deleteDescription" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.handler.DeleteDescriptionHandler" command="_MYd44I98EeqyUKRuXQ8miw"/>
   </fragments>
   <fragments xsi:type="fragment:StringModelFragment" xmi:id="_OyvD8KNOEee5fYT78qEx0A" featurename="children" parentElementId="bulkeditor.menus.openmenu" positionInList="last">
     <elements xsi:type="menu:HandledMenuItem" xmi:id="_SZZBkKNOEee5fYT78qEx0A" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.specimen_editor" label="%command.label.DERIVATIVE_EDITOR" tooltip="%command.label.DERIVATIVE_EDITOR" command="_PDjFMLsKEeeQJq8FDGEi1g">
index 326e95bfb0ad65d4e29b25ce421019eace553696..56d538549f26dcef60400ddb30569684ee7c69d7 100644 (file)
@@ -2,15 +2,24 @@
 package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.handler;
 
 import java.util.Iterator;
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
 
 import javax.inject.Named;
 
+import org.eclipse.core.runtime.ICoreRunnable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.e4.core.di.annotations.Execute;
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 import org.eclipse.e4.ui.services.IServiceConstants;
 import org.eclipse.jface.viewers.IStructuredSelection;
 
-import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
+import eu.etaxonomy.cdm.api.application.CdmApplicationState;
+import eu.etaxonomy.cdm.api.service.UpdateResult;
+import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
 import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
 import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.DescriptiveDataSetNavigator;
 import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
@@ -30,8 +39,9 @@ public class DeleteDescriptiveDataSetHandler {
                while(iterator.hasNext()){
                    Object next = iterator.next();
                    if(next instanceof DescriptiveDataSet){
-                           IDescriptiveDataSetService descriptiveDataSetService = CdmStore.getService(IDescriptiveDataSetService.class);
-                           descriptiveDataSetService.delete(((DescriptiveDataSet) next).getUuid());
+//                         IDescriptiveDataSetService descriptiveDataSetService = CdmStore.getService(IDescriptiveDataSetService.class);
+//                         descriptiveDataSetService.delete(((DescriptiveDataSet) next).getUuid());
+                           deleteDescriptiveDataSet(((DescriptiveDataSet) next).getUuid());
                            DescriptiveDataSetNavigator navigator = (DescriptiveDataSetNavigator) object;
                            navigator.removeDescriptiveDataSet((DescriptiveDataSet) next);
                            navigator.getConversationHolder().commit();
@@ -44,4 +54,44 @@ public class DeleteDescriptiveDataSetHandler {
            }
        }
 
+       private void deleteDescriptiveDataSet(UUID descriptiveDataSetUuid){
+        UUID monitorUuid =  CdmApplicationState.getLongRunningTasksService().deleteDescriptiveDataset(descriptiveDataSetUuid);
+
+        String jobLabel = "Delete descriptive dataset";
+        Job job = Job.create(jobLabel, (ICoreRunnable) monitor -> {
+            SubMonitor subMonitor = SubMonitor.convert(monitor);
+            subMonitor.beginTask(jobLabel, IProgressMonitor.UNKNOWN);
+            IRemotingProgressMonitor remotingMonitor;
+            try {
+                remotingMonitor = CdmStore.getProgressMonitorClientManager()
+                        .pollMonitor(jobLabel,
+                                monitorUuid,
+                                50,
+                                null,
+                                (List)null,
+                                subMonitor);
+                Object resultObject = remotingMonitor.getResult();
+                if(resultObject instanceof Exception){
+                    MessagingUtils.errorDialog("Deleting descriptive dataset failed", this, "Deleting descriptive dataset was not successfull", TaxeditorEditorPlugin.PLUGIN_ID, (Exception)resultObject, true, true);
+                }
+                else if(resultObject instanceof UpdateResult){
+                    UpdateResult result = (UpdateResult)resultObject;
+                    if(!result.getExceptions().isEmpty() && result.isOk()){
+                        MessagingUtils.warningDialog(Messages.DeleteDescriptiveDatasetHandler_Warning_Message, this,
+                                String.format(Messages.DeleteDescriptiveDatasetHandler_Warning_Message, result.getExceptions()
+                                        .stream().map(ex->ex.toString())
+                                        .collect(Collectors.joining("\n"))));
+                    }
+
+                }
+            } catch (InterruptedException e) {
+                return;
+            }
+            monitor.done();
+        });
+
+        job.schedule();
+    }
+
+
 }
\ No newline at end of file
index 259eb3255331fcf5f0a1752ba6e3fa54d49c6959..5203cac3eb31da01bfa8dc22c221e2b766ff5780 100644 (file)
@@ -188,6 +188,7 @@ public class CharacterMatrix extends Composite {
     private CharacterMatrixToolbar toolbar;
 
     private DescriptionTreeFormat treeFormat;
+    private List<UUID> descriptionUuidsToDelete;
 
     public CharacterMatrix(Composite parent, CharacterMatrixPart part) {
         super(parent, SWT.NONE);
@@ -722,6 +723,18 @@ public class CharacterMatrix extends Composite {
         part.setDirty();
     }
 
+    public List<UUID> getDescriptionsToDelete() {
+        return descriptionUuidsToDelete;
+    }
+
+    public void putDescriptionToDelete(UUID descriptionToDelete) {
+        if (descriptionUuidsToDelete == null){
+            descriptionUuidsToDelete = new ArrayList();
+        }
+
+        this.descriptionUuidsToDelete.add(descriptionToDelete);
+    }
+
     public CharacterMatrixPart getPart() {
         return part;
     }
index 30a0dfe494f187f5e838c9bdf50d59bd5ec3ed24..841d1c8a266043f81c67d5ecc897c43f2d8bd77a 100644 (file)
@@ -33,7 +33,6 @@ import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 
 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
-import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
 import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 import eu.etaxonomy.cdm.api.service.UpdateResult;
 import eu.etaxonomy.cdm.api.service.description.AggregationMode;
@@ -125,9 +124,11 @@ public class CharacterMatrixBottomToolbar extends Composite{
                     }
                 }
                 toRemove.forEach(rowToRemove -> {
+                    matrix.putDescriptionToDelete(rowToRemove.getDescription().getUuid());
                     matrix.getDescriptions().remove(rowToRemove);
-                    CdmStore.getService(IDescriptiveDataSetService.class).removeDescription(
-                            rowToRemove.getDescription().getUuid(), matrix.getDescriptiveDataSet().getUuid());
+
+//                    CdmStore.getService(IDescriptiveDataSetService.class).removeDescription(
+//                            rowToRemove.getDescription().getUuid(), matrix.getDescriptiveDataSet().getUuid());
                 });
             }
         });
index 956c7989671fb30a121cb26daf64af0d89b57ec0..a584c79cddd319a63dd287261dd44fc3e6196673 100644 (file)
@@ -189,6 +189,7 @@ ICdmEntitySessionEnabled, IPartContentHasSupplementalData, IPartContentHasDetail
         List<DescriptionBase> descriptions = matrix.getRowsToSave().stream()
         .map(row->row.getDescription())
         .collect(Collectors.toList());
+        CdmStore.getService(IDescriptiveDataSetService.class).removeDescriptions(matrix.getDescriptionsToDelete(), matrix.getDescriptiveDataSet().getUuid());
         CdmStore.getService(IDescriptionService.class).merge(descriptions);
 
         matrix.getRowsToSave().clear();
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/handler/DeleteDescriptionHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/handler/DeleteDescriptionHandler.java
new file mode 100755 (executable)
index 0000000..a3afc11
--- /dev/null
@@ -0,0 +1,66 @@
+/**
+* Copyright (C) 2018 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.descriptiveDataSet.matrix.handler;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.core.di.annotations.CanExecute;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.di.UISynchronize;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
+import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
+import eu.etaxonomy.cdm.model.description.SpecimenDescription;
+import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrixPart;
+import eu.etaxonomy.taxeditor.store.StoreUtil;
+
+/**
+ * @author pplitzner
+ * @since Sep 7, 2018
+ *
+ */
+public class DeleteDescriptionHandler{
+
+    @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();
+        SpecimenRowWrapperDTO wrapper = (SpecimenRowWrapperDTO) matrixPart.getSelection().getFirstElement();
+        SpecimenDescription description = wrapper.getDescription();
+
+        boolean ok = matrixPart.getMatrix().getDescriptions().remove(wrapper);
+        matrixPart.getMatrix().putDescriptionToDelete(description.getUuid());
+        matrixPart.getMatrix().update();
+        if (ok){
+            matrixPart.setDirty();
+        }
+    }
+
+    @CanExecute
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+            MHandledMenuItem menuItem){
+
+            CharacterMatrixPart matrixPart = (CharacterMatrixPart) activePart.getObject();
+            DescriptiveDataSet descriptiveDataSet = matrixPart.getDescriptiveDataSet();
+            IStructuredSelection selection = ((CharacterMatrixPart)activePart.getObject()).getSelection();
+
+            boolean canExecute = selection.size()==1
+                    && selection.getFirstElement() instanceof SpecimenRowWrapperDTO;
+            menuItem.setVisible(canExecute);
+            return canExecute;
+
+    }
+}
index 4c8d4152e3751cff6283d1cf9b91cbcf469647b6..ed8b348a6209bcdcd8f050c0d2ce79dcf5ab6013 100644 (file)
@@ -317,6 +317,8 @@ public class Messages extends NLS {
     public static String DistributionEditor_defaultSource;
     public static String FactualDataView_Lable;
     public static String NameFactsDataView_Lable;
+    public static String DeleteDescriptiveDatasetHandler_Warning_Message;
+    public static String DeleteDescriptiveDatasetHandler_Exception_Message;
 
     static {
         // initialize resource bundle
index 2ffd749bea82254be123fe433306a7768b8ce9e8..9f7189970df9bbc850c556e517f15f04ef9cd326 100644 (file)
@@ -295,4 +295,6 @@ ChecklistEditor_SEARCH_TOOLTIP=Textfilter for Taxa
 DistributionEditor_defaultSource=Default Source: 
 ChecklistEditor_REMOVE_DEFAULT_SOURCE=Remove Source
 FactualDataView_Lable=Factual Data
-NameFactsDataView_Lable=Name Facts
\ No newline at end of file
+NameFactsDataView_Lable=Name Facts
+DeleteDescriptiveDatasetHandler_Exception_Message=Descriptive Dataset could not be deleted.
+DeleteDescriptiveDatasetHandler_Warning_Message=Deletion was successful but with warnings. 
\ No newline at end of file
index 8b86535e73aec4bf0837ccc6e4b1627d7fdac49a..6d16cf78b00de85e72593233700330ff4aeb3664 100644 (file)
@@ -294,4 +294,6 @@ ChecklistEditor_SEARCH_TOOLTIP=Textfilter auf Taxa
 DistributionEditor_defaultSource= Standard Quelle: 
 ChecklistEditor_REMOVE_DEFAULT_SOURCE=Quelle entfernen
 FactualDataView_Lable=Faktendaten
-NameFactsDataView_Lable=Namensfaktendaten
\ No newline at end of file
+NameFactsDataView_Lable=Namensfaktendaten
+DeleteDescriptiveDatasetHandler_Exception_Message=Das Descriptive Dataset konnte nicht gelöscht werden.
+DeleteDescriptiveDatasetHandler_Warning_Message=Das Löschen war erfolgreich, es gibt aber Warnungen.
\ No newline at end of file