Search in sources :

Example 1 with MySQLDataSource

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

the class MySQLCommandChangeUser method getPersistActions.

@Override
public DBEPersistAction[] getPersistActions() {
    List<DBEPersistAction> actions = new ArrayList<>();
    boolean newUser = !getObject().isPersisted();
    if (newUser) {
        actions.add(new //$NON-NLS-2$
        SQLDatabasePersistAction(//$NON-NLS-2$
        MySQLMessages.edit_command_change_user_action_create_new_user, //$NON-NLS-2$
        "CREATE USER " + getObject().getFullName()) {

            @Override
            public void handleExecute(DBCSession session, Throwable error) {
                if (error == null) {
                    getObject().setPersisted(true);
                }
            }
        });
    }
    StringBuilder script = new StringBuilder();
    boolean hasSet;
    final MySQLDataSource dataSource = getObject().getDataSource();
    if (!dataSource.isMariaDB() && dataSource.isServerVersionAtLeast(5, 7)) {
        hasSet = generateAlterScript(script);
    } else {
        hasSet = generateUpdateScript(script);
    }
    if (hasSet) {
        actions.add(new SQLDatabasePersistAction(MySQLMessages.edit_command_change_user_action_update_user_record, script.toString()));
    }
    return actions.toArray(new DBEPersistAction[actions.size()]);
}
Also used : MySQLDataSource(org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource) DBEPersistAction(org.jkiss.dbeaver.model.edit.DBEPersistAction) ArrayList(java.util.ArrayList) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction) DBCSession(org.jkiss.dbeaver.model.exec.DBCSession)

Example 2 with MySQLDataSource

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

the class MySQLCommandChangeUser method getPersistActions.

@Override
public DBEPersistAction[] getPersistActions(Map<String, Object> options) {
    List<DBEPersistAction> actions = new ArrayList<>();
    boolean newUser = !getObject().isPersisted();
    if (newUser) {
        actions.add(new // $NON-NLS-2$
        SQLDatabasePersistAction(// $NON-NLS-2$
        MySQLMessages.edit_command_change_user_action_create_new_user, // $NON-NLS-2$
        "CREATE USER " + getObject().getFullName()) {

            @Override
            public void afterExecute(DBCSession session, Throwable error) {
                if (error == null) {
                    getObject().setPersisted(true);
                }
            }
        });
    }
    StringBuilder script = new StringBuilder();
    boolean hasSet;
    final MySQLDataSource dataSource = getObject().getDataSource();
    if (!dataSource.isMariaDB() && dataSource.isServerVersionAtLeast(5, 7)) {
        hasSet = generateAlterScript(script);
    } else {
        hasSet = generateUpdateScript(script);
    }
    if (hasSet) {
        actions.add(new SQLDatabasePersistAction(MySQLMessages.edit_command_change_user_action_update_user_record, script.toString()));
    }
    return actions.toArray(new DBEPersistAction[actions.size()]);
}
Also used : MySQLDataSource(org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource) DBEPersistAction(org.jkiss.dbeaver.model.edit.DBEPersistAction) ArrayList(java.util.ArrayList) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction) DBCSession(org.jkiss.dbeaver.model.exec.DBCSession)

Example 3 with MySQLDataSource

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

the class MySQLSessionEditor method createSessionViewer.

@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
    return new SessionManagerViewer<MySQLSession>(this, parent, new MySQLSessionManager((MySQLDataSource) executionContext.getDataSource())) {

        private boolean hideSleeping;

        @Override
        protected void contributeToToolbar(DBAServerSessionManager sessionManager, IContributionManager contributionManager) {
            contributionManager.add(killSessionAction);
            contributionManager.add(terminateQueryAction);
            contributionManager.add(new Separator());
            contributionManager.add(ActionUtils.makeActionContribution(new Action("Hide sleeping", Action.AS_CHECK_BOX) {

                {
                    setToolTipText("Show only active connections");
                    setChecked(hideSleeping);
                }

                @Override
                public void run() {
                    hideSleeping = isChecked();
                    refreshPart(MySQLSessionEditor.this, true);
                }
            }, true));
            contributionManager.add(new Separator());
        }

        @Override
        protected void onSessionSelect(DBAServerSession session) {
            super.onSessionSelect(session);
            killSessionAction.setEnabled(session != null);
            terminateQueryAction.setEnabled(session != null && !CommonUtils.isEmpty(session.getActiveQuery()));
        }

        @Override
        public Map<String, Object> getSessionOptions() {
            if (hideSleeping) {
                return Collections.singletonMap(MySQLSessionManager.OPTION_HIDE_SLEEPING, true);
            }
            return super.getSessionOptions();
        }

        @Override
        protected void loadSettings(IDialogSettings settings) {
            hideSleeping = CommonUtils.toBoolean(settings.get("hideSleeping"));
            super.loadSettings(settings);
        }

        @Override
        protected void saveSettings(IDialogSettings settings) {
            super.saveSettings(settings);
            settings.put("hideSleeping", hideSleeping);
        }
    };
}
Also used : SessionManagerViewer(org.jkiss.dbeaver.ui.views.session.SessionManagerViewer) Action(org.eclipse.jface.action.Action) DBAServerSession(org.jkiss.dbeaver.model.admin.sessions.DBAServerSession) MySQLDataSource(org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) DBAServerSessionManager(org.jkiss.dbeaver.model.admin.sessions.DBAServerSessionManager) MySQLSessionManager(org.jkiss.dbeaver.ext.mysql.model.session.MySQLSessionManager) IContributionManager(org.eclipse.jface.action.IContributionManager) Separator(org.eclipse.jface.action.Separator)

Example 4 with MySQLDataSource

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

the class MySQLCommandChangeUser method getPersistActions.

@Override
public DBEPersistAction[] getPersistActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, Map<String, Object> options) {
    List<DBEPersistAction> actions = new ArrayList<>();
    boolean newUser = !getObject().isPersisted();
    if (newUser) {
        actions.add(new // $NON-NLS-2$
        SQLDatabasePersistAction(// $NON-NLS-2$
        MySQLUIMessages.edit_command_change_user_action_create_new_user, // $NON-NLS-2$
        "CREATE USER " + getObject().getFullName()) {

            @Override
            public void afterExecute(DBCSession session, Throwable error) {
                if (error == null) {
                    getObject().setPersisted(true);
                }
            }
        });
    }
    boolean hasSet;
    final MySQLDataSource dataSource = getObject().getDataSource();
    if (MySQLUtils.isAlterUSerSupported(dataSource)) {
        StringBuilder script = new StringBuilder();
        if (generateAlterScript(script)) {
            actions.add(new SQLDatabasePersistAction(MySQLUIMessages.edit_command_change_user_action_update_user_record, script.toString()));
        }
    } else {
        String updateSQL = generateUpdateScript();
        if (updateSQL != null) {
            actions.add(new SQLDatabasePersistAction(MySQLUIMessages.edit_command_change_user_action_update_user_record, updateSQL));
        }
        updateSQL = generatePasswordSet();
        if (updateSQL != null) {
            actions.add(new SQLDatabasePersistAction(MySQLUIMessages.edit_command_change_user_action_update_user_record, updateSQL));
        }
    }
    return actions.toArray(new DBEPersistAction[0]);
}
Also used : MySQLDataSource(org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource) DBEPersistAction(org.jkiss.dbeaver.model.edit.DBEPersistAction) ArrayList(java.util.ArrayList) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction) DBCSession(org.jkiss.dbeaver.model.exec.DBCSession)

Example 5 with MySQLDataSource

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

the class MySQLSessionEditor method createSessionViewer.

@Override
protected SessionManagerViewer createSessionViewer(DBCExecutionContext executionContext, Composite parent) {
    return new SessionManagerViewer(this, parent, new MySQLSessionManager((MySQLDataSource) executionContext.getDataSource())) {

        @Override
        protected void contributeToToolbar(DBAServerSessionManager sessionManager, IContributionManager contributionManager) {
            contributionManager.add(killSessionAction);
            contributionManager.add(terminateQueryAction);
            contributionManager.add(new Separator());
        }

        @Override
        protected void onSessionSelect(DBAServerSession session) {
            super.onSessionSelect(session);
            killSessionAction.setEnabled(session != null);
            terminateQueryAction.setEnabled(session != null && !CommonUtils.isEmpty(session.getActiveQuery()));
        }
    };
}
Also used : SessionManagerViewer(org.jkiss.dbeaver.ui.views.session.SessionManagerViewer) DBAServerSession(org.jkiss.dbeaver.model.admin.sessions.DBAServerSession) MySQLDataSource(org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource) DBAServerSessionManager(org.jkiss.dbeaver.model.admin.sessions.DBAServerSessionManager) MySQLSessionManager(org.jkiss.dbeaver.ext.mysql.model.session.MySQLSessionManager) IContributionManager(org.eclipse.jface.action.IContributionManager) Separator(org.eclipse.jface.action.Separator)

Aggregations

MySQLDataSource (org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource)12 ArrayList (java.util.ArrayList)4 IContributionManager (org.eclipse.jface.action.IContributionManager)4 Separator (org.eclipse.jface.action.Separator)4 MySQLSessionManager (org.jkiss.dbeaver.ext.mysql.model.session.MySQLSessionManager)4 DBAServerSession (org.jkiss.dbeaver.model.admin.sessions.DBAServerSession)4 DBAServerSessionManager (org.jkiss.dbeaver.model.admin.sessions.DBAServerSessionManager)4 DBEPersistAction (org.jkiss.dbeaver.model.edit.DBEPersistAction)4 DBCSession (org.jkiss.dbeaver.model.exec.DBCSession)4 SQLDatabasePersistAction (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)4 SessionManagerViewer (org.jkiss.dbeaver.ui.views.session.SessionManagerViewer)4 Action (org.eclipse.jface.action.Action)2 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)2 MySQLCatalog (org.jkiss.dbeaver.ext.mysql.model.MySQLCatalog)2 MySQLTableBase (org.jkiss.dbeaver.ext.mysql.model.MySQLTableBase)2 MySQLTableColumn (org.jkiss.dbeaver.ext.mysql.model.MySQLTableColumn)2 MySQLTableConstraint (org.jkiss.dbeaver.ext.mysql.model.MySQLTableConstraint)2 MySQLTableConstraintColumn (org.jkiss.dbeaver.ext.mysql.model.MySQLTableConstraintColumn)2 MySQLDatabaseExportInfo (org.jkiss.dbeaver.ext.mysql.tasks.MySQLDatabaseExportInfo)2 DBSEntityAttribute (org.jkiss.dbeaver.model.struct.DBSEntityAttribute)2