Skip to main content


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 11:48 Go to next message
Geejay is currently offline GeejayFriend
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 13:42 Go to previous message
Geejay is currently offline GeejayFriend
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 Apr 25 22:12:41 GMT 2024

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

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

Back to the top