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=c3e07153c371d29f9dc197874f71996c045eb1c0;hb=af9457b0628ba4cc625192762d0c0fe7564b9846;hp=958be82768183a694ae30d1b508df16bdfd7b02b;hpb=651d33e13bfa9a7b46464be412023ee747e612e8;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 958be8276..c3e07153c 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,11 +33,15 @@ 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; @@ -86,13 +90,12 @@ import org.eclipse.ui.forms.widgets.ScrolledForm; /** 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 = ""; private Node processNode; + private final ExecutionModulesManager modulesManager; private TreeViewer flowsViewer; private TableViewer valuesViewer; @@ -104,9 +107,11 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { private AbstractFormPart formPart; private EventListener statusObserver; - public ProcessBuilderPage(ProcessEditor editor, Node processNode) { + public ProcessBuilderPage(ProcessEditor editor, Node processNode, + ExecutionModulesManager modulesManager) { super(editor, ID, "Definition"); this.processNode = processNode; + this.modulesManager = modulesManager; } @Override @@ -369,9 +374,10 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { // 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()); } } @@ -460,39 +466,14 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { /* * 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(); @@ -524,7 +505,7 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { /* * FLOWS SUBCLASSES */ - static class FlowsContentProvider implements ITreeContentProvider { + class FlowsContentProvider implements ITreeContentProvider { public Object[] getElements(Object obj) { if (!(obj instanceof Node)) return new Object[0]; @@ -533,11 +514,13 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { Node node = (Node) obj; List children = new ArrayList(); 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); } } @@ -563,7 +546,6 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { } static class FlowsLabelProvider extends ColumnLabelProvider { - @Override public String getText(Object element) { Node node = (Node) element; @@ -572,10 +554,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); } @@ -717,7 +701,14 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { 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(); @@ -766,9 +757,6 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { 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))