Java Code Examples for org.eclipse.swt.widgets.ToolItem#notifyListeners()

The following examples show how to use org.eclipse.swt.widgets.ToolItem#notifyListeners() . 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: AbapGitStagingView.java    From ADT_Frontend with MIT License 6 votes vote down vote up
/**
 * Action for switching a repository
 */
private void createRepositorySelectionToolbarAction() {
	this.actionSwitchRepository = new Action(Messages.AbapGitStaging_switch_repository, SWT.DROP_DOWN) {
		@Override
		public void runWithEvent(Event event) {
			Widget widget = event.widget;
			if (widget instanceof ToolItem) {
				ToolItem item = (ToolItem) widget;
				Rectangle bounds = item.getBounds();
				event.detail = SWT.ARROW;
				event.x = bounds.x;
				event.y = bounds.y + bounds.height;
				item.notifyListeners(SWT.Selection, event);
			}
		}
	};
	this.actionSwitchRepository
			.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(AbapGitUIPlugin.PLUGIN_ID, "icons/obj/repository.png")); //$NON-NLS-1$
	this.actionSwitchRepository.setMenuCreator(new SwitchRepositoryMenuCreator(this, this.stagingUtil));
}
 
Example 2
Source File: ExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void editControlSelected(final ToolBar tb, final Event event, final EditingDomain editingDomain) {
    boolean connectorEdit = false;
    final Expression selectedExpression = getSelectedExpression();
    if (tb != null && withConnector && selectedExpression != null
            && ExpressionConstants.CONNECTOR_TYPE.equals(selectedExpression.getType())) {
        for (final ToolItem ti : tb.getItems()) {
            final Object data = ti.getData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY);
            if (data != null && data.equals(SWTBotConstants.SWTBOT_ID_CONNECTORBUTTON)) {
                connectorEdit = true;
                ti.notifyListeners(SWT.Selection, event);
            }
        }
    }
    if (!connectorEdit) {
        final EditExpressionDialog dialog = createEditDialog();
        openEditDialog(dialog);
    }
}
 
Example 3
Source File: OpenUIDesignerCoolBarItemTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@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();
}