Search in sources :

Example 1 with GraphCanvas

use of org.apache.airavata.xbaya.ui.graph.GraphCanvas in project airavata by apache.

the class WorkflowFiler method saveAsWorkflow.

public void saveAsWorkflow() {
    GraphCanvas graphCanvas = engine.getGUI().getGraphCanvas();
    File saveAsWorkflowFile = saveAsWorkflow(graphCanvas);
    if (saveAsWorkflowFile != null) {
        graphCanvas.setWorkflowFile(saveAsWorkflowFile);
    }
}
Also used : GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas) File(java.io.File)

Example 2 with GraphCanvas

use of org.apache.airavata.xbaya.ui.graph.GraphCanvas in project airavata by apache.

the class WorkflowFiler method importWorkflow.

/**
 * Imports a workflow from the local file to the current workflow.
 */
public void importWorkflow() {
    int returnVal = this.graphFileChooser.showOpenDialog(this.engine.getGUI().getFrame());
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = this.graphFileChooser.getSelectedFile();
        try {
            String path = file.getPath();
            Workflow importedWorkflow;
            if (path.endsWith(XBayaConstants.GRAPH_FILE_SUFFIX)) {
                WSGraph importedGraph = WSGraphFactory.createGraph(file);
                importedWorkflow = Workflow.graphToWorkflow(importedGraph);
            } else {
                XmlElement importedWorkflowElement = XMLUtil.loadXML(file);
                importedWorkflow = new Workflow(importedWorkflowElement);
            }
            GraphCanvas newGraphCanvas = engine.getGUI().newGraphCanvas(true);
            newGraphCanvas.setWorkflow(importedWorkflow);
            this.engine.getGUI().setWorkflow(importedWorkflow);
            engine.getGUI().getGraphCanvas().setWorkflowFile(file);
        } catch (IOException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.OPEN_FILE_ERROR, e);
        } catch (GraphException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
        } catch (ComponentException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
        } catch (RuntimeException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
        } catch (Error e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
        }
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) ComponentException(org.apache.airavata.workflow.model.component.ComponentException) Workflow(org.apache.airavata.workflow.model.wf.Workflow) XmlElement(org.xmlpull.infoset.XmlElement) IOException(java.io.IOException) WSGraph(org.apache.airavata.workflow.model.graph.ws.WSGraph) File(java.io.File) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Example 3 with GraphCanvas

use of org.apache.airavata.xbaya.ui.graph.GraphCanvas in project airavata by apache.

the class WorkflowPropertyWindow method generateNewWorkflowName.

private String generateNewWorkflowName() {
    String baseName = "Workflow";
    List<String> existingNames = new ArrayList<String>();
    if (this.xbayaGUI != null) {
        List<GraphCanvas> graphCanvases = this.xbayaGUI.getGraphCanvases();
        for (GraphCanvas graphCanvas : graphCanvases) {
            existingNames.add(graphCanvas.getWorkflow().getName());
        }
    }
    int i = 1;
    String newName = baseName + i;
    while (existingNames.contains(newName)) {
        i++;
        newName = baseName + i;
    }
    return newName;
}
Also used : ArrayList(java.util.ArrayList) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Example 4 with GraphCanvas

use of org.apache.airavata.xbaya.ui.graph.GraphCanvas in project airavata by apache.

the class XBayaGUI method selectOrCreateGraphCanvas.

/**
 * Selects a canvas with a specified workflow if any; otherwise create one.
 *
 * This method needs to be called by Swing event thread.
 *
 * @param workflow
 */
public void selectOrCreateGraphCanvas(Workflow workflow) {
    GraphCanvas graphCanvas = null;
    for (GraphCanvas canvas : this.graphCanvases) {
        if (workflow == canvas.getWorkflow()) {
            graphCanvas = canvas;
        }
    }
    if (graphCanvas == null) {
        graphCanvas = newGraphCanvas(true);
        graphCanvas.setWorkflow(workflow);
    } else {
        setFocus(graphCanvas);
    }
}
Also used : GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Example 5 with GraphCanvas

use of org.apache.airavata.xbaya.ui.graph.GraphCanvas in project airavata by apache.

the class XBayaGUI method activeTabChanged.

private void activeTabChanged() {
    GraphCanvas graphPanel = getGraphCanvas();
    if (graphPanel != null) {
        // Reset the port viewers.
        Port inputPort = graphPanel.getSelectedInputPort();
        Port outputPort = graphPanel.getSelectedOutputPort();
        this.portViewer.setInputPort(inputPort);
        this.portViewer.setOutputPort(outputPort);
        // Reset component viewer.
        Node node = graphPanel.getSelectedNode();
        Component component;
        if (node != null) {
            component = node.getComponent();
        } else {
            component = this.componentSelector.getSelectedComponent();
        }
        this.componentViewer.setComponent(component);
        String name = graphPanel.getWorkflow().getName();
        setFrameName(name);
    } else {
    // TODO what to do when no tabs are present???
    }
}
Also used : Port(org.apache.airavata.workflow.model.graph.Port) Node(org.apache.airavata.workflow.model.graph.Node) Component(org.apache.airavata.workflow.model.component.Component) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Aggregations

GraphCanvas (org.apache.airavata.xbaya.ui.graph.GraphCanvas)14 Workflow (org.apache.airavata.workflow.model.wf.Workflow)6 File (java.io.File)3 GraphCanvasEventType (org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent.GraphCanvasEventType)3 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ArrayList (java.util.ArrayList)2 ComponentException (org.apache.airavata.workflow.model.component.ComponentException)2 WorkflowException (org.apache.airavata.workflow.model.exceptions.WorkflowException)2 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)2 GraphException (org.apache.airavata.workflow.model.graph.GraphException)2 Node (org.apache.airavata.workflow.model.graph.Node)2 Port (org.apache.airavata.workflow.model.graph.Port)2 WSGraph (org.apache.airavata.workflow.model.graph.ws.WSGraph)2 MonitorException (org.apache.airavata.xbaya.messaging.MonitorException)2 XmlElement (org.xmlpull.infoset.XmlElement)2 JsonObject (com.google.gson.JsonObject)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ContainerEvent (java.awt.event.ContainerEvent)1