根據給定的IEditPar或IEditorInput獲取IFile實例。

 

  1. 根據IEditorInput獲取IFile實例
     public static IFile getFile(IEditorInput editorInput) {
    if (editorInput == null) {
    return null;
    }
            Object o = editorInput.getAdapter(IFile.class);
            if (o instanceof IFile) {
    return (IFile) o;
    }
            return null;
        }

     

  2. 根據IEditorPart獲取IFile實例

 The code below will demonstrate how to do this.

 IFile file = (IFile) editorPart.getEditorInput().getAdapter(IFile.class);
 if (file != null) {
    // do stuff
}

 

 

 

 

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章