Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Editor close event and clean up of messages
Editor close event and clean up of messages [message #533887] Mon, 17 May 2010 07:48 Go to next message
Geejay is currently offline Geejay
Messages: 160
Registered: February 2010
Senior Member
Hi

I want to remove the messages when the editor that logged the messages is
closed.

I have written my own messages view, but the editor is a subclass of
MultiPageEditorPart.

What's the normal approach here? I can't find any way to catch the close
event of the editor.

Thanks

Greg
Re: Editor close event and clean up of messages [message #533926 is a reply to message #533887] Mon, 17 May 2010 09:42 Go to previous message
Geejay is currently offline Geejay
Messages: 160
Registered: February 2010
Senior Member
Ok I implemented this using:

private final IPartListener partListener = new IPartListener() {
public void partActivated(IWorkbenchPart part) {
}

public void partBroughtToTop(IWorkbenchPart part) {
}

public void partClosed(IWorkbenchPart part) {
if (part == MyEditor.this) {
messages.clear();
sendMessages();
((MyEditor) part).getActiveEditor().getSite()
.getWorkbenchWindow().getPartService()
.removePartListener(this);
}
}

public void partDeactivated(IWorkbenchPart part) {
}

public void partOpened(IWorkbenchPart part) {
}
};

Inside the editor, then registering the listener like so:

this.getSite().getWorkbenchWindow().getPartService().addPart Listener(
this.partListener);

The sendMessages() method removes all the messages related to this editor.

I used a hand coded unique string for each editor (basically using a static
editor counter) to tell which editor sent the message.

I am very open to suggestions on an eligible property that can be used to
uniquely identitfy each instance of the editor within eclipse (i.e if the
user opens two editors, of the same type, at the same time).

Cheers
Greg

"geejay" <gjmcknight@schlagundrahm.ch> wrote in message
news:hsradt$s0b$1@build.eclipse.org...
> Hi
>
> I want to remove the messages when the editor that logged the messages is
> closed.
>
> I have written my own messages view, but the editor is a subclass of
> MultiPageEditorPart.
>
> What's the normal approach here? I can't find any way to catch the close
> event of the editor.
>
> Thanks
>
> Greg
>
>
>
Previous Topic:Implementation of interactive maps
Next Topic:Refreshing View
Goto Forum:
  


Current Time: Thu Jul 31 11:33:23 EDT 2014

Powered by FUDForum. Page generated in 0.01903 seconds