Search in sources :

Example 6 with AbstractInputStreamRunnable

use of org.csstudio.swt.widgets.util.AbstractInputStreamRunnable in project yamcs-studio by yamcs.

the class SVGSymbolImage method loadImage.

private void loadImage(IJobErrorHandler errorHandler) {
    AbstractInputStreamRunnable uiTask = new AbstractInputStreamRunnable() {

        @Override
        public void runWithInputStream(InputStream stream) {
            synchronized (SVGSymbolImage.this) {
                try {
                    loadDocument(stream);
                } finally {
                    try {
                        stream.close();
                    } catch (IOException e) {
                        Activator.getLogger().log(Level.WARNING, "ERROR in closing SVG image stream ", e);
                    }
                }
                loadingImage = false;
                Display.getCurrent().syncExec(new Runnable() {

                    @Override
                    public void run() {
                        fireSymbolImageLoaded();
                    }
                });
            }
        }
    };
    ResourceUtil.pathToInputStreamInJob(imagePath, uiTask, "Loading SVG Image...", errorHandler);
}
Also used : AbstractInputStreamRunnable(org.csstudio.swt.widgets.util.AbstractInputStreamRunnable) InputStream(java.io.InputStream) AbstractInputStreamRunnable(org.csstudio.swt.widgets.util.AbstractInputStreamRunnable) IOException(java.io.IOException)

Aggregations

InputStream (java.io.InputStream)6 AbstractInputStreamRunnable (org.csstudio.swt.widgets.util.AbstractInputStreamRunnable)6 IOException (java.io.IOException)5 Image (org.eclipse.swt.graphics.Image)4 IJobErrorHandler (org.csstudio.swt.widgets.util.IJobErrorHandler)2 ImageData (org.eclipse.swt.graphics.ImageData)2 IntrospectionException (java.beans.IntrospectionException)1