| Summary: | [Toolbar] Index not considered when adding items afterwards | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [RT] RAP | Reporter: | Setya Nugdjaja <jsetya> | ||||
| Component: | JFace | Assignee: | Project Inbox <rap-inbox> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | ||||||
| Version: | 1.2 | ||||||
| Target Milestone: | 1.3 M1 | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 143856 [details] patch+testcase We always add new ToolItems at the end of the toolbar without looking at the index. This works when we initially set up the toolbar but fails when adding items dynamically with an index != itemlength. Waiting with the patch until bug 286073 is resolved. Ralf, do you think this is worth to backport to SR121? This has been fixed for 1.3 M1 in CVS HEAD. If we really backport this to SR121 we should also think about backporting bug 286179 |
Hi all, When adding toolbar item at runtime it's always placed last. Here's the snippet to reproduce the problem: @Override public void createPartControl(Composite parent) { parent.setLayout(GridLayoutFactory.fillDefaults().create()); toolkit = new FormToolkit(parent.getDisplay()); toolkit.adapt(parent); 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()); toolkit.adapt(toolbar, false, false); toolbarManager.add(new Separator("dynamic")); toolbarManager.add(new Separator("static")); final IAction dynamicAction = new Action("Dynamic") { @Override public String getId(){return "action.dynamic";} }; toolbarManager.appendToGroup("dynamic", dynamicAction); IAction action = new Action("Add") { @Override public String getId(){return "action.add";} @Override public void run() { if (toolbarManager.find("action.dynamic") != null) return; toolbarManager.appendToGroup("dynamic", dynamicAction); toolbarManager.update(true); } }; toolbarManager.appendToGroup("static", action); action = new Action("Remove") { @Override public String getId(){return "action.remove";} @Override public void run() { toolbarManager.remove("action.dynamic"); toolbarManager.update(true); } }; toolbarManager.appendToGroup("static", action); toolbarManager.update(true); } Using above snippets just click 'Remove' then 'Add' and you'll see that the 'Dynamic' button is always placed last. I've tried above snippet in RCP and it worked fine. Best Regards, Setya