use of org.jkiss.dbeaver.ui.controls.CustomTableEditor in project dbeaver by dbeaver.
the class ProcedureParameterBindDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
getShell().setText(procedure.getProcedureType().name() + " " + procedure.getName() + " parameter(s)");
final Composite composite = (Composite) super.createDialogArea(parent);
final Table paramTable = new Table(composite, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
final GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 400;
gd.heightHint = 200;
paramTable.setLayoutData(gd);
paramTable.setHeaderVisible(true);
paramTable.setLinesVisible(true);
final TableColumn nameColumn = UIUtils.createTableColumn(paramTable, SWT.LEFT, "Name");
nameColumn.setWidth(100);
final TableColumn valueColumn = UIUtils.createTableColumn(paramTable, SWT.LEFT, "Value");
valueColumn.setWidth(200);
final TableColumn typeColumn = UIUtils.createTableColumn(paramTable, SWT.LEFT, "Type");
typeColumn.setWidth(60);
final TableColumn kindColumn = UIUtils.createTableColumn(paramTable, SWT.LEFT, "Kind");
kindColumn.setWidth(40);
for (DBSProcedureParameter param : parameters) {
TableItem item = new TableItem(paramTable, SWT.NONE);
item.setData(param);
item.setImage(DBeaverIcons.getImage(DBIcon.TREE_ATTRIBUTE));
item.setText(0, param.getName());
Object value = values.get(param);
item.setText(1, CommonUtils.toString(value, ""));
item.setText(2, param.getParameterType().getFullTypeName());
item.setText(3, param.getParameterKind().getTitle());
}
final CustomTableEditor tableEditor = new CustomTableEditor(paramTable) {
{
firstTraverseIndex = 1;
lastTraverseIndex = 1;
editOnEnter = false;
}
@Override
protected Control createEditor(Table table, int index, TableItem item) {
if (index != 1) {
return null;
}
DBSProcedureParameter param = (DBSProcedureParameter) item.getData();
Text editor = new Text(table, SWT.BORDER);
editor.setText(CommonUtils.toString(values.get(param), ""));
editor.selectAll();
return editor;
}
@Override
protected void saveEditorValue(Control control, int index, TableItem item) {
DBSProcedureParameter param = (DBSProcedureParameter) item.getData();
String newValue = ((Text) control).getText();
item.setText(1, newValue);
values.put(param, newValue);
}
};
if (!parameters.isEmpty()) {
UIUtils.asyncExec(() -> {
paramTable.select(0);
tableEditor.showEditor(paramTable.getItem(0), 1);
});
}
updateStatus(GeneralUtils.makeInfoStatus("Use Tab to switch."));
return composite;
}
use of org.jkiss.dbeaver.ui.controls.CustomTableEditor in project dbeaver by dbeaver.
the class PostgreDebugPanelFunction method createParametersGroup.
private void createParametersGroup(Composite parent) {
Group composite = UIUtils.createControlGroup(parent, "Function parameters", 2, GridData.FILL_BOTH, SWT.DEFAULT);
parametersTable = new Table(composite, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
final GridData gd = new GridData(GridData.FILL_BOTH);
parametersTable.setLayoutData(gd);
parametersTable.setHeaderVisible(true);
parametersTable.setLinesVisible(true);
final TableColumn nameColumn = UIUtils.createTableColumn(parametersTable, SWT.LEFT, "Name");
nameColumn.setWidth(100);
final TableColumn valueColumn = UIUtils.createTableColumn(parametersTable, SWT.LEFT, "Value");
valueColumn.setWidth(200);
final TableColumn typeColumn = UIUtils.createTableColumn(parametersTable, SWT.LEFT, "Type");
typeColumn.setWidth(60);
final TableColumn kindColumn = UIUtils.createTableColumn(parametersTable, SWT.LEFT, "Kind");
kindColumn.setWidth(40);
new CustomTableEditor(parametersTable) {
{
firstTraverseIndex = 1;
lastTraverseIndex = 1;
editOnEnter = false;
}
@Override
protected Control createEditor(Table table, int index, TableItem item) {
if (index != 1) {
return null;
}
DBSProcedureParameter param = (DBSProcedureParameter) item.getData();
Text editor = new Text(table, SWT.BORDER);
editor.setText(CommonUtils.toString(parameterValues.get(param), ""));
editor.selectAll();
return editor;
}
@Override
protected void saveEditorValue(Control control, int index, TableItem item) {
DBSProcedureParameter param = (DBSProcedureParameter) item.getData();
String newValue = ((Text) control).getText();
item.setText(1, newValue);
parameterValues.put(param, newValue);
container.updateDialogState();
}
};
}
use of org.jkiss.dbeaver.ui.controls.CustomTableEditor in project dbeaver by dbeaver.
the class AttributesSelectorPage method createColumnsGroup.
protected void createColumnsGroup(Composite panel) {
columnsGroup = new Composite(panel, SWT.NONE);
columnsGroup.setLayout(new GridLayout(1, false));
columnsGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
UIUtils.createControlLabel(columnsGroup, EditorsMessages.dialog_struct_columns_select_group_columns);
// columnsViewer = new TableViewer(columnsGroup, SWT.BORDER | SWT.SINGLE | SWT.CHECK);
columnsTable = new Table(columnsGroup, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION | SWT.CHECK);
columnsTable.setHeaderVisible(true);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.minimumWidth = 300;
gd.minimumHeight = 150;
columnsTable.setLayoutData(gd);
columnsTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleItemSelect((TableItem) e.item, true);
}
});
createAttributeColumns(columnsTable);
final CustomTableEditor tableEditor = new CustomTableEditor(columnsTable) {
@Override
protected Control createEditor(Table table, final int index, final TableItem item) {
return createCellEditor(table, index, item, (AttributeInfo) item.getData());
}
@Override
protected void saveEditorValue(Control control, int index, TableItem item) {
saveCellValue(control, index, item, (AttributeInfo) item.getData());
}
};
toggleButton = new Button(columnsGroup, SWT.PUSH);
toggleButton.setText("Select All");
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.widthHint = 120;
toggleButton.setLayoutData(gd);
toggleButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TableItem[] items = columnsTable.getItems();
if (hasCheckedColumns()) {
// Clear all checked
for (TableItem item : items) {
if (item.getChecked()) {
item.setChecked(false);
handleItemSelect(item, true);
}
}
} else {
// Check all
for (TableItem item : items) {
if (!item.getChecked()) {
item.setChecked(true);
handleItemSelect(item, true);
}
}
}
}
});
}
Aggregations