use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.
the class GraphCanvas method maybeShowPopup.
private void maybeShowPopup(MouseEvent event) {
if (event.isPopupTrigger()) {
GraphPiece piece = NodeController.getGUI(this.graph).getGraphPieceAt(event.getPoint());
if (piece instanceof Node) {
prepareNodePopupMenu((Node) piece);
this.nodePopup.show(event.getComponent(), event.getX(), event.getY());
} else if (piece instanceof Edge) {
this.edgePopup.show(event.getComponent(), event.getX(), event.getY());
}
}
}
use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.
the class GraphCanvas method addNode.
/**
* Creates a new Node from a specified Component and adds it.
*
* @param component
* The Component to add.
* @param location
* The location to add the node.
*/
public synchronized Node addNode(Component component, Point location) {
if (component != null) {
Node node = this.workflow.addNode(component);
node.setPosition(location);
selectNode(node);
updateSize();
this.panel.repaint();
return node;
}
return null;
}
use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.
the class GraphCanvas method rerunSelectedNode.
private void rerunSelectedNode() {
if (this.selectedNode != null) {
ArrayList<Node> exploreNodes = new ArrayList<Node>();
exploreNodes.add(this.selectedNode);
while (exploreNodes.size() != 0) {
Node node = exploreNodes.get(0);
List<DataPort> outputPorts = node.getOutputPorts();
for (DataPort dataPort : outputPorts) {
exploreNodes.addAll(dataPort.getToNodes());
}
node.setState(NodeExecutionState.WAITING);
exploreNodes.remove(0);
}
this.repaint();
}
}
use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.
the class GraphCanvas method removeSelectedNode.
/**
* Removes the selected Node if any
*
* @throws GraphException
*/
public synchronized void removeSelectedNode() throws GraphException {
if (this.selectedNode != null) {
// deselect ports if they belong to this node.
if (this.selectedNode.containsPort(this.selectedInputPort)) {
deselectInputPort();
}
if (this.selectedNode.containsPort(this.selectedOutputPort)) {
deselectOutputPort();
}
this.workflow.removeNode(this.selectedNode);
deselectNode();
updateSize();
this.panel.repaint();
}
/*
* Delete multiple nodes as well
*/
if (this.multipleSelectedNodes != null) {
for (Node node : this.multipleSelectedNodes) {
// deselect ports if they belong to this node.
if (node.containsPort(this.selectedInputPort)) {
deselectInputPort();
}
if (node.containsPort(this.selectedOutputPort)) {
deselectOutputPort();
}
this.workflow.removeNode(node);
}
deselectNode();
updateSize();
this.panel.repaint();
}
}
use of org.apache.airavata.workflow.model.graph.Node 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);
}
Aggregations