diff --git a/src/eu/telecom_bretagne/praxis/core/workflow/Workflow.java b/src/eu/telecom_bretagne/praxis/core/workflow/Workflow.java index 8ef5ae755df6b40282758660c553aca55c161c4e..124f73e256f136c5fc34886c25ec9ffa7241564b 100644 --- a/src/eu/telecom_bretagne/praxis/core/workflow/Workflow.java +++ b/src/eu/telecom_bretagne/praxis/core/workflow/Workflow.java @@ -367,13 +367,19 @@ public class Workflow { @Override public Workflow clone() { + Workflow clone; try { - return new Workflow(toXMLDocument(), new XMLWarnings()); + clone = new Workflow(toXMLDocument(), new XMLWarnings()); } catch (InvalidXMLException e) { // Sounds impossible. If this happens, there's something wrong in the implementation itself! Log.log.log(Level.SEVERE, "Ooops, unable to clone() ?!!", e); return null; } + // when cloned inside the GUI, we should take care of the wf input's copiedFromResults status + // (see comments for this field for details) + for (WorkflowInput input: this.getInputs()) + clone.getInputWithId(this.getIdForInput(input)).copiedFromResults = input.copiedFromResults; + return clone; } /** diff --git a/src/eu/telecom_bretagne/praxis/core/workflow/WorkflowInput.java b/src/eu/telecom_bretagne/praxis/core/workflow/WorkflowInput.java index 2e7a2fd601f84acd2f555b8d86406b1a0fbd2a8d..3fa87785bb85ad5f3cfdfeb2009e879dab7c01b6 100644 --- a/src/eu/telecom_bretagne/praxis/core/workflow/WorkflowInput.java +++ b/src/eu/telecom_bretagne/praxis/core/workflow/WorkflowInput.java @@ -40,6 +40,13 @@ public class WorkflowInput protected transient ArrayList<Parameter> parameters = new ArrayList<Parameter>(); + /** + * This field is only used to mark the files copied from a result into the clipboard. When pasting such an + * input into a workflow, the file itself should be copied into an other location, so that the original file, + * belonging to a result, is not subject to changes. + */ + public transient boolean copiedFromResults = false; + void addOutput(Parameter p) { parameters.add(p); @@ -261,17 +268,25 @@ public class WorkflowInput this.name = name; propChgSupport.firePropertyChange("name", oldName, name); } - - public void setContent(List <String> content) { - if ( type == INPUT_TYPE.FILE || type == INPUT_TYPE.DIRECTORY) - { - List<String> _filepaths = this.filepaths; - filepaths = new ArrayList<String>(content); - propChgSupport.firePropertyChange("filepaths", _filepaths, filepaths); - } - else - eu.telecom_bretagne.praxis.common.Utile.unimplemented(); - } + + /** + * Sets the content of this object. + * @param content + * the content to set. A {@code null} value is equivalent to the empty array. + */ + public void setContent(List <String> content) { + if ( type == INPUT_TYPE.FILE || type == INPUT_TYPE.DIRECTORY) + { + List<String> _filepaths = this.filepaths; + if (content == null) + filepaths = new ArrayList<String>(); + else + filepaths = new ArrayList<String>(content); + propChgSupport.firePropertyChange("filepaths", _filepaths, filepaths); + } + else + eu.telecom_bretagne.praxis.common.Utile.unimplemented(); + } public void setX(int x) { int _x = this.x;