X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=plugins%2Forg.argeo.slc.client.ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Feditors%2FProcessBuilderPage.java;h=6ed8debf636a5df345f3f864425f8f3784133177;hb=b38be5eddf82923307efcc2440a98e8c85a3754a;hp=31b5d30b8eb0d961ace4c7348c5c7459c0f3ca1d;hpb=76420da459e9fe47612f77166f5e708648e40ef1;p=gpl%2Fargeo-slc.git diff --git a/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java b/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java index 31b5d30b8..6ed8debf6 100644 --- a/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java +++ b/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2012 Mathieu Baudier + * Copyright (C) 2007-2012 Argeo GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,15 +33,12 @@ import javax.jcr.query.Query; import javax.jcr.query.QueryManager; import org.argeo.ArgeoException; -import org.argeo.eclipse.ui.ErrorFeedback; import org.argeo.eclipse.ui.jcr.AsyncUiEventListener; import org.argeo.jcr.JcrUtils; import org.argeo.slc.SlcException; -import org.argeo.slc.client.ui.ClientUiPlugin; import org.argeo.slc.client.ui.SlcImages; import org.argeo.slc.core.execution.PrimitiveAccessor; import org.argeo.slc.core.execution.PrimitiveUtils; -import org.argeo.slc.execution.ExecutionModulesManager; import org.argeo.slc.execution.ExecutionProcess; import org.argeo.slc.jcr.SlcJcrUtils; import org.argeo.slc.jcr.SlcNames; @@ -95,7 +92,6 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { final static String NONE = ""; private Node processNode; - private final ExecutionModulesManager modulesManager; private TreeViewer flowsViewer; private TableViewer valuesViewer; @@ -107,11 +103,9 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { private AbstractFormPart formPart; private EventListener statusObserver; - public ProcessBuilderPage(ProcessEditor editor, Node processNode, - ExecutionModulesManager modulesManager) { + public ProcessBuilderPage(ProcessEditor editor, Node processNode) { super(editor, ID, "Definition"); this.processNode = processNode; - this.modulesManager = modulesManager; } @Override @@ -251,6 +245,8 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { GridData valuedGd = new GridData(SWT.FILL, SWT.FILL, true, true); // valuedGd.widthHint = 200; valuesViewer.getTable().setLayoutData(valuedGd); + valuesViewer.getTable().setHeaderVisible(true); + valuesViewer.setContentProvider(new ValuesContentProvider()); initializeValuesViewer(valuesViewer); sashForm.setWeights(getWeights()); @@ -517,22 +513,6 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { .hasNext();) { Node flowNode = nit.nextNode(); children.add(flowNode); - try { - // make sure modules are started for all nodes - String flowDefPath = flowNode.getNode(SLC_ADDRESS) - .getProperty(Property.JCR_PATH).getString(); - Node executionModuleNode = flowNode.getSession() - .getNode(SlcJcrUtils.modulePath(flowDefPath)); - if (!executionModuleNode.getProperty(SLC_STARTED) - .getBoolean()) - ClientUiPlugin.startStopExecutionModule( - modulesManager, executionModuleNode); - } catch (Exception e) { - ErrorFeedback.show( - "Cannot start execution module related to " - + flowNode, e); - } - } return children.toArray(); } catch (RepositoryException e) { @@ -562,7 +542,6 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { } static class FlowsLabelProvider extends ColumnLabelProvider { - @Override public String getText(Object element) { Node node = (Node) element; @@ -571,10 +550,12 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { if (node.hasNode(SLC_ADDRESS)) { String path = node.getNode(SLC_ADDRESS) .getProperty(Property.JCR_PATH).getString(); - Node executionModuleNode = node.getSession().getNode( - SlcJcrUtils.modulePath(path)); - String executionModuleName = executionModuleNode - .getProperty(SLC_NAME).getString(); + String executionModuleName = SlcJcrUtils + .moduleName(path); + // Node executionModuleNode = node.getSession().getNode( + // SlcJcrUtils.modulePath(path)); + // String executionModuleName = executionModuleNode + // .getProperty(SLC_NAME).getString(); return executionModuleName + ":" + SlcJcrUtils.flowRelativePath(path); } @@ -634,32 +615,40 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { @Override public boolean performDrop(Object data) { - String path = data.toString(); - try { - // either a node or a whole directory was dragged - QueryManager qm = processNode.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()); - } - for (String p : paths) { - addFlow(p); + // Parse the received String, paths are separated with a carriage + // return + String[] paths = data.toString().split(new String("\n")); + SortedSet resultPaths = new TreeSet(); + for (String path : paths) { + try { + // either a node or a whole directory can have been dragged + QueryManager qm = processNode.getSession().getWorkspace() + .getQueryManager(); + String statement = "SELECT * FROM [" + + SlcTypes.SLC_EXECUTION_FLOW + + "] WHERE ISDESCENDANTNODE(['" + path + + "']) OR ISSAMENODE(['" + path + "'])"; + Query query = qm.createQuery(statement, Query.JCR_SQL2); + + // order paths + for (NodeIterator nit = query.execute().getNodes(); nit + .hasNext();) { + String currPath = nit.nextNode().getPath(); + // do not add twice a same flow + if (!resultPaths.contains(currPath)) + resultPaths.add(currPath); + } + } catch (RepositoryException e) { + throw new SlcException("Cannot query flows under " + path, + e); } - return true; - } catch (RepositoryException e) { - throw new SlcException("Cannot query flows under " + path, e); } + for (String p : resultPaths) { + addFlow(p); + } + return true; + } @Override @@ -687,6 +676,12 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { if (!specAttrNode .isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE)) continue specAttrs; + // workaround to enable hiding of necessary but unusable + // flow parameters + else if (specAttrNode.hasProperty(SlcNames.SLC_IS_HIDDEN) + && specAttrNode.getProperty(SlcNames.SLC_IS_HIDDEN) + .getBoolean()) + continue specAttrs; specAttributes.add(specAttrNode); } return specAttributes.toArray(); @@ -739,7 +734,7 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { } return null; } catch (RepositoryException e) { - throw new SlcException("Cannot get celle editor", e); + throw new SlcException("Cannot get cell editor", e); } } @@ -747,10 +742,11 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { protected boolean canEdit(Object element) { try { Node specAttrNode = (Node) element; - return !(specAttrNode.getProperty(SLC_IS_IMMUTABLE) - .getBoolean() || specAttrNode.getProperty( - SLC_IS_CONSTANT).getBoolean()) - && isSupportedAttributeType(specAttrNode); + Boolean cannotEdit = specAttrNode.getProperty(SLC_IS_IMMUTABLE) + .getBoolean() + || specAttrNode.getProperty(SLC_IS_CONSTANT) + .getBoolean(); + return !cannotEdit && isSupportedAttributeType(specAttrNode); } catch (RepositoryException e) { throw new SlcException("Cannot check whether " + element + " is editable", e);