use of org.eclipse.swt.events.ModifyListener in project dbeaver by serge-rider.
the class TextViewDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogGroup = (Composite) super.createDialogArea(parent);
ReferenceValueEditor referenceValueEditor = new ReferenceValueEditor(getValueController(), this);
boolean isForeignKey = referenceValueEditor.isReferenceValue();
Label label = new Label(dialogGroup, SWT.NONE);
label.setText(CoreMessages.dialog_data_label_value);
boolean readOnly = getValueController().isReadOnly();
boolean useHex = !isForeignKey;
final DBSTypedObject valueType = getValueController().getValueType();
long maxSize = valueType.getMaxLength();
if (useHex) {
editorContainer = new CTabFolder(dialogGroup, SWT.FLAT | SWT.TOP);
editorContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
lengthLabel = new Label(editorContainer, SWT.RIGHT);
lengthLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
editorContainer.setTopRight(lengthLabel, SWT.FILL);
}
int selectedType = 0;
if (getDialogSettings().get(VALUE_TYPE_SELECTOR) != null) {
selectedType = getDialogSettings().getInt(VALUE_TYPE_SELECTOR);
}
{
int style = SWT.NONE;
if (readOnly) {
style |= SWT.READ_ONLY;
}
if (useHex) {
style |= SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP;
} else {
// Use border only for plain text editor, otherwise tab folder's border will be used
style |= SWT.BORDER;
}
textEdit = new StyledText(useHex ? editorContainer : dialogGroup, style);
textEdit.setMargins(3, 3, 3, 3);
if (maxSize > 0 && valueType.getDataKind() == DBPDataKind.STRING) {
textEdit.setTextLimit((int) maxSize);
}
if (readOnly) {
//textEdit.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
}
GridData gd = new GridData(isForeignKey ? GridData.FILL_HORIZONTAL : GridData.FILL_BOTH);
gd.widthHint = 300;
if (!isForeignKey) {
gd.heightHint = 200;
gd.grabExcessVerticalSpace = true;
}
textEdit.setLayoutData(gd);
textEdit.setFocus();
textEdit.setEditable(!readOnly);
textEdit.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
dirty = true;
updateValueLength();
}
});
UIUtils.fillDefaultStyledTextContextMenu(textEdit);
if (useHex) {
CTabItem item = new CTabItem(editorContainer, SWT.NO_FOCUS);
item.setText("Text");
item.setImage(DBeaverIcons.getImage(DBIcon.TYPE_TEXT));
item.setControl(textEdit);
}
}
Point minSize = null;
if (useHex) {
hexEditControl = new HexEditControl(editorContainer, readOnly ? SWT.READ_ONLY : SWT.NONE, 6, 8);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 200;
gd.minimumWidth = hexEditControl.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
hexEditControl.setLayoutData(gd);
minSize = hexEditControl.computeSize(SWT.DEFAULT, SWT.DEFAULT);
minSize.x += 50;
minSize.y += 50;
CTabItem item = new CTabItem(editorContainer, SWT.NO_FOCUS);
item.setText("Hex");
item.setImage(DBeaverIcons.getImage(DBIcon.TYPE_BINARY));
item.setControl(hexEditControl);
if (selectedType >= editorContainer.getItemCount()) {
selectedType = 0;
}
editorContainer.setSelection(selectedType);
editorContainer.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
getDialogSettings().put(VALUE_TYPE_SELECTOR, editorContainer.getSelectionIndex());
}
});
hexEditControl.addListener(SWT.Modify, new Listener() {
@Override
public void handleEvent(Event event) {
dirty = true;
}
});
updateValueLength();
}
primeEditorValue(getValueController().getValue());
if (isForeignKey) {
referenceValueEditor.createEditorSelector(dialogGroup);
}
if (minSize != null) {
// Set default size as minimum
getShell().setMinimumSize(minSize);
}
return dialogGroup;
}
use of org.eclipse.swt.events.ModifyListener in project dbeaver by serge-rider.
the class EditShellCommandsDialogPage method createControl.
@Override
public void createControl(Composite parent) {
Composite group = UIUtils.createPlaceholder(parent, 2);
group.setLayoutData(new GridData(GridData.FILL_BOTH));
{
Composite eventGroup = new Composite(group, SWT.NONE);
eventGroup.setLayout(new GridLayout(1, false));
eventGroup.setLayoutData(new GridData(GridData.FILL_VERTICAL));
UIUtils.createControlLabel(eventGroup, CoreMessages.dialog_connection_events_label_event);
eventTypeTable = new Table(eventGroup, SWT.BORDER | SWT.CHECK | SWT.SINGLE | SWT.FULL_SELECTION);
eventTypeTable.setLayoutData(new GridData(GridData.FILL_VERTICAL));
eventTypeTable.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (event.detail == SWT.CHECK) {
eventTypeTable.select(eventTypeTable.indexOf((TableItem) event.item));
}
}
});
for (DBPConnectionEventType eventType : DBPConnectionEventType.values()) {
DBRShellCommand command = eventsCache.get(eventType);
TableItem item = new TableItem(eventTypeTable, SWT.NONE);
item.setData(eventType);
item.setText(eventType.getTitle());
item.setImage(DBeaverIcons.getImage(UIIcon.EVENT));
item.setChecked(command != null && command.isEnabled());
}
eventTypeTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DBPConnectionEventType eventType = getSelectedEventType();
selectEventType(eventType);
DBRShellCommand command = eventType == null ? null : eventsCache.get(eventType);
boolean enabled = ((TableItem) e.item).getChecked();
if (enabled || (command != null && enabled != command.isEnabled())) {
updateEvent(false);
}
}
});
}
{
Composite detailsGroup = new Composite(group, SWT.NONE);
detailsGroup.setLayout(new GridLayout(1, false));
detailsGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
//UIUtils.createControlGroup(group, "Event", 1, GridData.FILL_BOTH | GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
UIUtils.createControlLabel(detailsGroup, CoreMessages.dialog_connection_events_label_command);
commandText = new Text(detailsGroup, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
commandText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
updateEvent(true);
}
});
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 60;
gd.widthHint = 300;
commandText.setLayoutData(gd);
SelectionAdapter eventEditAdapter = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateEvent(false);
}
};
showProcessCheck = UIUtils.createCheckbox(detailsGroup, CoreMessages.dialog_connection_events_checkbox_show_process, false);
showProcessCheck.addSelectionListener(eventEditAdapter);
waitFinishCheck = UIUtils.createCheckbox(detailsGroup, CoreMessages.dialog_connection_events_checkbox_wait_finish, false);
waitFinishCheck.addSelectionListener(eventEditAdapter);
terminateCheck = UIUtils.createCheckbox(detailsGroup, CoreMessages.dialog_connection_events_checkbox_terminate_at_disconnect, false);
terminateCheck.addSelectionListener(eventEditAdapter);
Group helpGroup = new Group(detailsGroup, SWT.NONE);
helpGroup.setText("Command parameters");
helpGroup.setLayout(new GridLayout(2, false));
helpGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
Label infoLabel = new Label(helpGroup, SWT.NONE);
infoLabel.setText("You may use following variables:");
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
infoLabel.setLayoutData(gd);
addVariableLegend(helpGroup, RegistryConstants.VARIABLE_HOST, "target host");
addVariableLegend(helpGroup, RegistryConstants.VARIABLE_PORT, "target port");
addVariableLegend(helpGroup, RegistryConstants.VARIABLE_SERVER, "target server name");
addVariableLegend(helpGroup, RegistryConstants.VARIABLE_DATABASE, "target database");
addVariableLegend(helpGroup, RegistryConstants.VARIABLE_USER, "user name");
addVariableLegend(helpGroup, RegistryConstants.VARIABLE_PASSWORD, "password (plain)");
addVariableLegend(helpGroup, RegistryConstants.VARIABLE_URL, "JDBC URL");
}
selectEventType(null);
setControl(group);
}
use of org.eclipse.swt.events.ModifyListener in project dbeaver by serge-rider.
the class DateTimeStandaloneEditor method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
IValueController valueController = getValueController();
Object value = valueController.getValue();
Composite dialogGroup = (Composite) super.createDialogArea(parent);
Composite panel = UIUtils.createPlaceholder(dialogGroup, 3);
panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
int style = SWT.BORDER;
if (valueController.isReadOnly()) {
style |= SWT.READ_ONLY;
}
UIUtils.createControlLabel(panel, "Time").setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
timeEditor = new CustomTimeEditor(panel, style);
timeEditor.getControl().addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
dirty = true;
}
});
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.CENTER;
timeEditor.getControl().setLayoutData(gd);
primeEditorValue(value);
Button button = UIUtils.createPushButton(panel, "Set Current", null);
button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
button.setEnabled(!valueController.isReadOnly());
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
primeEditorValue(new Date());
}
});
return dialogGroup;
}
use of org.eclipse.swt.events.ModifyListener in project dbeaver by serge-rider.
the class ExasolExportTableToolDialog method createControls.
@Override
protected void createControls(final Composite parent) {
Group optionsGroup = UIUtils.createControlGroup(parent, ExasolMessages.dialog_table_tools_options, 1, 0, 0);
optionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Composite composite = new Composite(optionsGroup, 2);
composite.setLayout(new GridLayout(2, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
// Directory select Button
btSelectDirectory = UIUtils.createPushButton(composite, ExasolMessages.dialog_table_open_output_directory, null);
btSelectDirectory.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final DirectoryDialog dialog = new DirectoryDialog(parent.getShell());
final String directory = dialog.open();
if (directory != null) {
selectedDirectory.setVisible(true);
selectedDirectory.setText(directory + File.separatorChar);
} else {
selectedDirectory.setVisible(false);
}
updateSQL();
}
});
//label for selected directory
selectedDirectory = UIUtils.createLabel(composite, "");
selectedDirectory.setVisible(false);
//file template
filename = "${schema}_${table}_${date}";
txFileName = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_file_template, filename);
txFileName.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
filename = txFileName.getText();
updateSQL();
}
});
// compress output
btSelectCompress = UIUtils.createCheckbox(composite, ExasolMessages.dialog_table_tools_export_compress, false);
btSelectCompress.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateSQL();
}
});
// PlaceHolder
UIUtils.createPlaceholder(composite, 1);
// include column headings
btInclColNames = UIUtils.createCheckbox(composite, ExasolMessages.dialog_table_tools_column_heading, true);
btInclColNames.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateSQL();
}
});
// PlaceHolder
UIUtils.createPlaceholder(composite, 1);
// encoding combo
cbEncoding = UIUtils.createLabelCombo(composite, ExasolMessages.dialog_table_tools_encoding, SWT.DROP_DOWN | SWT.READ_ONLY);
for (String enc : ExasolConstants.encodings) {
cbEncoding.add(enc);
}
cbEncoding.select(0);
encoding = ExasolConstants.encodings.get(0);
cbEncoding.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
encoding = ExasolConstants.encodings.get(cbEncoding.getSelectionIndex());
updateSQL();
}
});
// row seperator
cbRowSep = UIUtils.createLabelCombo(composite, ExasolMessages.dialog_table_tools_string_sep_mode, SWT.DROP_DOWN | SWT.READ_ONLY);
for (String mode : ExasolConstants.rowSeperators) {
cbRowSep.add(mode);
}
cbRowSep.select(0);
rowSep = ExasolConstants.rowSeperators.get(0);
cbRowSep.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
rowSep = ExasolConstants.rowSeperators.get(cbRowSep.getSelectionIndex());
updateSQL();
}
});
// string sep mode
cbStringSepMode = UIUtils.createLabelCombo(composite, ExasolMessages.dialog_table_tools_string_sep_mode, SWT.DROP_DOWN | SWT.READ_ONLY);
for (String mode : ExasolConstants.stringSepModes) {
cbStringSepMode.add(mode);
}
cbStringSepMode.select(0);
sepMode = ExasolConstants.stringSepModes.get(0);
cbStringSepMode.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sepMode = ExasolConstants.stringSepModes.get(cbStringSepMode.getSelectionIndex());
updateSQL();
}
});
// column sep
txColSep = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_column_sep, ";");
txColSep.setTextLimit(1);
txColSep.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
updateSQL();
}
});
// string sep
txStringSep = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_string_sep, "\"");
txStringSep.setTextLimit(1);
txStringSep.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
updateSQL();
}
});
createObjectsSelector(parent);
}
use of org.eclipse.swt.events.ModifyListener in project dbeaver by serge-rider.
the class ExasolImportTableToolDialog method createControls.
@Override
protected void createControls(final Composite parent) {
Group optionsGroup = UIUtils.createControlGroup(parent, ExasolMessages.dialog_table_tools_options, 1, 0, 0);
optionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Composite composite = new Composite(optionsGroup, 2);
composite.setLayout(new GridLayout(2, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
// Directory select Button
btSelectDirectory = UIUtils.createPushButton(composite, ExasolMessages.dialog_table_open_output_directory, null);
btSelectDirectory.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final DirectoryDialog dialog = new DirectoryDialog(parent.getShell());
final String directory = dialog.open();
if (directory != null) {
selectedDirectory.setVisible(true);
selectedDirectory.setText(directory + File.separatorChar);
} else {
selectedDirectory.setVisible(false);
}
updateSQL();
}
});
//label for selected directory
selectedDirectory = UIUtils.createLabel(composite, "");
selectedDirectory.setVisible(false);
//file template
filename = "${schema}_${table}_${date}";
txFileName = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_file_template, filename);
txFileName.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
filename = txFileName.getText();
updateSQL();
}
});
// compress output
btSelectCompress = UIUtils.createCheckbox(composite, ExasolMessages.dialog_table_tools_export_compress, false);
btSelectCompress.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateSQL();
}
});
// PlaceHolder
UIUtils.createPlaceholder(composite, 1);
// include column headings
btInclColNames = UIUtils.createCheckbox(composite, ExasolMessages.dialog_table_tools_column_heading, true);
btInclColNames.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateSQL();
}
});
// PlaceHolder
UIUtils.createPlaceholder(composite, 1);
// encoding combo
cbEncoding = UIUtils.createLabelCombo(composite, ExasolMessages.dialog_table_tools_encoding, SWT.DROP_DOWN | SWT.READ_ONLY);
for (String enc : ExasolConstants.encodings) {
cbEncoding.add(enc);
}
cbEncoding.select(0);
encoding = ExasolConstants.encodings.get(0);
cbEncoding.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
encoding = ExasolConstants.encodings.get(cbEncoding.getSelectionIndex());
updateSQL();
}
});
// row seperator
cbRowSep = UIUtils.createLabelCombo(composite, ExasolMessages.dialog_table_tools_string_sep_mode, SWT.DROP_DOWN | SWT.READ_ONLY);
for (String mode : ExasolConstants.rowSeperators) {
cbRowSep.add(mode);
}
cbRowSep.select(0);
rowSep = ExasolConstants.rowSeperators.get(0);
cbRowSep.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
rowSep = ExasolConstants.rowSeperators.get(cbRowSep.getSelectionIndex());
updateSQL();
}
});
// column sep
txColSep = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_column_sep, ";");
txColSep.setTextLimit(1);
txColSep.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
updateSQL();
}
});
// string sep
txStringSep = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_string_sep, "\"");
txStringSep.setTextLimit(1);
txStringSep.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
updateSQL();
}
});
createObjectsSelector(parent);
}
Aggregations