Java Code Examples for org.eclipse.swt.widgets.ToolBar#getItem()
The following examples show how to use
org.eclipse.swt.widgets.ToolBar#getItem() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenUIDesignerCoolBarItemTest.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Test public void call_open_ui_designer_command_on_selection() throws Exception { final OpenUIDesignerCoolBarItem openUIDesignerCoolBarItem = spy(new OpenUIDesignerCoolBarItem()); doReturn(openDesignerHandler).when(openUIDesignerCoolBarItem).getHandler(); doReturn(prefStore).when(openUIDesignerCoolBarItem).getPreferenceStore(); doReturn(eclipsePref).when(openUIDesignerCoolBarItem).getEclipsePreferences(); doReturn(true).when(eclipsePref).getBoolean(eq(OpenUIDesignerCoolBarItem.HIDE_UIDESIGNER_INFO_DIALOG), anyBoolean()); final Shell shell = realmWithDisplay.getShell(); doReturn(shell).when(openUIDesignerCoolBarItem).getShell(); final ToolBar toolbar = new ToolBar(realmWithDisplay.createComposite(), SWT.NONE); openUIDesignerCoolBarItem.fill(toolbar, 0, -1); final ToolItem toolItem = toolbar.getItem(0); toolItem.notifyListeners(SWT.Selection, new Event()); verify(openDesignerHandler).execute(); }
Example 2
Source File: CustomToolItem.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public void createControl(Composite parent, CoolbarSize size) { if (contributionItem instanceof SeparatorCoolbarItem) { Label separator = new Label(parent, SWT.SEPARATOR); separator.setLayoutData(GridDataFactory.fillDefaults() .hint(SWT.DEFAULT, size == CoolbarSize.SMALL ? ICON_SIZE : SWT.DEFAULT).create()); } else { Composite container = new Composite(parent, SWT.NONE); container.setLayoutData(GridDataFactory.swtDefaults().create()); container.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 3) .extendedMargins(0, 0, 0, size != CoolbarSize.SMALL ? 5 : 0).create()); ToolBar tb = new ToolBar(container, SWT.FLAT | SWT.HORIZONTAL); tb.setLayoutData(GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.FILL).grab(true, true).create()); contributionItem.fill(tb, -1, size == CoolbarSize.SMALL ? ICON_SIZE : -1); toolItem = tb.getItem(0); if (size != CoolbarSize.SMALL) { text = new Label(container, SWT.CENTER); text.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); text.setText(contributionItem.getText()); } update(); } }
Example 3
Source File: OpenUIDesignerCoolBarItemTest.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Test public void create_a_toolItem_to_open_ui_designer() throws Exception { final OpenUIDesignerCoolBarItem openUIDesignerCoolBarItem = new OpenUIDesignerCoolBarItem(); final ToolBar toolbar = new ToolBar(realmWithDisplay.createComposite(), SWT.NONE); openUIDesignerCoolBarItem.fill(toolbar, 0, -1); assertThat(toolbar.getItemCount()).isEqualTo(1); final ToolItem toolItem = toolbar.getItem(0); assertThat(openUIDesignerCoolBarItem.getText()).isEqualTo(Messages.uiDesignerLabel); }
Example 4
Source File: LaborOrderPulldownMenuCreator.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
/** * Pulldown menu wird anhand selection angepasst * * @param parent * @param action * @param image */ private void select(final Control parent, final IAction action, final Image image){ if (parent instanceof ToolBar) { ToolBar toolBar = (ToolBar) parent; if (toolBar.getItemCount() > 0) { ToolItem toolItem = toolBar.getItem(0); toolItem.setImage(image); toolItem.setHotImage(image); toolItem.setToolTipText(action.getToolTipText()); this.selectedAction = action; CoreHub.localCfg.set(LAB_ORDER_SELECTED_ACTION_ID, this.selectedAction.getId()); } } }