国产一区二区精品久久_蜜桃狠狠狠狠狠狠狠狠狠_午夜视频精品_激情都市一区二区

當前位置:首頁 > 網站舊欄目 > 學習園地 > 設計軟件教程 > eclipse3.3關于JavaFileEditorInput兼容性問題的解決

eclipse3.3關于JavaFileEditorInput兼容性問題的解決
2010-01-14 23:06:32  作者:  來源:

在eclipse3.3中,JavaFileEditorInput這個internal類已經被干掉了,所以導致在插件中使用了JavaFileEditorInput之后導致編譯不通過,為了做到與eclipse3.3以前版本兼容(至少是3.2),需要進行一下變通
通過google,我們發現,雖然eclipse3.3干掉了JavaFileEditorInput類,但是添加了FileStoreEditorInput來處理打開位于workspace之外的文件.
所以解決辦法出來了,首先要判斷一下當前的eclipse版本:

java 代碼
 
  1. private static boolean inEclipse33;   
  2.   
  3. static {   
  4.  String version = System.getProperty("osgi.framework.version"); //$NON-NLS-1$   
  5.  if (version != null && version.startsWith("3.3")) //$NON-NLS-1$   
  6.  {   
  7.   inEclipse33 = true;   
  8.  }   
  9. }   
  10.   

然后我們在使用到JavaFileEditorInput的地方這樣改寫:
 

java 代碼
 
  1. // 為了兼容3.3和3.2   
  2. String clazzName = element.getClass().getName();   
  3. if (inEclipse33) {   
  4.  if (clazzName.equals("org.eclipse.ui.ide.FileStoreEditorInput")) {   
  5.   IURIEditorInput uri = (IURIEditorInput) element;   
  6.   return getOperation(document, new Path(uri.getURI().getPath()));   
  7.  }   
  8. }else {   
  9.  if (clazzName.equals("org.eclipse.ui.internal.editors.text.JavaFileEditorInput")) {   
  10.   IPathEditorInput pei = (IPathEditorInput) element;   
  11.   return getOperation(document, pei.getPath());   
  12.  }   

安徽新華電腦學校專業職業規劃師為你提供更多幫助【在線咨詢