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

The following examples show how to use org.eclipse.swt.widgets.ToolItem#setData() . 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: QueryEditionControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createToolbar(Composite parent) {
    ToolBar toolBar = new ToolBar(parent, SWT.HORIZONTAL | SWT.LEFT | SWT.NO_FOCUS | SWT.FLAT);
    formPage.getToolkit().adapt(toolBar);

    ToolItem addQueryItem = new ToolItem(toolBar, SWT.PUSH);
    addQueryItem.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ADD_QUERY_BUTTON_ID);
    addQueryItem.setImage(BusinessObjectPlugin.getImage("/icons/add.png"));
    addQueryItem.setToolTipText(Messages.addQueryTooltip);
    addQueryItem.addListener(SWT.Selection, e -> addQuery());

    deleteQueryItem = new ToolItem(toolBar, SWT.PUSH);
    deleteQueryItem.setImage(BusinessObjectPlugin.getImage("/icons/delete_icon.png"));
    deleteQueryItem.setToolTipText(Messages.deleteQueryTooltip);
    deleteQueryItem.addListener(SWT.Selection, e -> removeQuery());

    ToolItem expandItem = new ToolItem(toolBar, SWT.PUSH);
    expandItem.setImage(Pics.getImage(PicsConstants.expandAll));
    expandItem.setToolTipText(Messages.expandAll);
    expandItem.addListener(SWT.Selection, e -> viewer.expandAll());

    ToolItem collapseItem = new ToolItem(toolBar, SWT.PUSH);
    collapseItem.setImage(Pics.getImage(PicsConstants.collapseAll));
    collapseItem.setToolTipText(Messages.collapseAll);
    collapseItem.addListener(SWT.Selection, e -> viewer.collapseAll());
}
 
Example 2
Source File: DeployCoolbarItem.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void fill(final ToolBar toolbar, final int index, final int iconSize) {
    item = new ToolItem(toolbar, SWT.PUSH);
    item.setToolTipText(Messages.DeployButtonLabel);
    item.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_DEPLOY_TOOLITEM);
    if (iconSize < 0) {
        item.setImage(Pics.getImage("deploy48.png", ApplicationPlugin.getDefault()));
    } else {
        item.setImage(Pics.getImage("deploy24.png", ApplicationPlugin.getDefault()));
    }
    item.setEnabled(false);
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            final Command cmd = getCommand();
            try {
                cmd.executeWithChecks(new ExecutionEvent());
            } catch (final Exception ex) {
                BonitaStudioLog.error(ex);
            }
        }
    });
}
 
Example 3
Source File: ExportBarCoolbarItem.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void fill(final ToolBar toolbar, final int index, final int iconSize) {
    final ToolItem item = new ToolItem(toolbar, SWT.PUSH);
    item.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_EXPORT_TOOLITEM);
    item.setToolTipText(Messages.ExportButtonLabel);
    if (iconSize < 0) {
        item.setImage(Pics.getImage(PicsConstants.coolbar_export_48));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_export_disabled_48));
    } else {
        item.setImage(Pics.getImage(PicsConstants.coolbar_export_16));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_export_disabled_16));
    }
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            final Command cmd = getCommand();
            try {
                cmd.executeWithChecks(new ExecutionEvent());
            } catch (final Exception ex) {
                BonitaStudioLog.error(ex);
            }
        }
    });

}
 
Example 4
Source File: ConfigureCoolbarItem.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void fill(final ToolBar toolbar, final int index, final int iconSize) {
    final ToolItem item = new ToolItem(toolbar, SWT.PUSH);
    item.setToolTipText(Messages.ConfigureButtonLabel);
    item.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_CONFIGURE_TOOLITEM);
    if (iconSize < 0) {
        item.setImage(Pics.getImage(PicsConstants.coolbar_configure_48));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_configure_disabled_48));
    } else {
        item.setImage(Pics.getImage(PicsConstants.coolbar_configure_16));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_configure_disabled_16));
    }
    item.setEnabled(false);
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            final Command cmd = getCommand();
            try {
                cmd.executeWithChecks(new ExecutionEvent());
            } catch (final Exception ex) {
                BonitaStudioLog.error(ex);
            }
        }
    });
}
 
Example 5
Source File: BusinessObjectList.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void createAddDeleteItems(AbstractBdmFormPage formPage, ToolBar toolBar) {
    addPackageItem = new ToolItem(toolBar, SWT.PUSH);
    addPackageItem.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ADD_PACKAGE_BUTTON_ID);
    addPackageItem.setImage(BusinessObjectPlugin.getImage("/icons/addPackageIcon.png"));
    addPackageItem.setToolTipText(Messages.createPackageTooltip);
    addPackageItem.addListener(SWT.Selection, e -> addPackage(formPage));

    addBoItem = new ToolItem(toolBar, SWT.PUSH);
    addBoItem.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ADD_BO_BUTTON_ID);
    addBoItem.setImage(BusinessObjectPlugin.getImage("/icons/addObjectIcon.png"));
    addBoItem.setToolTipText(Messages.createBoTooltip);
    addBoItem.addListener(SWT.Selection, e -> addBusinessObject(formPage));

    deleteItem = new ToolItem(toolBar, SWT.PUSH);
    deleteItem.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, REMOVE_BUTTON_ID);
    deleteItem.setImage(BusinessObjectPlugin.getImage("/icons/delete_icon.png"));
    deleteItem.setToolTipText(Messages.deleteTooltip);
    deleteItem.addListener(SWT.Selection, e -> remove(formPage));
}
 
Example 6
Source File: QueryDetailsControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createToolbar(Composite parent) {
    ToolBar toolBar = new ToolBar(parent, SWT.HORIZONTAL | SWT.LEFT | SWT.NO_FOCUS | SWT.FLAT);
    formPage.getToolkit().adapt(toolBar);

    addParameterItem = new ToolItem(toolBar, SWT.PUSH);
    addParameterItem.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ADD_PARAM_BUTTON_ID);
    addParameterItem.setImage(BusinessObjectPlugin.getImage("/icons/add.png"));
    addParameterItem.setToolTipText(Messages.addParameterTooltip);
    addParameterItem.addListener(SWT.Selection, e -> addParameter());

    deleteParameterItem = new ToolItem(toolBar, SWT.PUSH);
    deleteParameterItem.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, REMOVE_PARAM_BUTTON_ID);
    deleteParameterItem.setImage(BusinessObjectPlugin.getImage("/icons/delete_icon.png"));
    deleteParameterItem.setToolTipText(Messages.deleteParameterTooltip);
    deleteParameterItem.addListener(SWT.Selection, e -> removeParameter());
}
 
Example 7
Source File: AttributeEditionControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createToolbar(Composite parent) {
    ToolBar toolBar = new ToolBar(parent, SWT.HORIZONTAL | SWT.LEFT | SWT.NO_FOCUS | SWT.FLAT);
    formPage.getToolkit().adapt(toolBar);

    ToolItem addFieldItem = new ToolItem(toolBar, SWT.PUSH);
    addFieldItem.setImage(BusinessObjectPlugin.getImage("/icons/add.png"));
    addFieldItem.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ADD_ATTRIBUTE_BUTTON_ID);
    addFieldItem.setToolTipText(Messages.addFieldTooltip);
    addFieldItem.addListener(SWT.Selection, e -> addAttribute());

    deleteFieldItem = new ToolItem(toolBar, SWT.PUSH);
    deleteFieldItem.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, REMOVE_ATTRIBUTE_BUTTON_ID);
    deleteFieldItem.setImage(BusinessObjectPlugin.getImage("/icons/delete_icon.png"));
    deleteFieldItem.setToolTipText(Messages.deleteFieldTooltip);
    deleteFieldItem.addListener(SWT.Selection, e -> removeSelectedAttribute());

    upFieldItem = new ToolItem(toolBar, SWT.PUSH);
    upFieldItem.setImage(BusinessObjectPlugin.getImage("/icons/up.png"));
    upFieldItem.setToolTipText(Messages.up);
    upFieldItem.addListener(SWT.Selection, e -> upSelectedAttribute());

    downFieldItem = new ToolItem(toolBar, SWT.PUSH);
    downFieldItem.setImage(BusinessObjectPlugin.getImage("/icons/down.png"));
    downFieldItem.setToolTipText(Messages.down);
    downFieldItem.addListener(SWT.Selection, e -> downSelectedAttribute());
}
 
Example 8
Source File: ExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected ToolItem createEraseToolItem(final ToolBar tb) {
    eraseControl = new ToolItem(tb, SWT.PUSH | SWT.NO_FOCUS);
    eraseControl.setImage(Pics.getImage(PicsConstants.clear));
    eraseControl.setToolTipText(Messages.eraseExpression);

    /* For test purpose */
    eraseControl.setData(SWTBOT_WIDGET_ID_KEY, SWTBOT_ID_ERASEBUTTON);
    eraseControl.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event event) {
            erase(getSelectedExpression());
        }

    });

    eraseControl.addDisposeListener(disposeListener);
    return eraseControl;
}
 
Example 9
Source File: ExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected ToolItem createEditToolItem(final ToolBar tb) {
    final ToolItem editControl = new ToolItem(tb, SWT.PUSH | SWT.NO_FOCUS);
    editControl.setImage(Pics.getImage(PicsConstants.edit));
    editControl.setToolTipText(Messages.editAndContinue);

    /* For test purpose */
    editControl.setData(SWTBOT_WIDGET_ID_KEY, SWTBOT_ID_EDITBUTTON);
    editControl.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event event) {
            editControlSelected(tb, event, getEditingDomain());
        }

    });

    editControl.addDisposeListener(disposeListener);
    return editControl;
}
 
Example 10
Source File: TextWidget.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void edit(ToolBar toolBar) {
    Stream.of(toolBar.getItems()).forEach(ToolItem::dispose);
    updateEditableState(true);

    final ToolItem cancelButton = new ToolItem(toolBar, SWT.FLAT);
    cancelButton.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY,
            SWTBotConstants.SWTBOT_ID_TRANSACTIONAL_TEXT_CANCEL_BUTTON);
    cancelButton.setImage(ImageDescriptor.createFromFile(TextWidget.class, "error.png").createImage());
    cancelButton.setToolTipText(Messages.revertEdit);
    cancelButton.addListener(SWT.Selection, cancelListener(toolBar));
    cancelButton.addListener(SWT.Dispose, event -> cancelButton.getImage().dispose());

    okButton = new ToolItem(toolBar, SWT.FLAT);
    okButton.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY,
            SWTBotConstants.SWTBOT_ID_TRANSACTIONAL_TEXT_OK_BUTTON);
    okButton.setImage(ImageDescriptor.createFromFile(TextWidget.class, "checked.png").createImage());
    okButton.setToolTipText(Messages.applyEdit);
    okButton.addListener(SWT.Selection, okListener(toolBar));
    okButton.addListener(SWT.Dispose, event -> okButton.getImage().dispose());

    toolBar.getParent().layout();

    text.setFocus();
}
 
Example 11
Source File: ImportBarCoolbarItem.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void fill(final ToolBar toolbar, final int index, final int iconSize) {
    final ToolItem item = new ToolItem(toolbar, SWT.PUSH);
    item.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_IMPORT_TOOLITEM);
    item.setToolTipText(Messages.ImportProcessButtonLabel);
    if (iconSize < 0) {
        item.setImage(Pics.getImage(PicsConstants.coolbar_import_48));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_import_disabled_48));
    } else {
        item.setImage(Pics.getImage(PicsConstants.coolbar_import_16));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_import_disabled_16));
    }
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
                ECommandService eCommandService = PlatformUI.getWorkbench().getService(ECommandService.class);
                EHandlerService eHandlerService = PlatformUI.getWorkbench().getService(EHandlerService.class);
                ParameterizedCommand importCommand = ParameterizedCommand.generateCommand(
                        eCommandService.getCommand("org.bonitasoft.studio.importer.bos.command"), null);
                eHandlerService.executeHandler(importCommand);
        }
    });

}
 
Example 12
Source File: ConstraintEditionControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createToolbar(Composite parent) {
    ToolBar toolBar = new ToolBar(parent, SWT.HORIZONTAL | SWT.LEFT | SWT.NO_FOCUS | SWT.FLAT);
    formPage.getToolkit().adapt(toolBar);

    ToolItem addConstraintItem = new ToolItem(toolBar, SWT.PUSH);
    addConstraintItem.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ADD_CONSTRAINT_BUTTON_ID);
    addConstraintItem.setImage(BusinessObjectPlugin.getImage("/icons/add.png"));
    addConstraintItem.setToolTipText(Messages.addConstraintTooltip);
    addConstraintItem.addListener(SWT.Selection, e -> addUniqueConstraint());

    deleteConstraintItem = new ToolItem(toolBar, SWT.PUSH);
    deleteConstraintItem.setImage(BusinessObjectPlugin.getImage("/icons/delete_icon.png"));
    deleteConstraintItem.setToolTipText(Messages.deleteConstraintTooltip);
    deleteConstraintItem.addListener(SWT.Selection, e -> removeSelectedConstraint());
}
 
Example 13
Source File: SaveCoolbarItem.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void fill(final ToolBar toolbar, final int index, final int iconSize) {
    item = new ToolItem(toolbar, SWT.PUSH);
    item.setToolTipText(Messages.SaveProcessButtonLabel);
    item.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_SAVE_EDITOR);
    if (iconSize < 0) {
        item.setImage(Pics.getImage(PicsConstants.coolbar_save_48));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_save_disabled_48));
    } else {
        item.setImage(Pics.getImage(PicsConstants.coolbar_save_16));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_save_disabled_16));
    }
    item.setEnabled(false);
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            final IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
                    .getActiveEditor();
            if (editor != null) {
                if (editor instanceof DiagramEditor) {
                    final IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
                            .getService(IHandlerService.class);
                    final Command command = getCommand();
                    final ExecutionEvent executionEvent = new ExecutionEvent(command, Collections.EMPTY_MAP, null,
                            handlerService.getClass());
                    try {
                        command.executeWithChecks(executionEvent);
                    } catch (final Exception e1) {
                        BonitaStudioLog.error(e1);
                    }

                } else {
                    editor.doSave(null);
                }
            }
        }
    });
}
 
Example 14
Source File: IndexControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createToolbar(Composite parent) {
    ToolBar toolBar = new ToolBar(parent, SWT.HORIZONTAL | SWT.LEFT | SWT.NO_FOCUS | SWT.FLAT);
    formPage.getToolkit().adapt(toolBar);

    ToolItem addIndexItem = new ToolItem(toolBar, SWT.PUSH);
    addIndexItem.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ADD_INDEX_BUTTON_ID);
    addIndexItem.setImage(BusinessObjectPlugin.getImage("/icons/add.png"));
    addIndexItem.setToolTipText(Messages.addIndexTooltip);
    addIndexItem.addListener(SWT.Selection, e -> addIndex());

    deleteIndexItem = new ToolItem(toolBar, SWT.PUSH);
    deleteIndexItem.setImage(BusinessObjectPlugin.getImage("/icons/delete_icon.png"));
    deleteIndexItem.setToolTipText(Messages.deleteIndexTooltip);
    deleteIndexItem.addListener(SWT.Selection, e -> removeIndex());
}
 
Example 15
Source File: ValidateContributionItem.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void fill(ToolBar parent, int index) {
    item = new ToolItem(parent, SWT.PUSH);
    item.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ID);
    item.setText(Messages.validate);
    item.setToolTipText(Messages.validateTooltip);
    item.setImage(BusinessObjectPlugin.getImage("icons/validate.png"));
    item.addListener(SWT.Selection, e -> validate());
    item.setEnabled(true);
}
 
Example 16
Source File: DeployContributionItem.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void fill(ToolBar parent, int index) {
    item = new ToolItem(parent, SWT.PUSH);
    item.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ID);
    item.setText(Messages.deploy);
    item.setToolTipText(Messages.deploy);
    item.setImage(BusinessObjectPlugin.getImage("icons/deploy16.png"));
    item.addListener(SWT.Selection, event -> deploy(false));
    item.setEnabled(isEnabled());
}
 
Example 17
Source File: ExploreBDMContributionItem.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void fill(ToolBar parent, int index) {
    item = new ToolItem(parent, SWT.PUSH);
    item.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ID);
    item.setText(Messages.explore);
    item.setToolTipText(Messages.exploreTooltip);
    item.setImage(BusinessObjectPlugin.getImage("icons/wen.png"));
    item.addListener(SWT.Selection, event -> commandExecutor.executeCommand(EXPLORE_BDM_COMMAND, null));
    item.setEnabled(isEnabled());
}
 
Example 18
Source File: TextWidget.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createEditItem(final ToolBar toolBar) {
    final ToolItem editButton = new ToolItem(toolBar, SWT.FLAT);
    editButton.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY,
            SWTBotConstants.SWTBOT_ID_TRANSACTIONAL_TEXT_EDIT_BUTTON);
    editButton.setImage(ImageDescriptor.createFromFile(TextWidget.class, "edit.png").createImage());
    editButton.addListener(SWT.Dispose, event -> editButton.getImage().dispose());
    editButton.setToolTipText(Messages.edit);
    editButton.addListener(SWT.Selection, editListener(toolBar));
}
 
Example 19
Source File: WizardBaseDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void createTabToolButtons( CTabFolder tabFolder )
{
	List<IButtonHandler> buttons = wizardBase.getTabToolButtons( );
	if ( buttons.size( ) == 0 )
	{
		return;
	}
	ToolBar toolbar = new ToolBar( tabFolder, SWT.FLAT | SWT.WRAP );
	tabFolder.setTopRight( toolbar );
	for ( IButtonHandler btnHandler : buttons )
	{
		ToolItem btn = new ToolItem( toolbar, SWT.NONE );
		btn.addSelectionListener( this );
		btn.setData( btnHandler );
		if ( btnHandler.getLabel( ) != null )
		{
			btn.setText( btnHandler.getLabel( ) );
		}
		if ( btnHandler.getTooltip( ) != null )
		{
			btn.setToolTipText( btnHandler.getTooltip( ) );
		}
		if ( btnHandler.getIcon( ) != null )
		{
			btn.setImage( btnHandler.getIcon( ) );
		}
	}
}
 
Example 20
Source File: QuickLinksView.java    From BiglyBT with GNU General Public License v2.0 2 votes vote down vote up
private static void
addItem(
	BaseMDI					mdi,
	ToolBar					toolBar,
	QuickLinkItem			qli )
{
	String tt_id = qli.tt_id;
	
	ToolItem item = new ToolItem( toolBar, SWT.PUSH );
	
	if ( MessageText.keyExists( tt_id )){
	
		Messages.setLanguageTooltip( item, tt_id );
		
	}else{
		
		Utils.setTT( item,  tt_id );
	}
	
	ImageLoader imageLoader = ImageLoader.getInstance();
	
	Image image = imageLoader.getImage( qli.image_id );
	
	Image resized = imageLoader.resizeImageIfLarger(image, new Point( 15, 15 ));
	
	if ( resized == null ){
	
		item.setImage( image);
		
	}else{
		
		item.setImage( resized );
		
		item.addListener( SWT.Dispose, (ev)->{
			
			resized.dispose();
		});
	}
		
	item.addListener( SWT.Selection, ev->{
		
		if ( qli.ds_map == null ){
			
			mdi.showEntryByID( qli.mdi_id );
				
		}else{
				
			Object ds = DataSourceResolver.importDataSource( qli.ds_map );
				
			mdi.showEntryByID(	qli.mdi_id, ds );
		}
	});
	
	item.setData( "qli", qli );
}