Jump to: navigation, search

Difference between revisions of "Eclipsepedia talk:Tips and Tricks"

(Removing all content from page)
Line 1: Line 1:
== FAQ How do I open an editor programmatically in Eclipse 3.3? ==
First of all, this works on eclipse 3.3.0. I haven't tried the codes on the other versions of eclipse.
            import java.io.File;
            import org.eclipse.core.filesystem.EFS;
            import org.eclipse.core.filesystem.IFileStore;
            import org.eclipse.ui.PartInitException;
            import org.eclipse.ui.IWorkbenchPage;
            import org.eclipse.ui.PlatformUI;
            import org.eclipse.ui.ide.IDE;
            File fileToOpen = new File( textField.getText() );
            if ( fileToOpen.exists() && fileToOpen.isFile() )
                IFileStore fileStore = EFS.getLocalFileSystem().getStore( fileToOpen.toURI() );
                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                    IDE.openEditorOnFileStore( page, fileStore );
                catch ( PartInitException e )
                    //Create your error handler codes here
                //You may do something if the file is not a file and the file does not exist
== See Also: ==
*[[FAQ How do I open an editor programmatically?]]  ---  for eclipse 3.0 version
*[[FAQ Is Eclipse 3.0 going to break all of my old plug-ins?]]
*[[FAQ How do I find the active workbench page?]]
*[[FAQ How do I open an editor on a file in the workspace?]]
*[[FAQ Can I make a job run in the UI thread?]]

Latest revision as of 23:29, 24 February 2008