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;
}
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());
}
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.
}
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:
}
}
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:
}
}
Aggregations