From 7e3241a41f93b582e05dd3e95e9830c8e9a21dd9 Mon Sep 17 00:00:00 2001
From: buczekp <buczekp>
Date: Fri, 18 Dec 2009 13:50:29 +0000
Subject: [PATCH] [LMS-1075] fixed choosing of previously selected project
 after refresh

SVN: 14005
---
 .../ProjectSelectionTreeGridContainer.java    | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ProjectSelectionTreeGridContainer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ProjectSelectionTreeGridContainer.java
index 3e3d745052c..0e0b1051738 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ProjectSelectionTreeGridContainer.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ProjectSelectionTreeGridContainer.java
@@ -430,6 +430,29 @@ public final class ProjectSelectionTreeGridContainer extends LayoutContainer imp
             return project.getCode() + " (" + project.getGroup().getCode() + ")";
         }
 
+        // equals is needed because of weird TreeGrid implementation in GXT
+        // to be able to selection of previously selected project after refresh of the tree
+        // #selectByIdentifierIfPossible()
+        @Override
+        public boolean equals(Object obj)
+        {
+            if (obj == this)
+            {
+                return true;
+            }
+            if (obj instanceof ProjectItemModel == false)
+            {
+                return false;
+            }
+            final ProjectItemModel that = (ProjectItemModel) obj;
+            return this.getIdentifier().equals(that.getIdentifier());
+        }
+
+        private String getIdentifier()
+        {
+            return get(ModelDataPropertyNames.PROJECT_IDENTIFIER);
+        }
+
     }
 
     private static class GroupItemModel extends BaseModelDataWithCode
-- 
GitLab