以编程方式更改 Eclipse RCP 未知文件类型关联
Change Eclipse RCP unknown file type association programmatically
我正在构建一个 3.x RCP 应用程序,我添加了一些基于 Eclipse 的默认功能,例如 Project Explorer、工具栏、首选项页面等。
我的问题是当我拖放一个与任何编辑器都没有关联的文件时。在这种情况下,Eclipse RCP 使用我的 OS 使用的默认编辑器。我知道我可以从 Preferences > Editors 更改它,但我想通过编码更改该首选项的默认值。
我想将未知文件类型分配给 Eclipse 文本编辑器。我该怎么做?
'Preferences > General > Editors > File Associations > Open unassociated files with' 最终在 org.eclipse.ui.ide
plug-in 的首选项存储中设置了 IDE.UNASSOCIATED_EDITOR_STRATEGY_PREFERENCE_KEY
首选项键。使用文本退出器的键值为org.eclipse.ui.ide.textEditor
所以你应该可以使用类似的东西:
IPreferenceStoere store = new ScopedPreferenceStore(InstanceScope.INSTANCE, ""org.eclipse.ui.ide"");
store.setValue(IDE.UNASSOCIATED_EDITOR_STRATEGY_PREFERENCE_KEY,
"org.eclipse.ui.ide.textEditor");
我正在构建一个 3.x RCP 应用程序,我添加了一些基于 Eclipse 的默认功能,例如 Project Explorer、工具栏、首选项页面等。
我的问题是当我拖放一个与任何编辑器都没有关联的文件时。在这种情况下,Eclipse RCP 使用我的 OS 使用的默认编辑器。我知道我可以从 Preferences > Editors 更改它,但我想通过编码更改该首选项的默认值。
我想将未知文件类型分配给 Eclipse 文本编辑器。我该怎么做?
'Preferences > General > Editors > File Associations > Open unassociated files with' 最终在 org.eclipse.ui.ide
plug-in 的首选项存储中设置了 IDE.UNASSOCIATED_EDITOR_STRATEGY_PREFERENCE_KEY
首选项键。使用文本退出器的键值为org.eclipse.ui.ide.textEditor
所以你应该可以使用类似的东西:
IPreferenceStoere store = new ScopedPreferenceStore(InstanceScope.INSTANCE, ""org.eclipse.ui.ide"");
store.setValue(IDE.UNASSOCIATED_EDITOR_STRATEGY_PREFERENCE_KEY,
"org.eclipse.ui.ide.textEditor");