Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 312671 - SWT exceptions when removing facets with associated property page
Summary: SWT exceptions when removing facets with associated property page
Status: CLOSED INVALID
Alias: None
Product: WTP Common Tools
Classification: WebTools
Component: Faceted Project Framework (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: ---   Edit
Assignee: wst.common CLA
QA Contact: Konstantin Komissarchik CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-12 13:12 EDT by Eric Peters CLA
Modified: 2010-05-13 08:55 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Peters CLA 2010-05-12 13:12:01 EDT
JAX-RS facet provides a project property page that is available when the facet is installed. If I go to the property page followed by removing the facet I get a org.eclipse.swt.SWTException: Widget is disposed exception (see Bug311032). Method performOK() is accessing widgets on the property page which are disposed because the facet has been removed and the property page has subsequently been removed. The performOK() method should not be called when the property page no longer exists/removed due to facet uninstall.
Comment 1 Konstantin Komissarchik CLA 2010-05-12 20:48:31 EDT
Property pages are never disposed. I will guess that you are seeing this problem because JAX-RS property page is extending LibraryFacetPropertyPage (which is perfectly fine), but you aren't quite familiar with how that property page operates. There are a number of conditions that make it invalid to attempt to edit facet properties. The one you saw is one of these conditions. LibraryFacetPropertyPage handles this case by creating and destroying its contents on the fly. Either the user will see the expected contents or a message indicating the problem. The trick is that if you are overriding performOk method is that you need to check if you are still in a valid context. There are a number of ways to do this, but I would recommend calling getLibraryInstallDelegate() and making sure that the result is not null. 

The other thing to do is to make sure that you don't assume that your controls will only be created once during page existence. Do not hold the controls you allocate in page object's fields. Rather, register change listeners when you create controls and update data fields from those listeners.

Here is a fun scenario to try:

1. Start with a project with JAX-RS facet.
2. Open project properties page.
3. Visit JAX-RS page.
4. Visit facets page, uninstall JAX-RS facet, hit apply.
5. Visit JAX-RS page.
6. Visit facets page, install JAX-RS facet, hit apply.
7. Visit JAX-RS page.
8. Hit ok.
Comment 2 Eric Peters CLA 2010-05-13 08:55:56 EDT
Thanks a lot Konstantin, as you suggest the property page itself is not disposed (I never tried the scenario below but does prove your point quite well), but rather it's controls are disposed which is why we were getting the exception. As per your comments will use getLibraryInstallDelegate() to detect if we are in a valid context.