Wednesday, September 23, 2009

Eclipse Tips and Tricks

1) Path for tool bar and menu bar can be found in org.eclipse.ui.IWorkbenchActionConstant
2) Code to find out an active shell
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()
3) To find out an active page
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
4) To access file from workspace
ResourcesPlugin.getWorkspace().getRoot().getFile(IPath)
5) To access projects from workspace
ResourcesPlugin.getWorkspace().getRoot().getProjects()
6) To create an uri from file location
uri = org.eclipse.core.runtime.URIUtil.fromString("file://" + "C:/test.txt");
7) To open external file in an eclipse editor
IFileStore fileStore = org.eclipse.core.filesystem.EFS.getStore(uri);
org.eclipse.ui.ide.IDE.openEditorOnFileStore(activePage, fileStore);
8) To open external file in an external editor
IDE.openEditor(page, uri, IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID, true );

0 comments: