Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Checking the type of the active editor
Checking the type of the active editor [message #327111] Thu, 10 April 2008 03:25 Go to next message
Eclipse UserFriend
Hi.

I'm trying to hook some functionality to the Java editor. For that
purpose, I'm setting up an ISelectionListener, which I'm wiring to the
WorkbenchWindow selection service.

I'm getting the selection event, which receives an IEditorPart.
The question is: how can I determine which type of editor this is?

I'm interested only in JDT CompilationUnitEditor type editors. However,
using instanceof seems wrong in this case, as CompilationUnitEditor is an
internal JDT class. So what's the proper way of doing that?

Thanks,
Zviki
Re: Checking the type of the active editor [message #327113 is a reply to message #327111] Thu, 10 April 2008 04:35 Go to previous messageGo to next message
Eclipse UserFriend
zvikico wrote:
> Hi.
>
> I'm trying to hook some functionality to the Java editor. For that
> purpose, I'm setting up an ISelectionListener, which I'm wiring to the
> WorkbenchWindow selection service.
> I'm getting the selection event, which receives an IEditorPart. The
> question is: how can I determine which type of editor this is?
> I'm interested only in JDT CompilationUnitEditor type editors.
> However, using instanceof seems wrong in this case, as
> CompilationUnitEditor is an internal JDT class. So what's the proper
> way of doing that?
Use editor.getSite().getId() and check whether it is equal to
org.eclipse.jdt.ui.JavaUI.ID_CU_EDITOR.

Dani
>
> Thanks,
> Zviki
>
Re: Checking the type of the active editor [message #327118 is a reply to message #327113] Thu, 10 April 2008 10:05 Go to previous message
Eclipse UserFriend
Works great.
Thanks for the quick response.

Zviki
Previous Topic:Re: java.lang.UnsatisfiedLinkError: no localfile_1_0_0 in java.library.path
Next Topic:Job API : scheduling examples
Goto Forum:
  


Current Time: Sat Mar 22 09:23:26 EDT 2025

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

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

Back to the top