Search in sources :

Example 16 with Node

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());
        }
    }
}
Also used : GraphPiece(org.apache.airavata.workflow.model.graph.GraphPiece) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) DynamicNode(org.apache.airavata.workflow.model.graph.dynamic.DynamicNode) Node(org.apache.airavata.workflow.model.graph.Node) StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode) Edge(org.apache.airavata.workflow.model.graph.Edge)

Example 17 with Node

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;
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) DynamicNode(org.apache.airavata.workflow.model.graph.dynamic.DynamicNode) Node(org.apache.airavata.workflow.model.graph.Node) StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode)

Example 18 with Node

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();
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) DynamicNode(org.apache.airavata.workflow.model.graph.dynamic.DynamicNode) Node(org.apache.airavata.workflow.model.graph.Node) StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode) ArrayList(java.util.ArrayList)

Example 19 with Node

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();
    }
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) DynamicNode(org.apache.airavata.workflow.model.graph.dynamic.DynamicNode) Node(org.apache.airavata.workflow.model.graph.Node) StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode)

Example 20 with Node

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);
}
Also used : InputComponent(org.apache.airavata.workflow.model.component.system.InputComponent) GraphPiece(org.apache.airavata.workflow.model.graph.GraphPiece) OutputComponent(org.apache.airavata.workflow.model.component.system.OutputComponent) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) DynamicNode(org.apache.airavata.workflow.model.graph.dynamic.DynamicNode) Node(org.apache.airavata.workflow.model.graph.Node) StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode) DataPort(org.apache.airavata.workflow.model.graph.DataPort) Port(org.apache.airavata.workflow.model.graph.Port) Point(java.awt.Point)

Aggregations

Node (org.apache.airavata.workflow.model.graph.Node)74 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)46 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)40 DataPort (org.apache.airavata.workflow.model.graph.DataPort)31 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)24 Port (org.apache.airavata.workflow.model.graph.Port)20 OutputNode (org.apache.airavata.workflow.model.graph.system.OutputNode)20 StreamSourceNode (org.apache.airavata.workflow.model.graph.system.StreamSourceNode)18 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)16 ForEachNode (org.apache.airavata.workflow.model.graph.system.ForEachNode)16 MemoNode (org.apache.airavata.workflow.model.graph.system.MemoNode)15 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)14 SubWorkflowNode (org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode)14 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)13 ConstantNode (org.apache.airavata.workflow.model.graph.system.ConstantNode)12 EndifNode (org.apache.airavata.workflow.model.graph.system.EndifNode)12 IfNode (org.apache.airavata.workflow.model.graph.system.IfNode)12 GraphException (org.apache.airavata.workflow.model.graph.GraphException)11 LinkedList (java.util.LinkedList)9 ArrayList (java.util.ArrayList)8