Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Open an IFile in default editor
Open an IFile in default editor [message #224418] Thu, 08 April 2004 10:55 Go to next message
Eclipse UserFriend
Originally posted by: Newsletter.ThorstenSchaefer.de

Hi,

I have to open a file (java source, text file, xml file, ...) in it's
default editor. All I have is the corresponding IFile object. Does anybody
know how to open the editor with the file's content? I searched the help and
newsgoups but all solutions I saw were partial or don't function with the
3.0 M-builds.

TIA,

Thorsten
Re: Open an IFile in default editor [message #224720 is a reply to message #224418] Thu, 08 April 2004 17:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smesh.openrules.com

See OpenRules sources at:
:pserver:anonymous@cvs.sourceforge.net:/cvsroot/openl

I collected some Eclipse's 'philosophical stuff' in UtilBase.java.

Please see UtilBase.getSourceEditorForSourceElement(Object).
IMHO, it's not 'as if would be prescribed by doctor', but it works :-))
Next, this 'philosophical stuff' definitely should be somewhere in Wiki.

--
Sam Mesh - http://openrules.com
Re: Open an IFile in default editor [message #224865 is a reply to message #224418] Thu, 08 April 2004 20:47 Go to previous message
Eclipse UserFriend
Originally posted by: Marko.Schulz.gmx.de

Thorsten Schäfer wrote:
>
> I have to open a file (java source, text file, xml file, ...) in it's
> default editor. All I have is the corresponding IFile object.

Use org.eclipse.ui.ide.IDE.openEditor(IWorkbenchPage, IFile, boolean)


You usually get the IWorkbenchPage by calling getPage() on some instance
of IWorkbenchSite, depending on the context you are in. If that really
is impossible, you can revert to acquiring the active Page through
org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchW indow().getActivePage()



HTH
marko
Previous Topic:How can I run java application with input file
Next Topic:Rebuilding in M8
Goto Forum:
  


Current Time: Thu Sep 19 02:22:14 GMT 2024

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

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

Back to the top