use of org.jkiss.dbeaver.ext.mysql.controls.PrivilegeTableControl in project dbeaver by serge-rider.
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, MySQLMessages.editors_user_editor_general_group_login, 2, GridData.HORIZONTAL_ALIGN_BEGINNING, 200);
userNameText = UIUtils.createLabelText(loginGroup, MySQLMessages.editors_user_editor_general_label_user_name, getDatabaseObject().getUserName());
userNameText.setEditable(newUser);
if (newUser) {
ControlPropertyCommandListener.create(this, userNameText, UserPropertyHandler.NAME);
}
hostText = UIUtils.createLabelText(loginGroup, MySQLMessages.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, MySQLMessages.editors_user_editor_general_label_password, password, SWT.BORDER | SWT.PASSWORD);
ControlPropertyCommandListener.create(this, passwordText, UserPropertyHandler.PASSWORD);
Text confirmText = UIUtils.createLabelText(loginGroup, MySQLMessages.editors_user_editor_general_label_confirm, password, SWT.BORDER | SWT.PASSWORD);
ControlPropertyCommandListener.create(this, confirmText, UserPropertyHandler.PASSWORD_CONFIRM);
}
{
Composite limitsGroup = UIUtils.createControlGroup(container, MySQLMessages.editors_user_editor_general_group_limits, 2, GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
Spinner maxQueriesText = UIUtils.createLabelSpinner(limitsGroup, MySQLMessages.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, MySQLMessages.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, MySQLMessages.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, MySQLMessages.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, MySQLMessages.editors_user_editor_general_control_dba_privileges);
gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 2;
privTable.setLayoutData(gd);
privTable.addListener(SWT.Modify, new Listener() {
@Override
public void handleEvent(Event 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);
}
use of org.jkiss.dbeaver.ext.mysql.controls.PrivilegeTableControl in project dbeaver by serge-rider.
the class MySQLUserEditorPrivileges method createPartControl.
@Override
public void createPartControl(Composite parent) {
boldFont = UIUtils.makeBoldFont(parent.getFont());
pageControl = new PageControl(parent);
Composite container = UIUtils.createPlaceholder(pageControl, 2, 5);
GridData gd = new GridData(GridData.FILL_BOTH);
container.setLayoutData(gd);
Composite leftPane = UIUtils.createPlaceholder(container, 2);
leftPane.setLayoutData(new GridData(GridData.FILL_BOTH));
leftPane.setLayout(new GridLayout(2, true));
{
Composite catalogGroup = UIUtils.createControlGroup(leftPane, MySQLMessages.editors_user_editor_privileges_group_catalogs, 1, GridData.FILL_BOTH, 0);
catalogsTable = new Table(catalogGroup, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
catalogsTable.setHeaderVisible(true);
gd = new GridData(GridData.FILL_BOTH);
catalogsTable.setLayoutData(gd);
catalogsTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int selIndex = catalogsTable.getSelectionIndex();
if (selIndex <= 0) {
selectedCatalog = null;
} else {
selectedCatalog = (MySQLCatalog) catalogsTable.getItem(selIndex).getData();
}
showCatalogTables();
showGrants();
}
});
UIUtils.createTableColumn(catalogsTable, SWT.LEFT, MySQLMessages.editors_user_editor_privileges_column_catalog);
{
TableItem item = new TableItem(catalogsTable, SWT.NONE);
//$NON-NLS-1$
item.setText("% (All)");
item.setImage(DBeaverIcons.getImage(DBIcon.TREE_DATABASE));
}
for (MySQLCatalog catalog : getDatabaseObject().getDataSource().getCatalogs()) {
TableItem item = new TableItem(catalogsTable, SWT.NONE);
item.setText(catalog.getName());
item.setImage(DBeaverIcons.getImage(DBIcon.TREE_DATABASE));
item.setData(catalog);
}
UIUtils.packColumns(catalogsTable);
}
{
Composite tablesGroup = UIUtils.createControlGroup(leftPane, MySQLMessages.editors_user_editor_privileges_group_tables, 1, GridData.FILL_BOTH, 0);
tablesTable = new Table(tablesGroup, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
tablesTable.setHeaderVisible(true);
gd = new GridData(GridData.FILL_BOTH);
tablesTable.setLayoutData(gd);
tablesTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int selIndex = tablesTable.getSelectionIndex();
if (selIndex <= 0) {
selectedTable = null;
} else {
selectedTable = (MySQLTableBase) tablesTable.getItem(selIndex).getData();
}
showGrants();
}
});
UIUtils.createTableColumn(tablesTable, SWT.LEFT, MySQLMessages.editors_user_editor_privileges_column_table);
UIUtils.packColumns(tablesTable);
}
Composite ph = UIUtils.createPlaceholder(container, 1);
ph.setLayoutData(new GridData(GridData.FILL_BOTH));
tablePrivilegesTable = new PrivilegeTableControl(ph, MySQLMessages.editors_user_editor_privileges_control_table_privileges);
gd = new GridData(GridData.FILL_BOTH);
tablePrivilegesTable.setLayoutData(gd);
otherPrivilegesTable = new PrivilegeTableControl(ph, MySQLMessages.editors_user_editor_privileges_control_other_privileges);
gd = new GridData(GridData.FILL_BOTH);
otherPrivilegesTable.setLayoutData(gd);
catalogsTable.setSelection(0);
showCatalogTables();
pageControl.createProgressPanel();
parent.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
UIUtils.dispose(boldFont);
}
});
addGrantListener(tablePrivilegesTable);
addGrantListener(otherPrivilegesTable);
}
Aggregations