use of org.jkiss.dbeaver.model.virtual.DBVEntityAttribute in project dbeaver by dbeaver.
the class EditVirtualColumnsPage method editSelectedAttribute.
private void editSelectedAttribute(Table attrTable) {
TableItem[] selection = attrTable.getSelection();
if (selection.length <= 0) {
return;
}
TableItem tableItem = selection[0];
DBVEntityAttribute vAttr = (DBVEntityAttribute) tableItem.getData();
EditVirtualAttributePage editAttrPage = new EditVirtualAttributePage(viewer, vAttr);
if (editAttrPage.edit(attrTable.getShell())) {
tableItem.setText(0, vAttr.getName());
tableItem.setText(1, vAttr.getTypeName());
tableItem.setText(2, CommonUtils.notEmpty(vAttr.getExpression()));
}
}
use of org.jkiss.dbeaver.model.virtual.DBVEntityAttribute in project dbeaver by dbeaver.
the class EditVirtualColumnsPage method createPageContents.
@Override
protected Composite createPageContents(Composite parent) {
Composite panel = UIUtils.createComposite(parent, 1);
panel.setLayoutData(new GridData(GridData.FILL_BOTH));
attrTable = new Table(panel, SWT.FULL_SELECTION | SWT.BORDER);
attrTable.setLayoutData(new GridData(GridData.FILL_BOTH));
attrTable.setHeaderVisible(true);
UIUtils.executeOnResize(attrTable, () -> UIUtils.packColumns(attrTable, true));
UIUtils.createTableColumn(attrTable, SWT.LEFT, ResultSetMessages.virtual_edit_columns_page_table_column_name);
UIUtils.createTableColumn(attrTable, SWT.LEFT, ResultSetMessages.virtual_edit_columns_page_table_column_data_type);
UIUtils.createTableColumn(attrTable, SWT.LEFT, ResultSetMessages.virtual_edit_columns_page_table_column_expression);
{
Composite buttonsPanel = UIUtils.createComposite(panel, 3);
buttonsPanel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
Button btnAdd = UIUtils.createDialogButton(buttonsPanel, ResultSetMessages.virtual_edit_columns_page_dialog_button_add, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DBVEntityAttribute vAttr = new DBVEntityAttribute(vEntity, null, "vcolumn");
EditVirtualAttributePage editAttrPage = new EditVirtualAttributePage(viewer, vAttr);
if (editAttrPage.edit(parent.getShell())) {
vAttr.setCustom(true);
vEntity.addVirtualAttribute(vAttr);
structChanged = true;
createAttributeItem(attrTable, vAttr);
}
}
});
Button btnEdit = UIUtils.createDialogButton(buttonsPanel, ResultSetMessages.virtual_edit_columns_page_dialog_button_edit, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
editSelectedAttribute(attrTable);
}
});
btnEdit.setEnabled(false);
Button btnRemove = UIUtils.createDialogButton(buttonsPanel, ResultSetMessages.virtual_edit_columns_page_dialog_button_remove, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DBVEntityAttribute virtualAttr = (DBVEntityAttribute) attrTable.getSelection()[0].getData();
if (!UIUtils.confirmAction(parent.getShell(), ResultSetMessages.virtual_edit_columns_page_confirm_action_delete, NLS.bind(ResultSetMessages.virtual_edit_columns_page_confirm_action_question_delete_column, virtualAttr.getName()))) {
return;
}
vEntity.removeVirtualAttribute(virtualAttr);
attrTable.remove(attrTable.getSelectionIndices());
structChanged = true;
}
});
btnRemove.setEnabled(false);
attrTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean attrSelected = attrTable.getSelectionIndex() >= 0;
btnEdit.setEnabled(attrSelected);
btnRemove.setEnabled(attrSelected);
}
});
attrTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
editSelectedAttribute(attrTable);
}
});
}
refreshAttributes();
return panel;
}
use of org.jkiss.dbeaver.model.virtual.DBVEntityAttribute in project dbeaver by dbeaver.
the class VirtualAttributeAddAction method run.
@Override
public void run() {
DBVEntity vEntity = resultSetViewer.getModel().getVirtualEntity(false);
DBVEntityAttribute vAttr = new DBVEntityAttribute(vEntity, null, "vcolumn");
if (new EditVirtualAttributePage(resultSetViewer, vAttr).edit(resultSetViewer.getControl().getShell())) {
vAttr.setCustom(true);
vEntity.addVirtualAttribute(vAttr);
vEntity.persistConfiguration();
resultSetViewer.refreshMetaData();
DBDAttributeConstraint vAttrConstr = resultSetViewer.getModel().getDataFilter().getConstraint(vAttr, false);
if (vAttrConstr != null) {
}
}
}
use of org.jkiss.dbeaver.model.virtual.DBVEntityAttribute in project dbeaver by serge-rider.
the class EditVirtualColumnsPage method editSelectedAttribute.
private void editSelectedAttribute(Table attrTable) {
TableItem[] selection = attrTable.getSelection();
if (selection.length <= 0) {
return;
}
TableItem tableItem = selection[0];
DBVEntityAttribute vAttr = (DBVEntityAttribute) tableItem.getData();
EditVirtualAttributePage editAttrPage = new EditVirtualAttributePage(viewer, vAttr);
if (editAttrPage.edit(attrTable.getShell())) {
tableItem.setText(0, vAttr.getName());
tableItem.setText(1, vAttr.getTypeName());
tableItem.setText(2, CommonUtils.notEmpty(vAttr.getExpression()));
}
}
use of org.jkiss.dbeaver.model.virtual.DBVEntityAttribute in project dbeaver by serge-rider.
the class EditVirtualColumnsPage method createPageContents.
@Override
protected Composite createPageContents(Composite parent) {
Composite panel = UIUtils.createComposite(parent, 1);
panel.setLayoutData(new GridData(GridData.FILL_BOTH));
attrTable = new Table(panel, SWT.FULL_SELECTION | SWT.BORDER);
attrTable.setLayoutData(new GridData(GridData.FILL_BOTH));
attrTable.setHeaderVisible(true);
UIUtils.executeOnResize(attrTable, () -> UIUtils.packColumns(attrTable, true));
UIUtils.createTableColumn(attrTable, SWT.LEFT, ResultSetMessages.virtual_edit_columns_page_table_column_name);
UIUtils.createTableColumn(attrTable, SWT.LEFT, ResultSetMessages.virtual_edit_columns_page_table_column_data_type);
UIUtils.createTableColumn(attrTable, SWT.LEFT, ResultSetMessages.virtual_edit_columns_page_table_column_expression);
{
Composite buttonsPanel = UIUtils.createComposite(panel, 3);
buttonsPanel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
Button btnAdd = UIUtils.createDialogButton(buttonsPanel, ResultSetMessages.virtual_edit_columns_page_dialog_button_add, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DBVEntityAttribute vAttr = new DBVEntityAttribute(vEntity, null, "vcolumn");
EditVirtualAttributePage editAttrPage = new EditVirtualAttributePage(viewer, vAttr);
if (editAttrPage.edit(parent.getShell())) {
vAttr.setCustom(true);
vEntity.addVirtualAttribute(vAttr);
structChanged = true;
createAttributeItem(attrTable, vAttr);
}
}
});
Button btnEdit = UIUtils.createDialogButton(buttonsPanel, ResultSetMessages.virtual_edit_columns_page_dialog_button_edit, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
editSelectedAttribute(attrTable);
}
});
btnEdit.setEnabled(false);
Button btnRemove = UIUtils.createDialogButton(buttonsPanel, ResultSetMessages.virtual_edit_columns_page_dialog_button_remove, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DBVEntityAttribute virtualAttr = (DBVEntityAttribute) attrTable.getSelection()[0].getData();
if (!UIUtils.confirmAction(parent.getShell(), ResultSetMessages.virtual_edit_columns_page_confirm_action_delete, NLS.bind(ResultSetMessages.virtual_edit_columns_page_confirm_action_question_delete_column, virtualAttr.getName()))) {
return;
}
vEntity.removeVirtualAttribute(virtualAttr);
attrTable.remove(attrTable.getSelectionIndices());
structChanged = true;
}
});
btnRemove.setEnabled(false);
attrTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean attrSelected = attrTable.getSelectionIndex() >= 0;
btnEdit.setEnabled(attrSelected);
btnRemove.setEnabled(attrSelected);
}
});
attrTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
editSelectedAttribute(attrTable);
}
});
}
refreshAttributes();
return panel;
}
Aggregations