Search in sources :

Example 1 with EditObjectFilterDialog

use of org.jkiss.dbeaver.ui.navigator.dialogs.EditObjectFilterDialog in project dbeaver by dbeaver.

the class NavigatorHandlerFilterConfig method configureFilters.

public static void configureFilters(Shell shell, DBNNode node) {
    final DBNDatabaseFolder folder = (DBNDatabaseFolder) node;
    DBXTreeItem itemsMeta = folder.getItemsMeta();
    if (itemsMeta != null) {
        DBSObjectFilter objectFilter = folder.getNodeFilter(itemsMeta, true);
        if (objectFilter == null) {
            objectFilter = new DBSObjectFilter();
        }
        final DBPDataSourceRegistry dsRegistry = folder.getOwnerProject().getDataSourceRegistry();
        final boolean globalFilter = folder.getValueObject() instanceof DBPDataSource;
        String parentName = "?";
        if (folder.getValueObject() instanceof DBSObject) {
            parentName = ((DBSObject) folder.getValueObject()).getName();
        }
        EditObjectFilterDialog dialog = new EditObjectFilterDialog(shell, dsRegistry, globalFilter ? "All " + node.getNodeType() : node.getNodeType() + " of " + parentName, objectFilter, globalFilter);
        switch(dialog.open()) {
            case IDialogConstants.OK_ID:
                folder.setNodeFilter(itemsMeta, dialog.getFilter());
                NavigatorHandlerRefresh.refreshNavigator(Collections.singletonList(folder));
                break;
            case EditObjectFilterDialog.SHOW_GLOBAL_FILTERS_ID:
                objectFilter = folder.getDataSource().getContainer().getObjectFilter(folder.getChildrenClass(), null, true);
                dialog = new EditObjectFilterDialog(shell, dsRegistry, "All " + node.getNodeType(), objectFilter != null ? objectFilter : new DBSObjectFilter(), true);
                if (dialog.open() == IDialogConstants.OK_ID) {
                    // Set global filter
                    folder.getDataSource().getContainer().setObjectFilter(folder.getChildrenClass(), null, dialog.getFilter());
                    folder.getDataSource().getContainer().persistConfiguration();
                    NavigatorHandlerRefresh.refreshNavigator(Collections.singletonList(folder));
                }
                break;
        }
    }
}
Also used : DBSObjectFilter(org.jkiss.dbeaver.model.struct.DBSObjectFilter) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBXTreeItem(org.jkiss.dbeaver.model.navigator.meta.DBXTreeItem) EditObjectFilterDialog(org.jkiss.dbeaver.ui.navigator.dialogs.EditObjectFilterDialog) DBPDataSourceRegistry(org.jkiss.dbeaver.model.app.DBPDataSourceRegistry) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource) DBNDatabaseFolder(org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder)

Example 2 with EditObjectFilterDialog

use of org.jkiss.dbeaver.ui.navigator.dialogs.EditObjectFilterDialog in project dbeaver by serge-rider.

the class ConnectionPageGeneral method createControl.

@Override
public void createControl(Composite parent) {
    boldFont = UIUtils.makeBoldFont(parent.getFont());
    Composite group = UIUtils.createComposite(parent, 1);
    {
        Composite miscGroup = UIUtils.createControlGroup(group, CoreMessages.pref_page_ui_general_group_general, 2, GridData.FILL_HORIZONTAL, 0);
        // $NON-NLS-1$
        String connectionName = dataSourceDescriptor == null ? "" : dataSourceDescriptor.getName();
        connectionNameText = UIUtils.createLabelText(miscGroup, CoreMessages.dialog_connection_wizard_final_label_connection_name, CommonUtils.toString(connectionName));
        connectionNameText.addModifyListener(e -> {
            connectionNameChanged = true;
            ConnectionPageGeneral.this.getContainer().updateButtons();
        });
        {
            UIUtils.createControlLabel(miscGroup, CoreMessages.dialog_connection_wizard_final_label_connection_type);
            Composite ctGroup = UIUtils.createComposite(miscGroup, 2);
            connectionTypeCombo = new CSmartCombo<>(ctGroup, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY, new ConnectionTypeLabelProvider());
            loadConnectionTypes();
            connectionTypeCombo.select(0);
            connectionTypeCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    DBPConnectionType type = connectionTypeCombo.getItem(connectionTypeCombo.getSelectionIndex());
                    getWizard().firePropertyChangeEvent(ConnectionWizard.PROP_CONNECTION_TYPE, getActiveDataSource().getConnectionConfiguration().getConnectionType(), type);
                }
            });
            final GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            gd.widthHint = UIUtils.getFontHeight(connectionTypeCombo) * 20;
            connectionTypeCombo.setLayoutData(gd);
            UIUtils.createDialogButton(ctGroup, CoreMessages.dialog_connection_wizard_final_label_connection_types_edit, new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    DBPConnectionType curConType = connectionTypeCombo.getSelectedItem();
                    DataSourceDescriptor dataSource = getActiveDataSource();
                    UIUtils.showPreferencesFor(getControl().getShell(), dataSource.getConnectionConfiguration().getConnectionType(), PrefPageConnectionTypes.PAGE_ID);
                    loadConnectionTypes();
                    if (!connectionTypeCombo.getItems().contains(curConType)) {
                        curConType = connectionTypeCombo.getItems().get(0);
                    }
                    connectionTypeCombo.select(curConType);
                    getWizard().firePropertyChangeEvent(ConnectionWizard.PROP_CONNECTION_TYPE, curConType, curConType);
                }
            });
        }
        {
            UIUtils.createControlLabel(miscGroup, CoreMessages.dialog_connection_wizard_final_label_navigator_settings);
            Composite ctGroup = UIUtils.createComposite(miscGroup, 2);
            navigatorSettingsCombo = new Combo(ctGroup, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
            final GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            gd.widthHint = UIUtils.getFontHeight(navigatorSettingsCombo) * 20;
            navigatorSettingsCombo.setLayoutData(gd);
            for (String ncPresetName : DataSourceNavigatorSettings.PRESETS.keySet()) {
                navigatorSettingsCombo.add(ncPresetName);
            }
            navigatorSettingsCombo.select(0);
            navigatorSettingsCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (navigatorSettingsCombo.getSelectionIndex() == navigatorSettingsCombo.getItemCount() - 1) {
                    // Custom - no changes
                    } else {
                        DataSourceNavigatorSettings.Preset newSettings = DataSourceNavigatorSettings.PRESETS.get(navigatorSettingsCombo.getText());
                        if (newSettings == null) {
                            throw new IllegalStateException("Invalid preset name: " + navigatorSettingsCombo.getText());
                        }
                        ConnectionPageGeneral.this.navigatorSettings = newSettings.getSettings();
                    }
                }
            });
            UIUtils.createDialogButton(ctGroup, CoreMessages.dialog_connection_wizard_final_label_navigator_settings_customize, new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    editNavigatorSettings();
                }
            });
        }
        {
            UIUtils.createControlLabel(miscGroup, CoreMessages.dialog_connection_wizard_final_label_connection_folder);
            connectionFolderCombo = new Combo(miscGroup, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
            GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            gd.widthHint = UIUtils.getFontHeight(connectionFolderCombo) * 20;
            connectionFolderCombo.setLayoutData(gd);
            loadConnectionFolders();
            connectionFolderCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    dataSourceFolder = connectionFolders.get(connectionFolderCombo.getSelectionIndex());
                }
            });
        }
        {
            Label descLabel = UIUtils.createControlLabel(miscGroup, CoreMessages.dialog_connection_wizard_description);
            descLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
            descriptionText = new Text(miscGroup, SWT.BORDER | SWT.V_SCROLL | SWT.WRAP | SWT.MULTI);
            final GridData gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.heightHint = descriptionText.getLineHeight() * 3;
            descriptionText.setLayoutData(gd);
        }
    }
    Composite refsGroup = UIUtils.createComposite(group, 3);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    refsGroup.setLayoutData(gd);
    {
        // Security
        Group securityGroup = UIUtils.createControlGroup(refsGroup, CoreMessages.dialog_connection_wizard_final_group_security, 1, GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
        readOnlyConnection = UIUtils.createCheckbox(securityGroup, CoreMessages.dialog_connection_wizard_final_checkbox_connection_readonly, dataSourceDescriptor != null && dataSourceDescriptor.isConnectionReadOnly());
        readOnlyConnection.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        UIUtils.createDialogButton(securityGroup, "Edit permissions ...", new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                editPermissions();
            }
        });
    }
    {
        // Filters
        filtersGroup = UIUtils.createControlGroup(refsGroup, CoreMessages.dialog_connection_wizard_final_group_filters, 1, GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
        for (final FilterInfo filterInfo : filters) {
            filterInfo.link = UIUtils.createLink(filtersGroup, "<a>" + filterInfo.title + "</a>", new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    EditObjectFilterDialog dialog = new EditObjectFilterDialog(getShell(), getWizard().getDataSourceRegistry(), filterInfo.title, filterInfo.filter != null ? filterInfo.filter : new DBSObjectFilter(), true);
                    if (dialog.open() == IDialogConstants.OK_ID) {
                        filterInfo.filter = dialog.getFilter();
                        if (filterInfo.filter != null && !filterInfo.filter.isNotApplicable()) {
                            filterInfo.link.setFont(boldFont);
                        } else {
                            filterInfo.link.setFont(getFont());
                        }
                    }
                }
            });
            filterInfo.link.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        }
    }
    {
        Composite linkGroup = UIUtils.createComposite(refsGroup, 1);
        gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
        gd.horizontalSpan = 2;
        linkGroup.setLayoutData(gd);
        Link initConfigLink = new Link(linkGroup, SWT.NONE);
        initConfigLink.setText("<a>" + CoreMessages.dialog_connection_wizard_connection_init_description + "</a>");
        initConfigLink.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (getWizard().isNew()) {
                    DataSourceDescriptor dataSource = getActiveDataSource();
                    EditWizardPageDialog dialog = new EditWizardPageDialog(getWizard(), new ConnectionPageInitialization(dataSource), dataSource);
                    dialog.open();
                } else {
                    getWizard().openSettingsPage(ConnectionPageInitialization.PAGE_NAME);
                }
            }
        });
        initConfigLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        Link shellConfigLink = new Link(linkGroup, SWT.NONE);
        shellConfigLink.setText("<a>" + CoreMessages.dialog_connection_edit_wizard_shell_cmd + "</a>");
        shellConfigLink.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (getWizard().isNew()) {
                    DataSourceDescriptor dataSource = getActiveDataSource();
                    EditWizardPageDialog dialog = new EditWizardPageDialog(getWizard(), new ConnectionPageShellCommands(dataSource), dataSource);
                    dialog.open();
                } else {
                    getWizard().openSettingsPage(ConnectionPageShellCommands.PAGE_NAME);
                }
            }
        });
        shellConfigLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
    }
    setControl(group);
    UIUtils.setHelp(group, IHelpContextIds.CTX_CON_WIZARD_FINAL);
}
Also used : IColorProvider(org.eclipse.jface.viewers.IColorProvider) DBSTable(org.jkiss.dbeaver.model.struct.rdb.DBSTable) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) NotNull(org.jkiss.code.NotNull) ArrayList(java.util.ArrayList) DBPConnectionType(org.jkiss.dbeaver.model.connection.DBPConnectionType) EditObjectFilterDialog(org.jkiss.dbeaver.ui.navigator.dialogs.EditObjectFilterDialog) DBSSchema(org.jkiss.dbeaver.model.struct.rdb.DBSSchema) UIUtils(org.jkiss.dbeaver.ui.UIUtils) StringTokenizer(java.util.StringTokenizer) DataSourceProviderRegistry(org.jkiss.dbeaver.registry.DataSourceProviderRegistry) Font(org.eclipse.swt.graphics.Font) GridData(org.eclipse.swt.layout.GridData) org.jkiss.dbeaver.model(org.jkiss.dbeaver.model) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CommonUtils(org.jkiss.utils.CommonUtils) DBNBrowseSettings(org.jkiss.dbeaver.model.navigator.DBNBrowseSettings) DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) NLS(org.eclipse.osgi.util.NLS) DBSObjectFilter(org.jkiss.dbeaver.model.struct.DBSObjectFilter) DBSCatalog(org.jkiss.dbeaver.model.struct.rdb.DBSCatalog) org.eclipse.swt.widgets(org.eclipse.swt.widgets) CoreMessages(org.jkiss.dbeaver.core.CoreMessages) UINavigatorMessages(org.jkiss.dbeaver.ui.internal.UINavigatorMessages) PrefPageConnectionTypes(org.jkiss.dbeaver.ui.preferences.PrefPageConnectionTypes) List(java.util.List) DataSourceNavigatorSettings(org.jkiss.dbeaver.registry.DataSourceNavigatorSettings) Color(org.eclipse.swt.graphics.Color) CSmartCombo(org.jkiss.dbeaver.ui.controls.CSmartCombo) SWT(org.eclipse.swt.SWT) DBSEntityAttribute(org.jkiss.dbeaver.model.struct.DBSEntityAttribute) IHelpContextIds(org.jkiss.dbeaver.ui.IHelpContextIds) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DBPDataSourceRegistry(org.jkiss.dbeaver.model.app.DBPDataSourceRegistry) LabelProvider(org.eclipse.jface.viewers.LabelProvider) DBSObjectFilter(org.jkiss.dbeaver.model.struct.DBSObjectFilter) DBPConnectionType(org.jkiss.dbeaver.model.connection.DBPConnectionType) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) EditObjectFilterDialog(org.jkiss.dbeaver.ui.navigator.dialogs.EditObjectFilterDialog) CSmartCombo(org.jkiss.dbeaver.ui.controls.CSmartCombo) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor)

Example 3 with EditObjectFilterDialog

use of org.jkiss.dbeaver.ui.navigator.dialogs.EditObjectFilterDialog in project dbeaver by dbeaver.

the class ConnectionPageGeneral method createControl.

@Override
public void createControl(Composite parent) {
    boldFont = UIUtils.makeBoldFont(parent.getFont());
    Composite group = UIUtils.createComposite(parent, 1);
    {
        Composite miscGroup = UIUtils.createControlGroup(group, CoreMessages.pref_page_ui_general_group_general, 2, GridData.FILL_HORIZONTAL, 0);
        // $NON-NLS-1$
        String connectionName = dataSourceDescriptor == null ? "" : dataSourceDescriptor.getName();
        connectionNameText = UIUtils.createLabelText(miscGroup, CoreMessages.dialog_connection_wizard_final_label_connection_name, CommonUtils.toString(connectionName));
        connectionNameText.addModifyListener(e -> {
            connectionNameChanged = true;
            ConnectionPageGeneral.this.getContainer().updateButtons();
        });
        {
            UIUtils.createControlLabel(miscGroup, CoreMessages.dialog_connection_wizard_final_label_connection_type);
            Composite ctGroup = UIUtils.createComposite(miscGroup, 2);
            connectionTypeCombo = new CSmartCombo<>(ctGroup, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY, new ConnectionTypeLabelProvider());
            loadConnectionTypes();
            connectionTypeCombo.select(0);
            connectionTypeCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    DBPConnectionType type = connectionTypeCombo.getItem(connectionTypeCombo.getSelectionIndex());
                    getWizard().firePropertyChangeEvent(ConnectionWizard.PROP_CONNECTION_TYPE, getActiveDataSource().getConnectionConfiguration().getConnectionType(), type);
                }
            });
            final GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            gd.widthHint = UIUtils.getFontHeight(connectionTypeCombo) * 20;
            connectionTypeCombo.setLayoutData(gd);
            UIUtils.createDialogButton(ctGroup, CoreMessages.dialog_connection_wizard_final_label_connection_types_edit, new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    DBPConnectionType curConType = connectionTypeCombo.getSelectedItem();
                    DataSourceDescriptor dataSource = getActiveDataSource();
                    UIUtils.showPreferencesFor(getControl().getShell(), dataSource.getConnectionConfiguration().getConnectionType(), PrefPageConnectionTypes.PAGE_ID);
                    loadConnectionTypes();
                    if (!connectionTypeCombo.getItems().contains(curConType)) {
                        curConType = connectionTypeCombo.getItems().get(0);
                    }
                    connectionTypeCombo.select(curConType);
                    getWizard().firePropertyChangeEvent(ConnectionWizard.PROP_CONNECTION_TYPE, curConType, curConType);
                }
            });
        }
        {
            UIUtils.createControlLabel(miscGroup, CoreMessages.dialog_connection_wizard_final_label_navigator_settings);
            Composite ctGroup = UIUtils.createComposite(miscGroup, 2);
            navigatorSettingsCombo = new Combo(ctGroup, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
            final GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            gd.widthHint = UIUtils.getFontHeight(navigatorSettingsCombo) * 20;
            navigatorSettingsCombo.setLayoutData(gd);
            for (String ncPresetName : DataSourceNavigatorSettings.PRESETS.keySet()) {
                navigatorSettingsCombo.add(ncPresetName);
            }
            navigatorSettingsCombo.select(0);
            navigatorSettingsCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (navigatorSettingsCombo.getSelectionIndex() == navigatorSettingsCombo.getItemCount() - 1) {
                    // Custom - no changes
                    } else {
                        DataSourceNavigatorSettings.Preset newSettings = DataSourceNavigatorSettings.PRESETS.get(navigatorSettingsCombo.getText());
                        if (newSettings == null) {
                            throw new IllegalStateException("Invalid preset name: " + navigatorSettingsCombo.getText());
                        }
                        ConnectionPageGeneral.this.navigatorSettings = newSettings.getSettings();
                    }
                }
            });
            UIUtils.createDialogButton(ctGroup, CoreMessages.dialog_connection_wizard_final_label_navigator_settings_customize, new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    editNavigatorSettings();
                }
            });
        }
        {
            UIUtils.createControlLabel(miscGroup, CoreMessages.dialog_connection_wizard_final_label_connection_folder);
            connectionFolderCombo = new Combo(miscGroup, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
            GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            gd.widthHint = UIUtils.getFontHeight(connectionFolderCombo) * 20;
            connectionFolderCombo.setLayoutData(gd);
            loadConnectionFolders();
            connectionFolderCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    dataSourceFolder = connectionFolders.get(connectionFolderCombo.getSelectionIndex());
                }
            });
        }
        {
            Label descLabel = UIUtils.createControlLabel(miscGroup, CoreMessages.dialog_connection_wizard_description);
            descLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
            descriptionText = new Text(miscGroup, SWT.BORDER | SWT.V_SCROLL | SWT.WRAP | SWT.MULTI);
            final GridData gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.heightHint = descriptionText.getLineHeight() * 3;
            descriptionText.setLayoutData(gd);
        }
    }
    Composite refsGroup = UIUtils.createComposite(group, 3);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    refsGroup.setLayoutData(gd);
    {
        // Security
        Group securityGroup = UIUtils.createControlGroup(refsGroup, CoreMessages.dialog_connection_wizard_final_group_security, 1, GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
        readOnlyConnection = UIUtils.createCheckbox(securityGroup, CoreMessages.dialog_connection_wizard_final_checkbox_connection_readonly, dataSourceDescriptor != null && dataSourceDescriptor.isConnectionReadOnly());
        readOnlyConnection.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        UIUtils.createDialogButton(securityGroup, "Edit permissions ...", new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                editPermissions();
            }
        });
    }
    {
        // Filters
        filtersGroup = UIUtils.createControlGroup(refsGroup, CoreMessages.dialog_connection_wizard_final_group_filters, 1, GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
        for (final FilterInfo filterInfo : filters) {
            filterInfo.link = UIUtils.createLink(filtersGroup, "<a>" + filterInfo.title + "</a>", new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    EditObjectFilterDialog dialog = new EditObjectFilterDialog(getShell(), getWizard().getDataSourceRegistry(), filterInfo.title, filterInfo.filter != null ? filterInfo.filter : new DBSObjectFilter(), true);
                    if (dialog.open() == IDialogConstants.OK_ID) {
                        filterInfo.filter = dialog.getFilter();
                        if (filterInfo.filter != null && !filterInfo.filter.isNotApplicable()) {
                            filterInfo.link.setFont(boldFont);
                        } else {
                            filterInfo.link.setFont(getFont());
                        }
                    }
                }
            });
            filterInfo.link.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        }
    }
    {
        Composite linkGroup = UIUtils.createComposite(refsGroup, 1);
        gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
        gd.horizontalSpan = 2;
        linkGroup.setLayoutData(gd);
        Link initConfigLink = new Link(linkGroup, SWT.NONE);
        initConfigLink.setText("<a>" + CoreMessages.dialog_connection_wizard_connection_init_description + "</a>");
        initConfigLink.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (getWizard().isNew()) {
                    DataSourceDescriptor dataSource = getActiveDataSource();
                    EditWizardPageDialog dialog = new EditWizardPageDialog(getWizard(), new ConnectionPageInitialization(dataSource), dataSource);
                    dialog.open();
                } else {
                    getWizard().openSettingsPage(ConnectionPageInitialization.PAGE_NAME);
                }
            }
        });
        initConfigLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        Link shellConfigLink = new Link(linkGroup, SWT.NONE);
        shellConfigLink.setText("<a>" + CoreMessages.dialog_connection_edit_wizard_shell_cmd + "</a>");
        shellConfigLink.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (getWizard().isNew()) {
                    DataSourceDescriptor dataSource = getActiveDataSource();
                    EditWizardPageDialog dialog = new EditWizardPageDialog(getWizard(), new ConnectionPageShellCommands(dataSource), dataSource);
                    dialog.open();
                } else {
                    getWizard().openSettingsPage(ConnectionPageShellCommands.PAGE_NAME);
                }
            }
        });
        shellConfigLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
    }
    setControl(group);
    UIUtils.setHelp(group, IHelpContextIds.CTX_CON_WIZARD_FINAL);
}
Also used : IColorProvider(org.eclipse.jface.viewers.IColorProvider) DBSTable(org.jkiss.dbeaver.model.struct.rdb.DBSTable) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) NotNull(org.jkiss.code.NotNull) ArrayList(java.util.ArrayList) DBPConnectionType(org.jkiss.dbeaver.model.connection.DBPConnectionType) EditObjectFilterDialog(org.jkiss.dbeaver.ui.navigator.dialogs.EditObjectFilterDialog) DBSSchema(org.jkiss.dbeaver.model.struct.rdb.DBSSchema) UIUtils(org.jkiss.dbeaver.ui.UIUtils) StringTokenizer(java.util.StringTokenizer) DataSourceProviderRegistry(org.jkiss.dbeaver.registry.DataSourceProviderRegistry) Font(org.eclipse.swt.graphics.Font) GridData(org.eclipse.swt.layout.GridData) org.jkiss.dbeaver.model(org.jkiss.dbeaver.model) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CommonUtils(org.jkiss.utils.CommonUtils) DBNBrowseSettings(org.jkiss.dbeaver.model.navigator.DBNBrowseSettings) DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) NLS(org.eclipse.osgi.util.NLS) DBSObjectFilter(org.jkiss.dbeaver.model.struct.DBSObjectFilter) DBSCatalog(org.jkiss.dbeaver.model.struct.rdb.DBSCatalog) org.eclipse.swt.widgets(org.eclipse.swt.widgets) CoreMessages(org.jkiss.dbeaver.core.CoreMessages) UINavigatorMessages(org.jkiss.dbeaver.ui.internal.UINavigatorMessages) PrefPageConnectionTypes(org.jkiss.dbeaver.ui.preferences.PrefPageConnectionTypes) List(java.util.List) DataSourceNavigatorSettings(org.jkiss.dbeaver.registry.DataSourceNavigatorSettings) Color(org.eclipse.swt.graphics.Color) CSmartCombo(org.jkiss.dbeaver.ui.controls.CSmartCombo) SWT(org.eclipse.swt.SWT) DBSEntityAttribute(org.jkiss.dbeaver.model.struct.DBSEntityAttribute) IHelpContextIds(org.jkiss.dbeaver.ui.IHelpContextIds) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DBPDataSourceRegistry(org.jkiss.dbeaver.model.app.DBPDataSourceRegistry) LabelProvider(org.eclipse.jface.viewers.LabelProvider) DBSObjectFilter(org.jkiss.dbeaver.model.struct.DBSObjectFilter) DBPConnectionType(org.jkiss.dbeaver.model.connection.DBPConnectionType) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) EditObjectFilterDialog(org.jkiss.dbeaver.ui.navigator.dialogs.EditObjectFilterDialog) CSmartCombo(org.jkiss.dbeaver.ui.controls.CSmartCombo) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor)

Example 4 with EditObjectFilterDialog

use of org.jkiss.dbeaver.ui.navigator.dialogs.EditObjectFilterDialog in project dbeaver by serge-rider.

the class NavigatorHandlerFilterConfig method configureFilters.

public static void configureFilters(Shell shell, DBNNode node) {
    final DBNDatabaseFolder folder = (DBNDatabaseFolder) node;
    DBXTreeItem itemsMeta = folder.getItemsMeta();
    if (itemsMeta != null) {
        DBSObjectFilter objectFilter = folder.getNodeFilter(itemsMeta, true);
        if (objectFilter == null) {
            objectFilter = new DBSObjectFilter();
        }
        final DBPDataSourceRegistry dsRegistry = folder.getOwnerProject().getDataSourceRegistry();
        final boolean globalFilter = folder.getValueObject() instanceof DBPDataSource;
        String parentName = "?";
        if (folder.getValueObject() instanceof DBSObject) {
            parentName = ((DBSObject) folder.getValueObject()).getName();
        }
        EditObjectFilterDialog dialog = new EditObjectFilterDialog(shell, dsRegistry, globalFilter ? "All " + node.getNodeType() : node.getNodeType() + " of " + parentName, objectFilter, globalFilter);
        switch(dialog.open()) {
            case IDialogConstants.OK_ID:
                folder.setNodeFilter(itemsMeta, dialog.getFilter());
                NavigatorHandlerRefresh.refreshNavigator(Collections.singletonList(folder));
                break;
            case EditObjectFilterDialog.SHOW_GLOBAL_FILTERS_ID:
                objectFilter = folder.getDataSource().getContainer().getObjectFilter(folder.getChildrenClass(), null, true);
                dialog = new EditObjectFilterDialog(shell, dsRegistry, "All " + node.getNodeType(), objectFilter != null ? objectFilter : new DBSObjectFilter(), true);
                if (dialog.open() == IDialogConstants.OK_ID) {
                    // Set global filter
                    folder.getDataSource().getContainer().setObjectFilter(folder.getChildrenClass(), null, dialog.getFilter());
                    folder.getDataSource().getContainer().persistConfiguration();
                    NavigatorHandlerRefresh.refreshNavigator(Collections.singletonList(folder));
                }
                break;
        }
    }
}
Also used : DBSObjectFilter(org.jkiss.dbeaver.model.struct.DBSObjectFilter) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBXTreeItem(org.jkiss.dbeaver.model.navigator.meta.DBXTreeItem) EditObjectFilterDialog(org.jkiss.dbeaver.ui.navigator.dialogs.EditObjectFilterDialog) DBPDataSourceRegistry(org.jkiss.dbeaver.model.app.DBPDataSourceRegistry) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource) DBNDatabaseFolder(org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder)

Aggregations

DBPDataSourceRegistry (org.jkiss.dbeaver.model.app.DBPDataSourceRegistry)4 DBSObjectFilter (org.jkiss.dbeaver.model.struct.DBSObjectFilter)4 EditObjectFilterDialog (org.jkiss.dbeaver.ui.navigator.dialogs.EditObjectFilterDialog)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 StringTokenizer (java.util.StringTokenizer)2 IDialogConstants (org.eclipse.jface.dialogs.IDialogConstants)2 IColorProvider (org.eclipse.jface.viewers.IColorProvider)2 LabelProvider (org.eclipse.jface.viewers.LabelProvider)2 NLS (org.eclipse.osgi.util.NLS)2 SWT (org.eclipse.swt.SWT)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Color (org.eclipse.swt.graphics.Color)2 Font (org.eclipse.swt.graphics.Font)2 GridData (org.eclipse.swt.layout.GridData)2 org.eclipse.swt.widgets (org.eclipse.swt.widgets)2 NotNull (org.jkiss.code.NotNull)2 CoreMessages (org.jkiss.dbeaver.core.CoreMessages)2 org.jkiss.dbeaver.model (org.jkiss.dbeaver.model)2