Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 261622

Summary: [ActivityMgmt] View shortcut is displayed in the Show View's sub-menu if the activity was disabled
Product: [Eclipse Project] Platform Reporter: Hiroyuki <hiroyuki.inaba>
Component: UIAssignee: Paul Webster <pwebster>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: albert.choi, remy.suen, steffen.pingel
Version: 3.4.1   
Target Milestone: 3.5 M7   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Attachments:
Description Flags
screenshot.png none

Description Hiroyuki CLA 2009-01-20 07:08:23 EST
I used Eclipse 3.4.1 Build id: M20080911-1700
The activity was defined in the plug-in. 

<extension point="org.eclipse.ui.activities">
<category id="my.activity.ui.activities" 	name="Ant for test"  description="Ant for test"/>
<activity id="my.activity.ui.activity" name="Ant for test"  wescription="Ant for test"/>
<categoryActivityBinding  activityId="my.activity.ui.activity" categoryId="my.activity.ui.activities"/>
<activityPatternBinding activityId="my.activity.ui.activity" pattern="org\.eclipse\.ant\.ui/.*"/>
</extension>

View shortcut "Ant" is displayed in the Window > Show View's  sub-menu if the activity was disabled.
This case, "Ant" is not displayed in the Show View dialog.
Comment 1 Hiroyuki CLA 2009-01-20 07:13:06 EST
Created attachment 123068 [details]
screenshot.png
Comment 2 Hiroyuki CLA 2009-01-20 07:21:20 EST
I investigated. 

On org.eclipse.ui.workbench, org.eclipse.ui.activities.WorkbenchTriggerPointAdvisor,
Line 84: public Set allow(ITriggerPoint triggerPoint, IIdentifier identifier) {

Line 93: 	if (activity.getExpression() != null) {

activity.getExpression() always returns null. 

activity	org.eclipse.ui.internal.activities.Activity  (id=194)	
	activityListeners	null	
	activityPatternBindings	java.util.Collections$UnmodifiableSet<E>  (id=199)	
	activityPatternBindingsAsArray	org.eclipse.ui.activities.IActivityPatternBinding[1]  (id=205)	
	activityRequirementBindings	java.util.Collections$UnmodifiableSet<E>  (id=208)	
	activityRequirementBindingsAsArray	org.eclipse.ui.activities.IActivityRequirementBinding[0]  (id=209)	
	defaultEnabled	false	
	defined	true	
	description	"Ant for test" (id=212)	
	enabled	false	

>	expression	null	  

	hashCode	552537032 [0x20ef0bc8]	
	id	"my.activity.ui.activity" (id=191)	
	name	"Ant for test" (id=6644)	
	string	"[[],[[my.activity.ui.activity,false,org\\.eclipse\\.ant\\.ui/.*]],true,false,my.activity.ui.activity,Ant for test]" (id=198)	

allow( ) returned Collections.EMPTY_SET, and the sub-menu "Ant" were displayed. 
Comment 3 Remy Suen CLA 2009-01-21 10:20:33 EST
Pretty sure this isn't a UA problem...
Comment 4 Remy Suen CLA 2009-02-19 16:36:40 EST
On M20080911-1700, I can see the behaviour depicted by attachment 123068 [details]. On I20090217-2200, I see it both in the submenu and in the 'Show View' dialog.
Comment 5 Remy Suen CLA 2009-02-19 17:13:39 EST
(In reply to comment #4)
> On I20090217-2200, I see it both in the submenu and in the 'Show View' dialog.

I think it is failing here because the activity is enabled. There also seems to be another activity that Ant is contributing.

Paul, you can reproduce the problem with the following XML snippet instead that filters out the 'Outline' view.

<extension
    point="org.eclipse.ui.activities">
  <activity id="forbiddenViewActivityId"
      name="Forbidden"/> 
  <activityPatternBinding
      activityId="forbiddenViewActivityId"
      pattern="org.eclipse.ui.views/org.eclipse.ui.views.ContentOutline"/>
</extension>

Removing the null check for activity.getExpression() in line 93 of WorkbenchTriggerPointAdvisor as hinted at by Hiroyuki in comment 2 seems to work although I don't know if that's what's right since I'm not familiar with activities.
Comment 6 Paul Webster CLA 2009-04-27 14:20:19 EDT
This appears to be a bug I introduced switching to commands instead of ShowViewActions (which were IPluginContributions)

We don't filter CommandContributionItems the same way.

PW
Comment 7 Paul Webster CLA 2009-04-27 14:30:42 EDT
Released to HEAD >20090427
PW
Comment 8 Paul Webster CLA 2009-04-28 14:04:06 EDT
In I20090428-0100
PW
Comment 9 Paul Webster CLA 2009-09-09 14:39:31 EDT
*** Bug 279102 has been marked as a duplicate of this bug. ***