Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Adding multiple dynamic menus
Adding multiple dynamic menus [message #491619] Thu, 15 October 2009 09:09 Go to next message
Michael Matzen is currently offline Michael MatzenFriend
Messages: 13
Registered: July 2009
Junior Member
Hi all,

i'm trying to add multiple menus when starting eclipse, by creating
valid XML plug-ins with commands/commandHandler/menus/bindings, based on
some extension points.

Then i'm using the ExtensionRegistry.addContribution method to inject
the plug-in. For the contribution, i am using the contributor object
which contains my extension points and the 'CreateTemporaryUserToken'
method.

This works quite well, but only with a single plug-in. When i am trying
to add more contributions (where each of them has its own contributor),
the jface ContributionManager throws an IndexOutOfBoundsException when
executing this code:

public void insert(int index, IContributionItem item) {
if (index > contributions.size()) {
throw new IndexOutOfBoundsException(
"inserting " + item.getId() + "
at " + index); //$NON-NLS-1$ //$NON-NLS-2$
}
if (allowItem(item)) {
contributions.add(index, item);
itemAdded(item);
}
}


But i cant figure out why this exception is thrown ? Is it because i am
adding menu entries after eclipse has launched ? But why is there no
exception when creating a single plug-in ?

Regards,
Michael

Here's the complete exception stack-trace:

java.lang.IndexOutOfBoundsException: inserting
de.cau.cs.kieler.ksbase.SyncchartsDiagramEditor.Add_Predeces sor_State at 8
at
org.eclipse.jface.action.ContributionManager.insert(Contribu tionManager.java:312)
at
org.eclipse.ui.internal.menus.WorkbenchMenuService$5.run(Wor kbenchMenuService.java:599)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at
org.eclipse.ui.internal.menus.WorkbenchMenuService.processAd ditions(WorkbenchMenuService.java:609)
at
org.eclipse.ui.internal.menus.WorkbenchMenuService.addContri butionsToManager(WorkbenchMenuService.java:670)
at
org.eclipse.ui.internal.menus.WorkbenchMenuService.populateC ontributionManager(WorkbenchMenuService.java:656)
at
org.eclipse.ui.internal.menus.WorkbenchMenuService.addContri butionsToManager(WorkbenchMenuService.java:708)
at
org.eclipse.ui.internal.menus.WorkbenchMenuService.addContri butionFactory(WorkbenchMenuService.java:464)
at
org.eclipse.ui.internal.menus.WorkbenchMenuService.handleDyn amicAdditions(WorkbenchMenuService.java:908)
at
org.eclipse.ui.internal.menus.WorkbenchMenuService.handleMen uChanges(WorkbenchMenuService.java:974)
at
org.eclipse.ui.internal.menus.WorkbenchMenuService.handleReg istryChanges(WorkbenchMenuService.java:1021)
at
org.eclipse.ui.internal.menus.WorkbenchMenuService$2.run(Wor kbenchMenuService.java:262)
at
org.eclipse.ui.internal.UILockListener.doPendingWork(UILockL istener.java:155)
at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer. java:158)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3468)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3115)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 21)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:113)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:194)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:368)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Re: Adding multiple dynamic menus [message #495533 is a reply to message #491619] Thu, 05 November 2009 09:34 Go to previous message
Michael Matzen is currently offline Michael MatzenFriend
Messages: 13
Registered: July 2009
Junior Member
Hi all,

i have changed the way my plug-ins are added, i am now creating a jar
bundle and load it via BundleContext.installBundle("id", inputStream).

But that does not seem to solve the problem (i still got
indexOutOfBounds & Undefined context exceptions).

So what exactly is the difference in activating a plug-in by moving a
jar bundle in the eclipse/plugin folder and calling the
BundleContext.installBundle(jarfile) ?

Is it the bundle context ? (I'm using the context which is given to my
core plug-in to install the generated bundle)

Or the timing ? When calling BundleContext.installBundle eclipse is
already running or launching.

Regards,
Michael
Re: Adding multiple dynamic menus [message #603104 is a reply to message #491619] Thu, 05 November 2009 09:34 Go to previous message
Michael Matzen is currently offline Michael MatzenFriend
Messages: 13
Registered: July 2009
Junior Member
Hi all,

i have changed the way my plug-ins are added, i am now creating a jar
bundle and load it via BundleContext.installBundle("id", inputStream).

But that does not seem to solve the problem (i still got
indexOutOfBounds & Undefined context exceptions).

So what exactly is the difference in activating a plug-in by moving a
jar bundle in the eclipse/plugin folder and calling the
BundleContext.installBundle(jarfile) ?

Is it the bundle context ? (I'm using the context which is given to my
core plug-in to install the generated bundle)

Or the timing ? When calling BundleContext.installBundle eclipse is
already running or launching.

Regards,
Michael
Previous Topic:Hiding commands' UI elements
Next Topic:Does doc.zip no longer work in 3.5?
Goto Forum:
  


Current Time: Sat Aug 08 12:07:53 GMT 2020

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

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

Back to the top