user1365697
user1365697

Reputation: 6009

How to catch change in the focus of editor - TextEditor?

I create new editor that extend from TextEditor

 public class RDLEditor extends TextEditor {
 }

When I launch my program and press on the file ( file1) a new Editor is created.( like in java editor)

When I press on another file (file2) a new file is created.( in new tab )

Now I have two files that are exist as tabs ( file1,file2).

I want to add some logic when I change the focus of one file to another file.

Which event from TextEditor I can catch for the change of the focus ?

Upvotes: 0

Views: 94

Answers (1)

greg-449
greg-449

Reputation: 111217

Use org.eclipse.ui.IPartListener to listen for parts becoming active.

Set this up with something like:

PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPartListener(listener);

among other methods the part listener has:

public void partActivated(IWorkbenchPart part)

which will be called when any part is activated. You will need to check the part parameter matches your editor instances.

Upvotes: 1

Related Questions