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=37c8dc570d33b6f80f5a8d26528a3d42b44bbbd9;hb=d172f924a8524ff1e5a2d68db054103ca461ee1e;hp=5cb83c1523e39b261394b7769eb69d6301786876;hpb=ac38932aab09592c1ec0af26c26899536dff284f;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 5cb83c152..37c8dc570 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,17 +5,20 @@ 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.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.argeo.ArgeoException; import org.argeo.eclipse.ui.jcr.AsyncUiEventListener; import org.argeo.eclipse.ui.jcr.DefaultNodeLabelProvider; @@ -30,8 +33,6 @@ import org.argeo.slc.execution.ExecutionModulesManager; import org.argeo.slc.jcr.SlcJcrConstants; import org.argeo.slc.jcr.SlcNames; import org.argeo.slc.jcr.SlcTypes; -import org.eclipse.jface.fieldassist.SimpleContentProposalProvider; -import org.eclipse.jface.viewers.ColumnViewerToolTipSupport; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.IStructuredSelection; @@ -45,6 +46,7 @@ import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; @@ -52,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"; @@ -65,7 +67,9 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, public void createPartControl(Composite parent) { viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - ColumnViewerToolTipSupport.enableFor(viewer); + + // FIXME : does not work in RAP, find a way to have it for RCP only + // ColumnViewerToolTipSupport.enableFor(viewer); ViewContentProvider contentProvider = new ViewContentProvider(session); @@ -85,7 +89,7 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, session.getWorkspace() .getObservationManager() .addEventListener( - new VmAgentObserver(), + new VmAgentObserver(viewer.getTree().getDisplay()), Event.NODE_ADDED | Event.NODE_REMOVED | Event.NODE_MOVED, SlcJcrConstants.VM_AGENT_FACTORY_PATH, true, null, @@ -141,11 +145,30 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, throws RepositoryException { for (Iterator it = children.iterator(); it.hasNext();) { Node node = it.next(); + // execution spec definitions if (node.getName().equals(SLC_EXECUTION_SPECS)) it.remove(); + // flow values + else if (node.getParent().isNodeType( + SlcTypes.SLC_EXECUTION_FLOW)) + it.remove(); } 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 { @@ -207,39 +230,44 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, // } class VmAgentObserver extends AsyncUiEventListener { - protected void onEventInUiThread(EventIterator events) { -// List baseNodes = ((SimpleNodeContentProvider) viewer -// .getContentProvider()).getBaseNodes(); -// Node baseNode = baseNodes.get(0); -// -// while (events.hasNext()) { -// Event event = events.nextEvent(); -// try { -// String path = event.getPath(); -// String baseNodePath = baseNode.getPath(); -// if (path.startsWith(baseNodePath)) { -// String relPath = path -// .substring(baseNodePath.length() + 1); -// log.debug("relPath: " + relPath); -// if (baseNode.hasNode(relPath)) { -// Node refreshNode = baseNode.getNode(relPath); -// log.debug("refreshNode: " + refreshNode); -// viewer.refresh(refreshNode); -// } -// -// } -// // if (log.isDebugEnabled()) -// // log.debug("Process " + path + ": " + event); -// -// // if (session.itemExists(path)) { -// // Node parentNode = session.getNode(path).getParent(); -// // log.debug("Parent: " + parentNode); -// // viewer.refresh(parentNode); -// // } -// } catch (RepositoryException e) { -// log.warn("Cannot process event " + event + ": " + e); -// } -// } + + public VmAgentObserver(Display display) { + super(display); + } + + protected void onEventInUiThread(List events) { + // List baseNodes = ((SimpleNodeContentProvider) viewer + // .getContentProvider()).getBaseNodes(); + // Node baseNode = baseNodes.get(0); + // + // while (events.hasNext()) { + // Event event = events.nextEvent(); + // try { + // String path = event.getPath(); + // String baseNodePath = baseNode.getPath(); + // if (path.startsWith(baseNodePath)) { + // String relPath = path + // .substring(baseNodePath.length() + 1); + // log.debug("relPath: " + relPath); + // if (baseNode.hasNode(relPath)) { + // Node refreshNode = baseNode.getNode(relPath); + // log.debug("refreshNode: " + refreshNode); + // viewer.refresh(refreshNode); + // } + // + // } + // // if (log.isDebugEnabled()) + // // log.debug("Process " + path + ": " + event); + // + // // if (session.itemExists(path)) { + // // Node parentNode = session.getNode(path).getParent(); + // // log.debug("Parent: " + parentNode); + // // viewer.refresh(parentNode); + // // } + // } catch (RepositoryException e) { + // log.warn("Cannot process event " + event + ": " + e); + // } + // } // try { // Node vmAgentNode = session @@ -317,14 +345,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(); @@ -337,6 +358,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) {