Search in sources :

Example 51 with GridData

use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.

the class HexStatusLine method initialize.

private void initialize(boolean withSeparator) {
    GridLayout statusLayout = new GridLayout();
    statusLayout.numColumns = withSeparator ? 6 : 5;
    statusLayout.marginHeight = 0;
    setLayout(statusLayout);
    if (withSeparator) {
        GridData separator1GridData = new GridData();
        separator1GridData.grabExcessVerticalSpace = true;
        separator1GridData.verticalAlignment = SWT.FILL;
        Label separator1 = new Label(this, SWT.SEPARATOR);
        separator1.setLayoutData(separator1GridData);
    }
    GC gc = new GC(this);
    FontMetrics fontMetrics = gc.getFontMetrics();
    position = new Label(this, SWT.SHADOW_NONE);
    GridData gridData1 = new GridData(/*SWT.DEFAULT*/
    (11 + 10 + 12 + 3 + 10 + 12) * fontMetrics.getAverageCharWidth(), SWT.DEFAULT);
    position.setLayoutData(gridData1);
    GridData separator23GridData = new GridData();
    separator23GridData.grabExcessVerticalSpace = true;
    separator23GridData.verticalAlignment = SWT.FILL;
    Label separator2 = new Label(this, SWT.SEPARATOR);
    separator2.setLayoutData(separator23GridData);
    value = new Label(this, SWT.SHADOW_NONE);
    GridData gridData2 = new GridData(/*SWT.DEFAULT*/
    (7 + 3 + 9 + 2 + 9 + 8 + 6) * fontMetrics.getAverageCharWidth(), SWT.DEFAULT);
    value.setLayoutData(gridData2);
    // From Eclipse 3.1's GridData javadoc:
    // NOTE: Do not reuse GridData objects. Every control in a Composite that is managed by a
    // GridLayout must have a unique GridData
    GridData separator3GridData = new GridData();
    separator3GridData.grabExcessVerticalSpace = true;
    separator3GridData.verticalAlignment = SWT.FILL;
    Label separator3 = new Label(this, SWT.SEPARATOR);
    separator3.setLayoutData(separator3GridData);
    insertMode = new Label(this, SWT.SHADOW_NONE);
    GridData gridData3 = new GridData(/*SWT.DEFAULT*/
    (TEXT_OVERWRITE.length() + 2) * fontMetrics.getAverageCharWidth(), SWT.DEFAULT);
    insertMode.setLayoutData(gridData3);
    gc.dispose();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) FontMetrics(org.eclipse.swt.graphics.FontMetrics) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) GC(org.eclipse.swt.graphics.GC)

Example 52 with GridData

use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.

the class DriverEditDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    if (newDriver) {
        getShell().setText(CoreMessages.dialog_edit_driver_title_create_driver);
    } else {
        //$NON-NLS-2$
        getShell().setText(CoreMessages.dialog_edit_driver_title_edit_driver + driver.getName() + "'");
        getShell().setImage(DBeaverIcons.getImage(driver.getPlainIcon()));
    }
    boolean isReadOnly = !provider.isDriversManagable();
    int advStyle = isReadOnly ? SWT.READ_ONLY : SWT.NONE;
    final Composite group = (Composite) super.createDialogArea(parent);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = 500;
    group.setLayoutData(gd);
    {
        Group propsGroup = UIUtils.createControlGroup(group, "Settings", 4, -1, -1);
        propsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        gd = new GridData(GridData.FILL_HORIZONTAL);
        driverNameText = UIUtils.createLabelText(propsGroup, CoreMessages.dialog_edit_driver_label_driver_name + "*", driver.getName(), SWT.BORDER | advStyle, gd);
        driverNameText.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                onChangeProperty();
            }
        });
        UIUtils.createControlLabel(propsGroup, "Driver Type");
        final CSmartCombo<DataSourceProviderDescriptor> providerCombo = new CSmartCombo<>(propsGroup, SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN, new LabelProvider() {

            @Override
            public Image getImage(Object element) {
                return DBeaverIcons.getImage(((DataSourceProviderDescriptor) element).getIcon());
            }

            @Override
            public String getText(Object element) {
                return ((DataSourceProviderDescriptor) element).getName();
            }
        });
        providerCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        if (newDriver) {
            for (DataSourceProviderDescriptor provider : DataSourceProviderRegistry.getInstance().getDataSourceProviders()) {
                if (provider.isDriversManagable()) {
                    providerCombo.addItem(provider);
                }
            }
            providerCombo.select(provider);
            providerCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    provider = providerCombo.getItem(providerCombo.getSelectionIndex());
                    driver = provider.createDriver();
                }
            });
        } else {
            providerCombo.addItem(provider);
            providerCombo.select(provider);
        }
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 3;
        driverClassText = UIUtils.createLabelText(propsGroup, CoreMessages.dialog_edit_driver_label_class_name + "*", CommonUtils.notEmpty(driver.getDriverClassName()), SWT.BORDER | advStyle, gd);
        driverClassText.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                onChangeProperty();
            }
        });
        driverURLText = UIUtils.createLabelText(propsGroup, CoreMessages.dialog_edit_driver_label_sample_url, CommonUtils.notEmpty(driver.getSampleURL()), SWT.BORDER | advStyle, gd);
        driverURLText.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                onChangeProperty();
            }
        });
        gd = new GridData(GridData.FILL_HORIZONTAL);
        driverPortText = UIUtils.createLabelText(propsGroup, CoreMessages.dialog_edit_driver_label_default_port, driver.getDefaultPort() == null ? "" : driver.getDefaultPort(), SWT.BORDER | advStyle, gd);
        driverPortText.setLayoutData(new GridData(SWT.NONE));
        driverPortText.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                onChangeProperty();
            }
        });
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        embeddedDriverCheck = UIUtils.createCheckbox(propsGroup, "Embedded", driver.isEmbedded());
        embeddedDriverCheck.setLayoutData(gd);
    }
    {
        Group infoGroup = UIUtils.createControlGroup(group, "Description", 2, -1, -1);
        infoGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        driverCategoryCombo = UIUtils.createLabelCombo(infoGroup, CoreMessages.dialog_edit_driver_label_category, SWT.BORDER | SWT.DROP_DOWN | advStyle);
        driverCategoryCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        if (isReadOnly) {
            driverCategoryCombo.setEnabled(false);
        }
        Set<String> categories = new TreeSet<>();
        for (DataSourceProviderDescriptor provider : DataSourceProviderRegistry.getInstance().getDataSourceProviders()) {
            for (DriverDescriptor drv : provider.getEnabledDrivers()) {
                if (!CommonUtils.isEmpty(drv.getCategory())) {
                    categories.add(drv.getCategory());
                }
            }
        }
        for (String category : categories) {
            driverCategoryCombo.add(category);
        }
        if (!CommonUtils.isEmpty(driver.getCategory())) {
            driverCategoryCombo.setText(driver.getCategory());
        } else if (!CommonUtils.isEmpty(defaultCategory)) {
            driverCategoryCombo.setText(defaultCategory);
        }
        driverDescText = UIUtils.createLabelText(infoGroup, CoreMessages.dialog_edit_driver_label_description, CommonUtils.notEmpty(driver.getDescription()), SWT.BORDER | advStyle);
        if (!CommonUtils.isEmpty(driver.getWebURL())) {
            UIUtils.createControlLabel(infoGroup, CoreMessages.dialog_edit_driver_label_website);
            Link urlLabel = UIUtils.createLink(infoGroup, "<a>" + driver.getWebURL() + "</a>", new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    UIUtils.launchProgram(driver.getWebURL());
                }
            });
            urlLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        }
    }
    {
        TabFolder tabFolder = new TabFolder(group, SWT.NONE);
        tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
        if (provider.isDriversManagable()) {
            createLibrariesTab(tabFolder);
        }
        createConnectionPropertiesTab(tabFolder);
        createParametersTab(tabFolder);
        // Client homes
        if (driver.getClientManager() != null) {
            createClientHomesTab(tabFolder);
        }
        final String license = driver.getLicense();
        if (license != null) {
            createLicenseTab(tabFolder, license);
        }
        tabFolder.setSelection(0);
    }
    loadSettings(false);
    if (showAddFiles) {
        getShell().getDisplay().asyncExec(new Runnable() {

            @Override
            public void run() {
                addLibraryFiles();
            }
        });
    }
    return group;
}
Also used : DriverDescriptor(org.jkiss.dbeaver.registry.driver.DriverDescriptor) CSmartCombo(org.jkiss.dbeaver.ui.controls.CSmartCombo) GridData(org.eclipse.swt.layout.GridData) DataSourceProviderDescriptor(org.jkiss.dbeaver.registry.DataSourceProviderDescriptor)

Example 53 with GridData

use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.

the class DriverLibraryDetailsDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    //$NON-NLS-2$
    getShell().setText("Driver '" + driver.getName() + "' library '" + library.getDisplayName() + "'");
    getShell().setImage(DBeaverIcons.getImage(library.getIcon()));
    Composite group = (Composite) super.createDialogArea(parent);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = 500;
    group.setLayoutData(gd);
    Group propsGroup = UIUtils.createControlGroup(group, "Information", 2, -1, -1);
    propsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    UIUtils.createLabelText(propsGroup, "Driver", driver.getName(), SWT.BORDER | SWT.READ_ONLY);
    UIUtils.createLabelText(propsGroup, "Library", library.getDisplayName(), SWT.BORDER | SWT.READ_ONLY);
    UIUtils.createLabelText(propsGroup, "Path", library.getPath(), SWT.BORDER | SWT.READ_ONLY);
    UIUtils.createLabelText(propsGroup, "Version", library.getVersion(), SWT.BORDER | SWT.READ_ONLY);
    Text fileText = UIUtils.createLabelText(propsGroup, "File", "", SWT.BORDER | SWT.READ_ONLY);
    TabFolder tabs = new TabFolder(group, SWT.HORIZONTAL | SWT.FLAT);
    tabs.setLayoutData(new GridData(GridData.FILL_BOTH));
    createDependenciesTab(tabs);
    createLicenseTab(tabs);
    createDetailsTab(tabs);
    final File localFile = library.getLocalFile();
    if (localFile != null) {
        fileText.setText(localFile.getAbsolutePath());
    }
    return group;
}
Also used : GridData(org.eclipse.swt.layout.GridData) File(java.io.File)

Example 54 with GridData

use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.

the class DriverLibraryDetailsDialog method createLicenseTab.

/*
        private void createParametersTab(TabFolder group)
        {
            Composite paramsGroup = new Composite(group, SWT.NONE);
            paramsGroup.setLayout(new GridLayout(1, false));

            parametersEditor = new PropertyTreeViewer(paramsGroup, SWT.BORDER);
            driverPropertySource = new PropertySourceCustom(
                driver.getProviderDescriptor().getDriverProperties(),
                driver.getDriverParameters());
            driverPropertySource.setDefaultValues(driver.getDefaultDriverParameters());
            parametersEditor.loadProperties(driverPropertySource);

            TabItem paramsTab = new TabItem(group, SWT.NONE);
            paramsTab.setText(CoreMessages.dialog_edit_driver_tab_name_advanced_parameters);
            paramsTab.setToolTipText(CoreMessages.dialog_edit_driver_tab_tooltip_advanced_parameters);
            paramsTab.setControl(paramsGroup);
        }

        private void createConnectionPropertiesTab(TabFolder group)
        {
            Composite paramsGroup = new Composite(group, SWT.NONE);
            paramsGroup.setLayout(new GridLayout(1, false));

            connectionPropertiesEditor = new ConnectionPropertiesControl(paramsGroup, SWT.BORDER);
            connectionPropertySource = connectionPropertiesEditor.makeProperties(driver, driver.getConnectionProperties());
            connectionPropertiesEditor.loadProperties(connectionPropertySource);


            TabItem paramsTab = new TabItem(group, SWT.NONE);
            paramsTab.setText(CoreMessages.dialog_edit_driver_tab_name_connection_properties);
            paramsTab.setToolTipText(CoreMessages.dialog_edit_driver_tab_tooltip_connection_properties);
            paramsTab.setControl(paramsGroup);
        }

        private void createClientHomesTab(TabFolder group)
        {
            clientHomesPanel = new ClientHomesPanel(group, SWT.NONE);
            clientHomesPanel.loadHomes(driver);
            clientHomesPanel.setLayoutData(new GridData(GridData.FILL_BOTH));

            TabItem paramsTab = new TabItem(group, SWT.NONE);
            paramsTab.setText(CoreMessages.dialog_edit_driver_tab_name_client_homes);
            paramsTab.setToolTipText(CoreMessages.dialog_edit_driver_tab_name_client_homes);
            paramsTab.setControl(clientHomesPanel);
        }
    */
private void createLicenseTab(TabFolder group) {
    Composite paramsGroup = new Composite(group, SWT.NONE);
    paramsGroup.setLayout(new GridLayout(1, false));
    Text licenseText = new Text(paramsGroup, SWT.BORDER | SWT.WRAP | SWT.MULTI | SWT.V_SCROLL);
    licenseText.setText("License");
    licenseText.setEditable(false);
    licenseText.setMessage(CoreMessages.dialog_edit_driver_text_driver_license);
    final GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 200;
    //gd.grabExcessVerticalSpace = true;
    licenseText.setLayoutData(gd);
    TabItem paramsTab = new TabItem(group, SWT.NONE);
    paramsTab.setText(CoreMessages.dialog_edit_driver_tab_name_license);
    paramsTab.setToolTipText(CoreMessages.dialog_edit_driver_tab_tooltip_license);
    paramsTab.setControl(paramsGroup);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData)

Example 55 with GridData

use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.

the class DriverLibraryDetailsDialog method createDetailsTab.

private void createDetailsTab(TabFolder tabs) {
    Composite detailsGroup = new Composite(tabs, SWT.NONE);
    detailsGroup.setLayout(new GridLayout(1, false));
    UIUtils.createControlLabel(detailsGroup, "Description");
    Text descriptionText = new Text(detailsGroup, SWT.READ_ONLY | SWT.BORDER);
    descriptionText.setText(CommonUtils.notEmpty(library.getDescription()));
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.heightHint = 40;
    descriptionText.setLayoutData(gd);
    TabItem detailsTab = new TabItem(tabs, SWT.NONE);
    detailsTab.setText("Details");
    detailsTab.setToolTipText("Additional library information");
    detailsTab.setControl(detailsGroup);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData)

Aggregations

GridData (org.eclipse.swt.layout.GridData)2385 GridLayout (org.eclipse.swt.layout.GridLayout)1659 Composite (org.eclipse.swt.widgets.Composite)1448 Label (org.eclipse.swt.widgets.Label)982 Button (org.eclipse.swt.widgets.Button)732 SelectionEvent (org.eclipse.swt.events.SelectionEvent)719 Text (org.eclipse.swt.widgets.Text)578 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)577 Group (org.eclipse.swt.widgets.Group)509 Combo (org.eclipse.swt.widgets.Combo)234 ModifyListener (org.eclipse.swt.events.ModifyListener)225 ModifyEvent (org.eclipse.swt.events.ModifyEvent)214 SelectionListener (org.eclipse.swt.events.SelectionListener)213 Table (org.eclipse.swt.widgets.Table)196 Point (org.eclipse.swt.graphics.Point)167 TableViewer (org.eclipse.jface.viewers.TableViewer)162 FillLayout (org.eclipse.swt.layout.FillLayout)134 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)118 Control (org.eclipse.swt.widgets.Control)117 Image (org.eclipse.swt.graphics.Image)114