use of org.talend.designer.rowgenerator.data.Parameter 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);
}
Aggregations