<extension point="org.eclipse.ui.activities">
<activity description="Turn off My View"
id="com.myapp.myactivity" name="MyViewActivity">
</activity>
<activityPatternBinding activityId="com.myapp.myactivity"
pattern="com\.myapp\.mypluginid/com\.myapp\.myviewid">
</activityPatternBinding>
</extension>
This activity is by default disabled, so it hides the view by default. Now if you want to show the view programatically, you can do so by enabling this activity as below :
IWorkbenchActivitySupport workbenchActivitySupport =
PlatformUI.getWorkbench().getActivitySupport();
IActivityManager activityManager =
workbenchActivitySupport.getActivityManager();
Set<String> enabledActivityIds =
new HashSet<String>( activityManager.getEnabledActivityIds() );
enabledActivityIds.add( "MyViewActivity" ) );
.
So far so good. if you want to hide everything except a particular UI component, you can do so by specifying negative lookbehind ("?<!") regular expression in your activity pattern.
Lets say you want to hide all the ui components in your plugin execpt for 2 views in your plugin :
Plugin ID : com.myapp.myappid
View1 ID : com.myapp.myviewid1
View2 ID : com.myapp.myviewid2
Here is the snippet to Hide everything in plugin com.myapp.myappid except for view1 (com.myapp.myviewid1) & view2 (com.myapp.myviewid2).
Note that you have to use "?<!" instead of "?<!" as in xthml '<' character is not allowed.
<extension point="org.eclipse.ui.activities">
<activity description="Turn off My View"
id="com.myapp.myactivity" name="MyViewActivity">
</activity>
<activityPatternBinding activityId="com.myapp.myactivity"
pattern="com\.myapp\.mypluginid/.*(?<!myviewid1|myviewid2)">
</activityPatternBinding>
</extension>