Showing posts with label eclipse rcp. Show all posts
Showing posts with label eclipse rcp. Show all posts

Tuesday, January 10, 2017

Removing unwanted preference pages from eclipse


To remove unwanted preferences from your eclipse rcp app, we can do the following.


As part of your App MyRCPWorkbenchAdvisor#postStartup() method, you need to invoke the following code with the preference page id.


private void removeUnwantedPreferences()
{
PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager();
IPreferenceNode root = getRoot(pm);
if (root != null)
{
removePrefsPage(root"com.windows.preference.mypage.id"); 
}
}


//Identify preference node
private IPreferenceNode getRoot(PreferenceManager pm)
{
try
{
Method m = PreferenceManager.class.getDeclaredMethod("getRoot", (Class[]) null); 
m.setAccessible(true);
return (IPreferenceNode) m.invoke(pm);
}
catch (Exception e)
{
IdeLog.logWarning(TitaniumCorePlugin.getDefault(), e);
}
return null;
}


//remove preference id from the preference node
private void removePrefsPage(IPreferenceNode root, String id)
{
for (IPreferenceNode node : root.getSubNodes())
{
if (node.getId().equals(id))
{
root.remove(node);
}
else
{
removePrefsPage(node, id);
}
}

}



This seems to be work without any issues.

However, I could see other direct approach but that doesn't seem to work well in all scenarios.

PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager();
pm.remove("com.windows.preference.mypage.id");


Thursday, May 5, 2016

Programatically changing the eclipse perspective

try
{
   PlatformUI.getWorkbench().showPerspective("StudioPerspective", PlatformUI.getWorkbench().getActiveWorkbenchWindow());
}
catch (WorkbenchException e)
{
  e.printStackTrace();

}

Wednesday, July 16, 2014

Removing eclipse view title bar tab


public class Perspective implements IPerspectiveFactory {
  public void createInitialLayout(IPageLayout layout) {      
    String editorArea = layout.getEditorArea();
    layout.setEditorAreaVisible(false);

    layout.addStandaloneView(View.ID, false, IPageLayout.LEFT, 1.0f, editorArea);      
  }
}


A standalone view's title can optionally be hidden. If hidden, then any controls typically shown with the title (such as the close button) are also hidden. Any contributions or other content from the view itself are always shown (e.g. toolbar or view menu contributions, content description).

Source:
http://andydunkel.net/eclipse/java/swt/2011/10/04/eclipse-rcp-remove-tab-folder-from-view.html