Merge branch 'develop' into unify_derivative_views
authorPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 11 Nov 2015 10:07:36 +0000 (11:07 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 11 Nov 2015 10:07:36 +0000 (11:07 +0100)
40 files changed:
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/DerivatePerspective.java
eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin.properties
eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_de.properties
eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_en.properties
eu.etaxonomy.taxeditor.editor/icons/synced.gif [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenDerivateViewHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/create/NewSpecimenHandler.java [deleted file]
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
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/contextMenu/CreateFieldUnitContextMenu.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/contextMenu/DerivateViewContextMenu.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/CreateFieldUnitHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/ListenToSelectionChangeHandler.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/operation/DeleteDerivateOperation.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/searchFilter/DerivateSearchComposite.java [moved from eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateSearchComposite.java with 60% similarity]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/searchFilter/DerivateSearchCompositeController.java [moved from eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateSearchCompositeController.java with 61% similarity]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveViewPart.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/handler/AddImageGalleryHandler.java
eu.etaxonomy.taxeditor.store/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.store/plugin.xml
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewDerivedUnitBaseWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/IPreferenceKeys.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/SpecimenOrObservationPreferences.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionDialogFactory.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SpecimenOrObservationBaseSelectionDialog.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractFormSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/detail/IndividualsAssociationDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/association/DerivedUnitTypeDesignationElement.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/association/DerivedUnitTypeDesignationSection.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/association/TaxonAssociationDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EditFromSelectionWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/AbstractCdmViewPart.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateContentProvider.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateLabelProvider.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateSearchView.java [deleted file]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewPart.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java

index b7e8509325d8fc11a5d1aac3eac2a9ea2a7063de..1033f0c7ca10070bf6fd67d578840c3a90be257b 100644 (file)
@@ -13,9 +13,9 @@ import org.eclipse.ui.IPageLayout;
 import org.eclipse.ui.IPlaceholderFolderLayout;
 import org.eclipse.ui.progress.IProgressConstants;
 
+import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
 import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
-import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateSearchView;
 import eu.etaxonomy.taxeditor.view.datasource.CdmDataSourceViewPart;
 import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
 
@@ -30,16 +30,13 @@ public class DerivatePerspective extends Default {
 
     public static final String ADDITIONAL = "additional";
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
-     */
     @Override
     public void createInitialLayout(IPageLayout layout) {
         layout.addView(TaxonNavigator.ID, IPageLayout.LEFT, 0.25f, layout.getEditorArea());
 
         layout.addView(DetailsViewPart.ID, IPageLayout.RIGHT, 0.6f, layout.getEditorArea());
 
-        layout.addView(DerivateSearchView.ID, IPageLayout.TOP, 0.5f, layout.getEditorArea());
+        layout.addView(DerivateView.ID, IPageLayout.BOTTOM, 0.5f, layout.getEditorArea());
 
         layout.addView(DescriptiveViewPart.ID, IPageLayout.BOTTOM, 0.6f, TaxonNavigator.ID);
 
index 666680ec6119fe0d78b969e1a4697ea34ff29def..b41d0021e3f04873cc1ca802991898713ff7ae6d 100644 (file)
@@ -15,6 +15,7 @@ Export-Package: eu.etaxonomy.taxeditor.editor,
  eu.etaxonomy.taxeditor.editor.name.operation,
  eu.etaxonomy.taxeditor.editor.view.concept,
  eu.etaxonomy.taxeditor.editor.view.dataimport,
+ eu.etaxonomy.taxeditor.editor.view.derivate,
  eu.etaxonomy.taxeditor.editor.view.descriptive,
  eu.etaxonomy.taxeditor.editor.view.media,
  eu.etaxonomy.taxeditor.editor.view.uses
index 55c9c006b7565d7affc579117b18ac9f03a0db96..d6cc82eab6afb4ebd88098025c85e00b3b2df4ea 100644 (file)
@@ -101,7 +101,6 @@ command.name.23 = New Reference
 command.name.24 = New Name\r
 command.name.25 = New Team\r
 command.name.26 = New Person\r
-command.name.27 = New Specimen\r
 category.name.5 = -- Polytomous Keys\r
 command.name.28 = New Child Node\r
 command.name.29 = New Sibling Node\r
@@ -162,4 +161,4 @@ Bundle-Name = Editor Bundle
 command.name.48 = delete\r
 command.name.49 = delete\r
 command.name.50 = delete\r
-command.name.51 = delete
\ No newline at end of file
+command.name.51 = delete
index a4d096a11d103606e828005e75ba6cb461142e33..c571435e16f208ab3c24daf53eec7b592b672210 100644 (file)
@@ -101,7 +101,6 @@ command.name.23 = Neue Referenz
 command.name.24 = Neuer Name
 command.name.25 = Neues Team
 command.name.26 = Neue Person
-command.name.27 = Neuer Beleg
 category.name.5 = -- Polytomer Bestimmungsschl\u00fcssel
 command.name.28 = Neue Kinderknoten
 command.name.29 = Neuer Geschwisterknoten
index 17a5b049048252c4a6b4c41bee895d67cbf1b017..80f1ca7e6793865ed51fa89e5fdfc299675244c1 100644 (file)
@@ -100,7 +100,6 @@ command.name.23 = New Reference
 command.name.24 = New Name\r
 command.name.25 = New Team\r
 command.name.26 = New Person\r
-command.name.27 = New Specimen\r
 category.name.5 = -- Polytomous Keys\r
 command.name.28 = New Child Node\r
 command.name.29 = New Sibling Node\r
diff --git a/eu.etaxonomy.taxeditor.editor/icons/synced.gif b/eu.etaxonomy.taxeditor.editor/icons/synced.gif
new file mode 100644 (file)
index 0000000..870934b
Binary files /dev/null and b/eu.etaxonomy.taxeditor.editor/icons/synced.gif differ
index 8a6792b11c6b2dafeb36e86c7e647bd009b09c97..4d31b47f48c470435630df20f0705bd28fbf6656 100644 (file)
             id="eu.etaxonomy.taxeditor.editor.group.authority"
             name="%editor.name.4">
       </editor>
-      <editor
-            class="eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"
-            default="false"
-            icon="icons/derivate_view-16x16-32.png"
-            id="eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"
-            name="%editor.name.5">
-      </editor>
       <editor
             class="eu.etaxonomy.taxeditor.editor.view.dataimport.SpecimenImportEditor"
             default="false"
                id="eu.etaxonomy.taxeditor.editor.view.validation.problems"
                name="%view.name.6">
          </view>
+         <view
+               class="eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"
+               icon="icons/derivate_view-16x16-32.png"
+               id="eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"
+               name="Derivative Editor"
+               restorable="true">
+         </view>
       </extension>
       
        <!-- VALIDATION RELATED STUFF -->
                name="eu.etaxonomy.navigation.menu.new.separator2"
                visible="true">
          </separator>
-         <command
-               commandId="eu.etaxonomy.taxeditor.editor.command.new.specimen"
-               label="%command.label.3"
-               style="push">
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
-         </command>
          <separator
                name="eu.etaxonomy.navigation.menu.new.separator3"
                visible="true">
       </menuContribution>
       <menuContribution
             locationURI="menu:eu.etaxonomy.taxeditor.menu.showView?before=eu.etaxonomy.taxeditor.store.showViewMenu.details">
-         <separator
-               name="eu.etaxonomy.taxeditor.editor.showViewMenu"
-               visible="true">
-         </separator>
          <command
                commandId="org.eclipse.ui.views.showView"
                label="%command.label.4"
                </and>
             </visibleWhen>
          </command>
+         <separator
+               name="eu.etaxonomy.taxeditor.store.separator_derivative_start"
+               visible="true">
+         </separator>
+         <command
+               commandId="eu.etaxonomy.taxeditor.editor.openSpecimenEditor"
+               label="Derivative Editor"
+               style="push">
+            <visibleWhen
+                  checkEnabled="true">
+               <reference
+                     definitionId="isCdmStoreConnected">
+               </reference>
+            </visibleWhen>
+         </command>
+         <separator
+               name="eu.etaxonomy.taxeditor.editor.separator1"
+               visible="true">
+         </separator>
+      </menuContribution>
+      <menuContribution
+            locationURI="menu:eu.etaxonomy.taxeditor.menu.showView?after=org.eclipse.ui.views.showView.supplemental">
+         <separator
+               name="eu.etaxonomy.taxeditor.store.showViewMenu.validation.separator"
+               visible="true">
+         </separator>
+         <command
+               commandId="org.eclipse.ui.views.showView"
+               label="%command.name.40"
+               style="push">
+            <parameter
+                  name="org.eclipse.ui.views.showView.viewId"
+                  value="eu.etaxonomy.taxeditor.editor.view.validation.problems">
+            </parameter>
+            <visibleWhen
+                  checkEnabled="true">
+               <reference
+                     definitionId="isCdmStoreConnected">
+               </reference>
+            </visibleWhen>
+         </command>
       </menuContribution>
       <menuContribution
             locationURI="menu:org.eclipse.ui.main.menu.navigate">
                label="%command.label.52"
                style="push">
          </command>
-         <command
-               commandId="eu.etaxonomy.taxeditor.editor.derivate.createFieldUnit"
-               label="%command.label.53"
-               style="push">
-         </command>
          <command
                commandId="eu.etaxonomy.taxeditor.editor.derivate.deepDelete"
                icon="icons/deep-delete-16x16-32.png"
       </menuContribution>
       <menuContribution
             allPopups="false"
-            locationURI="popup:eu.etaxonomy.taxeditor.navigation.navigatorpopup?after=taxeditor-navigation.separator2">
+            locationURI="toolbar:eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView">
          <command
-               commandId="eu.etaxonomy.taxeditor.editor.handler.openDerivateView"
-               label="%command.label.55"
-               style="push">
+               commandId="eu.etaxonomy.taxeditor.editor.derivative.listenToSelectionChange"
+               icon="icons/synced.gif"
+               label="Link with Taxon Editor"
+               style="toggle">
             <visibleWhen
                   checkEnabled="false">
-               <and>
-                  <reference
-                        definitionId="isCdmStoreConnected">
-                  </reference>
-                  <reference
-                        definitionId="isTaxonNode">
-                  </reference>
-               </and>
-            </visibleWhen>
-         </command>
-         <separator
-               name="eu.etaxonomy.taxeditor.editor.separator1"
-               visible="true">
-         </separator>
-      </menuContribution>
-      <menuContribution
-            locationURI="menu:eu.etaxonomy.taxeditor.menu.showView?after=org.eclipse.ui.views.showView.supplemental">
-         <separator
-               name="eu.etaxonomy.taxeditor.store.showViewMenu.validation.separator"
-               visible="true">
-         </separator>
-         <command
-               commandId="org.eclipse.ui.views.showView"
-               label="%command.name.40"
-               style="push">
-            <parameter
-                  name="org.eclipse.ui.views.showView.viewId"
-                  value="eu.etaxonomy.taxeditor.editor.view.validation.problems">
-            </parameter>
-            <visibleWhen
-                  checkEnabled="true">
                <reference
                      definitionId="isCdmStoreConnected">
                </reference>
             id="eu.etaxonomy.taxeditor.editor.command.new.person"
             name="%command.name.26">
       </command>
-      <command
-            categoryId="eu.etaxonomy.taxeditor.editor.new.category"
-            defaultHandler="eu.etaxonomy.taxeditor.editor.handler.create.NewSpecimenHandler"
-            id="eu.etaxonomy.taxeditor.editor.command.new.specimen"
-            name="%command.name.27">
-      </command>
       <category
             id="eu.etaxonomy.taxeditor.editor.key.category"
             name="%category.name.5">
       <command
             defaultHandler="eu.etaxonomy.taxeditor.editor.handler.OpenDerivateViewHandler"
             id="eu.etaxonomy.taxeditor.editor.openSpecimenEditor"
-            name="Open Specimen Editor">
+            name="Open Derivative Editor">
          <commandParameter
                id="eu.etaxonomy.taxeditor.specimenUuidParameter"
                name="Specimen UUID parameter"
                typeId="eu.etaxonomy.taxeditor.specimenUuidParameterType">
          </commandParameter>
       </command>
+      <command
+            defaultHandler="eu.etaxonomy.taxeditor.editor.view.derivate.handler.ListenToSelectionChangeHandler"
+            id="eu.etaxonomy.taxeditor.editor.derivative.listenToSelectionChange"
+            name="Link with editor">
+      </command>
         
    </extension>
    <extension
index 9094200090805c610265ff7987a10c49498462d7..04307863d72e1f37b23bd45899aae9e0089015d5 100644 (file)
@@ -1,71 +1,17 @@
 package eu.etaxonomy.taxeditor.editor.handler;
 
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.UUID;
-
 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.description.IndividualsAssociation;
-import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
 
 public class OpenDerivateViewHandler extends AbstractHandler {
 
     @Override
     public Object execute(ExecutionEvent event) throws ExecutionException {
-        Set<UUID> selectedElementUUIDs = new HashSet<UUID>();
-        Object parameter;
-        //check if parameter is set
-        try {
-            parameter = event.getObjectParameterForExecution("eu.etaxonomy.taxeditor.specimenUuidParameter");
-        } catch (ExecutionException e) {
-            parameter = null;
-        }
-        if(parameter instanceof UUID){
-            selectedElementUUIDs.add((UUID) parameter);
-        }
-        else{
-            //if not, try with current selection
-            ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
-            if(currentSelection instanceof IStructuredSelection){
-                Iterator<?> selectionIterator = ((IStructuredSelection) currentSelection).iterator();
-                while(selectionIterator.hasNext()){
-                    Object object = selectionIterator.next();
-                    if(object instanceof SpecimenOrObservationBase<?>){
-                        selectedElementUUIDs.add(((SpecimenOrObservationBase<?>) object).getUuid());
-                    }
-                    else if(object instanceof IndividualsAssociation){
-                        SpecimenOrObservationBase specimen = ((IndividualsAssociation) object).getAssociatedSpecimenOrObservation();
-                        if(specimen!=null){
-                            selectedElementUUIDs.add(specimen.getUuid());
-                        }
-                    }
-                }
-            }
-        }
-        if(!selectedElementUUIDs.isEmpty()){
-            DerivateViewEditorInput input = new DerivateViewEditorInput(selectedElementUUIDs);
-            try {
-                EditorUtil.open(input);
-            } catch (PartInitException e) {
-                MessagingUtils.error(OpenDerivateViewHandler.class, "Could not open Derivative Editor", e);
-            } catch (NullPointerException npe){
-                MessagingUtils.messageDialog("Failed to open Editor", OpenDerivateViewHandler.class, "Could not open Derivative Editor. The derivate hierarchy is corrupted!", npe);
-            }
-        }
-        else{
-            MessagingUtils.informationDialog("Empty selection", "No Specimen selected.");
-        }
+        AbstractUtility.showView(DerivateView.ID);
         return null;
     }
 
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/create/NewSpecimenHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/create/NewSpecimenHandler.java
deleted file mode 100644 (file)
index dbd3353..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-// $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.handler.create;
-
-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.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.taxeditor.newWizard.NewDerivedUnitBaseWizard;
-
-/**
- * @author n.hoffmann
- * @created Jun 16, 2010
- * @version 1.0
- */
-public class NewSpecimenHandler extends AbstractHandler {
-       private static final Logger logger = Logger
-                       .getLogger(NewSpecimenHandler.class);
-
-       /** {@inheritDoc} */
-       @Override
-    public Object execute(ExecutionEvent event) throws ExecutionException {
-
-           //TODO: we need to discuss how specimens should be created and handled #5244
-//         ConversationHolder conversation = CdmStore.createConversation();
-//         conversation.bind();
-//         FieldUnit fieldUnit = FieldUnit.NewInstance();
-//         DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
-//         DerivationEvent.NewSimpleInstance(fieldUnit, derivedUnit, DerivationEventType.GATHERING_IN_SITU());
-//         fieldUnit.setCacheStrategy(new DerivedUnitFacadeFieldUnitCacheStrategy());
-//         derivedUnit.setCacheStrategy(new DerivedUnitFacadeCacheStrategy());
-//        CdmStore.getService(IOccurrenceService.class).save(fieldUnit);
-//        CdmStore.getService(IOccurrenceService.class).save(derivedUnit);
-//        conversation.commit();
-//        DerivateViewEditorInput input = new DerivateViewEditorInput(Collections.singleton(fieldUnit.getUuid()));
-//        try {
-//            EditorUtil.open(input);
-//        } catch (PartInitException e) {
-//            // TODO Auto-generated catch block
-//            e.printStackTrace();
-//        }
-               NewDerivedUnitBaseWizard wizard = new NewDerivedUnitBaseWizard();
-               wizard.init(null, null);
-               WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
-               dialog.open();
-               return null;
-       }
-}
index ec05a6b1d5421ca11cec44955593be749b3237c1..178c3f7f598010b1214797bbf3a6fbbe254c1991 100644 (file)
@@ -1,17 +1,21 @@
 package eu.etaxonomy.taxeditor.editor.view.derivate;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Map.Entry;
+import java.util.List;
+import java.util.Map;
 import java.util.Set;
+import java.util.UUID;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.util.LocalSelectionTransfer;
 import org.eclipse.jface.viewers.AbstractTreeViewer;
 import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TreeNode;
 import org.eclipse.jface.viewers.TreeSelection;
@@ -19,32 +23,37 @@ import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.dnd.DND;
 import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.part.EditorPart;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.ISaveablePart2;
+import org.eclipse.ui.IWorkbenchPart;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
-import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
-import eu.etaxonomy.cdm.api.service.molecular.ISequenceService;
+import eu.etaxonomy.cdm.api.service.IOccurrenceService;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.molecular.Sequence;
 import eu.etaxonomy.cdm.model.molecular.SingleRead;
+import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.editor.Messages;
-import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
+import eu.etaxonomy.taxeditor.editor.view.derivate.searchFilter.DerivateSearchCompositeController;
+import eu.etaxonomy.taxeditor.model.IContextListener;
 import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
 import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
 import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
-import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
 import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
 import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateContentProvider;
 import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
 
@@ -52,15 +61,29 @@ import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
  * Displays the derivate hierarchy of the specimen specified in the editor input.
  *
  */
-public class DerivateView extends EditorPart implements IPartContentHasFactualData, IDirtyMarkable,
-        IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IPartContentHasMedia,
-        ISelectionChangedListener, IPostOperationEnabled{
-
+public class DerivateView extends AbstractCdmViewPart implements IPartContentHasFactualData, ISaveablePart2,
+        IPartContentHasDetails, IPartContentHasSupplementalData, IPartContentHasMedia, IContextListener {
     public static final String ID = "eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"; //$NON-NLS-1$
 
     public static final String YOU_NEED_TO_SAVE_BEFORE_PERFORMING_THIS_ACTION = Messages.DerivateView_YOU_NEED_TO_SAVE;
     public static final String VIEW_HAS_UNSAVED_CHANGES = Messages.DerivateView_UNSAVED_CHANGES;
 
+    private static final List<String> SPECIMEN_INIT_STRATEGY = Arrays.asList(new String[] {
+            "descriptions",
+            "annotations",
+            "markers",
+            "credits",
+            "extensions",
+            "rights",
+            "sources",
+            "derivationEvents.derivatives.annotations",
+            "derivationEvents.derivatives.markers",
+            "derivationEvents.derivatives.credits",
+            "derivationEvents.derivatives.extensions",
+            "derivationEvents.derivatives.rights",
+            "derivationEvents.derivatives.sources"
+    });
+
        private ConversationHolder conversation;
 
        private TreeViewer viewer;
@@ -71,32 +94,88 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
 
     private DerivateLabelProvider labelProvider;
 
-    private Set<SingleRead> multiLinkSingleReads;
+    private DerivateContentProvider contentProvider;
 
-    private ISelection selection = null;
+    private DerivateSearchCompositeController derivateSearchCompositeController;
 
+    /**
+     * A map with keys being the derivative entities belonging to the {@link UUID}s passed to the constructor
+     * and values being the root elements of the hierarchy (may be the same objects as the derivative entities)
+     */
+    private Map<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>> derivateToRootEntityMap;
 
-    private DerivateContentProvider contentProvider;
+    /**
+     * The set of root elements
+     */
+    private Set<SpecimenOrObservationBase<?>> rootElements;
+
+    private ICdmEntitySession cdmEntitySession;
+
+    /**
+     * <code>true</code> if this view is listening to selection  changes
+     */
+    private boolean listenToSelectionChange;
+
+    private Taxon selectedTaxon;
 
     /**
      * Default constructor
      */
     public DerivateView() {
+        init();
+    }
+
+    /**
+     *
+     */
+    private void init() {
+        this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
+        this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
+
+        if (CdmStore.isActive() && conversation == null) {
+            conversation = CdmStore.createConversation();
+        }
+        if (CdmStore.isActive()) {
+            cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
+        }
+        //listen to context changes
+        CdmStore.getContextManager().addContextListener(this);
     }
 
     @Override
     public void createPartControl(Composite parent) {
+
+        parent.setLayout(new GridLayout());
+
+        //---search and filter---
+        derivateSearchCompositeController = new DerivateSearchCompositeController(parent, this);
+        GridData gridDataSearchBar = new GridData();
+        gridDataSearchBar.horizontalAlignment = GridData.FILL;
+        gridDataSearchBar.grabExcessHorizontalSpace = true;
+        derivateSearchCompositeController.setLayoutData(gridDataSearchBar);
+        derivateSearchCompositeController.setEnabled(CdmStore.isActive());
+
+        //---tree viewer---
         viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
+        GridData gridDataTree = new GridData();
+        gridDataTree.horizontalAlignment = GridData.FILL;
+        gridDataTree.verticalAlignment = GridData.FILL;
+        gridDataTree.grabExcessVerticalSpace = true;
+        gridDataTree.grabExcessHorizontalSpace = true;
+        viewer.getTree().setLayoutData(gridDataTree);
         contentProvider = new DerivateContentProvider();
         viewer.setContentProvider(contentProvider);
         labelProvider = new DerivateLabelProvider();
         labelProvider.setConversation(conversation);
         viewer.setLabelProvider(labelProvider);
         viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
+        viewer.getTree().setEnabled(CdmStore.isActive());
         // Propagate selection from viewer
         getSite().setSelectionProvider(viewer);
+
         //listen to selection changes
-        viewer.addSelectionChangedListener(this);
+        selectionService = getSite().getWorkbenchWindow().getSelectionService();
+        selectionService.addSelectionListener(this);
 
         //create context menu
         MenuManager menuManager = new MenuManager();
@@ -105,20 +184,8 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         Menu menu = menuManager.createContextMenu(control);
         control.setMenu(menu);
 
-        generateMultiLinkSingleReads();
-        labelProvider.setMultiLinkSingleReads(multiLinkSingleReads);
-        IEditorInput editorInput = getEditorInput();
-        viewer.setInput(((DerivateViewEditorInput) editorInput).getRootEntities());
-        //set selection to selected derivate if only one was selected
-        if(editorInput instanceof DerivateViewEditorInput){
-            Set<SpecimenOrObservationBase<?>> derivateEntities = ((DerivateViewEditorInput) editorInput).getDerivateEntities();
-            if(derivateEntities.size()==1){
-                SpecimenOrObservationBase<?> specimen = derivateEntities.iterator().next();
-                if(specimen != null){
-                    viewer.setSelection(new StructuredSelection(new TreeNode(specimen)));
-                }
-            }
-        }
+        //init tree
+        updateRootEntities();
 
         //add drag'n'drop support
         Transfer[] transfers = new Transfer[] {LocalSelectionTransfer.getTransfer(),};
@@ -126,13 +193,59 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         viewer.addDropSupport(dndOperations, transfers, new DerivateDropListener(this));
     }
 
+    public void updateRootEntities() {
+        updateRootEntities(null);
+    }
+
+    public void updateRootEntities(Collection<UUID> derivativeUuids) {
+        if(conversation!=null){
+            if (!conversation.isBound()) {
+                conversation.bind();
+            }
+            /*
+             * If the active session is not the session of the Derivate Editor then we will
+             * save it, bind temporarily to our session and rebind to the original session.
+             * This happens e.g. if a selection change happens in the taxon editor and
+             * "Link with editor" is enabled. The selection change event and thus the
+             * loading in updateRootEntities() happens in the session of the taxon
+             * editor.
+             */
+            ICdmEntitySession previousCdmEntitySession = CdmStore.getCurrentSessionManager().getActiveSession();
+            if(cdmEntitySession != null) {
+                cdmEntitySession.bind();
+            }
+
+            if(derivativeUuids!=null){
+                this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
+                this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
+                for (UUID uuid : derivativeUuids) {
+                    SpecimenOrObservationBase<?> derivate = CdmStore.getService(IOccurrenceService.class).load(uuid, SPECIMEN_INIT_STRATEGY);
+                    if(derivate instanceof FieldUnit){
+                        derivateToRootEntityMap.put(derivate, derivate);
+                    }
+                    else {
+                        SpecimenOrObservationBase<?> topMostDerivate = EditorUtil.getTopMostDerivate(derivate);
+                        if(topMostDerivate!=null){
+                            derivateToRootEntityMap.put(derivate, topMostDerivate);
+                        }
+                        else{
+                            derivateToRootEntityMap.put(derivate, derivate);
+                        }
+                    }
+                }
+                for (SpecimenOrObservationBase<?> specimen : derivateToRootEntityMap.values()) {
+                    rootElements.add(specimen);
+                }
+            }
+            viewer.setInput(rootElements);
+            refreshTree(false);
+            previousCdmEntitySession.bind();
+        }
+    }
+
     @Override
     public void doSave(IProgressMonitor monitor) {
         String taskName = Messages.DerivateView_SAVING_HIERARCHY;
-        if(getEditorInput() instanceof DerivateViewEditorInput){
-            DerivateViewEditorInput derivateViewEditorInput = (DerivateViewEditorInput) getEditorInput();
-            taskName += " "+derivateViewEditorInput.getName(); //$NON-NLS-1$
-        }
         monitor.beginTask(taskName, 3);
         if (!conversation.isBound()) {
             conversation.bind();
@@ -141,7 +254,10 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
 
         // commit the conversation and start a new transaction immediately
         conversation.commit(true);
-        ((DerivateViewEditorInput) getEditorInput()).merge();
+
+        if(CdmStore.getCurrentSessionManager().isRemoting()) {
+            CdmStore.getService(IOccurrenceService.class).merge(new ArrayList<SpecimenOrObservationBase>(rootElements), true);
+        }
         monitor.worked(1);
 
         this.setDirty(false);
@@ -157,24 +273,9 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
 
     @Override
     public String getTitleToolTip() {
-        if(getEditorInput() instanceof DerivateViewEditorInput){
-            DerivateViewEditorInput derivateViewEditorInput = (DerivateViewEditorInput) getEditorInput();
-            return derivateViewEditorInput.getName();
-        }
         return Messages.DerivateView_DERIVATIVE_EDITOR;
     }
 
-    @Override
-    public void init(IEditorSite site, IEditorInput input) throws PartInitException {
-        setSite(site);
-        setInput(input);
-        if(input instanceof DerivateViewEditorInput){
-            DerivateViewEditorInput derivateViewEditorInput = (DerivateViewEditorInput) input;
-            conversation = derivateViewEditorInput.getConversationHolder();
-            setPartName(derivateViewEditorInput.getName());
-        }
-    }
-
     @Override
     public boolean isDirty() {
         return isDirty;
@@ -196,10 +297,12 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
     public void setFocus() {
         viewer.getControl().setFocus();
         //make sure to bind again if maybe in another view the conversation was unbound
-        if(!conversation.isBound()){
+        if(conversation!=null && !conversation.isBound()){
             conversation.bind();
         }
-        ((DerivateViewEditorInput) getEditorInput()).bind();
+        if(cdmEntitySession != null) {
+            cdmEntitySession.bind();
+        }
     }
 
     @Override
@@ -214,6 +317,7 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
     /**
      * @return the viewer
      */
+    @Override
     public TreeViewer getViewer() {
         return viewer;
     }
@@ -230,6 +334,24 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         changed(null);
     }
 
+    @Override
+    public Map<Object, List<String>> getPropertyPathsMap() {
+        List<String> specimenPropertyPaths = Arrays.asList(new String[] {
+                "descriptions",
+                "derivationEvents.derivates",
+                "annotations",
+                "markers",
+                "credits",
+                "extensions",
+                "rights",
+                "sources"
+        });
+        Map<Object, List<String>> specimenPropertyPathMap =
+                new HashMap<Object, List<String>>();
+        specimenPropertyPathMap.put(SpecimenOrObservationBase.class,specimenPropertyPaths);
+        return specimenPropertyPathMap;
+    }
+
     /**
      * Refreshes the derivate hierarchy tree and expands the tree
      * to show and select the given object.
@@ -247,43 +369,40 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
      * Refreshes the derivate hierarchy tree
      */
     public void refreshTree(){
-        generateMultiLinkSingleReads();
-        labelProvider.setMultiLinkSingleReads(multiLinkSingleReads);
-        viewer.refresh();
+        refreshTree(true);
+    }
+
+    /**
+     * Refreshes the derivate hierarchy tree
+     * @param refreshViewer if <code>true</code> then also the
+     * viewer will be refreshed. This was implemented due to
+     * performance reasons. If passing <code>false</code>
+     * does what was expected use <code>false</code> preferably.
+     */
+    public void refreshTree(boolean refreshViewer){
+        //refresh typedesignations
+        labelProvider.refresh();
+        if(refreshViewer){
+            viewer.refresh();
+        }
     }
 
     //FIXME:Remoting hack to make this work for remoting
     //This should actually be resolved using remoting post operations
     public void remove(Object obj) {
-        Set<SpecimenOrObservationBase<?>> rootEntities = ((DerivateViewEditorInput) getEditorInput()).getRootEntities();
-        rootEntities.remove(obj);
-        viewer.setInput(rootEntities);
-    }
-
-    private void generateMultiLinkSingleReads() {
-        Set<SingleRead> multiLinkSingleReads = new HashSet<SingleRead>();
-        for(Entry<SingleRead, Collection<Sequence>> entry:CdmStore.getService(ISequenceService.class).getSingleReadSequencesMap().entrySet()){
-            if(entry.getValue().size()>1){
-                multiLinkSingleReads.add(entry.getKey());
-            }
-        }
-        this.multiLinkSingleReads = multiLinkSingleReads;
+        rootElements.remove(obj);
+        viewer.setInput(rootElements);
     }
 
     /**
      * @return a set of {@link SingleRead}s that have multiple parents
      */
     public Set<SingleRead> getMultiLinkSingleReads() {
-        return this.multiLinkSingleReads;
-    }
-
-    @Override
-    public void selectionChanged(SelectionChangedEvent event) {
-        this.selection  = event.getSelection();
+        return DerivateLabelProvider.getMultiLinkSingleReads();
     }
 
-    public ISelection getSelection() {
-        return selection;
+    public Object getSelectionInput() {
+        return selectedTaxon;
     }
 
     public DerivateLabelProvider getLabelProvider() {
@@ -304,15 +423,130 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         return true;
     }
 
+
+    @Override
+    public boolean canAttachMedia() {
+        return true;
+    }
+
+    public void addFieldUnit(FieldUnit fieldUnit) {
+        rootElements.add(fieldUnit);
+        derivateToRootEntityMap.put(fieldUnit, fieldUnit);
+    }
+
+    @Override
+    public ICdmEntitySession getCdmEntitySession() {
+        return cdmEntitySession;
+    }
+
     @Override
     public void dispose() {
-        ((DerivateViewEditorInput) getEditorInput()).dispose();
         super.dispose();
+        if(conversation!=null){
+            conversation.close();
+        }
+        if(cdmEntitySession != null) {
+            cdmEntitySession.dispose();
+        }
     }
 
+    @Override
+    public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+        if(listenToSelectionChange && selection instanceof IStructuredSelection){
+            Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
+            if(selectedElement instanceof CdmBase && ((CdmBase) selectedElement).isInstanceOf(Taxon.class)){
+                selectedTaxon = HibernateProxyHelper.deproxy(selectedElement, Taxon.class);
+                Collection<SpecimenOrObservationBase> fieldUnits = CdmStore.getService(IOccurrenceService.class).listFieldUnitsByAssociatedTaxon(selectedTaxon, null, null);
+                Collection<UUID> uuids = new HashSet<UUID>();
+                for (SpecimenOrObservationBase specimenOrObservationBase : fieldUnits) {
+                    uuids.add(specimenOrObservationBase.getUuid());
+                }
+                updateRootEntities(uuids);
+                setPartName("Derivative Editor: " + selectedTaxon.getName());
+            }
+        }
+    }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
-    public boolean canAttachMedia() {
-        return true;
+    public List<SpecimenOrObservationBase<?>> getRootEntities() {
+        return new ArrayList<SpecimenOrObservationBase<?>>(rootElements);
+    }
+
+    @Override
+    public void createViewer(Composite parent) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public boolean isSaveOnCloseNeeded() {
+        return isDirty();
     }
+
+    @Override
+    public int promptToSaveOnClose() {
+        return ISaveablePart2.DEFAULT;
+    }
+
+    public void toggleListenToSelectionChange() {
+        listenToSelectionChange = !listenToSelectionChange;
+        derivateSearchCompositeController.setEnabled(!listenToSelectionChange);
+        if(!listenToSelectionChange){
+            selectedTaxon = null;
+            setPartName("Derivative Editor");
+        }
+        else if(selectedTaxon==null){
+            setPartName("Derivative Editor [no taxon selected]");
+        }
+    }
+
+    public boolean isListenToSelectionChange(){
+        return listenToSelectionChange;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void contextAboutToStop(IMemento memento, IProgressMonitor monitor) {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void contextStop(IMemento memento, IProgressMonitor monitor) {
+        derivateSearchCompositeController.setEnabled(false);
+        viewer.getTree().setEnabled(false);
+        viewer.setInput(null);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void contextStart(IMemento memento, IProgressMonitor monitor) {
+        init();
+        derivateSearchCompositeController.setEnabled(!listenToSelectionChange);
+        viewer.getTree().setEnabled(true);
+        refreshTree();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void contextRefresh(IProgressMonitor monitor) {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void workbenchShutdown(IMemento memento, IProgressMonitor monitor) {
+    }
+
 }
index 198b15a0f1c30b819d3366d0cf19e90f88bff0ca..950533d113f7481f3717cbf08b95eb872a1055ab 100644 (file)
@@ -9,12 +9,6 @@
 */
 package eu.etaxonomy.taxeditor.editor.view.derivate;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 
@@ -22,18 +16,8 @@ import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IPersistableElement;
 
-import eu.etaxonomy.cdm.api.application.CdmApplicationState;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
-import eu.etaxonomy.cdm.api.service.IOccurrenceService;
-import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
 import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
-import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput;
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.Messages;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
-import eu.etaxonomy.taxeditor.store.CdmStore;
-import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
 
 /**
  * Editor input for the {@link DerivateView} which holds the currently selected derivate for which
@@ -43,74 +27,21 @@ import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
  * @date 25.11.2013
  *
  */
-public class DerivateViewEditorInput extends CdmEntitySessionInput implements IEditorInput {
+public class DerivateViewEditorInput implements IEditorInput {
 
     /**
-     * The selected derivate {@link UUID}s
+     * The {@link UUID}s of the derivative entities
      */
-    private final Set<SpecimenOrObservationBase<?>> derivateEntities;
-    /**
-     * List of the {@link UUID}s of the root elements of the hierarchy (may be the same objects as the derivates)
-     */
-    private Set<SpecimenOrObservationBase<?>> rootEntities;
-    private Set<UUID> rootUUIDs;
-
-    private final ConversationHolder conversationHolder;
-
-    private static final List<String> SPECIMEN_INIT_STRATEGY = Arrays.asList(new String[] {
-            "descriptions",
-            "annotations",
-            "markers",
-            "credits",
-            "extensions",
-            "rights",
-            "sources",
-            "derivationEvents.derivatives.annotations",
-            "derivationEvents.derivatives.markers",
-            "derivationEvents.derivatives.credits",
-            "derivationEvents.derivatives.extensions",
-            "derivationEvents.derivatives.rights",
-            "derivationEvents.derivatives.sources"
-    });
+    private Set<UUID> derivativeUUIDs;
 
     /**
      * Creates an editor input for the {@link DerivateView} with the currently selected derivates and the
      * corresponding {@link FieldUnit}s (both may be the same object).
      * @param derivateUuids the {@link UUID}s of the derivates for which the derivate hierarchy should be shown
-     * @param rootUUIDs the root of the hierarchy
+     * @param derivativeUUIDs the root of the hierarchy
      */
     public DerivateViewEditorInput(Set<UUID> derivateUuids) {
-        super(false);
-        rootUUIDs = derivateUuids;
-        //FIXME:Remoting temporary hack for making the sessions work
-        //This should ideally be changed to initializing the
-        //super class with a collection of (id) objects which can
-        //then be used for the hashCode, equals methods
-        initSession();
-        this.conversationHolder = CdmStore.createConversation();
-        this.derivateEntities = new HashSet<SpecimenOrObservationBase<?>>();
-        this.rootEntities = new HashSet<SpecimenOrObservationBase<?>>();
-        for (UUID uuid : derivateUuids) {
-            SpecimenOrObservationBase<?> derivate = CdmStore.getService(IOccurrenceService.class).load(uuid, SPECIMEN_INIT_STRATEGY);
-            derivateEntities.add(derivate);
-            if(derivate instanceof FieldUnit){
-                rootEntities.add(derivate);
-            }
-            else if(derivate instanceof DerivedUnit){
-                SpecimenOrObservationBase<?> topMostDerivate = EditorUtil.getTopMostDerivate(derivate);
-                if(topMostDerivate!=null){
-                    rootEntities.add(topMostDerivate);
-                }
-            }
-        }
-        if(rootEntities.isEmpty()){
-            rootEntities = derivateEntities;
-        }
-        if(rootEntities.isEmpty()){
-            MessagingUtils.messageDialog(Messages.DerivateViewEditorInput_FAIL_INIT, DerivateViewEditorInput.class, Messages.DerivateViewEditorInput_NO_ROOT);
-        }
-
-
+        this.derivativeUUIDs = derivateUuids;
     }
 
     /* (non-Javadoc)
@@ -164,52 +95,24 @@ public class DerivateViewEditorInput extends CdmEntitySessionInput implements IE
     }
 
     private String getEditorName() {
-        String name = null;
-        for( SpecimenOrObservationBase<?> specimen : rootEntities){
-            if(specimen!=null){
-                if(name==null){
-                    name = DerivateLabelProvider.getDerivateText(specimen, conversationHolder);
-                }
-                else{
-                    name += " + "+DerivateLabelProvider.getDerivateText(specimen, conversationHolder); //$NON-NLS-1$
-                }
-            }
-        }
-        return name;
-    }
-
-    @Override
-    public Set<SpecimenOrObservationBase<?>> getRootEntities() {
-        return rootEntities;
-    }
-
-    public Set<SpecimenOrObservationBase<?>> getDerivateEntities() {
-        return derivateEntities;
-    }
-
-    public void addRootEntity(SpecimenOrObservationBase<?> root){
-        rootEntities.add(root);
+            return "Derivative Editor";
     }
 
-
-    public ConversationHolder getConversationHolder() {
-        return conversationHolder;
+    /**
+     * @return the derivativeUUIDs
+     */
+    public Set<UUID> getDerivativeUUIDs() {
+        return derivativeUUIDs;
     }
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#hashCode()
-     */
     @Override
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + ((rootUUIDs == null) ? 0 : rootUUIDs.hashCode());
+        result = prime * result + ((derivativeUUIDs == null) ? 0 : derivativeUUIDs.hashCode());
         return result;
     }
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
     @Override
     public boolean equals(Object obj) {
         if (this == obj) {
@@ -222,47 +125,14 @@ public class DerivateViewEditorInput extends CdmEntitySessionInput implements IE
             return false;
         }
         DerivateViewEditorInput other = (DerivateViewEditorInput) obj;
-        if (rootUUIDs == null) {
-            if (other.rootUUIDs != null) {
+        if (derivativeUUIDs == null) {
+            if (other.derivativeUUIDs != null) {
                 return false;
             }
-        } else if (!rootUUIDs.equals(other.rootUUIDs)) {
+        } else if (!derivativeUUIDs.equals(other.derivativeUUIDs)) {
             return false;
         }
         return true;
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
-     */
-    @Override
-    public void merge() {
-        if(CdmStore.getCurrentSessionManager().isRemoting()) {
-            CdmApplicationState.getCurrentAppConfig().getOccurrenceService().merge(new ArrayList(getRootEntities()), true);
-        }
-
-    }
-
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap()
-     */
-    @Override
-    public Map<Object, List<String>> getPropertyPathsMap() {
-        List<String> specimenPropertyPaths = Arrays.asList(new String[] {
-                "descriptions",
-                "derivationEvents.derivates",
-                "annotations",
-                "markers",
-                "credits",
-                "extensions",
-                "rights",
-                "sources"
-        });
-        Map<Object, List<String>> specimenPropertyPathMap =
-                new HashMap<Object, List<String>>();
-        specimenPropertyPathMap.put(SpecimenOrObservationBase.class,specimenPropertyPaths);
-        return specimenPropertyPathMap;
-    }
-
-
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/contextMenu/CreateFieldUnitContextMenu.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/contextMenu/CreateFieldUnitContextMenu.java
new file mode 100644 (file)
index 0000000..838e5c0
--- /dev/null
@@ -0,0 +1,105 @@
+package eu.etaxonomy.taxeditor.editor.view.derivate.contextMenu;
+
+import org.eclipse.jface.action.ContributionItem;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.CompoundContributionItem;
+
+import eu.etaxonomy.cdm.api.service.IOccurrenceService;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
+import eu.etaxonomy.cdm.model.description.TaxonDescription;
+import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * Context menu for the SingleReads in the derivate hierarchy.
+ *
+ */
+public class CreateFieldUnitContextMenu extends CompoundContributionItem {
+
+    private enum CommandType {
+        COPY_TO_CLIPBOARD, REMOVE_FROM_SEQUENCE, ADD_TO_SEQUENCE
+    }
+
+    @Override
+    protected IContributionItem[] getContributionItems() {
+        IContributionItem[] contributionItems = new IContributionItem[] {
+                new ContributionItem() {
+                    @Override
+                    public void fill(Menu menu, int index) {
+                        final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+                        IWorkbenchPart activePart = window.getActivePage().getActivePart();
+                        if(activePart instanceof DerivateView){
+                            final DerivateView derivateView = (DerivateView) activePart;
+                            if(derivateView.isListenToSelectionChange()){
+                                Object selectionInput = derivateView.getSelectionInput();
+                                if(selectionInput instanceof CdmBase && ((CdmBase) selectionInput).isInstanceOf(Taxon.class)){
+                                    final Taxon taxon = HibernateProxyHelper.deproxy(selectionInput, Taxon.class);
+                                    MenuItem item = new MenuItem(menu, SWT.NONE);
+                                    item.setText("Create FieldUnit for "+taxon.getName());
+                                    item.addSelectionListener(new SelectionAdapter() {
+                                        @Override
+                                        public void widgetSelected(SelectionEvent e) {
+                                            if(derivateView.isDirty()){
+                                                MessagingUtils.warningDialog(DerivateView.VIEW_HAS_UNSAVED_CHANGES, this, DerivateView.YOU_NEED_TO_SAVE_BEFORE_PERFORMING_THIS_ACTION);
+                                                return;
+                                            }
+                                            FieldUnit fieldUnit = FieldUnit.NewInstance();
+                                            fieldUnit = CdmBase.deproxy(CdmStore.getService(IOccurrenceService.class).save(fieldUnit), FieldUnit.class);
+                                            IndividualsAssociation association = IndividualsAssociation.NewInstance(fieldUnit);
+                                            association.setFeature(Feature.SPECIMEN());
+                                            TaxonDescription description;
+                                            if(!taxon.getDescriptions().isEmpty()){
+                                                description = taxon.getDescriptions().iterator().next();
+                                            }
+                                            else{
+                                                description = TaxonDescription.NewInstance(taxon);
+                                            }
+                                            description.addElement(IndividualsAssociation.NewInstance(fieldUnit));
+
+                                            derivateView.getConversationHolder().commit();
+                                            derivateView.addFieldUnit(fieldUnit);
+                                            derivateView.refreshTree();
+                                        }
+                                    });
+                                }
+                            }
+                            else{
+                                MenuItem item = new MenuItem(menu, SWT.NONE);
+                                item.setText("Create FieldUnit");
+                                item.addSelectionListener(new SelectionAdapter() {
+                                    @Override
+                                    public void widgetSelected(SelectionEvent e) {
+                                        if(derivateView.isDirty()){
+                                            MessagingUtils.warningDialog(DerivateView.VIEW_HAS_UNSAVED_CHANGES, this, DerivateView.YOU_NEED_TO_SAVE_BEFORE_PERFORMING_THIS_ACTION);
+                                            return;
+                                        }
+                                        FieldUnit fieldUnit = FieldUnit.NewInstance();
+                                        fieldUnit = CdmBase.deproxy(CdmStore.getService(IOccurrenceService.class).save(fieldUnit), FieldUnit.class);
+                                        derivateView.getConversationHolder().commit();
+                                        derivateView.addFieldUnit(fieldUnit);
+                                        derivateView.refreshTree();
+                                    }
+                                });
+                            }
+                        }
+                    }
+                }
+        };
+        return contributionItems;
+    }
+}
+
index 17d95b1976ecb4531358069717fe7b26b50c4dac..659ea528365f43205a01c99cfbe3b74ea9371f90 100644 (file)
@@ -8,6 +8,7 @@ public class DerivateViewContextMenu extends CompoundContributionItem  {
     @Override
     protected IContributionItem[] getContributionItems() {
         IContributionItem[] contributionItems = new IContributionItem[] {
+                new CreateFieldUnitContextMenu(),
                 new CreateDerivateContextMenu(),
                 new SingleReadSequenceContextMenu()
         };
index 5129e44c572cd4673ad5cc1673b9a785f622a50c..21e9f678053ab07df1645757b33c0d7459164d58 100644 (file)
@@ -8,7 +8,6 @@ import eu.etaxonomy.cdm.api.service.IOccurrenceService;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
-import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.store.CdmStore;
@@ -26,8 +25,7 @@ public class CreateFieldUnitHandler extends AbstractHandler {
             FieldUnit fieldUnit = FieldUnit.NewInstance();
             fieldUnit = CdmBase.deproxy(CdmStore.getService(IOccurrenceService.class).save(fieldUnit), FieldUnit.class);
             derivateView.getConversationHolder().commit();
-            DerivateViewEditorInput input = (DerivateViewEditorInput) derivateView.getEditorInput();
-            input.addRootEntity(fieldUnit);
+            derivateView.addFieldUnit(fieldUnit);
             derivateView.refreshTree();
         }
         return null;
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/ListenToSelectionChangeHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/ListenToSelectionChangeHandler.java
new file mode 100644 (file)
index 0000000..413c377
--- /dev/null
@@ -0,0 +1,23 @@
+package eu.etaxonomy.taxeditor.editor.view.derivate.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
+
+public class ListenToSelectionChangeHandler extends AbstractHandler {
+
+    @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+        IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
+        if(activePart instanceof DerivateView){
+            DerivateView derivativeEditor = (DerivateView)activePart;
+            derivativeEditor.toggleListenToSelectionChange();
+        }
+        return null;
+    }
+
+}
index bfb5f5751547c5d54daf8bbe8fc89eb73de2e959..f5956fa1bebf439a99de347d0b52c9efb07a8d8f 100644 (file)
@@ -27,7 +27,6 @@ import eu.etaxonomy.cdm.model.molecular.Sequence;
 import eu.etaxonomy.cdm.model.molecular.SingleRead;
 import eu.etaxonomy.taxeditor.editor.Messages;
 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
@@ -94,10 +93,6 @@ public class DeleteDerivateOperation extends AbstractPostOperation<CdmBase> {
                 //update DerivateView
                 derivateView.getConversationHolder().commit();
                 IStatus returnStatus = postExecute(null);
-                //close if no more items left
-                if(derivateView.getViewer().getTree().getItemCount()<1){
-                    AbstractUtility.close(derivateView);
-                }
                 return returnStatus;
             }
         }
@@ -7,12 +7,9 @@
  * 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.view.derivateSearch;
+package eu.etaxonomy.taxeditor.editor.view.derivate.searchFilter;
 
-import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
@@ -20,7 +17,6 @@ import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.wb.swt.ResourceManager;
@@ -30,72 +26,82 @@ import org.eclipse.wb.swt.ResourceManager;
  *
  */
 public class DerivateSearchComposite extends Composite {
+
+    public static final int ALL_SPECIMENS = 0;
+    public static final int ASSIGNED_SPECIMENS = 1;
+    public static final int UNASSIGNED_SPECIMENS = 2;
+
     private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
     private final Text searchField;
-    private final Table table;
-    private final TableViewer resultViewer;
     private final Combo comboDerivateType;
     private final Button buttonSearch;
-    private final Button btnFilterUndeterminedSpecimen;
     private final Text textTaxonName;
     private final Button btnBrowseTaxa;
     private final Label lblTaxon;
     private final Label lblDerivateType;
     private final Button btnClearTaxon;
+    private Label lbltaxonAssignment;
+    private Combo comboTaxonAssignment;
+    private Label lblTitleCache;
 
     /**
      * Create the composite.
+     *
      * @param parent
      * @param style
      */
     public DerivateSearchComposite(Composite parent, int style) {
         super(parent, style);
-        setLayout(new GridLayout(4, false));
+        setLayout(new GridLayout(7, false));
 
         lblTaxon = new Label(this, SWT.NONE);
         lblTaxon.setText("Taxon");
 
-        textTaxonName = formToolkit.createText(this, "New Text", SWT.NONE);
+        textTaxonName = formToolkit.createText(this, "New Text", SWT.BORDER);
         textTaxonName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
         textTaxonName.setEnabled(false);
         textTaxonName.setText("");
 
         btnBrowseTaxa = formToolkit.createButton(this, "", SWT.NONE);
+        btnBrowseTaxa.setAlignment(SWT.RIGHT);
         btnBrowseTaxa.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
 
         btnClearTaxon = formToolkit.createButton(this, "", SWT.NONE);
-        btnClearTaxon.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
+        btnClearTaxon.setAlignment(SWT.RIGHT);
+        btnClearTaxon.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
         btnClearTaxon.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
 
+        lbltaxonAssignment = new Label(this, SWT.NONE);
+        lbltaxonAssignment.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+        lbltaxonAssignment.setText("Taxon assignment");
+
+        comboTaxonAssignment = new Combo(this, SWT.NONE);
+        comboTaxonAssignment.setItems(new String[] { "All", "Yes", "No" });
+        comboTaxonAssignment.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+        formToolkit.adapt(comboTaxonAssignment);
+        formToolkit.paintBordersFor(comboTaxonAssignment);
+        comboTaxonAssignment.select(ALL_SPECIMENS);
+        new Label(this, SWT.NONE);
+
+        lblTitleCache = new Label(this, SWT.NONE);
+        lblTitleCache.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+        lblTitleCache.setText("Title Cache");
+
+        searchField = formToolkit.createText(this, "New Text", SWT.BORDER);
+        searchField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1));
+        searchField.setText("");
+
         lblDerivateType = new Label(this, SWT.NULL);
+        lblDerivateType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
         lblDerivateType.setText("Derivative Type");
 
         comboDerivateType = new Combo(this, SWT.READ_ONLY);
         comboDerivateType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
         formToolkit.paintBordersFor(comboDerivateType);
 
-        btnFilterUndeterminedSpecimen = new Button(this, SWT.CHECK);
-        btnFilterUndeterminedSpecimen.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
-        btnFilterUndeterminedSpecimen.addSelectionListener(new SelectionAdapter() {
-            @Override
-            public void widgetSelected(SelectionEvent e) {
-            }
-        });
-        btnFilterUndeterminedSpecimen.setText("Determined");
-
-                buttonSearch = new Button(this, SWT.NONE);
-                formToolkit.adapt(buttonSearch, true, true);
-                buttonSearch.setText("Search");
-
-                searchField = formToolkit.createText(this, "New Text", SWT.NONE);
-                searchField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
-                searchField.setText("");
-                new Label(this, SWT.NONE);
-                new Label(this, SWT.NONE);
-
-                resultViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
-                table = resultViewer.getTable();
-                table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
+        buttonSearch = new Button(this, SWT.NONE);
+        formToolkit.adapt(buttonSearch, true, true);
+        buttonSearch.setText("Search");
 
     }
 
@@ -103,42 +109,51 @@ public class DerivateSearchComposite extends Composite {
     protected void checkSubclass() {
         // Disable the check that prevents subclassing of SWT components
     }
+
     public Text getSearchField() {
         return searchField;
     }
-    public TableViewer getResultViewer() {
-        return resultViewer;
-    }
+
     public Combo getComboDerivateType() {
         return comboDerivateType;
     }
+
     public Button getButtonSearch() {
         return buttonSearch;
     }
 
     @Override
-    public void setEnabled(boolean enabled){
+    public void setEnabled(boolean enabled) {
         super.setEnabled(enabled);
         searchField.setEnabled(enabled);
-        table.setEnabled(enabled);
-        //        resultViewer.setEnabled(enabled);
         comboDerivateType.setEnabled(enabled);
+        comboTaxonAssignment.setEnabled(enabled);
         buttonSearch.setEnabled(enabled);
-        btnFilterUndeterminedSpecimen.setEnabled(enabled);
         btnBrowseTaxa.setEnabled(enabled);
+        btnClearTaxon.setEnabled(enabled);
         lblTaxon.setEnabled(enabled);
+        lblTitleCache.setEnabled(enabled);
+        lbltaxonAssignment.setEnabled(enabled);
         lblDerivateType.setEnabled(enabled);
     }
-    public Button getBtnFilterUndeterminedSpecimen() {
-        return btnFilterUndeterminedSpecimen;
-    }
+
+
     public Button getBtnBrowseTaxa() {
         return btnBrowseTaxa;
     }
+
     public Text getTextTaxonName() {
         return textTaxonName;
     }
+
     public Button getBtnClearTaxon() {
         return btnClearTaxon;
     }
+    public Combo getComboTaxonAssignment() {
+        return comboTaxonAssignment;
+    }
+
+    public Label getLbltaxonAssignment() {
+        return lbltaxonAssignment;
+    }
 }
@@ -7,25 +7,19 @@
 * 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.view.derivateSearch;
+package eu.etaxonomy.taxeditor.editor.view.derivate.searchFilter;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
+import java.util.UUID;
 
-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;
-import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.handlers.IHandlerService;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.service.IOccurrenceService;
@@ -33,12 +27,13 @@ import eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;
+import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.store.SearchManager;
 import eu.etaxonomy.taxeditor.ui.dialog.selection.SelectionDialogFactory;
 import eu.etaxonomy.taxeditor.ui.mvc.combo.EnumTermComboController;
+import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
 
 /**
  * Controller class for the {@link DerivateSearchComposite}.<br>
@@ -50,17 +45,13 @@ public class DerivateSearchCompositeController implements Listener{
 
     private final DerivateSearchComposite derivateSearchComposite;
     private EnumTermComboController<SpecimenOrObservationType> comboSpecimenTypeController;
-    private final DerivateSearchView derivateSearchView;
        private DerivateLabelProvider labelProvider;
        private Taxon selectedTaxon;
+    private DerivateView derivativeEditor;
 
-    /**
-     * @param parent
-     * @param derivateSearchView
-     */
-    public DerivateSearchCompositeController(Composite parent, DerivateSearchView derivateSearchView) {
+    public DerivateSearchCompositeController(Composite parent, DerivateView derivativeEditor) {
         this.derivateSearchComposite = new DerivateSearchComposite(parent, SWT.NONE);
-        this.derivateSearchView = derivateSearchView;
+        this.derivativeEditor = derivativeEditor;
         init();
     }
 
@@ -75,40 +66,9 @@ public class DerivateSearchCompositeController implements Listener{
         derivateSearchComposite.getBtnBrowseTaxa().addListener(SWT.Selection, this);
         derivateSearchComposite.getBtnClearTaxon().addListener(SWT.Selection, this);
 
-
-        //result table
-        TableViewer resultViewer = derivateSearchComposite.getResultViewer();
-        resultViewer.setContentProvider(new ArrayContentProvider());
-        labelProvider = new DerivateLabelProvider();
-        resultViewer.setLabelProvider(labelProvider);
-        resultViewer.addDoubleClickListener(new IDoubleClickListener() {
-            @Override
-            public void doubleClick(DoubleClickEvent event) {
-                String commandId = "eu.etaxonomy.taxeditor.editor.handler.openDerivateView";
-
-                IHandlerService handlerService = (IHandlerService) AbstractUtility.getService(IHandlerService.class);
-                try {
-                    handlerService.executeCommand(commandId, null);
-                } catch (ExecutionException e) {
-                    MessagingUtils.error(DerivateSearchCompositeController.class, e);
-                } catch (NotDefinedException e) {
-                    MessagingUtils.error(DerivateSearchCompositeController.class, e);
-                } catch (NotEnabledException e) {
-                    MessagingUtils.error(DerivateSearchCompositeController.class, e);
-                } catch (NotHandledException e) {
-                    MessagingUtils.error(DerivateSearchCompositeController.class, e);
-                }
-
-            }
-        });
-
     }
 
     private void searchDerivates(){
-        if(!derivateSearchView.getConversationHolder().isBound()){
-            derivateSearchView.setFocus(); //rebind the conversation
-        }
-
         String queryString = derivateSearchComposite.getSearchField().getText();
         SpecimenOrObservationType specimenType = comboSpecimenTypeController.getSelection();
 
@@ -117,7 +77,6 @@ public class DerivateSearchCompositeController implements Listener{
         config.setSpecimenType(specimenType.equals(SpecimenOrObservationType.Unknown)?null:specimenType);//unknown := all types
         config.setTitleSearchString(queryString);
         if(selectedTaxon!=null){
-            config.setRetrieveIndirectlyAssociatedSpecimens(true);
             config.setSpecimenType(null);
         }
 
@@ -136,17 +95,31 @@ public class DerivateSearchCompositeController implements Listener{
             occurrences = specimensOfCorrectType;
         }
 
-        //filter out assigned specimens
-        if(derivateSearchComposite.getBtnFilterUndeterminedSpecimen().getSelection()){
-            List<SpecimenOrObservationBase> specimensWithNoDetermination = new ArrayList<SpecimenOrObservationBase>();
-            for(SpecimenOrObservationBase<?> result:occurrences){
-                if(CdmStore.getService(IOccurrenceService.class).countDeterminations(result, null)==0){
-                    specimensWithNoDetermination.add(result);
+        //filter out (un-)assigned specimens
+        if(selectedTaxon==null){
+            int selectionIndex = derivateSearchComposite.getComboTaxonAssignment().getSelectionIndex();
+            List<SpecimenOrObservationBase<?>> specimenWithAssociations = new ArrayList<SpecimenOrObservationBase<?>>();
+            if(selectionIndex!=DerivateSearchComposite.ALL_SPECIMENS){
+                for (SpecimenOrObservationBase specimenOrObservationBase : occurrences) {
+                    Collection<TaxonBase<?>> associatedTaxa = CdmStore.getService(IOccurrenceService.class).listAssociatedTaxa(specimenOrObservationBase, null, null, null, null);
+                    if(!associatedTaxa.isEmpty()){
+                        specimenWithAssociations.add(specimenOrObservationBase);
+                        specimenWithAssociations.addAll(CdmStore.getService(IOccurrenceService.class).getFieldUnits(specimenOrObservationBase.getUuid()));
+                    }
                 }
             }
-            occurrences = specimensWithNoDetermination;
+            if(selectionIndex==DerivateSearchComposite.UNASSIGNED_SPECIMENS){
+                occurrences.removeAll(specimenWithAssociations);
+            }
+            else if(selectionIndex==DerivateSearchComposite.ASSIGNED_SPECIMENS){
+                occurrences = new ArrayList<SpecimenOrObservationBase>(specimenWithAssociations);
+            }
+        }
+        List<UUID> derivateUuids = new ArrayList<UUID>();
+        for (SpecimenOrObservationBase specimenOrObservationBase : occurrences) {
+            derivateUuids.add(specimenOrObservationBase.getUuid());
         }
-        derivateSearchComposite.getResultViewer().setInput(occurrences);
+        derivativeEditor.updateRootEntities(derivateUuids);
     }
 
     @Override
@@ -157,14 +130,20 @@ public class DerivateSearchCompositeController implements Listener{
             searchDerivates();
         }
         else if(eventSource==derivateSearchComposite.getBtnBrowseTaxa()){
-            selectedTaxon = SelectionDialogFactory.getSelectionFromDialog(Taxon.class, derivateSearchView.getSite().getShell(), derivateSearchView.getConversationHolder(), null);
+            selectedTaxon = SelectionDialogFactory.getSelectionFromDialog(Taxon.class, this.derivateSearchComposite.getShell(), derivativeEditor.getConversationHolder(), null);
             if(selectedTaxon!=null){
                 derivateSearchComposite.getTextTaxonName().setText(selectedTaxon.getTitleCache());
             }
+            derivateSearchComposite.getComboTaxonAssignment().select(DerivateSearchComposite.ASSIGNED_SPECIMENS);
+            derivateSearchComposite.getComboTaxonAssignment().setEnabled(false);
+            derivateSearchComposite.getLbltaxonAssignment().setEnabled(false);
         }
         else if(eventSource==derivateSearchComposite.getBtnClearTaxon()){
             selectedTaxon = null;
             derivateSearchComposite.getTextTaxonName().setText("");
+            derivateSearchComposite.getComboTaxonAssignment().select(DerivateSearchComposite.ALL_SPECIMENS);
+            derivateSearchComposite.getComboTaxonAssignment().setEnabled(true);
+            derivateSearchComposite.getLbltaxonAssignment().setEnabled(true);
         }
     }
 
@@ -174,16 +153,22 @@ public class DerivateSearchCompositeController implements Listener{
      */
     public void setEnabled(boolean enabled) {
         if(!derivateSearchComposite.isDisposed()){
-            derivateSearchComposite.setEnabled(enabled);
+            GridData layoutData = (GridData) derivateSearchComposite.getLayoutData();
+            layoutData.exclude = !enabled;
+            derivateSearchComposite.setVisible(enabled);
+            derivateSearchComposite.getParent().layout(true);
         }
     }
 
+    public void setLayoutData(Object layoutData){
+        derivateSearchComposite.setLayoutData(layoutData);
+    }
+
     /**
      * Resets all input fields
      */
     public void reset(){
         if(!derivateSearchComposite.isDisposed()){
-            derivateSearchComposite.getResultViewer().setInput(null);
             derivateSearchComposite.getSearchField().setText("");
             derivateSearchComposite.getComboDerivateType().deselectAll();
             comboSpecimenTypeController.setSelection(SpecimenOrObservationType.Unknown);
@@ -191,17 +176,6 @@ public class DerivateSearchCompositeController implements Listener{
         selectedTaxon = null;
     }
 
-    public TableViewer getResultViewer() {
-        return derivateSearchComposite.getResultViewer();
-    }
-
-    public void setFocus() {
-        derivateSearchComposite.getResultViewer().getControl().setFocus();
-    }
-
-    /**
-     * @param conversationHolder
-     */
     public void setConversation(ConversationHolder conversationHolder) {
         labelProvider.setConversation(conversationHolder);
     }
index 3494cd6869b14468e21f31f0d6b6c660c3882db2..60d46862b9da5485d2e8fb2d3eb687d47bf83fd8 100644 (file)
 package eu.etaxonomy.taxeditor.editor.view.descriptive;
 
 import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
 
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.GroupMarker;
@@ -23,14 +19,11 @@ import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.ITreeContentProvider;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TreeNode;
-import org.eclipse.jface.viewers.TreeSelection;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWT;
@@ -43,20 +36,17 @@ import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.Tree;
 import org.eclipse.ui.IWorkbenchActionConstants;
 import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
 
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.description.DescriptionBase;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
 import eu.etaxonomy.cdm.model.description.IDescribable;
-import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor;
 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
-import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
 import eu.etaxonomy.taxeditor.editor.view.media.MediaViewPart;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
@@ -65,15 +55,12 @@ import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
 import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
 import eu.etaxonomy.taxeditor.model.ImageResources;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
 import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
 import eu.etaxonomy.taxeditor.view.supplementaldata.SupplementalDataViewPart;
 
 /**
- * <p>DescriptiveViewPart class.</p>
- *
  * @author n.hoffmann
  * @created Jun 9, 2010
  * @version 1.0
@@ -126,58 +113,8 @@ public class DescriptiveViewPart extends AbstractCdmEditorViewPart implements IP
 
                createToolbar();
 
-               // set initial input
-//             if(getEditor() != null){
-//                     viewer.setInput(getEditor().getEditorInput());
-//             }
-
-               viewer.addDoubleClickListener(new IDoubleClickListener() {
-            @Override
-            public void doubleClick(DoubleClickEvent event) {
-                //Open derivate editor when specimen description element is double clicked
-                TreeSelection selection = (TreeSelection) viewer.getSelection();
-                Iterator iterator = selection.iterator();
-                Set<UUID> specimenUuids = new HashSet<UUID>();
-                while(iterator.hasNext()){
-                    Object next = iterator.next();
-                    if(next instanceof IndividualsAssociation){
-                        SpecimenOrObservationBase<?> specimen = ((IndividualsAssociation)next).getAssociatedSpecimenOrObservation();
-                        if(specimen!=null){
-                            specimenUuids.add(specimen.getUuid());
-                        }
-                    }
-                }
-                try {
-                    if(!specimenUuids.isEmpty()){
-                        EditorUtil.open(new DerivateViewEditorInput(specimenUuids));
-                    }
-                } catch (PartInitException e) {
-                    MessagingUtils.error(DescriptiveViewPart.class, "Could not open Derivative Editor", e);
-                }
-
-
-                    //TODO: extend command to accept parameter to open editor
-//                    String commandId = "eu.etaxonomy.taxeditor.editor.handler.openDerivateView";
-//                    IHandlerService handlerService = (IHandlerService) AbstractUtility.getService(IHandlerService.class);
-//                    try {
-//                        handlerService.executeCommand(commandId, null);
-//                    } catch (ExecutionException e) {
-//                        MessagingUtils.error(DerivateSearchCompositeController.class, e);
-//                    } catch (NotDefinedException e) {
-//                        MessagingUtils.error(DerivateSearchCompositeController.class, e);
-//                    } catch (NotEnabledException e) {
-//                        MessagingUtils.error(DerivateSearchCompositeController.class, e);
-//                    } catch (NotHandledException e) {
-//                        MessagingUtils.error(DerivateSearchCompositeController.class, e);
-//                    }
-
-            }
-        });
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#getInitialSelection()
-        */
        /** {@inheritDoc} */
        @Override
        protected ISelection getInitialSelection() {
@@ -356,11 +293,6 @@ public class DescriptiveViewPart extends AbstractCdmEditorViewPart implements IP
                return viewer;
        }
 
-       /**
-        * <p>onComplete</p>
-        *
-        * @return a boolean.
-        */
        @Override
     public boolean onComplete() {
                return false;
index 4664282982638f122139ec308f039423d4e558e3..894440b0bbc64a74154b1d2734829c18456591e1 100644 (file)
@@ -7,28 +7,16 @@ 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.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeNode;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.cdm.model.taxon.TaxonBase;
-import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
-import eu.etaxonomy.taxeditor.bulkeditor.input.OccurrenceEditorInput;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
-import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
-import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
-import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.AddDerivedUnitFacadeMediaOperation;
-import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateSpecimenDescriptionOperation;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateTaxonDescriptionOperation;
 import eu.etaxonomy.taxeditor.editor.view.media.MediaViewPart;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
@@ -37,89 +25,44 @@ import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 
 /**
- * <p>AddImageGalleryHandler class.</p>
- *
  * @author p.ciardelli
  * @version $Id: $
  */
 public class AddImageGalleryHandler extends AbstractHandler {
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
-        */
        /** {@inheritDoc} */
        @Override
     public Object execute(ExecutionEvent event) throws ExecutionException {
 
-               IWorkbenchPart part = HandlerUtil.getActivePart(event);
-               IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null;
+           IWorkbenchPart part = HandlerUtil.getActivePart(event);
+           IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null;
 
+           if(part instanceof MediaViewPart){
+               Object viewerInput = ((MediaViewPart)part).getViewer().getInput();
+               try {
+                   if(viewerInput instanceof CdmBase){
+                       if(((CdmBase) viewerInput).isInstanceOf(Taxon.class)){
+                           Taxon taxon = HibernateProxyHelper.deproxy(viewerInput, Taxon.class);
 
-               IEditorPart editor = HandlerUtil.getActiveEditor(event);
-               IEditorInput input = editor.getEditorInput();
+                           AbstractPostOperation<?> operation = new CreateTaxonDescriptionOperation(event.getCommand().getName(),
+                                   EditorUtil.getUndoContext(), taxon, postOperationEnabled, true);
 
-               if (input instanceof TaxonEditorInput) {
-                       Taxon taxon = ((TaxonEditorInput) input).getTaxon();
-                       AbstractPostOperation<?> operation;
-                       try {
-                               // TODO use undo context specific to editor
-                               operation = new CreateTaxonDescriptionOperation(event.getCommand().getName(),
-                                               EditorUtil.getUndoContext(), taxon, postOperationEnabled, true);
-                               AbstractUtility.executeOperation(operation);
-                       } catch (NotDefinedException e) {
-                               MessagingUtils.warn(getClass(), "Command name not set.");
-                       }
-               }
-               else if(input instanceof OccurrenceEditorInput){
-                   BulkEditor bulkEditor = (BulkEditor) editor;
-                   ISelection selection = bulkEditor.getSelectionProvider().getSelection();
-                   invokeOperation(event, postOperationEnabled, selection);
-               }
-               else if(input instanceof DerivateViewEditorInput){
-                   ISelection selection = ((DerivateView)editor).getSelection();
-                   invokeOperation(event, postOperationEnabled, selection);
-               } else if(part instanceof MediaViewPart){
-                   Object viewerInput = ((MediaViewPart)part).getViewer().getInput();
-                   
-                   if(viewerInput instanceof Taxon){
-                       Taxon taxon = HibernateProxyHelper.deproxy(viewerInput, Taxon.class);
-                       AbstractPostOperation<?> operation;
-                               try {
-                                       // TODO use undo context specific to editor
-                                       operation = new CreateTaxonDescriptionOperation(event.getCommand().getName(),
-                                                       EditorUtil.getUndoContext(), taxon, postOperationEnabled, true);
-                                       AbstractUtility.executeOperation(operation);
-                               } catch (NotDefinedException e) {
-                                       MessagingUtils.warn(getClass(), "Command name not set.");
-                               }
-                       
-                   }
-               }
-               
-               return null;
-       }
+                           AbstractUtility.executeOperation(operation);
+                       }
+                       else if(((CdmBase) viewerInput).isInstanceOf(SpecimenOrObservationBase.class)){
+                           SpecimenOrObservationBase<?> specimen = HibernateProxyHelper.deproxy(viewerInput, SpecimenOrObservationBase.class);
 
-    /**
-     * @param event
-     * @param postOperationEnabled
-     * @param selection
-     */
-    private void invokeOperation(ExecutionEvent event, IPostOperationEnabled postOperationEnabled, ISelection selection) {
-        if(selection instanceof IStructuredSelection){
-            Object element = ((IStructuredSelection) selection).getFirstElement();
-            if(element instanceof TreeNode){
-                element = ((TreeNode) element).getValue();
-            }
-            if(element instanceof SpecimenOrObservationBase<?>){
-                try {
-                    AbstractPostOperation<?> operation = new AddDerivedUnitFacadeMediaOperation(event.getCommand().getName(),
-                            BulkEditorUtil.getUndoContext(), (SpecimenOrObservationBase<?>)element, postOperationEnabled);
-                    AbstractUtility.executeOperation(operation);
-                } catch (NotDefinedException e) {
-                    MessagingUtils.warn(getClass(), "Command name not set.");
-                }
-            }
-        }
-    }
+                        AbstractPostOperation<?> operation = new AddDerivedUnitFacadeMediaOperation(event.getCommand().getName(),
+                                   BulkEditorUtil.getUndoContext(), specimen, postOperationEnabled);
+
+                           AbstractUtility.executeOperation(operation);
+                       }
+                   }
+               } catch (NotDefinedException e) {
+                   MessagingUtils.warn(getClass(), "Command name not set.");
+               }
+           }
+           return null;
+       }
 
-}
+}
\ No newline at end of file
index c6f939078aa42c0bb528f4cefb4b2da78c0ee1c9..06ed980ec4ec942ae9b88f965c63a5b93730ac35 100644 (file)
@@ -36,6 +36,7 @@ Export-Package: eu.etaxonomy.cdm,
  eu.etaxonomy.taxeditor.ui.dialog.selection,
  eu.etaxonomy.taxeditor.ui.element,
  eu.etaxonomy.taxeditor.ui.group.grantedauthority,
+ eu.etaxonomy.taxeditor.ui.mvc.combo,
  eu.etaxonomy.taxeditor.ui.section,
  eu.etaxonomy.taxeditor.ui.section.agent,
  eu.etaxonomy.taxeditor.ui.section.classification,
@@ -54,7 +55,8 @@ Export-Package: eu.etaxonomy.cdm,
  eu.etaxonomy.taxeditor.view.derivateSearch,
  eu.etaxonomy.taxeditor.view.detail,
  eu.etaxonomy.taxeditor.view.specimenSearch,
- eu.etaxonomy.taxeditor.view.supplementaldata
+ eu.etaxonomy.taxeditor.view.supplementaldata,
+ org.eclipse.wb.swt
 Require-Bundle: org.eclipse.osgi,
  org.eclipse.ui,
  org.eclipse.jface.text,
index 21885b855c4a1e3a4d1b4d06a18682cae83440cd..8e7a4532b909d73a51bc3ac89db09839fa27f5b1 100644 (file)
         name="%view.name.5"
         restorable="true">
   </view>
-  <view
-        class="eu.etaxonomy.taxeditor.view.derivateSearch.DerivateSearchView"
-        icon="icons/derivate_search_view-16x16-32.png"
-        id="eu.etaxonomy.taxeditor.view.derivateSearch.DerivateSearchView"
-        name="%view.name.6"
-        restorable="true">
-  </view>
   <view
         allowMultiple="false"
         class="eu.etaxonomy.taxeditor.view.sessions.SessionsViewPart"
                label="%menu.label">
             <command
                   commandId="org.eclipse.ui.views.showView"
-                  label="%command.label"
-                  style="push">
-               <parameter
-                     name="org.eclipse.ui.views.showView.viewId"
-                     value="eu.etaxonomy.taxeditor.view.derivateSearch.DerivateSearchView">
-               </parameter>
-               <visibleWhen
-                     checkEnabled="true">
-                  <reference
-                        definitionId="isCdmStoreConnected">
-                  </reference>
-               </visibleWhen>
-            </command>
-            <separator
-                  name="eu.etaxonomy.taxeditor.store.showViewMenu.details"
-                  visible="true">
-            </separator>
-            <command
-                  commandId="org.eclipse.ui.views.showView"
+                  id="eu.etaxonomy.taxeditor.store.showViewMenu.details"
                   label="%command.label.0"
                   style="push">
                <parameter
             </visibleWhen>
          </command>
       </menuContribution>
-      <menuContribution
-            allPopups="false"
-            locationURI="popup:eu.etaxonomy.taxeditor.view.derivateSearch.DerivateSearchView">
-         <command
-               commandId="eu.etaxonomy.taxeditor.editor.handler.openDerivateView"
-               label="%command.label.openInSpecimenEditor"
-               style="push">
-            <visibleWhen
-                  checkEnabled="true">
-               <with
-                     variable="selection">
-                  <count
-                        value="+">
-                  </count>
-               </with>
-            </visibleWhen>
-         </command>
-      </menuContribution>
    </extension>
    <extension
          point="org.eclipse.ui.handlers">
index c98b8690be6d9240d7b490850f2086dbb4794f0e..9f382d431c04d2f2d14db62e6f4df8eb1c237209 100644 (file)
 
 package eu.etaxonomy.taxeditor.newWizard;
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.NotEnabledException;
-import org.eclipse.core.commands.NotHandledException;
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialogWithToggle;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.IHandlerService;
-
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
 import eu.etaxonomy.cdm.api.service.IOccurrenceService;
@@ -36,10 +19,7 @@ import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
 import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.IDerivedUnitFacadePart;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
-import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseWizardPage;
@@ -47,7 +27,6 @@ import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralWizardPage
 import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralWizardPage;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitWizardPage;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventWizardPage;
-import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateSearchCompositeController;
 
 /**
  * @author n.hoffmann
@@ -127,54 +106,4 @@ public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard<SpecimenOr
         return "Specimen";
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean performFinish() {
-        boolean performFinish = super.performFinish();
-        int returnCode = IDialogConstants.NO_ID;
-        if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.PROMPT_FOR_OPEN_SPECIMEN_IN_EDITOR)){
-            MessageDialogWithToggle messageDialog = MessageDialogWithToggle.openYesNoQuestion(getShell(),
-                    "Choose opening option", "Do you want to open the specimen in the specimen editor?",
-                    "Remember my decision?", false, PreferencesUtil.getPreferenceStore(),
-                    IPreferenceKeys.ALWAYS_OPEN_SPECIMEN_IN_EDITOR);
-            returnCode = messageDialog.getReturnCode();
-            PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.PROMPT_FOR_OPEN_SPECIMEN_IN_EDITOR, messageDialog.getToggleState());
-            if (returnCode != IDialogConstants.YES_ID) {
-                return performFinish;
-            }
-        }
-        if (returnCode==IDialogConstants.YES_ID ||
-                PreferencesUtil.getPreferenceStore().getString(IPreferenceKeys.ALWAYS_OPEN_SPECIMEN_IN_EDITOR)
-                .equals(MessageDialogWithToggle.ALWAYS)) {
-            IHandlerService handlerService = (IHandlerService) AbstractUtility.getService(IHandlerService.class);
-
-            // get the command from plugin.xml
-            IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-            ICommandService cmdService = (ICommandService) window.getService(ICommandService.class);
-            Command command = cmdService.getCommand("eu.etaxonomy.taxeditor.editor.openSpecimenEditor");
-            Map<String, UUID> parameters = new HashMap<String, UUID>();
-            parameters.put("eu.etaxonomy.taxeditor.specimenUuidParameter", getEntity().getUuid());
-            ParameterizedCommand parameterizedCommand = ParameterizedCommand.generateCommand(command, parameters);
-
-
-            // execute the command
-            try {
-                handlerService.executeCommand(parameterizedCommand, null);
-            } catch (ExecutionException e) {
-                MessagingUtils.error(DerivateSearchCompositeController.class, e);
-            } catch (NotDefinedException e) {
-                MessagingUtils.error(DerivateSearchCompositeController.class, e);
-            } catch (NotEnabledException e) {
-                MessagingUtils.error(DerivateSearchCompositeController.class, e);
-            } catch (NotHandledException e) {
-                MessagingUtils.error(DerivateSearchCompositeController.class, e);
-            }
-        }
-
-        return performFinish;
-    }
-
-
 }
index 51af3ddba7437d16e0fb8b2c22044c82ecc4d48a..ec73e3044249d9213fe8f10bcbe8411632524d53 100644 (file)
@@ -145,8 +145,6 @@ public interface IPreferenceKeys {
 
     public static final String SHOW_ADVANCED_MEDIA_SECTION = "eu.etaxonomy.taxeditor.media.showAdvancedMedia";
 
-    public static final String ALWAYS_OPEN_SPECIMEN_IN_EDITOR = "eu.etaxonomy.taxeditor.specimen.alwaysOpenSpecimenInEditor";
-
     public static final String PROMPT_FOR_OPEN_SPECIMEN_IN_EDITOR = "eu.etaxonomy.taxeditor.specimen.promptForOpenSpecimenInEditor";
 
     // TODO RL
index d9a9ac3cc47bcd9ec02c87aa489635523a2dff21..b0f25bddb25af39febf855f8a4b6b6b86c14199e 100644 (file)
@@ -9,9 +9,7 @@
 */
 package eu.etaxonomy.taxeditor.preference;
 
-import org.eclipse.jface.dialogs.MessageDialogWithToggle;
 import org.eclipse.jface.preference.BooleanFieldEditor;
-import org.eclipse.jface.preference.ComboFieldEditor;
 import org.eclipse.jface.preference.FieldEditorPreferencePage;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
@@ -39,10 +37,6 @@ public class SpecimenOrObservationPreferences extends FieldEditorPreferencePage
         addField(new BooleanFieldEditor(IPreferenceKeys.SHOW_TAXON_ASSOCIATIONS,
                 "Show taxon associations of a specimen in the details view",
                 getFieldEditorParent()));
-        addField(new ComboFieldEditor(IPreferenceKeys.ALWAYS_OPEN_SPECIMEN_IN_EDITOR,
-                "Open newly created specimens in specimen editor", new String[][] {
-                        { "always", MessageDialogWithToggle.ALWAYS }, { "never", MessageDialogWithToggle.NEVER } },
-                getFieldEditorParent()));
     }
 
 
index f6752d97249a171a4889be32dccbf539e6062731..a90ce1c9bca1c861a41b1d44c3dcd2411259cd3b 100644 (file)
@@ -34,6 +34,7 @@ import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.occurrence.Collection;
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
 import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.taxon.Classification;
 import eu.etaxonomy.cdm.model.taxon.Synonym;
@@ -103,10 +104,13 @@ public class SelectionDialogFactory {
                        return null;
                }
                if(clazz.equals(DerivedUnit.class)){
-                       return (T) DerivedUnitSelectionDialog.select(shell, conversation, (DerivedUnit) currentSelection);
+                   return (T) DerivedUnitSelectionDialog.select(shell, conversation, (DerivedUnit) currentSelection);
                }
                if(clazz.equals(FieldUnit.class)){
-                       return (T) FieldUnitSelectionDialog.select(shell, conversation, (FieldUnit) currentSelection);
+                   return (T) FieldUnitSelectionDialog.select(shell, conversation, (FieldUnit) currentSelection);
+               }
+               if(clazz.equals(SpecimenOrObservationBase.class)){
+                   return (T) SpecimenOrObservationBaseSelectionDialog.select(shell, conversation, (SpecimenOrObservationBase) currentSelection);
                }
                if(clazz.equals(NamedArea.class)){
                    if(parentElement instanceof IEntityElement && ((IEntityElement) parentElement).getEntity() instanceof DerivedUnitFacade){
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SpecimenOrObservationBaseSelectionDialog.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SpecimenOrObservationBaseSelectionDialog.java
new file mode 100644 (file)
index 0000000..589b084
--- /dev/null
@@ -0,0 +1,67 @@
+// $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.ui.dialog.selection;
+
+import java.util.UUID;
+
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.api.service.IOccurrenceService;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
+import eu.etaxonomy.taxeditor.newWizard.NewDerivedUnitBaseWizard;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author pplitzner
+ */
+public class SpecimenOrObservationBaseSelectionDialog extends
+               AbstractFilteredCdmResourceSelectionDialog<SpecimenOrObservationBase> {
+
+       public static SpecimenOrObservationBase select(Shell shell, ConversationHolder conversation, SpecimenOrObservationBase observation){
+               SpecimenOrObservationBaseSelectionDialog dialog = new SpecimenOrObservationBaseSelectionDialog(shell, conversation,
+                               "Choose field unit or derived unit", false, SpecimenOrObservationBaseSelectionDialog.class.getCanonicalName(), observation);
+               return getSelectionFromDialog(dialog);
+       }
+
+       protected SpecimenOrObservationBaseSelectionDialog(Shell shell, ConversationHolder conversation,
+                       String title, boolean multi, String settings,
+                       SpecimenOrObservationBase cdmObject) {
+               super(shell, conversation, title, multi, settings, cdmObject);
+       }
+
+       /** {@inheritDoc} */
+       @Override
+       protected SpecimenOrObservationBase getPersistentObject(UUID uuid) {
+               Object object = CdmStore.getService(IOccurrenceService.class).load(uuid);
+               return HibernateProxyHelper.deproxy(object, SpecimenOrObservationBase.class);
+       }
+
+       /** {@inheritDoc} */
+       @Override
+       protected void initModel() {
+               model = CdmStore.getService(IOccurrenceService.class).getUuidAndTitleCache();
+       }
+
+       /** {@inheritDoc} */
+       @Override
+       protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
+               return new NewDerivedUnitBaseWizard();
+       }
+
+       /** {@inheritDoc} */
+       @Override
+       protected String getNewWizardLinkText() {
+               return String.format("Create a new <a>%1s</a>", "field unit/derived unit");
+       }
+}
index a50561e501a82bb5de8d37b8de0b2fb76dfdcc85..ed5059677ad4d0b7e153026f43f59670051063ac 100644 (file)
@@ -569,16 +569,19 @@ public abstract class AbstractFormSection<ENTITY> extends Section implements ISe
         */
        @Override
     public ConversationHolder getConversationHolder() {
-               if(getParentElement() instanceof RootElement || getParentElement() == null){
-
-                       IEditorPart activeEditor = AbstractUtility.getActiveEditor();
-                       if(activeEditor instanceof IConversationEnabled){
-                               ConversationHolder conversation = ((IConversationEnabled) AbstractUtility.getActiveEditor()).getConversationHolder();
-                               return conversation;
-                       }
-               }else if(getParentElement() instanceof IConversationEnabled){
-                       return ((IConversationEnabled) getParentElement()).getConversationHolder();
-               }
+           if(AbstractUtility.getActivePart() instanceof IConversationEnabled){
+            return ((IConversationEnabled) AbstractUtility.getActivePart()).getConversationHolder();
+        }
+           if(getParentElement() instanceof RootElement || getParentElement() == null){
+
+               IEditorPart activeEditor = AbstractUtility.getActiveEditor();
+               if(activeEditor instanceof IConversationEnabled){
+                   ConversationHolder conversation = ((IConversationEnabled) AbstractUtility.getActiveEditor()).getConversationHolder();
+                   return conversation;
+               }
+           }else if(getParentElement() instanceof IConversationEnabled){
+               return ((IConversationEnabled) getParentElement()).getConversationHolder();
+           }
                MessagingUtils.messageDialog("Could not get conversation for AbstractFormSection",
                                getClass(), "There is an error in the implementation. There should have been an active editor but it wasn't",
                                new IllegalArgumentException());
index d0255238423d81458506fe3a027f3c8144f8e86d..1ba3c42ddd294369dc0a52e99c0d03b21d291030 100644 (file)
@@ -232,6 +232,8 @@ import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailElem
 import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenHierarchyDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenHierarchyDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationElement;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.derivedUnit.PreservedSpecimenCurrentDeterminationDetailSection;
@@ -1589,6 +1591,12 @@ public class CdmFormFactory extends FormToolkit {
         return section;
     }
 
+    public DerivedUnitTypeDesignationSection createDerivedUnitTypeDesignationSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
+        DerivedUnitTypeDesignationSection section = new DerivedUnitTypeDesignationSection(this, conversation, parentElement, style);
+        addAndAdaptSection(parentElement, section);
+        return section;
+    }
+
     public TaxonAssociationDetailSection createTaxonAssociationDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
         TaxonAssociationDetailSection section = new TaxonAssociationDetailSection(this, conversation, parentElement, selectionProvider, style);
         addAndAdaptSection(parentElement, section);
@@ -2503,8 +2511,14 @@ public class CdmFormFactory extends FormToolkit {
             element = new SynonymRelationshipDetailElement(this, parentElement, (SynonymRelationship) entity, removeListener,
                     style);
         } else if (entity instanceof SpecimenTypeDesignation) {
-            element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
-                    removeListener, style);
+            if(parentElement instanceof DerivedUnitTypeDesignationSection){
+                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
+                        removeListener, style);
+            }
+            else{
+                element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
+                        removeListener, style);
+            }
         } else if (entity instanceof StateData) {
             element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
         } else if (entity instanceof StatisticalMeasurementValue) {
index acfbf7c6dda406f8ac26826c8b90e1e1699e6064..b91fc58b7bc037b84d94919a443388e633e10669 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
  * 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.
  */
@@ -16,7 +16,7 @@ import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.Language;
 import eu.etaxonomy.cdm.model.common.LanguageString;
 import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
-import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
@@ -24,10 +24,6 @@ import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
 
 /**
- * <p>
- * IndividualsAssociationDetailElement class.
- * </p>
- * 
  * @author n.hoffmann
  * @created Jun 10, 2010
  * @version 1.0
@@ -36,26 +32,8 @@ public class IndividualsAssociationDetailElement extends
                AbstractDetailedDescriptionDetailElement<IndividualsAssociation> {
 
        private TextWithLabelElement text_description;
-       private EntitySelectionElement<DerivedUnit> selection_derivedUnit;
+       private EntitySelectionElement<SpecimenOrObservationBase> selection_derivedUnit;
 
-       /**
-        * <p>
-        * Constructor for IndividualsAssociationDetailElement.
-        * </p>
-        * 
-        * @param formFactory
-        *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
-        *            object.
-        * @param formElement
-        *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
-        *            object.
-        * @param entity
-        *            a
-        *            {@link eu.etaxonomy.cdm.model.description.IndividualsAssociation}
-        *            object.
-        * @param style
-        *            a int.
-        */
        public IndividualsAssociationDetailElement(CdmFormFactory formFactory,
                        ICdmFormElement formElement, IndividualsAssociation entity,
                        int style) {
@@ -67,9 +45,9 @@ public class IndividualsAssociationDetailElement extends
        protected void createControls(ICdmFormElement formElement,
                        IndividualsAssociation entity, int style) {
                selection_derivedUnit = formFactory
-                               .createSelectionElement(DerivedUnit.class,
-                                               getConversationHolder(), formElement, "Unit",
-                                               CdmBase.deproxy(entity.getAssociatedSpecimenOrObservation(),DerivedUnit.class),
+                               .createSelectionElement(SpecimenOrObservationBase.class,
+                                               getConversationHolder(), formElement, "Occurrence/Unit",
+                                               CdmBase.deproxy(entity.getAssociatedSpecimenOrObservation(),SpecimenOrObservationBase.class),
                                                EntitySelectionElement.ALL, style);
 
                text_description = formFactory.createMultiLineTextWithLabel(
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/association/DerivedUnitTypeDesignationElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/association/DerivedUnitTypeDesignationElement.java
new file mode 100644 (file)
index 0000000..d9b695a
--- /dev/null
@@ -0,0 +1,110 @@
+// $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.ui.section.occurrence.association;
+
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.swt.events.SelectionListener;
+
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.common.TermType;
+import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
+import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;
+import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
+import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.section.name.AbstractTypeDesignationElement;
+import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
+
+/**
+ * @author n.hoffmann
+ * @created May 17, 2010
+ * @version 1.0
+ */
+public class DerivedUnitTypeDesignationElement extends AbstractTypeDesignationElement<SpecimenTypeDesignation> {
+
+    private TermComboElement<SpecimenTypeDesignationStatus> combo_typeStatus;
+
+    private List<EntitySelectionElement<TaxonNameBase>> selectionTaxonNames;
+    private ICdmFormElement parentFormElement;
+    private int style;
+
+    private EntitySelectionElement<TaxonNameBase> selectionTaxonName;
+
+    public DerivedUnitTypeDesignationElement(CdmFormFactory formFactory,
+            AbstractFormSection section, SpecimenTypeDesignation entity,
+            SelectionListener removeListener, int style) {
+        super(formFactory, section, entity, removeListener, style);
+    }
+
+    @Override
+    public void setEntity(SpecimenTypeDesignation entity) {
+        super.setEntity(entity);
+        Set<TaxonNameBase> typifiedNames = entity.getTypifiedNames();
+        if(typifiedNames.size()==1){
+            selectionTaxonName.setEntity(typifiedNames.iterator().next());
+        }
+        else if(typifiedNames.size()>1){
+            formFactory.createLabel(getLayoutComposite(), "!!!!!!!!");
+        }
+
+        SpecimenTypeDesignationStatus typeStatus = (SpecimenTypeDesignationStatus) HibernateProxyHelper
+                .deproxy(entity.getTypeStatus());
+        combo_typeStatus.setSelection(typeStatus);
+        checkbox_notDesignated.setSelection(entity.isNotDesignated());
+
+//        for (TaxonNameBase taxonNameBase : typifiedNames) {
+//            EntitySelectionElement<TaxonNameBase> selectionElement = formFactory.createSelectionElement(
+//                    TaxonNameBase.class, getConversationHolder(), parentFormElement, "Scientific Name", null,
+//                    EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
+//            selectionElement.setEntity(taxonNameBase);
+//        }
+
+
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void createControls(ICdmFormElement element, int style) {
+        this.parentFormElement = element;
+        this.style = style;
+
+        selectionTaxonName = formFactory.createSelectionElement(
+                TaxonNameBase.class, getConversationHolder(), parentFormElement, "Scientific Name", null,
+                EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
+
+        combo_typeStatus = formFactory.createDefinedTermComboElement(TermType.SpecimenTypeDesignationStatus,
+                parentFormElement, "Designation Status", null, style);
+
+        super.createControls(element, style);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void handleEvent(Object eventSource) {
+        if (eventSource == selectionTaxonName) {
+            selectionTaxonName.getSelection().addTypeDesignation(getEntity(), false);
+        } else if (eventSource == combo_typeStatus) {
+            getEntity().setTypeStatus(combo_typeStatus.getSelection());
+        } else if (eventSource == checkbox_notDesignated) {
+            getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
+        } else if (eventSource == selection_reference) {
+            getEntity().setCitation(selection_reference.getSelection());
+        } else if (eventSource == text_referenceDetail) {
+            getEntity().setCitationMicroReference(
+                    text_referenceDetail.getText());
+        }
+    }
+
+}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/association/DerivedUnitTypeDesignationSection.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/association/DerivedUnitTypeDesignationSection.java
new file mode 100644 (file)
index 0000000..e63f84b
--- /dev/null
@@ -0,0 +1,91 @@
+// $Id$
+/**
+* Copyright (C) 2015 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.ui.section.occurrence.association;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
+import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
+
+/**
+ * @author pplitzner
+ * @date Oct 29, 2015
+ *
+ */
+public class DerivedUnitTypeDesignationSection extends AbstractEntityCollectionSection<DerivedUnitFacade, SpecimenTypeDesignation> {
+
+    private Collection<SpecimenTypeDesignation> typeDesignations;
+
+    public DerivedUnitTypeDesignationSection(CdmFormFactory formFactory,
+            ConversationHolder conversation, ICdmFormElement parentElement, int style) {
+        super(formFactory, conversation, parentElement, "Type Designations", style);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Collection<SpecimenTypeDesignation> getCollection(DerivedUnitFacade entity) {
+        typeDesignations = entity.innerDerivedUnit().getSpecimenTypeDesignations();
+        return typeDesignations;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public SpecimenTypeDesignation createNewElement() {
+        return SpecimenTypeDesignation.NewInstance();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void addElement(SpecimenTypeDesignation element) {
+        element.setTypeSpecimen(getEntity().innerDerivedUnit());
+        typeDesignations.add(element);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void removeElement(SpecimenTypeDesignation element) {
+        List<SpecimenTypeDesignation> toRemove = new ArrayList<SpecimenTypeDesignation>();
+        for (SpecimenTypeDesignation specimenTypeDesignation : typeDesignations) {
+            if(element.equals(specimenTypeDesignation)){
+                toRemove.add(specimenTypeDesignation);
+            }
+        }
+        for (SpecimenTypeDesignation specimenTypeDesignation : toRemove) {
+            specimenTypeDesignation.removeType();
+            Set<TaxonNameBase> names = specimenTypeDesignation.getTypifiedNames();
+            for (TaxonNameBase taxonNameBase : names) {
+                taxonNameBase.removeTypeDesignation(specimenTypeDesignation);
+            }
+        }
+        typeDesignations.removeAll(toRemove);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String getEmptyString() {
+        return "No type designation yet.";
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    protected String getTooltipString() {
+        return "Add a type designation";
+    }
+
+
+}
\ No newline at end of file
index 4ff63d538b054474d860e11497154cc29f6843fa..53d9ea6aba3146b8216d25b0d01c4f5f37fa8613 100644 (file)
@@ -11,8 +11,6 @@ package eu.etaxonomy.taxeditor.ui.section.occurrence.association;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
 
 import org.eclipse.core.commands.Command;
 import org.eclipse.core.commands.ExecutionException;
@@ -36,10 +34,6 @@ import org.eclipse.ui.handlers.IHandlerService;
 
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.api.service.IOccurrenceService;
-import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
-import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
-import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.store.CdmStore;
@@ -55,9 +49,7 @@ import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
  */
 public class TaxonAssociationDetailElement extends AbstractCdmDetailElement<DerivedUnitFacade> implements IDoubleClickListener{
 
-
     private TableViewer associationsViewer;
-    private TableViewer typeDesignationViewer;
 
     public TaxonAssociationDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) {
         super(formFactory, formElement);
@@ -70,7 +62,6 @@ public class TaxonAssociationDetailElement extends AbstractCdmDetailElement<Deri
         //TODO add context menu for deleting associations
 
         Collection<TaxonBase<?>> associatedTaxa = CdmStore.getService(IOccurrenceService.class).listAssociatedTaxa(entity.innerDerivedUnit(), null, null, null, null);
-        Collection<SpecimenTypeDesignation> typeDesignations = CdmStore.getService(IOccurrenceService.class).listTypeDesignations(entity.innerDerivedUnit(), null, null, null, null);
 
         if(!associatedTaxa.isEmpty()){
             associationsViewer = new TableViewer(getLayoutComposite(), SWT.FULL_SELECTION);
@@ -84,28 +75,6 @@ public class TaxonAssociationDetailElement extends AbstractCdmDetailElement<Deri
             label.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
         }
 
-        //TODO implement service method for this which is just used in the label provider
-        Collection<TaxonBase<?>> typedTaxa = new HashSet<TaxonBase<?>>();
-        for (SpecimenTypeDesignation specimenTypeDesignation : typeDesignations) {
-            for (TaxonNameBase taxonNameBase : specimenTypeDesignation.getTypifiedNames()) {
-                Set taxa = taxonNameBase.getTaxa();
-                for (Object taxon : taxa) {
-                    if(taxon instanceof CdmBase && ((CdmBase)taxon).isInstanceOf(TaxonBase.class)){
-                        typedTaxa.add(HibernateProxyHelper.deproxy(taxon, TaxonBase.class));
-                    }
-                }
-            }
-        }
-        if(!typedTaxa.isEmpty()){
-            Label typeLabel = formFactory.createLabel(getLayoutComposite(), "Type Designations");
-            typeLabel.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
-
-            typeDesignationViewer = new TableViewer(getLayoutComposite(), SWT.FULL_SELECTION);
-            typeDesignationViewer.getTable().setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
-            typeDesignationViewer.setContentProvider(new ArrayContentProvider());
-            typeDesignationViewer.setInput(typedTaxa);
-            typeDesignationViewer.addDoubleClickListener(this);
-        }
     }
 
     /** {@inheritDoc} */
index a9175681804242fd4de0d0f0ebc5b5ffc80ca804..22d5dd7a3972bc36b728f15cf3111bc1a50218bb 100644 (file)
@@ -30,6 +30,9 @@ import eu.etaxonomy.cdm.model.molecular.Primer;
 import eu.etaxonomy.cdm.model.name.NonViralName;
 import eu.etaxonomy.cdm.model.occurrence.Collection;
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
+import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
@@ -102,13 +105,21 @@ public class EditFromSelectionWizard extends Wizard implements
                        addPage(new NonViralNameWizardPage(formFactory,
                                        selectionElement.getConversationHolder(),
                                        (NonViralName) entity));
-               } else if (entity instanceof DerivedUnit) {
+               } else if (entity instanceof SpecimenOrObservationBase) {
 
                        DerivedUnitFacade facade;
                        try {
-                               facade = DerivedUnitFacade.NewInstance(
-                                               (DerivedUnit) entity,
-                                               PreferencesUtil.getDerivedUnitConfigurator());
+                           if(((SpecimenOrObservationBase) entity).isInstanceOf(DerivedUnit.class)){
+                               facade = DerivedUnitFacade.NewInstance(
+                                       HibernateProxyHelper.deproxy(entity, DerivedUnit.class),
+                                       PreferencesUtil.getDerivedUnitConfigurator());
+                           }
+                           else {
+                    facade = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.FieldUnit,
+                            HibernateProxyHelper.deproxy(entity, FieldUnit.class),
+                            PreferencesUtil.getDerivedUnitConfigurator());
+                           }
+
                        } catch (DerivedUnitFacadeNotSupportedException e) {
                                // we should never get here
                                throw new IllegalStateException();
@@ -120,8 +131,10 @@ public class EditFromSelectionWizard extends Wizard implements
                                        selectionElement.getConversationHolder(), facade));
                        addPage(new FieldUnitWizardPage(formFactory,
                                        selectionElement.getConversationHolder(), facade));
-                       addPage(new DerivedUnitBaseWizardPage(formFactory,
-                                       selectionElement.getConversationHolder(), facade));
+                       if(facade.innerDerivedUnit()!=null){
+                           addPage(new DerivedUnitBaseWizardPage(formFactory,
+                                   selectionElement.getConversationHolder(), facade));
+                       }
                } else if (entity instanceof Collection) {
                        addPage(new CollectionWizardPage(formFactory,
                                        selectionElement.getConversationHolder(),
index 27be236e307398262fb4612ca8fef58a28b159ef..f9cedbdb8dd9de570e31e1d1243aa24c7d4b8341 100644 (file)
@@ -186,7 +186,7 @@ public abstract class AbstractCdmViewPart extends ViewPart implements ISelection
     }
 
     @Override
-    public  List<CdmBase> getRootEntities() {
+    public  List<? extends CdmBase> getRootEntities() {
         return Arrays.asList((CdmBase)getViewer().getInput());
     }
 
index 65efef6d075eeec5e9cadf4f655ef02734a5e546..27b80b47a68ad4948ec1c0ad5a34a2800b121a9d 100644 (file)
@@ -1,6 +1,7 @@
 package eu.etaxonomy.taxeditor.view.derivateSearch;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
@@ -45,8 +46,8 @@ public class DerivateContentProvider implements ITreeContentProvider {
        @Override
        public Object[] getElements(Object inputElement) {
            rootNodes = new ArrayList<TreeNode>();
-           if(inputElement instanceof Set){
-               for (Object o: (Set)inputElement) {
+           if(inputElement instanceof Collection){
+               for (Object o: (Collection)inputElement) {
                    if(o instanceof SpecimenOrObservationBase){
                        SpecimenOrObservationBase<?> rootElement = (SpecimenOrObservationBase<?>)o;
                        if(rootElement!=null){
index 7b9a8d0630138f0f4bd428a3a5a07504709c9611..ad1ec3cf1198e5ad65c0372b6fdbb11960bd8355 100644 (file)
@@ -9,7 +9,13 @@
 */
 package eu.etaxonomy.taxeditor.view.derivateSearch;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 import java.util.UUID;
 
@@ -19,6 +25,8 @@ import org.eclipse.swt.graphics.Image;
 import org.hibernate.LazyInitializationException;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.api.service.IOccurrenceService;
+import eu.etaxonomy.cdm.api.service.molecular.ISequenceService;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.DefinedTerm;
@@ -26,6 +34,8 @@ import eu.etaxonomy.cdm.model.common.Identifier;
 import eu.etaxonomy.cdm.model.molecular.DnaSample;
 import eu.etaxonomy.cdm.model.molecular.Sequence;
 import eu.etaxonomy.cdm.model.molecular.SingleRead;
+import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
 import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
 import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
@@ -48,7 +58,9 @@ public class DerivateLabelProvider extends ColumnLabelProvider {
 
     private static final String NO_SAMPLE_DESIGNATION = "[no sample designation]";
 
-    private Set<SingleRead> multiLinkSingleReads;
+    private static Set<SingleRead> multiLinkSingleReads;
+
+    private static Map<DerivedUnit, List<SpecimenTypeDesignation>> typeDesignations;
 
     private ConversationHolder conversation;
 
@@ -151,7 +163,9 @@ public class DerivateLabelProvider extends ColumnLabelProvider {
             derivate = node.getValue();
         }
 
-        conversation.bind();
+        if(conversation!=null){
+            conversation.bind();
+        }
 
         final String emptyString = "";
         final String separator = " ";
@@ -215,6 +229,12 @@ public class DerivateLabelProvider extends ColumnLabelProvider {
         else if(derivate instanceof DerivedUnit){
             DerivedUnit derivedUnit = (DerivedUnit)derivate;
             if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.PreservedSpecimen){
+                //check for type designation
+                if(typeDesignations.get(derivedUnit)==null){
+                    for (SpecimenTypeDesignation specimenTypeDesignation : CdmStore.getService(IOccurrenceService.class).listTypeDesignations(derivedUnit, null, null, null, null)) {
+                        addTypeDesignation(derivedUnit, specimenTypeDesignation);
+                    }
+                }
                 //java.util.Collection<FieldUnit> fieldUnits = CdmStore.getService(IOccurrenceService.class).getFieldUnits(derivedUnit.getUuid());
                 //TODO : This is not generic anymore for performance reasons
                 Set<SpecimenOrObservationBase> originals = derivedUnit.getOriginals();
@@ -236,6 +256,20 @@ public class DerivateLabelProvider extends ColumnLabelProvider {
                 }
                 String mostSignificantIdentifier = derivedUnit.getMostSignificantIdentifier();
                 label += mostSignificantIdentifier!=null?mostSignificantIdentifier+separator:emptyString;
+                //type designation extension
+                List<SpecimenTypeDesignation> list = typeDesignations.get(derivedUnit);
+                if(list!=null){
+                    for (SpecimenTypeDesignation specimenTypeDesignation : list) {
+                        label += "("+specimenTypeDesignation.getTypeStatus()+" of ";
+                        for (TaxonNameBase taxonNameBase : specimenTypeDesignation.getTypifiedNames()) {
+                            label += taxonNameBase+separator;
+                        }
+                        if(label.endsWith(separator)){
+                            label = label.substring(0, label.length()-separator.length());
+                        }
+                        label += ")";
+                    }
+                }
             }
             else if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.TissueSample){
                 //TissueSample should only be created by using it's own class
@@ -292,9 +326,6 @@ public class DerivateLabelProvider extends ColumnLabelProvider {
         return label;
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.jface.viewers.ColumnLabelProvider#getImage(java.lang.Object)
-     */
     @Override
     public Image getImage(Object element) {
         if(element instanceof TreeNode){
@@ -348,7 +379,7 @@ public class DerivateLabelProvider extends ColumnLabelProvider {
             }
 
             else if(cdmBase.isInstanceOf(SingleRead.class)){
-                if(multiLinkSingleReads.contains(element)){
+                if(multiLinkSingleReads!=null && multiLinkSingleReads.contains(element)){
                     return ImageResources.getImage(ImageResources.SINGLE_READ_DERIVATE_MULTILINK);
                 }
                 else{
@@ -379,10 +410,30 @@ public class DerivateLabelProvider extends ColumnLabelProvider {
     }
 
     /**
-     * @param multiLinkSingleReads2
+     * Refreshes cached label extensions
+     * @param multiLinkSingleReads
      */
-    public void setMultiLinkSingleReads(Set<SingleRead> multiLinkSingleReads) {
-        this.multiLinkSingleReads = multiLinkSingleReads;
+    public void refresh() {
+        DerivateLabelProvider.multiLinkSingleReads = new HashSet<SingleRead>();
+        for(Entry<SingleRead, Collection<Sequence>> entry:CdmStore.getService(ISequenceService.class).getSingleReadSequencesMap().entrySet()){
+            if(entry.getValue().size()>1){
+                multiLinkSingleReads.add(entry.getKey());
+            }
+        }
+        DerivateLabelProvider.typeDesignations = new HashMap<DerivedUnit, List<SpecimenTypeDesignation>>();
+    }
+
+    private static void addTypeDesignation(DerivedUnit derivedUnit, SpecimenTypeDesignation typeDesignation){
+        List<SpecimenTypeDesignation> list = typeDesignations.get(derivedUnit);
+        if(list==null){
+            list = new ArrayList<SpecimenTypeDesignation>();
+        }
+        list.add(typeDesignation);
+        typeDesignations.put(derivedUnit, list);
+    }
+
+    public static Set<SingleRead> getMultiLinkSingleReads() {
+        return multiLinkSingleReads;
     }
 
 }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateSearchView.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateSearchView.java
deleted file mode 100644 (file)
index 8a14a5a..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-// $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.view.derivateSearch;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.part.ViewPart;
-
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
-import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
-import eu.etaxonomy.taxeditor.model.IContextListener;
-import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
-import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
-import eu.etaxonomy.taxeditor.store.CdmStore;
-
-/**
- * This view allows to search for and filter {@link SpecimenOrObservationBase}s and display
- * the results in a list. The results can be selected and opened in an editor.
- */
-public class DerivateSearchView extends ViewPart implements IContextListener, ICdmEntitySessionEnabled {
-
-    public static final String ID = "eu.etaxonomy.taxeditor.view.derivateSearch.DerivateSearchView";
-    private DerivateSearchCompositeController derivateSearchCompositeController;
-    private ConversationHolder conversationHolder;
-    private ICdmEntitySession cdmEntitySession;
-
-    /**
-     * Constructs a new DerivateSearchView and registers it to listen to context changes
-     */
-    public DerivateSearchView() {
-        CdmStore.getContextManager().addContextListener(this);
-    }
-
-    @Override
-    public void createPartControl(Composite parent) {
-
-        derivateSearchCompositeController = new DerivateSearchCompositeController(parent, this);
-        getSite().setSelectionProvider(derivateSearchCompositeController.getResultViewer());
-        derivateSearchCompositeController.setEnabled(CdmStore.isActive());
-
-        //create context menu
-        MenuManager menuManager = new MenuManager();
-        getSite().registerContextMenu(menuManager, derivateSearchCompositeController.getResultViewer());
-        Control control = derivateSearchCompositeController.getResultViewer().getControl();
-        Menu menu = menuManager.createContextMenu(control);
-        control.setMenu(menu);
-    }
-
-    @Override
-    public void setFocus() {
-        derivateSearchCompositeController.setFocus();
-        //make sure to bind again if maybe in another view the conversation was unbound
-        if(getConversationHolder()!=null && !getConversationHolder().isClosed() && !getConversationHolder().isBound()){
-            getConversationHolder().bind();
-        }
-        if(getCdmEntitySession() != null) {
-            getCdmEntitySession().bind();
-        }
-    }
-
-    @Override
-    public void contextAboutToStop(IMemento memento, IProgressMonitor monitor) {
-    }
-
-    @Override
-    public void contextStop(IMemento memento, IProgressMonitor monitor) {
-        derivateSearchCompositeController.setEnabled(false);
-        derivateSearchCompositeController.reset();
-    }
-
-    @Override
-    public void contextStart(IMemento memento, IProgressMonitor monitor) {
-        derivateSearchCompositeController.setEnabled(true);
-    }
-
-    @Override
-    public void contextRefresh(IProgressMonitor monitor) {
-        initConversation();
-        initSession();
-    }
-
-    private void initSession() {
-        if(CdmStore.isActive()) {
-            cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
-        }
-    }
-
-    private void initConversation(){
-        if(conversationHolder==null){
-            conversationHolder = CdmStore.createConversation();
-            derivateSearchCompositeController.setConversation(conversationHolder);
-        }
-    }
-
-    @Override
-    public void workbenchShutdown(IMemento memento, IProgressMonitor monitor) {
-    }
-
-    public ConversationHolder getConversationHolder() {
-        if(CdmStore.isActive() && conversationHolder==null){
-            initConversation();
-        }
-        return conversationHolder;
-    }
-
-
-    @Override
-    public void dispose() {
-        if(conversationHolder!=null){
-            conversationHolder.close();
-        }
-
-        if(cdmEntitySession != null) {
-            cdmEntitySession.dispose();
-        }
-        super.dispose();
-    }
-
-
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
-     */
-    @Override
-    public ICdmEntitySession getCdmEntitySession() {
-        initSession();
-        return cdmEntitySession;
-    }
-
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
-     */
-    @Override
-    public <T extends CdmBase> Collection<T> getRootEntities() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap()
-     */
-    @Override
-    public Map<Object, List<String>> getPropertyPathsMap() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-}
index d3f20092474906c4d04a7895f2f9b15320d32b9c..0f0df4522f04f5a863b8c5b756af12afdf544653 100644 (file)
@@ -18,6 +18,7 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IWorkbenchPart;
 
+import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.description.Feature;
@@ -52,7 +53,7 @@ public class DetailsViewPart extends AbstractCdmEditorViewPart implements IPartC
 
        @Override
     protected void selectionChanged_internal(IWorkbenchPart part, ISelection selection){
-           if(AbstractUtility.getActiveEditor() == null){
+           if(AbstractUtility.getActiveEditor() == null && !(AbstractUtility.getActivePart() instanceof IConversationEnabled)){
             showEmptyPage();
             return;
         }
index 6a0dab25f8ac9b57a3da8a371495f890d70fed8a..aa63bfbf3d72737b1f8391c9cc22ac56d375d9a4 100644 (file)
@@ -90,6 +90,7 @@ import eu.etaxonomy.taxeditor.ui.section.occurrence.EmptySection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailSection;
@@ -594,6 +595,10 @@ public class DetailsViewer extends AbstractCdmDataViewer {
             addPart(determinationDetailSection);
         }
 
+        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+        DerivedUnitTypeDesignationSection derivedUnitTypeDesignationSection = formFactory.createDerivedUnitTypeDesignationSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+        addPart(derivedUnitTypeDesignationSection);
+
     }
 
     private void createFieldUnitSection(RootElement parent) {