Search in sources :

Example 1 with ConfirmationDialog

use of org.jkiss.dbeaver.ui.dialogs.ConfirmationDialog in project dbeaver by dbeaver.

the class ExasolConnectionManager method addObjectModifyActions.

@Override
protected void addObjectModifyActions(List<DBEPersistAction> actionList, ObjectChangeCommand command, Map<String, Object> options) {
    ExasolConnection con = command.getObject();
    Map<Object, Object> com = command.getProperties();
    if (com.containsKey("description")) {
        actionList.add(Comment(con));
    }
    // url, username or password have changed
    if (com.containsKey("url") | com.containsKey("userName") | com.containsKey("password")) {
        // possible loss of information - warn
        if ((com.containsKey("url") | com.containsKey("userName")) & !con.getUserName().isEmpty() & con.getPassword().isEmpty()) {
            int result = new UITask<Integer>() {

                protected Integer runTask() {
                    ConfirmationDialog dialog = new ConfirmationDialog(DBeaverUI.getActiveWorkbenchShell(), ExasolMessages.dialog_connection_alter_title, null, ExasolMessages.dialog_connection_alter_message, MessageDialog.CONFIRM, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0, ExasolMessages.dialog_general_continue, false);
                    return dialog.open();
                }
            }.execute();
            if (result != IDialogConstants.YES_ID) {
                throw new IllegalStateException("User abort");
            }
        }
        StringBuilder script = new StringBuilder(String.format("ALTER CONNECTION %s ", DBUtils.getQuotedIdentifier(con)));
        script.append(" '" + ExasolUtils.quoteString(con.getConnectionString()) + "' ");
        if (!(con.getUserName().isEmpty() | con.getPassword().isEmpty())) {
            script.append(String.format(" USER '%s' IDENTIFIED BY '%s'", ExasolUtils.quoteString(con.getUserName()), ExasolUtils.quoteString(con.getPassword())));
        }
        actionList.add(new SQLDatabasePersistAction("alter Connection", script.toString()));
    }
}
Also used : ExasolConnection(org.jkiss.dbeaver.ext.exasol.model.ExasolConnection) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction) ConfirmationDialog(org.jkiss.dbeaver.ui.dialogs.ConfirmationDialog)

Example 2 with ConfirmationDialog

use of org.jkiss.dbeaver.ui.dialogs.ConfirmationDialog in project dbeaver by dbeaver.

the class ExasolSchemaManager method addObjectDeleteActions.

@Override
protected void addObjectDeleteActions(List<DBEPersistAction> actions, ObjectDeleteCommand command, Map<String, Object> options) {
    int result = new UITask<Integer>() {

        protected Integer runTask() {
            ConfirmationDialog dialog = new ConfirmationDialog(DBeaverUI.getActiveWorkbenchShell(), ExasolMessages.dialog_schema_drop_title, null, ExasolMessages.dialog_schema_drop_message, MessageDialog.CONFIRM, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0, ExasolMessages.dialog_general_continue, false);
            return dialog.open();
        }
    }.execute();
    if (result != IDialogConstants.YES_ID) {
        throw new IllegalStateException("User abort");
    }
    actions.add(// $NON-NLS-2$
    new SQLDatabasePersistAction("Drop schema", "DROP SCHEMA " + DBUtils.getQuotedIdentifier(command.getObject()) + " CASCADE"));
}
Also used : SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction) ConfirmationDialog(org.jkiss.dbeaver.ui.dialogs.ConfirmationDialog)

Aggregations

SQLDatabasePersistAction (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)2 ConfirmationDialog (org.jkiss.dbeaver.ui.dialogs.ConfirmationDialog)2 ExasolConnection (org.jkiss.dbeaver.ext.exasol.model.ExasolConnection)1