Chin
Chin

Reputation: 20705

Eclipse RCP 4: activityPatternBinding doesn't work for menu

I'm trying to migrate an Eclipse RCP 3 application to Eclipse RCP 4. We currently use activityPatternBinding to hide UI elements contributed from other plugins, like so:

<extension point="org.eclipse.ui.activities">
    <activity id="my.app" name="MyApp"></activity>
    
    <activityPatternBinding
          activityId="my.app"
          isEqualityPattern="false"
          pattern="my\.app/.*">
    </activityPatternBinding>    
</extension>

However this doesn't seem to work for main menu items in Eclipse RCP 4. It works for sub-menu items though.

Searching around the net I found these references to this problem:

https://wiki.eclipse.org/Eclipse4/KnownIssues/4.1

Menu / Toolbar Issues

(4.2) Capabilities / Activities are not integrated into the Command system's processing. While this is unlikely to be completely done by the release of 4.1 we've defaulted everything to being 'on'. This may result in more contributions appearing that you see in 3.x but should guarantee that anything you need is available to you.

and a bug report:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=450284

activity not working for menu We have updated our application target platform from Eclipse 3.7 to Eclipse 4.4.1. I now noticed that some activities are not working anymore.

So is this still a known issue in the latest Eclipse RCP version (4.7.x)? Is there a way to work around this to hide the main menu items?

Upvotes: 0

Views: 591

Answers (1)

Subash J
Subash J

Reputation: 2048

Try this. I too had this kind of similar issue in our E4 application

To hide the Main menu items inject MTrimmedWindow and get the mainmenu from trimmed window and check for your main menu using menu id and if you want to enable use setToBeRendered(true) and setVisible(true) for the specific menu (or) if you want to hide use setToBeRendered(false) and setVisible(false). Below is the sample code how I have done

  1. Inject the MTrimmedWindow

@Inject private MTrimmedWindow mTrimmedWindow;

///////////////

  1. Pass your menu Id to the following method

enter image description here

Upvotes: 4

Related Questions