use of org.apache.airavata.workflow.model.graph.GraphException in project airavata by apache.
the class XBayaToolBar method init.
private void init() {
this.toolbar = new JToolBar();
this.toolbar.setFloatable(false);
Border border = BorderFactory.createEtchedBorder();
this.toolbar.setBorder(border);
JButton addNodeButton = new JButton("Add Node");
addNodeButton.addActionListener(new AbstractAction() {
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent event) {
try {
XBayaToolBar.this.engine.getGUI().addNode();
} catch (RuntimeException e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
} catch (Error e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
}
}
});
JButton removeNodeButton = new JButton("Remove Node");
removeNodeButton.addActionListener(new AbstractAction() {
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent event) {
try {
XBayaToolBar.this.engine.getGUI().getGraphCanvas().removeSelectedNode();
} catch (GraphException e) {
// Should not happen
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
} catch (RuntimeException e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
} catch (Error e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
}
}
});
JButton connectEdgeButton = new JButton("Connect/Disconnect");
connectEdgeButton.addActionListener(new AbstractAction() {
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent event) {
try {
XBayaToolBar.this.engine.getGUI().getGraphCanvas().addOrRemoveEdge();
} catch (RuntimeException e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
} catch (Error e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
}
}
});
this.play = new JButton();
PAUSE_ICON = SwingUtil.createImageIcon(IMAGES_PAUSE_JPEG);
PLAY_ICON = SwingUtil.createImageIcon(IMAGES_PLAY_JPEG);
this.playAction = new AbstractAction(null, PAUSE_ICON) {
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e1) {
try {
Workflow workflow = engine.getGUI().getWorkflow();
WorkflowExecutionState executionState = workflow.getExecutionState();
if (executionState == WorkflowExecutionState.RUNNING || executionState == WorkflowExecutionState.STEP) {
workflow.setExecutionState(WorkflowExecutionState.PAUSED);
play.setIcon(PLAY_ICON);
} else if (executionState == WorkflowExecutionState.PAUSED) {
workflow.setExecutionState(WorkflowExecutionState.RUNNING);
play.setIcon(PAUSE_ICON);
} else {
throw new IllegalStateException("Unknown state :" + executionState);
}
} catch (RuntimeException e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
} catch (Error e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
}
}
};
this.play.setAction(this.playAction);
this.step = new JButton();
this.stepAction = new AbstractAction(null, SwingUtil.createImageIcon(IMAGES_STEP_JPEG)) {
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e2) {
try {
if (engine.getGUI().getWorkflow().getExecutionState() == WorkflowExecutionState.PAUSED) {
engine.getGUI().getWorkflow().setExecutionState(WorkflowExecutionState.STEP);
} else {
throw new IllegalStateException("Unknown state :" + engine.getGUI().getWorkflow().getExecutionState());
}
} catch (RuntimeException e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
} catch (Error e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
}
}
};
this.step.setAction(stepAction);
this.stop = new JButton();
this.stopAction = new AbstractAction(null, SwingUtil.createImageIcon(IMAGES_STOP_JPEG)) {
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e1) {
try {
if (engine.getGUI().getWorkflow().getExecutionState() != WorkflowExecutionState.NONE || engine.getGUI().getWorkflow().getExecutionState() != WorkflowExecutionState.STOPPED) {
engine.getGUI().getWorkflow().setExecutionState(WorkflowExecutionState.STOPPED);
} else {
throw new IllegalStateException("Unknown state :" + engine.getGUI().getWorkflow().getExecutionState());
}
} catch (RuntimeException e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
} catch (Error e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
}
}
};
this.stop.setAction(stopAction);
// this.toolbar.add(addNodeButton);
// this.toolbar.add(removeNodeButton);
// this.toolbar.addSeparator();
// this.toolbar.add(connectEdgeButton);
}
use of org.apache.airavata.workflow.model.graph.GraphException in project airavata by apache.
the class InstanceNode method edgeWasAdded.
/**
* @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasAdded(org.apache.airavata.workflow.model.graph.Edge)
*/
@Override
protected void edgeWasAdded(Edge edge) throws GraphException {
super.edgeWasAdded(edge);
if (edge instanceof ControlEdge) {
Port toPort = edge.getToPort();
Node toNode = toPort.getNode();
/*
* check if there is already more than instance node connecting to destination node
*/
if (!(toNode instanceof InstanceNode)) {
for (Node node : toNode.getControlInPort().getFromNodes()) {
if ((node instanceof InstanceNode) && this != node) {
throw new GraphException("Cannot connect more than one instance node to another node.");
}
}
}
}
}
use of org.apache.airavata.workflow.model.graph.GraphException in project airavata by apache.
the class ResourceNode method edgeWasAdded.
/**
* @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasAdded(org.apache.airavata.workflow.model.graph.Edge)
*/
@Override
protected void edgeWasAdded(Edge edge) throws GraphException {
super.edgeWasAdded(edge);
if (edge instanceof DataEdge) {
Port toPort = edge.getToPort();
Node toNode = toPort.getNode();
Port fromPort = edge.getFromPort();
Node fromNode = fromPort.getNode();
if (!(toNode instanceof ResourceNode && fromNode instanceof ResourceNode)) {
throw new GraphException("Cannot connect Resource Node to other type of nodes");
}
}
}
use of org.apache.airavata.workflow.model.graph.GraphException in project airavata by apache.
the class GraphImpl method importGraph.
/**
* @throws GraphException
* @see org.apache.airavata.workflow.model.graph.Graph#importGraph(org.apache.airavata.workflow.model.graph.Graph)
*/
public void importGraph(Graph graph) throws GraphException {
// Does not support other implementations.
if (!(graph instanceof GraphImpl)) {
throw new GraphException("Cannot import this graph implementation");
}
GraphImpl graphImpl = (GraphImpl) graph;
for (NodeImpl node : graphImpl.getNodes()) {
addNode(node);
// Recreates the ID so that it doesn't conflict with the existing
// one.
node.createID();
// Changes the position.
Point position = node.getPosition();
node.setPosition(new Point(position.x + 5, position.y + 5));
}
for (PortImpl port : graphImpl.getPorts()) {
addPort(port);
}
for (EdgeImpl edge : graphImpl.getEdges()) {
addEdge(edge);
}
}
use of org.apache.airavata.workflow.model.graph.GraphException in project airavata by apache.
the class WorkflowNodeGUI method openWorkflowTab.
public void openWorkflowTab(XBayaEngine engine) {
try {
Workflow workflow = this.node.getComponent().getWorkflow();
engine.getGUI().selectOrCreateGraphCanvas(workflow);
} catch (GraphException e) {
engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
} catch (ComponentException e) {
engine.getGUI().getErrorWindow().error(ErrorMessages.COMPONENT_FORMAT_ERROR, e);
}
}
Aggregations