Search in sources :

Example 6 with GraphCanvas

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

the class XBayaGUI method removeGraphCanvasFromIndex.

private boolean removeGraphCanvasFromIndex(int index) {
    boolean actionSuccess = true;
    if ((graphTabbedPane.getTabCount() > 0) && (index < this.graphTabbedPane.getTabCount())) {
        GraphCanvas graphCanvas = graphCanvases.get(index);
        if (graphCanvas.isWorkflowChanged()) {
            int result = JOptionPane.showConfirmDialog(frame, "'" + graphCanvas.getWorkflow().getName() + "' has been modified. Save changes?", "Save Workflow", JOptionPane.YES_NO_CANCEL_OPTION);
            try {
                if (result == JOptionPane.YES_OPTION) {
                    graphFiler.saveWorkflow(graphCanvas);
                    if (graphCanvas.isWorkflowChanged()) {
                        // if cancelled while trying to save
                        actionSuccess = false;
                    }
                } else if (result == JOptionPane.CANCEL_OPTION) {
                    actionSuccess = false;
                }
            } catch (Exception e) {
                logger.error(e.getMessage(), e);
            }
        }
        if (actionSuccess) {
            graphCanvases.remove(index);
            graphTabbedPane.removeTabAt(index);
            activeTabChanged();
        }
    }
    return actionSuccess;
}
Also used : GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas) 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)

Example 7 with GraphCanvas

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

the class XBayaMenuItem method createFileMenu.

private void createFileMenu() {
    createOpenWorkflowMenuItem();
    createSaveWorkflowItem();
    createSaveAsWorkflowItem();
    createSaveAllWorkflowItem();
    createSaveWorkflowtoRegistryItem();
    createImportWorkflowItemFromFileSystem();
    createImportWorkflowItemFromRegistry();
    createExportJythonScriptItem();
    createExportBpelScriptItem();
    createSaveWorkflowImageItem();
    createExportODEScriptsItem();
    clearWorkflowItem = createClearWorkflowItem();
    newWorkflowTabItem = createNewWorkflowTabMenuItem();
    closeWorkflowItem = createCloseWorkflowTabItem();
    closeAllWorkflowItem = createCloseAllWorkflowTabItem();
    nextWorkflowTabItem = createNextWorkflowTabItem();
    urlItem = createURLRegistryItem();
    // createRegisterHostDesc();
    // createRegisterServiceDesc();
    // createRegisterApplicationDesc();
    xbayaMenuItem = new JMenu("XBaya");
    xbayaMenuItem.setMnemonic(KeyEvent.VK_X);
    // JMenu newMenu = new JMenu("New");
    // newMenu.add(newWorkflowTabItem);
    // newMenu.addSeparator();
    // 
    // newMenu.add(this.registerApplicationDesc);
    // newMenu.addSeparator();
    // JMenu regAddSubMenuItem = new JMenu("Registry additions");
    // newMenu.add(regAddSubMenuItem);
    // regAddSubMenuItem.add(this.registerHostDesc);
    // regAddSubMenuItem.add(this.registerServiceDesc);
    // 
    // xbayaMenuItem.add(newMenu);
    xbayaMenuItem.add(newWorkflowTabItem);
    // xbayaMenuItem.add(registerHostDesc);
    // xbayaMenuItem.add(this.registerServiceDesc);
    // xbayaMenuItem.add(registerApplicationDesc);
    xbayaMenuItem.add(importWorkflowItemFromRegistry);
    xbayaMenuItem.add(saveWorkflowtoRegistryItem);
    xbayaMenuItem.addSeparator();
    xbayaMenuItem.add(this.openWorkflowItem);
    xbayaMenuItem.addSeparator();
    xbayaMenuItem.add(clearWorkflowItem);
    xbayaMenuItem.add(closeWorkflowItem);
    xbayaMenuItem.add(closeAllWorkflowItem);
    // This menu item did not seem useful at all
    // xbayaMenuItem.add(this.nextWorkflowTabItem);
    xbayaMenuItem.addSeparator();
    xbayaMenuItem.add(this.saveWorkflowItem);
    xbayaMenuItem.add(this.saveAsWorkflowItem);
    xbayaMenuItem.add(this.saveAllWorkflowItem);
    // JMenu importMenu = new JMenu("Import");
    // importMenu.add(importWorkflowItemFromFileSystem);
    // importMenu.add(importWorkflowItemFromRegistry);
    // importMenu.addSeparator();
    // importMenu.add(urlItem);
    // JMenu exportMenu = new JMenu("Export");
    // exportMenu.add(saveWorkflowtoRegistryItem);
    // exportMenu.addSeparator();
    // exportMenu.add(exportJythonItem);
    // exportMenu.add(exportBpelItem);
    // exportMenu.add(exportODEScriptsItem);
    // exportMenu.addSeparator();
    // exportMenu.add(saveImageItem);
    // 
    // xbayaMenuItem.add(importMenu);
    // xbayaMenuItem.add(exportMenu);
    xbayaMenuItem.addSeparator();
    xbayaMenuItem.add(exitItem);
    xbayaMenuItem.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(MenuEvent e) {
            GraphCanvas graphCanvas = engine.getGUI().getGraphCanvas();
            saveAsWorkflowItem.setEnabled(isWorkflowTabPresent() && graphCanvas.getWorkflowFile() != null);
            saveWorkflowItem.setEnabled(isSaveShouldBeActive());
            saveAllWorkflowItem.setEnabled(engine.getGUI().getGraphCanvases().size() > 0);
            saveWorkflowtoRegistryItem.setEnabled(isWorkflowTabPresent());
            exportJythonItem.setEnabled(isWorkflowTabPresent());
            exportBpelItem.setEnabled(isWorkflowTabPresent());
            exportODEScriptsItem.setEnabled(isWorkflowTabPresent());
            saveImageItem.setEnabled(isWorkflowTabPresent());
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });
    executionModeChanged(engine.getConfiguration());
}
Also used : MenuListener(javax.swing.event.MenuListener) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas) JMenu(javax.swing.JMenu) MenuEvent(javax.swing.event.MenuEvent)

Example 8 with GraphCanvas

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

the class MonitorEventHandler method handleEvent.

private void handleEvent(EventData event, boolean forward) {
    // EventType type = event.getType();
    // todo currrently we do not set the workflowID properly its just node ID
    // URI workflowID = event.getWorkflowID();
    List<GraphCanvas> graphCanvases = this.xbayaGUI.getGraphCanvases();
    for (GraphCanvas graphCanvas : graphCanvases) {
        Workflow workflow = graphCanvas.getWorkflow();
        // URI instanceID = workflow.getGPELInstanceID();
        // if (instanceID == null) {
        // If the workflow doesn't have an instance ID, it's a template.
        // We handle it so that users can use a workflow template to
        // monitor a workflow too.
        // This is also needed in the case of jython workflow.
        handleEvent(event, forward, workflow.getGraph());
        graphCanvas.repaint();
    // } else if (instanceID.equals(workflowID)) {
    // This is the regular case.
    // found = true;
    // handleEvent(event, forward, workflow.getGraph());
    // } else if (null != workflowID
    // && -1 != WSDLUtil.findWorkflowName(workflowID).indexOf(WSDLUtil.findWorkflowName(instanceID))) {
    // handleEvent(event, WSDLUtil.findWorkflowName(workflowID), workflow.getGraph());
    // }
    }
// // Load a sub-workflow.
// if (type == MonitorUtil.EventType.WORKFLOW_INITIALIZED) {
// if (forward) {
// // Check if the workflow instance is already open.
// for (GraphCanvas graphCanvas : graphCanvases) {
// Workflow workflow = graphCanvas.getWorkflow();
// URI instanceID = workflow.getGPELInstanceID();
// if (workflowID.equals(instanceID)) {
// // The workflow instance is already loaded.
// return;
// }
// }
// loadWorkflow(workflowID);
// } else {
// // Don't need to close the workflow when it's opened.
// }
// }
// 
// if (found == false && workflowID != null) {
// // Loads the workflow instance ID in case a user started to monitor
// // in the middle.
// loadWorkflow(workflowID);
// }
// 
// /*
// * Handle resource mapping message which contains resource from Amazon EC2 Since workflowID (workflowName) from
// * message and instanceID do not equal, so we have to handle it explicitly
// */
// if (type == EventType.RESOURCE_MAPPING && event.getMessage().contains("i-")) {
// String nodeID = event.getNodeID();
// for (GraphCanvas graphCanvas : graphCanvases) {
// Node node = graphCanvas.getWorkflow().getGraph().getNode(nodeID);
// if (node != null) {
// ControlPort control = node.getControlInPort();
// if (control != null) {
// Node fromNode = control.getFromNode();
// if (fromNode instanceof InstanceNode) {
// InstanceNode ec2Node = (InstanceNode) fromNode;
// 
// /*
// * parse message and set output to InstanceNode
// */
// int start = event.getMessage().indexOf("i-");
// String instanceId = event.getMessage().substring(start, start + 10);
// ec2Node.setOutputInstanceId(instanceId);
// 
// // make this node to not start a new instance
// ec2Node.setStartNewInstance(false);
// ec2Node.setInstanceId(instanceId);
// ec2Node.setAmiId(null);
// }
// }
// }
// }
// }
// TODO There is a possibility that XBaya misses to handle some
// notification while a workflow is being loaded. Create a thread for
// each workflow ID to handle notifications.
}
Also used : Workflow(org.apache.airavata.workflow.model.wf.Workflow) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Example 9 with GraphCanvas

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

the class ComponentViewer method graphCanvasChanged.

/**
 * @see org.apache.airavata.xbaya.ui.graph.GraphCanvasListener#graphCanvasChanged(org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent)
 */
public void graphCanvasChanged(GraphCanvasEvent event) {
    GraphCanvasEventType type = event.getType();
    GraphCanvas graphCanvas = event.getGraphCanvas();
    switch(type) {
        case NODE_SELECTED:
            Node node = graphCanvas.getSelectedNode();
            if (node == null) {
                setComponent(null);
            } else {
                setComponent(node.getComponent());
            }
            break;
        case GRAPH_LOADED:
        case NAME_CHANGED:
        case INPUT_PORT_SELECTED:
        case OUTPUT_PORT_SELECTED:
    }
}
Also used : GraphCanvasEventType(org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent.GraphCanvasEventType) Node(org.apache.airavata.workflow.model.graph.Node) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Example 10 with GraphCanvas

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

the class PortViewer method graphCanvasChanged.

/**
 * @see org.apache.airavata.xbaya.ui.graph.GraphCanvasListener#graphCanvasChanged(org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent)
 */
public void graphCanvasChanged(GraphCanvasEvent event) {
    GraphCanvasEventType type = event.getType();
    GraphCanvas graphCanvas = event.getGraphCanvas();
    switch(type) {
        case INPUT_PORT_SELECTED:
            Port inputPort = graphCanvas.getSelectedInputPort();
            setInputPort(inputPort);
            break;
        case OUTPUT_PORT_SELECTED:
            Port outputPort = graphCanvas.getSelectedOutputPort();
            setOutputPort(outputPort);
            break;
        case GRAPH_LOADED:
        case NAME_CHANGED:
        case NODE_SELECTED:
    }
}
Also used : GraphCanvasEventType(org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent.GraphCanvasEventType) DataPort(org.apache.airavata.workflow.model.graph.DataPort) Port(org.apache.airavata.workflow.model.graph.Port) 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