Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Open a file in Text Editor programatically?
Open a file in Text Editor programatically? [message #154886] Mon, 19 April 2004 00:11 Go to next message
Eclipse UserFriend
Originally posted by: lshan.imail.eecs.berkeley.edu

Hi all,

I am a newbie in Eclipse plugins. I want to have some hints on how to get an
instance of the eclipse's default text editor(not java editor). Then open an
IFile in it.

Do i have to go through the whole process like developing my own editor?? Or
is there any provided class that i can use since all i want is the default
text editor??

Thank you very much!!!

Lexin
Re: Open a file in Text Editor programatically? [message #154909 is a reply to message #154886] Mon, 19 April 2004 14:08 Go to previous message
Eclipse UserFriend
Hi Lexin,

You should know the id of the editor you want to open the file with, or you
can just get the default editor for the file name pattern.

IWorkbenchPage workbenchPage =
getViewSite().getWorkbenchWindow().getActivePage();

IEditorRegistry eReg = WorkbenchPlugin.getDefault().getEditorRegistry();

IEditorDescriptor defaultdisc = eReg.getDefaultEditor(file.getName());

if (defaultdisc == null)

defaultdisc = eReg.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID)

try {

workbenchPage.openEditor(new FileEditorInput(file), defaultdisc.getId());

} catch (PartInitException e) {

....

}


best regards.
Gunay Arslan






"Lexin Shan" <lshan@imail.eecs.berkeley.edu> wrote in message
news:c5vj6v$ulc$1@eclipse.org...
> Hi all,
>
> I am a newbie in Eclipse plugins. I want to have some hints on how to get
an
> instance of the eclipse's default text editor(not java editor). Then open
an
> IFile in it.
>
> Do i have to go through the whole process like developing my own editor??
Or
> is there any provided class that i can use since all i want is the default
> text editor??
>
> Thank you very much!!!
>
> Lexin
>
>
Previous Topic:Extending incremental java builder
Next Topic:CVS Newbie Question: re-use information from different projects & CVS.
Goto Forum:
  


Current Time: Sat Jul 19 14:13:02 EDT 2025

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

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

Back to the top