use of org.eclipse.swt.custom.TableEditor in project tdi-studio-se by Talend.
the class FunParaTableView2 method updateData.
private void updateData(List<Parameter> params) {
final Table table = this.getTable();
final TableViewer viewer = this.getTableViewerCreator().getTableViewer();
final TableEditor editor = new TableEditor(table);
// The editor must have the same size as the cell and must
// editing the Third column
final int eDITABLECOLUMN = 2;
table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// Clean up any previous editor control
Control oldEditor = editor.getEditor();
if (oldEditor != null) {
oldEditor.dispose();
}
// Identify the selected row
TableItem item = (TableItem) e.item;
if (item == null) {
return;
}
Parameter param = (Parameter) item.getData();
if (param instanceof ListParameter) {
createCombo((ListParameter) param, item);
}
}
private void createCombo(final ListParameter list, TableItem item) {
final CCombo combo = new CCombo(table, SWT.NONE);
combo.setItems(list.getValues());
combo.setFocus();
editor.setEditor(combo, item, eDITABLECOLUMN);
combo.setText(list.getValue());
Point size = combo.computeSize(SWT.DEFAULT, table.getItemHeight());
// Set attributes of the editor
editor.horizontalAlignment = SWT.LEFT;
editor.minimumHeight = size.y;
editor.minimumWidth = size.x;
combo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
list.setValue(combo.getText());
viewer.refresh(list);
ext.setChanged(true);
rowGenTableEditor2.getTableViewerCreator().getTableViewer().refresh();
}
});
combo.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
}
/**
* Sent when a control loses focus.
*
* @param e an event containing information about the focus change
*/
public void focusLost(FocusEvent e) {
combo.dispose();
}
});
}
});
getTableViewerCreator().setInputList(params);
}
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);
}
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();
}
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>();
}
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();
}
Aggregations