Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 151239 - [IDE] NPE in ResourceInfoPage
Summary: [IDE] NPE in ResourceInfoPage
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M1   Edit
Assignee: Wassim Melhem CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-20 10:14 EDT by Martin Aeschlimann CLA
Modified: 2007-06-06 14:45 EDT (History)
2 users (show)

See Also:


Attachments
org.eclipse.ui.ide patch (3.50 KB, patch)
2006-07-28 02:01 EDT, Wassim Melhem CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2006-07-20 10:14:15 EDT
I20060718-0800

1. open the propertie pages on an JAR entry in the JRE container
2. error dialogs says that a page couldn't be shown

java.lang.NullPointerException
	at org.eclipse.ui.internal.ide.dialogs.ResourceInfoPage.createContents(ResourceInfoPage.java:234)
	at org.eclipse.jface.preference.PreferencePage.createControl(PreferencePage.java:233)
	at org.eclipse.jface.preference.PreferenceDialog.createPageControl(PreferenceDialog.java:1403)
	at org.eclipse.jface.preference.PreferenceDialog$12.run(PreferenceDialog.java:1162)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.runtime.Platform.run(Platform.java:843)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:149)
	at org.eclipse.jface.preference.PreferenceDialog.showPage(PreferenceDialog.java:1156)
	at org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.showPage(FilteredPreferenceDialog.java:439)
	at org.eclipse.jface.preference.PreferenceDialog$8.selectionChanged(PreferenceDialog.java:661)
	at org.eclipse.jface.viewers.StructuredViewer$3.run(StructuredViewer.java:839)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.runtime.Platform.run(Platform.java:843)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:149)
	at org.eclipse.jface.viewers.StructuredViewer.firePostSelectionChanged(StructuredViewer.java:837)
	at org.eclipse.jface.viewers.StructuredViewer.setSelection(StructuredViewer.java:1578)
	at org.eclipse.jface.preference.PreferenceDialog.selectSavedItem(PreferenceDialog.java:958)
	at org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.selectSavedItem(FilteredPreferenceDialog.java:482)
	at org.eclipse.jface.preference.PreferenceDialog$3.run(PreferenceDialog.java:345)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.jface.preference.PreferenceDialog.createContents(PreferenceDialog.java:341)
	at org.eclipse.jface.window.Window.create(Window.java:426)
	at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1124)
	at org.eclipse.ui.internal.dialogs.PropertyDialog.createDialogOn(PropertyDialog.java:82)
	at org.eclipse.ui.dialogs.PropertyDialogAction.createDialog(PropertyDialogAction.java:175)
	at org.eclipse.ui.dialogs.PropertyDialogAction.run(PropertyDialogAction.java:154)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:499)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:539)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:400)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3377)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2997)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
Comment 1 Wassim Melhem CLA 2006-07-25 23:26:43 EDT
Martin,
the Info property page is registered on objects that adapt to IResource.

JarPackageFragmentRoot adapts to IResource but returns null for external JARs.

We can guard against the NPE, but what do you expect the behaviour to be?  An empty Info property page or one with a label telling you information could not be retrieved?
Comment 2 Martin Aeschlimann CLA 2006-07-26 05:50:02 EDT
I guess a label on the page would be good enough.

But maybe the approach of contributing to everything that adapts to IResource is too coarse.
- from the beginning on, adaptation to IResource has been blured as it is used in many contexts (actions, decorators...
- now all our element have such a info page but can't show Java specific info
Comment 3 Markus Keller CLA 2006-07-26 06:09:27 EDT
I think the Info page should just show the resource info. Mixing in model info (such as more info from an IJavaElement) would bloat the page -- that information should be shown on a separate page if it's really useful.

How about renaming the page to 'Resource' to make clear that this is only resource-related info? After all, all properties pages show some 'info'...

Then it would also be OK to hide the page when the element does not adapt to IResource. This would be consistent with all other properties pages which also only show up when they have something to show.
Comment 4 Wassim Melhem CLA 2006-07-28 02:01:55 EDT
Created attachment 46932 [details]
org.eclipse.ui.ide patch

comment 3 is right on the money.

The Resource property page shows up only on objects that adapt to IResource and displays resource-specific attributes only.

So if null is returned as in the case here, we display a label indicating so.

I also agree that the title 'Info' is not distinctive enough and has now been changed to 'Resource'.
Comment 5 Wassim Melhem CLA 2006-07-28 02:02:40 EDT
Boris, please review/release patch.  Thanks.
Comment 6 Martin Aeschlimann CLA 2006-07-28 04:36:11 EDT
Or 'Resource Info'?
Comment 7 Wassim Melhem CLA 2006-07-28 10:16:05 EDT
I hate the word 'info' as it's too informal.

'Resource Information'?
Comment 8 Boris Bokowski CLA 2006-07-28 10:56:04 EDT
Patch looks good, released (with just "Resource") to HEAD >20060728.  I don't think we need Info or Information since all property pages contain information. 

I have filed bug 152147, requesting additional API in IAdapterManager which in this case would allow us to hide the resource property page altogether.
Comment 9 Wassim Melhem CLA 2006-07-28 10:57:34 EDT
Thanks Boris.  Setting milestone.
Comment 10 Boris Bokowski CLA 2006-07-28 11:46:42 EDT
Thanks Wassim!