Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Open Java Editor
Open Java Editor [message #499374] Sat, 21 November 2009 15:03 Go to next message
Vanessa Aline is currently offline Vanessa AlineFriend
Messages: 11
Registered: July 2009
Junior Member
Hello,

I want to open a Java Editor with a given file. But I only got an
Default Text Editor. How can I get the Java Editor ID?

I am doing this:
if (workspaceResource instanceof IFile) {
IWorkbenchPage page = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
return null != page.openEditor(new FileEditorInput(
(IFile) workspaceResource), "org.eclipse.ui.DefaultTextEditor");
}


Thanks in advance,
--
Vanessa Aline
Re: Open Java Editor [message #499377 is a reply to message #499374] Sat, 21 November 2009 15:46 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hi,

as you precise to open with "org.eclipse.ui.DefaultTextEditor", that is normal that it is open with default text editor...

Several solutions :
- IDE.openEditor(...)
- page.openEditor but with the correct id of the java editor (which is
org.eclipse.jdt.ui.CompilationUnitEditor, thanks to plugin spy)

Regards,

Aurelien Pupier


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: Open Java Editor [message #499383 is a reply to message #499374] Sat, 21 November 2009 15:52 Go to previous message
Vanessa Aline is currently offline Vanessa AlineFriend
Messages: 11
Registered: July 2009
Junior Member
I got it to work, usingt his:

IEditorDescriptor javaDescriptor = PlatformUI.getWorkbench().
getEditorRegistry().getDefaultEditor(workspaceResource.getNa me());
return null != page.openEditor(new FileEditorInput(
(IFile) workspaceResource), javaDescriptor.getId());


Thanks

Vanessa Aline escreveu:
> Hello,
>
> I want to open a Java Editor with a given file. But I only got an
> Default Text Editor. How can I get the Java Editor ID?
>
> I am doing this:
> if (workspaceResource instanceof IFile) {
> IWorkbenchPage page = PlatformUI.getWorkbench()
> .getActiveWorkbenchWindow().getActivePage();
> return null != page.openEditor(new FileEditorInput(
> (IFile) workspaceResource), "org.eclipse.ui.DefaultTextEditor");
> }
>
>
> Thanks in advance,
> --
> Vanessa Aline
Re: Open Java Editor [message #603481 is a reply to message #499374] Sat, 21 November 2009 15:46 Go to previous message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hi,

as you precise to open with "org.eclipse.ui.DefaultTextEditor", that is normal that it is open with default text editor...

Several solutions :
- IDE.openEditor(...)
- page.openEditor but with the correct id of the java editor (which is
org.eclipse.jdt.ui.CompilationUnitEditor, thanks to plugin spy)

Regards,

Aurelien Pupier


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: Open Java Editor [message #603486 is a reply to message #499374] Sat, 21 November 2009 15:52 Go to previous message
Vanessa Aline is currently offline Vanessa AlineFriend
Messages: 11
Registered: July 2009
Junior Member
I got it to work, usingt his:

IEditorDescriptor javaDescriptor = PlatformUI.getWorkbench().
getEditorRegistry().getDefaultEditor(workspaceResource.getNa me());
return null != page.openEditor(new FileEditorInput(
(IFile) workspaceResource), javaDescriptor.getId());


Thanks

Vanessa Aline escreveu:
> Hello,
>
> I want to open a Java Editor with a given file. But I only got an
> Default Text Editor. How can I get the Java Editor ID?
>
> I am doing this:
> if (workspaceResource instanceof IFile) {
> IWorkbenchPage page = PlatformUI.getWorkbench()
> .getActiveWorkbenchWindow().getActivePage();
> return null != page.openEditor(new FileEditorInput(
> (IFile) workspaceResource), "org.eclipse.ui.DefaultTextEditor");
> }
>
>
> Thanks in advance,
> --
> Vanessa Aline
Previous Topic:Open Java Editor
Next Topic:Hooking into IWorkbenchPage.closeEditors
Goto Forum:
  


Current Time: Mon Aug 03 09:48:55 GMT 2020

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

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

Back to the top