eclipse IPreferenceStore
来源:互联网 发布:matlab编程pdf 编辑:程序博客网 时间:2024/05/21 10:15
IPreferenceStore可以保存和获取PreferencePage的设置,可以通过Activator获取IPreferenceStore。
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
要想在PreferencePage中使用IPreferenceStore,需要在PreferencePage中先设置IPreferenceStore。
this.setPreferenceStore(Activator.getDefault().getPreferenceStore());
然后在PreferencePage中获取IPreferenceStore。IPreferenceStore store = this.getPreferenceStore();如果不设置的话,会报空指针异常,为什么呢?看getPreferenceStore()是如何实现的。public IPreferenceStore getPreferenceStore() { if (preferenceStore == null) {preferenceStore = doGetPreferenceStore();} if (preferenceStore != null) {return preferenceStore;} else if (container != null) {return container.getPreferenceStore();} return null;}如果不设置的话,这时preferenceStore为空,将会执行doGetPreferenceStore()方法,而该方法直接返回null。protected IPreferenceStore doGetPreferenceStore() { return null;}而container实际上是PreferenceDialog,这个类里面没有任何生成IPreferenceStore的方法,只是有get/set方法,所以也会返回null。public void setPreferenceStore(IPreferenceStore store) {Assert.isNotNull(store);preferenceStore = store;}@Overridepublic IPreferenceStore getPreferenceStore() {return preferenceStore;}0 0
- eclipse IPreferenceStore
- eclipse IPreferenceStore如何保存Preference Page设置?
- eclipse
- eclipse
- Eclipse
- Eclipse
- Eclipse
- Eclipse
- Eclipse
- eclipse
- eclipse
- Eclipse
- eclipse
- Eclipse
- Eclipse
- Eclipse
- Eclipse
- Eclipse
- java设计模式-工厂模式
- 网络资源-黑马程序员Java 知识——精华总结
- git操作
- 【Leetcode】453. Minimum Moves to Equal Array Elements
- Hibernate框架的相关知识点及面试题
- eclipse IPreferenceStore
- spingmvc 导出excel,浏览器进行下载的解决方式
- Linux下串口通信详解(下)读写串口及关闭串口
- 机器学习笔记八:常见“距离”归纳
- SQLite 入门教程(二)创建、修改、删除表
- vim无法安装问题
- 用apktool工具反编译apk后怎么得到源码,重新打包,签名
- cocoapods版本更新,以及多个版本的问题
- Java 冒泡排序,选择排序,二分查找