merge
[taxeditor.git] / eu.etaxonomy.taxeditor.navigation / src / main / java / eu / etaxonomy / taxeditor / navigation / key / polytomous / PolytomousKeyViewPart.java
index 015cabe4278db0fc7c7f7ecc74d20f2d0a4597d4..e6757a31ba5d57fcb2b4071587dab500ac2706a9 100644 (file)
@@ -4,6 +4,7 @@
 package eu.etaxonomy.taxeditor.navigation.key.polytomous;
 
 import java.util.List;
+import java.util.Map;
 
 import org.eclipse.core.commands.Command;
 import org.eclipse.core.commands.common.NotDefinedException;
@@ -33,7 +34,10 @@ import org.eclipse.ui.commands.ICommandService;
 import org.eclipse.ui.handlers.IHandlerService;
 import org.eclipse.ui.part.ViewPart;
 
+import eu.etaxonomy.cdm.api.application.CdmApplicationState;
 import eu.etaxonomy.cdm.api.application.CdmChangeEvent;
+import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
+import eu.etaxonomy.cdm.api.application.ICdmChangeListener;
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
 import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
@@ -55,7 +59,8 @@ import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
  *
  */
 public class PolytomousKeyViewPart extends ViewPart implements
-               IConversationEnabled, ICdmEntitySessionEnabled, IPostOperationEnabled {
+               IConversationEnabled, ICdmEntitySessionEnabled, IPostOperationEnabled,
+               ICdmChangeListener {
 
        private class FilterModifyListener implements ModifyListener{
                @Override
@@ -200,6 +205,7 @@ public class PolytomousKeyViewPart extends ViewPart implements
                conversation = CdmStore.createConversation();
                conversation.registerForDataStoreChanges(this);
                cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
+               CdmApplicationState.getCurrentDataChangeService().register(this);
 
                List<PolytomousKey> input = CdmStore.getService(IPolytomousKeyService.class).list(PolytomousKey.class, null, null, null, null);
                if(!viewer.getControl().isDisposed()){
@@ -251,6 +257,7 @@ public class PolytomousKeyViewPart extends ViewPart implements
            if(cdmEntitySession != null) {
                cdmEntitySession.dispose();
            }
+           CdmApplicationState.getCurrentDataChangeService().unregister(this);
                super.dispose();
        }
 
@@ -259,6 +266,8 @@ public class PolytomousKeyViewPart extends ViewPart implements
         */
        @Override
        public boolean postOperation(CdmBase objectAffectedByOperation) {
+               getConversationHolder().bind();
+               getConversationHolder().commit(true);
                viewer.refresh();
                return true;
        }
@@ -309,8 +318,19 @@ public class PolytomousKeyViewPart extends ViewPart implements
      */
     @Override
     public void onChange(CdmChangeEvent event) {
-        // TODO Auto-generated method stub
+        if(event.getAction() == Action.Delete && PolytomousKey.class.equals(event.getEntityType())) {
+            refresh();
+        }
+
+    }
 
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap()
+     */
+    @Override
+    public Map<Object, List<String>> getPropertyPathsMap() {
+        // TODO Auto-generated method stub
+        return null;
     }
 
 }