Search in sources :

Example 1 with MySQLCollation

use of org.jkiss.dbeaver.ext.mysql.model.MySQLCollation in project dbeaver by serge-rider.

the class MySQLCreateDatabaseDialog method createDialogArea.

@Override
protected Composite createDialogArea(Composite parent) {
    final Composite composite = super.createDialogArea(parent);
    final Composite group = new Composite(composite, SWT.NONE);
    group.setLayout(new GridLayout(2, false));
    final Text nameText = UIUtils.createLabelText(group, "Database name", "");
    nameText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            name = nameText.getText();
            getButton(IDialogConstants.OK_ID).setEnabled(!name.isEmpty());
        }
    });
    final Combo charsetCombo = UIUtils.createLabelCombo(group, "Charset", SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
    for (MySQLCharset cs : dataSource.getCharsets()) {
        charsetCombo.add(cs.getName());
    }
    charsetCombo.setText(DEFAULT_CHARSET_NAME);
    charset = dataSource.getCharset(DEFAULT_CHARSET_NAME);
    assert charset != null;
    final Combo collationCombo = UIUtils.createLabelCombo(group, "Collation", SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
    for (MySQLCollation col : charset.getCollations()) {
        collationCombo.add(col.getName());
    }
    collation = charset.getDefaultCollation();
    if (collation != null) {
        UIUtils.setComboSelection(collationCombo, collation.getName());
    }
    charsetCombo.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            charset = dataSource.getCharset(charsetCombo.getText());
            assert charset != null;
            collationCombo.removeAll();
            for (MySQLCollation col : charset.getCollations()) {
                collationCombo.add(col.getName());
            }
            collation = charset.getDefaultCollation();
            if (collation != null) {
                UIUtils.setComboSelection(collationCombo, collation.getName());
            }
        }
    });
    collationCombo.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            collation = charset.getCollation(collationCombo.getText());
        }
    });
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) MySQLCharset(org.jkiss.dbeaver.ext.mysql.model.MySQLCharset) MySQLCollation(org.jkiss.dbeaver.ext.mysql.model.MySQLCollation)

Aggregations

ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 MySQLCharset (org.jkiss.dbeaver.ext.mysql.model.MySQLCharset)1 MySQLCollation (org.jkiss.dbeaver.ext.mysql.model.MySQLCollation)1