From 628ada137c339277f76d5a248b3db78459eab67d Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Mon, 18 Mar 2019 18:24:27 +0200 Subject: [PATCH] Always show version label for non-initial versions. gitlab #276 Change-Id: I5c1c2ad67c1bf010ceb372d06203395c52e6ed71 --- .../org/simantics/db/common/utils/Versions.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/Versions.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/Versions.java index d022a251e..588946745 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/Versions.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/Versions.java @@ -114,15 +114,16 @@ public class Versions { String name = graph.getPossibleRelatedValue(r, L0.HasName, Bindings.STRING); if(name != null) { VersionInfo versions = graph.syncRequest(new VersionInfoRequest(r)); - if(versions.versions.size() != 1) { - int pos = name.lastIndexOf('@'); - if(pos == -1) return name + " [No version]"; - String base = name.substring(0, pos); - String version = name.substring(pos+1); + int nVersions = versions.versions.size(); + // No version display, if "A", "1" or "" is the only version present + if ("".equals(versions.version)) + return nVersions == 1 ? name : name + " [No version]"; + String base = versions.baseName; + String version = versions.version; + if (("A".equals(version) || "1".equals(version)) && nVersions == 1) + return base; + else return base + " [Version " + version + "]"; - } else { - return versions.baseName; - } } // Fallback logic return NameUtils.getSafeName(graph, r); -- 2.47.1