Bug 2477 - [Editor Mgmt] [UI] Walback trying to open editor for plugin.xml file (1GF84I3)
Summary: [Editor Mgmt] [UI] Walback trying to open editor for plugin.xml file (1GF84I3)
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: All Windows NT
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Michael Van Meekeren CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate
Depends on:
Blocks:
 
Reported: 2001-10-10 22:37 EDT by Lynne Kues CLA
Modified: 2004-06-25 11:57 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 Lynne Kues CLA 2001-10-10 22:37:09 EDT
0. Create a Java Project.
1. Create New-->Other-->Simple-->File for the project.  Named it plugin.xml.
2. Enter XML text as follows:
	<?xml version="1.0">
	<plugin name="Online Help Sample"
		id="com.oti.helpexample"
		version="1.0"
		provider-name="My Company" />
3. Save, select another tab in the PDE and I'm told I have an error (missing ? on line 1).
4.Go to PlugIn Development Perspective.  "Convert to PDE Project" the project.  
	Select the plugin.xml file - it displays an error.
5. Now go to another plugin project while still in the Plugin Perspective. Try to double click on a plugin.xml file.  
	I get an error (see second walkback below).  
6. Go back to Java Perspective. Fix my plugin.xml problem.  Go to another project and try to open the 
	plugin.xml file.  I still get an error (see first walkback below).
7. Exit Eclipse and come back in.  Now I can view another plugin.xml with the plugin editor.

Log: Tue Jun 12 16:07:41 EDT 2001
2 org.eclipse.ui 2 Problems occurred when invoking code from plug-in: org.eclipse.ui.
java.lang.ClassCastException: org/eclipse/ui/internal/EditorPane$1$ErrorEditorPart incompatible with org/eclipse/pde/internal/editor/PDEMultiPageEditor

Stack trace:
   java/lang/Throwable.<init>()V
   java/lang/Throwable.<init>(Ljava/lang/String;)V
   java/lang/ClassCastException.<init>(Ljava/lang/String;)V
   org/eclipse/pde/internal/editor/PDEEditorContributor.setActiveEditor(Lorg/eclipse/ui/IEditorPart;)V
   org/eclipse/ui/internal/EditorActionBars.partChanged(Lorg/eclipse/ui/IWorkbenchPart;)V
   org/eclipse/ui/internal/WorkbenchPage$1.run()V
   org/eclipse/core/internal/runtime/InternalPlatform.run(Lorg/eclipse/core/runtime/ISafeRunnable;)V
   org/eclipse/core/runtime/Platform.run(Lorg/eclipse/core/runtime/ISafeRunnable;)V
   org/eclipse/ui/internal/WorkbenchPage.activatePart(Lorg/eclipse/ui/IWorkbenchPart;Z)V
   org/eclipse/ui/internal/WorkbenchPage.setActivePart(Lorg/eclipse/ui/IWorkbenchPart;)V
   org/eclipse/ui/internal/WorkbenchPage.activate(Lorg/eclipse/ui/IWorkbenchPart;)V
   org/eclipse/ui/internal/WorkbenchPage.openEditor(Lorg/eclipse/core/resources/IFile;Z)Lorg/eclipse/ui/IEditorPart;
   org/eclipse/ui/internal/WorkbenchPage.openEditor(Lorg/eclipse/core/resources/IFile;)Lorg/eclipse/ui/IEditorPart;
   org/eclipse/jdt/internal/ui/javaeditor/EditorUtility.openInEditor(Lorg/eclipse/core/resources/IFile;)Lorg/eclipse/ui/IEditorPart;
   org/eclipse/jdt/internal/ui/javaeditor/EditorUtility.openInEditor(Ljava/lang/Object;Z)Lorg/eclipse/ui/IEditorPart;
   org/eclipse/jdt/internal/ui/javaeditor/EditorUtility.openInEditor(Ljava/lang/Object;)Lorg/eclipse/ui/IEditorPart;
   org/eclipse/jdt/internal/ui/packageview/OpenResourceAction.run()V
   org/eclipse/jdt/internal/ui/packageview/PackageExplorerPart.handleDoubleClick(Lorg/eclipse/jface/viewers/DoubleClickEvent;)V
   org/eclipse/jdt/internal/ui/packageview/PackageExplorerPart.access$1(Lorg/eclipse/jdt/internal/ui/packageview/PackageExplorerPart;Lorg/eclipse/jface/viewers/DoubleClickEvent;)V
   org/eclipse/jdt/internal/ui/packageview/PackageExplorerPart$3.doubleClick(Lorg/eclipse/jface/viewers/DoubleClickEvent;)V
   org/eclipse/jface/viewers/StructuredViewer.fireDoubleClick(Lorg/eclipse/jface/viewers/DoubleClickEvent;)V
   org/eclipse/jface/viewers/StructuredViewer.handleDoubleSelect(Lorg/eclipse/swt/events/SelectionEvent;)V
   org/eclipse/jface/viewers/AbstractTreeViewer$1.widgetDefaultSelected(Lorg/eclipse/swt/events/SelectionEvent;)V
   org/eclipse/swt/widgets/TypedListener.handleEvent(Lorg/eclipse/swt/widgets/Event;)V
   org/eclipse/swt/widgets/EventTable.sendEvent(Lorg/eclipse/swt/widgets/Event;)V
   org/eclipse/swt/widgets/Widget.notifyListeners(ILorg/eclipse/swt/widgets/Event;)V
   org/eclipse/swt/widgets/Display.runDeferredEvents()Z
   org/eclipse/swt/widgets/Display.readAndDispatch()Z
   org/eclipse/ui/internal/Workbench.runEventLoop()V
   org/eclipse/ui/internal/Workbench.run(Ljava/lang/Object;)Ljava/lang/Object;
   org/eclipse/core/internal/boot/InternalBootLoader.run(Ljava/lang/String;Ljava/net/URL;Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/Object;
   org/eclipse/core/boot/BootLoader.run(Ljava/lang/String;Ljava/net/URL;Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/Object;
   java/lang/reflect/Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
   org/eclipse/core/launcher/Main.basicRun([Ljava/lang/String;)Ljava/lang/Object;
   org/eclipse/core/launcher/Main.run([Ljava/lang/String;)Ljava/lang/Object;
   org/eclipse/core/launcher/Main.main([Ljava/lang/String;)V



NOTES:

DG (6/12/2001 4:16:39 PM)
	This looks like a workbench problem. PDE's editor contributor should only receive 
	its own editor in 'setActiveEditor'. Instead, workbench is passing me some 'ErrorEditorPage' and
	there is a class cast exception.

	I am not sure, but this should not happen (only editor instances of the type registered together
	with the contributor should be passed to the contributor using 'setActiveEditor' method). Moving
	to ITPUI for comment.

DS (6/12/01 6:22:20 PM)
	In EditorManager.openInternalEditor we should check to see if editor creation fails.
	We can probably query the PartPane.  If so, get rid of the editor completely and 
	show a dialog to the user ( if not in startup ).


KH (6/12/2001 8:14:59 PM)
	Why did the editor fail to open in the first place? 

DS (6/13/01 1:01:43 PM)
	If an exception occurs during part creation it is usually logged.  That log appears to
	be missing from this PR, so there is no way to know.  I have asked DG.

DS (6/13/01 1:08:41 PM)
	Cannot dupe the original scenario.

KH (6/13/2001 1:48:21 PM)
	Pls follow up with Dejan or Lynne.

DS (6/13/01 2:43:19 PM)
	Talked with Lynne.  She has adjusted the steps to recreate problem.
	The following walkback occurs when you open the second editor ..

Log: Wed Jun 13 14:41:45 EDT 2001
2 org.eclipse.ui 2 Problems occurred when invoking code from plug-in: org.eclipse.ui.
java.lang.NullPointerException
	at org.eclipse.pde.internal.PDEPlugin.findPlugin(PDEPlugin.java:113)
	at org.eclipse.pde.internal.PDEPlugin.findPlugin(PDEPlugin.java:125)
	at org.eclipse.pde.internal.PDEPlugin.findPlugin(PDEPlugin.java:121)
	at org.eclipse.pde.internal.editor.manifest.AlertSection.checkReferences(AlertSection.java:136)
	at org.eclipse.pde.internal.editor.manifest.AlertSection.createAlerts(AlertSection.java:165)
	at org.eclipse.pde.internal.editor.manifest.AlertSection.createClient(AlertSection.java:189)
	at org.eclipse.pde.internal.forms.FormSection.createControl(FormSection.java:88)
	at org.eclipse.pde.internal.editor.manifest.ManifestForm.createFormClient(ManifestForm.java:46)
	at org.eclipse.pde.internal.forms.Form.createControl(Form.java:115)
	at org.eclipse.pde.internal.forms.ScrollableForm.createControl(ScrollableForm.java:29)
	at org.eclipse.pde.internal.editor.PDEFormPage.createPartControl(PDEFormPage.java:65)
	at org.eclipse.pde.internal.editor.PDEFormPage.createControl(PDEFormPage.java:61)
	at org.eclipse.pde.internal.forms.CustomWorkbook.switchPages(CustomWorkbook.java:132)
	at org.eclipse.pde.internal.forms.CustomWorkbook.access$2(CustomWorkbook.java:122)
	at org.eclipse.pde.internal.forms.CustomWorkbook$4.run(CustomWorkbook.java:99)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:98)
	at org.eclipse.pde.internal.forms.CustomWorkbook.selectPage(CustomWorkbook.java:97)
	at org.eclipse.pde.internal.editor.PDEMultiPageEditor.showPage(PDEMultiPageEditor.java:381)
	at org.eclipse.pde.internal.editor.PDEMultiPageEditor.showPage(PDEMultiPageEditor.java:372)
	at org.eclipse.pde.internal.editor.PDEMultiPageEditor.createPartControl(PDEMultiPageEditor.java:143)
	at org.eclipse.ui.internal.PartPane$2.run(PartPane.java:53)
	at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:758)
	at org.eclipse.core.runtime.Platform.run(Platform.java:393)
	at org.eclipse.ui.internal.PartPane.createChildControl(PartPane.java:51)
	at org.eclipse.ui.internal.PartPane.createControl(PartPane.java:94)
	at org.eclipse.ui.internal.EditorWorkbook.createPage(EditorWorkbook.java:183)
	at org.eclipse.ui.internal.EditorWorkbook.add(EditorWorkbook.java:75)
	at org.eclipse.ui.internal.EditorArea.addEditor(EditorArea.java:43)
	at org.eclipse.ui.internal.EditorPresentation.openEditor(EditorPresentation.java:292)
	at org.eclipse.ui.internal.EditorManager$2.run(EditorManager.java:388)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:98)
	at org.eclipse.ui.internal.EditorManager.openInternalEditor(EditorManager.java:374)
	at org.eclipse.ui.internal.EditorManager.openInternalEditor(EditorManager.java:426)
	at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:299)
	at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:272)
	at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:258)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:941)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:869)
	at org.eclipse.ui.actions.OpenFileAction.openFile(OpenFileAction.java:95)
	at org.eclipse.ui.actions.OpenSystemEditorAction.run(OpenSystemEditorAction.java:91)
	at org.eclipse.ui.views.navigator.ResourceNavigator.handleDoubleClick(ResourceNavigator.java:450)
	at org.eclipse.ui.views.navigator.ResourceNavigator$4.doubleClick(ResourceNavigator.java:185)
	at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:269)
	at org.eclipse.jface.viewers.StructuredViewer.handleDoubleSelect(StructuredViewer.java:409)
	at org.eclipse.jface.viewers.AbstractTreeViewer$1.widgetDefaultSelected(AbstractTreeViewer.java:626)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java(Compiled Code))
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:622)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java(Compiled Code))
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java(Compiled Code))
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java(Compiled Code))
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:620)
	at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:815)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285)
	at java.lang.reflect.Method.invoke(Native Method)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:126)
	at org.eclipse.core.launcher.Main.run(Main.java:408)
	at org.eclipse.core.launcher.Main.main(Main.java:281)

	Offending code in PDEPlugin ..

	private IPlugin findPlugin(IPluginModel[] models, String id, String version) {
		for (int i = 0; i < models.length; i++) {
			IPluginModel model = models[i];
			if (model.isEnabled() == false)
				continue;
			IPlugin plugin = model.getPlugin();
			if (plugin.getId().equals(id)) {														<----- exception occurs here.
				if (version == null || plugin.getVersion().equals(version))
					return plugin;
			}
		}
		return null;
	}

	There are two problems here.

	1. PDEEditor fails to open correctly.
	2. Workbench fails to deal with it correctly.

	I have logged a PR in ITPPDE for the first one,
		1GF9VS5: ITPPDE:ALL - NPE in Plugin Editor
	and will address the second in this PR.

DS (6/13/01 5:00:44 PM)
	In this scenario we replace the editor part with an error part and then call 
	setActiveEditor(errorPart) on the plugin editor action bar contributor.  A class cast 
	exception occurs when the contributor tries to cast this to a plugin editor.  

	In general, I think a contributor can assume that the argument for setActiveEditor is
	the editor type it is paired with in the registry.  Therefore, the workbench behavior is incorrect.
	To fix, we should deref the editor action bar contributor in the same
	way as we deref the editor part itself.  This will avoid the communication problem.

	Test fix in 
		>EditorActionBars :: org.eclipse.ui.internal 0.122 [ds pr#1GF84I3]
		>EditorPane :: org.eclipse.ui.internal 0.122 [ds pr#1GF84I3]
		>EditorPresentation :: org.eclipse.ui.internal 0.122 [ds pr#1GF84I3]
		>EditorWorkbook :: org.eclipse.ui.internal 0.122 [ds pr#1GF84I3]	
	Reviewed by EP.

KH (6/14/2001 2:02:32 PM)
	Defer
Comment 1 DJ Houghton CLA 2001-10-29 18:30:40 EST
PRODUCT VERSION:
122

Comment 2 Randy Giffen CLA 2002-05-27 21:28:06 EDT
Defer
Comment 3 Randy Giffen CLA 2002-08-08 11:46:53 EDT
Reopen for investigation
Comment 4 Michael Van Meekeren CLA 2004-06-25 11:57:19 EDT
this no longer occurs