如何使用 Eclipse RCP 中的plugin_customization.ini 使 org.eclipse.equinox.p2.ui.sdk.scheduler/enabled 为 true?

发布于 2024-09-13 13:28:35 字数 1029 浏览 3 评论 0原文

我正在尝试构建一个 Eclipse RCP 应用程序,在此过程中,我们尝试将应用程序设置为自动更新。我们试图让它在“首选项 ->”中自动设置正确的首选项。安装/更新 ->自动更新页面。

我已经在 .product 的 plugin_customization.ini 文件中设置了我想要的所有首选项(例如 org.eclipse.equinox.p2.ui.sdk.scheduler/download=true),并且几乎所有首选项都有效。然而,一个首选项似乎没有自动设置:这是 org.eclipse.equinox.p2.ui.sdk.scheduler/enabled 首选项(AutomaticUpdatesPreferencePage 上的“自动查找新更新并通知我”复选框引用的首选项)深入研究源代码,我明白为什么它没有正确设置它,但我不确定如何解决它,

这基本上是它不起作用的原因:在AutomaticUpdatePlugin.start方法的最后一行中, 由于它

PreferenceInitializer.migratePreferences();

是插件的启动方法,因此会在从plugin_customization.ini 读取任何首选项之前调用此首选项,该首选项在 3.4 和 3.3 中位于不同的位置,其中有一个隐藏的。 “migerated34Prefs”首选项,用于检查是否执行了此迁移:此迁移将启用的首选项的值设置为 false,因此如果我可以以某种方式阻止它执行此迁移(因为我知道不会有从 3.3 或3.4,因为我们只是建立在 3.5 之上),一切都会正常工作。默认值是通过plugin_customization.ini正确设置的,但实际值仍然是错误的(即,如果我在第一次打开RCP后在该首选项页面上点击恢复默认值,则该框从未选中变为选中)。

因为这一切都发生在 start 方法中,所以我不能简单地在 plugin_customization 中将 migerated34Prefs 的值设置为 true,因为直到迁移已经发生之后才会被读入。我知道问题是什么,但我不太清楚最后一步是如何实现的,因此默认情况下会启用此功能。还有其他我可以设置的东西,或者我找不到的其他解决方法吗?

I'm trying to build an Eclipse RCP application, and in the process, we're trying to set the application to automatically update. We're trying to have it automatically set the right preferences in the Preferences -> Install/Update -> Automatic Updates page.

I've set all of the preferences I want in the plugin_customization.ini file for our .product (such as org.eclipse.equinox.p2.ui.sdk.scheduler/download=true), and almost all of them work. However, one preference seems to not get set automatically: this is the org.eclipse.equinox.p2.ui.sdk.scheduler/enabled preference (the one referred to by the "Automatically find new updates and notify me" checkbox on the AutomaticUpdatesPreferencePage. Digging into the source code, I understand why it doesn't set it correctly, but I'm not sure how to get around it.

Here's essentially why it doesn't work: In the last line of the AutomaticUpdatePlugin.start method, it calls

PreferenceInitializer.migratePreferences();

As it's the start method for the plugin, this occurs before any of the preferences are read from the plugin_customization.ini. migratePreferences tries to migrate this preference, which was in a different place in 3.4 and 3.3. Inside AutomaticUpdatePlugin, there's a hidden "migrated34Prefs" preference which checks to see if it's performed this migration: this migration sets the value of the enabled preference to false, so if I could somehow stop it from performing this migration (since I know there's going to be no migration from 3.3 or 3.4, as we're just built on top of 3.5), everything would work fine. The default value is set correctly via the plugin_customization.ini, but the actual value is still false (i.e. if I hit restore defaults on that preference page after opening the RCP the first time, the box goes from unchecked to checked).

Because this all occurs in the start method, I can't simply set the value of migrated34Prefs to true in the plugin_customization, because that won't even be read in until after the migration has already occurred. I know what the problem is, but I can't quite see the last step to make it so that this will be enabled by default. Is there something else I can set, or some other workaround that I haven't been able to find?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往昔成烟 2024-09-20 13:28:35

解决此问题的方法是直接从您自己的插件访问 AutomaticUpdatePlugin 的首选项,例如在首选项初始值设定项中:

Preferences node = new DefaultScope().getNode(AutomaticUpdatePlugin.PLUGIN_ID);
node.putBoolean(PreferenceConstants.PREF_AUTO_UPDATE_ENABLED, true);

A workaround for this is to access the AutomaticUpdatePlugin's preferences directly from your own plugin, for example in a preference initializer:

Preferences node = new DefaultScope().getNode(AutomaticUpdatePlugin.PLUGIN_ID);
node.putBoolean(PreferenceConstants.PREF_AUTO_UPDATE_ENABLED, true);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文