views:

1164

answers:

2

I have an eclipse rcp and want to hide the security and help prerence pages. How can I do that?

+1  A: 

According to this entry, you could use the "workbench activities" mechanism, and:

  • define separate activities corresponding to the different access levels
  • define your actions in regular action sets, grouped according to access level
  • associate each activity with the appropriate action sets via activityPatternBinding elements
  • set the enabled activity ids after authentication, early in the workbench lifecycle, e.g. from your WorkbenchAdvisor's preStartup() method.

(Note, the above was for a filtering based on user's permissions, but it could be generalize to other criteria.)


Regarding the preference pages for the storage and help, you should bind the id of those pages with an activity you know you can disable:

<activityPatternBinding
  activityId="org.eclipse.javaDevelopment"
  pattern="org\.eclipse\.help\..*/.*">
</activityPatternBinding>

would disable all menu/preferences/views related to help.

If you use org.eclipse.help.ui.PrefPageHelp\..*, it would only bind prefPageHelp and prefPageHelpContent.

If you add another activity binding extension with org.eclipse.equinox.security.ui.sec_storage_preferences_context, that would also take care of the Secure Storage preference page.

VonC
I managed to hide my own views and prerference pages, but the preference pages for the storage and help remained :(
Bosso
+2  A: 

I was looking for the same thing and found the solution in this link:

http://sourceforge.net/apps/trac/fable/wiki/Preferences

Cheers. Stefan


Disable help preferences

Put the following code into your subclass of org.eclipse.ui.application.WorkbenchAdvisor, and it removes the "Help" group from RCP preference dialog:

public void postStartup() {
    PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager( );
    pm.remove( "org.eclipse.help.ui.browsersPreferencePage" );
}

"org.eclipse.help.ui.browsersPreferencePage" is the ID for the preferences extension point.
Add Perspective preferences ¶

Remark : to find plugin id preferences, select Window-->show view--> PDE Runtime--> Plugin Registry ..... and try to find what you are looking for .....
For example, for "Workbench preferences", have a look in fable.eclipse.ui.ide and extension org.eclipse.ui.preferencePages: id="org.eclipse.ui.preferencePages.Workbench"

If you want to add only perspective (for example) preferences, add a preference extension in MANIFEST.XML :

id : org.eclipse.ui.preferencePages.Perspectives
name:perspective(fable)
class:org.eclipse.ui.internal.ide.dialogs.IDEPerspectivesPreferencePage

//Add : org.eclipse.ui.ide in your Dependencies

In ApplicationWorkBenchAdvisor :

public void postStartup() {
    PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager( );

    pm.remove( ""org.eclipse.ui.preferencePages.Workbench"browsersPreferencePage" );
}

public String getInitialWindowPerspectiveId() {
    IPreferenceStore pref = Activator.getDefault().getPreferenceStore();
    String ret = pref.getDefaultString(IWorkbenchPreferenceConstants.DEFAULT_PERSPECTIVE_ID);
    ret=(ret==null || ret.equals(""))?"yourDefaultPerspectiveID":ret;
    return ret;
}//
Stefan
That's actually what I was lloking for. Thank you.
Bosso
Good catch. +1. I imported the wiki page here. That way, if the sourceforge project goes down, the information remain available here.
VonC