Bug 551586 - ControlContribution.computeWidth(Control) is only called once
Summary: ControlContribution.computeWidth(Control) is only called once
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.13   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.13 M3   Edit
Assignee: Christoph Laeubrich CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 551587
Blocks:
  Show dependency tree
 
Reported: 2019-09-28 04:21 EDT by Christoph Laeubrich CLA
Modified: 2019-11-14 06:17 EST (History)
3 users (show)

See Also:


Attachments
broken egit history scope drop down (227.50 KB, image/png)
2019-11-14 03:46 EST, Andrey Loskutov CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Laeubrich CLA 2019-09-28 04:21:41 EDT
I want to place a combobox inside a ToolbarManager, this Combobox changes size over time (item added/removed), so I call toolBarManager.update(true) after each change.

The javadoc of that function states:
> Updates this manager's underlying widget(s) with 
> any changes which have been made to it or its items

So I would assume this also includes size changes...

Sadly this has no effect, because ControlContribution.computeWidth(Control) is only called one when the Toolitem is created.
Comment 1 Eclipse Genie CLA 2019-10-04 05:22:13 EDT
New Gerrit change created: https://git.eclipse.org/r/150576
Comment 2 Thomas Wolf CLA 2019-10-04 07:05:43 EDT
Does your ControlContribution return true from isDynamic()? Probably it should.
Comment 3 Christoph Laeubrich CLA 2019-10-04 07:31:10 EDT
The isDynamic() is only used/accounted for MenuContributions as far as I can see.
Comment 4 Thomas Wolf CLA 2019-10-04 07:40:25 EDT
(In reply to Christoph Laeubrich from comment #3)
> The isDynamic() is only used/accounted for MenuContributions as far as I can
> see.

Your other change from bug 551587 just made sure that ControlContributions are added to the ToolItem (via setData()), so it seems to me that https://git.eclipse.org/r/#/c/150576/1/bundles/org.eclipse.jface/src/org/eclipse/jface/action/ToolBarManager.java@298 should now apply.
Comment 5 Christoph Laeubrich CLA 2019-10-04 07:48:45 EDT
Ah I see, but thats another case, that could be used when the number/type of control changes over time, but this is not the case here, just the size of the control changes. If isDynamic would be used, then the control is disposed/created each time update is called.
Comment 6 Rolf Theunissen CLA 2019-11-10 14:33:17 EST
See also Bug 186800 comment 21, that bug seems not to be completely fixed. This but must be the leftover of that bug.

Note you should be able to call getParent().update(true) on the contribution item. However that is broken in 4.x, see Bug 426499
Comment 7 Christoph Laeubrich CLA 2019-11-11 01:23:56 EST
(In reply to Rolf Theunissen from comment #6)
> Note you should be able to call getParent().update(true) on the contribution
> item. However that is broken in 4.x, see Bug 426499

I'm currently using ToolBarManger directly, as far as I can see the parent is set correctly.
Comment 9 Andrey Loskutov CLA 2019-11-14 03:45:40 EST
(In reply to Eclipse Genie from comment #8)
> Gerrit change https://git.eclipse.org/r/150576 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?id=cf899b210fc3d5da44f06bc4790727d950143b97

This causes regression for EGit history view "Scope" drop-down.
To reproduce:
1) Open git repositories view, select any repo
2) Open History view
3) Observe that  "Scope" drop-down has no icon and is not enabled (so drop-down is not working).

Please fix regression or we should revert this patch for M3.
Comment 10 Andrey Loskutov CLA 2019-11-14 03:46:13 EST
Created attachment 280636 [details]
broken egit history scope drop down
Comment 11 Andrey Loskutov CLA 2019-11-14 04:24:16 EST
(In reply to Andrey Loskutov from comment #9)
> This causes regression for EGit history view "Scope" drop-down.
> To reproduce:
> 1) Open git repositories view, select any repo
> 2) Open History view
> 3) Observe that  "Scope" drop-down has no icon and is not enabled (so
> drop-down is not working).

Correction: expected: icon is shown, observed: nothing (blank space instead).

It is OK that drop down is disabled  for a *repository* (will be enabled for a concrete path inside).
Comment 12 Andrey Loskutov CLA 2019-11-14 04:55:46 EST
The back trace to the org.eclipse.swt.widgets.ToolItem.setDisabledImage(Image) call on ActionContributionItem holding the org.eclipse.egit.ui.internal.history.GitHistoryPage$GitHistoryPageActions$FilterAction

ToolItem.setDisabledImage(Image) line: 997	
ActionContributionItem.updateImages(boolean) line: 1012	
ActionContributionItem.updateToolItem(ToolItem, boolean, boolean, boolean, boolean, boolean) line: 778	
ActionContributionItem.update(String) line: 741	
ActionContributionItem.update() line: 714	
SubContributionItem.update() line: 136	
ToolBarManager.update(boolean) line: 337	
ActionBars.updateActionBars() line: 81	
SubActionBars.updateActionBars() line: 602	
GitHistoryPage$SearchBar.setVisible(boolean) line: 1565	
GitHistoryPage$8.run() line: 2662

So we have probably regression on SWT here (via bug 302918), uncovered by this bug.

I have a patch.
Comment 13 Christoph Laeubrich CLA 2019-11-14 05:50:15 EST
Thanks Andrew for looking into this, in general I think it is always better to fix the underlying problem instead of reverting a patch that revealed a deeper problem that previously was hidden.
Comment 14 Andrey Loskutov CLA 2019-11-14 06:17:12 EST
Marking as resolved again, bug 302918 is the one we need to be fixed.