提交 455cf65f 编写于 作者: J jurgen

Privileges management fix

MySQL user refresh added
上级 52d14bcf
......@@ -20,10 +20,7 @@ package org.jkiss.dbeaver.ext.mysql.edit;
import org.jkiss.dbeaver.ext.IDatabasePersistAction;
import org.jkiss.dbeaver.ext.mysql.MySQLMessages;
import org.jkiss.dbeaver.ext.mysql.model.MySQLCatalog;
import org.jkiss.dbeaver.ext.mysql.model.MySQLPrivilege;
import org.jkiss.dbeaver.ext.mysql.model.MySQLTable;
import org.jkiss.dbeaver.ext.mysql.model.MySQLUser;
import org.jkiss.dbeaver.ext.mysql.model.*;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.edit.DBECommand;
import org.jkiss.dbeaver.model.impl.edit.AbstractDatabasePersistAction;
......@@ -38,10 +35,10 @@ public class MySQLCommandGrantPrivilege extends DBECommandAbstract<MySQLUser> {
private boolean grant;
private MySQLCatalog schema;
private MySQLTable table;
private MySQLTableBase table;
private MySQLPrivilege privilege;
public MySQLCommandGrantPrivilege(MySQLUser user, boolean grant, MySQLCatalog schema, MySQLTable table, MySQLPrivilege privilege)
public MySQLCommandGrantPrivilege(MySQLUser user, boolean grant, MySQLCatalog schema, MySQLTableBase table, MySQLPrivilege privilege)
{
super(user, grant ? MySQLMessages.edit_command_grant_privilege_action_grant_privilege : MySQLMessages.edit_command_grant_privilege_name_revoke_privilege);
this.grant = grant;
......
......@@ -57,7 +57,7 @@ public class MySQLUserEditorPrivileges extends MySQLUserEditorAbstract
private boolean isLoaded = false;
private MySQLCatalog selectedCatalog;
private MySQLTable selectedTable;
private MySQLTableBase selectedTable;
private PrivilegeTableControl tablePrivilegesTable;
private PrivilegeTableControl otherPrivilegesTable;
private volatile List<MySQLGrant> grants;
......@@ -127,7 +127,7 @@ public class MySQLUserEditorPrivileges extends MySQLUserEditorAbstract
if (selIndex <= 0) {
selectedTable = null;
} else {
selectedTable = (MySQLTable) tablesTable.getItem(selIndex).getData();
selectedTable = (MySQLTableBase) tablesTable.getItem(selIndex).getData();
}
showGrants();
}
......@@ -172,7 +172,7 @@ public class MySQLUserEditorPrivileges extends MySQLUserEditorAbstract
final MySQLPrivilege privilege = (MySQLPrivilege) event.data;
final boolean isGrant = event.detail == 1;
final MySQLCatalog curCatalog = selectedCatalog;
final MySQLTable curTable = selectedTable;
final MySQLTableBase curTable = selectedTable;
updateLocalData(privilege, isGrant, curCatalog, curTable);
// Add command
......@@ -205,7 +205,7 @@ public class MySQLUserEditorPrivileges extends MySQLUserEditorAbstract
});
}
private void updateLocalData(MySQLPrivilege privilege, boolean isGrant, MySQLCatalog curCatalog, MySQLTable curTable)
private void updateLocalData(MySQLPrivilege privilege, boolean isGrant, MySQLCatalog curCatalog, MySQLTableBase curTable)
{
// Modify local grants (and clear grants cache in user objects)
getDatabaseObject().clearGrantsCache();
......@@ -246,16 +246,16 @@ public class MySQLUserEditorPrivileges extends MySQLUserEditorAbstract
private void showCatalogTables()
{
LoadingUtils.createService(
new DatabaseLoadService<Collection<MySQLTable>>(MySQLMessages.editors_user_editor_privileges_service_load_tables, getDataSource()) {
new DatabaseLoadService<Collection<MySQLTableBase>>(MySQLMessages.editors_user_editor_privileges_service_load_tables, getDataSource()) {
@Override
public Collection<MySQLTable> evaluate()
public Collection<MySQLTableBase> evaluate()
throws InvocationTargetException, InterruptedException
{
if (selectedCatalog == null) {
return Collections.emptyList();
}
try {
return selectedCatalog.getTables(getProgressMonitor());
return selectedCatalog.getTableCache().getObjects(getProgressMonitor(), selectedCatalog);
}
catch (DBException e) {
log.error(e);
......@@ -348,7 +348,7 @@ public class MySQLUserEditorPrivileges extends MySQLUserEditorAbstract
private void highlightTables()
{
for (TableItem item : tablesTable.getItems()) {
MySQLTable table = (MySQLTable) item.getData();
MySQLTableBase table = (MySQLTableBase) item.getData();
item.setFont(null);
if (grants != null) {
for (MySQLGrant grant : grants) {
......@@ -372,10 +372,10 @@ public class MySQLUserEditorPrivileges extends MySQLUserEditorAbstract
super(parent);
}
public ProgressVisualizer<Collection<MySQLTable>> createTablesLoadVisualizer() {
return new ProgressVisualizer<Collection<MySQLTable>>() {
public ProgressVisualizer<Collection<MySQLTableBase>> createTablesLoadVisualizer() {
return new ProgressVisualizer<Collection<MySQLTableBase>>() {
@Override
public void completeLoading(Collection<MySQLTable> tables) {
public void completeLoading(Collection<MySQLTableBase> tables) {
super.completeLoading(tables);
if (tablesTable.isDisposed()) {
return;
......@@ -386,7 +386,7 @@ public class MySQLUserEditorPrivileges extends MySQLUserEditorAbstract
item.setText("% (All)"); //$NON-NLS-1$
item.setImage(DBIcon.TREE_TABLE.getImage());
}
for (MySQLTable table : tables) {
for (MySQLTableBase table : tables) {
TableItem item = new TableItem(tablesTable, SWT.NONE);
item.setText(table.getName());
item.setImage(table.isView() ? DBIcon.TREE_VIEW.getImage() : DBIcon.TREE_TABLE.getImage());
......
......@@ -110,7 +110,7 @@ public class MySQLGrant {
return (catalog == null && isAllCatalogs()) || (catalog != null && catalog.getName().equalsIgnoreCase(catalogName));
}
public boolean matches(MySQLTable table)
public boolean matches(MySQLTableBase table)
{
return (table == null && isAllTables()) || (table != null && table.getName().equalsIgnoreCase(tableName));
}
......
......@@ -21,6 +21,7 @@ package org.jkiss.dbeaver.ext.mysql.model;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.DBPRefreshableObject;
import org.jkiss.dbeaver.model.DBPSaveableObject;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.access.DBAUser;
......@@ -43,7 +44,7 @@ import java.util.regex.Matcher;
/**
* MySQLUser
*/
public class MySQLUser implements DBAUser, DBPSaveableObject
public class MySQLUser implements DBAUser, DBPRefreshableObject, DBPSaveableObject
{
static final Log log = LogFactory.getLog(MySQLUser.class);
......@@ -295,4 +296,10 @@ public class MySQLUser implements DBAUser, DBPSaveableObject
this.maxUserConnections = maxUserConnections;
}
@Override
public boolean refreshObject(DBRProgressMonitor monitor) throws DBException
{
grants = null;
return true;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册