Search in sources :

Example 1 with DriverSelectViewer

use of org.jkiss.dbeaver.ui.dialogs.driver.DriverSelectViewer in project dbeaver by serge-rider.

the class ConfigImportWizardPageCustomDriver method createControl.

@Override
public void createControl(Composite parent) {
    Composite placeholder = new Composite(parent, SWT.NONE);
    placeholder.setLayout(new GridLayout(1, true));
    DriverSelectViewer driverSelectViewer = new DriverSelectViewer(placeholder, this, DataSourceProviderRegistry.getInstance().getEnabledDataSourceProviders(), true);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 200;
    driverSelectViewer.getControl().setLayoutData(gd);
    setControl(placeholder);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) DriverSelectViewer(org.jkiss.dbeaver.ui.dialogs.driver.DriverSelectViewer) GridData(org.eclipse.swt.layout.GridData)

Example 2 with DriverSelectViewer

use of org.jkiss.dbeaver.ui.dialogs.driver.DriverSelectViewer in project dbeaver by dbeaver.

the class ConnectionPageDriver method createControl.

@Override
public void createControl(Composite parent) {
    Composite placeholder = UIUtils.createComposite(parent, 1);
    {
        driverSelectViewer = new DriverSelectViewer(placeholder, this, wizard.getAvailableProvides(), true);
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.heightHint = 200;
        driverSelectViewer.getControl().setLayoutData(gd);
    }
    setControl(placeholder);
    Composite controlsGroup = UIUtils.createComposite(placeholder, 5);
    controlsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // Navigator view preset
    {
        Composite presetComposite = new Composite(controlsGroup, SWT.NONE);
        presetComposite.setLayout(new RowLayout());
        new Label(presetComposite, SWT.NONE).setImage(DBeaverIcons.getImage(UIIcon.CONFIGURATION));
        new Label(presetComposite, SWT.NONE).setText("Connection view:  ");
        for (DataSourceNavigatorSettings.Preset p : DataSourceNavigatorSettings.PRESETS.values()) {
            if (p != DataSourceNavigatorSettings.PRESET_CUSTOM) {
                Button pButton = new Button(presetComposite, SWT.RADIO);
                pButton.setText(p.getName());
                pButton.setToolTipText(p.getDescription());
                if (p == navigatorPreset) {
                    pButton.setSelection(true);
                }
                pButton.addSelectionListener(new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        if (pButton.getSelection()) {
                            navigatorPreset = p;
                            DBeaverActivator.getInstance().getPreferences().setValue(DEFAULT_NAVIGATOR_SETTINGS_RESET, navigatorPreset.getId());
                        }
                    }
                });
            }
        }
    }
    {
        // Spacer
        new Label(controlsGroup, SWT.NONE).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    }
    {
        // Sorter
        Composite orderGroup = new Composite(controlsGroup, SWT.NONE);
        orderGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
        orderGroup.setLayout(new RowLayout());
        new Label(orderGroup, SWT.NONE).setImage(DBeaverIcons.getImage(UIIcon.SORT));
        new Label(orderGroup, SWT.NONE).setText("Sort by: ");
        for (DriverSelectViewer.OrderBy ob : DriverSelectViewer.OrderBy.values()) {
            Button obScoreButton = new Button(orderGroup, SWT.RADIO);
            obScoreButton.setText(ob.getLabel());
            obScoreButton.setToolTipText(ob.getDescription());
            obScoreButton.setData(ob);
            if (ob == driverSelectViewer.getOrderBy()) {
                obScoreButton.setSelection(true);
            }
            obScoreButton.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    driverSelectViewer.setOrderBy((DriverSelectViewer.OrderBy) obScoreButton.getData());
                }
            });
        }
    }
    {
        // Spacer
        new Label(controlsGroup, SWT.NONE).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    }
    final List<DBPProject> projects = DBWorkbench.getPlatform().getWorkspace().getProjects();
    if (projects.size() == 1) {
        if (connectionProject == null) {
            connectionProject = projects.get(0);
        }
    } else if (projects.size() > 1) {
        Composite projectGroup = UIUtils.createComposite(controlsGroup, 3);
        projectGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
        new Label(projectGroup, SWT.NONE).setImage(DBeaverIcons.getImage(DBIcon.PROJECT));
        UIUtils.createControlLabel(projectGroup, CoreMessages.dialog_connection_driver_project);
        final Combo projectCombo = new Combo(projectGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
        projectCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        for (DBPProject project : projects) {
            projectCombo.add(project.getName());
        }
        if (connectionProject == null) {
            projectCombo.select(0);
            connectionProject = projects.get(0);
        } else {
            projectCombo.setText(connectionProject.getName());
        }
        projectCombo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                connectionProject = projects.get(projectCombo.getSelectionIndex());
            }
        });
        if (projects.size() < 2) {
        // projectCombo.setEnabled(false);
        }
    } else {
        setErrorMessage("You need to create a project first");
    }
    UIUtils.setHelp(placeholder, IHelpContextIds.CTX_CON_WIZARD_DRIVER);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) Combo(org.eclipse.swt.widgets.Combo) DriverSelectViewer(org.jkiss.dbeaver.ui.dialogs.driver.DriverSelectViewer) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 3 with DriverSelectViewer

use of org.jkiss.dbeaver.ui.dialogs.driver.DriverSelectViewer in project dbeaver by dbeaver.

the class ConfigImportWizardPageNavicatDriver method createControl.

@Override
public void createControl(Composite parent) {
    Composite placeholder = new Composite(parent, SWT.NONE);
    placeholder.setLayout(new GridLayout(1, true));
    DriverSelectViewer driverSelectViewer = new DriverSelectViewer(placeholder, this, DataSourceProviderRegistry.getInstance().getEnabledDataSourceProviders(), true);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 200;
    driverSelectViewer.getControl().setLayoutData(gd);
    setControl(placeholder);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) DriverSelectViewer(org.jkiss.dbeaver.ui.dialogs.driver.DriverSelectViewer) GridData(org.eclipse.swt.layout.GridData)

Example 4 with DriverSelectViewer

use of org.jkiss.dbeaver.ui.dialogs.driver.DriverSelectViewer in project dbeaver by dbeaver.

the class ConfigImportWizardPageCustomDriver method createControl.

@Override
public void createControl(Composite parent) {
    Composite placeholder = new Composite(parent, SWT.NONE);
    placeholder.setLayout(new GridLayout(1, true));
    DriverSelectViewer driverSelectViewer = new DriverSelectViewer(placeholder, this, DataSourceProviderRegistry.getInstance().getEnabledDataSourceProviders(), true);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 200;
    driverSelectViewer.getControl().setLayoutData(gd);
    setControl(placeholder);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) DriverSelectViewer(org.jkiss.dbeaver.ui.dialogs.driver.DriverSelectViewer) GridData(org.eclipse.swt.layout.GridData)

Example 5 with DriverSelectViewer

use of org.jkiss.dbeaver.ui.dialogs.driver.DriverSelectViewer in project dbeaver by serge-rider.

the class ConnectionPageDriver method createControl.

@Override
public void createControl(Composite parent) {
    Composite placeholder = UIUtils.createComposite(parent, 1);
    {
        driverSelectViewer = new DriverSelectViewer(placeholder, this, wizard.getAvailableProvides(), true);
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.heightHint = 200;
        driverSelectViewer.getControl().setLayoutData(gd);
    }
    setControl(placeholder);
    Composite controlsGroup = UIUtils.createComposite(placeholder, 5);
    controlsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // Navigator view preset
    {
        Composite presetComposite = new Composite(controlsGroup, SWT.NONE);
        presetComposite.setLayout(new RowLayout());
        new Label(presetComposite, SWT.NONE).setImage(DBeaverIcons.getImage(UIIcon.CONFIGURATION));
        new Label(presetComposite, SWT.NONE).setText("Connection view:  ");
        for (DataSourceNavigatorSettings.Preset p : DataSourceNavigatorSettings.PRESETS.values()) {
            if (p != DataSourceNavigatorSettings.PRESET_CUSTOM) {
                Button pButton = new Button(presetComposite, SWT.RADIO);
                pButton.setText(p.getName());
                pButton.setToolTipText(p.getDescription());
                if (p == navigatorPreset) {
                    pButton.setSelection(true);
                }
                pButton.addSelectionListener(new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        if (pButton.getSelection()) {
                            navigatorPreset = p;
                            DBeaverActivator.getInstance().getPreferences().setValue(DEFAULT_NAVIGATOR_SETTINGS_RESET, navigatorPreset.getId());
                        }
                    }
                });
            }
        }
    }
    {
        // Spacer
        new Label(controlsGroup, SWT.NONE).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    }
    {
        // Sorter
        Composite orderGroup = new Composite(controlsGroup, SWT.NONE);
        orderGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
        orderGroup.setLayout(new RowLayout());
        new Label(orderGroup, SWT.NONE).setImage(DBeaverIcons.getImage(UIIcon.SORT));
        new Label(orderGroup, SWT.NONE).setText("Sort by: ");
        for (DriverSelectViewer.OrderBy ob : DriverSelectViewer.OrderBy.values()) {
            Button obScoreButton = new Button(orderGroup, SWT.RADIO);
            obScoreButton.setText(ob.getLabel());
            obScoreButton.setToolTipText(ob.getDescription());
            obScoreButton.setData(ob);
            if (ob == driverSelectViewer.getOrderBy()) {
                obScoreButton.setSelection(true);
            }
            obScoreButton.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    driverSelectViewer.setOrderBy((DriverSelectViewer.OrderBy) obScoreButton.getData());
                }
            });
        }
    }
    {
        // Spacer
        new Label(controlsGroup, SWT.NONE).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    }
    final List<DBPProject> projects = DBWorkbench.getPlatform().getWorkspace().getProjects();
    if (projects.size() == 1) {
        if (connectionProject == null) {
            connectionProject = projects.get(0);
        }
    } else if (projects.size() > 1) {
        Composite projectGroup = UIUtils.createComposite(controlsGroup, 3);
        projectGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
        new Label(projectGroup, SWT.NONE).setImage(DBeaverIcons.getImage(DBIcon.PROJECT));
        UIUtils.createControlLabel(projectGroup, CoreMessages.dialog_connection_driver_project);
        final Combo projectCombo = new Combo(projectGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
        projectCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        for (DBPProject project : projects) {
            projectCombo.add(project.getName());
        }
        if (connectionProject == null) {
            projectCombo.select(0);
            connectionProject = projects.get(0);
        } else {
            projectCombo.setText(connectionProject.getName());
        }
        projectCombo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                connectionProject = projects.get(projectCombo.getSelectionIndex());
            }
        });
        if (projects.size() < 2) {
        // projectCombo.setEnabled(false);
        }
    } else {
        setErrorMessage("You need to create a project first");
    }
    UIUtils.setHelp(placeholder, IHelpContextIds.CTX_CON_WIZARD_DRIVER);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) Combo(org.eclipse.swt.widgets.Combo) DriverSelectViewer(org.jkiss.dbeaver.ui.dialogs.driver.DriverSelectViewer) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

GridData (org.eclipse.swt.layout.GridData)6 Composite (org.eclipse.swt.widgets.Composite)6 DriverSelectViewer (org.jkiss.dbeaver.ui.dialogs.driver.DriverSelectViewer)6 GridLayout (org.eclipse.swt.layout.GridLayout)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 RowLayout (org.eclipse.swt.layout.RowLayout)2 Button (org.eclipse.swt.widgets.Button)2 Combo (org.eclipse.swt.widgets.Combo)2 Label (org.eclipse.swt.widgets.Label)2 DBPProject (org.jkiss.dbeaver.model.app.DBPProject)2