Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 368466

Summary: [Contributions] Part toolbar does not refresh after adding or removing items to it
Product: [Eclipse Project] Platform Reporter: Josh Davis <josh.davis>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: andreix, ben.cox, bsd, christian.pontesegger, cidhawk, cwiscount, daniel_megert, dirk.fauth, emoffatt, john.palof, ledina.hido, markus.kell.r, nobody, pwebster, remy.suen, rollsisu, rouven.mueck
Version: 4.2.1   
Target Milestone: ---   
Hardware: All   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=550268
Whiteboard: stalebug
Attachments:
Description Flags
Simple project to reproduce the bug
none
Small project for visible state refresh not working
none
Sample application with toolbar on non-modal dialog none

Description Josh Davis CLA 2012-01-12 11:30:40 EST
Created attachment 209389 [details]
Simple project to reproduce the bug

I have attached a sample project to show this bug.

In order to reproduce do the following
1) Enter text in the text box and press add button, this will add the first button which will have space to display (Unless you set the text of button to a long string, in my tests I used the label of "1")
2) Enter some different text in the text box and press add button (this button will not be shown, in my tests I used a label of "2")

To force it to render, minimize the part and then restore it. The second button added will be displayed in the part toolbar.

This was also mentioned in the follow forum:
http://www.eclipse.org/forums/index.php/mv/msg/266040/775705/#msg_775705
Comment 1 Josh Davis CLA 2012-01-31 17:10:39 EST
I have also found that this issue also exists when removing a tool or menu item.  The render is not properly resizing the toolbar or menu
Comment 2 Eric Moffatt CLA 2012-02-08 16:02:24 EST
This is almost certainly a layout issue; we're simply not causing the CTabFolder to re-calculate its layout once the toolbar changes its items.

Wherever we're calling the TBManager's 'update' we should likely be adding some layout code. At least the TB should be 'packed', we could (maybe already do) listen for size changes to the TB in the Stack renderer (which is the one that 'knows' the TB is should as part of a CTabFolder...
Comment 3 Remy Suen CLA 2012-03-02 14:37:41 EST
Fix pushed to master.
http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=37b3b45c0a81ec12e49aa9dec1bc2e63696a12c3

Thanks for the bug report, Josh. Sorry it took us a while to get this fixed. Please do not hesitate to let us know if you find other problems with Eclipse.
Comment 4 Remy Suen CLA 2012-03-13 09:24:21 EDT
Verified by source code inspection with I20120312-1730.
Comment 5 Josh Davis CLA 2012-03-16 14:16:48 EDT
(In reply to comment #4)
> Verified by source code inspection with I20120312-1730.

I am trying to test this fix locally and I can't get it to work

What I did was download eclipse-4.2-I20120314-2200-repository
and am using those jars in my target

There are two swt renderer jars in that repository
0.10.0.v20120314-1758
0.10.100.201203160704

If I use 0314 the bug is not fixed.
If I use 201203160704 I get java.lang.ClassNotFoundException: org.eclipse.e4.ui.internal.workbench.renderers.swt.IUpdateService

I saw you verified this on 3/13 and it appears the code was moved to the master so I am assumed the fix would be in the 20120314 repo. Is that correct?
Comment 6 Remy Suen CLA 2012-03-16 14:22:17 EDT
(In reply to comment #5)
> I am trying to test this fix locally and I can't get it to work

I unzipped I20120315-1300 and imported your project and it worked for me. Does this work for you?
Comment 7 Josh Davis CLA 2012-03-16 15:19:15 EDT
(In reply to comment #6)
> (In reply to comment #5)
> > I am trying to test this fix locally and I can't get it to work
> 
> I unzipped I20120315-1300 and imported your project and it worked for me. Does
> this work for you?

I  think problem is I don't know how to properly install the integration build. I am trying to find documentation on how to do it, and will try again.
Comment 8 Josh Davis CLA 2012-03-16 15:26:19 EDT
(In reply to comment #7)
> (In reply to comment #6)
> > (In reply to comment #5)
> > > I am trying to test this fix locally and I can't get it to work
> > 
> > I unzipped I20120315-1300 and imported your project and it worked for me. Does
> > this work for you?
> 
> I  think problem is I don't know how to properly install the integration build.
> I am trying to find documentation on how to do it, and will try again.

I figured it out and got it working.
Comment 9 Dirk Fauth CLA 2012-10-30 08:37:17 EDT
It worked with 4.2 but is broken again in 4.2.1
Comment 10 Ben Roling CLA 2012-11-06 13:33:48 EST
(In reply to comment #9)
> It worked with 4.2 but is broken again in 4.2.1

I'm a little confused.  The specific case tested by Josh's sample project seems to work for me in both 4.2.0 and 4.2.1.

The case of removing toolbar items as mentioned in comment 1 seems to be broken in both 4.2.0 and 4.2.1.  To test that case I just used Josh's example project and added another button that does the following:

mPart.getToolbar().getChildren().remove(mPart.getToolbar().getChildren().get(0));

When I do that I don't see the toolbar button go away.

Dirk - which case is it that you were referring to?
Comment 11 Dirk Fauth CLA 2012-11-08 03:39:01 EST
Created attachment 223334 [details]
Small project for visible state refresh not working
Comment 12 Dirk Fauth CLA 2012-11-08 03:44:05 EST
Hi Ben,

you are right, removing the button doesn't work in both cases. What worked in 4.2.0 is the refresh of the toolbar when changing the visible state of a toolbar item. This doesn't work with 4.2.1 anymore. I added a small project showing that case.

@Paul
If you are running the example on Windows, this example should also show Bug 391741. Not sure how it behaves on other OS.
Comment 13 Markus Keller CLA 2014-01-13 06:21:46 EST
Bug 409008 is a similar scenario.
Comment 14 Chris Boerger CLA 2015-01-12 12:16:39 EST
Created attachment 249871 [details]
Sample application with toolbar on non-modal dialog
Comment 15 Chris Boerger CLA 2015-01-12 12:19:00 EST
I am seeing the same issue with a toolbar on a non-modal dialog in 4.4.

This sample app uses a source provider (provides selection from a list in the dialog) to enable a toolbar contribution.

The toolbar contribution on the dialog will not refresh unless the user moves focus over to the main application window.
Comment 16 Dani Megert CLA 2015-08-12 07:49:58 EDT
Can also bee seen in the Search view, see bug 474787.
Comment 17 Dani Megert CLA 2015-08-12 07:50:13 EDT
*** Bug 474787 has been marked as a duplicate of this bug. ***
Comment 18 Lars Vogel CLA 2016-04-20 12:17:05 EDT
Mass move to 4.7 as M7 is approaching. Please move back in case you are planning to fix it for Neon.
Comment 19 Ledina Hido-Evans CLA 2017-10-10 05:40:55 EDT
Still seeing this issue in 4.6.3. See Bug 525775
Comment 20 Christian Pontesegger CLA 2019-08-20 07:07:23 EDT
*** Bug 511519 has been marked as a duplicate of this bug. ***
Comment 21 Eclipse Genie CLA 2021-08-10 02:33:13 EDT
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.