use of org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorLabelProvider in project dbeaver by dbeaver.
the class ObjectACLEditor method createPartControl.
public void createPartControl(Composite parent) {
this.pageControl = new PageControl(parent);
SashForm composite = UIUtils.createPartDivider(getSite().getPart(), this.pageControl, SWT.HORIZONTAL);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
roleOrObjectTable = new DatabaseNavigatorTree(composite, DBWorkbench.getPlatform().getNavigatorModel().getRoot(), SWT.MULTI | SWT.FULL_SELECTION, false, isRoleEditor() ? new DatabaseObjectFilter() : null);
roleOrObjectTable.setLayoutData(new GridData(GridData.FILL_BOTH));
final TreeViewer treeViewer = roleOrObjectTable.getViewer();
treeViewer.setLabelProvider(new DatabaseNavigatorLabelProvider(treeViewer) {
@Override
public Font getFont(Object element) {
if (element instanceof DBNDatabaseNode) {
DBSObject object = ((DBNDatabaseNode) element).getObject();
if (object instanceof DBSSchema) {
String schemaPrefix = DBUtils.getQuotedIdentifier(object) + ".";
for (String tableName : privilegeMap.keySet()) {
if (tableName.startsWith(schemaPrefix)) {
return boldFont;
}
}
} else if (getObjectPermissions(object) != null) {
return boldFont;
}
}
return null;
}
});
treeViewer.addSelectionChangedListener(event -> handleSelectionChange());
treeViewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof DBNNode && !(element instanceof DBNDatabaseNode)) {
return false;
}
if (element instanceof DBNDatabaseFolder) {
try {
String elementTypeName = ((DBNDatabaseFolder) element).getMeta().getType();
if (elementTypeName == null) {
return false;
}
Class<?> childType = Class.forName(elementTypeName);
return DBAPrivilegeOwner.class.isAssignableFrom(childType);
} catch (ClassNotFoundException e) {
return false;
}
}
return true;
}
});
{
permEditPanel = new Composite(composite, SWT.NONE);
permEditPanel.setLayout(new GridLayout(1, true));
permissionTable = new ObjectListControl<DBAPrivilege>(permEditPanel, SWT.FULL_SELECTION | SWT.CHECK, new ListContentProvider()) {
@Override
protected String getListConfigId(List<Class<?>> classList) {
return ObjectACLEditor.this.getClass().getName();
}
@Override
protected LoadingJob<Collection<DBAPrivilege>> createLoadService() {
return null;
}
};
permissionTable.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
/*
UIUtils.createTableColumn(permissionTable, SWT.LEFT, "Permission");
UIUtils.createTableColumn(permissionTable, SWT.CENTER, "With GRANT");
UIUtils.createTableColumn(permissionTable, SWT.CENTER, "With Hierarchy");
permissionTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (e.detail == SWT.CHECK) {
updateCurrentPrivileges(((TableItem) e.item).getChecked(), (DBAPrivilegeType) e.item.getData());
}
}
});
if (!isRoleEditor()) {
for (PRIVILEGE_TYPE pt : getACLManager().getPrivilegeTypes()) {
if (!pt.isValid() || !pt.supportsType(getDatabaseObject().getClass())) {
continue;
}
TableItem privItem = new TableItem(permissionTable, SWT.LEFT);
privItem.setText(0, pt.getName());
privItem.setData(pt);
}
}
*/
Composite buttonPanel = new Composite(permEditPanel, SWT.NONE);
buttonPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
buttonPanel.setLayout(new RowLayout());
UIUtils.createPushButton(buttonPanel, "Grant All", null, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
/*
boolean hadNonChecked = false;
for (TableItem item : permissionTable.getItems()) {
if (!item.getChecked()) hadNonChecked = true;
item.setChecked(true);
}
if (hadNonChecked) updateCurrentPrivileges(true, null);
*/
}
});
UIUtils.createPushButton(buttonPanel, "Revoke All", null, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
/*
boolean hadChecked = false;
for (TableItem item : permissionTable.getItems()) {
if (item.getChecked()) hadChecked = true;
item.setChecked(false);
}
if (hadChecked) {
updateCurrentPrivileges(false, null);
}
*/
}
});
objectDescriptionText = new Text(permEditPanel, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
objectDescriptionText.setLayoutData(new GridData(GridData.FILL_BOTH));
}
pageControl.createOrSubstituteProgressPanel(getSite());
updateObjectPermissions(null);
}
use of org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorLabelProvider in project dbeaver by serge-rider.
the class PostgresRolePrivilegesEditor method createPartControl.
public void createPartControl(Composite parent) {
this.pageControl = new PageControl(parent);
SashForm composite = UIUtils.createPartDivider(getSite().getPart(), this.pageControl, SWT.HORIZONTAL);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
roleOrObjectTable = new DatabaseNavigatorTree(composite, DBWorkbench.getPlatform().getNavigatorModel().getRoot(), SWT.MULTI | SWT.FULL_SELECTION, false, isRoleEditor() ? new DatabaseObjectFilter() : null);
roleOrObjectTable.setLayoutData(new GridData(GridData.FILL_BOTH));
final TreeViewer treeViewer = roleOrObjectTable.getViewer();
treeViewer.setLabelProvider(new DatabaseNavigatorLabelProvider(treeViewer) {
@Override
public Font getFont(Object element) {
if (element instanceof DBNDatabaseNode) {
DBSObject object = ((DBNDatabaseNode) element).getObject();
if (object instanceof PostgreSchema) {
String schemaPrefix = DBUtils.getQuotedIdentifier(object) + ".";
for (String tableName : permissionMap.keySet()) {
if (tableName.startsWith(schemaPrefix)) {
return boldFont;
}
}
} else if (getObjectPermissions(object) != null) {
return boldFont;
}
}
return null;
}
});
treeViewer.addSelectionChangedListener(event -> handleSelectionChange());
treeViewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof DBNNode && !(element instanceof DBNDatabaseNode)) {
return false;
}
if (element instanceof DBNDatabaseFolder) {
try {
String elementTypeName = ((DBNDatabaseFolder) element).getMeta().getType();
if (elementTypeName == null) {
return false;
}
Class<?> childType = Class.forName(elementTypeName);
return PostgreTableReal.class.isAssignableFrom(childType) || PostgreSequence.class.isAssignableFrom(childType) || PostgreProcedure.class.isAssignableFrom(childType);
} catch (ClassNotFoundException e) {
return false;
}
}
return true;
}
});
{
permEditPanel = new Composite(composite, SWT.NONE);
permEditPanel.setLayout(new GridLayout(1, true));
permissionTable = new Table(permEditPanel, SWT.FULL_SELECTION | SWT.CHECK);
permissionTable.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
permissionTable.setHeaderVisible(true);
permissionTable.setLinesVisible(true);
UIUtils.createTableColumn(permissionTable, SWT.LEFT, PostgreMessages.dialog_create_table_column_name_permission);
UIUtils.createTableColumn(permissionTable, SWT.CENTER, PostgreMessages.dialog_create_table_column_name_with_garant);
UIUtils.createTableColumn(permissionTable, SWT.CENTER, PostgreMessages.dialog_create_table_column_name_with_hierarchy);
permissionTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (e.detail == SWT.CHECK) {
updateCurrentPrivileges(((TableItem) e.item).getChecked(), (PostgrePrivilegeType) e.item.getData());
}
}
});
permissionTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
super.mouseDown(e);
}
});
if (!isRoleEditor()) {
for (PostgrePrivilegeType pt : PostgrePrivilegeType.values()) {
if (!pt.isValid() || !pt.supportsType(getDatabaseObject().getClass())) {
continue;
}
TableItem privItem = new TableItem(permissionTable, SWT.LEFT);
privItem.setText(0, pt.name());
privItem.setData(pt);
}
}
Composite buttonPanel = new Composite(permEditPanel, SWT.NONE);
buttonPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
buttonPanel.setLayout(new RowLayout());
UIUtils.createPushButton(buttonPanel, PostgreMessages.dialog_create_push_button_grant_all, null, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean hadNonChecked = false;
for (TableItem item : permissionTable.getItems()) {
if (!item.getChecked())
hadNonChecked = true;
item.setChecked(true);
}
if (hadNonChecked)
updateCurrentPrivileges(true, null);
}
});
UIUtils.createPushButton(buttonPanel, PostgreMessages.dialog_create_push_button_revoke_all, null, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean hadChecked = false;
for (TableItem item : permissionTable.getItems()) {
if (item.getChecked())
hadChecked = true;
item.setChecked(false);
}
if (hadChecked) {
updateCurrentPrivileges(false, null);
}
}
});
objectDescriptionText = new Text(permEditPanel, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
objectDescriptionText.setLayoutData(new GridData(GridData.FILL_BOTH));
}
pageControl.createOrSubstituteProgressPanel(getSite());
updateObjectPermissions(null);
}
use of org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorLabelProvider in project dbeaver by serge-rider.
the class ObjectACLEditor method createPartControl.
public void createPartControl(Composite parent) {
this.pageControl = new PageControl(parent);
SashForm composite = UIUtils.createPartDivider(getSite().getPart(), this.pageControl, SWT.HORIZONTAL);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
roleOrObjectTable = new DatabaseNavigatorTree(composite, DBWorkbench.getPlatform().getNavigatorModel().getRoot(), SWT.MULTI | SWT.FULL_SELECTION, false, isRoleEditor() ? new DatabaseObjectFilter() : null);
roleOrObjectTable.setLayoutData(new GridData(GridData.FILL_BOTH));
final TreeViewer treeViewer = roleOrObjectTable.getViewer();
treeViewer.setLabelProvider(new DatabaseNavigatorLabelProvider(treeViewer) {
@Override
public Font getFont(Object element) {
if (element instanceof DBNDatabaseNode) {
DBSObject object = ((DBNDatabaseNode) element).getObject();
if (object instanceof DBSSchema) {
String schemaPrefix = DBUtils.getQuotedIdentifier(object) + ".";
for (String tableName : privilegeMap.keySet()) {
if (tableName.startsWith(schemaPrefix)) {
return boldFont;
}
}
} else if (getObjectPermissions(object) != null) {
return boldFont;
}
}
return null;
}
});
treeViewer.addSelectionChangedListener(event -> handleSelectionChange());
treeViewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof DBNNode && !(element instanceof DBNDatabaseNode)) {
return false;
}
if (element instanceof DBNDatabaseFolder) {
try {
String elementTypeName = ((DBNDatabaseFolder) element).getMeta().getType();
if (elementTypeName == null) {
return false;
}
Class<?> childType = Class.forName(elementTypeName);
return DBAPrivilegeOwner.class.isAssignableFrom(childType);
} catch (ClassNotFoundException e) {
return false;
}
}
return true;
}
});
{
permEditPanel = new Composite(composite, SWT.NONE);
permEditPanel.setLayout(new GridLayout(1, true));
permissionTable = new ObjectListControl<DBAPrivilege>(permEditPanel, SWT.FULL_SELECTION | SWT.CHECK, new ListContentProvider()) {
@Override
protected String getListConfigId(List<Class<?>> classList) {
return ObjectACLEditor.this.getClass().getName();
}
@Override
protected LoadingJob<Collection<DBAPrivilege>> createLoadService() {
return null;
}
};
permissionTable.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
/*
UIUtils.createTableColumn(permissionTable, SWT.LEFT, "Permission");
UIUtils.createTableColumn(permissionTable, SWT.CENTER, "With GRANT");
UIUtils.createTableColumn(permissionTable, SWT.CENTER, "With Hierarchy");
permissionTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (e.detail == SWT.CHECK) {
updateCurrentPrivileges(((TableItem) e.item).getChecked(), (DBAPrivilegeType) e.item.getData());
}
}
});
if (!isRoleEditor()) {
for (PRIVILEGE_TYPE pt : getACLManager().getPrivilegeTypes()) {
if (!pt.isValid() || !pt.supportsType(getDatabaseObject().getClass())) {
continue;
}
TableItem privItem = new TableItem(permissionTable, SWT.LEFT);
privItem.setText(0, pt.getName());
privItem.setData(pt);
}
}
*/
Composite buttonPanel = new Composite(permEditPanel, SWT.NONE);
buttonPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
buttonPanel.setLayout(new RowLayout());
UIUtils.createPushButton(buttonPanel, "Grant All", null, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
/*
boolean hadNonChecked = false;
for (TableItem item : permissionTable.getItems()) {
if (!item.getChecked()) hadNonChecked = true;
item.setChecked(true);
}
if (hadNonChecked) updateCurrentPrivileges(true, null);
*/
}
});
UIUtils.createPushButton(buttonPanel, "Revoke All", null, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
/*
boolean hadChecked = false;
for (TableItem item : permissionTable.getItems()) {
if (item.getChecked()) hadChecked = true;
item.setChecked(false);
}
if (hadChecked) {
updateCurrentPrivileges(false, null);
}
*/
}
});
objectDescriptionText = new Text(permEditPanel, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
objectDescriptionText.setLayoutData(new GridData(GridData.FILL_BOTH));
}
pageControl.createOrSubstituteProgressPanel(getSite());
updateObjectPermissions(null);
}
use of org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorLabelProvider in project dbeaver by dbeaver.
the class PostgresRolePrivilegesEditor method createPartControl.
public void createPartControl(Composite parent) {
this.pageControl = new PageControl(parent);
SashForm composite = UIUtils.createPartDivider(getSite().getPart(), this.pageControl, SWT.HORIZONTAL);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
roleOrObjectTable = new DatabaseNavigatorTree(composite, DBWorkbench.getPlatform().getNavigatorModel().getRoot(), SWT.MULTI | SWT.FULL_SELECTION, false, isRoleEditor() ? new DatabaseObjectFilter() : null);
roleOrObjectTable.setLayoutData(new GridData(GridData.FILL_BOTH));
final TreeViewer treeViewer = roleOrObjectTable.getViewer();
treeViewer.setLabelProvider(new DatabaseNavigatorLabelProvider(treeViewer) {
@Override
public Font getFont(Object element) {
if (element instanceof DBNDatabaseNode) {
DBSObject object = ((DBNDatabaseNode) element).getObject();
if (object instanceof PostgreSchema) {
String schemaPrefix = DBUtils.getQuotedIdentifier(object) + ".";
for (String tableName : permissionMap.keySet()) {
if (tableName.startsWith(schemaPrefix)) {
return boldFont;
}
}
} else if (getObjectPermissions(object) != null) {
return boldFont;
}
}
return null;
}
});
treeViewer.addSelectionChangedListener(event -> handleSelectionChange());
treeViewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof DBNNode && !(element instanceof DBNDatabaseNode)) {
return false;
}
if (element instanceof DBNDatabaseFolder) {
try {
String elementTypeName = ((DBNDatabaseFolder) element).getMeta().getType();
if (elementTypeName == null) {
return false;
}
Class<?> childType = Class.forName(elementTypeName);
return PostgreTableReal.class.isAssignableFrom(childType) || PostgreSequence.class.isAssignableFrom(childType) || PostgreProcedure.class.isAssignableFrom(childType);
} catch (ClassNotFoundException e) {
return false;
}
}
return true;
}
});
{
permEditPanel = new Composite(composite, SWT.NONE);
permEditPanel.setLayout(new GridLayout(1, true));
permissionTable = new Table(permEditPanel, SWT.FULL_SELECTION | SWT.CHECK);
permissionTable.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
permissionTable.setHeaderVisible(true);
permissionTable.setLinesVisible(true);
UIUtils.createTableColumn(permissionTable, SWT.LEFT, PostgreMessages.dialog_create_table_column_name_permission);
UIUtils.createTableColumn(permissionTable, SWT.CENTER, PostgreMessages.dialog_create_table_column_name_with_garant);
UIUtils.createTableColumn(permissionTable, SWT.CENTER, PostgreMessages.dialog_create_table_column_name_with_hierarchy);
permissionTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (e.detail == SWT.CHECK) {
updateCurrentPrivileges(((TableItem) e.item).getChecked(), (PostgrePrivilegeType) e.item.getData());
}
}
});
permissionTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
super.mouseDown(e);
}
});
if (!isRoleEditor()) {
for (PostgrePrivilegeType pt : PostgrePrivilegeType.values()) {
if (!pt.isValid() || !pt.supportsType(getDatabaseObject().getClass())) {
continue;
}
TableItem privItem = new TableItem(permissionTable, SWT.LEFT);
privItem.setText(0, pt.name());
privItem.setData(pt);
}
}
Composite buttonPanel = new Composite(permEditPanel, SWT.NONE);
buttonPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
buttonPanel.setLayout(new RowLayout());
UIUtils.createPushButton(buttonPanel, PostgreMessages.dialog_create_push_button_grant_all, null, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean hadNonChecked = false;
for (TableItem item : permissionTable.getItems()) {
if (!item.getChecked())
hadNonChecked = true;
item.setChecked(true);
}
if (hadNonChecked)
updateCurrentPrivileges(true, null);
}
});
UIUtils.createPushButton(buttonPanel, PostgreMessages.dialog_create_push_button_revoke_all, null, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean hadChecked = false;
for (TableItem item : permissionTable.getItems()) {
if (item.getChecked())
hadChecked = true;
item.setChecked(false);
}
if (hadChecked) {
updateCurrentPrivileges(false, null);
}
}
});
objectDescriptionText = new Text(permEditPanel, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
objectDescriptionText.setLayoutData(new GridData(GridData.FILL_BOTH));
}
pageControl.createOrSubstituteProgressPanel(getSite());
updateObjectPermissions(null);
}
Aggregations