Set taxon filter when opening derivativwe editor from taxon navigator
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / view / derivate / DerivateViewEditorInput.java
index 395e95a8f93cabfb93eabd7c0472137ce178495b..76358b0c4f0ffaf330bc8b2ffce631af5b3a77d9 100644 (file)
@@ -16,165 +16,70 @@ import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IPersistableElement;
 
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
-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.model.AbstractUtility;
-import eu.etaxonomy.taxeditor.store.CdmStore;
-
 /**
- * Editor input for the {@link DerivateView} which holds the currently selected derivate for which
- * the derivate hierarchy should be shown in the DerivateView.<br>
- * It also holds a {@link FieldUnit} which is the root of the hierarchy. (both may be the same object)
+ * Editor input for the {@link DerivateView}
+ *
  * @author pplitzner
- * @date 25.11.2013
+ * @date Nov 11, 2015
  *
  */
 public class DerivateViewEditorInput implements IEditorInput {
 
-    /**
-     * The selected derivate
-     */
-    private final SpecimenOrObservationBase<?> derivate;
-    /**
-     * The root of the hierarchy (may be the same object as the derivate)
-     */
-    private FieldUnit fieldUnit;
-
-    private ConversationHolder conversationHolder;
-
-    /**
-     * Creates an editor input for the {@link DerivateView} with the currently selected derivate and the
-     * corresponding {@link FieldUnit} (both may be the same object).
-     * @param derivateUuid the {@link UUID} of the derivate for which the derivate hierarchy should be shown
-     * @param fieldUnit the root of the hierarchy
-     */
-    public DerivateViewEditorInput(UUID derivateUuid) {
-        super();
-        this.conversationHolder = CdmStore.createConversation();
-        this.derivate = CdmStore.getCurrentApplicationConfiguration().getOccurrenceService().load(derivateUuid);
-        if(derivate instanceof FieldUnit){
-            this.fieldUnit = (FieldUnit) derivate;
-        }
-        else if(derivate instanceof DerivedUnit){
-            Collection<FieldUnit> fieldUnits = CdmStore.getCurrentApplicationConfiguration().getOccurrenceService().getFieldUnits(derivateUuid);
-            if(!fieldUnits.isEmpty()){
-                // TODO think about handling multiple parent FieldUnits
-                this.fieldUnit = fieldUnits.iterator().next();
-            }
-        }
-        if(fieldUnit==null){
-            AbstractUtility.errorDialog("Failed initializing editor", DerivateViewEditorInput.class, "No FieldUnit found!");
-        }
+    private Collection<UUID> derivativeUuids;
+    private UUID taxonUuid;
+
+    public DerivateViewEditorInput() {
+    }
+
+    public DerivateViewEditorInput(Collection<UUID> derivativeUuids, UUID taxonUuid) {
+        this.derivativeUuids = derivativeUuids;
+        this.taxonUuid = taxonUuid;
+    }
+
+    public DerivateViewEditorInput(Collection<UUID> derivativeUuids) {
+        this(derivativeUuids, null);
+    }
+
+    public Collection<UUID> getDerivativeUuids() {
+        return derivativeUuids;
+    }
+
+    public UUID getTaxonUuid() {
+        return taxonUuid;
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
-     */
     @Override
     public Object getAdapter(Class adapter) {
-        // TODO Auto-generated method stub
         return null;
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IEditorInput#exists()
-     */
     @Override
     public boolean exists() {
         return false;
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
-     */
     @Override
     public ImageDescriptor getImageDescriptor() {
-        // TODO Auto-generated method stub
         return null;
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IEditorInput#getName()
-     */
     @Override
     public String getName() {
-        return derivate.toString();
+        return getEditorName();
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IEditorInput#getPersistable()
-     */
     @Override
     public IPersistableElement getPersistable() {
         return null;
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IEditorInput#getToolTipText()
-     */
     @Override
     public String getToolTipText() {
-        return derivate.toString();
+        return getEditorName();
     }
 
-
-    /**
-     * @return the specimen
-     */
-    public SpecimenOrObservationBase<?> getDerivate() {
-        return derivate;
-    }
-
-    /**
-     * @return the fieldUnit
-     */
-    public FieldUnit getFieldUnit() {
-        return fieldUnit;
-    }
-
-    /**
-     * @return the conversationHolder
-     */
-    public ConversationHolder getConversationHolder() {
-        return conversationHolder;
-    }
-
-    /* (non-Javadoc)
-     * @see java.lang.Object#hashCode()
-     */
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((fieldUnit == null) ? 0 : fieldUnit.hashCode());
-        return result;
-    }
-
-    /* (non-Javadoc)
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        DerivateViewEditorInput other = (DerivateViewEditorInput) obj;
-        if (fieldUnit == null) {
-            if (other.fieldUnit != null) {
-                return false;
-            }
-        } else if (!fieldUnit.equals(other.fieldUnit)) {
-            return false;
-        }
-        return true;
+    private String getEditorName() {
+        return "Derivative Editor";
     }
 
 }