in taverna-dataflow-activity-ui/src/main/java/org/apache/taverna/workbench/file/importworkflow/gui/ImportWorkflowWizard.java [1097:1217]
public void updateSource() {
ButtonModel selection = sourceSelection.getSelection();
Workflow chosenDataflow = null;
if (selection == null) {
chosenDataflow = null;
} else if (selection.equals(radioNew.getModel())) {
WorkflowBundle workflowBundle = new WorkflowBundle();
workflowBundle.setMainWorkflow(new Workflow());
workflowBundle.getMainWorkflow().setName(fileManager.getDefaultWorkflowName());
workflowBundle.setMainProfile(new Profile());
scufl2Tools.setParents(workflowBundle);
chosenDataflow = workflowBundle.getMainWorkflow();
} else if (selection.equals(radioFile.getModel())) {
final String filePath = fieldFile.getText();
try {
DataflowInfo opened = fileManager
.openDataflowSilently(null, new File(filePath));
if (checkInterrupted()) {
return;
}
chosenDataflow = opened.getDataflow().getMainWorkflow();
} catch (final OpenException e1) {
if (!background && !shownWarning) {
shownWarning = true;
logger.warn("Could not open workflow for merging: " + filePath, e1);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
radioFile.requestFocus();
JOptionPane.showMessageDialog(parentComponent,
"An error occured while trying to open " + filePath + "\n"
+ e1.getMessage(), "Could not open workflow",
JOptionPane.WARNING_MESSAGE);
setVisible(true);
}
});
}
}
} else if (selection.equals(radioUrl.getModel())) {
final String url = fieldUrl.getText();
try {
DataflowInfo opened = fileManager.openDataflowSilently(null, new URL(url));
if (checkInterrupted()) {
return;
}
chosenDataflow = opened.getDataflow().getMainWorkflow();
} catch (final OpenException e1) {
if (!background && !shownWarning) {
logger.warn("Could not open source workflow: " + url, e1);
shownWarning = true;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
fieldUrl.requestFocus();
JOptionPane.showMessageDialog(
parentComponent,
"An error occured while trying to open " + url + "\n"
+ e1.getMessage(), "Could not open workflow",
JOptionPane.WARNING_MESSAGE);
setVisible(true);
}
});
}
if (checkInterrupted()) {
return;
}
} catch (final MalformedURLException e1) {
if (!background && !shownWarning) {
logger.warn("Invalid workflow URL: " + url, e1);
shownWarning = true;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
fieldUrl.requestFocus();
JOptionPane.showMessageDialog(
parentComponent,
"The workflow location " + url + " is invalid\n"
+ e1.getLocalizedMessage(), "Invalid URL",
JOptionPane.ERROR_MESSAGE);
setVisible(true);
}
});
}
if (checkInterrupted()) {
return;
}
}
} else if (selection.equals(radioOpened.getModel())) {
DataflowSelection chosen = (DataflowSelection) chooseDataflow.getSelectedItem();
chosenDataflow = chosen.getDataflow().getMainWorkflow();
} else if (selection.equals(radioCustomSource.getModel())) {
chosenDataflow = customSourceDataFlow.getMainWorkflow();
} else {
logger.error("Unknown selection " + selection);
}
if (checkInterrupted()) {
return;
}
if (chosenDataflow != ImportWorkflowWizard.this.sourceWorkflow) {
Profile chosenProfile = null;
if (chosenDataflow != null) {
chosenProfile = chosenDataflow.getParent().getMainProfile();
}
updateWorkflowGraphic(previewSource, chosenDataflow, chosenProfile);
if (checkInterrupted()) {
return;
}
ImportWorkflowWizard.this.sourceWorkflow = chosenDataflow;
}
if (chosenDataflow == null) {
if (!background && !shownWarning) {
shownWarning = true;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(parentComponent,
"You need to choose a workflow for merging",
"No workflow chosen", JOptionPane.ERROR_MESSAGE);
setVisible(true);
}
});
}
}
}