2007-11-24
eclipse3.3关于JavaFileEditorInput兼容性问题的解决
关键字: Eclipse 兼容 JavaFileEditorInput在eclipse3.3中,JavaFileEditorInput这个internal类已经被干掉了,所以导致在插件中使用了JavaFileEditorInput之后导致编译不通过,为了做到与eclipse3.3以前版本兼容(至少是3.2),需要进行一下变通
通过google,我们发现,虽然eclipse3.3干掉了JavaFileEditorInput类,但是添加了FileStoreEditorInput来处理打开位于workspace之外的文件.
所以解决办法出来了,首先要判断一下当前的eclipse版本:
java 代码
- private static boolean inEclipse33;
- static {
- String version = System.getProperty("osgi.framework.version"); //$NON-NLS-1$
- if (version != null && version.startsWith("3.3")) //$NON-NLS-1$
- {
- inEclipse33 = true;
- }
- }
然后我们在使用到JavaFileEditorInput的地方这样改写:
java 代码
- // 为了兼容3.3和3.2
- String clazzName = element.getClass().getName();
- if (inEclipse33) {
- if (clazzName.equals("org.eclipse.ui.ide.FileStoreEditorInput")) {
- IURIEditorInput uri = (IURIEditorInput) element;
- return getOperation(document, new Path(uri.getURI().getPath()));
- }
- }else {
- if (clazzName.equals("org.eclipse.ui.internal.editors.text.JavaFileEditorInput")) {
- IPathEditorInput pei = (IPathEditorInput) element;
- return getOperation(document, pei.getPath());
- }
- }
评论
wzfj2002
2008-05-31
看到一则这样的东西:“刚刚遇到同样的问题,更新jsEclipse 1.5.5就ok了,相信你已经解决了,1.5.3版本是有这样的问题,呵呵!”相信能解决了
wzfj2002
2008-05-31
晕了,在哪里改写嵌入以上代码,能否说的更清楚些,继续关注中。。
发表评论
- 浏览: 264748 次
- 性别:

- 来自: 杭州

- 详细资料
搜索本博客
我的相册
t61 thinkpad
共 143 张
共 143 张
最近加入圈子
链接
最新评论
-
使用Dorado框架开发必备参 ...
哈哈,顶,收藏了啊
-- by liufeikl2008 -
使用Dorado框架开发必备参 ...
谢谢了,收藏啦!!期望更新中
-- by liufeikl2008 -
在云南做项目的日子――20 ...
波xx,咪xx全家..
-- by Diablofrog -
在云南做项目的日子――20 ...
太漂亮了..无法用言语形容了.....
-- by xiaozmn -
jBPM中Timer的使用
引用楼主使用没有发现什么问题吗?为什么我在用的时候,线程启动成功后,倒是执行了, ...
-- by macrochen






评论排行榜