Search in sources :

Example 71 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project cubrid-manager by CUBRID.

the class JdbcOptionComposite method createJdbcTableGroup.

/**
	 *
	 * Create JDBC table group
	 *
	 * @param composite the composite
	 */
private void createJdbcTableGroup(Composite composite) {
    final String[] columnNameArr = new String[] { Messages.tblColJdbcAttrName, Messages.tblColJdbcAttrValue };
    jdbcInfoTv = CommonUITool.createCommonTableViewer(composite, null, columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 150));
    jdbcInfoTv.setInput(jdbcListData);
    TableLayout tableLayout = new TableLayout();
    jdbcInfoTv.getTable().setLayout(tableLayout);
    tableLayout.addColumnData(new ColumnWeightData(35, true));
    tableLayout.addColumnData(new ColumnWeightData(65, true));
    editor = new TableEditor(jdbcInfoTv.getTable());
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    jdbcInfoTv.getTable().addListener(SWT.MouseUp, new Listener() {

        public void handleEvent(Event event) {
            if (event.button != 1) {
                return;
            }
            Point pt = new Point(event.x, event.y);
            int newIndex = jdbcInfoTv.getTable().getSelectionIndex();
            if (jdbcInfoTv.getTable().getItemCount() <= newIndex || newIndex < 0) {
                return;
            }
            final TableItem item = jdbcInfoTv.getTable().getItem(newIndex);
            if (item == null) {
                return;
            }
            for (int i = 0; i < 2; i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                    focusCell(item, newIndex, i);
                    break;
                }
            }
        }
    });
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Listener(org.eclipse.swt.widgets.Listener) TraverseListener(org.eclipse.swt.events.TraverseListener) MouseListener(org.eclipse.swt.events.MouseListener) TableItem(org.eclipse.swt.widgets.TableItem) Rectangle(org.eclipse.swt.graphics.Rectangle) Event(org.eclipse.swt.widgets.Event) TraverseEvent(org.eclipse.swt.events.TraverseEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Point(org.eclipse.swt.graphics.Point) TableLayout(org.eclipse.jface.viewers.TableLayout) TableEditor(org.eclipse.swt.custom.TableEditor)

Example 72 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project tdi-studio-se by Talend.

the class PromptDefaultValueDialog method createTextEditor.

private void createTextEditor(TableItem item, int column, String displayText) {
    TableEditor editor = new TableEditor(table);
    final Text text = new Text(table, SWT.NONE);
    text.setText(displayText);
    editor.setEditor(text, item, column);
    editor.grabHorizontal = true;
    editor.layout();
    editors.add(editor);
}
Also used : Text(org.eclipse.swt.widgets.Text) TableEditor(org.eclipse.swt.custom.TableEditor)

Example 73 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project tdi-studio-se by Talend.

the class PromptDefaultValueDialog method close.

@Override
public boolean close() {
    for (TableEditor editor : editors) {
        Control control = editor.getEditor();
        if (control != null && !control.isDisposed()) {
            control.dispose();
        }
        editor.dispose();
    }
    editors.clear();
    return super.close();
}
Also used : Control(org.eclipse.swt.widgets.Control) TableEditor(org.eclipse.swt.custom.TableEditor)

Example 74 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project tdi-studio-se by Talend.

the class PromptDefaultValueDialog method createTable.

/**
     * DOC hcw Comment method "createTableViewer".
     * 
     * @param parent
     */
private void createTable(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    table = new Table(composite, SWT.BORDER);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    table.setLayoutData(gd);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    TableColumn nameColumn = new TableColumn(table, SWT.NONE);
    nameColumn.setWidth(120);
    //$NON-NLS-1$
    nameColumn.setText(Messages.getString("PromptDefaultValueDialog.column"));
    TableColumn defaultColumn = new TableColumn(table, SWT.NONE);
    defaultColumn.setWidth(108);
    //$NON-NLS-1$
    defaultColumn.setText(Messages.getString("PromptDefaultValueDialog.defaultValue"));
    editors = new ArrayList<TableEditor>();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) TableColumn(org.eclipse.swt.widgets.TableColumn) TableEditor(org.eclipse.swt.custom.TableEditor)

Example 75 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project tdi-studio-se by Talend.

the class PromptDefaultValueDialog method okPressed.

@Override
protected void okPressed() {
    for (TableEditor editor : editors) {
        Control control = editor.getEditor();
        TableItem item = editor.getItem();
        ColumnInfo row = (ColumnInfo) item.getData();
        EParameterFieldType field = row.parameter.getFieldType();
        if (field == EParameterFieldType.CHECK) {
            Button button = (Button) control;
            row.defaultValue = button.getSelection();
        } else if (field == EParameterFieldType.TEXT) {
            Text text = (Text) control;
            row.defaultValue = text.getText();
        } else if (field == EParameterFieldType.CLOSED_LIST || field == EParameterFieldType.PREV_COLUMN_LIST) {
            CCombo combo = (CCombo) control;
            int index = combo.getSelectionIndex();
            Object[] values = row.parameter.getListItemsValue();
            if (values.length > index && index != -1) {
                row.defaultValue = values[index];
            }
        }
    }
    super.okPressed();
}
Also used : Control(org.eclipse.swt.widgets.Control) EParameterFieldType(org.talend.core.model.process.EParameterFieldType) CCombo(org.eclipse.swt.custom.CCombo) Button(org.eclipse.swt.widgets.Button) TableItem(org.eclipse.swt.widgets.TableItem) Text(org.eclipse.swt.widgets.Text) TableEditor(org.eclipse.swt.custom.TableEditor)

Aggregations

TableEditor (org.eclipse.swt.custom.TableEditor)124 TableItem (org.eclipse.swt.widgets.TableItem)60 GridData (org.eclipse.swt.layout.GridData)52 Table (org.eclipse.swt.widgets.Table)49 Button (org.eclipse.swt.widgets.Button)41 Text (org.eclipse.swt.widgets.Text)40 GridLayout (org.eclipse.swt.layout.GridLayout)36 Point (org.eclipse.swt.graphics.Point)33 SelectionEvent (org.eclipse.swt.events.SelectionEvent)31 Composite (org.eclipse.swt.widgets.Composite)30 Label (org.eclipse.swt.widgets.Label)29 TableColumn (org.eclipse.swt.widgets.TableColumn)27 CCombo (org.eclipse.swt.custom.CCombo)26 SWT (org.eclipse.swt.SWT)23 Control (org.eclipse.swt.widgets.Control)23 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)20 Rectangle (org.eclipse.swt.graphics.Rectangle)17 FocusEvent (org.eclipse.swt.events.FocusEvent)15 ModifyEvent (org.eclipse.swt.events.ModifyEvent)14 ModifyListener (org.eclipse.swt.events.ModifyListener)14