Project

General

Profile

« Previous | Next » 

Revision ff071396

Added by Katja Luther about 5 years ago

catch widget is disposed exceptions

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmDataViewerE4.java
13 13

  
14 14
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
15 15
import org.eclipse.e4.core.contexts.IEclipseContext;
16
import org.eclipse.e4.core.services.log.Logger;
16 17
import org.eclipse.jface.viewers.Viewer;
17 18
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.SWTException;
18 20
import org.eclipse.swt.widgets.Composite;
19 21
import org.eclipse.swt.widgets.Control;
20 22
import org.eclipse.swt.widgets.Display;
......
25 27
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
26 28
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
27 29
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
30
import eu.etaxonomy.taxeditor.model.MessagingUtils;
31
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
28 32
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
29 33
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
30 34
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
......
39 43
 *
40 44
 */
41 45
public abstract class AbstractCdmDataViewerE4 extends Viewer implements IConversationEnabled{
46
	 @Inject
47
	 private Logger logger;
42 48

  
43 49
	protected ManagedForm managedForm;
44 50

  
......
95 101
    }
96 102

  
97 103
    public void showEmptyPage(){
98
        destroySections();
104
    	destroySections();
99 105
        createEmptySection(rootElement);
100 106
    }
101 107

  
......
174 180
		rootElement = new RootElement(formFactory, body);
175 181

  
176 182
		for(Control control : body.getChildren()){
177
		    if (control != null && !control.isDisposed()){
178
		        control.dispose();
179
		    }
183
			try{
184
				if (control != null && !control.isDisposed()){
185
					control.dispose();
186
				}
187
			}catch(SWTException e){
188
				if (PreferencesUtil.isShowUpWidgetIsDisposedMessages() && e.getMessage().equals("Widget is disposed")){
189
                    MessagingUtils.errorDialog("Widget is disposed",
190
                            null,
191
                            MessagingUtils.WIDGET_IS_DISPOSED_MESSAGE,
192
                            null,
193
                            e,
194
                            true);
195

  
196
                }
197
			}
180 198
			control = null;
181 199
		}
182 200
	}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPartE4.java
41 41
import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
42 42
import eu.etaxonomy.taxeditor.event.EventUtility;
43 43
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
44
import eu.etaxonomy.taxeditor.model.MessagingUtils;
44 45
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
46
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
45 47
import eu.etaxonomy.taxeditor.view.e4.details.DetailsViewerE4;
46 48
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
47 49
import eu.etaxonomy.taxeditor.workbench.part.ISelectionElementEditingPart;
......
60 62
     * If it is <code>true</code> then it is currently delaying a selection.
61 63
     */
62 64
    private boolean isInDelay;
65
    private boolean isEnabled;
63 66
    private static final Logger logger = Logger.getLogger(AbstractCdmEditorPartE4.class);
64 67

  
65 68
    /**
......
221 224
    protected void showEmptyPage() {
222 225
        if(viewer!=null && viewer.getControl()!=null && !viewer.getControl().isDisposed() ){
223 226
            viewer.setInput(null);
224
            if (!viewer.getControl().isDisposed()){
225
                viewer.getControl().setEnabled(false);
227
            try{
228
	            if (!viewer.getControl().isDisposed()){
229
	                viewer.getControl().setEnabled(false);
230
	            }
231
            }catch(SWTException e){
232
            	if (PreferencesUtil.isShowUpWidgetIsDisposedMessages() && e.getMessage().equals("Widget is disposed")){
233
                    MessagingUtils.errorDialog("Widget is disposed",
234
                            null,
235
                            MessagingUtils.WIDGET_IS_DISPOSED_MESSAGE,
236
                            null,
237
                            e,
238
                            true);
239

  
240
                }
226 241
            }
242
            
227 243
        }
228 244
        selectionProvidingPart = null;
229 245
        if(thisPart!=null){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsPartE4.java
14 14

  
15 15
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
16 16
import org.eclipse.e4.core.contexts.IEclipseContext;
17
import org.eclipse.e4.core.services.log.Logger;
17 18
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
18 19
import org.eclipse.jface.viewers.IStructuredSelection;
20
import org.eclipse.swt.SWTException;
19 21
import org.eclipse.swt.widgets.Composite;
20 22

  
21 23
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
......
25 27
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
26 28
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
27 29
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
30
import eu.etaxonomy.taxeditor.model.MessagingUtils;
31
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
28 32
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmEditorPartE4;
29 33
import eu.etaxonomy.taxeditor.view.e4.supplementaldata.SupplementalDataPartE4;
30 34
import eu.etaxonomy.taxeditor.workbench.part.ISelectionElementEditingPart;
......
35 39
 *
36 40
 */
37 41
public class DetailsPartE4 extends AbstractCdmEditorPartE4 implements IPartContentHasSupplementalData {
38

  
39
    @Inject
42
	@Inject
43
	private Logger logger;
44
    
45
	@Inject
40 46
    public DetailsPartE4() {
41 47
    }
42 48

  
......
108 114
    protected void showEmptyPage() {
109 115
        super.showEmptyPage();
110 116
        if(viewer!=null && viewer.getControl()!=null && !viewer.getControl().isDisposed() ){
111
            ((DetailsViewerE4)viewer).destroySections();
117
        	try{
118
        		((DetailsViewerE4)viewer).destroySections();
119
        	}catch(SWTException e){
120
        		if (PreferencesUtil.isShowUpWidgetIsDisposedMessages() && e.getMessage().equals("Widget is disposed")){
121
                    MessagingUtils.errorDialog("Widget is disposed",
122
                            null,
123
                            MessagingUtils.WIDGET_IS_DISPOSED_MESSAGE,
124
                            null,
125
                            e,
126
                            true);
127

  
128
                }
129
        	}
112 130
        }
113 131
    }
114 132

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java
139 139
        }else{
140 140
            detailsEnabled = true;
141 141
        }
142

  
143 142
        setInput(input);
144
        detailsEnabled = true;
143
        
145 144
    }
146 145
    // START HACK TO MAKE THE DERIVED UNIT FACADE WORK
147 146
    // since we are getting implementations of DerivedUnitBase from the bulk
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/supplementaldata/SupplementalDataPartE4.java
16 16

  
17 17
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
18 18
import org.eclipse.e4.core.contexts.IEclipseContext;
19
import org.eclipse.e4.core.services.log.Logger;
19 20
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
20 21
import org.eclipse.jface.viewers.IStructuredSelection;
21 22
import org.eclipse.jface.viewers.StructuredSelection;
22 23
import org.eclipse.jface.viewers.TreeNode;
24
import org.eclipse.swt.SWTException;
23 25
import org.eclipse.swt.widgets.Composite;
24 26

  
25 27
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
......
32 34
import eu.etaxonomy.taxeditor.l10n.Messages;
33 35
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
34 36
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
37
import eu.etaxonomy.taxeditor.model.MessagingUtils;
38
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
35 39
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmEditorPartE4;
36 40

  
37 41

  
......
42 46
 *
43 47
 */
44 48
public class SupplementalDataPartE4 extends AbstractCdmEditorPartE4 {
45

  
49
	@Inject
50
	private Logger logger;
51
	
46 52
	@Inject
47 53
    public SupplementalDataPartE4() {
48 54
    }
......
125 131
    protected void showEmptyPage() {
126 132
        super.showEmptyPage();
127 133
        if(viewer!=null && viewer.getControl()!=null && !viewer.getControl().isDisposed()){
128
            ((SupplementalDataViewerE4)viewer).destroySections();
134
        	try{
135
        		((SupplementalDataViewerE4)viewer).destroySections();
136
        	}catch (SWTException e){
137
        		if (PreferencesUtil.isShowUpWidgetIsDisposedMessages() && e.getMessage().equals("Widget is disposed")){
138
                    MessagingUtils.errorDialog("Widget is disposed",
139
                            null,
140
                            MessagingUtils.WIDGET_IS_DISPOSED_MESSAGE,
141
                            null,
142
                            e,
143
                            true);
144

  
145
                }
146
        	}
129 147
        }
130 148
    }
131 149

  

Also available in: Unified diff