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

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

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

	makeScrollableCompositeAware(comboBox);

	updateCombo(comboBox);

	comboBoxes.add(comboBox);
	return comboBox;
}
 
Example 2
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 3
Source File: OptionsConfigurationBlock.java    From typescript.java with MIT License 6 votes vote down vote up
protected Combo addInversedComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels,
		int indent) {
	GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
	gd.horizontalIndent = indent;
	gd.horizontalSpan = 3;

	Composite composite = new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout();
	layout.marginHeight = 0;
	layout.marginWidth = 0;
	layout.numColumns = 2;
	composite.setLayout(layout);
	composite.setLayoutData(gd);

	Combo comboBox = newComboControl(composite, key, values, valueLabels);
	comboBox.setFont(JFaceResources.getDialogFont());
	comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

	Label labelControl = new Label(composite, SWT.LEFT | SWT.WRAP);
	labelControl.setText(label);
	labelControl.setLayoutData(new GridData());

	fLabels.put(comboBox, labelControl);
	return comboBox;
}
 
Example 4
Source File: OptionsConfigurationBlock.java    From typescript.java with MIT License 6 votes vote down vote up
protected Combo newComboControl(Composite composite, Key key, String[] values, String[] valueLabels,
		boolean readOnly) {
	Combo comboBox = new Combo(composite, readOnly ? SWT.READ_ONLY : SWT.NONE);
	comboBox.setItems(valueLabels);
	comboBox.setFont(JFaceResources.getDialogFont());

	makeScrollableCompositeAware(comboBox);

	String currValue = getValue(key);
	if (readOnly) {
		ControlData data = new ControlData(key, values);
		comboBox.setData(data);
		comboBox.addSelectionListener(getSelectionListener());
		comboBox.select(data.getSelection(currValue));
	} else {
		comboBox.setData(key);
		if (currValue != null) {
			comboBox.setText(currValue);
		}
		comboBox.addModifyListener(getTextModifyListener());
	}

	fComboBoxes.add(comboBox);
	return comboBox;
}
 
Example 5
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion 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.setItems(valueLabels);
	comboBox.setData(data);
	comboBox.addSelectionListener(getSelectionListener());
	comboBox.setFont(JFaceResources.getDialogFont());
	SWTUtil.setDefaultVisibleItemCount(comboBox);

	makeScrollableCompositeAware(comboBox);

	updateCombo(comboBox);

	fComboBoxes.add(comboBox);
	return comboBox;
}
 
Example 6
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
protected Combo addInversedComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels, int indent) {
	GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
	gd.horizontalIndent= indent;
	gd.horizontalSpan= 3;

	Composite composite= new Composite(parent, SWT.NONE);
	GridLayout layout= new GridLayout();
	layout.marginHeight= 0;
	layout.marginWidth= 0;
	layout.numColumns= 2;
	composite.setLayout(layout);
	composite.setLayoutData(gd);

	Combo comboBox= newComboControl(composite, key, values, valueLabels);
	comboBox.setFont(JFaceResources.getDialogFont());
	comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

	Label labelControl= new Label(composite, SWT.LEFT | SWT.WRAP);
	labelControl.setText(label);
	labelControl.setLayoutData(new GridData());

	fLabels.put(comboBox, labelControl);
	return comboBox;
}
 
Example 7
Source File: ScriptSWTFactory.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public static Combo createCombo( Composite parent, Font font, int hspan )
{
	Combo cb = new Combo( parent, SWT.BORDER | SWT.READ_ONLY );
	cb.setFont( font );
	GridData gd = new GridData( );
	gd.horizontalSpan = hspan;
	cb.setLayoutData( gd );
	return cb;
}
 
Example 8
Source File: AdvancedNewProjectPage.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected Combo DropDown(Composite parent, Procedure1<? super Combo> config) {
	Combo combo = new Combo(parent, SWT.READ_ONLY);
	combo.setFont(parent.getFont());
	combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	config.apply(combo);
	return combo;
}
 
Example 9
Source File: OptionsConfigurationBlock.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected Combo addInversedComboBox( Composite parent, String label,
		Key key, String[] values, String[] valueLabels, int indent )
{
	GridData gd = new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING );
	gd.horizontalIndent = indent;
	gd.horizontalSpan = 3;

	Composite composite = new Composite( parent, SWT.NONE );
	GridLayout layout = new GridLayout( );
	layout.marginHeight = 0;
	layout.marginWidth = 0;
	layout.numColumns = 2;
	composite.setLayout( layout );
	composite.setLayoutData( gd );

	Combo comboBox = newComboControl( composite, key, values, valueLabels );
	comboBox.setFont( JFaceResources.getDialogFont( ) );
	comboBox.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_FILL ) );

	Label labelControl = new Label( composite, SWT.LEFT | SWT.WRAP );
	labelControl.setText( label );
	labelControl.setLayoutData( new GridData( ) );

	fLabels.put( comboBox, labelControl );

	updateCombo( comboBox );

	return comboBox;
}
 
Example 10
Source File: JavaCamelJobScriptsExportWSWizardPage.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
@Override
protected void createDestinationGroup(Composite parent) {
    Font font = parent.getFont();
    // destination specification group
    Composite destinationSelectionGroup = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    destinationSelectionGroup.setLayout(layout);
    destinationSelectionGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
    destinationSelectionGroup.setFont(font);

    destinationLabel = new Label(destinationSelectionGroup, SWT.NONE);
    destinationLabel.setText(getDestinationLabel());
    destinationLabel.setFont(font);

    // destination name entry field
    destinationNameField = new Combo(destinationSelectionGroup, SWT.SINGLE | SWT.BORDER);
    destinationNameField.addListener(SWT.Modify, this);
    destinationNameField.addListener(SWT.Selection, this);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
    data.widthHint = SIZING_TEXT_FIELD_WIDTH;
    destinationNameField.setLayoutData(data);
    destinationNameField.setFont(font);
    BidiUtils.applyBidiProcessing(destinationNameField, "file"); //$NON-NLS-1$

    // destination browse button
    destinationBrowseButton = new Button(destinationSelectionGroup, SWT.PUSH);
    destinationBrowseButton.setText(DataTransferMessages.DataTransfer_browse);
    destinationBrowseButton.addListener(SWT.Selection, this);
    destinationBrowseButton.setFont(font);
    setButtonLayoutData(destinationBrowseButton);

    new Label(parent, SWT.NONE); // vertical spacer
}
 
Example 11
Source File: ModifyDialogTabPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create a new ComboPreference.
 * @param composite The composite on which the SWT widgets are added.
 * @param numColumns The number of columns in the composite's GridLayout.
 * @param preferences The map to store the values.
 * @param key The key to store the values.
 * @param values An array of n elements indicating the values to store for each selection.
 * @param text The label text for this Preference.
 * @param items An array of n elements indicating the text to be written in the combo box.
 */
public ComboPreference(Composite composite, int numColumns,
						  Map<String, String> preferences, String key,
						  String [] values, String text, String [] items) {
    super(preferences, key);
    if (values == null || items == null || text == null)
        throw new IllegalArgumentException(FormatterMessages.ModifyDialogTabPage_error_msg_values_items_text_unassigned);
	fValues= values;
	fItems= items;
	createLabel(numColumns - 1, composite, text);
	fCombo= new Combo(composite, SWT.SINGLE | SWT.READ_ONLY);
	fCombo.setFont(composite.getFont());
	SWTUtil.setDefaultVisibleItemCount(fCombo);
	fCombo.setItems(items);

	int max= 0;
	for (int i= 0; i < items.length; i++)
	    if (items[i].length() > max) max= items[i].length();

	fCombo.setLayoutData(createGridData(1, GridData.HORIZONTAL_ALIGN_FILL, fCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT).x));

	updateWidget();

	fCombo.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			comboSelected(((Combo)e.widget).getSelectionIndex());
		}
	});
}
 
Example 12
Source File: ProfileConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static Combo createProfileCombo(Composite composite, int span, int widthHint) {
	final GridData gd = new GridData(GridData.FILL_HORIZONTAL);
	gd.horizontalSpan = span;
	gd.widthHint= widthHint;

	final Combo combo= new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY );
	combo.setFont(composite.getFont());
	SWTUtil.setDefaultVisibleItemCount(combo);
	combo.setLayoutData(gd);
	return combo;
}
 
Example 13
Source File: AbstractFormatterSelectionBlock.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private static Combo createProfileCombo(Composite composite, int span, int widthHint)
{
	final GridData gd = new GridData(GridData.FILL_HORIZONTAL);
	gd.horizontalSpan = span;
	gd.widthHint = widthHint;

	final Combo combo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
	combo.setFont(composite.getFont());
	combo.setLayoutData(gd);

	return combo;
}
 
Example 14
Source File: AbstractWizardNewTypeScriptProjectCreationPage.java    From typescript.java with MIT License 5 votes vote down vote up
/** Creates the field for the embedded Node.js. */
private void createEmbeddedNodejsField(Composite parent, IEmbeddedNodejs[] installs) {
	useEmbeddedNodeJsButton = new Button(parent, SWT.RADIO);
	useEmbeddedNodeJsButton
			.setText(TypeScriptUIMessages.AbstractWizardNewTypeScriptProjectCreationPage_useEmbeddedNodeJs_label);
	useEmbeddedNodeJsButton.addListener(SWT.Selection, nodeJsStatusChanged());

	embeddedNodeJs = new Combo(parent, SWT.READ_ONLY);
	embeddedNodeJs.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

	// Create combo of embedded node.js
	String[] values = new String[installs.length];
	String[] valueLabels = new String[installs.length];
	int i = 0;
	for (IEmbeddedNodejs install : installs) {
		values[i] = install.getId();
		valueLabels[i] = install.getName();
		i++;
	}
	embeddedNodeJs.setItems(valueLabels);
	embeddedNodeJs.setFont(JFaceResources.getDialogFont());
	embeddedNodeJs.addListener(SWT.Modify, nodeJsStatusChanged());
	embeddedNodeJs.addModifyListener(new ModifyListener() {

		@Override
		public void modifyText(ModifyEvent e) {
			embeddedNodeJsId = embeddedNodeJs.getText();
		}
	});
}
 
Example 15
Source File: SWTFactory.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * This method is used to make a combo box with a default fill style of GridData.FILL_HORIZONTAL
 * 
 * @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 items the item to put into the combo
 * @return a new Combo instance
 */
public static Combo createCombo(Composite parent, int style, int hspan, String[] items) {
	Combo c = new Combo(parent, style);
	c.setFont(parent.getFont());
	GridData gd = new GridData(GridData.FILL_HORIZONTAL);
	gd.horizontalSpan = hspan;
	c.setLayoutData(gd);
	if (items != null){
		c.setItems(items);
	}
	c.select(0);
	return c;
}
 
Example 16
Source File: SWTFactory.java    From tlaplus with MIT License 5 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);
	if (items != null){
		c.setItems(items);
	}
	c.select(0);
	return c;
}
 
Example 17
Source File: NewCheckCatalogWizardPage.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the grammars controls.
 * 
 * @param composite
 *          the composite
 */
private void createGrammarsControls(final Composite composite) {
  Label generatorConfigLabel = new Label(composite, SWT.NONE);
  generatorConfigLabel.setText(Messages.GRAMMAR_FIELD_NAME_LABEL);

  Combo generatorConfigurationField = new Combo(composite, SWT.READ_ONLY);
  GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
  data.widthHint = PAGE_WIDTH_HINT; // prevents shrinking of combo view
  generatorConfigurationField.setLayoutData(data);
  generatorConfigurationField.setFont(composite.getFont());

  ComboViewer grammars = new ComboViewer(generatorConfigurationField);
  grammars.setContentProvider(new ArrayContentProvider());
  grammars.setLabelProvider(new LabelProvider() {
    @Override
    public String getText(final Object object) {
      if (object instanceof Grammar) {
        return new GrammarHelper((Grammar) object).getLabelName();
      }
      return super.getText(object);
    }
  });
  grammars.setInput(resourceUtil.getGrammars());

  // React to the selection of the viewer
  // Note that the viewer return the real object and not just a string
  // representation
  grammars.addSelectionChangedListener(new ISelectionChangedListener() {
    public void selectionChanged(final SelectionChangedEvent event) {
      if (event.getSelection() instanceof StructuredSelection) {
        grammar = (Grammar) ((StructuredSelection) event.getSelection()).getFirstElement();
        grammarStatus = validateGrammarAccess();
        handleFieldChanged(GRAMMAR);
      }
    }
  });
  grammars.setSelection(null); // no pre-defined grammar to be used, forces the user to make a decision about which language to target
}
 
Example 18
Source File: SWTFactory.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public static Combo createCombo(Composite parent, int hspan, int style, int gdStyle) {
    Combo c = new Combo(parent, style);
    c.setFont(parent.getFont());
    GridData gd = new GridData(gdStyle);
    gd.horizontalSpan = hspan;
    c.setLayoutData(gd);
    return c;
}
 
Example 19
Source File: SWTStrategySelectionPanel.java    From atdl4j with MIT License 4 votes vote down vote up
public Composite buildStrategySelectionPanel(Composite aParentComposite, Atdl4jOptions atdl4jOptions)
	{
		setAtdl4jOptions( atdl4jOptions );
		
		// Strategy selector dropdown
		dropdownComposite = new Composite(aParentComposite, SWT.NONE);
		GridLayout dropdownLayout = new GridLayout(2, false);
		dropdownComposite.setLayout(dropdownLayout);
		dropdownComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
		// label
		Label strategiesDropDownLabel = new Label(dropdownComposite, SWT.NONE);
		strategiesDropDownLabel.setText("Strategy");
		// dropDownList
		strategiesDropDown = new Combo(dropdownComposite, SWT.READ_ONLY | SWT.BORDER);
		strategiesDropDown.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));

		// -- Increase font size for Drop Down --
		FontData[] fontData = strategiesDropDown.getFont().getFontData(); 
		for(int i = 0; i < fontData.length; ++i)
		{
		    fontData[i].setHeight( fontData[i].getHeight() + 3 ); 
		    fontData[i].setStyle( SWT.BOLD );
		}
		
		final Font newFont = new Font(strategiesDropDown.getDisplay(), fontData); 
		strategiesDropDown.setFont(newFont); 
		 
		// Since you created the font, you must dispose it 
		strategiesDropDown.addDisposeListener(new DisposeListener()
		{
		    public void widgetDisposed(DisposeEvent e) 
		    { 
		        newFont.dispose(); 
		    } 
		}); 
		
// TODO wish to avoid issue with changing the font causes the initial combo box display to be very narrow 
	
		if ( Atdl4jConfig.getConfig().getStrategyDropDownItemDepth() != null )
		{
			strategiesDropDown.setVisibleItemCount( Atdl4jConfig.getConfig().getStrategyDropDownItemDepth().intValue() );
		}
		// tooltip
		strategiesDropDown.setToolTipText("Select a Strategy");
		// action listener
		strategiesDropDown.addSelectionListener(new SelectionAdapter() 
			{
				@Override
				public void widgetSelected(SelectionEvent event) 
				{
					int index = strategiesDropDown.getSelectionIndex();
					logger.debug( "strategiesDropDown.widgetSelected.  strategiesDropDown.getSelectionIndex(): " + index );					
					selectDropDownStrategy( index );
				}
			} 
		);
	
		return dropdownComposite;
	}
 
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;
}