Speaking at Jfokus!

I’ve been invited to  present the following session at Jfokus:

Presentation: What to Expect from HotRockit

Oracle is converging the HotSpot and Oracle JRockit JVMs to produce a "best-of-breed JVM." Internally, the project is sometimes referred to as the HotRockit project. This presentation discusses what to expect from the converged JVM over the next two years and how this will benefit the Java community.

My session will take place in A2, at 14:00 on Wednesday the 15th of February. Looking forward to seeing you there!

Getting Rid of Unwanted Preference Pages in Eclipse

I recently wanted to get rid of a preference page I did not want to expose in Mission Control (an Eclipse RCP based application), and ended up with the following code in my ApplicationWorkbenchWindowAdvisor:

private void removeUnwantedPreferencesPages() {
    PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager();
    IPreferenceNode root = getRoot(pm);
    removePrefsPage(root, "org.eclipse.equinox.security.ui.category"); //$NON-NLS-1$
}


private IPreferenceNode getRoot(PreferenceManager pm) {
    try {
        Method m = PreferenceManager.class.getDeclaredMethod("getRoot", (Class[]) null); //$NON-NLS-1$
        m.setAccessible(true);
        return (IPreferenceNode) m.invoke(pm);
    } catch (Exception e) {
       LoggingToolkit.getLogger().log(Level.WARNING, "Could not get the root node for the preferences, and will not be able to prune unwanted prefs pages.", e); //$NON-NLS-1$
    }
    return null;
}

private void removePrefsPage(IPreferenceNode root, String id) {
    for (IPreferenceNode node : root.getSubNodes()) {
        logPrefsNode(node);
        if (node.getId().equals(id)) {
           root.remove(node);
           LoggingToolkit.getLogger().log(Level.INFO, String.format("Removed preference page %s (ID:%s)", node.getLabelText(), node.getId()));   //$NON-NLS-1$
        } else {
           removePrefsPage(node, id);
        }
    }
}

If you need to know the ID of the preference page you wish to remove, simply walk the tree and print all the nodes instead of removing selected ones.

Hope this helps someone. Blinkar