Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » General (non-technical) » Test » Notification of MPart close action(What is the best way to notify other MPart objects if an MPart closes?)
Notification of MPart close action [message #1401517] Tue, 15 July 2014 18:39
Gernot Krause is currently offline Gernot KrauseFriend
Messages: 22
Registered: June 2014
Junior Member
Dear community,

I am developing an E4 RCP application based on Eclipse 4.3 (Kepler) with several parts.

One part is an editor which bases on an MPartDescriptor. Beside this I have supporting parts that show details of the editor, i.e. an outline or other details. And, I have parts that show something else.

A supporting part (i.e. OutlinePart) displays information that it retrieves from the active editor part. I am using the IAdapterManager then to adapt the active parts object to an provider interface. From the provider I'll get all information I need to display in my OutlinePart. If the active part changes my OutlinePart gets notified by CI like:
@Inject
private IAdapterManager adapterMgr;

@Inject
public void setActiveProvider(@Optional @Named(IServiceConstants.ACTIVE_PART) MPart part) {
    if (part != null && part.getObject() != null) {
        IXYZProvider provider = (IXYZProvider) adapter.adapt(part.getObject(), IXYZProvider.class);
        // do something with the provider...
    }
}


So far so good, that works fine.

Now the problem:
If another part becomes active and this part has no object that can be adapted to my provider interface then the SupportPart should stay unchanged (like in the IDE if I switch from the editor to - let's say - the console, the outline does not disappear and still shows the outline of my editor).
However, if I close the editor and some other part becomes active I want to clear the outline because it then points to data that are no longer available (editor closed).

So the problem is to distinguish between "active part changes" because the user has switch to another part and "active part changes" because the editor has closed (= information provider has gone).

To solve the problem...
(i) I tried IPartListener but
1. its methods do only detect hidden and deactivate events and
2. I feel the part listeners are not called when a part closes that bases on a part descriptor (like my editor) and
2. I then had to save the Mpart instance before and compare if the deactivated/hidden part is the one I am displaying
(ii) I searched for an event topic that specifically notifies about part closures. Could not find any. Is there a dedicated topic for this?
(iii) Send an own part closure message via the event broker from the @PreDesctroy method in my editor part object. But then my outline part has to rely on the other parts to send this event. And, my 2 plugins (the one that provides the outline part and the other with the editor) both have to know the topic for this which causes coupling.

What is a good solution for this kind of communication across parts? I want to have the supporting part as generic as possible with minimum of coupling.
Or do I oversee something?
Is the use of the IAdapterManager a good idea at all?

I appreciate any help on this.

Best regards,
Gernot.
Previous Topic:Test 123
Next Topic:Hello
Goto Forum:
  


Current Time: Tue Oct 08 06:16:51 GMT 2024

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

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

Back to the top