Project

General

Profile

« Previous | Next » 

Revision 3b069ad4

Added by Patrick Plitzner almost 5 years ago

ref #8129 Handel widget disposed exceptions

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/media/MediaDetailElement.java
82 82
                        singleMediaRepresentationPart.getMediaRepresentation().setSuffix(imageInfo.getSuffix());
83 83
                    }
84 84
                    disposeImage();
85
                    element_image = formFactory.createImageElement(parentFormElement, uri, style);
86
                    StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
87
                    try {
88
                        element_image.initImageUri(uri);
89
                    } catch (IOException | HttpException e) {
90
                        exception(e);
85
                    if (!parentFormElement.getLayoutComposite().isDisposed()) {
86
                        element_image = formFactory.createImageElement(parentFormElement, uri, style);
87
                        StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
88
                        try {
89
                            element_image.initImageUri(uri);
90
                        } catch (IOException | HttpException e) {
91
                            exception(e);
92
                        }
93
                        element_image.loadImage();
94
                        disposeErrorLabel();
91 95
                    }
92
                    element_image.loadImage();
93
                    disposeErrorLabel();
94 96
                });
95 97
            } catch (Exception e){
96 98
               exception(e);
......
152 154
    }
153 155

  
154 156
    private void exception(Exception e){
155
        getLayoutComposite().getDisplay().asyncExec(()->{
156
            String exceptionString;
157
            if(e.getCause()!=null && e.getCause().getClass().equals(ImageReadException.class)){
158
                disposeErrorLabel();
159
                exceptionString = Messages.MediaDetailElement_NO_PREVIEW;
160
            }
161
            else{
162
                disposeErrorLabel();
163
                exceptionString = Messages.MediaDetailElement_NO_FILE_FOUND;
164
            }
165
            disposeImage();
166
            if(lblNoImage==null){
167
            	lblNoImage = formFactory.createLabel(getLayoutComposite(), exceptionString);
168
                lblNoImage.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
169
                lblNoImage.setAlignment(SWT.CENTER);
170
            }
171
            StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
172
        });
157
        if(!getLayoutComposite().isDisposed()){
158
            getLayoutComposite().getDisplay().asyncExec(()->{
159
                String exceptionString;
160
                if(e.getCause()!=null && e.getCause().getClass().equals(ImageReadException.class)){
161
                    disposeErrorLabel();
162
                    exceptionString = Messages.MediaDetailElement_NO_PREVIEW;
163
                }
164
                else{
165
                    disposeErrorLabel();
166
                    exceptionString = Messages.MediaDetailElement_NO_FILE_FOUND;
167
                }
168
                disposeImage();
169
                if(lblNoImage==null){
170
                    lblNoImage = formFactory.createLabel(getLayoutComposite(), exceptionString);
171
                    lblNoImage.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
172
                    lblNoImage.setAlignment(SWT.CENTER);
173
                }
174
                StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
175
            });
176
        }
173 177
    }
174 178

  
175 179
    private void disposeImage(){

Also available in: Unified diff