X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=eclipse%2Fplugins%2Forg.argeo.slc.client.ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fviews%2FJcrExecutionModulesView.java;h=108cbd5e2d87f815b7e011b92b3362b31f6f2a31;hb=dd737627cf2209c2f27a640a3e85fb01ed9b953f;hp=41e0be09510dd81f3814ead5bdf0d72a75faa5ac;hpb=26cd9f658531888bfa9ba69ea5c034839b4c4149;p=gpl%2Fargeo-slc.git diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java b/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java index 41e0be095..108cbd5e2 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java @@ -5,14 +5,19 @@ import java.util.Arrays; import java.util.Comparator; import java.util.Iterator; import java.util.List; +import java.util.SortedSet; +import java.util.TreeSet; import javax.jcr.Node; +import javax.jcr.NodeIterator; import javax.jcr.Property; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.nodetype.NodeType; import javax.jcr.observation.Event; import javax.jcr.observation.EventIterator; +import javax.jcr.query.Query; +import javax.jcr.query.QueryManager; import org.argeo.ArgeoException; import org.argeo.eclipse.ui.jcr.AsyncUiEventListener; @@ -49,8 +54,8 @@ import org.eclipse.ui.part.ViewPart; /** JCR based view of the execution modules. */ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, SlcNames { -// private final static Log log = LogFactory -// .getLog(JcrExecutionModulesView.class); + // private final static Log log = LogFactory + // .getLog(JcrExecutionModulesView.class); public static final String ID = "org.argeo.slc.client.ui.jcrExecutionModulesView"; @@ -148,6 +153,20 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, } return super.filterChildren(children); } + + @Override + public boolean hasChildren(Object element) { + if (element instanceof Node) { + Node node = (Node) element; + try { + if (node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW)) + return false; + } catch (RepositoryException e) { + throw new SlcException("Cannot check has children", e); + } + } + return super.hasChildren(element); + } } static class ViewComparator implements Comparator { @@ -319,14 +338,7 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, try { if (obj instanceof Node) { Node node = (Node) obj; - if (node.isNodeType(SLC_EXECUTION_FLOW)) { - List paths = new ArrayList(); - paths.add(node.getPath()); - IWorkbenchPage activePage = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage(); - activePage.openEditor(new ProcessEditorInput(paths, - true), ProcessEditor.ID); - } else if (node.isNodeType(SLC_EXECUTION_MODULE)) { + if (node.isNodeType(SLC_EXECUTION_MODULE)) { String name = node.getProperty(SLC_NAME).getString(); String version = node.getProperty(SLC_VERSION) .getString(); @@ -339,6 +351,32 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, } else { modulesManager.start(nameVersion); } + } else { + String path = node.getPath(); + // TODO factorize with editor + QueryManager qm = node.getSession().getWorkspace() + .getQueryManager(); + String statement = "SELECT * FROM [" + + SlcTypes.SLC_EXECUTION_FLOW + + "] WHERE ISDESCENDANTNODE(['" + path + + "']) OR ISSAMENODE(['" + path + "'])"; + // log.debug(statement); + Query query = qm.createQuery(statement, Query.JCR_SQL2); + + // order paths + SortedSet paths = new TreeSet(); + for (NodeIterator nit = query.execute().getNodes(); nit + .hasNext();) { + paths.add(nit.nextNode().getPath()); + } + + // List paths = new ArrayList(); + // paths.add(node.getPath()); + IWorkbenchPage activePage = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage(); + activePage.openEditor(new ProcessEditorInput( + new ArrayList(paths), true), + ProcessEditor.ID); } } } catch (Exception e) {