简体   繁体   English

如何在 Eclipse 中找到偏好页面的偏好页面 ID?

[英]How do I find out the preference page ID of a preference page in Eclipse?

I'd like to know how to find out the preference page ID of an existing preference page in Eclipse.我想知道如何在 Eclipse 中找出现有偏好页面的偏好页面 ID。 Specifically, I want to find out the preference page ID of the General > Capabilities preference page in Eclipse.具体来说,我想在 Eclipse 中找出 General > Capabilities 首选项页面的首选项页面 ID。 I have tried "org.eclipse.ui.activities.ActivityCategoryPreferencePage" and that does not seem to be working.我试过“org.eclipse.ui.activities.ActivityCategoryPreferencePage”,但这似乎不起作用。

Thanks!谢谢!

The easiest way I found, assuming you have the PDE as part of your eclipse installation, is to use the Plugin-Spy and go from there.我发现的最简单的方法是,假设您将 PDE 作为 eclipse 安装的一部分,从那里使用 Plugin-Spy 和 go。

Open the preference page and hit Alt+Shift+F1.打开首选项页面并按 Alt+Shift+F1。 A 'Plug-in Selection Spy' dialog should appear.应该会出现一个“插件选择间谍”对话框。 In that dialog you will find the contributing plugin and the class name for the active page.在该对话框中,您将找到活动页面的贡献插件和 class 名称。 Then go to that plugin and check out its plugin.xml to find the ID.然后 go 到该插件并检查其 plugin.xml 以找到 ID。

Note that some implementations may have the ID as a constant in the viewer class, so you can start by viewing the class's code, and if it's not there, check the plugin.xml.请注意,某些实现可能在查看器 class 中将 ID 作为常量,因此您可以从查看类的代码开始,如果不存在,请检查 plugin.xml。

Cheers干杯

I wrote some code in a command handler to find out all the preference page labels and their IDs based on http://rcpexperiments.blogspot.com/2010/03/how-to-remove-unwanted-preference-pages.html .我在命令处理程序中编写了一些代码,以根据http://rcpexperiments.blogspot.com/2010/03/how-to-remove-unwanted-preference-pages.html找出所有偏好页面标签及其 ID。 However, the code on that site only prints out the highest-level preference nodes;但是,该站点上的代码仅打印出最高级别的首选项节点; whereas the page I wanted resided as a child page of the top level General (org.eclipse.ui.preferencePages.Workbench) preference page.而我想要的页面作为顶级 General (org.eclipse.ui.preferencePages.Workbench) 首选项页面的子页面。 So I modified the code slightly to print out the children as ewll.所以我稍微修改了代码以将孩子打印为 ewll。

    PreferenceManager pm = PlatformUI.getWorkbench( ).getPreferenceManager();
    List<IPreferenceNode> l = pm.getElements(PreferenceManager.PRE_ORDER);

    for(IPreferenceNode node : l){
        System.out.println("Label:" + node.getLabelText() + " ID:" + node.getId());
    }

This printed out all the preference page names and ID, after which I just did a search for the label I wanted.这打印出所有偏好页面名称和 ID,之后我只是搜索了我想要的 label。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM