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;
}
}
}
});
}
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