21

I'm using Eclipse 4.2 with compatibility layer to reuse existing part for my RCP application.

I want to reuse New from File menu and Run menu in my RCP application, so for that I opens EMF editor for Eclipse and its look like this:

enter image description here

But for New menu its showing something like this: org.eclipse.e4.model.application....

My application is look-like this (it is just the Java Script debugger with some extra features):

enter image description here

So how I can reuse those menus in my RCP application?

Lii
  • 11,553
  • 8
  • 64
  • 88
Sumit Singh
  • 15,743
  • 6
  • 59
  • 89
  • 1
    I do see your "bumps" (edits) every time, but at this point, a (small) bounty would be more effective. Also edit your question (when setting up the bounty) with a bit more details on what you have tried, what doc you have looked. – VonC Nov 13 '12 at 08:40
  • 3
    I don't think I get your question right. What is it you exactly want to do? A) Contribute commands to the New resp. Run menu or B) use commands already available within the New menu? – col.panic Nov 19 '12 at 20:52
  • I know this may not be relevant to the question, but all my buttons on the main toolbar come after the Quick Access as well, just like in the image above. Is that a bug for the compatibility layer? – nbz Dec 07 '12 at 17:09
  • 1
    Can't understand your question absolutely. As @col.panic has mentioned , question can be about linking some commands to menu `File->New` or about linking the same command `Run` to `File->New`. In any case there is insufficient information about what have you tried, and your screenshots don't show anything helpful. – Andremoniy Jan 14 '13 at 07:52
  • Hi all, I think at the last line of my question I'm mentioning that i have to reuse. – Sumit Singh Jan 15 '13 at 04:49
  • 1
    @SumitSingh Could you please explain for stupid (as me): you want to reuse `New` from File menu and `Run` menu in your RCP application - ok, its briefly clear. But **from which application you want reuse those menus**?? – Andremoniy Jan 15 '13 at 14:32
  • @Andremoniy sorry sir but I don't why you are using "stupid" this word for your self, I don't think I'm insulting any body . Moreover for "from which application you want reuse those menus" --> Just give me one example with any application I'll do it same for mine. Thank's – Sumit Singh Jan 15 '13 at 14:57
  • 1
    @SumitSingh, could you provide current source of generated file `plugin.xml` for your RCP project, where you did attempts to create those menus? – Andremoniy Jan 15 '13 at 14:59
  • Did you define the New and Run in your own RCP or are you using the ones defined by Eclipse? – nbz Jan 17 '13 at 01:11

1 Answers1

3

I think I understand what you are saying. You opened the E4 Live Editor on your Eclipse Juno, to get the commands for New and Run menu items so that you can reuse it in your own code?

If I am correct, then in E4 you can no longer use the default commands provided by Eclipse. You need to define your own commands. See here for details.

If you know Eclipse 3.x you are probably searching for the predefined commands which you can re-use. The Eclipse 4 platform tries to be as lean as possible.

Eclipse 4 does not include standard commands anymore. You have to define all your commands.

So if you try to add these commands via the .e4xmi file, then you must define your own commands with its own handlers.

There is a way out if you still wish to use the commands given by Eclipse and that will have to be done via the plugin.xml file. Since you said you are using the compatibility layer, you probably still have a lot of legacy code, and it might be ok to add these menu items via the plugin.xml. Although, once you do a hard migration, I believe Eclipse is trying to reduce the use of extensions in plugin.xml and in that case you will have to define your own commands.

So if you want to add these commands then you must do it via the extensions in the plugin.xml.

To add the New menu item, go to your plugin.xml, in the Extensions tab, add org.eclipse.ui.menus. Create a menucontribution with a locationURI of menu:org.eclipse.ui.main.menu. Then you must add a menu and give it the label File.

This will add the menu File to your RCP. Then to this you must add the New command. In order to do this, you add a command to the File menu you just created. Once you add a command, in commandID you select Browse and look for org.eclipse.ui.file.newQuickMenu.

So your plugin.xml will have the following code.

<extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="menu:org.eclipse.ui.main.menu">
         <menu
               id="fileMenu"
               label="File">
            <command
                  commandId="org.eclipse.ui.file.newQuickMenu"
                  style="push">
            </command>....
nbz
  • 3,806
  • 3
  • 28
  • 56