- 根據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;}
- 根據IEditorPart獲取IFile實例
The code below will demonstrate how to do this.
IFile file = (IFile) editorPart.getEditorInput().getAdapter(IFile.class);
if (file != null) {
// do stuff
}