Search in sources :

Example 1 with WorkflowExecutionState

use of org.apache.airavata.workflow.model.wf.WorkflowExecutionState in project airavata by apache.

the class SSWorkflowInterpreterInteractorImpl method notify.

@Override
public boolean notify(WorkflowExecutionMessage messageType, WorkflowInterpreterConfiguration config, Object data) {
    switch(messageType) {
        case NODE_STATE_CHANGED:
            break;
        case EXECUTION_STATE_CHANGED:
            WorkflowExecutionState state = (WorkflowExecutionState) data;
            config.getWorkflow().setExecutionState(state);
            // }
            break;
        case EXECUTION_TASK_START:
            break;
        case EXECUTION_TASK_END:
            break;
        case OPEN_SUBWORKFLOW:
            break;
        case HANDLE_DEPENDENT_NODES_DIFFERED_INPUTS:
            break;
        default:
            return false;
    }
    return true;
}
Also used : WorkflowExecutionState(org.apache.airavata.workflow.model.wf.WorkflowExecutionState)

Example 2 with WorkflowExecutionState

use of org.apache.airavata.workflow.model.wf.WorkflowExecutionState 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);
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) WorkflowExecutionState(org.apache.airavata.workflow.model.wf.WorkflowExecutionState) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Workflow(org.apache.airavata.workflow.model.wf.Workflow) JToolBar(javax.swing.JToolBar) Border(javax.swing.border.Border) AbstractAction(javax.swing.AbstractAction)

Aggregations

WorkflowExecutionState (org.apache.airavata.workflow.model.wf.WorkflowExecutionState)2 ActionEvent (java.awt.event.ActionEvent)1 AbstractAction (javax.swing.AbstractAction)1 JButton (javax.swing.JButton)1 JToolBar (javax.swing.JToolBar)1 Border (javax.swing.border.Border)1 GraphException (org.apache.airavata.workflow.model.graph.GraphException)1 Workflow (org.apache.airavata.workflow.model.wf.Workflow)1