use of org.csstudio.swt.widgets.util.IJobErrorHandler 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.IJobErrorHandler 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.IJobErrorHandler in project yamcs-studio by yamcs.
the class TabEditPart method setTabFigureProperty.
private void setTabFigureProperty(int index, TabProperty tabProperty, final Object newValue) {
Label label = getTabFigure().getTabLabel(index);
switch(tabProperty) {
case TITLE:
label.setText((String) newValue);
updateTabAreaSize();
break;
case FONT:
label.setFont(((OPIFont) newValue).getSWTFont());
updateTabAreaSize();
break;
case BACKCOLOR:
getTabFigure().setTabColor(index, ((OPIColor) newValue).getSWTColor());
break;
case FORECOLOR:
label.setForegroundColor(CustomMediaFactory.getInstance().getColor(((OPIColor) newValue).getRGBValue()));
break;
case ENABLED:
getTabFigure().setTabEnabled(index, (Boolean) newValue);
break;
case ICON_PATH:
getTabFigure().setIconPath(index, getWidgetModel().toAbsolutePath((IPath) newValue), new IJobErrorHandler() {
@Override
public void handleError(Exception e) {
String message = "Failed to load image from " + newValue + "\n" + e;
Activator.getLogger().log(Level.WARNING, message, e);
ConsoleService.getInstance().writeError(message);
}
});
break;
default:
break;
}
}
use of org.csstudio.swt.widgets.util.IJobErrorHandler in project yamcs-studio by yamcs.
the class GIFSymbolImage method asyncLoadImage.
@Override
public void asyncLoadImage() {
if (imagePath == null)
return;
loadingImage = true;
if (animated) {
stopAnimation();
showIndex = 0;
animationIndex = 0;
}
// loading by stream
loadAnimatedImage(new IJobErrorHandler() {
private int maxAttempts = 5;
@Override
public void handleError(Exception e) {
if (maxAttempts-- > 0) {
try {
Thread.sleep(100);
loadAnimatedImage(this);
return;
} catch (InterruptedException exception) {
}
}
loadingImage = false;
// fireSymbolImageLoaded();
Activator.getLogger().log(Level.WARNING, "ERROR in loading GIF image " + imagePath, e);
}
});
}
use of org.csstudio.swt.widgets.util.IJobErrorHandler in project yamcs-studio by yamcs.
the class PNGSymbolImage method asyncLoadImage.
public void asyncLoadImage() {
if (imagePath == null)
return;
loadingImage = true;
loadImage(new IJobErrorHandler() {
private int maxAttempts = 5;
public void handleError(Exception exception) {
if (maxAttempts-- > 0) {
try {
Thread.sleep(100);
loadImage(this);
return;
} catch (InterruptedException e) {
}
}
loadingImage = false;
// fireSymbolImageLoaded();
Activator.getLogger().log(Level.WARNING, "ERROR in loading PNG image " + imagePath, exception);
}
});
}
Aggregations