Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 135739

Summary: [PropertiesDialog] Incorrect filter selection in Property Pages
Product: [Eclipse Project] Platform Reporter: Fred Rotbart <rotbartf>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 Keywords: helpwanted
Version: 3.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard: stalebug

Description Fred Rotbart CLA 2006-04-09 05:39:42 EDT
When the properties dialog is opened all the pages contributed by the extension point org.eclipse.ui.propertyPages are checked for their class and filter definitions.

The method RegistryPageContributor.isApplicableTo(Object) activates the filters (if any) on the selected object.
The problem is that before it checks if the object implements or adapts to IActionFilter (required for the filter), it first get the object adapter to IResource (adaptedObject). Then the check for IActionFilter is done on the adapter and not the object.

IRapidComponent gives the class file as the adapter to IResource, so we never get to out adapter to IActionFilter: RapidActionFilter.
	
Our contribution in plugin.xml is:
    <extension
          point="org.eclipse.ui.propertyPages">
       <page
             adaptable="true"
             class="com.esim.eclipse.rapid.internal.ui.wizard.NewClassPage"
             id="com.esim.eclipse.rapid.ui.internal.properies.ClassPage"
             name="%RapidPropertyPages.Class.name"
             objectClass="com.esim.eclipse.rapid.model.IRapidComponent">
          <filter
                name="isLoaded"
                value="true"/>
       </page>
    </extension>

(isLoaded attribute is defined in RapidActionFilter, which is the adapter to IActionFilter for IRapidComponent).

The correct code should FIRST ask for the adapter for IActionFilter from the object, and only if not found, ask it for the IResource adapter.
Something like:

        if (object instanceof IActionFilter) {
            filter = (IActionFilter) object;
        } else if (object instanceof IAdaptable) {
            filter = (IActionFilter) ((IAdaptable) object)
                    .getAdapter(IActionFilter.class);
        }

        if (filter == null) 
	Object adaptedObject = LegacyResourceSupport.getAdaptedResource(object);
	if(adaptedObject != null) {
      		 // and now again on the adapted object:
		object = adaptedObject;
        	if (object instanceof IActionFilter) {
            	filter = (IActionFilter) object;
       	} else if (object instanceof IAdaptable) {
            	filter = (IActionFilter) ((IAdaptable) object)
                    		.getAdapter(IActionFilter.class);
		}
      }

       // and only then, activate the filter
  if (filter != null) 
     return testCustom(object, filter);

Just to make clearer here is the stack trace for a breakpoint at the problematic code:
Thread [main] (Suspended (breakpoint at line 178 in RegistryPageContributor))
	RegistryPageContributor.isApplicableTo(Object) line: 178
	PropertyPageContributorManager.contribute(PropertyPageManager, IAdaptable) line: 140
	PropertyDialog.createDialogOn(Shell, String, IAdaptable) line: 56
	PropertyDialogAction.createDialog() line: 174
	PropertyDialogAction.run() line: 155
	PropertyDialogAction(Action).runWithEvent(Event) line: 492
	ActionContributionItem.handleWidgetSelection(Event, boolean) line: 530
	ActionContributionItem.access$2(ActionContributionItem, Event, boolean) line: 480
	ActionContributionItem$5.handleEvent(Event) line: 392
	EventTable.sendEvent(Event) line: 66
	MenuItem(Widget).sendEvent(Event) line: 925
	Display.runDeferredEvents() line: 3287
	Display.readAndDispatch() line: 2907
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 1899

- Fred
Comment 1 Eric Moffatt CLA 2006-04-10 15:03:47 EDT
Tod, this looks like a prop page contribution issue.
Comment 2 Eclipse Webmaster CLA 2019-09-06 16:14:04 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
Comment 3 Eclipse Genie CLA 2022-02-17 20:14:29 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.