*/
public class ImageElement extends AbstractCdmFormElement implements PaintListener{
+ /**
+ * @author pplitzner
+ * @since Jul 17, 2019
+ *
+ */
+ public class LoadImageJob extends Job {
+ public LoadImageJob(String name) {
+ super(name);
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ IRunnableWithProgress runnable = getLoadImageRunnable(postRunnable);
+ try {
+ runnable.run(monitor);
+ } catch (Exception e) {
+ MessagingUtils.messageDialog("Could not load image", getClass(), e.getMessage() + ": " + getImageUri(), e);
+ }
+
+ return Status.OK_STATUS;
+ }
+ }
+
private URI imageUri;
private Image image;
public void loadImage(){
if(getImageUri() != null){
- Job job = new Job("Loading image") {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- IRunnableWithProgress runnable = getLoadImageRunnable(postRunnable);
- try {
- runnable.run(monitor);
- } catch (Exception e) {
- MessagingUtils.messageDialog("Could not load image", getClass(), e.getMessage() + ": " + getImageUri(), e);
- }
-
- return Status.OK_STATUS;
- }
- };
+ Job job = new LoadImageJob("Loading image");
job.schedule();
}
}
- public void unloadImage() {
- Job job = new Job("Unloading image") {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- IRunnableWithProgress runnable = getLoadImageRunnable(postRunnable);
- try {
- runnable.run(monitor);
- } catch (Exception e) {
- MessagingUtils.messageDialog("Could not unload image", getClass(), e.getMessage() + ": " + getImageUri(), e);
- }
-
- return Status.OK_STATUS;
- }
- };
- job.schedule();
-
- }
-
public IRunnableWithProgress getLoadImageRunnable(final Runnable postRunnable){
final Display display = getLayoutComposite().getDisplay();