use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.
the class JobScheduleTest method testProcessingExceptionWithRunnable.
@Test
public void testProcessingExceptionWithRunnable() {
final ProcessingException exception = new ProcessingException("expected JUnit test exception");
IFuture<Void> future = Jobs.getJobManager().schedule(new IRunnable() {
@Override
public void run() throws Exception {
throw exception;
}
}, Jobs.newInput().withRunContext(RunContexts.copyCurrent()).withExceptionHandling(null, false));
try {
future.awaitDoneAndGet();
fail("Exception expected");
} catch (Exception e) {
assertSame(exception, e);
assertTrue(future.isDone());
}
}
use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.
the class AbstractSmartColumn2 method initConfig.
@Override
protected void initConfig() {
super.initConfig();
m_contributionHolder = new ContributionComposite(this);
setSortCodesByDisplayText(getConfiguredSortCodesByDisplayText());
// code type
if (getConfiguredCodeType() != null) {
setCodeTypeClass(getConfiguredCodeType());
}
// lazy lookup decorator
Class<? extends ILookupCall<VALUE>> lookupCallClass = getConfiguredLookupCall();
if (lookupCallClass != null) {
ILookupCall<VALUE> call;
try {
call = BEANS.get(lookupCallClass);
setLookupCall(call);
} catch (Exception e) {
BEANS.get(ExceptionHandler.class).handle(new ProcessingException("error creating instance of class '" + lookupCallClass.getName() + "'.", e));
}
}
}
use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.
the class SVGUtility method writeSVGDocument.
public static void writeSVGDocument(SVGDocument doc, OutputStream out, String encoding) {
try {
DOMSource domSource = new DOMSource(doc);
StreamResult streamResult = new StreamResult(out);
Transformer t = XmlUtility.newTransformer();
if (encoding != null) {
t.setOutputProperty("encoding", encoding);
}
t.transform(domSource, streamResult);
} catch (TransformerException e) {
throw new ProcessingException("Writing SVG Failed", e);
}
}
use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.
the class SVGUtility method readSVGDocument.
/**
* Parses a SVG document read by the given input stream. The document returned can be modified on XML-level. If you
* need to perform any CSS, text size and and bounding box operations use
* {@link #readSVGDocumentForGraphicalModification(InputStream)} instead.
*
* @param in
* input stream the SVG document is read from.
* @return Returns the SVG document.
*/
public static SVGDocument readSVGDocument(InputStream in) {
String cn;
try {
cn = Class.forName("org.apache.xerces.parsers.SAXParser").getName();
} catch (ClassNotFoundException t) {
// NOSONAR
try {
cn = Class.forName("com.sun.org.apache.xerces.internal.parsers.SAXParser").getName();
} catch (ClassNotFoundException e) {
throw new ProcessingException("Could not find SAXParser", e);
}
}
SAXSVGDocumentFactory documentFactory = new SAXSVGDocumentFactory(cn);
documentFactory.setValidating(false);
SVGDocument doc;
try {
doc = documentFactory.createSVGDocument(null, in);
} catch (Exception e) {
throw new ProcessingException("Reading SVG Failed", e);
}
try {
// needed to make anchors work but only works in dom level 3
doc.setDocumentURI("urn:svg");
} catch (RuntimeException e) {
LOG.debug("Could not set document uri. Dom level seems to be lass than version 3", e);
}
return doc;
}
use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.
the class JsonSvgField method svgToString.
protected String svgToString(SVGDocument svg) {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
SVGUtility.writeSVGDocument(svg, out, SVG_ENCODING);
return new String(out.toByteArray(), SVG_ENCODING);
} catch (UnsupportedEncodingException | ProcessingException e) {
throw new UiException("Failed to write SVG document", e);
}
}
Aggregations