/** * Create a new CheckboxPreference. * * @param parentComposite The composite on which the SWT widgets are added. * @param indent how many levels of indentation to apply. * @param label The label text for this Preference. * @param key The key to store the values. * @param values An array of two elements indicating the values to store when unchecked/checked. * @return a newly created CheckboxPreference. */ public static CheckboxPreference create(Composite parentComposite, int indent, String label, String key, String[] values) { Button checkbox= new Button(parentComposite, SWT.CHECK); checkbox.setText(label); checkbox.setLayoutData(createGridData(GRID_COLUMNS - 1, GridData.FILL_HORIZONTAL, SWT.DEFAULT, indent)); checkbox.setFont(parentComposite.getFont()); return new CheckboxPreference(checkbox, label, key, values); }
/** * @param parentComposite The composite on which the SWT widgets are added. * @param indent how many levels of indentation to apply. * @param label the label text for this Preference. * @param key the key to store the values. * @param highlight whether highlight arrow should be added * @return a newly created StringPreference */ public static StringPreference create(Composite parentComposite, int indent, String label, String key, boolean highlight) { Text text= new Text(parentComposite, SWT.SINGLE | SWT.BORDER); text.setFont(parentComposite.getFont()); final int length= 30; PixelConverter pixelConverter= new PixelConverter(parentComposite); GridData gridData= createGridData(1, GridData.HORIZONTAL_ALIGN_BEGINNING, pixelConverter.convertWidthInCharsToPixels(length), 0); gridData.grabExcessHorizontalSpace= true; text.setLayoutData(gridData); StringPreference stringPreference= new StringPreference(text, label, key); stringPreference.addLabel(label, highlight, indent); return stringPreference; }
static Spinner createSpinner(Composite parentComposite, int minValue, int maxValue) { Spinner spinner= new Spinner(parentComposite, SWT.BORDER); spinner.setFont(parentComposite.getFont()); spinner.setMinimum(minValue); spinner.setMaximum(maxValue); spinner.setLayoutData(createGridData(1, GridData.HORIZONTAL_ALIGN_END, SWT.DEFAULT, 0)); return spinner; }
/** * @param parentComposite The composite on which the SWT widgets are added. * @param indent how many levels of indentation to apply. * @param label The label text for this Preference or {@code null} if none. * @param key The key to store the values. * @param values An array of n elements indicating the values to store for each selection. * @param items An array of n elements indicating the text to be written in the combo box. * @param highlight whether highlight arrow should be added. * @return a newly created ComboPreference. */ public static ComboPreference create(Composite parentComposite, int indent, String label, String key, String[] values, String[] items, boolean highlight) { Combo combo= new Combo(parentComposite, SWT.SINGLE | SWT.READ_ONLY); combo.setFont(parentComposite.getFont()); SWTUtil.setDefaultVisibleItemCount(combo); combo.setItems(items); combo.setLayoutData(createGridData(1, GridData.HORIZONTAL_ALIGN_FILL, combo.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, 0)); ComboPreference comboPreference= new ComboPreference(combo, label, key, values); comboPreference.addLabel(label, highlight, indent); return comboPreference; }