fix #7009 Replace part descriptor IDs in open handler with constants
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / group / authority / CdmAuthorityEditorInput.java
index 0e2553a51756e8a4d3dad6c6c607ee3dd78a533b..1e52926c7127002969f92b9e723292750571c617 100644 (file)
@@ -1,66 +1,63 @@
 /**
 * 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.
 */
 package eu.etaxonomy.taxeditor.editor.group.authority;
 
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.UUID;
 
-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.conversation.IConversationEnabled;
 import eu.etaxonomy.cdm.api.service.IGroupService;
 import eu.etaxonomy.cdm.model.common.Group;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
  * Editor input for the {@link CdmAuthorityEditor}.
- * 
+ *
  * @author cmathew
  * @created Mar 28, 2013
  *
  */
 
-public class CdmAuthorityEditorInput implements IEditorInput, IConversationEnabled {
+public class CdmAuthorityEditorInput extends CdmEntitySessionInput implements IConversationEnabled {
        private ConversationHolder conversation;
        private Group group;
-       
+
        protected CdmAuthorityEditorInput(ConversationHolder conversation, Group group) {
+           super(true);
                this.conversation = conversation;
-               this.group = group;
-               
+               this.group = CdmApplicationState.getCurrentAppConfig().getGroupService().load(group.getUuid());
+
        }
-       
+
        /**
         * Creates a new instance of the input for a given group.
-        * 
+        *
         * @param groupUuid
         * @return
         * @throws Exception
         */
        public static CdmAuthorityEditorInput NewInstance(UUID groupUuid) throws Exception{
                ConversationHolder conversation = CdmStore.createConversation();
-               Group group = CdmStore.getService(IGroupService.class).load(groupUuid, null);                   
+               Group group = CdmStore.getService(IGroupService.class).load(groupUuid, null);
                return new CdmAuthorityEditorInput(conversation, group);
        }
-       
-       /* (non-Javadoc)
-        * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
-        */
-       @Override
+
        public Object getAdapter(Class adapter) {
                if (adapter == Group.class) {
                        return this.group;
-               }               
-               
+               }
+
                return null;
        }
        /* (non-Javadoc)
@@ -69,7 +66,7 @@ public class CdmAuthorityEditorInput implements IEditorInput, IConversationEnabl
        @Override
        public void update(CdmDataChangeMap changeEvents) {
                // TODO Auto-generated method stub
-               
+
        }
        /* (non-Javadoc)
         * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
@@ -78,44 +75,10 @@ public class CdmAuthorityEditorInput implements IEditorInput, IConversationEnabl
        public ConversationHolder getConversationHolder() {
                return this.conversation;
        }
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IEditorInput#exists()
-        */
-       @Override
-       public boolean exists() {
-               return group != null;
-       }
-       /* (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 group.getName();
        }
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IEditorInput#getPersistable()
-        */
-       @Override
-       public IPersistableElement getPersistable() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IEditorInput#getToolTipText()
-        */
-       @Override
-       public String getToolTipText() {
-               return getName();
-       }       
-       
+
        /* (non-Javadoc)
         * @see java.lang.Object#equals(java.lang.Object)
         */
@@ -129,13 +92,30 @@ public class CdmAuthorityEditorInput implements IEditorInput, IConversationEnabl
                }
                return super.equals(object);
        }
-       
+
        /**
         * Getter method for group member.
-        * 
+        *
         * @return
         */
        public Group getGroup() {
                return this.group;
        }
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
+     */
+    @Override
+    public Collection<Group> getRootEntities() {
+        return Arrays.asList(group);
+    }
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
+     */
+    @Override
+    public void merge() {
+        group = CdmStore.getService(IGroupService.class).merge(group, true).getMergedEntity();
+
+    }
 }