fix #7324 Add "Open in.." for GatheringEvents in ReferencingObjectsView
authorPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 21 Mar 2018 18:10:48 +0000 (19:10 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 21 Mar 2018 18:11:34 +0000 (19:11 +0100)
eu.etaxonomy.taxeditor.editor/fragment.e4xmi
eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForGatheringEvent.java [new file with mode: 0644]

index feb8e2f1390e3421fab878b0ee6305aa2dfce574..926035c724dac8f74e2c5d7d96881f45193aaaea 100644 (file)
     <elements xsi:type="commands:Command" xmi:id="_XO7eUOSjEee9gvnH2Eirpw" elementId="eu.etaxonomy.taxeditor.editor.command.createWorkingSet" commandName="New Working Set"/>
     <elements xsi:type="commands:Command" xmi:id="_uPmNgOS3EeeKONG__xkGZg" elementId="eu.etaxonomy.taxeditor.editor.command.deleteWorkingSet" commandName="Delete Working Set"/>
     <elements xsi:type="commands:Command" xmi:id="_4k-uYPycEeeOqKfc2I-67A" elementId="eu.etaxonomy.taxeditor.editor.command.refresh" commandName="Refresh"/>
+    <elements xsi:type="commands:Command" xmi:id="_eTTa4C0vEeiiqYcnQ2drEA" elementId="eu.etaxonomy.taxeditor.openSpecimenEditorForGatheringEvent" commandName="Open specimen editor for gathering event"/>
   </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="_Xi9w8K22EeeykrJkROy5EA" elementId="eu.etaxonomy.taxeditor.editor.handler.create.NewNameHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.handler.create.NewNameHandler" command="_1CaG8K21EeeykrJkROy5EA"/>
     <elements xsi:type="commands:Handler" xmi:id="_ahCroK22EeeykrJkROy5EA" elementId="eu.etaxonomy.taxeditor.editor.handler.create.NewTeamHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.handler.create.NewTeamHandler" command="_2vSfgK21EeeykrJkROy5EA"/>
     <elements xsi:type="commands:Handler" xmi:id="_c0Ba4K22EeeykrJkROy5EA" elementId="eu.etaxonomy.taxeditor.editor.handler.create.NewPersonHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.handler.create.NewPersonHandler" command="_4nv18K21EeeykrJkROy5EA"/>
+    <elements xsi:type="commands:Handler" xmi:id="_jkqm0C0vEeiiqYcnQ2drEA" elementId="eu.etaxonomy.taxeditor.editor.view.derivate.handler.OpenDerivativeEditorForGatheringEvent" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.derivate.handler.OpenDerivativeEditorForGatheringEvent" command="_eTTa4C0vEeiiqYcnQ2drEA"/>
   </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 27ef9933f5e930b615ba677e1be6c75ade8fac20..3e1339fba708bf77a7a897f58666539c2c4c0104 100644 (file)
             selection="eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache"
             viewerName="Working Set Editor">
       </viewCommandMapping>
+      <viewCommandMapping
+            commandId="eu.etaxonomy.taxeditor.openSpecimenEditorForGatheringEvent"
+            selection="eu.etaxonomy.cdm.model.occurrence.GatheringEvent"
+            viewerName="%viewCommandMapping.viewerName.SPECIMEN_EDITOR">
+      </viewCommandMapping>
     </extension>
    <extension
          id="eu.etaxonomy.taxeditor.editor.workbench.model"
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForGatheringEvent.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForGatheringEvent.java
new file mode 100644 (file)
index 0000000..d53428c
--- /dev/null
@@ -0,0 +1,50 @@
+package eu.etaxonomy.taxeditor.editor.view.derivate.handler;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+
+import org.eclipse.e4.ui.workbench.modeling.EPartService;
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.cdm.api.service.IEventBaseService;
+import eu.etaxonomy.cdm.api.service.IOccurrenceService;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.common.ICdmBase;
+import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
+import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.l10n.Messages;
+import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
+import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+public class OpenDerivativeEditorForGatheringEvent extends DefaultOpenHandlerBaseE4<GatheringEvent> {
+
+    protected static final String OPEN_DERIVATIVE_EDITOR_FOR_TAXON_NODE_COULD_NOT_OPEN = Messages.OpenDerivativeEditorForTaxonNode_COULD_NOT_OPEN;
+
+    @Override
+    protected GatheringEvent getEntity(UUID uuid) {
+        ICdmBase load = CdmStore.getService(IEventBaseService.class).load(uuid);
+        return HibernateProxyHelper.deproxy(load, GatheringEvent.class );
+    }
+
+    @Override
+    protected void open(GatheringEvent entity, Shell shell, EPartService partService) {
+        Collection<UUID> specimenUuids = new ArrayList<UUID>();
+        List<FieldUnit> fieldUnits = CdmStore.getService(IOccurrenceService.class).getFieldUnitsForGatheringEvent(entity.getUuid());
+        fieldUnits.forEach(fieldUnit->specimenUuids.add(fieldUnit.getUuid()));
+        DerivateViewEditorInput input = new DerivateViewEditorInput(specimenUuids);
+        EditorUtil.openSpecimenEditor(input, modelService, partService, application);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected boolean canExecute(GatheringEvent entity) {
+        return true;
+    }
+
+}