use of org.jkiss.dbeaver.ext.postgresql.model.PostgreRole in project dbeaver by serge-rider.
the class PostgreSchemaManager method addObjectCreateActions.
@Override
protected void addObjectCreateActions(List<DBEPersistAction> actions, ObjectCreateCommand command) {
final PostgreSchema schema = command.getObject();
final StringBuilder script = new StringBuilder("CREATE SCHEMA " + DBUtils.getQuotedIdentifier(schema));
try {
final PostgreRole owner = schema.getOwner(VoidProgressMonitor.INSTANCE);
if (owner != null) {
script.append("\nAUTHORIZATION ").append(owner.getName());
}
} catch (DBException e) {
log.error(e);
}
actions.add(//$NON-NLS-2$
new SQLDatabasePersistAction("Create schema", script.toString()));
}
use of org.jkiss.dbeaver.ext.postgresql.model.PostgreRole in project dbeaver by serge-rider.
the class PostgreCreateSchemaDialog 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, "Schema name", "");
nameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
name = nameText.getText();
getButton(IDialogConstants.OK_ID).setEnabled(!name.isEmpty());
}
});
final Combo userCombo = UIUtils.createLabelCombo(group, "Owner", SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
userCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
owner = allUsers.get(userCombo.getSelectionIndex());
}
});
new AbstractJob("Load users") {
@Override
protected IStatus run(DBRProgressMonitor monitor) {
try {
final List<String> userNames = new ArrayList<>();
allUsers = new ArrayList<>(database.getUsers(monitor));
final PostgreRole dba = database.getDBA(monitor);
final String defUserName = dba == null ? "" : dba.getName();
DBeaverUI.syncExec(new Runnable() {
@Override
public void run() {
for (PostgreRole authId : allUsers) {
String name = authId.getName();
userCombo.add(name);
if (name.equals(defUserName)) {
owner = authId;
}
}
userCombo.setText(defUserName);
}
});
} catch (DBException e) {
return GeneralUtils.makeExceptionStatus(e);
}
return Status.OK_STATUS;
}
}.schedule();
return composite;
}
Aggregations