IOException {
Tuple<ITutorialDocument, IEditorConnector> tuple = getTutorialDocument();
if (tuple == null)
return;
ITutorialDocument document = tuple.getLeft();
IEditorConnector editorConnector = tuple.getRight();
tuple = null;
boolean doIntegration = false;
for (ArtefactLocation location : artefactLocations) {
String providerID = location.getProviderID();
String artefactID = location.getArtefactID();
if (providerID == null || artefactID == null)
continue;
XMLProvider provider = new XMLProvider(providerID,
artefactID);
XMLReference reference = new XMLReference(provider);
IntegrationDialog dialog = new IntegrationDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell(),
document);
if (dialog.open() != Dialog.OK)
continue;
for (MetaArtefactOperation operation : dialog.getOperations()) {
XMLArtefactOperation o = new XMLArtefactOperation(operation
.getId());
o.setConfiguration(operation.getConfiguration());
reference.getOperations().add(o);
}
MetaIntegrator integrator = dialog.getIntegrator();
if (integrator != null) {
XMLIntegrator i = new XMLIntegrator(integrator.getId());
i.setConfiguration(integrator.getConfiguration());
reference.setIntegrator(i);
}
XMLArtefact artefactTag = ReferenceManager.getInstance()
.generateArtefact(document, reference);
if (editorConnector.insertTag(document, artefactTag.toString()))
doIntegration = true;
}
if (doIntegration) {
IntegrationJob job = new IntegrationJob(document);
job.setUser(true);
job.schedule();
try {
job.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
if (job.getResult().isOK())
document.setModified(true);
}
}