Java EclipseRCP-ScopedReferenceStore限定符。如何使用默认首选项存储?

Java EclipseRCP-ScopedReferenceStore限定符。如何使用默认首选项存储?,java,eclipse-rcp,default,preferences,Java,Eclipse Rcp,Default,Preferences,在我的Eclipse 3.7 RCP应用程序中,我得到的首选项存储如下: Activator.getDefault().getPreferenceStore()返回一个IPreferenceStore。 这里使用激活器自己的首选项存储 现在我想使用ScopedPreferenceStore的一个实例,它也是IPreferenceStore现在不能通过在构造函数scopedReferenceStore(IScopeContext context,String qualifier)中传递插件id作为

在我的Eclipse 3.7 RCP应用程序中,我得到的首选项存储如下:
Activator.getDefault().getPreferenceStore()
返回一个
IPreferenceStore
。 这里使用激活器自己的首选项存储

现在我想使用
ScopedPreferenceStore
的一个实例,它也是
IPreferenceStore

现在不能通过在构造函数
scopedReferenceStore(IScopeContext context,String qualifier)
中传递插件id作为限定符参数来明确设置首选项存储节点

示例:
ScopedReferenceStore(ConfigurationScope.INSTANCE,“com.example.myplugin.id”)

问题:

如何获取Activator自己的首选存储限定符?换句话说,我如何创建一个
ScopedPreferenceStore
,它将首选项存储在Activator自己的首选项存储中?

如果您想在不访问Activator本身的情况下获得捆绑包的等效首选项存储,您可以使用您列出的相同模式:

preferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, "your.bundle.id");
编辑:查找捆绑包id

当eclipse自动生成bundle activator时,它会创建一个带有bundle id的静态字段。但是如果没有activator,您仍然可以检索bundle id。您可以使用
FrameworkUtil
从任何一个类获取
bundle
对象

import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;

final Bundle bundle = FrameworkUtil.getBundle(PrintIdHandler.class);
System.out.println(bundle.getSymbolicName());

你是在问如何在不去激活器的情况下获得你的插件的首选项存储吗?我没有看到,激活器默认有一个静态属性
plugin\u ID
。这就是我要找的!我只是在寻找访问bundleID的可能性,而没有明确地写下来。默认激活器生成存储ID的字段
PLUGIN\u ID