Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Making view visible throws IndexOutOfBoundsException
Making view visible throws IndexOutOfBoundsException [message #696365] Wed, 13 July 2011 19:39 Go to next message
Alex Molochnikov is currently offline Alex MolochnikovFriend
Messages: 25
Registered: July 2009
Junior Member
I have a view that is displayed automatically when the editor becomes
active. If the editor is opened following selection of an IResource,
everything works. However, if it is restored from the previous session,
and the editor is not active when restored (i.e. some other editor has
focus), then making this editor active again throws
IndexOutOfBoundsException in this code fragment:

IWorkbenchPage page = getSite().getWorkbenchWindow().getActivePage();
try {
if (page != null) {
MyView view = (MyView) page.findView(MyView.ID);
if (view == null) {
page.showView(MyView.ID, null, IWorkbenchPage.VIEW_CREATE); //
line 1068: throws IndexOutOfBoundsException
}
}
....

The exception is:

java.lang.IndexOutOfBoundsException: Index: -1, Size: 3
at java.util.ArrayList.add(ArrayList.java:367)
at org.eclipse.ui.internal.PartStack.replace(PartStack.java:912)
at
org.eclipse.ui.internal.PerspectiveHelper.addPart(PerspectiveHelper.java:400)
at org.eclipse.ui.internal.Perspective.showView(Perspective.java:2331)
at
org.eclipse.ui.internal.WorkbenchPage.busyShowView(WorkbenchPage.java:1071)
at org.eclipse.ui.internal.WorkbenchPage$20.run(WorkbenchPage.java:3822)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at
org.eclipse.ui.internal.WorkbenchPage.showView(WorkbenchPage.java:3819)
at
MyEditor.updateMyView(MyEditor.java:1068)
....

Any idea as to what to look for?

Thanks,

Alex Molochnikov
Fugro Seismic Imaging
Re: Making view visible throws IndexOutOfBoundsException [message #698000 is a reply to message #696365] Mon, 18 July 2011 15:19 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You might have to put your view creation in a job or display.asyncExec(*) to allow your editor part creation to finish before the showView(*) is called.

If that doesn't help, please open a bug at https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform&component=UI

PW


Previous Topic:[solved] popupMenus on IMarker
Next Topic:How to change the caption of a button in the eclipse main toolbar
Goto Forum:
  


Current Time: Tue Jul 25 17:04:24 GMT 2017

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

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