【发布时间】:2013-12-09 05:58:45
【问题描述】:
我正在使用 Eclipse RCP 并创建编辑器,我需要以下代码:
new Path("c:/myfile.txt")
我遇到了以下问题:
Path must include project and resource name
我不知道项目或资源名称是什么(我不关心它们 - 我想打开那个文件)。我很惊讶如此简单的事情(以及许多其他事情)在 Eclipse RCP 中如此复杂。
【问题讨论】:
-
您如何使用
Path?听起来您可能正在使用需要工作区中的资源的 Eclipse API。 -
我有一个动作,我正在尝试创建编辑器(在 Swing 的几分钟问题中,在 Eclipse RCP 中它似乎非常复杂):PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file. getName());
-
什么是
EclipseUtils? -
它包含以下静态函数: public static IFileEditorInput getFileEditorInput(IPath path){ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IFile 文件 = root.getFile(path);如果(文件==空)返回空; IFileEditorInput fileEditorInput = new FileEditorInput(file);返回文件编辑器输入; }