Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 378395 - IStatusLineManager should be available from WorkbenchWindow's context
Summary: IStatusLineManager should be available from WorkbenchWindow's context
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-03 13:15 EDT by Brian de Alwis CLA
Modified: 2020-01-31 12:13 EST (History)
3 users (show)

See Also:


Attachments
context function (2.79 KB, text/plain)
2017-02-02 10:09 EST, Gunnar Wagenknecht CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brian de Alwis CLA 2012-05-03 13:15:20 EDT
Surprisingly it is not.
Comment 1 Brian de Alwis CLA 2012-05-03 13:16:42 EDT
This bug is different from bug 332499 as it is with the compatibility layer where there is an IStatusLineManager already.
Comment 2 Brian de Alwis CLA 2013-03-27 11:53:29 EDT
It's easy to expose the WorkbenchWindow's IStatusLineManager to its context.  But then any part would have direct access to the window's IStatusLineManager rather than go through the sub-manager managed by the part's IActionBars.  We could set the part's action-bar's IStatusLineManager in its context, but that could be seen to violate the spirit of the IActionBars, whose docs say:

 * A part may also contribute new actions to the action bars as required.  To do
 * this, call <code>getMenuManager</code>, <code>getToolBarManager</code>, or
 * <code>getStatusLineManager</code> as appropriate to get the action target.
 * Add the action(s) to the target and call <code>update</code> to commit
 * any changes to the underlying widgets.

The last line could be interpreted as meaning that changes are expected to be pushed using IActionBars#updateActionBars(), rather than explicitly call IStatusLineManager#update().
Comment 3 Brian de Alwis CLA 2014-03-31 16:49:58 EDT
I'm thinking that we can expose an IStatusLineManager wrapper that delegates to the underlying IStatusLineManager except for #update() which will call getActionBars().updateActionBars().
Comment 4 Gunnar Wagenknecht CLA 2017-02-01 14:53:39 EST
Brian, do you happen to know any workaround for accessing the IStatusLineManager from an e4 view running inside the workbench?
Comment 5 Brian de Alwis CLA 2017-02-01 15:49:23 EST
I should have closed this bug as WONTFIX: my original desire had been to allow background services to display information on the status, but that doesn't really fit in with the workbench policies.

But now that we support `e4view`, we should make this available via DI.

As a hack: I think you'll need to do as org.eclipse.ui.internal.ViewSite#initializeDefaultServices() and org.eclipse.ui.internal.e4.compatibility.ActionBars do:

  - get the IWorkbenchPage
  - cast to WorkbenchPage
  - call WorkbenchPage.getActionBars().getStatusLineManager()
  - build a SubStatusLineManager around it

I suppose we could do this as an IContextFunction.
Comment 6 Gunnar Wagenknecht CLA 2017-02-02 10:09:49 EST
Created attachment 266599 [details]
context function

Great tip! I've crafted together the attached context function. It looks up the required things from the context and creates a SubStatusLineManager. It uses DS annotations for easy registration with the DI system in order to allow injection of IStatusLineManager objects into parts.
Comment 7 Brian de Alwis CLA 2017-02-02 11:34:23 EST
Comment on attachment 266599 [details]
context function

Cool!  A few nits:

  - You'll want that RAT to run on the part's context, rather than the provided context (e.g., a part could have allocated multiple child contexts for its own use).
  - You should record the SubStatusLineManager in the part context (as IStatusLineManager.class) and try retrieving it (with IEclipseContext.getLocal()) to avoid creating multiple sub line managers.

We should build this into the workbench: we shouldn't need each part to have their own RAT to track the status visibility.
Comment 8 Gunnar Wagenknecht CLA 2017-02-02 13:14:24 EST
(In reply to Brian de Alwis from comment #7)
>   - You'll want that RAT to run on the part's context, rather than the
> provided context (e.g., a part could have allocated multiple child contexts
> for its own use).

That's a good point. It actually just needs to run on the context that has the active part set. Is that the part context?

>   - You should record the SubStatusLineManager in the part context (as
> IStatusLineManager.class) and try retrieving it (with
> IEclipseContext.getLocal()) to avoid creating multiple sub line managers.

Ah I wasn't aware of this. I thought the context would cache whatever I return in my ContextFunction.

> We should build this into the workbench: we shouldn't need each part to have
> their own RAT to track the status visibility.

Yes, the goal is to have that available in the workbench. Maybe this could avoid the RAT as well as the OSGi service part altogether. Happy to submit a review. Do you have a pointer to the code that deals with part activation?
Comment 9 Eclipse Genie CLA 2020-01-31 12:13:03 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.