Howto hide a preference page in an eclipse RCP
Asked Answered
F

2

16

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

Ferree answered 22/9, 2009 at 15:26 Comment(4)
You mean you are the developer of the RCP software?Breezy
I am the devleoper, but the preference pages are from other plugins, like the help plugins.Ferree
Just added the preference page ids needed to hide the extra preference page (help and storage)M
Note: the activityPatternBinding in my answer was invisible due to an incorrect formatting of the xml code. I take it from the tick that you manage to hide your extra preference page I suppose?M
P
18

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;
}//
Penitential answered 23/11, 2009 at 22:47 Comment(3)
That's actually what I was lloking for. Thank you.Ferree
Good catch. +1. I imported the wiki page here. That way, if the sourceforge project goes down, the information remain available here.M
Another good way to find the ids of preferences is to open the Plugin Registry... Then go go down to the plugin org.eclipse.ui...expand it... then expand Extension points, then expand org.eclipse.ui.preferencePages and this will have a list of all the preferences added to the Eclipse you are using for development.Privateer
M
8

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.

M answered 22/9, 2009 at 16:0 Comment(1)
I managed to hide my own views and prerference pages, but the preference pages for the storage and help remained :(Ferree

© 2022 - 2024 — McMap. All rights reserved.