Make distribution browser more robust
authorMathieu Baudier <mbaudier@argeo.org>
Sun, 26 Jan 2014 12:22:42 +0000 (12:22 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sun, 26 Jan 2014 12:22:42 +0000 (12:22 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@6766 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/DistParentElem.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/GroupElem.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/RepoElem.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/WorkspaceElem.java

index 8b1f045d3dc6809e9bc0fff5fc1127d8d0cdba21..3d7cef270c7288c71d59c27a70353b3156cdb827 100644 (file)
@@ -2,6 +2,8 @@ package org.argeo.slc.client.ui.dist.model;
 
 /** Common super class for all dist tree elements */
 public abstract class DistParentElem {
+       public final static Character VERSION_SEP = '-';
+
        private boolean inHome = false;
        private boolean isReadOnly = false;
 
index ca7213a276e7f0b284b4348f49b875adafcc1dd8..bc5e94e77c613110cd461e59a0d77548ba99e92a 100644 (file)
@@ -60,7 +60,7 @@ public class GroupElem extends DistParentElem {
                                // filter technical workspaces
                                if (workspaceName.startsWith(name)
                                                && workspaceName.substring(0,
-                                                               workspaceName.indexOf("-")).equals(name)) {
+                                                               workspaceName.lastIndexOf(VERSION_SEP)).equals(name)) {
                                        distributionElems.add(new WorkspaceElem(repoElem,
                                                        workspaceName));
                                }
index 6fdde8af2dfcf27640e8b0409a41ea6b28f7cbab..7d584f7875d311927e90b2566e8e3eb4cab3a263 100644 (file)
@@ -144,9 +144,9 @@ public class RepoElem extends DistParentElem {
 
                                // filter technical workspaces
                                // FIXME: rely on a more robust rule than just wksp name
-                               if (workspaceName.lastIndexOf('-') > 0) {
+                               if (workspaceName.lastIndexOf(VERSION_SEP) > 0) {
                                        String prefix = workspaceName.substring(0,
-                                                       workspaceName.lastIndexOf('-'));
+                                                       workspaceName.lastIndexOf(VERSION_SEP));
                                        if (!children.containsKey(prefix)) {
                                                children.put(prefix, new GroupElem(RepoElem.this,
                                                                prefix));
index 5c5181d7797cff07e176cb37664b71d5e0056f79..f5fb3722ea7c48fe1d1456a402f8309857f64206 100644 (file)
@@ -10,8 +10,8 @@ public class WorkspaceElem extends DistParentElem {
         * Helper to display only version when the workspace name is well formatted
         */
        private static String formatName(String name) {
-               if (name != null && name.lastIndexOf('-') > 0)
-                       return name.substring(name.lastIndexOf('-') + 1);
+               if (name != null && name.lastIndexOf(VERSION_SEP) > 0)
+                       return name.substring(name.lastIndexOf(VERSION_SEP) + 1);
                else
                        return name;
        }