1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| private IWorkbenchPage page;
private IFile file;
public void openFile (Path pathFile) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
file = root.getFileForLocation(pathFile);
IWorkbenchWindow[] workbenchWindowTable = monPlugin.getWorkbench().getWorkbenchWindows();
if (workbenchWindowTable.length > 0) {
page = workbenchWindowTable[0].getActivePage();
}
if (page!=null)
monPlugin.getWorkbench().getDisplay().syncExec(new Runnable(){
public void run(){
try {
IDE.openEditor(page, file);
} catch (Exception e) {
System.out.println(e);
}
}
});
} |
Partager