Search in sources :

Example 36 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project linuxtools by eclipse.

the class SelectGraphAndSeriesWizardPage method createControl.

@Override
public void createControl(Composite parent) {
    wizard = (SelectGraphAndSeriesWizard) getWizard();
    model = wizard.model;
    boolean edit = wizard.isEditing();
    // Set the layout data
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout());
    Group cmpGraphOptsGraph = new Group(comp, SWT.SHADOW_ETCHED_IN);
    cmpGraphOptsGraph.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    RowLayout rowLayout = new RowLayout();
    rowLayout.type = SWT.HORIZONTAL;
    rowLayout.spacing = 10;
    cmpGraphOptsGraph.setLayout(rowLayout);
    // $NON-NLS-1$
    cmpGraphOptsGraph.setText(Localization.getString("SelectGraphAndSeriesWizardPage.Graph"));
    String[] graphIDs = GraphFactory.getAvailableGraphs(wizard.model.getDataSet());
    int btnGraphSelected = -1;
    btnGraphs = new Button[graphIDs.length];
    for (int i = 0; i < btnGraphs.length; i++) {
        btnGraphs[i] = new Button(cmpGraphOptsGraph, SWT.RADIO);
        btnGraphs[i].setImage(GraphFactory.getGraphImage(graphIDs[i]));
        btnGraphs[i].addListener(SWT.Selection, this);
        btnGraphs[i].setData(graphIDs[i]);
        btnGraphs[i].setToolTipText(// $NON-NLS-1$
        GraphFactory.getGraphName(btnGraphs[i].getData().toString()) + "\n\n" + GraphFactory.getGraphDescription(btnGraphs[i].getData().toString()));
        if (btnGraphSelected == -1 && wizard.isEditing() && graphIDs[i].equals(wizard.model.getGraphID())) {
            btnGraphs[i].setSelection(true);
            btnGraphSelected = i;
        }
    }
    ScrolledComposite scrolledComposite = new ScrolledComposite(comp, SWT.V_SCROLL | SWT.BORDER);
    scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    scrolledComposite.setExpandHorizontal(true);
    Composite cmpGraphOptsSeries = new Composite(scrolledComposite, SWT.NONE);
    cmpGraphOptsSeries.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    cmpGraphOptsSeries.setLayout(new GridLayout(2, false));
    scrolledComposite.setContent(cmpGraphOptsSeries);
    Label lblTitle = new Label(cmpGraphOptsSeries, SWT.NONE);
    lblTitle.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    // $NON-NLS-1$
    lblTitle.setText(Localization.getString("SelectGraphAndSeriesWizardPage.Title"));
    txtTitle = new Text(cmpGraphOptsSeries, SWT.BORDER);
    txtTitle.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    if (edit) {
        txtTitle.setText(model.getGraphData().title);
    }
    txtTitle.addModifyListener(e -> checkErrors(false));
    // Add the data series widgets
    String[] labels = model.getSeries();
    cboYItems = new Combo[!edit ? labels.length : Math.max(labels.length, model.getYSeries().length)];
    lblYItems = new Label[cboYItems.length];
    deleted = new boolean[cboYItems.length + 1];
    Label lblXItem = new Label(cmpGraphOptsSeries, SWT.NONE);
    lblXItem.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    // $NON-NLS-1$
    lblXItem.setText(Localization.getString("SelectGraphAndSeriesWizardPage.XSeries"));
    cboXItem = new Combo(cmpGraphOptsSeries, SWT.DROP_DOWN | SWT.READ_ONLY);
    cboXItem.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    cboXItem.addSelectionListener(new ComboSelectionListener());
    // $NON-NLS-1$
    cboXItem.add(Localization.getString("SelectGraphAndSeriesWizardPage.RowID"));
    for (int i = 0; i < cboYItems.length; i++) {
        lblYItems[i] = new Label(cmpGraphOptsSeries, SWT.NONE);
        lblYItems[i].setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
        // $NON-NLS-1$
        lblYItems[i].setText(MessageFormat.format(Localization.getString("SelectGraphAndSeriesWizardPage.YSeries"), i));
        cboYItems[i] = new Combo(cmpGraphOptsSeries, SWT.DROP_DOWN | SWT.READ_ONLY);
        cboYItems[i].setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
        cboYItems[i].addSelectionListener(new ComboSelectionListener());
        if (i > 0) {
            // $NON-NLS-1$
            cboYItems[i].add(Localization.getString("SelectGraphAndSeriesWizardPage.NA"));
            cboYItems[i].setVisible(false);
            lblYItems[i].setVisible(false);
        }
    }
    for (int j, i = 0; i < labels.length; i++) {
        cboXItem.add(labels[i]);
        for (j = 0; j < lblYItems.length; j++) {
            cboYItems[j].add(labels[i]);
        }
    }
    int selected;
    if (!edit) {
        cboXItem.select(0);
        cboYItems[0].select(0);
    } else {
        selected = model.getXSeries();
        if (selected < labels.length) {
            cboXItem.select(selected + 1);
        } else {
            // $NON-NLS-1$
            cboXItem.add(Localization.getString("SelectGraphAndSeriesWizardPage.Deleted"), 0);
            cboXItem.select(0);
            deleted[0] = true;
        }
        selected = model.getYSeries()[0];
        if (selected < labels.length) {
            cboYItems[0].select(selected);
        } else {
            // $NON-NLS-1$
            cboYItems[0].add(Localization.getString("SelectGraphAndSeriesWizardPage.Deleted"), 0);
            cboYItems[0].select(0);
            deleted[1] = true;
        }
    }
    boolean cvisible = true;
    for (int i = 1; i < cboYItems.length; i++) {
        if (!edit || model.getYSeries().length <= i) {
            cboYItems[i].select(selected = 0);
        } else {
            selected = model.getYSeries()[i];
            if (selected < labels.length) {
                cboYItems[i].select(selected + 1);
            } else {
                cboYItems[i].add(Localization.getString("SelectGraphAndSeriesWizardPage.Deleted"), // $NON-NLS-1$
                0);
                cboYItems[i].select(0);
                deleted[i + 1] = true;
            }
        }
        cboYItems[i].setVisible(cvisible);
        lblYItems[i].setVisible(cvisible);
        cvisible = (selected > 0);
    }
    // Select one of the graph types by default, rather than blank choice
    if (!edit) {
        btnGraphs[0].setSelection(true);
        saveDataToModelGraph(graphIDs[0]);
    } else if (btnGraphSelected == -1) {
        saveDataToModelGraph(null);
    }
    cmpGraphOptsSeries.pack();
    setControl(comp);
    checkErrors(true);
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite)

Example 37 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project knime-core by knime.

the class LabeledFilterViewContributionItem method createControl.

/**
 * {@inheritDoc}
 */
@Override
protected Control createControl(final Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    RowLayout layout = new RowLayout();
    layout.fill = true;
    layout.wrap = false;
    layout.center = true;
    layout.marginBottom = 0;
    layout.marginTop = 0;
    layout.marginLeft = 0;
    layout.marginRight = 0;
    comp.setLayout(layout);
    m_label = new Text(comp, SWT.NONE);
    m_label.setText("Filter");
    m_label.setEditable(false);
    m_label.setBackground(parent.getBackground());
    Combo combo = new Combo(comp, SWT.DROP_DOWN);
    combo.addKeyListener(this);
    combo.addSelectionListener(createSelectionAdaptor());
    RowData rowData = new RowData();
    rowData.width = 150;
    combo.setLayoutData(rowData);
    setCombo(combo);
    return comp;
}
Also used : RowData(org.eclipse.swt.layout.RowData) Composite(org.eclipse.swt.widgets.Composite) RowLayout(org.eclipse.swt.layout.RowLayout) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo)

Example 38 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project eclipse.platform.swt by eclipse.

the class ImageAnalyzer method createWidgets.

void createWidgets() {
    // Add the widgets to the shell in a grid layout.
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.numColumns = 2;
    shell.setLayout(layout);
    // Add a composite to contain some control widgets across the top.
    Composite controls = new Composite(shell, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.marginTop = 5;
    rowLayout.marginBottom = 5;
    rowLayout.spacing = 8;
    controls.setLayout(rowLayout);
    GridData gridData = new GridData();
    gridData.horizontalSpan = 2;
    controls.setLayoutData(gridData);
    // Combo to change the background.
    Group group = new Group(controls, SWT.NONE);
    group.setLayout(new RowLayout());
    group.setText(bundle.getString("Background"));
    backgroundCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY);
    backgroundCombo.setItems(bundle.getString("None"), bundle.getString("White"), bundle.getString("Black"), bundle.getString("Red"), bundle.getString("Green"), bundle.getString("Blue"));
    backgroundCombo.select(backgroundCombo.indexOf(bundle.getString("White")));
    backgroundCombo.addSelectionListener(widgetSelectedAdapter(event -> changeBackground()));
    // Combo to change the compression ratio.
    group = new Group(controls, SWT.NONE);
    group.setLayout(new GridLayout(3, true));
    group.setText(bundle.getString("Save_group"));
    imageTypeCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY);
    String[] types = { "JPEG", "PNG", "GIF", "ICO", "TIFF", "BMP" };
    for (String type : types) {
        imageTypeCombo.add(type);
    }
    imageTypeCombo.select(imageTypeCombo.indexOf("JPEG"));
    imageTypeCombo.addSelectionListener(widgetSelectedAdapter(event -> {
        int index = imageTypeCombo.getSelectionIndex();
        switch(index) {
            case 0:
                compressionCombo.setEnabled(true);
                compressionRatioLabel.setEnabled(true);
                if (compressionCombo.getItemCount() == 100)
                    break;
                compressionCombo.removeAll();
                for (int i = 0; i < 100; i++) {
                    compressionCombo.add(String.valueOf(i + 1));
                }
                compressionCombo.select(compressionCombo.indexOf("75"));
                break;
            case 1:
                compressionCombo.setEnabled(true);
                compressionRatioLabel.setEnabled(true);
                if (compressionCombo.getItemCount() == 10)
                    break;
                compressionCombo.removeAll();
                for (int i = 0; i < 4; i++) {
                    compressionCombo.add(String.valueOf(i));
                }
                compressionCombo.select(0);
                break;
            case 2:
            case 3:
            case 4:
            case 5:
                compressionCombo.setEnabled(false);
                compressionRatioLabel.setEnabled(false);
                break;
        }
    }));
    imageTypeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    compressionRatioLabel = new Label(group, SWT.NONE);
    compressionRatioLabel.setText(bundle.getString("Compression"));
    compressionRatioLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    compressionCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY);
    for (int i = 0; i < 100; i++) {
        compressionCombo.add(String.valueOf(i + 1));
    }
    compressionCombo.select(compressionCombo.indexOf("75"));
    compressionCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    // Combo to change the x scale.
    String[] values = { "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2", "3", "4", "5", "6", "7", "8", "9", "10" };
    group = new Group(controls, SWT.NONE);
    group.setLayout(new RowLayout());
    group.setText(bundle.getString("X_scale"));
    scaleXCombo = new Combo(group, SWT.DROP_DOWN);
    for (String value : values) {
        scaleXCombo.add(value);
    }
    scaleXCombo.select(scaleXCombo.indexOf("1"));
    scaleXCombo.addSelectionListener(widgetSelectedAdapter(event -> scaleX()));
    // Combo to change the y scale.
    group = new Group(controls, SWT.NONE);
    group.setLayout(new RowLayout());
    group.setText(bundle.getString("Y_scale"));
    scaleYCombo = new Combo(group, SWT.DROP_DOWN);
    for (String value : values) {
        scaleYCombo.add(value);
    }
    scaleYCombo.select(scaleYCombo.indexOf("1"));
    scaleYCombo.addSelectionListener(widgetSelectedAdapter(event -> scaleY()));
    // Combo to change the alpha value.
    group = new Group(controls, SWT.NONE);
    group.setLayout(new RowLayout());
    group.setText(bundle.getString("Alpha_K"));
    alphaCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY);
    for (int i = 0; i <= 255; i += 5) {
        alphaCombo.add(String.valueOf(i));
    }
    alphaCombo.select(alphaCombo.indexOf("255"));
    alphaCombo.addSelectionListener(widgetSelectedAdapter(event -> alpha()));
    // Check box to request incremental display.
    group = new Group(controls, SWT.NONE);
    group.setLayout(new RowLayout());
    group.setText(bundle.getString("Display"));
    incrementalCheck = new Button(group, SWT.CHECK);
    incrementalCheck.setText(bundle.getString("Incremental"));
    incrementalCheck.setSelection(incremental);
    incrementalCheck.addSelectionListener(widgetSelectedAdapter(event -> incremental = ((Button) event.widget).getSelection()));
    // Check box to request transparent display.
    transparentCheck = new Button(group, SWT.CHECK);
    transparentCheck.setText(bundle.getString("Transparent"));
    transparentCheck.setSelection(transparent);
    transparentCheck.addSelectionListener(widgetSelectedAdapter(event -> {
        transparent = ((Button) event.widget).getSelection();
        if (image != null) {
            imageCanvas.redraw();
        }
    }));
    // Check box to request mask display.
    maskCheck = new Button(group, SWT.CHECK);
    maskCheck.setText(bundle.getString("Mask"));
    maskCheck.setSelection(showMask);
    maskCheck.addSelectionListener(widgetSelectedAdapter(event -> {
        showMask = ((Button) event.widget).getSelection();
        if (image != null) {
            imageCanvas.redraw();
        }
    }));
    // Check box to request background display.
    backgroundCheck = new Button(group, SWT.CHECK);
    backgroundCheck.setText(bundle.getString("Background"));
    backgroundCheck.setSelection(showBackground);
    backgroundCheck.addSelectionListener(widgetSelectedAdapter(event -> showBackground = ((Button) event.widget).getSelection()));
    // Group the animation buttons.
    group = new Group(controls, SWT.NONE);
    group.setLayout(new RowLayout());
    group.setText(bundle.getString("Animation"));
    // Push button to display the previous image in a multi-image file.
    previousButton = new Button(group, SWT.PUSH);
    previousButton.setText(bundle.getString("Previous"));
    previousButton.setEnabled(false);
    previousButton.addSelectionListener(widgetSelectedAdapter(event -> previous()));
    // Push button to display the next image in a multi-image file.
    nextButton = new Button(group, SWT.PUSH);
    nextButton.setText(bundle.getString("Next"));
    nextButton.setEnabled(false);
    nextButton.addSelectionListener(widgetSelectedAdapter(event -> next()));
    // Push button to toggle animation of a multi-image file.
    animateButton = new Button(group, SWT.PUSH);
    animateButton.setText(bundle.getString("Animate"));
    animateButton.setEnabled(false);
    animateButton.addSelectionListener(widgetSelectedAdapter(event -> animate()));
    // Label to show the image file type.
    typeLabel = new Label(shell, SWT.NONE);
    typeLabel.setText(bundle.getString("Type_initial"));
    typeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    // Canvas to show the image.
    imageCanvas = new Canvas(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.NO_REDRAW_RESIZE | SWT.NO_BACKGROUND);
    imageCanvas.setBackground(whiteColor);
    imageCanvas.setCursor(crossCursor);
    gridData = new GridData();
    gridData.verticalSpan = 15;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    imageCanvas.setLayoutData(gridData);
    imageCanvas.addPaintListener(event -> {
        if (image == null) {
            Rectangle bounds = imageCanvas.getBounds();
            event.gc.fillRectangle(0, 0, bounds.width, bounds.height);
        } else {
            paintImage(event);
        }
    });
    imageCanvas.addMouseMoveListener(event -> {
        if (image != null) {
            showColorAt(event.x, event.y);
        }
    });
    // Set up the image canvas scroll bars.
    ScrollBar horizontal = imageCanvas.getHorizontalBar();
    horizontal.setVisible(true);
    horizontal.setMinimum(0);
    horizontal.setEnabled(false);
    horizontal.addSelectionListener(widgetSelectedAdapter(event -> scrollHorizontally((ScrollBar) event.widget)));
    ScrollBar vertical = imageCanvas.getVerticalBar();
    vertical.setVisible(true);
    vertical.setMinimum(0);
    vertical.setEnabled(false);
    vertical.addSelectionListener(widgetSelectedAdapter(event -> scrollVertically((ScrollBar) event.widget)));
    // Label to show the image size.
    sizeLabel = new Label(shell, SWT.NONE);
    sizeLabel.setText(bundle.getString("Size_initial"));
    sizeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    // Label to show the image depth.
    depthLabel = new Label(shell, SWT.NONE);
    depthLabel.setText(bundle.getString("Depth_initial"));
    depthLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    // Label to show the transparent pixel.
    transparentPixelLabel = new Label(shell, SWT.NONE);
    transparentPixelLabel.setText(bundle.getString("Transparent_pixel_initial"));
    transparentPixelLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    // Label to show the time to load.
    timeToLoadLabel = new Label(shell, SWT.NONE);
    timeToLoadLabel.setText(bundle.getString("Time_to_load_initial"));
    timeToLoadLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    // Separate the animation fields from the rest of the fields.
    Label separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    // Label to show the logical screen size for animation.
    screenSizeLabel = new Label(shell, SWT.NONE);
    screenSizeLabel.setText(bundle.getString("Animation_size_initial"));
    screenSizeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    // Label to show the background pixel.
    backgroundPixelLabel = new Label(shell, SWT.NONE);
    backgroundPixelLabel.setText(bundle.getString("Background_pixel_initial"));
    backgroundPixelLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    // Label to show the image location (x, y).
    locationLabel = new Label(shell, SWT.NONE);
    locationLabel.setText(bundle.getString("Image_location_initial"));
    locationLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    // Label to show the image disposal method.
    disposalMethodLabel = new Label(shell, SWT.NONE);
    disposalMethodLabel.setText(bundle.getString("Disposal_initial"));
    disposalMethodLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    // Label to show the image delay time.
    delayTimeLabel = new Label(shell, SWT.NONE);
    delayTimeLabel.setText(bundle.getString("Delay_initial"));
    delayTimeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    // Label to show the background pixel.
    repeatCountLabel = new Label(shell, SWT.NONE);
    repeatCountLabel.setText(bundle.getString("Repeats_initial"));
    repeatCountLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    // Separate the animation fields from the palette.
    separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    // Label to show if the image has a direct or indexed palette.
    paletteLabel = new Label(shell, SWT.NONE);
    paletteLabel.setText(bundle.getString("Palette_initial"));
    paletteLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    // Canvas to show the image's palette.
    paletteCanvas = new Canvas(shell, SWT.BORDER | SWT.V_SCROLL | SWT.NO_REDRAW_RESIZE);
    paletteCanvas.setFont(fixedWidthFont);
    paletteCanvas.getVerticalBar().setVisible(true);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    GC gc = new GC(paletteLabel);
    paletteWidth = gc.stringExtent(bundle.getString("Max_length_string")).x;
    gc.dispose();
    gridData.widthHint = paletteWidth;
    // show at least 16 colors
    gridData.heightHint = 16 * 11;
    paletteCanvas.setLayoutData(gridData);
    paletteCanvas.addPaintListener(event -> {
        if (image != null)
            paintPalette(event);
    });
    // Set up the palette canvas scroll bar.
    vertical = paletteCanvas.getVerticalBar();
    vertical.setVisible(true);
    vertical.setMinimum(0);
    vertical.setIncrement(10);
    vertical.setEnabled(false);
    vertical.addSelectionListener(widgetSelectedAdapter(event -> scrollPalette((ScrollBar) event.widget)));
    // Sash to see more of image or image data.
    sash = new Sash(shell, SWT.HORIZONTAL);
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    gridData.horizontalAlignment = GridData.FILL;
    sash.setLayoutData(gridData);
    sash.addSelectionListener(widgetSelectedAdapter(event -> {
        if (event.detail != SWT.DRAG) {
            ((GridData) paletteCanvas.getLayoutData()).heightHint = SWT.DEFAULT;
            Rectangle paletteCanvasBounds = paletteCanvas.getBounds();
            int minY = paletteCanvasBounds.y + 20;
            Rectangle dataLabelBounds = dataLabel.getBounds();
            int maxY = statusLabel.getBounds().y - dataLabelBounds.height - 20;
            if (event.y > minY && event.y < maxY) {
                Rectangle oldSash = sash.getBounds();
                sash.setBounds(event.x, event.y, event.width, event.height);
                int diff = event.y - oldSash.y;
                Rectangle bounds = imageCanvas.getBounds();
                imageCanvas.setBounds(bounds.x, bounds.y, bounds.width, bounds.height + diff);
                bounds = paletteCanvasBounds;
                paletteCanvas.setBounds(bounds.x, bounds.y, bounds.width, bounds.height + diff);
                bounds = dataLabelBounds;
                dataLabel.setBounds(bounds.x, bounds.y + diff, bounds.width, bounds.height);
                bounds = dataText.getBounds();
                dataText.setBounds(bounds.x, bounds.y + diff, bounds.width, bounds.height - diff);
            // shell.layout(true);
            }
        }
    }));
    // Label to show data-specific fields.
    dataLabel = new Label(shell, SWT.NONE);
    dataLabel.setText(bundle.getString("Pixel_data_initial"));
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    gridData.horizontalAlignment = GridData.FILL;
    dataLabel.setLayoutData(gridData);
    // Text to show a dump of the data.
    dataText = new StyledText(shell, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
    dataText.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    dataText.setFont(fixedWidthFont);
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.heightHint = 128;
    gridData.grabExcessVerticalSpace = true;
    dataText.setLayoutData(gridData);
    dataText.addMouseListener(MouseListener.mouseDownAdapter(event -> {
        if (image != null && event.button == 1) {
            showColorForData();
        }
    }));
    dataText.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent event) {
            if (image != null) {
                showColorForData();
            }
        }
    });
    // Label to show status and cursor location in image.
    statusLabel = new Label(shell, SWT.NONE);
    statusLabel.setText("");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    gridData.horizontalAlignment = GridData.FILL;
    statusLabel.setLayoutData(gridData);
}
Also used : ImageLoader(org.eclipse.swt.graphics.ImageLoader) StyledText(org.eclipse.swt.custom.StyledText) URL(java.net.URL) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point) Dialog(org.eclipse.swt.widgets.Dialog) SWTError(org.eclipse.swt.SWTError) PaintEvent(org.eclipse.swt.events.PaintEvent) PrintDialog(org.eclipse.swt.printing.PrintDialog) Composite(org.eclipse.swt.widgets.Composite) KeyEvent(org.eclipse.swt.events.KeyEvent) SWTException(org.eclipse.swt.SWTException) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Cursor(org.eclipse.swt.graphics.Cursor) Text(org.eclipse.swt.widgets.Text) Button(org.eclipse.swt.widgets.Button) Sash(org.eclipse.swt.widgets.Sash) Display(org.eclipse.swt.widgets.Display) List(java.util.List) MouseListener(org.eclipse.swt.events.MouseListener) MenuItem(org.eclipse.swt.widgets.MenuItem) SWT(org.eclipse.swt.SWT) Label(org.eclipse.swt.widgets.Label) SelectionListener(org.eclipse.swt.events.SelectionListener) Printer(org.eclipse.swt.printing.Printer) PrinterData(org.eclipse.swt.printing.PrinterData) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) ControlListener(org.eclipse.swt.events.ControlListener) ImageData(org.eclipse.swt.graphics.ImageData) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) ControlEvent(org.eclipse.swt.events.ControlEvent) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) ResourceBundle(java.util.ResourceBundle) RGB(org.eclipse.swt.graphics.RGB) Canvas(org.eclipse.swt.widgets.Canvas) Font(org.eclipse.swt.graphics.Font) GridData(org.eclipse.swt.layout.GridData) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) FileDialog(org.eclipse.swt.widgets.FileDialog) StyleRange(org.eclipse.swt.custom.StyleRange) ImageLoaderEvent(org.eclipse.swt.graphics.ImageLoaderEvent) Group(org.eclipse.swt.widgets.Group) RowLayout(org.eclipse.swt.layout.RowLayout) ShellListener(org.eclipse.swt.events.ShellListener) Color(org.eclipse.swt.graphics.Color) MessageBox(org.eclipse.swt.widgets.MessageBox) Menu(org.eclipse.swt.widgets.Menu) ScrollBar(org.eclipse.swt.widgets.ScrollBar) InputStream(java.io.InputStream) GridLayout(org.eclipse.swt.layout.GridLayout) Group(org.eclipse.swt.widgets.Group) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) Sash(org.eclipse.swt.widgets.Sash) Canvas(org.eclipse.swt.widgets.Canvas) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) Rectangle(org.eclipse.swt.graphics.Rectangle) Combo(org.eclipse.swt.widgets.Combo) Point(org.eclipse.swt.graphics.Point) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) GC(org.eclipse.swt.graphics.GC) ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Example 39 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project eclipse.platform.swt by eclipse.

the class RowLayoutTab method createLayout.

/**
 * Creates the example layout.
 */
@Override
void createLayout() {
    rowLayout = new RowLayout();
    layoutComposite.setLayout(rowLayout);
}
Also used : RowLayout(org.eclipse.swt.layout.RowLayout)

Example 40 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project eclipse.platform.swt by eclipse.

the class DNDExample method createDropOperations.

private void createDropOperations(Composite parent) {
    parent.setLayout(new RowLayout(SWT.VERTICAL));
    final Button moveButton = new Button(parent, SWT.CHECK);
    moveButton.setText("DND.DROP_MOVE");
    moveButton.addSelectionListener(widgetSelectedAdapter(e -> {
        Button b = (Button) e.widget;
        if (b.getSelection()) {
            dropOperation |= DND.DROP_MOVE;
        } else {
            dropOperation = dropOperation & ~DND.DROP_MOVE;
            if (dropOperation == 0 || (dropDefaultOperation & DND.DROP_MOVE) != 0) {
                dropOperation |= DND.DROP_MOVE;
                moveButton.setSelection(true);
            }
        }
        if (dropEnabled) {
            createDropTarget();
        }
    }));
    final Button copyButton = new Button(parent, SWT.CHECK);
    copyButton.setText("DND.DROP_COPY");
    copyButton.addSelectionListener(widgetSelectedAdapter(e -> {
        Button b = (Button) e.widget;
        if (b.getSelection()) {
            dropOperation |= DND.DROP_COPY;
        } else {
            dropOperation = dropOperation & ~DND.DROP_COPY;
            if (dropOperation == 0 || (dropDefaultOperation & DND.DROP_COPY) != 0) {
                dropOperation = DND.DROP_COPY;
                copyButton.setSelection(true);
            }
        }
        if (dropEnabled) {
            createDropTarget();
        }
    }));
    final Button linkButton = new Button(parent, SWT.CHECK);
    linkButton.setText("DND.DROP_LINK");
    linkButton.addSelectionListener(widgetSelectedAdapter(e -> {
        Button eb = (Button) e.widget;
        if (eb.getSelection()) {
            dropOperation |= DND.DROP_LINK;
        } else {
            dropOperation = dropOperation & ~DND.DROP_LINK;
            if (dropOperation == 0 || (dropDefaultOperation & DND.DROP_LINK) != 0) {
                dropOperation = DND.DROP_LINK;
                linkButton.setSelection(true);
            }
        }
        if (dropEnabled) {
            createDropTarget();
        }
    }));
    Button b = new Button(parent, SWT.CHECK);
    b.setText("DND.DROP_DEFAULT");
    defaultParent = new Composite(parent, SWT.NONE);
    b.addSelectionListener(widgetSelectedAdapter(e -> {
        Button eb = (Button) e.widget;
        if (eb.getSelection()) {
            dropOperation |= DND.DROP_DEFAULT;
            defaultParent.setVisible(true);
        } else {
            dropOperation = dropOperation & ~DND.DROP_DEFAULT;
            defaultParent.setVisible(false);
        }
        if (dropEnabled) {
            createDropTarget();
        }
    }));
    defaultParent.setVisible(false);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 20;
    defaultParent.setLayout(layout);
    Label label = new Label(defaultParent, SWT.NONE);
    label.setText("Value for default operation is:");
    b = new Button(defaultParent, SWT.RADIO);
    b.setText("DND.DROP_MOVE");
    b.addSelectionListener(widgetSelectedAdapter(e -> {
        Button eb = (Button) e.widget;
        if (eb.getSelection()) {
            dropDefaultOperation = DND.DROP_MOVE;
            dropOperation |= DND.DROP_MOVE;
            moveButton.setSelection(true);
            if (dropEnabled) {
                createDropTarget();
            }
        }
    }));
    b = new Button(defaultParent, SWT.RADIO);
    b.setText("DND.DROP_COPY");
    b.addSelectionListener(widgetSelectedAdapter(e -> {
        Button eb = (Button) e.widget;
        if (eb.getSelection()) {
            dropDefaultOperation = DND.DROP_COPY;
            dropOperation |= DND.DROP_COPY;
            copyButton.setSelection(true);
            if (dropEnabled) {
                createDropTarget();
            }
        }
    }));
    b = new Button(defaultParent, SWT.RADIO);
    b.setText("DND.DROP_LINK");
    b.addSelectionListener(widgetSelectedAdapter(e -> {
        Button eb = (Button) e.widget;
        if (eb.getSelection()) {
            dropDefaultOperation = DND.DROP_LINK;
            dropOperation |= DND.DROP_LINK;
            linkButton.setSelection(true);
            if (dropEnabled) {
                createDropTarget();
            }
        }
    }));
    b = new Button(defaultParent, SWT.RADIO);
    b.setText("DND.DROP_NONE");
    b.setSelection(true);
    b.addSelectionListener(widgetSelectedAdapter(e -> {
        Button eb = (Button) e.widget;
        if (eb.getSelection()) {
            dropDefaultOperation = DND.DROP_NONE;
            dropOperation &= ~DND.DROP_DEFAULT;
            if (dropEnabled) {
                createDropTarget();
            }
        }
    }));
    // initialize state
    moveButton.setSelection(true);
    copyButton.setSelection(true);
    linkButton.setSelection(true);
    dropOperation = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) URL(java.net.URL) DND(org.eclipse.swt.dnd.DND) TableColumn(org.eclipse.swt.widgets.TableColumn) FontMetrics(org.eclipse.swt.graphics.FontMetrics) Point(org.eclipse.swt.graphics.Point) SWTError(org.eclipse.swt.SWTError) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) URLTransfer(org.eclipse.swt.dnd.URLTransfer) Composite(org.eclipse.swt.widgets.Composite) TreeColumn(org.eclipse.swt.widgets.TreeColumn) DropTarget(org.eclipse.swt.dnd.DropTarget) Text(org.eclipse.swt.widgets.Text) Button(org.eclipse.swt.widgets.Button) Display(org.eclipse.swt.widgets.Display) Transfer(org.eclipse.swt.dnd.Transfer) MenuItem(org.eclipse.swt.widgets.MenuItem) Tree(org.eclipse.swt.widgets.Tree) SWT(org.eclipse.swt.SWT) HTMLTransfer(org.eclipse.swt.dnd.HTMLTransfer) List(org.eclipse.swt.widgets.List) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) Label(org.eclipse.swt.widgets.Label) RTFTransfer(org.eclipse.swt.dnd.RTFTransfer) DragSourceListener(org.eclipse.swt.dnd.DragSourceListener) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) Table(org.eclipse.swt.widgets.Table) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Canvas(org.eclipse.swt.widgets.Canvas) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) FileTransfer(org.eclipse.swt.dnd.FileTransfer) DragSource(org.eclipse.swt.dnd.DragSource) TableItem(org.eclipse.swt.widgets.TableItem) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) MalformedURLException(java.net.MalformedURLException) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) FormLayout(org.eclipse.swt.layout.FormLayout) FileDialog(org.eclipse.swt.widgets.FileDialog) FormData(org.eclipse.swt.layout.FormData) FormAttachment(org.eclipse.swt.layout.FormAttachment) Group(org.eclipse.swt.widgets.Group) TreeItem(org.eclipse.swt.widgets.TreeItem) File(java.io.File) RowLayout(org.eclipse.swt.layout.RowLayout) Menu(org.eclipse.swt.widgets.Menu) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Control(org.eclipse.swt.widgets.Control) GridLayout(org.eclipse.swt.layout.GridLayout) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) Label(org.eclipse.swt.widgets.Label)

Aggregations

RowLayout (org.eclipse.swt.layout.RowLayout)86 Composite (org.eclipse.swt.widgets.Composite)73 GridData (org.eclipse.swt.layout.GridData)55 Button (org.eclipse.swt.widgets.Button)54 GridLayout (org.eclipse.swt.layout.GridLayout)52 Label (org.eclipse.swt.widgets.Label)44 SelectionEvent (org.eclipse.swt.events.SelectionEvent)41 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)34 Group (org.eclipse.swt.widgets.Group)27 Text (org.eclipse.swt.widgets.Text)23 Combo (org.eclipse.swt.widgets.Combo)19 Shell (org.eclipse.swt.widgets.Shell)17 Display (org.eclipse.swt.widgets.Display)16 Point (org.eclipse.swt.graphics.Point)12 ArrayList (java.util.ArrayList)10 StyledText (org.eclipse.swt.custom.StyledText)10 Table (org.eclipse.swt.widgets.Table)10 List (java.util.List)9 SelectionListener (org.eclipse.swt.events.SelectionListener)9 FillLayout (org.eclipse.swt.layout.FillLayout)9