在rcp中获取文件

来源:互联网 发布:挺固防盗门 知乎 编辑:程序博客网 时间:2024/05/26 16:01

    得到Appliaction workspace, Platform.asLocalURL(PRODUCT_BUNDLE.getEntry("")).getPath()).getAbsolutePath();
    得到runtimeworkspace, Platform.getInstanceLocation().getURL().getPath();

通过EditorInput来得到工程的绝对路径:

    ((IFileEditorInput)input).getFile().getLocation().makeAbsolute().toFile().getAbsoluteFile().getParentFile();

通过父EditPart得到编辑器的方法(GEF):

    IEditorPart editor = ((DefaultEditDomain)(parent.getViewer().getEditDomain())).getEditorPart();