- linked DerivateSearch with DerivateView via double-click (selection does not yet...
authorPatric Plitzner <p.plitzner@bgbm.org>
Tue, 26 Nov 2013 08:29:03 +0000 (08:29 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Tue, 26 Nov 2013 08:29:03 +0000 (08:29 +0000)
.gitattributes
eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenDerivateViewHandler.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateViewEditorInput.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/campanula/derivatesearch/DerivateSearchCompositeController.java

index c14388084fd56544ac9f52e4f56af139b79d0361..5085be8e70ea7b693c113e617ce4a55edae16646 100644 (file)
@@ -362,6 +362,7 @@ eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/CdmAuthorityEditorInput.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/handler/EditCdmAuthoritiesHandler.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/EditNewTaxonHandler.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenDerivateViewHandler.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenParentHandler.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/SaveAllHandler.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/SaveTaxonHandler.java -text
@@ -473,6 +474,7 @@ eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/d
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateLabelProvider.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateMenuPropertyTester.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateViewEditorInput.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptionElementDragListener.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptionElementDropAdapter.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptionElementTransfer.java -text
index ddc7082a68860e418dc34b80ce5e4d663ecbc6a1..a60cd7be3a91d33569e92f046c27394e401fd122 100644 (file)
             id="eu.etaxonomy.taxeditor.editor.group.authority"
             name="Cdm Authority Editor">
       </editor>
+      <editor
+            class="eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"
+            default="false"
+            id="eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"
+            name="Derivate View">
+      </editor>
    </extension>
       <extension
             point="org.eclipse.ui.views">
                name="Concept Graph"
                restorable="true">
          </view>
-         <view
-               allowMultiple="false"
-               category="eu.etaxonomy.taxeditor.editor.category"
-               class="eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"
-               icon="icons/leaf_detail.png"
-               id="eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"
-               name="Derivate View"
-               restorable="true">
-         </view>
          <category
                id="eu.etaxonomy.taxeditor.editor.category"
                name="Taxonomic Editor">
             id="eu.etaxonomy.taxeditor.group.cdmauthorities.edit"
             name="Edit CDM Authorities">
       </command>
+      <command
+            defaultHandler="eu.etaxonomy.taxeditor.editor.handler.OpenDerivateViewHandler"
+            id="eu.etaxonomy.taxeditor.editor.handler.openDerivateView"
+            name="Open Derivate View">
+      </command>
    </extension>
    <extension
          point="org.eclipse.core.expressions.definitions">
index a951ef9030fb6dfa797c384340a67361a46f2350..135d2a7bfd32d638ab47cfba472d9d03cb05c35f 100644 (file)
@@ -1,8 +1,8 @@
 /**
  * Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy 
+ * 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.
  */
@@ -31,11 +31,13 @@ import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditorInput;
 import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
 import eu.etaxonomy.taxeditor.editor.key.KeyEditor;
 import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorInput;
+import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
+import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 
 /**
  * Utility for the editor package
- * 
+ *
  * @author n.hoffmann
  * @created 20.01.2009
  * @version 1.0
@@ -46,7 +48,7 @@ public class EditorUtil extends AbstractUtility {
 
        /**
         * Opens a new editor window with the given input
-        * 
+        *
         * @param input
         * @param editorId
         * @return
@@ -60,7 +62,7 @@ public class EditorUtil extends AbstractUtility {
 
        /**
         * Opens a new editor window with the given TaxonEditorInput
-        * 
+        *
         * @param input
         *            a {@link eu.etaxonomy.taxeditor.editor.TaxonEditorInput}
         *            object.
@@ -75,16 +77,26 @@ public class EditorUtil extends AbstractUtility {
                        throws PartInitException {
                open(input, KeyEditor.ID);
        }
-       
+
        public static void open(CdmAuthorityEditorInput input)
                        throws PartInitException {
                open(input, CdmAuthorityEditor.ID);
        }
 
+       /**
+        * Opens a new DerivateView for the given input
+        * @param input a {@link DerivateViewEditorInput} representing the selected derivate
+        * @throws PartInitException
+        */
+       public static void open(DerivateViewEditorInput input)
+               throws PartInitException {
+           open(input, DerivateView.ID);
+       }
+
        /**
         * Taxon Editors may be opened by supplying a taxon node uuid. Session gets
         * initialised here and is passed to the editor
-        * 
+        *
         * @param taxonNodeUuid
         *            a {@link java.util.UUID} object.
         * @throws java.lang.Exception
@@ -99,7 +111,7 @@ public class EditorUtil extends AbstractUtility {
         * <p>
         * openTaxonBase
         * </p>
-        * 
+        *
         * @param taxonBaseUuid
         *            a {@link java.util.UUID} object.
         * @throws org.eclipse.ui.PartInitException
@@ -116,7 +128,7 @@ public class EditorUtil extends AbstractUtility {
         * <p>
         * findEditorByTaxonNodeUuid
         * </p>
-        * 
+        *
         * @param taxonNodeUuid
         *            a {@link java.util.UUID} object.
         * @return a {@link org.eclipse.ui.IEditorPart} object.
@@ -133,7 +145,7 @@ public class EditorUtil extends AbstractUtility {
         * An uninitialized taxon is one that hasn't been saved yet. As such, it
         * should appear in neither the list of recent names nor in the taxonomic
         * tree when opened.
-        * 
+        *
         * @throws org.eclipse.ui.PartInitException
         *             if any.
         * @param parentNodeUuid
@@ -152,7 +164,7 @@ public class EditorUtil extends AbstractUtility {
         * <p>
         * setSaving
         * </p>
-        * 
+        *
         * @param isSaving
         *            a boolean.
         */
@@ -164,7 +176,7 @@ public class EditorUtil extends AbstractUtility {
         * <p>
         * isSaving
         * </p>
-        * 
+        *
         * @return a boolean.
         */
        public static boolean isSaving() {
@@ -173,7 +185,7 @@ public class EditorUtil extends AbstractUtility {
 
        /**
         * Returns a set of all currently open <code>MultiPageTaxonEditor</code>s.
-        * 
+        *
         * @return a {@link java.util.Set} object.
         */
        public static Set<IEditorPart> getOpenEditors() {
@@ -194,7 +206,7 @@ public class EditorUtil extends AbstractUtility {
 
        /**
         * Returns the currently active taxon editor
-        * 
+        *
         * @return the taxon editor that has focus
         */
        public static MultiPageTaxonEditor getActiveMultiPageTaxonEditor() {
@@ -211,7 +223,7 @@ public class EditorUtil extends AbstractUtility {
         * <p>
         * getActiveEditorPage
         * </p>
-        * 
+        *
         * @param page
         *            a {@link eu.etaxonomy.taxeditor.editor.Page} object.
         * @return a {@link org.eclipse.ui.IEditorPart} object.
@@ -224,7 +236,7 @@ public class EditorUtil extends AbstractUtility {
 
        /**
         * Returns the selection of the currently active taxon editor
-        * 
+        *
         * @return a {@link org.eclipse.jface.viewers.ISelection} object.
         */
        public static ISelection getCurrentSelection() {
@@ -240,7 +252,7 @@ public class EditorUtil extends AbstractUtility {
         * <p>
         * getUndoContext
         * </p>
-        * 
+        *
         * @param editor
         *            a {@link eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor}
         *            object.
@@ -255,7 +267,7 @@ public class EditorUtil extends AbstractUtility {
         * <p>
         * getUndoContext
         * </p>
-        * 
+        *
         * @return a {@link org.eclipse.core.commands.operations.IUndoContext}
         *         object.
         */
@@ -267,7 +279,7 @@ public class EditorUtil extends AbstractUtility {
         * <p>
         * forceUserSave
         * </p>
-        * 
+        *
         * @param editor
         *            a {@link org.eclipse.ui.IEditorPart} object.
         * @param shell
@@ -295,7 +307,7 @@ public class EditorUtil extends AbstractUtility {
         * <p>
         * getSelection
         * </p>
-        * 
+        *
         * @param event
         *            a {@link org.eclipse.core.commands.ExecutionEvent} object.
         * @return a {@link org.eclipse.jface.viewers.IStructuredSelection} object.
@@ -311,7 +323,7 @@ public class EditorUtil extends AbstractUtility {
         * <p>
         * getPluginId
         * </p>
-        * 
+        *
         * @return a {@link java.lang.String} object.
         */
        public static String getPluginId() {
@@ -324,7 +336,7 @@ public class EditorUtil extends AbstractUtility {
                                .NewInstance(polytomousKeyUuid);
                open(input);
        }
-       
+
        public static void openCdmAuthorities(UUID groupUuid)
                        throws Exception {
                CdmAuthorityEditorInput input = CdmAuthorityEditorInput.NewInstance(groupUuid);
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenDerivateViewHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenDerivateViewHandler.java
new file mode 100644 (file)
index 0000000..5c8977d
--- /dev/null
@@ -0,0 +1,39 @@
+package eu.etaxonomy.taxeditor.editor.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import eu.etaxonomy.cdm.model.common.ICdmBase;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+
+public class OpenDerivateViewHandler extends AbstractHandler {
+
+    /* (non-Javadoc)
+     * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+     */
+    @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+        ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
+        if(currentSelection instanceof IStructuredSelection){
+            Object selectedElement = ((IStructuredSelection) currentSelection).getFirstElement();
+            if(selectedElement instanceof ICdmBase){
+                DerivateViewEditorInput input = new DerivateViewEditorInput(((ICdmBase) selectedElement).getUuid());
+                try {
+                    EditorUtil.open(input);
+                } catch (PartInitException e) {
+                    AbstractUtility.error(OpenDerivateViewHandler.class, "Could not open DerivateView", e);
+                }
+            }
+        }
+        return null;
+
+    }
+
+}
index 8910a5ee7f67c0ad3aaaf99a544ee9e3508999d2..24154d93b2ce380ab973e189117e0b04fd00eaf5 100644 (file)
@@ -74,8 +74,7 @@ public class DerivateView extends EditorPart implements IPartContentHasDetails,
      */
     @Override
     public void init(IEditorSite site, IEditorInput input) throws PartInitException {
-        // TODO Auto-generated method stub
-
+        viewer.setInput(input);
     }
 
     /* (non-Javadoc)
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateViewEditorInput.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateViewEditorInput.java
new file mode 100644 (file)
index 0000000..bf09a14
--- /dev/null
@@ -0,0 +1,125 @@
+// $Id$
+/**
+* Copyright (C) 2013 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.view.derivate;
+
+import java.util.UUID;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+/**
+ * @author pplitzner
+ * @date 25.11.2013
+ *
+ */
+public class DerivateViewEditorInput implements IEditorInput {
+
+    private final UUID uuid;
+
+    /**
+     * @param uuid
+     */
+    public DerivateViewEditorInput(UUID uuid) {
+        super();
+        this.uuid = uuid;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+     */
+    @Override
+    public Object getAdapter(Class adapter) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#exists()
+     */
+    @Override
+    public boolean exists() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+     */
+    @Override
+    public ImageDescriptor getImageDescriptor() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getName()
+     */
+    @Override
+    public String getName() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getPersistable()
+     */
+    @Override
+    public IPersistableElement getPersistable() {
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getToolTipText()
+     */
+    @Override
+    public String getToolTipText() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
+        return result;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        DerivateViewEditorInput other = (DerivateViewEditorInput) obj;
+        if (uuid == null) {
+            if (other.uuid != null) {
+                return false;
+            }
+        } else if (!uuid.equals(other.uuid)) {
+            return false;
+        }
+        return true;
+    }
+
+}
index a6583d19eeed80f5c0ee34f2901b1e8be37d5551..3513d823271e424ee44eda0d48d647a6c9f1756d 100644 (file)
@@ -11,6 +11,10 @@ package eu.etaxonomy.taxeditor.ui.campanula.derivatesearch;
 
 import java.util.List;
 
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.NotEnabledException;
+import org.eclipse.core.commands.NotHandledException;
+import org.eclipse.core.commands.common.NotDefinedException;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
@@ -18,10 +22,13 @@ import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.KeyAdapter;
 import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.ui.handlers.IHandlerService;
 
+import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeCacheStrategy;
 import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
 import eu.etaxonomy.cdm.api.service.config.IdentifiableServiceConfiguratorImpl;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
@@ -31,8 +38,8 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  */
 public class DerivateSearchCompositeController {
 
-    private DerivateSearchComposite derivateSearchComposite;
-    private IIdentifiableEntityServiceConfigurator<SpecimenOrObservationBase<?>> configurator;
+    private final DerivateSearchComposite derivateSearchComposite;
+    private IIdentifiableEntityServiceConfigurator<SpecimenOrObservationBase<DerivedUnitFacadeCacheStrategy>> configurator;
 
     /**
      * @param derivateSearchComposite
@@ -63,11 +70,25 @@ public class DerivateSearchCompositeController {
         resultViewer.addDoubleClickListener(new IDoubleClickListener() {
             @Override
             public void doubleClick(DoubleClickEvent event) {
-//                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, editorId);
+                String commandId = "eu.etaxonomy.taxeditor.editor.handler.openDerivateView";
+
+                IHandlerService handlerService = (IHandlerService) AbstractUtility.getService(IHandlerService.class);
+                try {
+                    handlerService.executeCommand(commandId, null);
+                } catch (ExecutionException e) {
+                    AbstractUtility.error(DerivateSearchCompositeController.class, e);
+                } catch (NotDefinedException e) {
+                    AbstractUtility.error(DerivateSearchCompositeController.class, e);
+                } catch (NotEnabledException e) {
+                    AbstractUtility.error(DerivateSearchCompositeController.class, e);
+                } catch (NotHandledException e) {
+                    AbstractUtility.error(DerivateSearchCompositeController.class, e);
+                }
+
             }
         });
 
-        configurator = new IdentifiableServiceConfiguratorImpl<SpecimenOrObservationBase<?>>();
+        configurator = new IdentifiableServiceConfiguratorImpl<SpecimenOrObservationBase<DerivedUnitFacadeCacheStrategy>>();
     }
 
     private void searchDerivates(String searchString){