Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Editor programmatically opened with wrong EditorInput
Editor programmatically opened with wrong EditorInput [message #651970] Wed, 02 February 2011 10:19 Go to next message
Juergen Weber is currently offline Juergen WeberFriend
Messages: 65
Registered: July 2009
Member
Hi,

I have two editors A and B. From A I try to open a B editor with

getSite().getPage().openEditor(BInput, BEditor.ID);

this runs into BInput.equals(Object obj) to check if there is already a BEditor open for this input.

But, strangely obj is an AInput instead of a BInput, so my compare code runs into a ClassCastException.

Has anybody an idea what went wrong?

Thanks,
Juergen


java.lang.ClassCastException: AEditorInput cannot be cast to BEditorInput
at BEditorInput.equals(BEditorInput.java:34)
at org.eclipse.ui.internal.EditorHistoryItem.matches(EditorHist oryItem.java:114)
at org.eclipse.ui.internal.EditorHistory.remove(EditorHistory.j ava:117)
at org.eclipse.ui.internal.EditorHistory.add(EditorHistory.java :60)
at org.eclipse.ui.internal.EditorHistory.add(EditorHistory.java :50)
at org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:681)
at org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:638)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2860)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2768)
at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2760)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2711)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:70)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2707)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2691)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2674)
Re: Editor programmatically opened with wrong EditorInput [message #652037 is a reply to message #651970] Wed, 02 February 2011 13:34 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 02/02/2011 05:19 AM, Juergen Weber wrote:
> java.lang.ClassCastException: AEditorInput cannot be cast to BEditorInput
> at BEditorInput.equals(BEditorInput.java:34)

Your equals(Object) method should never throw a CCE, no matter what's
passed in there. Fix it so you don't blindly cast in that method.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Editor programmatically opened with wrong EditorInput [message #652055 is a reply to message #652037] Wed, 02 February 2011 14:33 Go to previous messageGo to next message
Juergen Weber is currently offline Juergen WeberFriend
Messages: 65
Registered: July 2009
Member
Certainly.

But the input for B is still in the BInput, not in the AInput.
Re: Editor programmatically opened with wrong EditorInput [message #652129 is a reply to message #652055] Wed, 02 February 2011 17:55 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 02/02/2011 09:33 AM, Juergen Weber wrote:
> Certainly.
>
> But the input for B is still in the BInput, not in the AInput.

Yes, but nothing in the stack trace speaks to that one way or another.
Fix the CCE and continue.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Editor programmatically opened with wrong EditorInput [message #652239 is a reply to message #652129] Thu, 03 February 2011 10:13 Go to previous message
Juergen Weber is currently offline Juergen WeberFriend
Messages: 65
Registered: July 2009
Member
Paul, you're right,

adding this helped:

if (!(obj instanceof BEditorInput))
{
return false;
}

Looks like the equals() method is called several times with different input.

Thanks for your help,
Juergen
Previous Topic:PLS HELP compression in java using eclipse
Next Topic:Integrated Help File Formatting
Goto Forum:
  


Current Time: Tue Apr 16 20:25:55 GMT 2024

Powered by FUDForum. Page generated in 1.78531 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top