Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 279102 - [ActivityMgmt] CommandContributionItems from ShowViewMenu are not filtered properly by WorkbenchActivityHelper
Summary: [ActivityMgmt] CommandContributionItems from ShowViewMenu are not filtered pr...
Status: CLOSED DUPLICATE of bug 261622
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4.2   Edit
Hardware: PC Windows 2000
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact: Paul Webster CLA
URL: http://www.eclipse.org/newsportal/art...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-04 09:57 EDT by Albert Choi CLA
Modified: 2009-09-09 14:39 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Albert Choi CLA 2009-06-04 09:57:28 EDT
I have a plugin (say pluginB) which
contributes a viewShortcut and a perspectiveShortcut to a custom perspective,
which exists in pluginA:

<extension point="org.eclipse.ui.perspectiveExtensions">
    <perspectiveExtension targetID="pluginA.myPerspective">
        <viewShortcut id="pluginB.myView">
        </viewShortcut>
    </perspectiveExtension>
    <perspectiveExtension targetID="pluginA.myPerspective">
        <perspectiveShortcut id="pluginB.myOtherPerspective">
        </perspectiveShortcut>
    </perspectiveExtension>
</extension>

I also have a extension for org.eclipse.ui.activities.  pluginA is mapped to one
activity, and pluginB and mapped to another activity. E.g.

<extension point="org.eclipse.ui.activities">
    <activity id="activityA" name="Activity A">
    </activity>
    <activity id="activityB" name="Activity B">
    </activity>
    <activityPatternBinding activityId="activityA" pattern="pluginA/.*">
    </activityPatternBinding>
    <activityPatternBinding activityId="activityB" pattern="pluginB/.*">
    </activityPatternBinding>
</extension>

If I have pluginA.myPerspective open, I see pluginB.myOtherPerspective in the
Open Perspective menu, and pluginB.myView in the Show View menu, as expected.
When I go to disable activityB in the Capabilities preference page,
pluginB.myOtherPerspective disappears from the Open Perspective menu (good), but
pluginB.myView remains in the Show View menu (bad).

I was able to trace the issue to the internal class
org.eclipse.ui.internal.ShowViewMenu.  In particular, it executes the following
when it populates the menu:

for (Iterator i = actions.iterator(); i.hasNext();) {
    CommandContributionItem item = new CommandContributionItem(
           (CommandContributionItemParameter) i.next());
    if (WorkbenchActivityHelper.filterItem(item)) {
        item.dispose();
        continue;
    }
    innerMgr.add(item);
}

This is the right idea, but WorkbenchActivityHelper has the following filterItem
implementation:

public static final boolean filterItem(Object object) {
    if (object instanceof IPluginContribution) {
        ...snip...
    }
    return false;
}

Trouble is, CommandContributionItem is not derived from IPluginContribution.
Therefore, the items are never filtered out.

Original thread: http://www.eclipse.org/newsportal/article.php?id=81490&group=eclipse.platform#81490
Comment 1 Paul Webster CLA 2009-06-04 10:00:24 EDT
Are you on 3.4.2?  Then this might have already been fixed in 3.5.  bug 261622

PW
Comment 2 Albert Choi CLA 2009-06-04 10:02:34 EDT
(In reply to comment #1)
> Are you on 3.4.2?  Then this might have already been fixed in 3.5.  bug 261622
> 
> PW
> 

Yes, I am using 3.4.2
Comment 3 Paul Webster CLA 2009-09-09 14:39:31 EDT

*** This bug has been marked as a duplicate of bug 261622 ***