use of org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider in project dbeaver by serge-rider.
the class AbstractNativeToolWizardPage method createExtraArgsInput.
protected void createExtraArgsInput(Composite outputGroup) {
extraCommandArgsText = UIUtils.createLabelText(outputGroup, "Extra command args", wizard.getSettings().getExtraCommandArgs());
extraCommandArgsText.setToolTipText("Set extra command args for tool executable.");
ContentAssistUtils.installContentProposal(extraCommandArgsText, new SmartTextContentAdapter(), new StringContentProposalProvider(new String[] {}));
extraCommandArgsText.addModifyListener(e -> wizard.getSettings().setExtraCommandArgs(extraCommandArgsText.getText()));
}
use of org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider in project dbeaver by serge-rider.
the class TabbedFolderPageForm method createEditorControl.
/**
* Supported editors:
* Combo (lists)
* Text (strings, numbers, dates)
* Button (booleans)
*/
public Control createEditorControl(Composite parent, Object object, DBPPropertyDescriptor property, Object value, boolean readOnly) {
// List
if (!readOnly && property instanceof IPropertyValueListProvider) {
final IPropertyValueListProvider listProvider = (IPropertyValueListProvider) property;
Object[] items = listProvider.getPossibleValues(object);
if (items == null && property instanceof ObjectPropertyDescriptor && ((ObjectPropertyDescriptor) property).hasListValueProvider()) {
// It is a list provider but it seems to be lazy and not yet initialized
items = new Object[0];
}
if (items != null) {
final String[] strings = new String[items.length];
for (int i = 0, itemsLength = items.length; i < itemsLength; i++) {
strings[i] = objectValueToString(items[i]);
}
Combo combo = UIUtils.createLabelCombo(parent, property.getDisplayName(), SWT.BORDER | SWT.DROP_DOWN | (listProvider.allowCustomValue() ? SWT.NONE : SWT.READ_ONLY) | (readOnly ? SWT.READ_ONLY : SWT.NONE));
combo.setItems(strings);
combo.setText(objectValueToString(value));
combo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING));
if ((combo.getStyle() & SWT.READ_ONLY) == 0) {
StringContentProposalProvider proposalProvider = new StringContentProposalProvider(strings);
ContentAssistUtils.installContentProposal(combo, new ComboContentAdapter(), proposalProvider);
}
return combo;
}
}
Class<?> propType = property.getDataType();
if (isTextPropertyType(propType)) {
if (property instanceof ObjectPropertyDescriptor && ((ObjectPropertyDescriptor) property).isMultiLine()) {
Label label = UIUtils.createControlLabel(parent, property.getDisplayName());
label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
Text editor = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.WRAP | (readOnly ? SWT.READ_ONLY : SWT.NONE));
editor.setText(objectValueToString(value));
GridData gd = new GridData(GridData.FILL_BOTH);
// Make multline editor at least two lines height
gd.heightHint = (UIUtils.getTextHeight(editor) + editor.getBorderWidth()) * 2;
editor.setLayoutData(gd);
return editor;
} else {
Text text = UIUtils.createLabelText(parent, property.getDisplayName(), objectValueToString(value), SWT.BORDER | (readOnly ? SWT.READ_ONLY : SWT.NONE) | (property instanceof ObjectPropertyDescriptor && ((ObjectPropertyDescriptor) property).isPassword() ? SWT.PASSWORD : SWT.NONE));
text.setLayoutData(new GridData((BeanUtils.isNumericType(propType) ? GridData.HORIZONTAL_ALIGN_BEGINNING : GridData.FILL_HORIZONTAL) | GridData.VERTICAL_ALIGN_BEGINNING));
return text;
}
} else if (BeanUtils.isBooleanType(propType)) {
if (curButtonsContainer == null) {
UIUtils.createEmptyLabel(parent, 1, 1);
curButtonsContainer = new Composite(parent, SWT.NONE);
RowLayout layout = new RowLayout(SWT.HORIZONTAL);
curButtonsContainer.setLayout(layout);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
curButtonsContainer.setLayoutData(gd);
}
Button editor = UIUtils.createCheckbox(curButtonsContainer, property.getDisplayName(), "", CommonUtils.toBoolean(value), 1);
if (readOnly) {
editor.setEnabled(false);
}
return editor;
} else if (!readOnly && propType.isEnum()) {
final Object[] enumConstants = propType.getEnumConstants();
final String[] strings = new String[enumConstants.length];
for (int i = 0, itemsLength = enumConstants.length; i < itemsLength; i++) {
strings[i] = ((Enum) enumConstants[i]).name();
}
Combo combo = UIUtils.createLabelCombo(parent, property.getDisplayName(), SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY | (readOnly ? SWT.READ_ONLY : SWT.NONE));
combo.setItems(strings);
combo.setText(objectValueToString(value));
combo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING));
return combo;
} else if (DBSObject.class.isAssignableFrom(propType) || (property instanceof ObjectPropertyDescriptor && ((ObjectPropertyDescriptor) property).isLinkPossible())) {
UIUtils.createControlLabel(parent, property.getDisplayName());
Composite linkPH = new Composite(parent, SWT.NONE);
{
linkPH.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 1;
linkPH.setLayout(layout);
Link link = new Link(linkPH, SWT.NONE);
link.setText(getLinktitle(value));
link.setData(value);
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DBSObject object = (DBSObject) link.getData();
if (object != null) {
NavigatorHandlerObjectOpen.openEntityEditor(object);
}
}
});
link.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
return link;
} else {
return UIUtils.createLabelText(parent, property.getDisplayName(), objectValueToString(value), SWT.BORDER | SWT.READ_ONLY);
}
}
use of org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider 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.StringContentProposalProvider in project dbeaver by serge-rider.
the class GroupingConfigDialog method createDialogArea.
@Override
protected Composite createDialogArea(Composite parent) {
Composite composite = super.createDialogArea(parent);
List<String> proposals = new ArrayList<>();
for (DBDAttributeBinding attr : resultsContainer.getOwnerPresentation().getController().getModel().getAttributes()) {
proposals.add(attr.getName());
}
StringContentProposalProvider proposalProvider = new StringContentProposalProvider(new String[0]);
proposalProvider.setProposals(proposals.toArray(new String[0]));
columnsTable = StringEditorTable.createEditableList(composite, "Columns", resultsContainer.getGroupAttributes(), DBIcon.TREE_ATTRIBUTE, proposalProvider);
Collections.addAll(proposals, "COUNT", "AVG", "MAX", "MIN", "SUM");
proposalProvider.setProposals(proposals.toArray(new String[0]));
functionsTable = StringEditorTable.createEditableList(composite, "Functions", resultsContainer.getGroupFunctions(), DBIcon.TREE_FUNCTION, proposalProvider);
return composite;
}
use of org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider 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;
}
Aggregations