【发布时间】:2018-06-05 16:10:54
【问题描述】:
我想为一种文件配置一些外观设置。所以我在General->Appearance->Colors and Fonts 中创建了一个新条目。
我的plugin.xml 看起来像这样:
<extension point="org.eclipse.ui.themes">
<themeElementCategory
id="com.example.themeElementCategory"
label="My specific settings">
<description>
Control the appearance of .example files
</description>
</themeElementCategory>
<colorDefinition
categoryId="com.example.themeElementCategory"
id="com.example.colorDefinition"
label="Some Color"
value="COLOR_DARK_BLUE">
<description>
Your description goes here
</description>
</colorDefinition>
<fontDefinition
categoryId="com.example.themeElementCategory"
id="com.example.fontDefinition"
label="Some Font"
value="Lucida Sans-italic-18">
<description>
Description for this font
</description>
</fontDefinition>
</extension>
现在在Colors and Fonts 我有一个新条目,我可以设置颜色和字体。
如何扩展首选项窗口,以便覆盖Restore defaults、Apply 和Apply and Close 按钮?
在我的
<themeElementCategory>中,我必须添加一个class=MyHandlingClass,它将覆盖performApply(),但是该类应该扩展/实现什么?同1,不过加了
PropertyChangeEvent,还是不知道应该扩展/实现什么不太可能,创建一个扩展
PreferencePage并实现IWorkbenchPreferencePage的新首选项页面
如何实现前两个选项之一?
澄清更新
目前,特定文件扩展名的颜色和字体被硬编码在一个类中(我知道)。
当文件在编辑器中打开时,信息将从该静态类中读取并在编辑器中可见。
我想做的事:
- 在
static{}块中,读取首选项中配置的设置并更新我班级的静态字段。 - 如果用户从首选项中更改了这些设置,我想在应用时更新类中的静态字段并“重新绘制”编辑器。
【问题讨论】:
-
您不能覆盖首选项页面中的按钮。为什么你认为你需要?
-
@greg-449 哦,这是个坏消息……我更新了问题,提供了更多信息,说明我为什么要这样做