Search in sources :

Example 21 with Spinner

use of org.eclipse.swt.widgets.Spinner in project linuxtools by eclipse.

the class ValgrindOptionsTab method createErrorOptions.

private void createErrorOptions(Composite top) {
    Group errorGroup = new Group(top, SWT.NONE);
    errorGroup.setLayout(new GridLayout());
    errorGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // $NON-NLS-1$
    errorGroup.setText(Messages.getString("ValgrindOptionsTab.Error_Options"));
    Composite errorTop = new Composite(errorGroup, SWT.NONE);
    errorTop.setLayout(new GridLayout(2, true));
    errorTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    demangleButton = new Button(errorTop, SWT.CHECK);
    // $NON-NLS-1$
    demangleButton.setText(Messages.getString("ValgrindOptionsTab.demangle"));
    demangleButton.addSelectionListener(selectListener);
    demangleButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Composite numCallersTop = new Composite(errorTop, SWT.NONE);
    numCallersTop.setLayout(new GridLayout(2, false));
    Label numCallersLabel = new Label(numCallersTop, SWT.NONE);
    // $NON-NLS-1$
    numCallersLabel.setText(Messages.getString("ValgrindOptionsTab.num_callers"));
    numCallersSpinner = new Spinner(numCallersTop, SWT.BORDER);
    numCallersSpinner.setMaximum(50);
    numCallersSpinner.addModifyListener(modifyListener);
    numCallersSpinner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    errorLimitButton = new Button(errorTop, SWT.CHECK);
    // $NON-NLS-1$
    errorLimitButton.setText(Messages.getString("ValgrindOptionsTab.limit_errors"));
    errorLimitButton.addSelectionListener(selectListener);
    errorLimitButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    showBelowMainButton = new Button(errorTop, SWT.CHECK);
    // $NON-NLS-1$
    showBelowMainButton.setText(Messages.getString("ValgrindOptionsTab.show_errors_below_main"));
    showBelowMainButton.addSelectionListener(selectListener);
    showBelowMainButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Composite maxStackFrameTop = new Composite(errorTop, SWT.NONE);
    maxStackFrameTop.setLayout(new GridLayout(2, false));
    Label maxStackFrameLabel = new Label(maxStackFrameTop, SWT.NONE);
    // $NON-NLS-1$
    maxStackFrameLabel.setText(Messages.getString("ValgrindOptionsTab.max_size_of_stack_frame"));
    maxStackFrameSpinner = new Spinner(maxStackFrameTop, SWT.BORDER);
    maxStackFrameSpinner.setMaximum(Integer.MAX_VALUE);
    maxStackFrameSpinner.addModifyListener(modifyListener);
    maxStackFrameSpinner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // Option only visible for valgrind > 3.4.0
    mainStackSizeTop = new Composite(errorTop, SWT.NONE);
    GridLayout mainStackSizeLayout = new GridLayout(2, false);
    mainStackSizeLayout.marginHeight = mainStackSizeLayout.marginWidth = 0;
    mainStackSizeTop.setLayout(mainStackSizeLayout);
    mainStackSizeButton = new Button(mainStackSizeTop, SWT.CHECK);
    // $NON-NLS-1$
    mainStackSizeButton.setText(Messages.getString("ValgrindOptionsTab.Main_stack_size"));
    mainStackSizeButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
        checkMainStackEnablement();
        updateLaunchConfigurationDialog();
    }));
    mainStackSizeSpinner = new Spinner(mainStackSizeTop, SWT.BORDER);
    mainStackSizeSpinner.setMaximum(Integer.MAX_VALUE);
    mainStackSizeSpinner.addModifyListener(modifyListener);
    mainStackSizeSpinner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    mainStackSizeTop.setVisible(false);
    // Option only visible for valgrind > 3.6.0
    dSymUtilButton = new Button(errorTop, SWT.CHECK);
    // $NON-NLS-1$
    dSymUtilButton.setText(Messages.getString("ValgrindOptionsTab.dsymutil"));
    dSymUtilButton.addSelectionListener(selectListener);
    dSymUtilButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    dSymUtilButton.setVisible(false);
}
Also used : WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) Arrays(java.util.Arrays) TabFolder(org.eclipse.swt.widgets.TabFolder) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) ConfigUtils(org.eclipse.linuxtools.profiling.launch.ConfigUtils) Image(org.eclipse.swt.graphics.Image) CoreException(org.eclipse.core.runtime.CoreException) Spinner(org.eclipse.swt.widgets.Spinner) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) Point(org.eclipse.swt.graphics.Point) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IStatus(org.eclipse.core.runtime.IStatus) IProject(org.eclipse.core.resources.IProject) IPath(org.eclipse.core.runtime.IPath) AbstractLaunchConfigurationTab(org.eclipse.debug.ui.AbstractLaunchConfigurationTab) VariablesPlugin(org.eclipse.core.variables.VariablesPlugin) Composite(org.eclipse.swt.widgets.Composite) AbstractUIPlugin(org.eclipse.ui.plugin.AbstractUIPlugin) GridData(org.eclipse.swt.layout.GridData) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) TabItem(org.eclipse.swt.widgets.TabItem) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) Button(org.eclipse.swt.widgets.Button) NLS(org.eclipse.osgi.util.NLS) FileDialog(org.eclipse.swt.widgets.FileDialog) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) Status(org.eclipse.core.runtime.Status) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Version(org.osgi.framework.Version) Group(org.eclipse.swt.widgets.Group) ModifyListener(org.eclipse.swt.events.ModifyListener) IResource(org.eclipse.core.resources.IResource) SWT(org.eclipse.swt.SWT) List(org.eclipse.swt.widgets.List) IValgrindToolPage(org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) Control(org.eclipse.swt.widgets.Control) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) SelectionListener(org.eclipse.swt.events.SelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Button(org.eclipse.swt.widgets.Button) Spinner(org.eclipse.swt.widgets.Spinner) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label)

Example 22 with Spinner

use of org.eclipse.swt.widgets.Spinner in project linuxtools by eclipse.

the class MassifToolPage method createControl.

@Override
public void createControl(Composite parent) {
    Composite top = new Composite(parent, SWT.NONE);
    GridLayout topLayout = new GridLayout(2, true);
    topLayout.horizontalSpacing = 10;
    top.setLayout(topLayout);
    top.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite heapTop = new Composite(top, SWT.NONE);
    heapTop.setLayout(new GridLayout(2, false));
    heapButton = new Button(heapTop, SWT.CHECK);
    // $NON-NLS-1$
    heapButton.setText(Messages.getString("MassifToolPage.profile_heap"));
    heapButton.addSelectionListener(selectListener);
    Composite heapAdminTop = new Composite(top, SWT.NONE);
    heapAdminTop.setLayout(new GridLayout(2, false));
    Label heapAdminLabel = new Label(heapAdminTop, SWT.NONE);
    // $NON-NLS-1$
    heapAdminLabel.setText(Messages.getString("MassifToolPage.administrative_bytes"));
    heapAdminSpinner = new Spinner(heapAdminTop, SWT.BORDER);
    heapAdminSpinner.addModifyListener(modifyListener);
    Composite stacksTop = new Composite(top, SWT.NONE);
    stacksTop.setLayout(new GridLayout(2, false));
    stacksButton = new Button(stacksTop, SWT.CHECK);
    // $NON-NLS-1$
    stacksButton.setText(Messages.getString("MassifToolPage.profile_stack"));
    stacksButton.addSelectionListener(selectListener);
    if (valgrindVersion == null || valgrindVersion.compareTo(VER_3_6_0) >= 0) {
        Composite pagesasheapTop = new Composite(top, SWT.NONE);
        pagesasheapTop.setLayout(new GridLayout(2, false));
        pagesasheapButton = new Button(pagesasheapTop, SWT.CHECK);
        // $NON-NLS-1$
        pagesasheapButton.setText(Messages.getString("MassifToolPage.profile_pagesasheap"));
        pagesasheapButton.addSelectionListener(selectListener);
    }
    Composite depthTop = new Composite(top, SWT.NONE);
    depthTop.setLayout(new GridLayout(2, false));
    Label depthLabel = new Label(depthTop, SWT.NONE);
    // $NON-NLS-1$
    depthLabel.setText(Messages.getString("MassifToolPage.allocation_tree_depth"));
    depthSpinner = new Spinner(depthTop, SWT.BORDER);
    depthSpinner.addModifyListener(modifyListener);
    Composite thresholdTop = new Composite(top, SWT.NONE);
    thresholdTop.setLayout(new GridLayout(3, false));
    Label thresholdLabel = new Label(thresholdTop, SWT.NONE);
    // $NON-NLS-1$
    thresholdLabel.setText(Messages.getString("MassifToolPage.heap_allocation_threshold"));
    thresholdSpinner = new Spinner(thresholdTop, SWT.BORDER);
    thresholdSpinner.setDigits(1);
    thresholdSpinner.setMaximum(1000);
    thresholdSpinner.addModifyListener(modifyListener);
    Label thresholdPercentLabel = new Label(thresholdTop, SWT.NONE);
    // $NON-NLS-1$
    thresholdPercentLabel.setText("%");
    Composite peakInaccuracyTop = new Composite(top, SWT.NONE);
    peakInaccuracyTop.setLayout(new GridLayout(3, false));
    Label peakInaccuracyLabel = new Label(peakInaccuracyTop, SWT.NONE);
    // $NON-NLS-1$
    peakInaccuracyLabel.setText(Messages.getString("MassifToolPage.allocation_peak_inaccuracy"));
    peakInaccuracySpinner = new Spinner(peakInaccuracyTop, SWT.BORDER);
    peakInaccuracySpinner.setDigits(1);
    peakInaccuracySpinner.setMaximum(1000);
    peakInaccuracySpinner.addModifyListener(modifyListener);
    Label peakInaccuracyPercentLabel = new Label(peakInaccuracyTop, SWT.NONE);
    // $NON-NLS-1$
    peakInaccuracyPercentLabel.setText("%");
    Composite timeUnitTop = new Composite(top, SWT.NONE);
    timeUnitTop.setLayout(new GridLayout(2, false));
    Label timeUnitLabel = new Label(timeUnitTop, SWT.NONE);
    // $NON-NLS-1$
    timeUnitLabel.setText(Messages.getString("MassifToolPage.time_unit"));
    timeUnitCombo = new Combo(timeUnitTop, SWT.READ_ONLY);
    String[] items = new String[] { TIME_I_STRING, TIME_MS_STRING, TIME_B_STRING };
    timeUnitCombo.setItems(items);
    timeUnitCombo.addSelectionListener(selectListener);
    Composite detailedFreqTop = new Composite(top, SWT.NONE);
    detailedFreqTop.setLayout(new GridLayout(2, false));
    Label detailedFreqLabel = new Label(detailedFreqTop, SWT.NONE);
    // $NON-NLS-1$
    detailedFreqLabel.setText(Messages.getString("MassifToolPage.detailed_snapshot_freq"));
    detailedFreqSpinner = new Spinner(detailedFreqTop, SWT.BORDER);
    detailedFreqSpinner.setMinimum(1);
    detailedFreqSpinner.setMaximum(Integer.MAX_VALUE);
    detailedFreqSpinner.addModifyListener(modifyListener);
    Composite maxSnapshotsTop = new Composite(top, SWT.NONE);
    maxSnapshotsTop.setLayout(new GridLayout(2, false));
    Label maxSnapshotsLabel = new Label(maxSnapshotsTop, SWT.NONE);
    // $NON-NLS-1$
    maxSnapshotsLabel.setText(Messages.getString("MassifToolPage.max_snapshots"));
    maxSnapshotsSpinner = new Spinner(maxSnapshotsTop, SWT.BORDER);
    maxSnapshotsSpinner.setMaximum(Integer.MAX_VALUE);
    maxSnapshotsSpinner.addModifyListener(modifyListener);
    Composite alignmentTop = new Composite(top, SWT.NONE);
    GridLayout alignmentLayout = new GridLayout(2, false);
    alignmentLayout.marginWidth = alignmentLayout.marginHeight = 0;
    alignmentTop.setLayout(alignmentLayout);
    alignmentButton = new Button(alignmentTop, SWT.CHECK);
    // $NON-NLS-1$
    alignmentButton.setText(Messages.getString("MassifToolPage.minimum_heap_block"));
    alignmentButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
        checkAlignmentEnablement();
        updateLaunchConfigurationDialog();
    }));
    alignmentSpinner = new Spinner(alignmentTop, SWT.BORDER);
    alignmentSpinner.setMinimum(0);
    alignmentSpinner.setMaximum(4096);
    alignmentSpinner.addModifyListener(modifyListener);
    Composite allocFnTop = new Composite(top, SWT.NONE);
    allocFnTop.setLayout(new GridLayout(3, false));
    allocFnTop.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1));
    Label allocFnLabel = new Label(allocFnTop, SWT.NONE);
    // $NON-NLS-1$
    allocFnLabel.setText(Messages.getString("MassifToolPage.allocation_functions"));
    allocFnLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
    createAllocFnControls(allocFnTop);
    Composite ignoreFnTop = new Composite(top, SWT.NONE);
    ignoreFnTop.setLayout(new GridLayout(3, false));
    ignoreFnTop.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1));
    Label ignoreFnLabel = new Label(ignoreFnTop, SWT.NONE);
    // $NON-NLS-1$
    ignoreFnLabel.setText(Messages.getString("MassifToolPage.ignore_functions"));
    ignoreFnLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
    createIgnoreFnControls(ignoreFnTop);
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) Arrays(java.util.Arrays) Combo(org.eclipse.swt.widgets.Combo) Button(org.eclipse.swt.widgets.Button) LaunchConfigurationConstants(org.eclipse.linuxtools.internal.valgrind.launch.LaunchConfigurationConstants) FontMetrics(org.eclipse.swt.graphics.FontMetrics) CoreException(org.eclipse.core.runtime.CoreException) Spinner(org.eclipse.swt.widgets.Spinner) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Version(org.osgi.framework.Version) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) Window(org.eclipse.jface.window.Window) AbstractLaunchConfigurationTab(org.eclipse.debug.ui.AbstractLaunchConfigurationTab) Dialog(org.eclipse.jface.dialogs.Dialog) ModifyListener(org.eclipse.swt.events.ModifyListener) Composite(org.eclipse.swt.widgets.Composite) SWT(org.eclipse.swt.SWT) List(org.eclipse.swt.widgets.List) IValgrindToolPage(org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionListener(org.eclipse.swt.events.SelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) Spinner(org.eclipse.swt.widgets.Spinner) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo)

Example 23 with Spinner

use of org.eclipse.swt.widgets.Spinner in project knime-core by knime.

the class BorderStyleDialog method createSizeSelector.

private void createSizeSelector(final Composite parent) {
    Composite panel = new Composite(parent, SWT.FILL);
    GridData gData = new GridData(GridData.FILL_HORIZONTAL);
    panel.setLayoutData(gData);
    panel.setLayout(new GridLayout(2, false));
    Label msg = new Label(panel, SWT.LEFT);
    msg.setText("Border size (0 = no border):");
    msg.setLayoutData(gData);
    final Spinner spinner = new Spinner(panel, SWT.NONE);
    spinner.setDigits(3);
    spinner.setValues(m_defBorderSize, 0, 100, 0, 1, 5);
    spinner.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            m_size = spinner.getSelection();
        }
    });
    m_size = m_defBorderSize;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Spinner(org.eclipse.swt.widgets.Spinner) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label)

Example 24 with Spinner

use of org.eclipse.swt.widgets.Spinner in project eclipse.platform.swt by eclipse.

the class ImageTransformTab method createControlPanel.

/**
 * This method creates the controls specific to the tab. The call to the
 * createControlPanel method in the super class create the controls that are
 * defined in the super class.
 *
 * @param parent The parent composite
 */
@Override
public void createControlPanel(Composite parent) {
    Composite comp;
    GridLayout gridLayout = new GridLayout(2, false);
    // create spinner for the rotation angle
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(gridLayout);
    // $NON-NLS-1$
    new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("Rotate"));
    rotateSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP);
    GC gc = new GC(rotateSpinner);
    int width = (int) (gc.getFontMetrics().getAverageCharacterWidth() * 5);
    gc.dispose();
    rotateSpinner.setLayoutData(new GridData(width, SWT.DEFAULT));
    rotateSpinner.setSelection(0);
    rotateSpinner.setMinimum(-720);
    rotateSpinner.setMaximum(720);
    rotateSpinner.setIncrement(30);
    rotateSpinner.addListener(SWT.Selection, event -> example.redraw());
    // create a spinner for translating along the x axis
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(gridLayout);
    // $NON-NLS-1$
    new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("xtranslate"));
    translateSpinnerX = new Spinner(comp, SWT.BORDER | SWT.WRAP);
    translateSpinnerX.setLayoutData(new GridData(width, SWT.DEFAULT));
    translateSpinnerX.setMinimum(-100);
    translateSpinnerX.setMaximum(500);
    translateSpinnerX.setSelection(0);
    translateSpinnerX.setIncrement(10);
    translateSpinnerX.addListener(SWT.Selection, event -> example.redraw());
    // create a spinner for translating along the y axis
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(gridLayout);
    // $NON-NLS-1$
    new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("ytranslate"));
    translateSpinnerY = new Spinner(comp, SWT.BORDER | SWT.WRAP);
    translateSpinnerY.setLayoutData(new GridData(width, SWT.DEFAULT));
    translateSpinnerY.setMinimum(-100);
    translateSpinnerY.setMaximum(500);
    translateSpinnerY.setSelection(0);
    translateSpinnerY.setIncrement(10);
    translateSpinnerY.addListener(SWT.Selection, event -> example.redraw());
    // create a spinner for scaling along the x axis
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(gridLayout);
    // $NON-NLS-1$
    new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("xscale"));
    scaleSpinnerX = new Spinner(comp, SWT.BORDER | SWT.WRAP);
    scaleSpinnerX.setLayoutData(new GridData(width, SWT.DEFAULT));
    scaleSpinnerX.setDigits(2);
    scaleSpinnerX.setMinimum(1);
    scaleSpinnerX.setMaximum(400);
    scaleSpinnerX.setSelection(100);
    scaleSpinnerX.setIncrement(10);
    scaleSpinnerX.addListener(SWT.Selection, event -> example.redraw());
    // create a spinner for scaling along the y axis
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(gridLayout);
    // $NON-NLS-1$
    new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("yscale"));
    scaleSpinnerY = new Spinner(comp, SWT.BORDER | SWT.WRAP);
    scaleSpinnerY.setLayoutData(new GridData(width, SWT.DEFAULT));
    scaleSpinnerY.setDigits(2);
    scaleSpinnerY.setMinimum(1);
    scaleSpinnerY.setMaximum(400);
    scaleSpinnerY.setSelection(100);
    scaleSpinnerY.setIncrement(10);
    scaleSpinnerY.addListener(SWT.Selection, event -> example.redraw());
    // create a button for inverting the transform matrix
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout());
    invertButton = new Button(comp, SWT.TOGGLE);
    // $NON-NLS-1$
    invertButton.setText(GraphicsExample.getResourceString("Invert"));
    invertButton.addListener(SWT.Selection, event -> example.redraw());
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) Spinner(org.eclipse.swt.widgets.Spinner) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) GC(org.eclipse.swt.graphics.GC)

Example 25 with Spinner

use of org.eclipse.swt.widgets.Spinner in project eclipse.platform.swt by eclipse.

the class SpiralTab method createControlPanel.

/**
 * This method creates a spinner for specifying the number of petals. The call to the
 * createControlPanel method in the super class create the controls that are
 * defined in the super class.
 *
 * @param parent The parent composite
 */
@Override
public void createControlPanel(Composite parent) {
    super.createControlPanel(parent);
    // create spinner number of petals
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));
    new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString(// $NON-NLS-1$
    "Petals"));
    petalSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP);
    petalSpinner.setSelection(8);
    petalSpinner.setMinimum(3);
    petalSpinner.setMaximum(20);
    petalSpinner.addListener(SWT.Selection, event -> example.redraw());
    // create color button
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout());
    ColorMenu cm = new ColorMenu();
    cm.setPatternItems(example.checkAdvancedGraphics());
    menu = cm.createMenu(parent.getParent(), gb -> {
        foreground = gb;
        colorButton.setImage(gb.getThumbNail());
        example.redraw();
    });
    // initialize the foreground to the 2nd item in the menu
    foreground = (GraphicsBackground) menu.getItem(1).getData();
    // color button
    colorButton = new Button(comp, SWT.PUSH);
    colorButton.setText(GraphicsExample.getResourceString(// $NON-NLS-1$
    "Color"));
    colorButton.setImage(foreground.getThumbNail());
    colorButton.addListener(SWT.Selection, event -> {
        final Button button = (Button) event.widget;
        final Composite parent1 = button.getParent();
        Rectangle bounds = button.getBounds();
        Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));
        menu.setLocation(point.x, point.y + bounds.height);
        menu.setVisible(true);
    });
}
Also used : Transform(org.eclipse.swt.graphics.Transform) Button(org.eclipse.swt.widgets.Button) Device(org.eclipse.swt.graphics.Device) Pattern(org.eclipse.swt.graphics.Pattern) Rectangle(org.eclipse.swt.graphics.Rectangle) Spinner(org.eclipse.swt.widgets.Spinner) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point) Composite(org.eclipse.swt.widgets.Composite) SWT(org.eclipse.swt.SWT) Menu(org.eclipse.swt.widgets.Menu) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) Spinner(org.eclipse.swt.widgets.Spinner) Label(org.eclipse.swt.widgets.Label) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point)

Aggregations

Spinner (org.eclipse.swt.widgets.Spinner)70 GridLayout (org.eclipse.swt.layout.GridLayout)54 Label (org.eclipse.swt.widgets.Label)54 Button (org.eclipse.swt.widgets.Button)53 Composite (org.eclipse.swt.widgets.Composite)52 GridData (org.eclipse.swt.layout.GridData)51 Group (org.eclipse.swt.widgets.Group)32 SelectionEvent (org.eclipse.swt.events.SelectionEvent)25 Text (org.eclipse.swt.widgets.Text)24 Combo (org.eclipse.swt.widgets.Combo)20 SelectionListener (org.eclipse.swt.events.SelectionListener)19 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)18 SWT (org.eclipse.swt.SWT)16 ModifyListener (org.eclipse.swt.events.ModifyListener)14 ModifyEvent (org.eclipse.swt.events.ModifyEvent)11 Point (org.eclipse.swt.graphics.Point)11 Control (org.eclipse.swt.widgets.Control)10 CoreException (org.eclipse.core.runtime.CoreException)6 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)6 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)6