X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=eclipse%2Fplugins%2Forg.argeo.slc.client.ui%2Fsrc%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fviews%2FExecutionModulesContentProvider.java;h=3dea55524eb0b6b1c92127f6d9f59dff5359462f;hb=73dfaee2dea3e0fcb8d4c4cc46c1c7b526650c1d;hp=8fe82baae7e5a05e52f3f784445f1f52de938ff3;hpb=c208feddd6ceb7c4a6861e9a49228edc25a13181;p=gpl%2Fargeo-slc.git diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ExecutionModulesContentProvider.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ExecutionModulesContentProvider.java index 8fe82baae..3dea55524 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ExecutionModulesContentProvider.java +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ExecutionModulesContentProvider.java @@ -130,25 +130,35 @@ public class ExecutionModulesContentProvider implements ITreeContentProvider { SortedMap folderNodes = new TreeMap(); - // SortedMap directChildren = new TreeMap(); - flowDescriptors = new HashMap(); for (ExecutionFlowDescriptor fd : descriptor.getExecutionFlows()) { - if (log.isTraceEnabled()) - log - .trace("path=" + fd.getPath() + ", name=" - + fd.getName()); - - String path = fd.getPath(); - String name = fd.getName(); + // if (log.isTraceEnabled()) + // log.trace("fd.path=" + fd.getPath() + ", fd.name=" + // + fd.getName()); + + // find path and label + String path; + String label; + int lastSlash = fd.getName().lastIndexOf('/'); + if ((fd.getPath() == null || fd.getPath().trim().equals("")) + && lastSlash >= 0) { + path = fd.getName().substring(0, lastSlash); + label = fd.getName().substring(lastSlash + 1); + } else { + path = fd.getPath(); + label = fd.getName(); + } + // if (log.isTraceEnabled()) + // log.trace("path=" + path + ", label=" + label); - if (path == null || path.trim().equals("")) { + if (path == null || path.trim().equals("") + || path.trim().equals("/")) { // directChildren.put(name, new FlowNode(name, this)); - addChild(new FlowNode(name, this)); + addChild(new FlowNode(label, fd.getName(), this)); } else { FolderNode folderNode = mkdirs(this, path, folderNodes); - folderNode.addChild(new FlowNode(name, this)); + folderNode + .addChild(new FlowNode(label, fd.getName(), this)); } flowDescriptors.put(fd.getName(), fd); @@ -158,6 +168,9 @@ public class ExecutionModulesContentProvider implements ITreeContentProvider { protected FolderNode mkdirs(TreeParent root, String path, SortedMap folderNodes) { + // Normalize + if (path.charAt(0) != '/') + path = '/' + path; if (path.charAt(path.length() - 1) == '/') path = path.substring(0, path.length() - 1); @@ -165,8 +178,15 @@ public class ExecutionModulesContentProvider implements ITreeContentProvider { return folderNodes.get(path); int lastIndx = path.lastIndexOf('/'); - String folderName = path.substring(lastIndx + 1); - String parentPath = path.substring(0, lastIndx); + String folderName; + String parentPath; + if (lastIndx >= 0) { + folderName = path.substring(lastIndx + 1); + parentPath = path.substring(0, lastIndx); + } else { + folderName = path; + parentPath = ""; + } TreeParent parent; if (parentPath.equals("")) @@ -189,8 +209,9 @@ public class ExecutionModulesContentProvider implements ITreeContentProvider { private final String flowName; private final ExecutionModuleNode executionModuleNode; - public FlowNode(String flowName, ExecutionModuleNode executionModuleNode) { - super(flowName); + public FlowNode(String label, String flowName, + ExecutionModuleNode executionModuleNode) { + super(label); this.flowName = flowName; this.executionModuleNode = executionModuleNode; }