Add code to read my extension point and update editor menu [message #460889] |
Mon, 01 January 2007 17:33 |
Eclipse User |
|
|
|
Originally posted by: pascal.wassong.free.fr
Hello,
using 3.3M4 with Java 1.5, I created my own extension in my RCP application.
I created my editor using org.eclipse.ui.editors and org.eclipse.ui.editorActions.
I also have my own new extension point, which should add menu entries for my editor, so other plugin will be able to contribute. I have the code to read the extension point entries, but I don't know where to branch that code.
I tried in the createPartControl function of my EditorPart, but then I get multiple menu entries each time I open several editors.
What is the correct place to add my code ?
Happy New Year,
Pascal Wassong
|
|
|
|
Re: Add code to read my extension point and update editor menu [message #461013 is a reply to message #460987] |
Wed, 03 January 2007 15:52 |
Eclipse User |
|
|
|
Originally posted by: pascal.wassong.free.fr
I want to update the menu from the main toolbar.
By the way, I found a workaround but I am not satisfied with it. In the function createPartControl of my EditorPart, I cound the number of editor of my type, and if this number is 1, I update the menu with my info. There must be a better than counting.
Below is my current code:
int nb = 0;
IEditorReference[] editors = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage().getEditorReferences();
for (IEditorReference editor : editors) {
if (editor.getId().equals(GameEditor.ID)) {
nb++;
}
}
if (nb == 1) {
IMenuManager menuBar = getEditorSite().getActionBars().getMenuManager();
IMenuManager menu = menuBar.findMenuUsingPath("game_menu/conditions_menu");
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extensionPoint = registry.getExtensionPoint("fr.wassong.iNatch.conditions");
IExtension[] extensions = extensionPoint.getExtensions();
for (IExtension extension : extensions) {
IConfigurationElement[] elements = extension.getConfigurationElements();
for (IConfigurationElement element : elements) {
menu.add(new ConditionAction(
element.getAttribute("id"),
element.getAttribute("name"),
element.getAttribute("class")));
}
}
}
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03950 seconds