Skip to content

Instantly share code, notes, and snippets.

@jvanzyl
Created August 5, 2010 22:13
Show Gist options
  • Save jvanzyl/510483 to your computer and use it in GitHub Desktop.
Save jvanzyl/510483 to your computer and use it in GitHub Desktop.
public void run(IAction action) {
IFile file;
// If I am in the POM editor I want to get hold of the IFile that is currently
// in the buffer
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if ( window != null )
{
IWorkbenchPage page = window.getActivePage();
if ( page != null )
{
IEditorPart editor = page.getActiveEditor();
if ( editor != null )
{
IEditorInput input = editor.getEditorInput();
if ( input instanceof IFileEditorInput )
{
IFileEditorInput fileInput = (IFileEditorInput) input;
file = fileInput.getFile();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment