/**
* 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 IEditorInput, 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)
*/
public Object getAdapter(Class adapter) {
if (adapter == Group.class) {
return this.group;
- }
-
+ }
+
return null;
}
/* (non-Javadoc)
@Override
public void update(CdmDataChangeMap changeEvents) {
// TODO Auto-generated method stub
-
+
}
/* (non-Javadoc)
* @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
@Override
public String getToolTipText() {
return getName();
- }
-
+ }
+
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
}
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() {
+ if(CdmStore.getCurrentSessionManager().isRemoting()) {
+ group = CdmStore.getService(IGroupService.class).merge(group, true).getMergedEntity();
+ }
+ }
}