2

因此,我可以导出我的 RCP 应用程序并在我的导出目录中的 .settings 文件夹下找到特定于我的应用程序的 .pref 文件。

当我在 Eclipse IDE 中运行/调试应用程序时,应用程序 .prefs 文件存储在哪里?例如,我从 eclipse ide 运行我的程序,它执行以下操作。我在哪里可以找到这个的首选项文件?

Preferences prefs = ConfigurationScope.INSTANCE.getNode("hostname.controllers");
    prefs.putInt("numCtrlrs", 2);
    prefs.put("ctrlr1", "adamctrlr.ohmasd.org");
    prefs.put("ctrlr2", "mnet.ohmasd.org");

    try{
        prefs.flush();
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }
4

2 回答 2

2

为了扩展tkotisis答案,位置路径的示例如下,用于使用ConfigurationScopeand的首选项InstanceScope。如果我们在 RCP 应用程序中使用以下代码:

IEclipsePreferences sharedPreferences = ConfigurationScope.INSTANCE.getNode("ConfigurationScopeExample"); 
sharedPreferences.put("Property1", "Value1");
sharedPreferences.flush();

IEclipsePreferences workspacePreferences = InstanceScope.INSTANCE.getNode("InstanceScopeExample"); 
workspacePreferences.put("Property2", "Value2");
workspacePreferences.flush();

我们通过名为“TestRcp.application”和工作空间“${workspace_loc}/../runtime-TestRcp.application”的IDE启动RCP应用程序(如下所示):

将创建/更新相应的首选项文件:

\{workspace}\.metadata\.plugins\org.eclipse.pde.core\TestRcp.application\.settings\ConfigurationScopeExample.prefs
    Property1=Value1
    eclipse.preferences.version=1

\runtime-TestRcp.application\.metadata\.plugins\org.eclipse.core.runtime\.settings\InstanceScopeExample.prefs
    Property2=Value2
    eclipse.preferences.version=1
于 2012-12-20T02:48:08.270 回答
1

在 IDE 中运行 RCP 时,它使用的是在运行/调试配置中设置的工作区(通常命名为runtime-product.name并位于与运行的 Eclipse 工作区相同的路径中)。

可以在此运行时工作区中的相应路径中找到首选项文件。

于 2012-04-20T12:22:09.223 回答