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

Bug 294155

Summary: [ToolBar] Some toolbar items are missing when part is resized too narrowly
Product: [RT] RAP Reporter: Setya Nugdjaja <jsetya>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: 1.3   
Target Milestone: 1.3 M3   
Hardware: All   
OS: All   
Whiteboard:

Description Setya Nugdjaja CLA 2009-11-03 23:38:12 EST
Using the following snippet I can reproduce problems with contribution item when part is resized.

@Override
public void createPartControl(Composite parent)
{
  parent.setLayout(GridLayoutFactory.fillDefaults().create());
  final IToolBarManager toolbarManager = new ToolBarManager(SWT.FLAT | SWT.WRAP | SWT.HORIZONTAL);

  ToolBar toolbar = ((ToolBarManager)toolbarManager).createControl(parent);
  toolbar.setLayoutData(GridDataFactory.swtDefaults().align(SWT.END, SWT.TOP).grab(true, false).create());

 toolbarManager.add(new Separator("dynamic"));
 toolbarManager.add(new Separator("static"));
 IAction action = new Action("Add")
 {
    @Override
    public String getId(){return "action.add";}

    @Override
    public void run()
    {
        IContributionItem contributionItem = new     ControlContribution("item" + (++counter))
        {
            @Override
            protected Control createControl(Composite parent)
            {
                        parent.setLayout(GridLayoutFactory.fillDefaults().create());
                                       Text text = new Text(parent,SWT.NONE);
                 text.setLayoutData(GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.CENTER).hint(SWT.DEFAULT, 16).create());
                                               return text;
            }
        };
                       toolbarManager.appendToGroup("dynamic", contributionItem);
        toolbarManager.update(true);
        }
    };
    toolbarManager.appendToGroup("static", action);
           action = new Action("Remove")
{
    @Override
    public String getId(){return "action.remove";}

    @Override
    public void run()
    {
        if (counter == 0) return;
                       toolbarManager.remove("item" + (counter--));
        toolbarManager.update(true);
    }
};
toolbarManager.appendToGroup("static", action);
       toolbarManager.update(true);
}

Step to reproduce:

1. Add some contribution items (by clicking 'Add' action).
2. Resize part until it's not wide enough to display all the items.
3. At this point we can observe that some text boxes are missing.
4. When part is resized back, the missing text boxes are still missing.

Regards,

Setya
Comment 1 Ivan Furnadjiev CLA 2009-11-09 03:19:52 EST
Steya, I can reproduce it with your snippet. Is this working in RCP?
Comment 2 Setya Nugdjaja CLA 2009-11-09 03:41:06 EST
Hi,

Thank you for investigating.

I've just tried the snippet on RCP. It works fine there.


Regards,

Setya
Comment 3 Ivan Furnadjiev CLA 2009-11-09 05:08:33 EST
Steya, if I remove form your snippet (setting toolbar layout):
---
parent.setLayout(GridLayoutFactory.fillDefaults().create());
---
form ControlContribution#createControl() method, everything is working as expected.
Can you confirm this?
Comment 4 Ivan Furnadjiev CLA 2009-11-09 05:17:44 EST
BTW... in RAP the ToolBar does not support SWT.WRAP style.
Comment 5 Setya Nugdjaja CLA 2009-11-09 06:22:25 EST
(In reply to comment #3)
> Steya, if I remove form your snippet (setting toolbar layout):
> ---
> parent.setLayout(GridLayoutFactory.fillDefaults().create());
> ---
> form ControlContribution#createControl() method, everything is working as
> expected.
> Can you confirm this?

Yes, It works as expected if setting toolbar layout is removed.

Regards,

Setya
Comment 6 Ivan Furnadjiev CLA 2009-11-09 07:16:36 EST
Setya, what is the use case of setting ToolBar layout to GridLayout. Using the snippet above:
---
parent.setLayout(GridLayoutFactory.fillDefaults().create());
---
will create a single column grid layout. Actually in RAP when you resize the view part the GridLayout correctly positions all the ToolItem.SEPARATOR controls in one column :-) - only first is visible, rest are out of ToolBar height. I think that SWT behaves wrong in this case and the bug is invalid.
Comment 7 Ivan Furnadjiev CLA 2009-11-10 02:40:33 EST
When ToolBar is resized the ToolItem control bounds are recalculated too. Fixed in CVS HEAD.