PDA

View Full Version : aprire file con editor


simo9115
11-07-2016, 11:02
Salve a tutti, sto lavorando su un plugin di eclipse che permette di aprire un file con il suo relativo editor. In rete ho cercato questa soluzione:


public void openFile(Path filepath) throws Exception {
File fileToOpen = new File(filepath.toString());

if (fileToOpen.exists() && fileToOpen.isFile()) {
IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileToOpen.toURI());
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

try {
IDE.openEditorOnFileStore( page, fileStore );
} catch ( PartInitException e ) {
//Put your exception handler here if you wish to
}
} else {
//Do something if the file does not exist
}

}


il problema sta nel fatto che quando mando in run il plugin, mi dice che

IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

qualcuno sa spiegarmi come posso risolvere?