Add entity type to CdmChangeEvent and fixes #5139
authorCherian Mathew <c.mathew@bgbm.org>
Mon, 24 Aug 2015 12:33:09 +0000 (14:33 +0200)
committerCherian Mathew <c.mathew@bgbm.org>
Mon, 24 Aug 2015 12:33:09 +0000 (14:33 +0200)
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmChangeEvent.java
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigator.java
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/RemotingDeleteTaxonNodeOperation.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/RemotingCdmOperation.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java

index 26fb75d6803ff596edd56cd5ebd2131fe804e2cc..4dddf33c8db3ddd2c081921d2d067ea1f2390e7b 100644 (file)
@@ -30,6 +30,7 @@ public class CdmChangeEvent {
     private final Action action;
     private final Set<CdmBase> changedObjects;
     private final Class sourceType;
+    private Class entityType;
     private Object source;
 
     public CdmChangeEvent(Action action, Set<CdmBase> changedObjects, Class sourceType) {
@@ -45,6 +46,11 @@ public class CdmChangeEvent {
         this.sourceType = sourceType;
     }
 
+    public CdmChangeEvent(Action action, Set<CdmBase> changedObjects, Class sourceType, Class entityType) {
+        this(action, changedObjects, sourceType);
+        this.entityType = entityType;
+    }
+
     public CdmChangeEvent(Action action, Set<CdmBase> changedObjects, Object source) {
         this(action, changedObjects, source.getClass());
         this.source = source;
@@ -79,6 +85,10 @@ public class CdmChangeEvent {
         return source;
     }
 
+    public Class getEntityType() {
+        return entityType;
+    }
+
     public boolean hasChanges() {
         return changedObjects != null && !changedObjects.isEmpty();
     }
index ccf26252a58f1ab68c1288b765f1a6b617823ed5..d41b1489f4711b19ad724d8b9c9b7322dd383043 100644 (file)
@@ -33,6 +33,7 @@ import org.eclipse.ui.navigator.CommonNavigator;
 
 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;
@@ -524,6 +525,10 @@ public class TaxonNavigator extends CommonNavigator implements
      */
     @Override
     public void onChange(CdmChangeEvent event) {
+        if(event.getAction() == Action.Delete && Classification.class.equals(event.getEntityType())) {
+            refresh();
+            return;
+        }
         for(CdmBase cb : event.getChangedObjects()) {
             if(cb instanceof TaxonNode) {
                 TaxonNode tn = (TaxonNode)cb;
index 0445bc10bc9f95bf254de4108d08f1036134d578..e1df3bd07e20d6c7474da39d5c043529c026e799 100644 (file)
@@ -63,6 +63,7 @@ public class RemotingDeleteTaxonNodeOperation extends RemotingCdmUpdateOperation
             if(node instanceof TaxonNode) {
                 return CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().deleteTaxonNode(((TaxonNode)node).getUuid(), config);
             } else if(node instanceof Classification) {
+                entityType = Classification.class;
                 return CdmApplicationState.getCurrentAppConfig().getClassificationService().delete(((Classification)node).getUuid());
             }
         } else {
index 7084fa68a3625207669011e36b32ee0b263cad0a..129b96cdb9a02c9fb4aed230ead930991a9e2617 100644 (file)
@@ -33,6 +33,7 @@ public abstract class RemotingCdmOperation extends AbstractOperation {
     private final Object source;
     private final Action action;
     private final boolean async;
+    protected Class entityType;
 
     public RemotingCdmOperation(String label, Action action, Object source, boolean async) {
         super(label);
@@ -66,9 +67,8 @@ public abstract class RemotingCdmOperation extends AbstractOperation {
 
     protected void fireDataChangeEvent(UpdateResult updateResult) {
         Set<CdmBase> updatedObjects = updateResult.getUpdatedObjects();
-        if(updatedObjects != null && !updatedObjects.isEmpty()) {
-            CdmApplicationState.getCurrentDataChangeService().fireChangeEvent(new CdmChangeEvent(action, updatedObjects, source.getClass()), async);
-        }
+        CdmApplicationState.getCurrentDataChangeService()
+            .fireChangeEvent(new CdmChangeEvent(action, updatedObjects, source.getClass(), entityType), async);
     }
 
     protected void fireDataChangeEvent(CdmBase cdmBase) {
index ee7107e088d9dbf088922fc1f260a860e698bbae..19e24f0735ae70ccebc11e13d79aa5b5f54e4d1d 100644 (file)
@@ -689,9 +689,9 @@ public class RemotingLoginDialog extends Dialog {
         String username, password;
         IEclipsePreferences preferences = ConfigurationScope.INSTANCE.getNode(STORE_PREFERENCES_NODE);
         Preferences credentialsPrefs = preferences.node(LOGIN_NODE);
-        username = credentialsPrefs.get(getUsernamePrefKey(), "");
+        username = credentialsPrefs.get(getUsernamePrefKey(), txtLogin.getText());
         txtLogin.setText(username);
-        password = credentialsPrefs.get(getPasswordPrefKey(), "");
+        password = credentialsPrefs.get(getPasswordPrefKey(),txtPassword.getText());
         txtPassword.setText(password);
         if(username.isEmpty() || password.isEmpty()) {
             autoConnect = false;