Search in sources :

Example 46 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project eclipse.platform.swt by eclipse.

the class StackLayoutTab method createChildWidgets.

/**
 * Creates the widgets in the "child" group.
 */
@Override
void createChildWidgets() {
    /* Add common controls */
    super.createChildWidgets();
    /* Add TableEditors */
    comboEditor = new TableEditor(table);
    nameEditor = new TableEditor(table);
    table.addMouseListener(MouseListener.mouseDownAdapter(e -> {
        resetEditors();
        index = table.getSelectionIndex();
        if (index == -1)
            return;
        // set top layer of stack to the selected item
        setTopControl(index);
        TableItem oldItem = comboEditor.getItem();
        newItem = table.getItem(index);
        if (newItem == oldItem || newItem != lastSelected) {
            lastSelected = newItem;
            return;
        }
        table.showSelection();
        combo = new CCombo(table, SWT.READ_ONLY);
        createComboEditor(combo, comboEditor);
        nameText = new Text(table, SWT.SINGLE);
        nameText.setText(data.get(index)[NAME_COL]);
        createTextEditor(nameText, nameEditor, NAME_COL);
    }));
}
Also used : TableEditor(org.eclipse.swt.custom.TableEditor) TableItem(org.eclipse.swt.widgets.TableItem) Text(org.eclipse.swt.widgets.Text) StackLayout(org.eclipse.swt.custom.StackLayout) Button(org.eclipse.swt.widgets.Button) Spinner(org.eclipse.swt.widgets.Spinner) Group(org.eclipse.swt.widgets.Group) MouseListener(org.eclipse.swt.events.MouseListener) Composite(org.eclipse.swt.widgets.Composite) SWT(org.eclipse.swt.SWT) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) CCombo(org.eclipse.swt.custom.CCombo) Control(org.eclipse.swt.widgets.Control) SelectionListener(org.eclipse.swt.events.SelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) CCombo(org.eclipse.swt.custom.CCombo) TableItem(org.eclipse.swt.widgets.TableItem) Text(org.eclipse.swt.widgets.Text) TableEditor(org.eclipse.swt.custom.TableEditor)

Example 47 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project eclipse.platform.swt by eclipse.

the class MJ_Table method tableEditor_multiple_controls_Snippet149.

/**
 * Snippet 149 was modified.
 * - No added columns.
 * - Button instead of progress bar.
 */
@Test
public void tableEditor_multiple_controls_Snippet149() {
    knownToBeBrokenGtk3("Snippet is broken on Gtk3. See Bug 531885");
    Shell shell = mkShell("Items should be replaced with Buttons (broken on Gtk3, Bug 531885)");
    shell.setLayout(new FillLayout());
    Table table = new Table(shell, SWT.BORDER);
    for (int i = 0; i < 20; i++) {
        TableItem item = new TableItem(table, SWT.NONE);
        item.setText("Task " + i);
        Button button = new Button(table, SWT.NONE);
        button.setText("hello world " + i);
        button.setVisible(true);
        button.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                System.out.println("Button pressed");
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
        TableEditor editor = new TableEditor(table);
        editor.grabHorizontal = editor.grabVertical = true;
        editor.setEditor(button, item, 0);
    }
    shell.setSize(SWIDTH, SHEIGHT);
    shell.open();
    mainLoop(shell);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Table(org.eclipse.swt.widgets.Table) Button(org.eclipse.swt.widgets.Button) TableItem(org.eclipse.swt.widgets.TableItem) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FillLayout(org.eclipse.swt.layout.FillLayout) TableEditor(org.eclipse.swt.custom.TableEditor) Point(org.eclipse.swt.graphics.Point) SelectionListener(org.eclipse.swt.events.SelectionListener) Test(org.junit.Test)

Example 48 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project eclipse.platform.swt by eclipse.

the class Bug166720_TableEditorFlicker method main.

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());
    Table table = new Table(shell, SWT.BORDER | SWT.MULTI);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 200;
    gd.widthHint = 200;
    table.setLayoutData(gd);
    TableColumn column = new TableColumn(table, SWT.NONE);
    column.setWidth(100);
    for (int i = 0; i < 100; i++) {
        new TableItem(table, SWT.NONE);
    }
    TableItem[] items = table.getItems();
    for (int i = 0; i < items.length; i++) {
        TableEditor editor = new TableEditor(table);
        editor = new TableEditor(table);
        Text text = new Text(table, SWT.NONE);
        text.setText("Text" + i);
        editor.grabHorizontal = true;
        editor.setEditor(text, items[i], 0);
        editor = new TableEditor(table);
    }
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) TableItem(org.eclipse.swt.widgets.TableItem) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) TableColumn(org.eclipse.swt.widgets.TableColumn) TableEditor(org.eclipse.swt.custom.TableEditor) Display(org.eclipse.swt.widgets.Display)

Aggregations

TableEditor (org.eclipse.swt.custom.TableEditor)48 TableItem (org.eclipse.swt.widgets.TableItem)25 GridData (org.eclipse.swt.layout.GridData)18 SelectionEvent (org.eclipse.swt.events.SelectionEvent)17 Point (org.eclipse.swt.graphics.Point)15 Button (org.eclipse.swt.widgets.Button)15 GridLayout (org.eclipse.swt.layout.GridLayout)14 Text (org.eclipse.swt.widgets.Text)14 CCombo (org.eclipse.swt.custom.CCombo)12 Label (org.eclipse.swt.widgets.Label)12 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)10 Table (org.eclipse.swt.widgets.Table)10 Rectangle (org.eclipse.swt.graphics.Rectangle)9 Composite (org.eclipse.swt.widgets.Composite)9 Control (org.eclipse.swt.widgets.Control)9 TableColumn (org.eclipse.swt.widgets.TableColumn)8 Event (org.eclipse.swt.widgets.Event)7 Group (org.eclipse.swt.widgets.Group)7 Listener (org.eclipse.swt.widgets.Listener)7 SWT (org.eclipse.swt.SWT)6