Я пишу плагин Eclipse, который требует, чтобы я получил полный путь к любому файлу, открытому в рабочей области.Eclipse PDE: Получить полный путь к внешнему файлу, открытому в Workbench
Я могу получить полный путь к любому файлу, который является частью любого проекта Eclipse. Код для открытия открытого/активного файла редактора из рабочей области.
public static String getActiveFilename(IWorkbenchWindow window) {
IWorkbenchPage activePage = window.getActivePage();
IEditorInput input = activePage.getActiveEditor().getEditorInput();
String name = activePage.getActiveEditor().getEditorInput().getName();
PluginUtils.log(activePage.getActiveEditor().getClass() +" Editor.");
IPath path = input instanceof FileEditorInput ? ((FileEditorInput) input).getPath() : null;
if (path != null) {
return path.toPortableString();
}
return name;
}
Однако, если какой-либо файл drag-dropped in Workspace
или открыт с помощью File -> Open File
. Например, я открыл файл из /Users/mac/log.txt из File -> Open File. Мой плагин не может найти местоположение этого файла.