Bug 101256 - [Palette] Try to bring up popup menu when palette is empty gives exception
Summary: [Palette] Try to bring up popup menu when palette is empty gives exception
Status: NEW
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy GEF (MVC) (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: gef-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-22 10:35 EDT by Richard Kulp CLA
Modified: 2013-10-17 09:49 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Kulp CLA 2005-06-22 10:35:04 EDT
I had an empty palette and tried to bring up the popup menu. Got the following
exception because it tried to get the first selected editpart, but since there
were none it failed:

ENTRY org.eclipse.ui 4 0 2005-06-22 10:27:01.722
!MESSAGE Index: 0, Size: 0
!STACK 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.RangeCheck(ArrayList.java:507)
	at java.util.ArrayList.get(ArrayList.java:324)
	at java.util.Collections$UnmodifiableList.get(Collections.java:1139)
	at
org.eclipse.gef.ui.palette.PaletteContextMenuProvider.buildContextMenu(PaletteContextMenuProvider.java:54)
	at org.eclipse.gef.ContextMenuProvider.menuAboutToShow(ContextMenuProvider.java:60)
	at org.eclipse.jface.action.MenuManager.fireAboutToShow(MenuManager.java:285)
	at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:372)
	at org.eclipse.jface.action.MenuManager.access$0(MenuManager.java:369)
	at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:386)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:116)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:844)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:868)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:849)
	at org.eclipse.swt.widgets.Control.WM_INITMENUPOPUP(Control.java:3336)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3063)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1577)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:3682)
	at org.eclipse.swt.internal.win32.OS.TrackPopupMenu(Native Method)
	at org.eclipse.swt.widgets.Menu._setVisible(Menu.java:225)
	at org.eclipse.swt.widgets.Display.runPopups(Display.java:3084)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2685)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1716)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1680)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:365)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103)
	at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
	at org.eclipse.core.launcher.Main.run(Main.java:973)
	at org.eclipse.core.launcher.Main.main(Main.java:948)

!ENTRY org.eclipse.ui 4 4 2005-06-22 10:27:05.698
!MESSAGE Unhandled event loop exception
Comment 1 Randy Hudson CLA 2005-06-22 12:14:33 EDT
Ok, so don't set a context menu on an empty viewer?!?
Comment 2 Richard Kulp CLA 2005-06-22 13:05:23 EDT
No, it is just trying to use the selected editpart to determine if it is a
drawer so that it can add "pinned" to the menu. I would just first check if
there are none selected then just skip that part but continue with the the rest
of the menu.
Comment 3 Randy Hudson CLA 2005-06-22 13:28:31 EDT
Are you not calling EditPartViewer#setContextMenu(MenuManager)?
Comment 4 Richard Kulp CLA 2005-06-22 13:47:59 EDT
No I'm not, but it's not needed for me to do that. That is taken care of by the
gef.PaletteViewerProvider. 

That's not the problem. The problem was that I had an empty palette when I tried
to bring up the menu. The
org.eclipse.gef.ui.palette.PaletteContextMenuProvider.buildContextMenu(PaletteContextMenuProvider.java:54)
method did not handle this case. It assumed that there is always at least one
selected editpart in the palette. With an empty palette there can't be any
selected. 
Comment 5 Anthony Hunter CLA 2009-01-30 10:40:43 EST
Not sure if a palette with nothing in it is a valid use case, but we may as well fix if a simple one is at hand.
Comment 6 Alexander Nyßen CLA 2013-10-17 09:49:55 EDT
Assigning back to gef-inbox (and state to new), as specified assignee is no current GEF committer.