Java Code Examples for org.eclipse.swt.widgets.Combo#select()

The following examples show how to use org.eclipse.swt.widgets.Combo#select() . 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: OptionsConfigurationBlock.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected Combo newComboControl( Composite composite, Key key,
		String[] values, String[] valueLabels )
{
	ControlData data = new ControlData( key, values );

	Combo comboBox = new Combo( composite, SWT.READ_ONLY );
	comboBox.setVisibleItemCount( 30 );
	comboBox.setItems( valueLabels );
	comboBox.setData( data );
	comboBox.addSelectionListener( getSelectionListener( ) );
	comboBox.setFont( JFaceResources.getDialogFont( ) );

	String currValue = getValue( key );
	comboBox.select( data.getSelection( currValue ) );

	fComboBoxes.add( comboBox );

	return comboBox;
}
 
Example 2
Source File: KonsFilterDialog.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent){
	Composite ret = new Composite(parent, SWT.NONE);
	ret.setLayout(new GridLayout());
	ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
	new Label(ret, SWT.NONE).setText(Messages.KonsFilterDialog_onlyForCase); //$NON-NLS-1$
	cbFaelle = new Combo(ret, SWT.SINGLE);
	cbFaelle.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	faelle = pat.getCoverages().toArray(new ICoverage[0]);
	cbFaelle.add(Messages.KonsFilterDialog_dontMind); //$NON-NLS-1$
	for (ICoverage f : faelle) {
		cbFaelle.add(f.getLabel());
	}
	new Label(ret, SWT.SEPARATOR | SWT.HORIZONTAL);
	new Label(ret, SWT.WRAP).setText(Messages.KonsFilterDialog_enterWords + //$NON-NLS-1$
		Messages.KonsFilterDialog_separateFilters); //$NON-NLS-1$
	
	tBed = SWTHelper.createText(ret, 4, SWT.BORDER);
	new Label(ret, SWT.SEPARATOR | SWT.HORIZONTAL);
	bCase = new Button(ret, SWT.CHECK);
	bCase.setText(Messages.KonsFilterDialog_respectCase); //$NON-NLS-1$
	bRegex = new Button(ret, SWT.CHECK);
	bRegex.setText(Messages.KonsFilterDialog_regExp); //$NON-NLS-1$
	cbFaelle.select(0);
	bCase.setSelection(true);
	return ret;
}
 
Example 3
Source File: ComboBoxSelectionDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected Control createDialogArea( Composite parent )
{
	getShell( ).setText( fShellTitle );

	Composite composite = (Composite) super.createDialogArea( parent );
	Composite innerComposite = new Composite( composite, SWT.NONE );
	innerComposite.setLayoutData( new GridData( ) );
	GridLayout gl = new GridLayout( );
	gl.numColumns = 2;
	innerComposite.setLayout( gl );

	Label label = new Label( innerComposite, SWT.NONE );
	label.setText( fLabelText );
	label.setLayoutData( new GridData( ) );

	final Combo combo = new Combo( innerComposite, SWT.READ_ONLY );
	for ( int i = 0; i < fAllowedStrings.length; i++ )
	{
		combo.add( fAllowedStrings[i] );
	}
	if ( fInitialSelectionIndex != -1 )
	{
		combo.select( fInitialSelectionIndex );
		fSelection = combo.getItem( combo.getSelectionIndex( ) );
	}
	GridData gd = new GridData( );
	gd.widthHint = convertWidthInCharsToPixels( getMaxStringLength( ) );
	combo.setLayoutData( gd );
	combo.setVisibleItemCount( 30 );
	combo.addSelectionListener( new SelectionAdapter( ) {

		public void widgetSelected( SelectionEvent e )
		{
			fSelection = combo.getItem( combo.getSelectionIndex( ) );
		}
	} );
	applyDialogFont( composite );
	return composite;
}
 
Example 4
Source File: Regression_139334_swt.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * main() method for constructing the layout.
 * 
 * @param args
 */
public static void main( String[] args )
{
	Display display = Display.getDefault( );
	Shell shell = new Shell( display );
	shell.setSize( 600, 400 );
	shell.setLayout( new GridLayout( ) );

	Regression_139334_swt siv = new Regression_139334_swt(
			shell,
			SWT.NO_BACKGROUND );
	siv.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	siv.addPaintListener( siv );

	Composite cBottom = new Composite( shell, SWT.NONE );
	cBottom.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	cBottom.setLayout( new RowLayout( ) );

	Label la = new Label( cBottom, SWT.NONE );

	la.setText( "Choose: " );//$NON-NLS-1$
	cbType = new Combo( cBottom, SWT.DROP_DOWN | SWT.READ_ONLY );
	cbType.add( "Bar Chart" );
	cbType.select( 0 );

	btn = new Button( cBottom, SWT.NONE );
	btn.setText( "Update" );//$NON-NLS-1$
	btn.addSelectionListener( siv );

	shell.open( );
	while ( !shell.isDisposed( ) )
	{
		if ( !display.readAndDispatch( ) )
			display.sleep( );
	}
	display.dispose( );
}
 
Example 5
Source File: Regression_78699_swt.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * main() method for constructing the layout.
 * 
 * @param args
 */
public static void main( String[] args )
{
	Display display = Display.getDefault( );
	Shell shell = new Shell( display );
	shell.setSize( 600, 400 );
	shell.setLayout( new GridLayout( ) );

	Regression_78699_swt siv = new Regression_78699_swt(
			shell,
			SWT.NO_BACKGROUND );
	siv.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	siv.addPaintListener( siv );

	Composite cBottom = new Composite( shell, SWT.NONE );
	cBottom.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	cBottom.setLayout( new RowLayout( ) );

	Label la = new Label( cBottom, SWT.NONE );

	la.setText( "Choose: " );//$NON-NLS-1$
	cbType = new Combo( cBottom, SWT.DROP_DOWN | SWT.READ_ONLY );
	cbType.add( "Bar Chart" );
	cbType.select( 0 );

	btn = new Button( cBottom, SWT.NONE );
	btn.setText( "Update" );//$NON-NLS-1$
	btn.addSelectionListener( siv );

	shell.open( );
	while ( !shell.isDisposed( ) )
	{
		if ( !display.readAndDispatch( ) )
			display.sleep( );
	}
	display.dispose( );
}
 
Example 6
Source File: RnDialogs.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent){
	Composite ret = new Composite(parent, SWT.NONE);
	ret.setLayout(new GridLayout());
	ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
	Label lblSelectState = new Label(ret, SWT.NONE);
	lblSelectState.setText(Messages.RnDialogs_pleaseNewStateForMulti);
	
	cbStates = new Combo(ret, SWT.READ_ONLY);
	cbStates.setItems(RnStatus.getStatusTexts());
	cbStates.setVisibleItemCount(RnStatus.getStatusTexts().length);
	cbStates.select(rechnungen.get(0).getStatus());
	cbStates.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	
	tableViewer = new TableViewer(ret, SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
	GridData gd_Table = new GridData();
	gd_Table.grabExcessHorizontalSpace = true;
	gd_Table.horizontalSpan = 1;
	gd_Table.minimumHeight = 150;
	gd_Table.heightHint = 150;
	tableViewer.getTable().setLayoutData(gd_Table);
	tableViewer.getTable().setHeaderVisible(true);
	tableViewer.getTable().setLinesVisible(false);
	
	tableViewer.setContentProvider(new ArrayContentProvider());
	TableViewerColumn colRnNumber = new TableViewerColumn(tableViewer, SWT.NONE);
	colRnNumber.getColumn().setWidth(200);
	colRnNumber.getColumn().setText(Messages.RnDialogs_invoiceNumber);
	colRnNumber.setLabelProvider(new ColumnLabelProvider());
	
	tableViewer.setInput(rnNumbers);
	
	return ret;
}
 
Example 7
Source File: DepthComboHelper.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public static void addDepths(Combo combo, boolean includeUnknown, String defaultSelection) {
	if (includeUnknown) combo.add(ISVNUIConstants.DEPTH_UNKNOWN);
	combo.add(ISVNUIConstants.DEPTH_INFINITY);
	combo.add(ISVNUIConstants.DEPTH_IMMEDIATES);
	combo.add(ISVNUIConstants.DEPTH_FILES);
	combo.add(ISVNUIConstants.DEPTH_EMPTY);
	if (defaultSelection != null) combo.select(combo.indexOf(defaultSelection));
}
 
Example 8
Source File: BorderThicknessPicker.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public BorderThicknessPicker(Composite parent) {
    super(parent, NONE);
    setLayout(new RowLayout());

    combo = new Combo(this, SWT.READ_ONLY | SWT.DROP_DOWN);
    combo.setItems(new String[] { "Thin", "Thick", "Very Thick" });
    combo.select(0);
}
 
Example 9
Source File: Regression_118773_swt.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * main() method for constructing the layout.
 * 
 * @param args
 */
public static void main( String[] args )
{
	Display display = Display.getDefault( );
	Shell shell = new Shell( display );
	shell.setSize( 600, 400 );
	shell.setLayout( new GridLayout( ) );

	Regression_118773_swt siv = new Regression_118773_swt(
			shell,
			SWT.NO_BACKGROUND );
	siv.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	siv.addPaintListener( siv );

	Composite cBottom = new Composite( shell, SWT.NONE );
	cBottom.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	cBottom.setLayout( new RowLayout( ) );

	Label la = new Label( cBottom, SWT.NONE );

	la.setText( "Choose: " );//$NON-NLS-1$
	cbType = new Combo( cBottom, SWT.DROP_DOWN | SWT.READ_ONLY );
	cbType.add( "Bar Chart" );
	cbType.select( 0 );

	btn = new Button( cBottom, SWT.NONE );
	btn.setText( "Update" );//$NON-NLS-1$
	btn.addSelectionListener( siv );

	shell.open( );
	while ( !shell.isDisposed( ) )
	{
		if ( !display.readAndDispatch( ) )
			display.sleep( );
	}
	display.dispose( );
}
 
Example 10
Source File: AbstractExampleTab.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void createBackMode(Composite parent) {
	parent.setLayout(new GridLayout());
	final Combo backMode = new Combo(parent, SWT.READ_ONLY);
	backMode.setItems(new String[] { "SWT.INHERIT_NONE", "SWT.INHERIT_DEFAULT", "SWT.INHERIT_FORCE" });
	backMode.select(0);
	backMode.addListener(SWT.Selection, event -> {
		int mode = SWT.INHERIT_NONE;
		if (backMode.getText().indexOf("DEFAULT") != -1) {
			mode = SWT.INHERIT_DEFAULT;
		}
		if (backMode.getText().indexOf("FORCE") != -1) {
			mode = SWT.INHERIT_FORCE;
		}
		controlArea.setBackgroundMode(mode);
	});

	final Button backImage = new Button(parent, SWT.CHECK);
	backImage.setText("Background Image");
	backImage.addListener(SWT.Selection, event -> {
		if (backImage.getSelection()) {
			controlArea.setBackgroundImage(ExamplesView.getImage("icons/background.PNG"));
		} else {
			controlArea.setBackgroundImage(null);
		}
	});

	final Button backColor = new Button(parent, SWT.CHECK);
	backColor.setText("Background Color");
	backColor.addListener(SWT.Selection, event -> {
		if (backColor.getSelection()) {
			controlArea.setBackground(controlArea.getDisplay().getSystemColor(SWT.COLOR_CYAN));
		} else {
			controlArea.setBackground(null);
		}
	});
}
 
Example 11
Source File: InputParameterDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * If the combo is cascade then: If the value in the combo data list: then
 * select the value else: then select the first item if items exists else :
 * then set the value to combo
 * 
 * @param value
 * @param combo
 * @param listParam
 * @param isCascade
 * @param comboData
 */
private void dealWithValueNotInComboList( Object value, Combo combo,
		ScalarParameter listParam, boolean isCascade, Object comboData )
{
	if ( !isCascade
			|| ( isCascade && isContainValue( listParam.getDefaultObject( ),
					comboData ) ) )
	{
		combo.setText( value == null ? NULL_VALUE_STR : value.toString( ) );
		listParam.setSelectionValue( combo.getText( ) );
		putConfigValue( listParam.getHandle( ).getName( ), combo.getText( ) );
	}
	else
	{
		if ( combo.getItemCount( ) > 0 )
		{
			combo.select( 0 );
			listParam.setSelectionValue( combo.getText( ) );
			putConfigValue( listParam.getHandle( ).getName( ),
					combo.getData( String.valueOf( combo.getSelectionIndex( ) ) ) );
		}
		else
		{
			putConfigValue( listParam.getHandle( ).getName( ), null );
		}

	}
}
 
Example 12
Source File: GraphicsPageableTableExample.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	GridLayout layout = new GridLayout(1, false);
	shell.setLayout(layout);

	final List<String> items = createList();

	// 1) Create pageable table with 10 items per page
	// This SWT Component create internally a SWT Table+JFace TreeViewer
	int pageSize = 10;
	final PageableTable pageableTable = new PageableTable(
			shell,
			SWT.BORDER,
			SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL,
			pageSize,
			PageResultContentProvider.getInstance(),
			ResultAndNavigationPageGraphicsRendererFactory.getBlueFactory(),
			null);
	pageableTable.setLayoutData(new GridData(GridData.FILL_BOTH));

	// 2) Initialize the table viewer
	TableViewer viewer = pageableTable.getViewer();
	viewer.setContentProvider(ArrayContentProvider.getInstance());
	viewer.setLabelProvider(new LabelProvider());

	// 3) Set the page loader used to load a page (sublist of String)
	// according the page index selected, the page size etc.
	pageableTable.setPageLoader(new PageResultLoaderList<>(items));

	// 4) Set current page to 0 to display the first page
	pageableTable.setCurrentPage(0);

	final Combo styleCombo = new Combo(shell, SWT.READ_ONLY);
	styleCombo.setItems(new String[] { "Blue", "Green", "Black" });
	styleCombo.select(0);
	styleCombo.addListener(SWT.Selection, e -> {
		if (styleCombo.getText().equals("Blue")) {
			((ResultAndNavigationPageGraphicsRenderer) pageableTable.getCompositeTop()).getNavigationPage()
					.setConfigurator(BlueNavigationPageGraphicsConfigurator.getInstance());
		} else if (styleCombo.getText().equals("Green")) {
			((ResultAndNavigationPageGraphicsRenderer) pageableTable.getCompositeTop())
					.setConfigurator(GreenNavigationPageGraphicsConfigurator.getInstance());
		} else {
			((ResultAndNavigationPageGraphicsRenderer) pageableTable.getCompositeTop())
					.setConfigurator(BlackNavigationPageGraphicsConfigurator.getInstance());
		}

	});

	shell.setSize(450, 300);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
Example 13
Source File: PatientErfassenDialog.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected Control createDialogArea(final Composite parent){
	Composite ret = new Composite(parent, SWT.NONE);
	ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
	ret.setLayout(new GridLayout(2, false));
	new Label(ret, SWT.NONE).setText(Messages.PatientErfassenDialog_Name); //$NON-NLS-1$
	tName = new Text(ret, SWT.BORDER);
	tName.setText(getField(Patient.FLD_NAME));
	tName.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	new Label(ret, SWT.NONE).setText(Messages.PatientErfassenDialog_firstName); //$NON-NLS-1$
	tVorname = new Text(ret, SWT.BORDER);
	tVorname.setText(getField(Patient.FLD_FIRSTNAME));
	tVorname.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	new Label(ret, SWT.NONE).setText(Messages.PatientErfassenDialog_sex); //$NON-NLS-1$
	cbSex = new Combo(ret, SWT.SINGLE);
	String toolTip = String.format(Messages.Patient_male_female_tooltip,
			Messages.Patient_male_short, Messages.Patient_female_short,
			Messages.Patient_male_long, Messages.Patient_female_long);
	cbSex.setToolTipText(toolTip);
	cbSex.setItems(new String[] {
		Messages.Patient_male_short, Messages.Patient_female_short
	}); //$NON-NLS-1$ //$NON-NLS-2$
	if (StringTool.isNothing(getField(Patient.FLD_SEX))) {
		cbSex.select(0);
	} else {
		cbSex.select(StringTool.isFemale(getField(Patient.FLD_FIRSTNAME)) ? 1 : 0);
	}
	new Label(ret, SWT.NONE).setText(Messages.PatientErfassenDialog_birthDate); //$NON-NLS-1$
	tGebDat = new Text(ret, SWT.BORDER);
	tGebDat.setText(getField(Patient.FLD_DOB));
	tGebDat.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	
	new Label(ret, SWT.NONE).setText(Messages.PatientErfassenDialog_street); //$NON-NLS-1$
	tStrasse = new Text(ret, SWT.BORDER);
	tStrasse.setText(getField(Patient.FLD_STREET));
	tStrasse.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	
	new Label(ret, SWT.NONE).setText(Messages.PatientErfassenDialog_zip); //$NON-NLS-1$
	tPlz = new Text(ret, SWT.BORDER);
	tPlz.setText(getField(Patient.FLD_ZIP));
	tPlz.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	
	new Label(ret, SWT.NONE).setText(Messages.PatientErfassenDialog_city); //$NON-NLS-1$
	tOrt = new Text(ret, SWT.BORDER);
	tOrt.setText(getField(Patient.FLD_PLACE));
	tOrt.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	
	new Label(ret, SWT.NONE).setText(Messages.PatientErfassenDialog_phone); //$NON-NLS-1$
	tTel = new Text(ret, SWT.BORDER);
	tTel.setText(getField(Patient.FLD_PHONE1));
	tTel.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	return ret;
}
 
Example 14
Source File: ConfigurationSettingsWizardPage.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Setups gateway SWT controls by populating a gateway combobox and configuring an information
 * Label and the enabling checkbox.
 *
 * @param combo {@link Combo} selector to populate with discovered gateways
 * @param info {@link Label} displaying status information of the discovery
 * @param checkbox {@link Button} checkbox to enable/disable UPnP support
 */
private void populateGatewaySelectionControls(
    List<GatewayDevice> gateways, final Combo combo, final Label info, final Button checkbox) {

  combo.setEnabled(false);
  checkbox.setEnabled(false);
  combo.removeAll();

  // if no devices are found, return now - nothing to populate
  if (gateways == null || gateways.isEmpty()) {
    info.setText(Messages.UPnPUIUtils_no_gateway);
    info.getParent().pack();
    return;
  }

  this.gateways = new ArrayList<GatewayDevice>();

  // insert found gateways into combobox
  for (GatewayDevice gw : gateways) {
    try {
      String name = gw.getFriendlyName();
      if (!gw.isConnected()) name += Messages.UPnPUIUtils_disconnected;

      combo.add(name);
      this.gateways.add(gw);

    } catch (Exception e) {
      log.debug("Error updating UPnP selector:" + e.getMessage()); // $NON-NLS-1$
      // ignore faulty gateway
    }
  }

  // if valid gateway found, show info and enable
  if (combo.getItemCount() > 0) {
    checkbox.setEnabled(true);
    combo.setEnabled(true);
    combo.select(0);
    combo.pack();
    info.setVisible(false);
  } else {
    info.setText(Messages.UPnPUIUtils_no_valid_gateway);
  }
  info.getParent().pack();
}
 
Example 15
Source File: JavaViewer.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Execute application
 * 
 * @param args
 */
public static void main( String[] args )
{
	Display display = Display.getDefault( );
	Shell shell = new Shell( display );
	shell.setSize( 600, 400 );
	shell.setLayout( new GridLayout( ) );

	JavaViewer jViewer = new JavaViewer( shell, SWT.NO_BACKGROUND );
	jViewer.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	jViewer.addPaintListener( jViewer );

	Composite cBottom = new Composite( shell, SWT.NONE );
	cBottom.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	cBottom.setLayout( new RowLayout( ) );

	description = new Label( shell, SWT.NONE );
	description.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	description.setText( "beforeDrawAxisLabel( Axis, Label, IChartScriptContext )" //$NON-NLS-1$
			+ "\nbeforeDrawAxisTitle( Axis, Label, IChartScriptContext )" ); //$NON-NLS-1$

	Label la = new Label( cBottom, SWT.NONE );

	la.setText( "&Choose: " );//$NON-NLS-1$
	cbType = new Combo( cBottom, SWT.DROP_DOWN | SWT.READ_ONLY );
	cbType.add( "Axis" );//$NON-NLS-1$
	cbType.add( "DataPoints" );//$NON-NLS-1$
	cbType.add( "Marker" );//$NON-NLS-1$
	cbType.add( "Series" );//$NON-NLS-1$
	cbType.add( "Series Title" ); //$NON-NLS-1$
	cbType.add( "Block" );//$NON-NLS-1$
	cbType.add( "Legend" ); //$NON-NLS-1$
	cbType.select( 0 );

	btn = new Button( cBottom, SWT.NONE );
	btn.setText( "&Update" );//$NON-NLS-1$
	btn.setToolTipText( "&Update" );//$NON-NLS-1$
	btn.addSelectionListener( jViewer );

	shell.open( );
	while ( !shell.isDisposed( ) )
	{
		if ( !display.readAndDispatch( ) )
			display.sleep( );
	}
	display.dispose( );

}
 
Example 16
Source File: MultiCellEditDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
private void createUpdateCombo(Composite composite) {
	updateCombo = new Combo(composite, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER);

	for (String option : OPTIONS) {
		updateCombo.add(option);
	}

	updateCombo.select(0);

	updateCombo.addDisposeListener(new DisposeListener() {

		public void widgetDisposed(DisposeEvent arg0) {
			lastSelectedIndex = updateCombo.getSelectionIndex();
		}

	});

	GridDataFactory.swtDefaults().applyTo(updateCombo);
}
 
Example 17
Source File: EditorCriterionProfitability.java    From arx with Apache License 2.0 4 votes vote down vote up
@Override
protected Composite build(Composite parent) {
    
       // Create input group
       Composite group = new Composite(parent, SWT.NONE);
       group.setLayoutData(SWTUtil.createFillHorizontallyGridData());
       GridLayout groupInputGridLayout = new GridLayout();
       groupInputGridLayout.numColumns = 4;
       group.setLayout(groupInputGridLayout);
       
       // Attacker model
       Label labelAttackerModel = new Label(group, SWT.NONE);
       labelAttackerModel.setText(Resources.getMessage("CriterionDefinitionView.120"));

       comboAttackerModel = new Combo(group, SWT.READ_ONLY);
       comboAttackerModel.setLayoutData(SWTUtil.createFillHorizontallyGridData());
       comboAttackerModel.setItems(LABELS);
       comboAttackerModel.select(0);
       comboAttackerModel.addSelectionListener(new SelectionAdapter() {
           @Override
           public void widgetSelected(final SelectionEvent arg0) {
               if (comboAttackerModel.getSelectionIndex() != -1) {
                   model.setAttackerModel(MODELS[comboAttackerModel.getSelectionIndex()]);
               }
           }
       });
       
       // Allow attack
       Label labelAllowAttack = new Label(group, SWT.NONE);
       labelAllowAttack.setText(Resources.getMessage("CriterionDefinitionView.123"));

       checkboxAllowAttack = new Button(group, SWT.CHECK);
       checkboxAllowAttack.addSelectionListener(new SelectionAdapter() {
           @Override
           public void widgetSelected(SelectionEvent e) {
               model.setAllowAttacks(checkboxAllowAttack.getSelection());
           }
       });
       
       return group;
}
 
Example 18
Source File: RectifierDesign.java    From ldparteditor with MIT License 4 votes vote down vote up
/**
 * Create contents of the dialog.
 *
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite cmp_container = (Composite) super.createDialogArea(parent);
    GridLayout gridLayout = (GridLayout) cmp_container.getLayout();
    gridLayout.verticalSpacing = 10;
    gridLayout.horizontalSpacing = 10;

    Label lbl_specify = new Label(cmp_container, SWT.NONE);
    lbl_specify.setText(I18n.RECTIFIER_Title);

    Label lbl_separator = new Label(cmp_container, SWT.SEPARATOR | SWT.HORIZONTAL);
    lbl_separator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    Label lbl_angle = new Label(cmp_container, SWT.NONE);
    lbl_angle.setText(I18n.RECTIFIER_MaxAngle);

    BigDecimalSpinner spn_angle = new BigDecimalSpinner(cmp_container, SWT.NONE);
    this.spn_angle [0] = spn_angle;
    spn_angle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    spn_angle.setMaximum(new BigDecimal(90));
    spn_angle.setMinimum(new BigDecimal(0));
    spn_angle.setValue(rs.getMaximumAngle());

    {
        Combo cmb_colourise = new Combo(cmp_container, SWT.READ_ONLY);
        this.cmb_colourise[0] = cmb_colourise;
        cmb_colourise.setItems(new String[] {I18n.RECTIFIER_Colour1, I18n.RECTIFIER_Colour2});
        cmb_colourise.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        cmb_colourise.setText(cmb_colourise.getItem(rs.isColourise() ? 1 : 0));
        cmb_colourise.select(rs.isColourise() ? 1 : 0);
    }
    {
        Combo cmb_noQuadConversation = new Combo(cmp_container, SWT.READ_ONLY);
        this.cmb_noQuadConversation[0] = cmb_noQuadConversation;
        cmb_noQuadConversation.setItems(new String[] {I18n.RECTIFIER_TriQuads1, I18n.RECTIFIER_TriQuads2});
        cmb_noQuadConversation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        cmb_noQuadConversation.setText(cmb_noQuadConversation.getItem(rs.isNoQuadConversation() ? 1 : 0));
        cmb_noQuadConversation.select(rs.isNoQuadConversation() ? 1 : 0);
    }
    {
        Combo cmb_noBorderedQuadToRectConversation = new Combo(cmp_container, SWT.READ_ONLY);
        this.cmb_noBorderedQuadToRectConversation[0] = cmb_noBorderedQuadToRectConversation;
        cmb_noBorderedQuadToRectConversation.setItems(new String[] {I18n.RECTIFIER_Rect1, I18n.RECTIFIER_Rect2});
        cmb_noBorderedQuadToRectConversation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        cmb_noBorderedQuadToRectConversation.setText(cmb_noBorderedQuadToRectConversation.getItem(rs.isNoBorderedQuadToRectConversation() ? 1 : 0));
        cmb_noBorderedQuadToRectConversation.select(rs.isNoBorderedQuadToRectConversation() ? 1 : 0);
    }
    {
        Combo cmb_noRectConversationOnAdjacentCondlines = new Combo(cmp_container, SWT.READ_ONLY);
        this.cmb_noRectConversationOnAdjacentCondlines[0] = cmb_noRectConversationOnAdjacentCondlines;
        cmb_noRectConversationOnAdjacentCondlines.setItems(new String[] {I18n.RECTIFIER_Rect3, I18n.RECTIFIER_Rect4});
        cmb_noRectConversationOnAdjacentCondlines.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        cmb_noRectConversationOnAdjacentCondlines.setText(cmb_noRectConversationOnAdjacentCondlines.getItem(rs.isNoRectConversationOnAdjacentCondlines() ? 1 : 0));
        cmb_noRectConversationOnAdjacentCondlines.select(rs.isNoRectConversationOnAdjacentCondlines() ? 1 : 0);
    }
    Combo cmb_scope = new Combo(cmp_container, SWT.READ_ONLY);
    this.cmb_scope[0] = cmb_scope;
    cmb_scope.setItems(new String[] {I18n.RECTIFIER_ScopeFile, I18n.RECTIFIER_ScopeSelection});
    cmb_scope.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    cmb_scope.setText(cmb_scope.getItem(rs.getScope()));
    cmb_scope.select(rs.getScope());

    NButton btn_verbose = new NButton(cmp_container, SWT.CHECK);
    this.btn_verbose[0] = btn_verbose;
    btn_verbose.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btn_verbose.setText(I18n.RECTIFIER_Verbose);
    btn_verbose.setSelection(rs.isVerbose());

    cmp_container.pack();
    return cmp_container;
}
 
Example 19
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
protected void updateCombo(Combo curr) {
	ControlData data= (ControlData) curr.getData();

	String currValue= getValue(data.getKey());
	curr.select(data.getSelection(currValue));
}
 
Example 20
Source File: SWTFactory.java    From APICloud-Studio with GNU General Public License v3.0 3 votes vote down vote up
/**
 * This method is used to make a combo box
 * 
 * @param parent
 *            the parent composite to add the new combo to
 * @param style
 *            the style for the Combo
 * @param hspan
 *            the horizontal span to take up on the parent composite
 * @param fill
 *            how the combo will fill into the composite Can be one of <code>GridData.FILL_HORIZONAL</code>,
 *            <code>GridData.FILL_BOTH</code> or <code>GridData.FILL_VERTICAL</code>
 * @param items
 *            the item to put into the combo
 * @return a new Combo instance
 */
public static Combo createCombo(Composite parent, int style, int hspan, int fill, String[] items)
{
	Combo c = new Combo(parent, style);
	c.setFont(parent.getFont());
	GridData gd = new GridData(fill);
	gd.horizontalSpan = hspan;
	c.setLayoutData(gd);
	c.setItems(items);
	c.select(0);
	return c;
}