SortedMap<String, FolderNode> folderNodes = new TreeMap<String, FolderNode>();
- // SortedMap<String, FlowNode> directChildren = new TreeMap<String,
- // FlowNode>();
-
flowDescriptors = new HashMap<String, ExecutionFlowDescriptor>();
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);
protected FolderNode mkdirs(TreeParent root, String path,
SortedMap<String, FolderNode> folderNodes) {
+ // Normalize
+ if (path.charAt(0) != '/')
+ path = '/' + path;
if (path.charAt(path.length() - 1) == '/')
path = path.substring(0, path.length() - 1);
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(""))
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;
}
import java.util.List;
import org.argeo.slc.client.ui.ClientUiPlugin;
+import org.argeo.slc.execution.ExecutionModuleDescriptor;
import org.argeo.slc.process.RealizedFlow;
import org.argeo.slc.process.SlcExecution;
import org.eclipse.jface.viewers.DoubleClickEvent;
class ViewLabelProvider extends LabelProvider implements
ITableLabelProvider {
public String getColumnText(Object obj, int index) {
- return getText(obj);
+ if (obj instanceof ExecutionModulesContentProvider.ExecutionModuleNode) {
+ ExecutionModuleDescriptor emd = ((ExecutionModulesContentProvider.ExecutionModuleNode) obj)
+ .getDescriptor();
+ if (emd.getLabel() != null)
+ return emd.getLabel();
+ else
+ return getText(emd);
+ } else
+ return getText(obj);
}
public Image getColumnImage(Object obj, int index) {
public Image getImage(Object obj) {
if (obj instanceof ExecutionModulesContentProvider.AgentNode)
- return ClientUiPlugin.getDefault().getImageRegistry().get("agent");
+ return ClientUiPlugin.getDefault().getImageRegistry().get(
+ "agent");
else if (obj instanceof ExecutionModulesContentProvider.ExecutionModuleNode)
return ClientUiPlugin.getDefault().getImageRegistry().get(
"executionModule");
else if (obj instanceof ExecutionModulesContentProvider.FolderNode)
- return ClientUiPlugin.getDefault().getImageRegistry().get("folder");
+ return ClientUiPlugin.getDefault().getImageRegistry().get(
+ "folder");
else if (obj instanceof ExecutionModulesContentProvider.FlowNode)
- return ClientUiPlugin.getDefault().getImageRegistry().get("flow");
+ return ClientUiPlugin.getDefault().getImageRegistry().get(
+ "flow");
else
return PlatformUI.getWorkbench().getSharedImages().getImage(
ISharedImages.IMG_OBJ_ELEMENT);