public CommandContributionItem(IServiceLocator serviceLocator, String id, String commandId, Map parameters, ImageDescriptor icon, ImageDescriptor disabledIcon, ImageDescriptor hoverIcon, String label, String mnemonic, String tooltip, int style)
has been deprecated in Ganymede (Eclipse 3.4) in favor of the less unwieldy
public CommandContributionItem(CommandContributionItemParameter contributionParameters)
CommandContributionItemParameter has both a complete and a minimal constructor (for injecting just the required parameters), and its fields are public and non-final, so they can be set as needed.
The equivalent revised example class looks something like this:
public class MyCompoundContributionItem extends CompoundContributionItem {
private static int counter = 0;
@Override
protected IContributionItem[] getContributionItems() {
final CommandContributionItemParameter contributionParameter =
new CommandContributionItemParameter(
PlatformUI.getWorkbench().getActiveWorkbenchWindow(),
"my.project.myCommandContributionItem", "my.project.myCommand",
SWT.NONE);
contributionParameter.label = "Dynamic Menu Item " + counter++;
return new IContributionItem[] {
new CommandContributionItem(contributionParameter) };
}
}
2 comments:
Is it possible to create dynamic menus inside of dynamic menus? maybe programatically?
Hi m@,
I apologize for the delay in responding.
I do not have an answer offhand for this, but I would imagine it is definitely possible both programmatically and through extension points using menu contributions and visibleWhen expressions; although, without actually sitting down and trying, I cannot say for sure.
You might start by looking here if you have not already figured out how to do this:
http://www.ibm.com/developerworks/library/os-eclipse-3.3menu/index.html#N102EE
http://wiki.eclipse.org/index.php/Menu_Contributions#Declarative_menus_-_some_constraints
I am interested in hearing what solution you come up with!
Thanks.
-----Tim-----
Post a Comment