Search in sources :

Example 1 with DatabaseNavigatorLabelProvider

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);
}
Also used : DatabaseNavigatorLabelProvider(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorLabelProvider) ObjectListControl(org.jkiss.dbeaver.ui.navigator.itemlist.ObjectListControl) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TreeViewer(org.eclipse.jface.viewers.TreeViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) Font(org.eclipse.swt.graphics.Font) GridLayout(org.eclipse.swt.layout.GridLayout) ListContentProvider(org.jkiss.dbeaver.ui.controls.ListContentProvider) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree) SashForm(org.eclipse.swt.custom.SashForm) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ProgressPageControl(org.jkiss.dbeaver.ui.controls.ProgressPageControl) GridData(org.eclipse.swt.layout.GridData) Collection(java.util.Collection) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject)

Example 2 with DatabaseNavigatorLabelProvider

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);
}
Also used : DatabaseNavigatorLabelProvider(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorLabelProvider) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TreeViewer(org.eclipse.jface.viewers.TreeViewer) TableItem(org.eclipse.swt.widgets.TableItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) Font(org.eclipse.swt.graphics.Font) GridLayout(org.eclipse.swt.layout.GridLayout) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Table(org.eclipse.swt.widgets.Table) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Text(org.eclipse.swt.widgets.Text) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree) SashForm(org.eclipse.swt.custom.SashForm) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ProgressPageControl(org.jkiss.dbeaver.ui.controls.ProgressPageControl) GridData(org.eclipse.swt.layout.GridData) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject)

Example 3 with DatabaseNavigatorLabelProvider

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);
}
Also used : DatabaseNavigatorLabelProvider(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorLabelProvider) ObjectListControl(org.jkiss.dbeaver.ui.navigator.itemlist.ObjectListControl) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TreeViewer(org.eclipse.jface.viewers.TreeViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) Font(org.eclipse.swt.graphics.Font) GridLayout(org.eclipse.swt.layout.GridLayout) ListContentProvider(org.jkiss.dbeaver.ui.controls.ListContentProvider) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree) SashForm(org.eclipse.swt.custom.SashForm) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ProgressPageControl(org.jkiss.dbeaver.ui.controls.ProgressPageControl) GridData(org.eclipse.swt.layout.GridData) Collection(java.util.Collection) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject)

Example 4 with DatabaseNavigatorLabelProvider

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);
}
Also used : DatabaseNavigatorLabelProvider(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorLabelProvider) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TreeViewer(org.eclipse.jface.viewers.TreeViewer) TableItem(org.eclipse.swt.widgets.TableItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) Font(org.eclipse.swt.graphics.Font) GridLayout(org.eclipse.swt.layout.GridLayout) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Table(org.eclipse.swt.widgets.Table) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Text(org.eclipse.swt.widgets.Text) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree) SashForm(org.eclipse.swt.custom.SashForm) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ProgressPageControl(org.jkiss.dbeaver.ui.controls.ProgressPageControl) GridData(org.eclipse.swt.layout.GridData) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject)

Aggregations

TreeViewer (org.eclipse.jface.viewers.TreeViewer)4 Viewer (org.eclipse.jface.viewers.Viewer)4 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)4 SashForm (org.eclipse.swt.custom.SashForm)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Font (org.eclipse.swt.graphics.Font)4 GridData (org.eclipse.swt.layout.GridData)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 RowLayout (org.eclipse.swt.layout.RowLayout)4 Composite (org.eclipse.swt.widgets.Composite)4 Text (org.eclipse.swt.widgets.Text)4 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)4 ProgressPageControl (org.jkiss.dbeaver.ui.controls.ProgressPageControl)4 DatabaseNavigatorLabelProvider (org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorLabelProvider)4 DatabaseNavigatorTree (org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree)4 Collection (java.util.Collection)2 List (java.util.List)2 MouseAdapter (org.eclipse.swt.events.MouseAdapter)2 MouseEvent (org.eclipse.swt.events.MouseEvent)2