/*
- * 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.
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
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.ExecutionProcess;
import org.argeo.slc.jcr.SlcJcrUtils;
/** Definition of the process. */
public class ProcessBuilderPage extends FormPage implements SlcNames {
public final static String ID = "processBuilderPage";
- // private final static Log log =
- // LogFactory.getLog(ProcessBuilderPage.class);
/** To be displayed in empty lists */
final static String NONE = "<none>";
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());
// override with flow value
if (flowNode.hasNode(attrName)) {
// assuming this is a primitive
- realizedAttrNode.setProperty(SLC_VALUE,
- flowNode.getNode(attrName).getProperty(SLC_VALUE)
- .getValue());
+ Node attrNode = flowNode.getNode(attrName);
+ if (attrNode.hasProperty(SLC_VALUE))
+ realizedAttrNode.setProperty(SLC_VALUE, attrNode
+ .getProperty(SLC_VALUE).getValue());
}
}
/*
* UTILITIES
*/
- // protected static Object getAttributeSpecValue(Node specAttrNode) {
- // try {
- // if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
- // if (!specAttrNode.hasProperty(SLC_VALUE))
- // return null;
- // String type = specAttrNode.getProperty(SLC_TYPE).getString();
- // // TODO optimize based on data type?
- // Object value = PrimitiveUtils.convert(type, specAttrNode
- // .getProperty(SLC_VALUE).getString());
- // // log.debug(specAttrNode + ", type=" + type + ", value=" +
- // // value);
- // return value;
- // } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) {
- // if (specAttrNode.hasNode(SLC_VALUE)) {
- // // return the index of the sub node
- // // in the future we may manage reference as well
- // return specAttrNode.getProperty(SLC_VALUE).getLong();
- // } else
- // return null;
- // }
- // return null;
- // } catch (RepositoryException e) {
- // throw new SlcException("Cannot get value", e);
- // }
- //
- // }
-
protected static String getAttributeSpecText(Node specAttrNode) {
try {
if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
if (!specAttrNode.hasProperty(SLC_VALUE))
return "";
String type = specAttrNode.getProperty(SLC_TYPE).getString();
+ if (PrimitiveAccessor.TYPE_PASSWORD.equals(type))
+ return "****************";
Object value = PrimitiveUtils.convert(type, specAttrNode
.getProperty(SLC_VALUE).getString());
return value.toString();
/*
* FLOWS SUBCLASSES
*/
- static class FlowsContentProvider implements ITreeContentProvider {
+ class FlowsContentProvider implements ITreeContentProvider {
public Object[] getElements(Object obj) {
if (!(obj instanceof Node))
return new Object[0];
Node node = (Node) obj;
List<Node> children = new ArrayList<Node>();
for (NodeIterator nit = node.getNode(SLC_FLOW).getNodes(); nit
- .hasNext();)
- children.add(nit.nextNode());
+ .hasNext();) {
+ Node flowNode = nit.nextNode();
+ children.add(flowNode);
+ }
return children.toArray();
} catch (RepositoryException e) {
- throw new SlcException("Cannot list children of " + obj, e);
+ throw new SlcException("Cannot list flows of " + obj, e);
}
}
}
static class FlowsLabelProvider extends ColumnLabelProvider {
-
@Override
public String getText(Object element) {
Node node = (Node) element;
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);
}
@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<String> paths = new TreeSet<String>();
- 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<String> resultPaths = new TreeSet<String>();
+ 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
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();
Node specAttrNode = (Node) element;
if (specAttrNode
.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
- return new TextCellEditor(tableViewer.getTable());
+ String type = specAttrNode.getProperty(SLC_TYPE)
+ .getString();
+ if (PrimitiveAccessor.TYPE_PASSWORD.equals(type)) {
+ return new TextCellEditor(tableViewer.getTable(),
+ SWT.PASSWORD);
+ } else {
+ return new TextCellEditor(tableViewer.getTable());
+ }
} else if (specAttrNode
.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) {
NodeIterator children = specAttrNode.getNodes();
}
return null;
} catch (RepositoryException e) {
- throw new SlcException("Cannot get celle editor", e);
+ throw new SlcException("Cannot get cell editor", e);
}
}
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);
protected Object getValue(Object element) {
Node specAttrNode = (Node) element;
try {
- // Object value = getAttributeSpecValue(specAttrNode);
- // if (value == null)
- // throw new SlcException("Unsupported attribute " + element);
if (specAttrNode
.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
if (!specAttrNode.hasProperty(SLC_VALUE))