【发布时间】:2014-08-21 07:40:15
【问题描述】:
我正在编写一个插件,当按下按钮时,它必须在某一行打开文件。 我有以下代码在某一行打开文件。
String filePath = "file path" ;
final IFile inputFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(Path.fromOSString(filePath));
if (inputFile != null) {
IWorkbenchPage page1 = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart openEditor11 = IDE.openEditor(page1, inputFile);
}
int Line = 20;
if (openEditor11 instanceof ITextEditor) {
ITextEditor textEditor = (ITextEditor) openEditor ;
IDocument document= textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
textEditor.selectAndReveal(document.getLineOffset(Line - 1), document.getLineLength(Line-1));
}
我的问题是 if 语句中的变量 openEditor11 给出了错误:openEditor11 无法解析为变量。可能是什么问题?
【问题讨论】:
-
问题是openEditor11无法解析为变量。 :) 如果您重新学习 Java 课程,您会帮自己一个忙,因为在掌握基础知识之前潜入任何编程都是一种痛苦。
-
我现在在一个项目中尝试学习 Java。
-
我已经完成了那个名为 eclipselink 的项目。多年前在 eclipseplugincentral.com 下可用。现在在这里服务:webmasterwork.com/page/…
-
谢谢!我只是尝试学习一些Java和Eclipse插件:)
-
我在决定如果文件被打开两次时我应该关注哪个编辑器以及如果 eclipse 窗口被克隆并且如果用户启动多个 eclipse 实例时我应该使用哪个窗口时遇到问题,eclipse 应该采取什么请求(最后一个问题可能不是你的,因为你知道你的日食)。
标签: java eclipse plugins eclipse-plugin