use of org.eclipse.swt.widgets.Label in project dbeaver by serge-rider.
the class ExasolConnectionPage method createControl.
@Override
public void createControl(Composite composite) {
setImageDescriptor(EXASOL_LOGO_IMG);
Composite control = new Composite(composite, SWT.NONE);
control.setLayout(new GridLayout(1, false));
control.setLayoutData(new GridData(GridData.FILL_BOTH));
ModifyListener textListener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
evaluateURL();
}
};
{
Composite addrGroup = UIUtils.createControlGroup(control, "Database", 2, 0, 0);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
addrGroup.setLayoutData(gd);
Label hostLabel = UIUtils.createControlLabel(addrGroup, "Host List");
hostLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
hostText = new Text(addrGroup, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
hostText.setLayoutData(gd);
hostText.addModifyListener(textListener);
backupHostLabel = UIUtils.createControlLabel(addrGroup, "Backup Host List");
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
backupHostLabel.setLayoutData(gd);
backupHostLabel.setEnabled(showBackupHosts);
backupHostText = new Text(addrGroup, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
backupHostText.setLayoutData(gd);
backupHostText.addModifyListener(textListener);
useBackupHostList = UIUtils.createLabelCheckbox(addrGroup, "Use Backup Host List", showBackupHosts);
useBackupHostList.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
backupHostLabel.setEnabled(useBackupHostList.getSelection());
backupHostText.setEnabled(useBackupHostList.getSelection());
//reset text if disabled
if (!useBackupHostList.getSelection())
backupHostText.setText("");
}
});
Label portLabel = UIUtils.createControlLabel(addrGroup, ExasolMessages.dialog_connection_port);
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
portLabel.setLayoutData(gd);
portText = new Text(addrGroup, SWT.BORDER);
gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
gd.widthHint = 40;
portText.setLayoutData(gd);
portText.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.getDefault()));
portText.addModifyListener(textListener);
encryptCommunication = UIUtils.createLabelCheckbox(addrGroup, "Encrypt Communication", false);
}
{
Composite addrGroup = UIUtils.createControlGroup(control, "Security", 2, 0, 0);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
addrGroup.setLayoutData(gd);
Label usernameLabel = UIUtils.createControlLabel(addrGroup, ExasolMessages.dialog_connection_user_name);
usernameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
usernameText = new Text(addrGroup, SWT.BORDER);
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.widthHint = 200;
usernameText.setLayoutData(gd);
usernameText.addModifyListener(textListener);
Label passwordLabel = UIUtils.createControlLabel(addrGroup, ExasolMessages.dialog_connection_password);
passwordLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
passwordText = new Text(addrGroup, SWT.BORDER | SWT.PASSWORD);
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.widthHint = 200;
passwordText.setLayoutData(gd);
passwordText.addModifyListener(textListener);
}
createDriverPanel(control);
setControl(control);
}
use of org.eclipse.swt.widgets.Label in project dbeaver by serge-rider.
the class ColumnsMappingDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
DBPDataSource targetDataSource = settings.getTargetDataSource(mapping);
getShell().setText("Map columns of " + mapping.getTargetName());
boldFont = UIUtils.makeBoldFont(parent.getFont());
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(1, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
new Label(composite, SWT.NONE).setText("Source entity: " + DBUtils.getObjectFullName(mapping.getSource(), DBPEvaluationContext.UI) + " [" + mapping.getSource().getDataSource().getContainer().getName() + "]");
new Label(composite, SWT.NONE).setText("Target entity: " + mapping.getTargetName() + " [" + (targetDataSource == null ? "?" : targetDataSource.getContainer().getName()) + "]");
mappingViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 600;
gd.heightHint = 300;
mappingViewer.getTable().setLayoutData(gd);
mappingViewer.getTable().setLinesVisible(true);
mappingViewer.getTable().setHeaderVisible(true);
mappingViewer.setContentProvider(new ListContentProvider());
mappingViewer.getTable().addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.character == SWT.DEL) {
for (TableItem item : mappingViewer.getTable().getSelection()) {
DatabaseMappingAttribute attribute = (DatabaseMappingAttribute) item.getData();
attribute.setMappingType(DatabaseMappingType.skip);
}
updateStatus(Status.OK_STATUS);
mappingViewer.refresh();
} else if (e.character == SWT.SPACE) {
for (TableItem item : mappingViewer.getTable().getSelection()) {
DatabaseMappingAttribute attribute = (DatabaseMappingAttribute) item.getData();
attribute.setMappingType(DatabaseMappingType.existing);
try {
attribute.updateMappingType(VoidProgressMonitor.INSTANCE);
} catch (DBException e1) {
updateStatus(GeneralUtils.makeExceptionStatus(e1));
}
}
mappingViewer.refresh();
}
}
});
{
TableViewerColumn columnSource = new TableViewerColumn(mappingViewer, SWT.LEFT);
columnSource.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
DatabaseMappingAttribute attrMapping = (DatabaseMappingAttribute) cell.getElement();
cell.setText(DBUtils.getObjectFullName(attrMapping.getSource(), DBPEvaluationContext.UI));
if (attrMapping.getIcon() != null) {
cell.setImage(DBeaverIcons.getImage(attrMapping.getIcon()));
}
}
});
columnSource.getColumn().setText("Source Column");
columnSource.getColumn().setWidth(170);
}
{
TableViewerColumn columnSourceType = new TableViewerColumn(mappingViewer, SWT.LEFT);
columnSourceType.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
cell.setText(((DatabaseMappingAttribute) cell.getElement()).getSourceType());
}
});
columnSourceType.getColumn().setText("Source Type");
columnSourceType.getColumn().setWidth(100);
}
{
TableViewerColumn columnTarget = new TableViewerColumn(mappingViewer, SWT.LEFT);
columnTarget.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
DatabaseMappingAttribute mapping = (DatabaseMappingAttribute) cell.getElement();
cell.setText(mapping.getTargetName());
if (mapping.mappingType == DatabaseMappingType.unspecified) {
cell.setBackground(DBeaverUI.getSharedTextColors().getColor(SharedTextColors.COLOR_WARNING));
} else {
cell.setBackground(null);
}
cell.setFont(boldFont);
}
});
columnTarget.getColumn().setText("Target Column");
columnTarget.getColumn().setWidth(170);
columnTarget.setEditingSupport(new EditingSupport(mappingViewer) {
@Override
protected CellEditor getCellEditor(Object element) {
try {
java.util.List<String> items = new ArrayList<>();
DatabaseMappingAttribute mapping = (DatabaseMappingAttribute) element;
if (mapping.getParent().getMappingType() == DatabaseMappingType.existing && mapping.getParent().getTarget() instanceof DBSEntity) {
DBSEntity parentEntity = (DBSEntity) mapping.getParent().getTarget();
for (DBSEntityAttribute attr : CommonUtils.safeCollection(parentEntity.getAttributes(VoidProgressMonitor.INSTANCE))) {
items.add(attr.getName());
}
}
items.add(DatabaseMappingAttribute.TARGET_NAME_SKIP);
CustomComboBoxCellEditor editor = new CustomComboBoxCellEditor(mappingViewer.getTable(), items.toArray(new String[items.size()]), SWT.DROP_DOWN);
updateStatus(Status.OK_STATUS);
return editor;
} catch (DBException e) {
updateStatus(GeneralUtils.makeExceptionStatus(e));
return null;
}
}
@Override
protected boolean canEdit(Object element) {
return true;
}
@Override
protected Object getValue(Object element) {
return ((DatabaseMappingAttribute) element).getTargetName();
}
@Override
protected void setValue(Object element, Object value) {
try {
String name = CommonUtils.toString(value);
DatabaseMappingAttribute attrMapping = (DatabaseMappingAttribute) element;
if (DatabaseMappingAttribute.TARGET_NAME_SKIP.equals(name)) {
attrMapping.setMappingType(DatabaseMappingType.skip);
} else {
if (attrMapping.getParent().getMappingType() == DatabaseMappingType.existing && attrMapping.getParent().getTarget() instanceof DBSEntity) {
DBSEntity parentEntity = (DBSEntity) attrMapping.getParent().getTarget();
for (DBSEntityAttribute attr : CommonUtils.safeCollection(parentEntity.getAttributes(VoidProgressMonitor.INSTANCE))) {
if (name.equalsIgnoreCase(attr.getName())) {
attrMapping.setTarget(attr);
attrMapping.setMappingType(DatabaseMappingType.existing);
return;
}
}
}
attrMapping.setMappingType(DatabaseMappingType.create);
attrMapping.setTargetName(name);
}
updateStatus(Status.OK_STATUS);
} catch (DBException e) {
updateStatus(GeneralUtils.makeExceptionStatus(e));
} finally {
mappingViewer.refresh();
}
}
});
}
{
TableViewerColumn columnTargetType = new TableViewerColumn(mappingViewer, SWT.LEFT);
columnTargetType.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
DatabaseMappingAttribute attrMapping = (DatabaseMappingAttribute) cell.getElement();
DBPDataSource dataSource = settings.getTargetDataSource(attrMapping);
cell.setText(attrMapping.getTargetType(dataSource));
cell.setFont(boldFont);
}
});
columnTargetType.getColumn().setText("Target Type");
columnTargetType.getColumn().setWidth(100);
columnTargetType.setEditingSupport(new EditingSupport(mappingViewer) {
@Override
protected CellEditor getCellEditor(Object element) {
DatabaseMappingAttribute attrMapping = (DatabaseMappingAttribute) element;
Set<String> types = new LinkedHashSet<>();
DBPDataSource dataSource = settings.getTargetDataSource(attrMapping);
if (dataSource instanceof DBPDataTypeProvider) {
for (DBSDataType type : ((DBPDataTypeProvider) dataSource).getLocalDataTypes()) {
types.add(type.getName());
}
}
types.add(attrMapping.getTargetType(dataSource));
return new CustomComboBoxCellEditor(mappingViewer.getTable(), types.toArray(new String[types.size()]), SWT.BORDER);
}
@Override
protected boolean canEdit(Object element) {
return true;
}
@Override
protected Object getValue(Object element) {
DatabaseMappingAttribute attrMapping = (DatabaseMappingAttribute) element;
return attrMapping.getTargetType(settings.getTargetDataSource(attrMapping));
}
@Override
protected void setValue(Object element, Object value) {
DatabaseMappingAttribute attrMapping = (DatabaseMappingAttribute) element;
attrMapping.setTargetType(CommonUtils.toString(value));
mappingViewer.refresh(element);
}
});
}
{
TableViewerColumn columnType = new TableViewerColumn(mappingViewer, SWT.LEFT);
columnType.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
DatabaseMappingAttribute mapping = (DatabaseMappingAttribute) cell.getElement();
String text = "";
switch(mapping.getMappingType()) {
case unspecified:
text = "?";
break;
case existing:
text = "existing";
break;
case create:
text = "new";
break;
case skip:
text = "skip";
break;
}
cell.setText(text);
}
});
columnType.getColumn().setText("Mapping");
columnType.getColumn().setWidth(60);
}
mappingViewer.setInput(attributeMappings);
return parent;
}
use of org.eclipse.swt.widgets.Label in project dbeaver by serge-rider.
the class PostgreWizardPageSettings method createSecurityGroup.
public void createSecurityGroup(Composite parent) {
try {
final SecuredPasswordEncrypter encrypter = new SecuredPasswordEncrypter();
final DBPConnectionConfiguration connectionInfo = wizard.getConnectionInfo();
final String authProperty = DBConstants.INTERNAL_PROP_PREFIX + "-auth-" + wizard.getObjectsName() + "@";
String authUser = null;
String authPassword = null;
{
String authValue = connectionInfo.getProviderProperty(authProperty);
if (authValue != null) {
String authCredentials = encrypter.decrypt(authValue);
int divPos = authCredentials.indexOf(':');
if (divPos != -1) {
authUser = authCredentials.substring(0, divPos);
authPassword = authCredentials.substring(divPos + 1);
}
}
}
wizard.setToolUserName(authUser == null ? connectionInfo.getUserName() : authUser);
wizard.setToolUserPassword(authPassword == null ? connectionInfo.getUserPassword() : authPassword);
final boolean savePassword = authUser != null;
Group securityGroup = UIUtils.createControlGroup(parent, "Security", 2, GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
Label infoLabel = new Label(securityGroup, SWT.NONE);
infoLabel.setText("Override user credentials (" + wizard.getConnectionInfo().getUserName() + ") for pg_dump'.");
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
infoLabel.setLayoutData(gd);
Button authButton = new Button(securityGroup, SWT.PUSH);
authButton.setText("Authentication");
authButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
BaseAuthDialog authDialog = new BaseAuthDialog(getShell(), "Authentication", false);
authDialog.setUserName(wizard.getToolUserName());
authDialog.setUserPassword(wizard.getToolUserPassword());
authDialog.setSavePassword(savePassword);
if (authDialog.open() == IDialogConstants.OK_ID) {
wizard.setToolUserName(authDialog.getUserName());
wizard.setToolUserPassword(authDialog.getUserPassword());
if (authDialog.isSavePassword()) {
try {
connectionInfo.setProviderProperty(authProperty, encrypter.encrypt(wizard.getToolUserName() + ':' + wizard.getToolUserPassword()));
} catch (EncryptionException e1) {
// Never be here
}
}
}
}
});
Button resetButton = new Button(securityGroup, SWT.PUSH);
resetButton.setText("Reset to default");
resetButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
connectionInfo.getProviderProperties().remove(authProperty);
wizard.setToolUserName(connectionInfo.getUserName());
wizard.setToolUserPassword(connectionInfo.getUserPassword());
}
});
} catch (EncryptionException e) {
// Never be here
}
}
use of org.eclipse.swt.widgets.Label in project dbeaver by serge-rider.
the class WMIConnectionPage method createControl.
@Override
public void createControl(Composite composite) {
//Composite group = new Composite(composite, SWT.NONE);
//group.setLayout(new GridLayout(1, true));
setImageDescriptor(logoImage);
ModifyListener textListener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
evaluateURL();
}
};
Composite addrGroup = new Composite(composite, SWT.NONE);
GridLayout gl = new GridLayout(4, false);
gl.marginHeight = 10;
gl.marginWidth = 10;
addrGroup.setLayout(gl);
GridData gd = new GridData(GridData.FILL_BOTH);
addrGroup.setLayoutData(gd);
Label hostLabel = UIUtils.createControlLabel(addrGroup, "Host");
hostLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
hostText = new Text(addrGroup, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
hostText.setLayoutData(gd);
hostText.addModifyListener(textListener);
Label domainLabel = UIUtils.createControlLabel(addrGroup, "Domain");
domainLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
domainText = new Text(addrGroup, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
domainText.setLayoutData(gd);
domainText.addModifyListener(textListener);
Label namespaceLabel = UIUtils.createControlLabel(addrGroup, "Namespace");
namespaceLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
namespaceCombo = new Combo(addrGroup, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 3;
namespaceCombo.setLayoutData(gd);
namespaceCombo.addModifyListener(textListener);
Label divLabel = new Label(addrGroup, SWT.SEPARATOR | SWT.SHADOW_OUT | SWT.HORIZONTAL);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 4;
divLabel.setLayoutData(gd);
{
Label usernameLabel = UIUtils.createControlLabel(addrGroup, "User");
usernameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
usernameText = new Text(addrGroup, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
usernameText.setLayoutData(gd);
usernameText.addModifyListener(textListener);
Label passwordLabel = UIUtils.createControlLabel(addrGroup, "Password");
passwordLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
passwordText = new Text(addrGroup, SWT.BORDER | SWT.PASSWORD);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
passwordText.setLayoutData(gd);
passwordText.addModifyListener(textListener);
}
setControl(addrGroup);
}
use of org.eclipse.swt.widgets.Label in project dbeaver by serge-rider.
the class VersionUpdateDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
getShell().setText(CoreMessages.dialog_version_update_title);
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
composite.setLayout(new GridLayout(1, false));
Composite propGroup = UIUtils.createControlGroup(composite, CoreMessages.dialog_version_update_title, 2, GridData.FILL_BOTH, 0);
boldFont = UIUtils.makeBoldFont(composite.getFont());
final Label titleLabel = new Label(propGroup, SWT.NONE);
titleLabel.setText(newVersion == null ? CoreMessages.dialog_version_update_no_new_version : CoreMessages.dialog_version_update_available_new_version);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
titleLabel.setLayoutData(gd);
titleLabel.setFont(boldFont);
final String versionStr = GeneralUtils.getProductVersion().toString();
UIUtils.createControlLabel(propGroup, CoreMessages.dialog_version_update_current_version);
new Label(propGroup, SWT.NONE).setText(versionStr);
UIUtils.createControlLabel(propGroup, CoreMessages.dialog_version_update_new_version);
new Label(propGroup, SWT.NONE).setText(//$NON-NLS-2$ //$NON-NLS-3$
newVersion == null ? versionStr : newVersion.getProgramVersion().toString() + " (" + newVersion.getUpdateTime() + ")");
if (newVersion != null) {
final Label notesLabel = UIUtils.createControlLabel(propGroup, CoreMessages.dialog_version_update_notes);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
notesLabel.setLayoutData(gd);
final Label notesText = new Label(propGroup, SWT.NONE);
notesText.setText(newVersion.getReleaseNotes());
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
notesText.setLayoutData(gd);
final Label hintLabel = new Label(propGroup, SWT.NONE);
hintLabel.setText(CoreMessages.dialog_version_update_press_more_info_);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
hintLabel.setLayoutData(gd);
hintLabel.setFont(boldFont);
}
return parent;
}
Aggregations