PROBLEMA plugin eclipse aprire file con relativo editor

simo9115

Nuovo Utente
139
3
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:
Codice:
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
        }            
        
    }
[FONT=Lato]
[/FONT]il problema sta nel fatto che quando mando in run il plugin, mi dice che
Codice:
[FONT=Lato] IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();[/FONT][FONT=Lato]
[/FONT]è null quindi mi causa errore...perchè? non riesco proprio a capire...

- - - Updated - - -

non mi sa aiutare nessuno?
 

Entra

oppure Accedi utilizzando
Discord Ufficiale Entra ora!