eclipse - 如何覆盖应用和恢复默认值
问题描述
我想为一种文件配置一些外观设置。所以我在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{}
块中,读取首选项中配置的设置并更新我班级的静态字段。 - 如果用户从首选项中更改了这些设置,则在应用时,我想更新类中的静态字段并“重新绘制”编辑器。
解决方案
如果您只想知道主题项何时更改值,请使用添加监听器的addPropertyChangeListener
方法IThemeManager
进行更改:
IThemeManager manager = PlatformUI.getWorkbench().getThemeManager();
manager.addPropertyChangeListener(listener);
PropertyChangeEvent
传递给 的方法propertyChanged
包含IPropertyChangeListener
更改的主题项的 id、旧值和新值。
推荐阅读
- reactjs - React Hooks Mobx:无效的钩子调用。Hooks 只能在函数组件的主体内部调用
- angular7 - 如何从 Angular 7 中传递 id 的 json 对象获取特定数据
- postgresql - 触发器根据另一个表记录更新计数
- angular - 将 ionic4/socket.io 连接到 expressjs net::ERR_CONNECTION_REFUSED
- checkbox - 在Google表格中选中复选框时如何更改指定单元格的颜色?
- audio - FLUTTER:我想录制麦克风流并立即播放
- python - 无法弄清楚硒 - 无法定位元素
- python-3.x - 使用 pandas 对多列求和
- ios - 在 CI 构建中使用 Facebook iOS SDK - 未找到框架
- django - 通用外键字段上的搜索字段