use of org.eclipse.mylyn.docs.epub.core.wikitext.MarkupToOPS in project mylyn.docs by eclipse.
the class ConvertFromMarkupWizard method performFinish.
@Override
public boolean performFinish() {
final MarkupToOPS markupToEPUB = new MarkupToOPS();
markupToEPUB.setMarkupLanguage(markupLanguage);
final MultiStatus ms = new MultiStatus(EPUBUIPlugin.PLUGIN_ID, 0, Messages.ConvertFromMarkupWizard_1, null);
try {
getContainer().run(false, false, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
monitor.beginTask(Messages.ConvertFromMarkupWizard_2, 3);
try {
if (epubFile.exists()) {
// Delete the old one
epubFile.delete(true, monitor);
}
// Parse the wiki markup and populate the EPUB
markupFolder = markupToEPUB.parse(oebps, markupFile.getLocation().toFile());
monitor.worked(1);
EPUB publication = new EPUB();
publication.add(oebps);
epubFolder = publication.pack(epubFile.getLocation().toFile());
monitor.worked(1);
epubFile.refreshLocal(IResource.DEPTH_ONE, monitor);
monitor.worked(1);
List<ValidationMessage> messages = oebps.getMessages();
for (ValidationMessage validationMessage : messages) {
ms.add(new Status(IStatus.WARNING, EPUBUIPlugin.PLUGIN_ID, validationMessage.getMessage()));
}
} catch (Exception e) {
e.printStackTrace();
ms.add(new Status(IStatus.ERROR, EPUBUIPlugin.PLUGIN_ID, Messages.ConvertFromMarkupWizard_3, e));
} finally {
deleteFolder(epubFolder);
deleteFolder(markupFolder);
monitor.done();
}
}
});
} catch (Throwable e) {
ms.add(new Status(IStatus.ERROR, EPUBUIPlugin.PLUGIN_ID, Messages.ConvertFromMarkupWizard_4, e));
return false;
}
if (!ms.isOK()) {
StatusManager.getManager().handle(ms, StatusManager.BLOCK);
}
return ms.isOK();
}
Aggregations