Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 364456 - SWTBotWorkbenchPart cannot find toolbar buttons for editor
Summary: SWTBotWorkbenchPart cannot find toolbar buttons for editor
Status: NEW
Alias: None
Product: SWTBot
Classification: Technology
Component: SWTBot (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-22 07:18 EST by Tim Moore CLA
Modified: 2011-11-22 07:18 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Moore CLA 2011-11-22 07:18:22 EST
Build Identifier: M20100909-0800

SWTBotWorkbenchPart.getToolbarButtons() has the following code:
---
PartPane obj = ((WorkbenchPartReference) partReference).getPane();
ToolBar toolbar = (ToolBar) obj.getToolBar();
---

But the implementation of getToolbar for EditorPane is:
---
public Control getToolBar() {
  return null;
}
---

So obviously that can never find any. Something like this in SWTBotWorkbenchPart.getToolbarButtons() allows Editor toolbars to be accessed as well:
---
final IToolBarManager toolbarMgr;
if (partReference instanceof IEditorReference) {
  toolbarMgr = ((IEditorReference) partReference).getEditor(false).getEditorSite().getActionBars().getToolBarManager();
}
else {
  toolbarMgr = ((IViewReference) partReference).getView(false).getViewSite().getActionBars().getToolBarManager();
}
final ToolItem[] items = ((ToolBarManager) toolbarMgr).getControl().getItems();
---

No doubt there is a more succinct solution, but this does at least appear to work.

Reproducible: Always