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

The following examples show how to use org.eclipse.swt.widgets.ToolItem#setSelection() . 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: TestView.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings ("synthetic-access")
@Override
public void createToolItems(final GamaToolbar2 tb) {
	super.createToolItems(tb);
	TESTS_SORTED.removeChangeListeners();
	FAILED_TESTS.removeChangeListeners();
	final ToolItem t = tb.check(GamaIcons.create("test.sort2").getCode(), "Sort by severity",
			"When checked, sort the tests by their decreasing state severity (i.e. errored > failed > warning > passed > not run). Otherwise they are sorted by their order of execution.",
			e -> {
				TESTS_SORTED.set(!TESTS_SORTED.getValue());
				TestView.super.reset();
				reset();
			}, SWT.RIGHT);
	t.setSelection(TESTS_SORTED.getValue());
	TESTS_SORTED.onChange(v -> t.setSelection(v));

	final ToolItem t2 = tb.check(GamaIcons.create("test.filter2").getCode(), "Filter tests",
			"When checked, show only errored and failed tests and assertions", e -> {
				FAILED_TESTS.set(!FAILED_TESTS.getValue());
				TestView.super.reset();
				reset();
			}, SWT.RIGHT);
	t2.setSelection(FAILED_TESTS.getValue());
	FAILED_TESTS.onChange(v -> t2.setSelection(v));

}
 
Example 2
Source File: SyncGraphvizExportHandler.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent executionEvent)
		throws ExecutionException {

	Event event = (Event) executionEvent.getTrigger();

	ToolItem toolItem = (ToolItem) event.widget;

	if (toolItem.getSelection()) {// the toggle button was switched on

		// check if Graphviz is configured properly
		if (!GraphvizPreferencePage.isGraphvizConfigured()) {
			showGraphvizConfigurationDialog();
		}

		// if Graphviz is still not configured properly, do not exportd
		if (!GraphvizPreferencePage.isGraphvizConfigured()) {
			toolItem.setSelection(false);
			return null;
		}
		addListeners();

		IWorkbenchPart activeEditor = HandlerUtil
				.getActiveWorkbenchWindow(executionEvent).getActivePage()
				.getActiveEditor();
		checkActiveEditorAndExportGraph(activeEditor);

	} else { // the toggle button was switched off
		removeListeners();
	}

	return null;
}
 
Example 3
Source File: FindBarOption.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public ToolItem createToolItem(ToolBar optionsToolBar)
{
	if (!canCreateItem())
	{
		return null;
	}
	ToolItem item = isCheckable() ? new ToolItem(optionsToolBar, SWT.CHECK)
			: new ToolItem(optionsToolBar, SWT.PUSH);

	item.setImage(FindBarPlugin.getImage(this.image));
	if (imageDisabled != null)
	{
		item.setDisabledImage(FindBarPlugin.getImage(this.imageDisabled));
	}
	item.setToolTipText(this.initialText);
	if (preferencesKey != null)
	{
		IPreferenceStore preferenceStore = FindBarPlugin.getDefault().getPreferenceStore();
		item.setSelection(preferenceStore.getBoolean(preferencesKey));
	}
	item.addSelectionListener(this);
	if (!this.initiallyEnabled)
	{
		item.setEnabled(false);
	}
	setToolItemInDecorator(item);
	return item;
}
 
Example 4
Source File: TabbedPropertyTitle.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void updateToolBar( )
{
	if ( toolbar != null )
	{
		ResourceManager parentResourceManager = JFaceResources.getResources( );
		LocalResourceManager localManager = new LocalResourceManager( parentResourceManager );

		for ( int i = 0; i < toolbar.getItemCount( ); i++ )
		{
			ToolItem item = toolbar.getItem( i );
			IAction action = (IAction) actionMap.get( item );
			if ( action != null )
			{
				ImageDescriptor image = null;
				if ( action.getImageDescriptor( ) != null )
					image = action.getImageDescriptor( );
				if ( image != null )
					item.setImage( localManager.createImageWithDefault( image ) );

				item.setToolTipText( action.getToolTipText( ) );
				if ( IAction.AS_CHECK_BOX == action.getStyle( ) )
				{
					item.setSelection( action.isChecked( ) );
				}

				item.setEnabled( action.isEnabled( ) );
			}
		}

		disposeOldImages( );
		imageManager = localManager;

		if ( toolbar.isFocusControl( ) )
			toolbar.setFocus( );
	}
}
 
Example 5
Source File: EditExpressionDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void updateTrayVisibility() {
    if (helpControl != null) {
        helpControl.setVisible(false);
        if (currentExpressionEditor != null && currentExpressionEditor.provideDialogTray()) {
            final ToolItem item = ((ToolBar) helpControl).getItem(0);
            item.setSelection(true);
            openTrayListener.handleEvent(new Event());
        } else if (getTray() != null) {
            closeTray();
        }
    }
}