Search in sources :

Example 1 with WorkflowParameter

use of org.vcell.workflow.WorkflowParameter in project vcell by virtualcell.

the class WorkflowObjectsTableModel method propertyChange.

@Override
public void propertyChange(java.beans.PropertyChangeEvent evt) {
    super.propertyChange(evt);
    if (evt.getSource() instanceof WorkflowObject) {
        int changeRow = getRowIndex((WorkflowObject) evt.getSource());
        if (changeRow >= 0) {
            fireTableRowsUpdated(changeRow, changeRow);
        }
    } else {
        String propertyName = evt.getPropertyName();
        if (evt.getSource() == taskContext.getWorkflow()) {
            if (propertyName.equals(Workflow.PROPERTY_NAME_PARAMETERS)) {
                WorkflowParameter[] oldValue = (WorkflowParameter[]) evt.getOldValue();
                if (oldValue != null) {
                    for (WorkflowParameter parameter : oldValue) {
                        parameter.removePropertyChangeListener(this);
                    }
                }
                WorkflowParameter[] newValue = (WorkflowParameter[]) evt.getNewValue();
                if (newValue != null) {
                    for (WorkflowParameter parameter : newValue) {
                        parameter.addPropertyChangeListener(this);
                    }
                }
                refreshData();
            } else if (propertyName.equals(Workflow.PROPERTY_NAME_TASKS)) {
                Task[] oldValue = (Task[]) evt.getOldValue();
                if (oldValue != null) {
                    for (Task task : oldValue) {
                        task.removePropertyChangeListener(this);
                        for (DataInput dataInput : task.getInputs()) {
                            dataInput.removePropertyChangeListener(this);
                        }
                        for (DataOutput dataOutput : task.getOutputs()) {
                            dataOutput.removePropertyChangeListener(this);
                        }
                    }
                }
                Task[] newValue = (Task[]) evt.getNewValue();
                if (newValue != null) {
                    for (Task task : newValue) {
                        task.addPropertyChangeListener(this);
                        for (DataInput dataInput : task.getInputs()) {
                            dataInput.addPropertyChangeListener(this);
                        }
                        for (DataOutput dataOutput : task.getOutputs()) {
                            dataOutput.addPropertyChangeListener(this);
                        }
                    }
                }
                refreshData();
            }
        }
    }
}
Also used : DataInput(org.vcell.workflow.DataInput) DataOutput(org.vcell.workflow.DataOutput) Task(org.vcell.workflow.Task) WorkflowParameter(org.vcell.workflow.WorkflowParameter) WorkflowObject(org.vcell.workflow.WorkflowObject)

Example 2 with WorkflowParameter

use of org.vcell.workflow.WorkflowParameter in project vcell by virtualcell.

the class WorkflowObjectsTableModel method setValueAt.

public void setValueAt(Object value, int row, int col) {
    if (value == null) {
        return;
    }
    try {
        String inputValue = (String) value;
        inputValue = inputValue.trim();
        WorkflowObject workflowObject = getValueAt(row);
        switch(col) {
            case COLUMN_VALUE:
                {
                    if (inputValue.length() == 0) {
                        return;
                    }
                    if (workflowObject instanceof WorkflowParameter) {
                        WorkflowParameter dataHolder = (WorkflowParameter) workflowObject;
                        Class dataClass = dataHolder.getType();
                        Repository repository = taskContext.getRepository();
                        Workflow workflow = taskContext.getWorkflow();
                        if (dataClass.equals(Double.class)) {
                            repository.setData(dataHolder, Double.valueOf(inputValue));
                            workflow.refreshStatus();
                        } else if (dataClass.equals(Float.class)) {
                            repository.setData(dataHolder, Float.valueOf(inputValue));
                            workflow.refreshStatus();
                        } else if (dataClass.equals(Integer.class)) {
                            repository.setData(dataHolder, Integer.valueOf(inputValue));
                            workflow.refreshStatus();
                        } else if (dataClass.equals(Boolean.class)) {
                            repository.setData(dataHolder, Boolean.valueOf(inputValue));
                            workflow.refreshStatus();
                        } else if (dataClass.equals(String.class)) {
                            repository.setData(dataHolder, inputValue);
                            workflow.refreshStatus();
                        } else {
                            System.out.println("type " + dataClass.getSimpleName() + " not supported");
                        }
                    }
                    break;
                }
        }
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : Repository(org.vcell.workflow.Repository) Workflow(org.vcell.workflow.Workflow) WorkflowParameter(org.vcell.workflow.WorkflowParameter) WorkflowObject(org.vcell.workflow.WorkflowObject)

Aggregations

WorkflowObject (org.vcell.workflow.WorkflowObject)2 WorkflowParameter (org.vcell.workflow.WorkflowParameter)2 DataInput (org.vcell.workflow.DataInput)1 DataOutput (org.vcell.workflow.DataOutput)1 Repository (org.vcell.workflow.Repository)1 Task (org.vcell.workflow.Task)1 Workflow (org.vcell.workflow.Workflow)1