Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Add code to read my extension point and update editor menu
Add code to read my extension point and update editor menu [message #460889] Mon, 01 January 2007 17:33 Go to next message
Eclipse UserFriend
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 #460987 is a reply to message #460889] Wed, 03 January 2007 11:29 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Pascal Wassong wrote:

>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 ?
>
>
Editor context menu or menus from the main tool bar?

Dani

>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 Go to previous messageGo to next message
Eclipse UserFriend
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"))); 
	            }
	        }
 	}
Re: Add code to read my extension point and update editor menu [message #461015 is a reply to message #461013] Wed, 03 January 2007 16:44 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Pascal Wassong wrote:

>I want to update the menu from the main toolbar.
>
>
Take a look at EditorActionBarContributor and its subclasses.

Dani

>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"))); 
>	            }
>	        }
> 	}
>

>
>
Re: Add code to read my extension point and update editor menu [message #461043 is a reply to message #461015] Thu, 04 January 2007 11:59 Go to previous message
Eclipse UserFriend
Originally posted by: pascal.wassong.free.fr

And the link with the editor is made through the "contributorClass" element in the "editor" extension definition for my editor.

Thank you for your help.
Pascal Wassong
Previous Topic:SWT_AWT bridge usage
Next Topic:Initializing Preferences
Goto Forum:
  


Current Time: Sat Apr 20 02:38:17 GMT 2024

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

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

Back to the top