【问题标题】:eclipse preferences: setting proxy bypass defaults via plugineclipse 首选项:通过插件设置代理绕过默认值
【发布时间】:2013-10-04 13:25:37
【问题描述】:

我正在尝试在Eclipse 首选项中设置一些值,尤其是在网络连接-> 代理绕过中。我想做一些自己的条目。 那么我怎样才能放一些值呢? 由

IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();

或更好

InstanceScope.INSTANCE.getNode(...   ?

我如何访问它,将一些值放入其中? 欢迎任何提示。

非常感谢大家!

【问题讨论】:

    标签: eclipse preferences


    【解决方案1】:

    您可以找到有关ConfigurationScopeInstanceScopeDefaultScope right here, from Vogella 的详细信息。

    你要做的是创建FieldEditors。

    像这样创建偏好页面:
    public class ProxyPreferencesPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage

    您还需要一个“静态”类(最好是接口)来保存首选项键 IProxyPreferenceKeys -> 把你所有的偏好变量放在这里。

    当您创建字段编辑器时,将首选项常量传递给它。

    new ColorFieldEditor(IProxyPreferenceKeys.PROXY, "Proxy color:", parent);
    

    最后,在你的代码中,当你需要偏好设置的时候,就这样搞定:

    Activator.getDefault().getPreferenceStore().getString(IProxyPreferenceKeys.PROXY)

    【讨论】:

    • 嗨,格雷格,感谢您的建议。但我不想在 Eclipse 首选项中开始新页面,我想将值添加到现有的代理绕过字段(在网络连接页面上)。您的最后一个代码 sn-p 是我正在寻找的,但我需要有关如何将值添加到商店的更多信息。或者我可以访问 ProxyPreferencePage 来添加我的值吗?
    • @Ahpuch 尝试使用来自InstanceScope.INSTANCE.getNode(..)put API,或来自首选项存储的setValue(..) API。测试一下。我认为使用InstanceScope 是更好的解决方案,只有您需要知道代理设置的偏好键。
    【解决方案2】:

    网络连接首选项页面是org.eclipse.ui.internal.net.ProxyPreferencePage。这不会直接从首选项中获取值,而是通过诸如ProxySelectorProxyManager(所有内部类)之类的类获取值。

    看起来值实际上来自ConfigurationScope.INSTANCE.getNode("org.eclipse.core.net"),而键在org.eclipse.core.internal.net.ProxyManager中定义

    【讨论】:

      猜你喜欢
      • 2013-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-28
      • 1970-01-01
      • 2012-11-19
      • 2011-07-02
      相关资源
      最近更新 更多