use of org.jkiss.dbeaver.model.sql.registry.SQLDialectDescriptor in project dbeaver by serge-rider.
the class DatabaseConsumerPageLoadSettings method loadInsertMethods.
private void loadInsertMethods() {
DatabaseConsumerSettings settings = getSettings();
DBPDataSource dataSource = settings.getContainerNode().getDataSource();
List<SQLInsertReplaceMethodDescriptor> insertMethodsDescriptors = null;
if (dataSource != null) {
SQLDialectDescriptor dialectDescriptor = SQLDialectRegistry.getInstance().getDialect(dataSource.getSQLDialect().getDialectId());
insertMethodsDescriptors = dialectDescriptor.getSupportedInsertReplaceMethodsDescriptors();
}
onDuplicateKeyInsertMethods.add(DBSDataManipulator.INSERT_NONE_METHOD);
if (!CommonUtils.isEmpty(insertMethodsDescriptors)) {
boolean emptyButton = true;
for (SQLInsertReplaceMethodDescriptor insertMethod : insertMethodsDescriptors) {
onDuplicateKeyInsertMethods.add(insertMethod.getLabel());
if (insertMethod.getId().equals(settings.getOnDuplicateKeyInsertMethodId())) {
onDuplicateKeyInsertMethods.setText(insertMethod.getLabel());
emptyButton = false;
}
}
if (emptyButton) {
onDuplicateKeyInsertMethods.setText(DBSDataManipulator.INSERT_NONE_METHOD);
}
} else {
onDuplicateKeyInsertMethods.setText(DBSDataManipulator.INSERT_NONE_METHOD);
onDuplicateKeyInsertMethods.setEnabled(false);
Label descLabel = new Label(loadSettings, SWT.NONE);
descLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 2, 1));
descLabel.setText("Replace method not supported by target database");
}
List<SQLInsertReplaceMethodDescriptor> finalInsertMethodsDescriptors = insertMethodsDescriptors;
onDuplicateKeyInsertMethods.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int selIndex = onDuplicateKeyInsertMethods.getSelectionIndex();
if (selIndex > 0 && !CommonUtils.isEmpty(finalInsertMethodsDescriptors)) {
SQLInsertReplaceMethodDescriptor methodDescriptor = finalInsertMethodsDescriptors.get(selIndex - 1);
settings.setOnDuplicateKeyInsertMethodId(methodDescriptor.getId());
} else {
settings.setOnDuplicateKeyInsertMethodId(onDuplicateKeyInsertMethods.getText());
}
}
});
}
use of org.jkiss.dbeaver.model.sql.registry.SQLDialectDescriptor in project dbeaver by dbeaver.
the class DatabaseConsumerPageLoadSettings method loadInsertMethods.
private void loadInsertMethods() {
DatabaseConsumerSettings settings = getSettings();
DBPDataSource dataSource = settings.getContainerNode().getDataSource();
List<SQLInsertReplaceMethodDescriptor> insertMethodsDescriptors = null;
if (dataSource != null) {
SQLDialectDescriptor dialectDescriptor = SQLDialectRegistry.getInstance().getDialect(dataSource.getSQLDialect().getDialectId());
insertMethodsDescriptors = dialectDescriptor.getSupportedInsertReplaceMethodsDescriptors();
}
onDuplicateKeyInsertMethods.add(DBSDataManipulator.INSERT_NONE_METHOD);
if (!CommonUtils.isEmpty(insertMethodsDescriptors)) {
boolean emptyButton = true;
for (SQLInsertReplaceMethodDescriptor insertMethod : insertMethodsDescriptors) {
onDuplicateKeyInsertMethods.add(insertMethod.getLabel());
if (insertMethod.getId().equals(settings.getOnDuplicateKeyInsertMethodId())) {
onDuplicateKeyInsertMethods.setText(insertMethod.getLabel());
emptyButton = false;
}
}
if (emptyButton) {
onDuplicateKeyInsertMethods.setText(DBSDataManipulator.INSERT_NONE_METHOD);
}
} else {
onDuplicateKeyInsertMethods.setText(DBSDataManipulator.INSERT_NONE_METHOD);
onDuplicateKeyInsertMethods.setEnabled(false);
Label descLabel = new Label(loadSettings, SWT.NONE);
descLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 2, 1));
descLabel.setText("Replace method not supported by target database");
}
List<SQLInsertReplaceMethodDescriptor> finalInsertMethodsDescriptors = insertMethodsDescriptors;
onDuplicateKeyInsertMethods.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int selIndex = onDuplicateKeyInsertMethods.getSelectionIndex();
if (selIndex > 0 && !CommonUtils.isEmpty(finalInsertMethodsDescriptors)) {
SQLInsertReplaceMethodDescriptor methodDescriptor = finalInsertMethodsDescriptors.get(selIndex - 1);
settings.setOnDuplicateKeyInsertMethodId(methodDescriptor.getId());
} else {
settings.setOnDuplicateKeyInsertMethodId(onDuplicateKeyInsertMethods.getText());
}
}
});
}
use of org.jkiss.dbeaver.model.sql.registry.SQLDialectDescriptor in project dbeaver by serge-rider.
the class PrefPageSQLDialects method createContents.
@Override
protected Control createContents(Composite parent) {
boolean isPrefPage = element == null;
Composite composite = UIUtils.createComposite(parent, isPrefPage ? 2 : 1);
if (isPrefPage) {
// Create dialect selector
Composite dialectsGroup = UIUtils.createComposite(composite, 1);
dialectsGroup.setLayoutData(new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_BEGINNING));
UIUtils.createControlLabel(dialectsGroup, "Dialects", 2);
Tree dialectTable = new Tree(dialectsGroup, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 200;
dialectTable.setLayoutData(gd);
List<SQLDialectDescriptor> dialects = SQLDialectRegistry.getInstance().getRootDialects();
// dialects.sort(Comparator.comparing(SQLDialectDescriptor::getLabel));
for (SQLDialectDescriptor dialect : dialects) {
createDialectItem(dialectTable, null, dialect);
}
dialectTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem[] selection = dialectTable.getSelection();
if (selection.length == 1) {
curDialect = (SQLDialectDescriptor) selection[0].getData();
loadDialectSettings();
}
}
});
}
{
Composite settingsGroup = UIUtils.createComposite(composite, 2);
GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
gd.widthHint = UIUtils.getFontHeight(settingsGroup) * 50;
settingsGroup.setLayoutData(gd);
if (!isPrefPage) {
Composite nameComp = UIUtils.createComposite(settingsGroup, 2);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
nameComp.setLayoutData(gd);
dialectText = UIUtils.createLabelText(nameComp, "Dialect", "", SWT.READ_ONLY);
}
// UIUtils.createControlLabel(settingsGroup, SQLEditorMessages.pref_page_sql_format_label_settings, 2);
Group kwGroup = UIUtils.createControlGroup(settingsGroup, "Keywords", 2, GridData.FILL_HORIZONTAL, 0);
((GridData) kwGroup.getLayoutData()).horizontalSpan = 2;
reservedWordsText = UIUtils.createLabelTextAdvanced(kwGroup, "Reserved words", "", SWT.BORDER);
dataTypesText = UIUtils.createLabelTextAdvanced(kwGroup, "Data Types", "", SWT.BORDER);
functionNamesText = UIUtils.createLabelTextAdvanced(kwGroup, "Function names", "", SWT.BORDER);
ddlKeywordsText = UIUtils.createLabelTextAdvanced(kwGroup, "DDL keywords", "", SWT.BORDER);
dmlKeywordsText = UIUtils.createLabelTextAdvanced(kwGroup, "Data modify keywords", "", SWT.BORDER);
executeKeywordsText = UIUtils.createLabelTextAdvanced(kwGroup, "Execute keywords", "", SWT.BORDER);
transactionKeywordsText = UIUtils.createLabelTextAdvanced(kwGroup, "Transaction keywords", "", SWT.BORDER);
blockStatementsText = UIUtils.createLabelTextAdvanced(kwGroup, "Block statements", "", SWT.BORDER);
Group miscGroup = UIUtils.createControlGroup(settingsGroup, "Miscellaneous", 2, GridData.FILL_HORIZONTAL, 0);
statementDelimiterText = UIUtils.createLabelText(miscGroup, "Statement delimiter", "", SWT.BORDER);
dualTableNameText = UIUtils.createLabelText(miscGroup, "Dual table name", "", SWT.BORDER);
testQueryText = UIUtils.createLabelText(miscGroup, "Test query", "", SWT.BORDER);
}
performDefaults();
return composite;
}
use of org.jkiss.dbeaver.model.sql.registry.SQLDialectDescriptor in project dbeaver by dbeaver.
the class PrefPageSQLDialects method createContents.
@Override
protected Control createContents(Composite parent) {
boolean isPrefPage = element == null;
Composite composite = UIUtils.createComposite(parent, isPrefPage ? 2 : 1);
if (isPrefPage) {
// Create dialect selector
Composite dialectsGroup = UIUtils.createComposite(composite, 1);
dialectsGroup.setLayoutData(new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_BEGINNING));
UIUtils.createControlLabel(dialectsGroup, "Dialects", 2);
Tree dialectTable = new Tree(dialectsGroup, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 200;
dialectTable.setLayoutData(gd);
List<SQLDialectDescriptor> dialects = SQLDialectRegistry.getInstance().getRootDialects();
// dialects.sort(Comparator.comparing(SQLDialectDescriptor::getLabel));
for (SQLDialectDescriptor dialect : dialects) {
createDialectItem(dialectTable, null, dialect);
}
dialectTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem[] selection = dialectTable.getSelection();
if (selection.length == 1) {
curDialect = (SQLDialectDescriptor) selection[0].getData();
loadDialectSettings();
}
}
});
}
{
Composite settingsGroup = UIUtils.createComposite(composite, 2);
GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
gd.widthHint = UIUtils.getFontHeight(settingsGroup) * 50;
settingsGroup.setLayoutData(gd);
if (!isPrefPage) {
Composite nameComp = UIUtils.createComposite(settingsGroup, 2);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
nameComp.setLayoutData(gd);
dialectText = UIUtils.createLabelText(nameComp, "Dialect", "", SWT.READ_ONLY);
}
// UIUtils.createControlLabel(settingsGroup, SQLEditorMessages.pref_page_sql_format_label_settings, 2);
Group kwGroup = UIUtils.createControlGroup(settingsGroup, "Keywords", 2, GridData.FILL_HORIZONTAL, 0);
((GridData) kwGroup.getLayoutData()).horizontalSpan = 2;
reservedWordsText = UIUtils.createLabelTextAdvanced(kwGroup, "Reserved words", "", SWT.BORDER);
dataTypesText = UIUtils.createLabelTextAdvanced(kwGroup, "Data Types", "", SWT.BORDER);
functionNamesText = UIUtils.createLabelTextAdvanced(kwGroup, "Function names", "", SWT.BORDER);
ddlKeywordsText = UIUtils.createLabelTextAdvanced(kwGroup, "DDL keywords", "", SWT.BORDER);
dmlKeywordsText = UIUtils.createLabelTextAdvanced(kwGroup, "Data modify keywords", "", SWT.BORDER);
executeKeywordsText = UIUtils.createLabelTextAdvanced(kwGroup, "Execute keywords", "", SWT.BORDER);
transactionKeywordsText = UIUtils.createLabelTextAdvanced(kwGroup, "Transaction keywords", "", SWT.BORDER);
blockStatementsText = UIUtils.createLabelTextAdvanced(kwGroup, "Block statements", "", SWT.BORDER);
Group miscGroup = UIUtils.createControlGroup(settingsGroup, "Miscellaneous", 2, GridData.FILL_HORIZONTAL, 0);
statementDelimiterText = UIUtils.createLabelText(miscGroup, "Statement delimiter", "", SWT.BORDER);
dualTableNameText = UIUtils.createLabelText(miscGroup, "Dual table name", "", SWT.BORDER);
testQueryText = UIUtils.createLabelText(miscGroup, "Test query", "", SWT.BORDER);
}
performDefaults();
return composite;
}
Aggregations