use of org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter in project dbeaver by serge-rider.
the class PostgreBackupWizardPageSettings method createControl.
@Override
public void createControl(Composite parent) {
Composite composite = UIUtils.createPlaceholder(parent, 1);
SelectionListener changeListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateState();
}
};
Group formatGroup = UIUtils.createControlGroup(composite, PostgreMessages.wizard_backup_page_setting_group_setting, 2, GridData.FILL_HORIZONTAL, 0);
formatCombo = UIUtils.createLabelCombo(formatGroup, PostgreMessages.wizard_backup_page_setting_label_format, SWT.DROP_DOWN | SWT.READ_ONLY);
formatCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
for (PostgreDatabaseBackupSettings.ExportFormat format : PostgreDatabaseBackupSettings.ExportFormat.values()) {
formatCombo.add(format.getTitle());
}
formatCombo.select(wizard.getSettings().getFormat().ordinal());
formatCombo.addSelectionListener(changeListener);
compressCombo = UIUtils.createLabelCombo(formatGroup, PostgreMessages.wizard_backup_page_setting_label_compression, SWT.DROP_DOWN | SWT.READ_ONLY);
compressCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
compressCombo.add("");
for (int i = 0; i <= 9; i++) {
String compStr = String.valueOf(i);
compressCombo.add(compStr);
if (compStr.equals(wizard.getSettings().getCompression())) {
compressCombo.select(i);
}
}
if (compressCombo.getSelectionIndex() < 0) {
compressCombo.select(0);
}
compressCombo.addSelectionListener(changeListener);
UIUtils.createControlLabel(formatGroup, PostgreMessages.wizard_backup_page_setting_label_encoding);
encodingCombo = UIUtils.createEncodingCombo(formatGroup, null);
encodingCombo.addSelectionListener(changeListener);
encodingCombo.setText(wizard.getSettings().getEncoding());
useInsertsCheck = UIUtils.createCheckbox(formatGroup, PostgreMessages.wizard_backup_page_setting_checkbox_use_insert, null, wizard.getSettings().isUseInserts(), 2);
useInsertsCheck.addSelectionListener(changeListener);
noPrivilegesCheck = UIUtils.createCheckbox(formatGroup, PostgreMessages.wizard_backup_page_setting_checkbox_no_privileges, null, wizard.getSettings().isNoPrivileges(), 2);
noPrivilegesCheck.addSelectionListener(changeListener);
noOwnerCheck = UIUtils.createCheckbox(formatGroup, PostgreMessages.wizard_backup_page_setting_checkbox_no_owner, null, wizard.getSettings().isNoOwner(), 2);
noOwnerCheck.addSelectionListener(changeListener);
Group outputGroup = UIUtils.createControlGroup(composite, PostgreMessages.wizard_backup_page_setting_group_output, 2, GridData.FILL_HORIZONTAL, 0);
outputFolderText = DialogUtils.createOutputFolderChooser(outputGroup, PostgreMessages.wizard_backup_page_setting_label_output_folder, wizard.getSettings().getOutputFolder() != null ? wizard.getSettings().getOutputFolder().getAbsolutePath() : null, e -> updateState());
outputFileText = UIUtils.createLabelText(outputGroup, PostgreMessages.wizard_backup_page_setting_label_file_name_pattern, wizard.getSettings().getOutputFilePattern());
UIUtils.setContentProposalToolTip(outputFileText, PostgreMessages.wizard_backup_page_setting_label_file_name_pattern_output, NativeToolUtils.VARIABLE_HOST, NativeToolUtils.VARIABLE_DATABASE, NativeToolUtils.VARIABLE_TABLE, NativeToolUtils.VARIABLE_DATE, NativeToolUtils.VARIABLE_TIMESTAMP, NativeToolUtils.VARIABLE_CONN_TYPE);
ContentAssistUtils.installContentProposal(outputFileText, new SmartTextContentAdapter(), new StringContentProposalProvider(GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_HOST), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_DATABASE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_TABLE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_DATE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_TIMESTAMP), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_CONN_TYPE)));
outputFileText.addModifyListener(e -> wizard.getSettings().setOutputFilePattern(outputFileText.getText()));
createExtraArgsInput(outputGroup);
Composite extraGroup = UIUtils.createComposite(composite, 2);
createSecurityGroup(extraGroup);
wizard.createTaskSaveGroup(extraGroup);
setControl(composite);
}
use of org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter in project dbeaver by serge-rider.
the class EditVirtualAttributePage method createPageContents.
@Override
protected Control createPageContents(Composite parent) {
final Composite dialogArea = UIUtils.createComposite(parent, 1);
dialogArea.setLayoutData(new GridData(GridData.FILL_BOTH));
DBPDataSource dataSource = vAttr.getEntity().getDataSource();
Composite panel = UIUtils.createComposite(dialogArea, 2);
panel.setLayoutData(new GridData(GridData.FILL_BOTH));
String name = vAttr.getName();
int index = 1;
for (; ; ) {
DBVEntityAttribute vAttr2 = vAttr.getEntity().getVirtualAttribute(name);
if (vAttr2 == null || vAttr2 == vAttr) {
break;
}
index++;
name = vAttr.getName() + index;
}
nameText = UIUtils.createLabelText(panel, "Column Name", name);
typeCombo = UIUtils.createLabelCombo(panel, "Type Name", "Column type name", SWT.BORDER | SWT.DROP_DOWN);
{
DBPDataTypeProvider dataTypeProvider = DBUtils.getAdapter(DBPDataTypeProvider.class, dataSource);
if (dataTypeProvider != null) {
List<DBSDataType> localDataTypes = new ArrayList<>(dataTypeProvider.getLocalDataTypes());
localDataTypes.sort(Comparator.comparing(DBSDataType::getFullTypeName));
for (DBSDataType dataType : localDataTypes) {
typeCombo.add(dataType.getFullTypeName());
}
String defTypeName = vAttr.getTypeName();
if (CommonUtils.isEmpty(defTypeName)) {
defTypeName = dataTypeProvider.getDefaultDataTypeName(DBPDataKind.STRING);
vAttr.setTypeName(defTypeName);
DBSDataType dataType = dataTypeProvider.getLocalDataType(defTypeName);
if (dataType != null) {
vAttr.setDataKind(dataType.getDataKind());
}
}
if (!CommonUtils.isEmpty(defTypeName)) {
typeCombo.setText(defTypeName);
}
typeCombo.addModifyListener(e -> {
DBSDataType dataType = dataTypeProvider.getLocalDataType(typeCombo.getText());
if (dataType != null) {
kindCombo.setText(dataType.getDataKind().name());
}
});
} else {
typeCombo.setText(CommonUtils.notEmpty(vAttr.getTypeName()));
}
ContentAssistUtils.installContentProposal(typeCombo, new ComboContentAdapter(), new StringContentProposalProvider(typeCombo.getItems()));
}
kindCombo = UIUtils.createLabelCombo(panel, "Data Kind", "Column data kind", SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
for (DBPDataKind dataKind : DBPDataKind.values()) {
if (dataKind != DBPDataKind.UNKNOWN) {
kindCombo.add(dataKind.name());
}
}
kindCombo.setText(vAttr.getDataKind().name());
expressionText = UIUtils.createLabelText(panel, "Expression", CommonUtils.notEmpty(vAttr.getExpression()), SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 300;
gd.heightHint = expressionText.getLineHeight() * 5;
expressionText.setLayoutData(gd);
List<String> expressionProposals = new ArrayList<>();
if (viewer != null) {
for (DBDAttributeBinding attr : viewer.getModel().getAttributes()) {
expressionProposals.add(attr.getLabel());
}
}
ContentAssistUtils.installContentProposal(expressionText, new SmartTextContentAdapter(), new StringContentProposalProvider(expressionProposals.toArray(new String[0])));
previewText = UIUtils.createLabelText(panel, "Preview", "", SWT.BORDER | SWT.READ_ONLY);
previewText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
expressionText.addModifyListener(e -> generatePreviewValue());
generatePreviewValue();
return dialogArea;
}
use of org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter in project dbeaver by serge-rider.
the class MySQLExportWizardPageSettings method createControl.
@Override
public void createControl(Composite parent) {
Composite composite = UIUtils.createPlaceholder(parent, 1);
SelectionListener changeListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateState();
}
};
Group methodGroup = UIUtils.createControlGroup(composite, MySQLUIMessages.tools_db_export_wizard_page_settings_group_exe_method, 1, GridData.FILL_HORIZONTAL, 0);
methodCombo = new Combo(methodGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
methodCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
methodCombo.add(MySQLUIMessages.tools_db_export_wizard_page_settings_combo_item_online_backup);
methodCombo.add(MySQLUIMessages.tools_db_export_wizard_page_settings_combo_item_lock_tables);
methodCombo.add(MySQLUIMessages.tools_db_export_wizard_page_settings_combo_item_normal);
methodCombo.select(wizard.getSettings().getMethod().ordinal());
methodCombo.addSelectionListener(changeListener);
Group settingsGroup = UIUtils.createControlGroup(composite, MySQLUIMessages.tools_db_export_wizard_page_settings_group_settings, 3, GridData.FILL_HORIZONTAL, 0);
noCreateStatementsCheck = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_no_create, wizard.getSettings().isNoCreateStatements());
noCreateStatementsCheck.addSelectionListener(changeListener);
addDropStatementsCheck = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_add_drop, wizard.getSettings().isAddDropStatements());
addDropStatementsCheck.addSelectionListener(changeListener);
disableKeysCheck = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_disable_keys, wizard.getSettings().isDisableKeys());
disableKeysCheck.addSelectionListener(changeListener);
extendedInsertsCheck = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_ext_inserts, wizard.getSettings().isExtendedInserts());
extendedInsertsCheck.addSelectionListener(changeListener);
dumpEventsCheck = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_dump_events, wizard.getSettings().isDumpEvents());
dumpEventsCheck.addSelectionListener(changeListener);
commentsCheck = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_addnl_comments, wizard.getSettings().isComments());
commentsCheck.addSelectionListener(changeListener);
removeDefiner = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_remove_definer, wizard.getSettings().isRemoveDefiner());
removeDefiner.addSelectionListener(changeListener);
binaryInHex = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_binary_hex, wizard.getSettings().isBinariesInHex());
binaryInHex.addSelectionListener(changeListener);
noData = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_no_data, wizard.getSettings().isNoData());
noData.addSelectionListener(changeListener);
Group outputGroup = UIUtils.createControlGroup(composite, MySQLUIMessages.tools_db_export_wizard_page_settings_group_output, 2, GridData.FILL_HORIZONTAL, 0);
outputFolderText = DialogUtils.createOutputFolderChooser(outputGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_label_out_text, e -> updateState());
outputFileText = UIUtils.createLabelText(outputGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_label_file_name_pattern_text, wizard.getSettings().getOutputFilePattern());
UIUtils.setContentProposalToolTip(outputFileText, MySQLUIMessages.tools_db_export_wizard_page_settings_label_file_name_pattern_tip, NativeToolUtils.VARIABLE_HOST, NativeToolUtils.VARIABLE_DATABASE, NativeToolUtils.VARIABLE_TABLE, NativeToolUtils.VARIABLE_DATE, NativeToolUtils.VARIABLE_TIMESTAMP, NativeToolUtils.VARIABLE_CONN_TYPE);
ContentAssistUtils.installContentProposal(outputFileText, new SmartTextContentAdapter(), new StringContentProposalProvider(GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_HOST), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_DATABASE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_TABLE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_DATE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_TIMESTAMP), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_CONN_TYPE)));
createExtraArgsInput(outputGroup);
if (wizard.getSettings().getOutputFolder() != null) {
outputFolderText.setText(wizard.getSettings().getOutputFolder().getAbsolutePath());
}
outputFileText.addModifyListener(e -> wizard.getSettings().setOutputFilePattern(outputFileText.getText()));
Composite extraGroup = UIUtils.createComposite(composite, 2);
createSecurityGroup(extraGroup);
wizard.createTaskSaveGroup(extraGroup);
setControl(composite);
}
use of org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter in project dbeaver by dbeaver.
the class PostgreBackupWizardPageSettings method createControl.
@Override
public void createControl(Composite parent) {
Composite composite = UIUtils.createPlaceholder(parent, 1);
SelectionListener changeListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateState();
}
};
Group formatGroup = UIUtils.createControlGroup(composite, PostgreMessages.wizard_backup_page_setting_group_setting, 2, GridData.FILL_HORIZONTAL, 0);
formatCombo = UIUtils.createLabelCombo(formatGroup, PostgreMessages.wizard_backup_page_setting_label_format, SWT.DROP_DOWN | SWT.READ_ONLY);
formatCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
for (PostgreDatabaseBackupSettings.ExportFormat format : PostgreDatabaseBackupSettings.ExportFormat.values()) {
formatCombo.add(format.getTitle());
}
formatCombo.select(wizard.getSettings().getFormat().ordinal());
formatCombo.addSelectionListener(changeListener);
compressCombo = UIUtils.createLabelCombo(formatGroup, PostgreMessages.wizard_backup_page_setting_label_compression, SWT.DROP_DOWN | SWT.READ_ONLY);
compressCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
compressCombo.add("");
for (int i = 0; i <= 9; i++) {
String compStr = String.valueOf(i);
compressCombo.add(compStr);
if (compStr.equals(wizard.getSettings().getCompression())) {
compressCombo.select(i);
}
}
if (compressCombo.getSelectionIndex() < 0) {
compressCombo.select(0);
}
compressCombo.addSelectionListener(changeListener);
UIUtils.createControlLabel(formatGroup, PostgreMessages.wizard_backup_page_setting_label_encoding);
encodingCombo = UIUtils.createEncodingCombo(formatGroup, null);
encodingCombo.addSelectionListener(changeListener);
encodingCombo.setText(wizard.getSettings().getEncoding());
useInsertsCheck = UIUtils.createCheckbox(formatGroup, PostgreMessages.wizard_backup_page_setting_checkbox_use_insert, null, wizard.getSettings().isUseInserts(), 2);
useInsertsCheck.addSelectionListener(changeListener);
noPrivilegesCheck = UIUtils.createCheckbox(formatGroup, PostgreMessages.wizard_backup_page_setting_checkbox_no_privileges, null, wizard.getSettings().isNoPrivileges(), 2);
noPrivilegesCheck.addSelectionListener(changeListener);
noOwnerCheck = UIUtils.createCheckbox(formatGroup, PostgreMessages.wizard_backup_page_setting_checkbox_no_owner, null, wizard.getSettings().isNoOwner(), 2);
noOwnerCheck.addSelectionListener(changeListener);
Group outputGroup = UIUtils.createControlGroup(composite, PostgreMessages.wizard_backup_page_setting_group_output, 2, GridData.FILL_HORIZONTAL, 0);
outputFolderText = DialogUtils.createOutputFolderChooser(outputGroup, PostgreMessages.wizard_backup_page_setting_label_output_folder, wizard.getSettings().getOutputFolder() != null ? wizard.getSettings().getOutputFolder().getAbsolutePath() : null, e -> updateState());
outputFileText = UIUtils.createLabelText(outputGroup, PostgreMessages.wizard_backup_page_setting_label_file_name_pattern, wizard.getSettings().getOutputFilePattern());
UIUtils.setContentProposalToolTip(outputFileText, PostgreMessages.wizard_backup_page_setting_label_file_name_pattern_output, NativeToolUtils.VARIABLE_HOST, NativeToolUtils.VARIABLE_DATABASE, NativeToolUtils.VARIABLE_TABLE, NativeToolUtils.VARIABLE_DATE, NativeToolUtils.VARIABLE_TIMESTAMP, NativeToolUtils.VARIABLE_CONN_TYPE);
ContentAssistUtils.installContentProposal(outputFileText, new SmartTextContentAdapter(), new StringContentProposalProvider(GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_HOST), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_DATABASE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_TABLE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_DATE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_TIMESTAMP), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_CONN_TYPE)));
outputFileText.addModifyListener(e -> wizard.getSettings().setOutputFilePattern(outputFileText.getText()));
createExtraArgsInput(outputGroup);
Composite extraGroup = UIUtils.createComposite(composite, 2);
createSecurityGroup(extraGroup);
wizard.createTaskSaveGroup(extraGroup);
setControl(composite);
}
use of org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter in project dbeaver by dbeaver.
the class EditVirtualAttributePage method createPageContents.
@Override
protected Control createPageContents(Composite parent) {
final Composite dialogArea = UIUtils.createComposite(parent, 1);
dialogArea.setLayoutData(new GridData(GridData.FILL_BOTH));
DBPDataSource dataSource = vAttr.getEntity().getDataSource();
Composite panel = UIUtils.createComposite(dialogArea, 2);
panel.setLayoutData(new GridData(GridData.FILL_BOTH));
String name = vAttr.getName();
int index = 1;
for (; ; ) {
DBVEntityAttribute vAttr2 = vAttr.getEntity().getVirtualAttribute(name);
if (vAttr2 == null || vAttr2 == vAttr) {
break;
}
index++;
name = vAttr.getName() + index;
}
nameText = UIUtils.createLabelText(panel, "Column Name", name);
typeCombo = UIUtils.createLabelCombo(panel, "Type Name", "Column type name", SWT.BORDER | SWT.DROP_DOWN);
{
DBPDataTypeProvider dataTypeProvider = DBUtils.getAdapter(DBPDataTypeProvider.class, dataSource);
if (dataTypeProvider != null) {
List<DBSDataType> localDataTypes = new ArrayList<>(dataTypeProvider.getLocalDataTypes());
localDataTypes.sort(Comparator.comparing(DBSDataType::getFullTypeName));
for (DBSDataType dataType : localDataTypes) {
typeCombo.add(dataType.getFullTypeName());
}
String defTypeName = vAttr.getTypeName();
if (CommonUtils.isEmpty(defTypeName)) {
defTypeName = dataTypeProvider.getDefaultDataTypeName(DBPDataKind.STRING);
vAttr.setTypeName(defTypeName);
DBSDataType dataType = dataTypeProvider.getLocalDataType(defTypeName);
if (dataType != null) {
vAttr.setDataKind(dataType.getDataKind());
}
}
if (!CommonUtils.isEmpty(defTypeName)) {
typeCombo.setText(defTypeName);
}
typeCombo.addModifyListener(e -> {
DBSDataType dataType = dataTypeProvider.getLocalDataType(typeCombo.getText());
if (dataType != null) {
kindCombo.setText(dataType.getDataKind().name());
}
});
} else {
typeCombo.setText(CommonUtils.notEmpty(vAttr.getTypeName()));
}
ContentAssistUtils.installContentProposal(typeCombo, new ComboContentAdapter(), new StringContentProposalProvider(typeCombo.getItems()));
}
kindCombo = UIUtils.createLabelCombo(panel, "Data Kind", "Column data kind", SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
for (DBPDataKind dataKind : DBPDataKind.values()) {
if (dataKind != DBPDataKind.UNKNOWN) {
kindCombo.add(dataKind.name());
}
}
kindCombo.setText(vAttr.getDataKind().name());
expressionText = UIUtils.createLabelText(panel, "Expression", CommonUtils.notEmpty(vAttr.getExpression()), SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 300;
gd.heightHint = expressionText.getLineHeight() * 5;
expressionText.setLayoutData(gd);
List<String> expressionProposals = new ArrayList<>();
if (viewer != null) {
for (DBDAttributeBinding attr : viewer.getModel().getAttributes()) {
expressionProposals.add(attr.getLabel());
}
}
ContentAssistUtils.installContentProposal(expressionText, new SmartTextContentAdapter(), new StringContentProposalProvider(expressionProposals.toArray(new String[0])));
previewText = UIUtils.createLabelText(panel, "Preview", "", SWT.BORDER | SWT.READ_ONLY);
previewText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
expressionText.addModifyListener(e -> generatePreviewValue());
generatePreviewValue();
return dialogArea;
}
Aggregations