@NotNull public static Spinner createLabelSpinner( @NotNull Composite parent, @NotNull String label, int value, int minimum, int maximum) { createControlLabel(parent, label); Spinner spinner = new Spinner(parent, SWT.BORDER); spinner.setMinimum(minimum); spinner.setMaximum(maximum); spinner.setSelection(value); return spinner; }
@NotNull public static Text createOutputFolderChooser( final Composite parent, @Nullable String label, @Nullable ModifyListener changeListener) { UIUtils.createControlLabel( parent, label != null ? label : CoreMessages.data_transfer_wizard_output_label_directory); Composite chooserPlaceholder = UIUtils.createPlaceholder(parent, 2); chooserPlaceholder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); final Text directoryText = new Text(chooserPlaceholder, SWT.BORDER); directoryText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); if (changeListener != null) { directoryText.addModifyListener(changeListener); } final Runnable folderChooser = new Runnable() { @Override public void run() { DirectoryDialog dialog = new DirectoryDialog(parent.getShell(), SWT.NONE); dialog.setMessage(CoreMessages.data_transfer_wizard_output_dialog_directory_message); dialog.setText(CoreMessages.data_transfer_wizard_output_dialog_directory_text); String directory = directoryText.getText(); if (!CommonUtils.isEmpty(directory)) { dialog.setFilterPath(directory); } directory = dialog.open(); if (directory != null) { directoryText.setText(directory); } } }; directoryText.addMouseListener( new MouseAdapter() { @Override public void mouseUp(MouseEvent e) { folderChooser.run(); } }); Button openFolder = new Button(chooserPlaceholder, SWT.PUSH | SWT.FLAT); openFolder.setImage(DBeaverIcons.getImage(DBIcon.TREE_FOLDER)); openFolder.setLayoutData( new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.HORIZONTAL_ALIGN_CENTER)); openFolder.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { folderChooser.run(); } }); return directoryText; }
@Override protected Control createPageContents(Composite parent) { Composite propsGroup = new Composite(parent, SWT.NONE); propsGroup.setLayout(new GridLayout(2, false)); GridData gd = new GridData(GridData.FILL_HORIZONTAL); propsGroup.setLayoutData(gd); final Text nameText = UIUtils.createLabelText(propsGroup, "Name", attribute.getName()); // $NON-NLS-2$ nameText.addModifyListener( new ModifyListener() { @Override public void modifyText(ModifyEvent e) { if (attribute instanceof DBPNamedObject2) { ((DBPNamedObject2) attribute).setName(nameText.getText()); } } }); UIUtils.createControlLabel(propsGroup, "Properties") .setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); PropertyTreeViewer propertyViewer = new PropertyTreeViewer(propsGroup, SWT.BORDER); gd = new GridData(GridData.FILL_BOTH); gd.widthHint = 400; propertyViewer.getControl().setLayoutData(gd); propertyViewer.addFilter( new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { return true; } }); PropertySourceAbstract pc = new PropertySourceEditable(commandContext, attribute, attribute); pc.collectProperties(); for (DBPPropertyDescriptor prop : pc.getProperties()) { if (prop instanceof ObjectPropertyDescriptor) { if (((ObjectPropertyDescriptor) prop).isEditPossible() && !prop.getId().equals(DBConstants.PROP_ID_NAME)) { continue; } } pc.removeProperty(prop); } propertyViewer.loadProperties(pc); return propsGroup; }
@NotNull public static Text createLabelText( @NotNull Composite parent, @NotNull String label, @Nullable String value, int style, @Nullable Object layoutData) { createControlLabel(parent, label); Text text = new Text(parent, style); if (value != null) { text.setText(value); } if (layoutData != null) { text.setLayoutData(layoutData); } return text; }
@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)); DBDDataFormatter formatter = helper.getFormatter(valueController, valueController.getValueType()); timeEditor = new CustomTimeEditor(panel, style, formatter); 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; }
@Override public void createControl(Composite parent) { final Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, false)); GridData gd = new GridData(GridData.FILL_BOTH); gd.minimumHeight = 200; composite.setLayoutData(gd); { Group certGroup = UIUtils.createControlGroup(composite, "Certificates", 2, GridData.FILL_HORIZONTAL, -1); UIUtils.createControlLabel(certGroup, "CA certificate"); gd = new GridData(GridData.FILL_HORIZONTAL); gd.minimumWidth = 130; clientCAText = new TextWithOpenFile( certGroup, "CA Certificate", new String[] {"*.*", "*.crt", "*.cert", "*.pem", "*"}); clientCAText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); UIUtils.createControlLabel(certGroup, "SSL certificate"); gd = new GridData(GridData.FILL_HORIZONTAL); gd.minimumWidth = 130; clientCertText = new TextWithOpenFile( certGroup, "SSL Certificate", new String[] {"*.*", "*.cert", "*.pem", "*"}); clientCertText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); UIUtils.createControlLabel(certGroup, "SSL certificate key"); gd = new GridData(GridData.FILL_HORIZONTAL); gd.minimumWidth = 130; clientKeyText = new TextWithOpenFile( certGroup, "SSL Certificate", new String[] {"*.*", "*.cert", "*.pem", "*"}); clientKeyText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); cipherSuitesText = UIUtils.createLabelText(certGroup, "Cipher suites (optional)", ""); cipherSuitesText.setToolTipText( "Overrides the cipher suites enabled for use on the underlying SSL sockets.\nThis may be required when using external JSSE providers or to specify cipher suites compatible with both MySQL server and used JVM."); } { Group advGroup = UIUtils.createControlGroup(composite, "Advanced", 2, GridData.FILL_HORIZONTAL, -1); requireSSQL = UIUtils.createLabelCheckbox( advGroup, "Require SSL", "Require server support of SSL connection.", false); veryServerCert = UIUtils.createLabelCheckbox( advGroup, "Verify server certificate", "Should the driver verify the server's certificate?\nWhen using this feature, the explicit certificate parameters should be specified, rather than system properties.", true); allowPublicKeyRetrieval = UIUtils.createLabelCheckbox( advGroup, "Allow public key retrieval", "Allows special handshake roundtrip to get server RSA public key directly from server.", false); } // debugSSL = UIUtils.createLabelCheckbox(composite, "Debug SSL", "Prints debug // information in standard output.", false); }
@Override protected Control createContents(final Composite parent) { Composite composite = UIUtils.createPlaceholder(parent, 1, 5); { typeTable = new Table(composite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION); typeTable.setLayoutData(new GridData(GridData.FILL_BOTH)); UIUtils.createTableColumn(typeTable, SWT.LEFT, "Name"); UIUtils.createTableColumn(typeTable, SWT.LEFT, "Description"); typeTable.setHeaderVisible(true); typeTable.setLayoutData(new GridData(GridData.FILL_BOTH)); typeTable.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { showSelectedType(getSelectedType()); } }); Composite tableGroup = UIUtils.createPlaceholder(composite, 2, 5); tableGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Button newButton = new Button(tableGroup, SWT.PUSH); newButton.setText("New"); newButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String name; for (int i = 1; ; i++) { name = "Type" + i; boolean hasName = false; for (DBPConnectionType type : changedInfo.keySet()) { if (type.getName().equals(name)) { hasName = true; break; } } if (!hasName) { break; } } DBPConnectionType newType = new DBPConnectionType( SecurityUtils.generateUniqueId(), name, "255,255,255", "New type", true, false); addTypeToTable(newType, newType); typeTable.select(typeTable.getItemCount() - 1); typeTable.showSelection(); showSelectedType(newType); } }); deleteButton = new Button(tableGroup, SWT.PUSH); deleteButton.setText("Delete"); deleteButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DBPConnectionType connectionType = getSelectedType(); if (!UIUtils.confirmAction( deleteButton.getShell(), "Delete connection type", "Are you sure you want to delete connection type '" + connectionType.getName() + "'?\n" + "All connections of this type will be reset to default type (" + DBPConnectionType.DEFAULT_TYPE.getName() + ")")) { return; } changedInfo.remove(connectionType); int index = typeTable.getSelectionIndex(); typeTable.remove(index); if (index > 0) index--; typeTable.select(index); showSelectedType(getSelectedType()); } }); } { Group groupSettings = UIUtils.createControlGroup( composite, "Settings", 2, GridData.VERTICAL_ALIGN_BEGINNING, 300); groupSettings.setLayoutData(new GridData(GridData.FILL_BOTH)); typeName = UIUtils.createLabelText(groupSettings, "Name", null); typeName.addModifyListener( new ModifyListener() { @Override public void modifyText(ModifyEvent e) { getSelectedType().setName(typeName.getText()); updateTableInfo(); } }); typeDescription = UIUtils.createLabelText(groupSettings, "Description", null); typeDescription.addModifyListener( new ModifyListener() { @Override public void modifyText(ModifyEvent e) { getSelectedType().setDescription(typeDescription.getText()); updateTableInfo(); } }); { UIUtils.createControlLabel(groupSettings, "Color"); Composite colorGroup = UIUtils.createPlaceholder(groupSettings, 2, 5); colorGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); colorPicker = new CImageCombo(colorGroup, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY); colorPicker.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); colorPicker.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { getSelectedType() .setColor( StringConverter.asString( colorPicker .getItem(colorPicker.getSelectionIndex()) .getBackground() .getRGB())); updateTableInfo(); } }); Button pickerButton = new Button(colorGroup, SWT.PUSH); pickerButton.setText("..."); pickerButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DBPConnectionType connectionType = getSelectedType(); ColorDialog colorDialog = new ColorDialog(parent.getShell()); colorDialog.setRGB(StringConverter.asRGB(connectionType.getColor())); RGB rgb = colorDialog.open(); if (rgb != null) { Color color = null; int count = colorPicker.getItemCount(); for (int i = 0; i < count; i++) { TableItem item = colorPicker.getItem(i); if (item.getBackground() != null && item.getBackground().getRGB().equals(rgb)) { color = item.getBackground(); break; } } if (color == null) { color = new Color(colorPicker.getDisplay(), rgb); colorPicker.add(null, COLOR_TEXT, color, color); } colorPicker.select(color); getSelectedType().setColor(StringConverter.asString(color.getRGB())); updateTableInfo(); } } }); } GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; autocommitCheck = UIUtils.createCheckbox(groupSettings, "Auto-commit by default", false); autocommitCheck.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { getSelectedType().setAutocommit(autocommitCheck.getSelection()); } }); autocommitCheck.setLayoutData(gd); confirmCheck = UIUtils.createCheckbox(groupSettings, "Confirm SQL execution", false); confirmCheck.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { getSelectedType().setConfirmExecute(confirmCheck.getSelection()); } }); confirmCheck.setLayoutData(gd); } performDefaults(); return composite; }