use of org.apache.airavata.workflow.model.component.system.InputComponent in project airavata by apache.
the class GraphCanvas method mouseClicked.
private void mouseClicked(MouseEvent event) {
/*
* If there is multi-selected and a click on a node, switch to that node or deselect node if it is already
* selected
*/
Point point = event.getPoint();
GraphPiece clicked = NodeController.getGUI(this.graph).getGraphPieceAt(point);
if ((clicked instanceof Node) && this.multipleSelectedNodes != null) {
Node node = (Node) clicked;
if (!this.crtlPressed) {
selectNode(node);
}
return;
} else if ((clicked instanceof Port) && event.getClickCount() == 2) {
// double click to add Input/Output nodes and connect with them when a DataPort is double clicked
Port port = (Port) clicked;
Point pos = port.getNode().getPosition();
Node node = null;
int xgap = (int) (1.5 * NodeGUI.MINIMUM_WIDTH);
int ygap = (int) (NodeGUI.MINIMUM_HEIGHT / 2);
Point nodePos = null;
switch(port.getKind()) {
case DATA_IN:
if (port.getFromNode() == null) {
nodePos = new Point(Math.max(0, pos.x - xgap), Math.max(0, pos.y - ygap));
node = addNode(new InputComponent(), nodePos);
connect(node.getOutputPorts().get(0), port);
}
break;
case DATA_OUT:
nodePos = new Point(pos.x + NodeGUI.MINIMUM_WIDTH + xgap, pos.y + ygap);
node = addNode(new OutputComponent(), nodePos);
connect(port, node.getInputPorts().get(0));
break;
default:
}
}
// delegate the event.
NodeController.getGUI(this.graph).mouseClicked(event, this.engine);
}
use of org.apache.airavata.workflow.model.component.system.InputComponent in project airavata by apache.
the class InputNode method getComponent.
/**
* @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#getComponent()
*/
@Override
public Component getComponent() {
Component component = super.getComponent();
if (component == null) {
// The component is null when read from the graph XML.
component = new InputComponent();
setComponent(component);
}
return component;
}
use of org.apache.airavata.workflow.model.component.system.InputComponent in project airavata by apache.
the class WorkflowModifier method createInputNodes.
/**
* @param graph
* @param originalFromPorts
* @throws GraphException
*/
private void createInputNodes(WSGraph graph, Set<WSPort> originalFromPorts) throws GraphException {
InputComponent inputComponent = new InputComponent();
for (WSPort originalFromPort : originalFromPorts) {
InputNode inputNode = inputComponent.createNode(graph);
List<Port> originalToPorts = originalFromPort.getToPorts();
boolean first = true;
for (Port originalToPort : originalToPorts) {
String toPortID = originalToPort.getID();
Port toPort = graph.getPort(toPortID);
graph.addEdge(inputNode.getPort(), toPort);
if (first) {
first = false;
Point position = NodeController.getGUI(originalToPort).getPosition();
Point inputNodePosition = new Point(0, position.y);
inputNode.setPosition(inputNodePosition);
}
}
}
}
use of org.apache.airavata.workflow.model.component.system.InputComponent in project airavata by apache.
the class WorkflowHarvester method harvest.
public Workflow[] harvest(Workflow workflow, QName dataType) {
LinkedList<Workflow> harvest = new LinkedList<Workflow>();
LinkedList<Pair<String, String>> candidates = getCandidates(workflow, dataType);
for (Pair<String, String> pair : candidates) {
Workflow clone = workflow.clone();
NodeImpl node = clone.getGraph().getNode(pair.getLeft());
if (null == node) {
throw new WorkflowRuntimeException("Specified node not found:" + pair.getLeft());
}
Port candidatePort = null;
List<DataPort> inPorts = node.getInputPorts();
for (DataPort dataPort : inPorts) {
if (pair.getRight().equals(dataPort.getID())) {
candidatePort = dataPort;
break;
}
}
if (null == candidatePort) {
throw new WorkflowRuntimeException("Specifies Port was not found:" + pair.getRight());
}
if (!(candidatePort.getFromNode() instanceof InputNode)) {
removeUnnecessaryNodes(node, candidatePort, clone);
Node input = clone.addNode(new InputComponent());
input.setPosition(new Point(Math.max(0, node.getPosition().x - 150), node.getPosition().y));
// original
if (clone.getGraph().getNodes().size() < workflow.getGraph().getNodes().size() && // its not the same as one already harvested
!isWorkflowAlreadyHarvested(harvest, clone)) {
try {
clone.getGraph().addEdge(input.getOutputPort(0), candidatePort);
cleanLeftOverInputNodes(clone);
} catch (GraphException e) {
throw new RuntimeException(e);
}
harvest.add(clone);
}
}
}
return harvest.toArray(new Workflow[0]);
}
use of org.apache.airavata.workflow.model.component.system.InputComponent in project airavata by apache.
the class WorkflowHarvester method harvest.
public Workflow[] harvest(Workflow workflow, QName dataType) {
LinkedList<Workflow> harvest = new LinkedList<Workflow>();
LinkedList<Pair<String, String>> candidates = getCandidates(workflow, dataType);
for (Pair<String, String> pair : candidates) {
Workflow clone = workflow.clone();
NodeImpl node = clone.getGraph().getNode(pair.getLeft());
if (null == node) {
throw new WorkflowRuntimeException("Specified node not found:" + pair.getLeft());
}
Port candidatePort = null;
List<DataPort> inPorts = node.getInputPorts();
for (DataPort dataPort : inPorts) {
if (pair.getRight().equals(dataPort.getID())) {
candidatePort = dataPort;
break;
}
}
if (null == candidatePort) {
throw new WorkflowRuntimeException("Specifies Port was not found:" + pair.getRight());
}
if (!(candidatePort.getFromNode() instanceof InputNode)) {
removeUnnecessaryNodes(node, candidatePort, clone);
Node input = clone.addNode(new InputComponent());
input.setPosition(new Point(Math.max(0, node.getPosition().x - 150), node.getPosition().y));
// original
if (clone.getGraph().getNodes().size() < workflow.getGraph().getNodes().size() && // its not the same as one already harvested
!isWorkflowAlreadyHarvested(harvest, clone)) {
try {
clone.getGraph().addEdge(input.getOutputPort(0), candidatePort);
cleanLeftOverInputNodes(clone);
} catch (GraphException e) {
throw new RuntimeException(e);
}
harvest.add(clone);
}
}
}
return harvest.toArray(new Workflow[0]);
}
Aggregations