You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何指定org.eclipse.ui.preferencePages扩展中页面的显示顺序?

问题

我已在org.eclipse.ui.preferencePages扩展中添加了foo、bar、test页面。目前菜单按bar、foo、test的字母顺序显示,请问能否指定自定义的显示顺序?

相关配置代码如下:

<page
   category="fooCategory"
   class="fooClass"
   id="fooId"
   name="foo">
</page>
<page
   category="barCategory"
   class="barClass"
   id="barId"
   name="bar">
</page>
<page
   category="testCategory"
   class="testClass"
   id="testId"
   name="test">
</page>
解答

可以指定自定义显示顺序,在Eclipse的preferencePages扩展配置里,给每个<page>元素添加**weight属性**即可,Eclipse会根据weight值从小到大排序显示偏好页面,值越小越靠前。

比如你想让顺序变成foo、bar、test,可按如下配置设置weight值:

<page
   category="fooCategory"
   class="fooClass"
   id="fooId"
   name="foo"
   weight="10">
</page>
<page
   category="barCategory"
   class="barClass"
   id="barId"
   name="bar"
   weight="20">
</page>
<page
   category="testCategory"
   class="testClass"
   id="testId"
   name="test"
   weight="30">
</page>
  • weight属性支持整数取值,建议设置有间隔的数值(如10、20、30),方便后续插入新页面时调整顺序。
  • 未设置weight属性时,Eclipse默认按页面名称的字母顺序排序,这就是当前显示bar、foo、test顺序的原因。

内容的提问来源于stack exchange,提问作者user21415561

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 12:02:21