Merge branch 'develop' of wp5.e-taxonomy.eu:/var/git/taxeditor into remoting-4.0
authorCherian Mathew <c.mathew@bgbm.org>
Fri, 3 Jul 2015 10:09:47 +0000 (12:09 +0200)
committerCherian Mathew <c.mathew@bgbm.org>
Fri, 3 Jul 2015 10:09:47 +0000 (12:09 +0200)
Conflicts:
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java

1  2 
eu.etaxonomy.taxeditor.application/.classpath
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientOccurenceService.java

@@@ -3,7 -3,6 +3,6 @@@
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
        <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
        <classpathentry including="**/*.java" kind="src" path="src/main/java"/>
--      <classpathentry kind="src" path="src/main/resources"/>
-       <classpathentry kind="src" path="src/test/java/"/>
++      <classpathentry kind="src" path="src/test/java"/>
        <classpathentry kind="output" path="target/classes"/>
  </classpath>
@@@ -198,225 -181,210 +198,223 @@@ public class TaxonEditorInput extends C
      }
  
      /**
 -     * <p>NewEmptyInstance</p>
 +     * <p>NewInstance</p>
       *
 -     * @param parentNodeUuid a {@link java.util.UUID} object.
 +     * @param taxonNodeUuid a {@link java.util.UUID} object.
       * @return a {@link eu.etaxonomy.taxeditor.editor.TaxonEditorInput} object.
 +     * @throws java.lang.Exception if any.
       */
 -    public static TaxonEditorInput NewEmptyInstance(UUID parentNodeUuid){
 -      ConversationHolder conversation = CdmStore.createConversation();
 +    public static TaxonEditorInput NewInstance(UUID taxonNodeUuid) throws Exception {
 +        return new TaxonEditorInput(taxonNodeUuid, CdmType.TAXON_NODE);
  
 -              TaxonNameBase<?, ?> name = PreferencesUtil.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null);
 -              ITaxonTreeNode parentNode = CdmStore.getService(IClassificationService.class).getTreeNodeByUuid(parentNodeUuid);
 +    }
  
 -              Taxon newTaxon = Taxon.NewInstance(name, parentNode.getReference());
 -              TaxonNode newTaxonNode = parentNode.addChildTaxon(newTaxon, parentNode.getReference(), parentNode.getMicroReference());
 +    /**
 +     * <p>NewInstanceFromTaxonBase</p>
 +     *
 +     * @param taxonBaseUuid a {@link java.util.UUID} object.
 +     * @return a {@link eu.etaxonomy.taxeditor.editor.TaxonEditorInput} object.
 +     */
 +    public static TaxonEditorInput NewInstanceFromTaxonBase(UUID taxonBaseUuid){
 +        return new TaxonEditorInput(taxonBaseUuid, CdmType.TAXON_BASE);
 +    }
  
 -              // add the new taxon to the editors persistence context
 -              UUID newTaxonNodeUuid = CdmStore.getService(ITaxonNodeService.class).save(newTaxonNode).getUuid();
  
 -              return new TaxonEditorInput(newTaxonNode, conversation);
 +    /**
 +     * <p>NewEmptyInstance</p>
 +     *
 +     * @param parentNodeUuid a {@link java.util.UUID} object.
 +     * @return a {@link eu.etaxonomy.taxeditor.editor.TaxonEditorInput} object.
 +     */
 +    public static TaxonEditorInput NewEmptyInstance(UUID parentNodeUuid){
 +        return new TaxonEditorInput(parentNodeUuid, CdmType.PARENT_TAXON_NODE);
      }
  
 -      /* (non-Javadoc)
 -       * @see org.eclipse.ui.IEditorInput#exists()
 -       */
 -      /**
 -       * <p>exists</p>
 -       *
 -       * @return a boolean.
 -       */
 -      @Override
 +    /* (non-Javadoc)
 +     * @see org.eclipse.ui.IEditorInput#exists()
 +     */
 +    /**
 +     * <p>exists</p>
 +     *
 +     * @return a boolean.
 +     */
 +    @Override
      public boolean exists() {
 -              return taxonNode != null;
 -      }
 -
 -      /* (non-Javadoc)
 -       * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
 -       */
 -      /**
 -       * <p>getImageDescriptor</p>
 -       *
 -       * @return a {@link org.eclipse.jface.resource.ImageDescriptor} object.
 -       */
 -      @Override
 +        return taxonNode != null;
 +    }
 +
 +    /* (non-Javadoc)
 +     * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
 +     */
 +    /**
 +     * <p>getImageDescriptor</p>
 +     *
 +     * @return a {@link org.eclipse.jface.resource.ImageDescriptor} object.
 +     */
 +    @Override
      public ImageDescriptor getImageDescriptor() {
 -              return null;
 -      }
 -
 -      /* (non-Javadoc)
 -       * @see org.eclipse.ui.IEditorInput#getName()
 -       */
 -      /**
 -       * <p>getName</p>
 -       *
 -       * @return a {@link java.lang.String} object.
 -       */
 -      @Override
 +        return null;
 +    }
 +
 +    /* (non-Javadoc)
 +     * @see org.eclipse.ui.IEditorInput#getName()
 +     */
 +    /**
 +     * <p>getName</p>
 +     *
 +     * @return a {@link java.lang.String} object.
 +     */
 +    @Override
      public String getName() {
 -              if(getTaxon() == null){
 -                      return null;
 -              }
 -              TaxonNameBase<?, ?> name = getTaxon().getName();
 -              if (name == null || name.getTitleCache() == null) {
 -                      return "New taxon";
 -              } else {
 -                      return name.getTitleCache();
 -              }
 -      }
 -
 -      /* (non-Javadoc)
 -       * @see org.eclipse.ui.IEditorInput#getPersistable()
 -       */
 -      /**
 -       * <p>getPersistable</p>
 -       *
 -       * @return a {@link org.eclipse.ui.IPersistableElement} object.
 -       */
 -      @Override
 +        if(getTaxon() == null){
 +            return null;
 +        }
 +        TaxonNameBase<?, ?> name = getTaxon().getName();
 +        if (name == null || name.getTitleCache() == null) {
 +            return "New taxon";
 +        } else {
 +            return name.getTitleCache();
 +        }
 +    }
 +
 +    /* (non-Javadoc)
 +     * @see org.eclipse.ui.IEditorInput#getPersistable()
 +     */
 +    /**
 +     * <p>getPersistable</p>
 +     *
 +     * @return a {@link org.eclipse.ui.IPersistableElement} object.
 +     */
 +    @Override
      public IPersistableElement getPersistable() {
 -//            if(CdmStore.isActive()){
 -//                    TaxonNode test = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNode.getUuid());
 -//                    boolean isPersistable = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNode.getUuid()) != null;
 -//                    if (isPersistable) {
 -//                            return this;
 -//                    }
 -//            }
 -              return null;
 -      }
 -
 -      /* (non-Javadoc)
 -       * @see org.eclipse.ui.IEditorInput#getToolTipText()
 -       */
 -      /**
 -       * <p>getToolTipText</p>
 -       *
 -       * @return a {@link java.lang.String} object.
 -       */
 -      @Override
 +        //            if(CdmStore.isActive()){
 +        //                    TaxonNode test = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNode.getUuid());
 +        //                    boolean isPersistable = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNode.getUuid()) != null;
 +        //                    if (isPersistable) {
 +        //                            return this;
 +        //                    }
 +        //            }
 +        return null;
 +    }
 +
 +    /* (non-Javadoc)
 +     * @see org.eclipse.ui.IEditorInput#getToolTipText()
 +     */
 +    /**
 +     * <p>getToolTipText</p>
 +     *
 +     * @return a {@link java.lang.String} object.
 +     */
 +    @Override
      public String getToolTipText() {
 -              return getName();
 -      }
 -
 -      /* (non-Javadoc)
 -       * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
 -       */
 -      /** {@inheritDoc} */
 -      @Override
 +        return getName();
 +    }
 +
 +    /* (non-Javadoc)
 +     * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
 +     */
 +    /** {@inheritDoc} */
 +    @Override
      public Object getAdapter(Class adapter) {
  
 -              if (adapter == Taxon.class) {
 -                      return taxonNode.getTaxon();
 -              }
 +        if (adapter == Taxon.class) {
 +            return getTaxon();
 +        }
  
 -              if (adapter == TaxonNode.class) {
 -                      return taxonNode;
 -              }
 +        if (adapter == TaxonNode.class) {
 +            return taxonNode;
 +        }
  
 -              return null;
 -      }
 +        return null;
 +    }
  
 -      /**
 -       * {@inheritDoc}
 -       *
 -       * Overrides equals to ensure that a taxon can only be edited by
 -       * one editor at a time.
 -       */
 -      @Override
 +    /**
 +     * {@inheritDoc}
 +     *
 +     * Overrides equals to ensure that a taxon can only be edited by
 +     * one editor at a time.
 +     */
 +    @Override
      public boolean equals(Object obj) {
 -              if (TaxonEditorInput.class.equals(obj.getClass())
 -                              && getTaxon() != null
 -                              && getTaxon().equals(((TaxonEditorInput) obj).getTaxon())){
 -                      if(((TaxonEditorInput) obj).getInitiallySelectedTaxonBase() != null){
 -                              setInitiallySelectedTaxonBase(((TaxonEditorInput) obj).getInitiallySelectedTaxonBase());
 -                      }
 -                      return true;
 -              }
 -              return false;
 -      }
 -
 -      /**
 -       * <p>getTaxon</p>
 -       *
 -       * @return the taxon
 -       */
 -      public Taxon getTaxon(){
 -              return taxonNode.getTaxon();
 -      }
 -
 -      /**
 -       * <p>Getter for the field <code>taxonNode</code>.</p>
 -       *
 -       * @return the taxonNode
 -       */
 -      public TaxonNode getTaxonNode() {
 -              return taxonNode;
 -      }
 -
 -      /*
 -       * (non-Javadoc)
 -       * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
 -       */
 -      /**
 -       * <p>getConversationHolder</p>
 -       *
 -       * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
 -       */
 -      @Override
 +        if (TaxonEditorInput.class.equals(obj.getClass())
 +                && getTaxon() != null
 +                && getTaxon().equals(((TaxonEditorInput) obj).getTaxon())){
 +            if(((TaxonEditorInput) obj).getInitiallySelectedTaxonBase() != null){
 +                setInitiallySelectedTaxonBase(((TaxonEditorInput) obj).getInitiallySelectedTaxonBase());
 +            }
 +            return true;
 +        }
 +        return false;
 +    }
 +
 +    /**
 +     * <p>getTaxon</p>
 +     *
 +     * @return the taxon
 +     */
 +    public Taxon getTaxon(){
 +        Taxon taxon = CdmBase.deproxy(taxonNode.getTaxon(), Taxon.class);
 +        return taxon;
 +    }
 +
 +    /**
 +     * <p>Getter for the field <code>taxonNode</code>.</p>
 +     *
 +     * @return the taxonNode
 +     */
 +    public TaxonNode getTaxonNode() {
 +        return taxonNode;
 +    }
 +
 +    /*
 +     * (non-Javadoc)
 +     * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
 +     */
 +    /**
 +     * <p>getConversationHolder</p>
 +     *
 +     * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
 +     */
 +    @Override
      public ConversationHolder getConversationHolder() {
 -              return conversation;
 -      }
 -
 -      /*
 -       * (non-Javadoc)
 -       * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
 -       */
 -      /** {@inheritDoc} */
 -      @Override
 +        return conversation;
 +    }
 +
 +    /*
 +     * (non-Javadoc)
 +     * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
 +     */
 +    /** {@inheritDoc} */
 +    @Override
      public void update(CdmDataChangeMap events) {
 -              if(dataChangeBehavior == null){
 -                      dataChangeBehavior = new TaxonEditorInputDataChangeBehaviour(this);
 -              }
 -
 -              DataChangeBridge.handleDataChange(events, dataChangeBehavior);
 -      }
 -
 -      /* (non-Javadoc)
 -       * @see org.eclipse.ui.IPersistableElement#getFactoryId()
 -       */
 -      /**
 -       * <p>getFactoryId</p>
 -       *
 -       * @return a {@link java.lang.String} object.
 -       */
 -      @Override
 +        if(dataChangeBehavior == null){
 +            dataChangeBehavior = new TaxonEditorInputDataChangeBehaviour(this);
 +        }
 +
 +        DataChangeBridge.handleDataChange(events, dataChangeBehavior);
 +    }
 +
 +    /* (non-Javadoc)
 +     * @see org.eclipse.ui.IPersistableElement#getFactoryId()
 +     */
 +    /**
 +     * <p>getFactoryId</p>
 +     *
 +     * @return a {@link java.lang.String} object.
 +     */
 +    @Override
      public String getFactoryId() {
 -              return TaxonEditorInputFactory.getFactoryId();
 -      }
 -
 -      /* (non-Javadoc)
 -       * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
 -       */
 -      /** {@inheritDoc} */
 -      @Override
 +        return TaxonEditorInputFactory.getFactoryId();
 +    }
 +
 +    /* (non-Javadoc)
 +     * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
 +     */
 +    /** {@inheritDoc} */
 +    @Override
      public void saveState(IMemento memento) {
 -              TaxonEditorInputFactory.saveState(memento, this);
 -      }
 +        TaxonEditorInputFactory.saveState(memento, this);
 +    }
  
  
      /**