[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.newcomer] Re: MVC philosophical question

On 9/10/09 5:14 PM, Ric Wright wrote:
I have plugin that supports physics modeling. It implements a PDE like
editor that hosts a FormEditor with multiple pages (overview, datasets,
multiple graphics views, etc.).  One can of course have several projects
open at once in different tabs, just as one can have several PDE editors
open.  However, there are several Eclipse entities that are effectively
static, e.g. I have a VCR-like control bar that allows one to
start/stop/pause the current model. But that bar implements an actionSet
through a IWorkbenchWindowActionDelegate.

Question is, what is the proper way for such a delegate to know WHICH of the
currently open editors is the active one?  At present, the editor with the
focus populates a field in the plugin's activator and the currently active
editor-object can be fetched from the delegate via a static member in the
plugin's activator.  This doesn't feel very nice to me though.

The delegate (or any component, really) can get the active editor part with a call like this:
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()


I'm not sure of the ramifications of doing that in a multi-workbench (ie, multiple windows open from the same Eclipse instance), so you should read the API docs on each of those methods.

Hope this helps,
Eric