use of org.csstudio.swt.widgets.util.AbstractInputStreamRunnable in project yamcs-studio by yamcs.
the class NativeButtonFigure method setImagePath.
@SuppressWarnings("nls")
public void setImagePath(final IPath path) {
if (image != null) {
image.dispose();
image = null;
button.setImage(null);
}
AbstractInputStreamRunnable uiTask = new AbstractInputStreamRunnable() {
@Override
public void runWithInputStream(InputStream stream) {
image = new Image(null, stream);
try {
stream.close();
} catch (IOException e) {
}
if (!button.isDisposed()) {
button.setImage(image);
}
}
};
if (path != null && !path.isEmpty()) {
ResourceUtil.pathToInputStreamInJob(path, uiTask, "Load Button Icon...", new IJobErrorHandler() {
@Override
public void handleError(Exception exception) {
image = null;
ErrorHandlerUtil.handleError("Failed to load button icon.", exception);
}
});
}
}
use of org.csstudio.swt.widgets.util.AbstractInputStreamRunnable in project yamcs-studio by yamcs.
the class GIFSymbolImage method loadAnimatedImage.
private void loadAnimatedImage(IJobErrorHandler errorHandler) {
AbstractInputStreamRunnable uiTask = new AbstractInputStreamRunnable() {
@Override
public void runWithInputStream(InputStream stream) {
synchronized (GIFSymbolImage.this) {
ImageData[] dataArray = loader.load(stream);
if (dataArray == null || dataArray.length < 1)
return;
originalImageDataArray = dataArray;
originalImageData = originalImageDataArray[0];
animated = originalImageDataArray.length > 1;
loadingImage = false;
resetData();
if (animated)
startAnimation();
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
fireSymbolImageLoaded();
}
});
}
}
};
ResourceUtil.pathToInputStreamInJob(imagePath, uiTask, "Loading GIF Image...", errorHandler);
}
use of org.csstudio.swt.widgets.util.AbstractInputStreamRunnable in project yamcs-studio by yamcs.
the class PNGSymbolImage method loadImage.
private void loadImage(IJobErrorHandler errorHandler) {
AbstractInputStreamRunnable uiTask = new AbstractInputStreamRunnable() {
@Override
public void runWithInputStream(InputStream stream) {
synchronized (PNGSymbolImage.this) {
Image tempImage = null;
try {
tempImage = new Image(Display.getDefault(), stream);
ImageData imgData = tempImage.getImageData();
setOriginalImageData(imgData);
} finally {
try {
stream.close();
if (tempImage != null && !tempImage.isDisposed()) {
tempImage.dispose();
}
} catch (IOException e) {
Activator.getLogger().log(Level.WARNING, "ERROR in closing PNG image stream ", e);
}
}
loadingImage = false;
Display.getDefault().syncExec(new Runnable() {
public void run() {
fireSymbolImageLoaded();
}
});
}
}
};
ResourceUtil.pathToInputStreamInJob(imagePath, uiTask, "Loading PNG Image...", errorHandler);
}
use of org.csstudio.swt.widgets.util.AbstractInputStreamRunnable in project yamcs-studio by yamcs.
the class ActionButtonFigure method setImagePath.
@SuppressWarnings("nls")
public void setImagePath(final IPath path) {
dispose();
AbstractInputStreamRunnable uiTask = new AbstractInputStreamRunnable() {
@Override
public void runWithInputStream(InputStream stream) {
image = new Image(null, stream);
try {
stream.close();
} catch (IOException e) {
}
if (label.isEnabled())
label.setIcon(image);
else {
if (grayImage == null && image != null)
grayImage = new Image(null, image, SWT.IMAGE_GRAY);
label.setIcon(grayImage);
}
calculateTextPosition();
}
};
if (path != null && !path.isEmpty()) {
this.imagePath = path;
ResourceUtil.pathToInputStreamInJob(path, uiTask, "Load Action Button Icon...", new IJobErrorHandler() {
@Override
public void handleError(Exception exception) {
image = null;
Activator.getLogger().log(Level.WARNING, "Failed to load image from path" + path, exception);
}
});
}
if (label.isEnabled())
label.setIcon(image);
else {
if (grayImage == null && image != null)
grayImage = new Image(null, image, SWT.IMAGE_GRAY);
label.setIcon(grayImage);
}
calculateTextPosition();
}
use of org.csstudio.swt.widgets.util.AbstractInputStreamRunnable in project yamcs-studio by yamcs.
the class TabFigure method setIconPath.
public void setIconPath(final int index, final IPath path, final IJobErrorHandler errorHandler) {
dispose(index);
if (path != null && !path.isEmpty()) {
AbstractInputStreamRunnable uiTask = new AbstractInputStreamRunnable() {
@Override
public void runWithInputStream(InputStream stream) {
Image image = new Image(null, stream);
try {
stream.close();
} catch (IOException e) {
}
getTabLabel(index).setIcon(image);
}
};
ResourceUtil.pathToInputStreamInJob(path, uiTask, "Loading Tab Icon...", errorHandler);
}
}
Aggregations