[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform] Dispatching application-level events to Eclipse parts

Dear all

I was thinking of a mechanism for dispatching application-level event to interested Eclipse parts using the Eclipse platform.

A scenario might be the following: an FTP application with an explorer that shows different FTP connections and their content.

For example, imagine that a user selects the "connect" command on one of the connection listed in the explorer and the connection is established.

At this point it would be good to reflect this fact in all the parts that displays information about that connection.

The idea is to dispatch a sort of "connection established" event with a reference to the connection that has been established. In this way the interested listeners could, in case, decorate the icon, write in bold the connection name, update connection information, etc. in order to reflect this state change.

This mechanism is a straightforward publish-subscribe pattern with event providers and listener that can be implemented quite easily.

However I was wondering if there is already an infrastructure in the Eclipse framework that could accommodate this scenario.

The selection system might be a good candidate. When such an application-level event happens I might create a selection that contains an object that represents the application level event; something like that:

...getSelectionProvider().setSelection(new StructuredSelection(new ConnectionEstablishedEvent(ftpConnection)));

This selection change will be broadcasted to all the listeners that will, indirectly, receive also the application-level event

However, this might be an hack for something that could be achieved in a more elegant way using the Eclipse platform.

So the question is, does this elegant way exist?

Thank you.

Cheers,
Fabio