Search in sources :

Example 11 with GraphCanvas

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

the class WorkflowImportWindow method ok.

private void ok() {
    List<RegistrySearchResult> selectedValues = this.list.getSelectedValues();
    try {
        for (RegistrySearchResult result : selectedValues) {
            org.apache.airavata.model.Workflow workflow = getClient().getWorkflow(result.getResourceName());
            XmlElement workflowElement = XMLUtil.stringToXmlElement(workflow.getGraph());
            Workflow w = new Workflow(workflowElement);
            GraphCanvas newGraphCanvas = engine.getGUI().newGraphCanvas(true);
            newGraphCanvas.setWorkflow(w);
            engine.getGUI().getGraphCanvas().setWorkflowFile(null);
        }
        hide();
    } catch (Exception e) {
        engine.getGUI().getErrorWindow().error(e);
    }
}
Also used : RegistrySearchResult(org.apache.airavata.xbaya.ui.experiment.RegistrySearchResult) XmlElement(org.xmlpull.infoset.XmlElement) Workflow(org.apache.airavata.workflow.model.wf.Workflow) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) TException(org.apache.thrift.TException) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException)

Example 12 with GraphCanvas

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

the class RegistryWorkflowPublisherWindow method ok.

private void ok() {
    String name = this.nameTextField.getText();
    String description = this.descriptionTextArea.getText();
    GraphCanvas graphCanvas = this.engine.getGUI().getGraphCanvas();
    graphCanvas.setNameAndDescription(name, description);
    workflow.setName(name);
    String workflowTemplateName = workflow.getName();
    try {
        ThriftClientData thriftClientData = engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE);
        Client client = AiravataClientFactory.createAiravataClient(thriftClientData.getServerAddress(), thriftClientData.getServerPort());
        if (client.isWorkflowExistWithName(workflowTemplateName)) {
            int result = JOptionPane.showConfirmDialog(this.dialog.getDialog(), "A workflow with the name " + workflowTemplateName + " already exists. Do you want to update it?", "Register Workflow", JOptionPane.YES_NO_CANCEL_OPTION);
            if (result == JOptionPane.NO_OPTION) {
                return;
            } else if (result == JOptionPane.CANCEL_OPTION) {
                hide();
            }
            String workflowAsString = XMLUtil.xmlElementToString(engine.getGUI().getGraphCanvas().getWorkflow().toXML());
            org.apache.airavata.model.Workflow workflowData = new org.apache.airavata.model.Workflow();
            workflowData.setName(workflowTemplateName);
            workflowData.setGraph(workflowAsString);
            client.registerWorkflow(engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE).getGatewayId(), workflowData);
            hide();
        }
    } catch (Exception e) {
        this.engine.getGUI().getErrorWindow().error(e.getMessage());
    }
}
Also used : ThriftClientData(org.apache.airavata.xbaya.ThriftClientData) Workflow(org.apache.airavata.workflow.model.wf.Workflow) Client(org.apache.airavata.api.Airavata.Client) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Example 13 with GraphCanvas

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

the class XBayaGUI method getNewGraphCanvas.

public GraphCanvas getNewGraphCanvas(String wfName, String wfDescription) {
    GraphCanvas newGraphCanvas = new GraphCanvas(this.engine, wfName);
    newGraphCanvas.setDescription(wfDescription);
    this.graphCanvases.add(newGraphCanvas);
    this.graphTabbedPane.addTab(newGraphCanvas.getWorkflow().getName(), newGraphCanvas.getSwingComponent());
    final int index = graphTabbedPane.getTabCount() - 1;
    TabLabelButton tabLabelButton = new TabLabelButton(graphTabbedPane, "Close this workflow");
    graphTabbedPane.setTabComponentAt(index, tabLabelButton);
    tabLabelButton.setCloseButtonListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            removeGraphCanvasFromIndex(index);
        }
    });
    graphTabbedPane.addContainerListener(new ContainerListener() {

        @Override
        public void componentAdded(ContainerEvent event) {
        }

        @Override
        public void componentRemoved(ContainerEvent event) {
            List<GraphCanvas> graphCanvases = engine.getGUI().getGraphCanvases();
            for (GraphCanvas graphCanvas : graphCanvases) {
                if (graphCanvas.getSwingComponent() == event.getComponent()) {
                    if (graphCanvas.isWorkflowChanged()) {
                        setFocus(graphCanvas);
                        if (JOptionPane.showConfirmDialog(null, "The workflow '" + graphCanvas.getWorkflow().getName() + "' has been modified. Save changes?", "Save Workflow", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                            graphFiler.saveWorkflow(graphCanvas);
                        }
                    }
                    break;
                }
            }
        }
    });
    newGraphCanvas.addGraphCanvasListener(this.componentViewer);
    newGraphCanvas.addGraphCanvasListener(this.portViewer);
    newGraphCanvas.addGraphCanvasListener(new GraphCanvasListener() {

        public void graphCanvasChanged(GraphCanvasEvent event) {
            GraphCanvasEventType type = event.getType();
            final GraphCanvas graphCanvas = event.getGraphCanvas();
            final Workflow workflow = event.getWorkflow();
            switch(type) {
                case GRAPH_LOADED:
                case NAME_CHANGED:
                    SwingUtilities.invokeLater(new Runnable() {

                        public void run() {
                            String name = workflow.getName();
                            // Change the name of the tab.
                            updateTabTitle(graphCanvas, workflow);
                            // Change the name of the frame.
                            setFrameName(name);
                        }
                    });
                    break;
                case NODE_SELECTED:
                case INPUT_PORT_SELECTED:
                case OUTPUT_PORT_SELECTED:
                // Do nothing
                case WORKFLOW_CHANGED:
                    updateTabTitle(graphCanvas, graphCanvas.getWorkflow());
                    setFrameName(workflow.getName());
                    for (ChangeListener listener : tabChangeListeners) {
                        try {
                            listener.stateChanged(null);
                        } catch (Exception e) {
                            logger.error(e.getMessage(), e);
                        }
                    }
            }
        }

        private void updateTabTitle(final GraphCanvas graphCanvas, final Workflow workflow) {
            int index = XBayaGUI.this.graphTabbedPane.indexOfComponent(graphCanvas.getSwingComponent());
            String newTitle = workflow.getName();
            if (graphCanvas.isWorkflowChanged()) {
                newTitle = "*" + newTitle;
            }
            XBayaGUI.this.graphTabbedPane.setTitleAt(index, newTitle);
        }
    });
    return newGraphCanvas;
}
Also used : ContainerEvent(java.awt.event.ContainerEvent) TabLabelButton(org.apache.airavata.xbaya.ui.widgets.TabLabelButton) ActionEvent(java.awt.event.ActionEvent) Workflow(org.apache.airavata.workflow.model.wf.Workflow) InvocationTargetException(java.lang.reflect.InvocationTargetException) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) MonitorException(org.apache.airavata.xbaya.messaging.MonitorException) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) ActionListener(java.awt.event.ActionListener) GraphCanvasEventType(org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent.GraphCanvasEventType) GraphCanvasListener(org.apache.airavata.xbaya.ui.graph.GraphCanvasListener) ContainerListener(java.awt.event.ContainerListener) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) ChangeListener(javax.swing.event.ChangeListener) GraphCanvasEvent(org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Example 14 with GraphCanvas

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

the class WorkflowFiler method openWorkflow.

/**
 * Opens a current workflow from the local file.
 */
public void openWorkflow() {
    Workflow workflow = null;
    int returnVal = this.graphFileChooser.showOpenDialog(this.engine.getGUI().getFrame());
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = this.graphFileChooser.getSelectedFile();
        logger.debug(file.getPath());
        try {
            String path = file.getPath();
            if (path.endsWith(XBayaConstants.GRAPH_FILE_SUFFIX)) {
                WSGraph graph = WSGraphFactory.createGraph(file);
                workflow = Workflow.graphToWorkflow(graph);
            } else {
                JsonObject workflowObject = JSONUtil.loadJSON(file);
                // XmlElement workflowElement = XMLUtil.loadXML(file);
                // workflow = new Workflow(workflowElement);
                workflow = new Workflow(workflowObject);
            }
            GraphCanvas newGraphCanvas = engine.getGUI().newGraphCanvas(true);
            newGraphCanvas.setWorkflow(workflow);
            // this.engine.setWorkflow(workflow);
            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) JsonObject(com.google.gson.JsonObject) 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)

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