Search in sources :

Example 6 with MySQLUser

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

the class MySQLUserManager method createNewObject.

@Override
public MySQLUser createNewObject(DBRProgressMonitor monitor, DBECommandContext commandContext, MySQLDataSource parent, Object copyFrom) {
    MySQLUser newUser = new MySQLUser(parent, null);
    if (copyFrom instanceof MySQLUser) {
        MySQLUser tplUser = (MySQLUser) copyFrom;
        newUser.setUserName(tplUser.getUserName());
        newUser.setHost(tplUser.getHost());
        newUser.setMaxQuestions(tplUser.getMaxQuestions());
        newUser.setMaxUpdates(tplUser.getMaxUpdates());
        newUser.setMaxConnections(tplUser.getMaxConnections());
        newUser.setMaxUserConnections(tplUser.getMaxUserConnections());
    }
    commandContext.addCommand(new CommandCreateUser(newUser), new CreateObjectReflector<>(this), true);
    return newUser;
}
Also used : MySQLUser(org.jkiss.dbeaver.ext.mysql.model.MySQLUser)

Example 7 with MySQLUser

use of org.jkiss.dbeaver.ext.mysql.model.MySQLUser in project dbeaver by dbeaver.

the class MySQLUserEditorGeneral method createPartControl.

@Override
public void createPartControl(Composite parent) {
    pageControl = new PageControl(parent);
    Composite container = UIUtils.createPlaceholder(pageControl, 2, 5);
    GridData gd = new GridData(GridData.FILL_VERTICAL);
    container.setLayoutData(gd);
    newUser = !getDatabaseObject().isPersisted();
    {
        Composite loginGroup = UIUtils.createControlGroup(container, MySQLUIMessages.editors_user_editor_general_group_login, 2, GridData.HORIZONTAL_ALIGN_BEGINNING, 200);
        userNameText = UIUtils.createLabelText(loginGroup, MySQLUIMessages.editors_user_editor_general_label_user_name, getDatabaseObject().getUserName());
        userNameText.setEditable(newUser);
        if (newUser) {
            ControlPropertyCommandListener.create(this, userNameText, UserPropertyHandler.NAME);
        }
        hostText = UIUtils.createLabelText(loginGroup, MySQLUIMessages.editors_user_editor_general_label_host, getDatabaseObject().getHost());
        hostText.setEditable(newUser);
        if (newUser) {
            ControlPropertyCommandListener.create(this, hostText, UserPropertyHandler.HOST);
        }
        // $NON-NLS-1$
        String password = newUser ? "" : DEF_PASSWORD_VALUE;
        Text passwordText = UIUtils.createLabelText(loginGroup, MySQLUIMessages.editors_user_editor_general_label_password, password, SWT.BORDER | SWT.PASSWORD);
        ControlPropertyCommandListener.create(this, passwordText, UserPropertyHandler.PASSWORD);
        Text confirmText = UIUtils.createLabelText(loginGroup, MySQLUIMessages.editors_user_editor_general_label_confirm, password, SWT.BORDER | SWT.PASSWORD);
        ControlPropertyCommandListener.create(this, confirmText, UserPropertyHandler.PASSWORD_CONFIRM);
    }
    {
        Composite limitsGroup = UIUtils.createControlGroup(container, MySQLUIMessages.editors_user_editor_general_group_limits, 2, GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
        Spinner maxQueriesText = UIUtils.createLabelSpinner(limitsGroup, MySQLUIMessages.editors_user_editor_general_spinner_max_queries, getDatabaseObject().getMaxQuestions(), 0, Integer.MAX_VALUE);
        ControlPropertyCommandListener.create(this, maxQueriesText, UserPropertyHandler.MAX_QUERIES);
        Spinner maxUpdatesText = UIUtils.createLabelSpinner(limitsGroup, MySQLUIMessages.editors_user_editor_general_spinner_max_updates, getDatabaseObject().getMaxUpdates(), 0, Integer.MAX_VALUE);
        ControlPropertyCommandListener.create(this, maxUpdatesText, UserPropertyHandler.MAX_UPDATES);
        Spinner maxConnectionsText = UIUtils.createLabelSpinner(limitsGroup, MySQLUIMessages.editors_user_editor_general_spinner_max_connections, getDatabaseObject().getMaxConnections(), 0, Integer.MAX_VALUE);
        ControlPropertyCommandListener.create(this, maxConnectionsText, UserPropertyHandler.MAX_CONNECTIONS);
        Spinner maxUserConnectionsText = UIUtils.createLabelSpinner(limitsGroup, MySQLUIMessages.editors_user_editor_general_spinner_max_user_connections, getDatabaseObject().getMaxUserConnections(), 0, Integer.MAX_VALUE);
        ControlPropertyCommandListener.create(this, maxUserConnectionsText, UserPropertyHandler.MAX_USER_CONNECTIONS);
    }
    {
        privTable = new PrivilegeTableControl(container, MySQLUIMessages.editors_user_editor_general_control_dba_privileges, true);
        gd = new GridData(GridData.FILL_BOTH);
        gd.horizontalSpan = 2;
        privTable.setLayoutData(gd);
        privTable.addListener(SWT.Modify, event -> {
            final MySQLPrivilege privilege = (MySQLPrivilege) event.data;
            final boolean grant = event.detail == 1;
            addChangeCommand(new MySQLCommandGrantPrivilege(getDatabaseObject(), grant, null, null, privilege), new DBECommandReflector<MySQLUser, MySQLCommandGrantPrivilege>() {

                @Override
                public void redoCommand(MySQLCommandGrantPrivilege mySQLCommandGrantPrivilege) {
                    if (!privTable.isDisposed()) {
                        privTable.checkPrivilege(privilege, grant);
                    }
                }

                @Override
                public void undoCommand(MySQLCommandGrantPrivilege mySQLCommandGrantPrivilege) {
                    if (!privTable.isDisposed()) {
                        privTable.checkPrivilege(privilege, !grant);
                    }
                }
            });
        });
    }
    pageControl.createProgressPanel();
    commandlistener = new CommandListener();
    getEditorInput().getCommandContext().addCommandListener(commandlistener);
}
Also used : MySQLPrivilege(org.jkiss.dbeaver.ext.mysql.model.MySQLPrivilege) DBECommandAdapter(org.jkiss.dbeaver.model.impl.edit.DBECommandAdapter) DatabaseLoadService(org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService) Text(org.eclipse.swt.widgets.Text) Iterator(java.util.Iterator) DBECommandReflector(org.jkiss.dbeaver.model.edit.DBECommandReflector) PrivilegeTableControl(org.jkiss.dbeaver.ext.mysql.ui.controls.PrivilegeTableControl) Spinner(org.eclipse.swt.widgets.Spinner) MySQLUIMessages(org.jkiss.dbeaver.ext.mysql.ui.internal.MySQLUIMessages) UserPropertyHandler(org.jkiss.dbeaver.ext.mysql.ui.config.UserPropertyHandler) InvocationTargetException(java.lang.reflect.InvocationTargetException) MySQLCommandGrantPrivilege(org.jkiss.dbeaver.ext.mysql.ui.config.MySQLCommandGrantPrivilege) List(java.util.List) DBException(org.jkiss.dbeaver.DBException) Composite(org.eclipse.swt.widgets.Composite) UIUtils(org.jkiss.dbeaver.ui.UIUtils) SWT(org.eclipse.swt.SWT) MySQLGrant(org.jkiss.dbeaver.ext.mysql.model.MySQLGrant) MySQLUser(org.jkiss.dbeaver.ext.mysql.model.MySQLUser) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) ControlPropertyCommandListener(org.jkiss.dbeaver.ui.editors.ControlPropertyCommandListener) GridData(org.eclipse.swt.layout.GridData) LoadingJob(org.jkiss.dbeaver.ui.LoadingJob) ControlPropertyCommandListener(org.jkiss.dbeaver.ui.editors.ControlPropertyCommandListener) Composite(org.eclipse.swt.widgets.Composite) MySQLCommandGrantPrivilege(org.jkiss.dbeaver.ext.mysql.ui.config.MySQLCommandGrantPrivilege) Spinner(org.eclipse.swt.widgets.Spinner) PrivilegeTableControl(org.jkiss.dbeaver.ext.mysql.ui.controls.PrivilegeTableControl) DBECommandReflector(org.jkiss.dbeaver.model.edit.DBECommandReflector) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) MySQLPrivilege(org.jkiss.dbeaver.ext.mysql.model.MySQLPrivilege)

Example 8 with MySQLUser

use of org.jkiss.dbeaver.ext.mysql.model.MySQLUser in project dbeaver by dbeaver.

the class MySQLUserManager method createNewObject.

@Override
public MySQLUser createNewObject(DBRProgressMonitor monitor, DBECommandContext commandContext, Object container, Object copyFrom, Map<String, Object> options) {
    MySQLUser newUser = new MySQLUser((MySQLDataSource) container, null);
    if (copyFrom instanceof MySQLUser) {
        MySQLUser tplUser = (MySQLUser) copyFrom;
        newUser.setUserName(tplUser.getUserName());
        newUser.setHost(tplUser.getHost());
        newUser.setMaxQuestions(tplUser.getMaxQuestions());
        newUser.setMaxUpdates(tplUser.getMaxUpdates());
        newUser.setMaxConnections(tplUser.getMaxConnections());
        newUser.setMaxUserConnections(tplUser.getMaxUserConnections());
    }
    commandContext.addCommand(new CommandCreateUser(newUser), new CreateObjectReflector<>(this), true);
    return newUser;
}
Also used : MySQLUser(org.jkiss.dbeaver.ext.mysql.model.MySQLUser)

Aggregations

MySQLUser (org.jkiss.dbeaver.ext.mysql.model.MySQLUser)8 GridData (org.eclipse.swt.layout.GridData)4 MySQLPrivilege (org.jkiss.dbeaver.ext.mysql.model.MySQLPrivilege)4 ControlPropertyCommandListener (org.jkiss.dbeaver.ui.editors.ControlPropertyCommandListener)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Iterator (java.util.Iterator)2 List (java.util.List)2 SWT (org.eclipse.swt.SWT)2 Composite (org.eclipse.swt.widgets.Composite)2 Spinner (org.eclipse.swt.widgets.Spinner)2 Text (org.eclipse.swt.widgets.Text)2 DBException (org.jkiss.dbeaver.DBException)2 PrivilegeTableControl (org.jkiss.dbeaver.ext.mysql.controls.PrivilegeTableControl)2 MySQLCommandGrantPrivilege (org.jkiss.dbeaver.ext.mysql.edit.MySQLCommandGrantPrivilege)2 MySQLGrant (org.jkiss.dbeaver.ext.mysql.model.MySQLGrant)2 MySQLCommandGrantPrivilege (org.jkiss.dbeaver.ext.mysql.ui.config.MySQLCommandGrantPrivilege)2 UserPropertyHandler (org.jkiss.dbeaver.ext.mysql.ui.config.UserPropertyHandler)2 PrivilegeTableControl (org.jkiss.dbeaver.ext.mysql.ui.controls.PrivilegeTableControl)2 MySQLUIMessages (org.jkiss.dbeaver.ext.mysql.ui.internal.MySQLUIMessages)2 DBECommandReflector (org.jkiss.dbeaver.model.edit.DBECommandReflector)2