Eclipse RCP将值保存到工作台 [英] Eclipse RCP save values to workbench

查看:111
本文介绍了Eclipse RCP将值保存到工作台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为uDig开发插件,uDig是基于Eclipse RCP构建的项目。我的插件包含一个表,该表中填充了Workbench选择中的数据。用户可以对表数据进行分组,排序和过滤。当工作台选择更改组时,将重置排序和过滤器信息,并将新的选择数据加载到表中。

I am working on a plugin for uDig, a project build on Eclipse RCP. My plugin contains a table that gets populated with data from the Workbench selection. The table data can be grouped, sorted and filtered by the user. When the workbench selection changes the group, sort and filter information is reset and the new selection data loaded into the table.

如何将值保存到他的工作台中以便以后可以访问它们?

How do I save values to he workbench so I can access them later?

当工作台选择更改时,我希望保存组,进行排序和过滤状态到工作台,以便如果工作台选择曾经变回保存的选择,我可以恢复状态。

When the workbench selection gets changed I wish to save the group, sort and filter state out to the Workbench so that if the workbench selection ever changes back to the saved selection I can restore the state.

我看过IViewPart.saveState(IMemento memento),但感觉只有在添加和删除视图时,这才有用。

I have looked at IViewPart.saveState(IMemento memento) but get the feeling this is only useful when you are adding and removing a view.

I还查看了使用首选项的情况,但认为这是对资源的不正确使用。

I have also looked at using preferences but feel this is an incorrect usage of this resource.

IEclipsePreferences node = InstanceScope.INSTANCE.getNode(PluginUI.PLUGIN_ID);
node.put(key, value);



最后



我有些新知识Eclipse RCP,并且可能以错误的方式攻击此问题。如果有更好的方法来保存和加载此信息,请随时共享。

Finally

I am some what new to Eclipse RCP and may be attacking this problem the wrong way. If there is a better way to save and load this information please feel free to share.

推荐答案

在您的描述中,听起来像您可以在桌子上看风景。教科书中保存视图状态的方法是通过 IMemento 。您可以在演示文稿中看到使用此界面的代码。或者,您也可以使用 IPreferenceStore

From your description, it sounds like you have a view with the table. The text book way to save state for a view, is via IMemento. You can see the code to use this interface in this presentation. As an alternative, you can also use the IPreferenceStore.

通常,当状态具有全局范围时,使用首选项和纪念品时,它们是特定于视图的。

You usually use preferences when the state has a global scope and memento when they are specific to a view.

这篇关于Eclipse RCP将值保存到工作台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆