Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » get IFile from IDocument
get IFile from IDocument [message #333608] Thu, 18 December 2008 12:11 Go to next message
Artur Zeiler is currently offline Artur ZeilerFriend
Messages: 10
Registered: July 2009
Junior Member
Hi all,

is it possible to get an IFile from IDocument?
A code example would be very helpful.

Thanks!
Re: get IFile from IDocument [message #333610 is a reply to message #333608] Thu, 18 December 2008 12:16 Go to previous messageGo to next message
Artur Zeiler is currently offline Artur ZeilerFriend
Messages: 10
Registered: July 2009
Junior Member
A solution is:

ITextEditor textEditor= (ITextEditor) editor;
IEditorInput input= textEditor.getEditorInput();
IFile file = ((FileEditorInput) input).getFile();
IPath path = file.getFullPath();
Re: get IFile from IDocument [message #1769217 is a reply to message #333610] Thu, 27 July 2017 22:08 Go to previous message
Ígor Brasileiro is currently offline Ígor BrasileiroFriend
Messages: 1
Registered: July 2017
Junior Member
I want to do the same with eclipse neon, but i don't find FileEditorInput.

My code here
public static File getFileFromEditor() {
		IWorkbench iworkbench = PlatformUI.getWorkbench();

		IWorkbenchWindow activeWorkbenchWindow = null;
		if(iworkbench != null) {
			activeWorkbenchWindow = iworkbench.getActiveWorkbenchWindow();
		}

		IWorkbenchPage activePage = null;
		if(activeWorkbenchWindow != null) {
			activePage = activeWorkbenchWindow.getActivePage();
		}

		IEditorPart activeEditor = null;
		if(activePage != null ) {
			activeEditor = activePage.getActiveEditor();
		}

		if(activeEditor != null) {
			return findFileFromWorkspace(activeEditor.getTitle());
		[code][/code]}
		return null;
	}
Previous Topic:Eclipse WorkerPool does not start new Workers for Jobs
Next Topic:extension points in fragment
Goto Forum:
  


Current Time: Fri Jul 05 03:27:21 GMT 2024

Powered by FUDForum. Page generated in 0.03820 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top