Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Plugin to open file in eclipse java editor
Plugin to open file in eclipse java editor [message #148087] Wed, 10 March 2004 15:50 Go to next message
Eclipse UserFriend
Originally posted by: ricardo.qualiti.com.br

I need to develop a plugin that opens a file in eclipse java editor given
its file path. Does anybody know anything about it? Thanks
Re: Plugin to open file in eclipse java editor [message #150029 is a reply to message #148087] Sat, 20 March 2004 18:10 Go to previous message
Eclipse UserFriend
Originally posted by: lord.of.board.gmx.de

Maybe this code will help you:

//
// get default editor descriptor
//
IEditorRegistry editorRegistry =3D =

WorkbenchPlugin.getDefault().getEditorRegistry();
IEditorDescriptor defaultEditorDescriptor =3D =

editorRegistry.getDefaultEditor(file.toString());
//// || defaultEditorDescriptor.isOpenExternal() is only eclips=
e =

3.x!!!
if( defaultEditorDescriptor =3D=3D null){
defaultEditorDescriptor =3D =

editorRegistry.getDefaultEditor("dummy.txt");
}

// Open new file in editor
IWorkbenchWindow dw =3D getWorkbench().getActiveWorkbenchWindow();
FileEditorInput fileEditorInput =3D new FileEditorInput(file);
try {
IWorkbenchPage page =3D dw.getActivePage();
if (page !=3D null)
//page.openEditor(fileEditorInput,"org.eclipse.ui.Defau=
ltTextEditor");
page.openEditor(fileEditorInput, =

defaultEditorDescriptor.getId() );
} catch (PartInitException e) {
DialogUtil.openError(dw.getShell(), "Could not open new fil=
e",
e.getMessage(), e);
}

The code will open every file in it's corresponding editor

> I need to develop a plugin that opens a file in eclipse java editor gi=
ven
> its file path. Does anybody know anything about it? Thanks
>
Previous Topic:"java.net.ConnectException" when trying to run JUnit test
Next Topic:3.0M7 cvs passwords lost
Goto Forum:
  


Current Time: Tue Sep 16 04:27:51 EDT 2025

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

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

Back to the top