use of org.eclipse.mylyn.wikitext.parser.util.MarkupToDocbook in project mylyn.docs by eclipse.
the class TextileToDocbookTest method setUp.
@Override
public void setUp() {
textileToDocbook = new MarkupToDocbook();
textileToDocbook.setMarkupLanguage(new TextileLanguage());
}
use of org.eclipse.mylyn.wikitext.parser.util.MarkupToDocbook in project mylyn.docs by eclipse.
the class ConvertMarkupToDocbook method handleFile.
@Override
protected void handleFile(final IFile file, String name) {
// $NON-NLS-1$
final IFile newFile = file.getParent().getFile(new Path(name + ".xml"));
if (newFile.exists()) {
if (!MessageDialog.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.ConvertMarkupToDocbook_overwrite, NLS.bind(Messages.ConvertMarkupToDocbook_fileExistsOverwrite, new Object[] { newFile.getFullPath() }))) {
return;
}
}
final MarkupToDocbook markupToDocbook = new MarkupToDocbook();
markupToDocbook.setMarkupLanguage(markupLanguage);
markupToDocbook.setBookTitle(name);
try {
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
String content = IOUtil.readFully(file);
final String docbook = markupToDocbook.parse(content);
if (newFile.exists()) {
// $NON-NLS-1$
newFile.setContents(// $NON-NLS-1$
new ByteArrayInputStream(docbook.getBytes("utf-8")), // $NON-NLS-1$
false, // $NON-NLS-1$
true, monitor);
} else {
// $NON-NLS-1$
newFile.create(new ByteArrayInputStream(docbook.getBytes("utf-8")), false, monitor);
}
// $NON-NLS-1$
newFile.setCharset("utf-8", monitor);
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
};
try {
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runnable);
} catch (InterruptedException e) {
return;
} catch (InvocationTargetException e) {
throw e.getCause();
}
} catch (Throwable e) {
StringWriter message = new StringWriter();
PrintWriter out = new PrintWriter(message);
out.println(Messages.ConvertMarkupToDocbook_cannotConvert + e.getMessage());
out.println(Messages.ConvertMarkupToDocbook_detailsFollow);
e.printStackTrace(out);
out.close();
MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.ConvertMarkupToDocbook_cannotCompleteOperation, message.toString());
}
}
Aggregations