Eclipse插件项目首选项保存异常

发布于 2024-11-26 17:52:17 字数 961 浏览 3 评论 0原文

我目前正在开发一个 Eclipse 插件,我创建了自己的属性页,右键单击所选项目的上下文菜单时将显示该属性页。我尝试通过按该页面上的“确定”按钮来保存该页面的值,但出现异常:“保存项目首选项时发生异常:/test/.settings/com.example.plugin.prefs.Resource is out与文件系统同步:'/test/.settings/com.example.plugin.prefs'。”

以下是我实现的内容:

//Get the project
IAdaptable resource = getElement();
if (resource != null) {
   IProject project = (IProject) resource.getAdapter(IProject.class);
}    
//Define project scope
IScopeContext projectScope = new ProjectScope(project);
//Get node by qualified name
Preferences projectNode = projectScope.getNode(MyPlugin.PLUGIN_ID);
//set the value and save it
if (projectNode != null) {
projectNode.put(PROPERTIES_SERVICENAME, serviceName);
}       
try {
projectNode.flush();  // Exception occurs here!!!
} catch (BackingStoreException e) {
e.printStackTrace();
}

据我所知,它应该自动在runtime-EclipseApplication\test.settings下保存一个像“com.example.plugin.prefs”这样的文件,这是正确的吗? 有人知道如何解决这个问题吗?

I am currently developing an eclipse plugin, i created my own property page which will be displayed when right-clicking on the context menu of selected project. I tried to save values of that page by pressing OK button on that page, but i got exception saying: "Exception occurred while saving project preferences: /test/.settings/com.example.plugin.prefs.Resource is out of sync with the file system: '/test/.settings/com.example.plugin.prefs'."

Following is what i implemented:

//Get the project
IAdaptable resource = getElement();
if (resource != null) {
   IProject project = (IProject) resource.getAdapter(IProject.class);
}    
//Define project scope
IScopeContext projectScope = new ProjectScope(project);
//Get node by qualified name
Preferences projectNode = projectScope.getNode(MyPlugin.PLUGIN_ID);
//set the value and save it
if (projectNode != null) {
projectNode.put(PROPERTIES_SERVICENAME, serviceName);
}       
try {
projectNode.flush();  // Exception occurs here!!!
} catch (BackingStoreException e) {
e.printStackTrace();
}

To my knowledge, it should automatically save a file like "com.example.plugin.prefs" under runtime-EclipseApplication\test.settings as well, is that correct?
Anybody has idea how to solve this problem?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文