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