Search in sources :

Example 41 with GridData

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

the class VersionUpdateDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    getShell().setText(CoreMessages.dialog_version_update_title);
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setLayout(new GridLayout(1, false));
    Composite propGroup = UIUtils.createControlGroup(composite, CoreMessages.dialog_version_update_title, 2, GridData.FILL_BOTH, 0);
    boldFont = UIUtils.makeBoldFont(composite.getFont());
    final Label titleLabel = new Label(propGroup, SWT.NONE);
    titleLabel.setText(newVersion == null ? CoreMessages.dialog_version_update_no_new_version : CoreMessages.dialog_version_update_available_new_version);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    titleLabel.setLayoutData(gd);
    titleLabel.setFont(boldFont);
    final String versionStr = GeneralUtils.getProductVersion().toString();
    UIUtils.createControlLabel(propGroup, CoreMessages.dialog_version_update_current_version);
    new Label(propGroup, SWT.NONE).setText(versionStr);
    UIUtils.createControlLabel(propGroup, CoreMessages.dialog_version_update_new_version);
    new Label(propGroup, SWT.NONE).setText(//$NON-NLS-2$ //$NON-NLS-3$
    newVersion == null ? versionStr : newVersion.getProgramVersion().toString() + "    (" + newVersion.getUpdateTime() + ")");
    if (newVersion != null) {
        final Label notesLabel = UIUtils.createControlLabel(propGroup, CoreMessages.dialog_version_update_notes);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        notesLabel.setLayoutData(gd);
        final Label notesText = new Label(propGroup, SWT.NONE);
        notesText.setText(newVersion.getReleaseNotes());
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        notesText.setLayoutData(gd);
        final Label hintLabel = new Label(propGroup, SWT.NONE);
        hintLabel.setText(CoreMessages.dialog_version_update_press_more_info_);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        hintLabel.setLayoutData(gd);
        hintLabel.setFont(boldFont);
    }
    return parent;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label)

Example 42 with GridData

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

the class ValueViewDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    /*
        SashForm sash = new SashForm(parent, SWT.VERTICAL);
        sash.setLayoutData(new GridData(GridData.FILL_BOTH));
        Composite dialogGroup = (Composite)super.createDialogArea(sash);
        dialogGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        new ColumnInfoPanel(dialogGroup, SWT.BORDER, getValueController());
        Composite editorGroup = (Composite) super.createDialogArea(sash);
        editorGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
        //editorGroup.setLayout(new GridLayout(1, false));
        return editorGroup;

*/
    Composite dialogGroup = (Composite) super.createDialogArea(parent);
    if (valueController instanceof IAttributeController) {
        final Link columnHideLink = new Link(dialogGroup, SWT.NONE);
        columnHideLink.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                columnInfoVisible = !columnInfoVisible;
                dialogSettings.put(getInfoVisiblePrefId(), columnInfoVisible);
                initColumnInfoVisibility(columnHideLink);
                getShell().layout();
                int width = getShell().getSize().x;
                getShell().setSize(width, getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
            }
        });
        columnPanel = new ColumnInfoPanel(dialogGroup, SWT.BORDER, valueController);
        columnPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
        initColumnInfoVisibility(columnHideLink);
    }
    return dialogGroup;
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) ColumnInfoPanel(org.jkiss.dbeaver.ui.dialogs.ColumnInfoPanel)

Example 43 with GridData

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

the class DriverDownloadAutoPage method createControl.

@Override
public void createControl(Composite parent) {
    final DriverDownloadWizard wizard = getWizard();
    final DriverDescriptor driver = wizard.getDriver();
    setMessage("Download " + driver.getFullName() + " driver files");
    initializeDialogUnits(parent);
    Composite composite = UIUtils.createPlaceholder(parent, 1);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    if (!wizard.isForceDownload()) {
        Composite infoGroup = UIUtils.createPlaceholder(composite, 2, 5);
        infoGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        Label infoText = new Label(infoGroup, SWT.NONE);
        infoText.setText(driver.getFullName() + " driver files are missing.\nDBeaver can download these files automatically.\n\n");
        infoText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        final Button forceCheckbox = UIUtils.createCheckbox(infoGroup, "Force download / overwrite", wizard.isForceDownload());
        forceCheckbox.setToolTipText("Force files download. Will download files even if they are already on the disk");
        forceCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_BEGINNING));
        forceCheckbox.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                wizard.setForceDownload(forceCheckbox.getSelection());
            }
        });
    }
    {
        Group filesGroup = UIUtils.createControlGroup(composite, "Files required by driver", 1, -1, -1);
        filesGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
        depsTree = new DriverDependenciesTree(filesGroup, new RunnableContextDelegate(getContainer()), getWizard().getDependencies(), driver, driver.getDriverLibraries(), true) {

            protected void setLibraryVersion(final DBPDriverLibrary library, final String version) {
                String curVersion = library.getVersion();
                if (CommonUtils.equalObjects(curVersion, version)) {
                    return;
                }
                library.setPreferredVersion(version);
                resolveLibraries();
            }
        };
        new Label(filesGroup, SWT.NONE).setText("You can change driver version by clicking on version column.\nThen you can choose one of the available versions.");
    }
    if (!wizard.isForceDownload()) {
        Label infoText = new Label(composite, SWT.NONE);
        infoText.setText("\nOr you can obtain driver files by yourself and add them in driver editor.");
        infoText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    }
    createLinksPanel(composite);
    setControl(composite);
}
Also used : DriverDescriptor(org.jkiss.dbeaver.registry.driver.DriverDescriptor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) RunnableContextDelegate(org.jkiss.dbeaver.runtime.RunnableContextDelegate) DBPDriverLibrary(org.jkiss.dbeaver.model.connection.DBPDriverLibrary) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 44 with GridData

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

the class DriverDownloadManualPage method createControl.

@Override
public void createControl(Composite parent) {
    final DriverDescriptor driver = getWizard().getDriver();
    setMessage("Download & configure " + driver.getFullName() + " driver files");
    Composite composite = UIUtils.createPlaceholder(parent, 1);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    Link infoText = new Link(composite, SWT.NONE);
    infoText.setText(driver.getFullName() + " driver files missing.\n\n" + "According to vendor policy this driver isn't publicly available\nand you have to download it manually from vendor's web site.\n\n" + "After successful driver download you will need to <a>add JAR files</a> in DBeaver libraries list.");
    infoText.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            getWizard().getContainer().buttonPressed(DriverDownloadDialog.EDIT_DRIVER_BUTTON_ID);
        }
    });
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    infoText.setLayoutData(gd);
    Group filesGroup = UIUtils.createControlGroup(composite, "Driver files", 1, -1, -1);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.verticalIndent = 10;
    filesGroup.setLayoutData(gd);
    final Combo sourceCombo = new Combo(filesGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    for (DriverFileSource source : driver.getDriverFileSources()) {
        sourceCombo.add(source.getName());
    }
    final Link driverLink = new Link(filesGroup, SWT.NONE);
    driverLink.setText("<a>" + driver.getDriverFileSources().get(0).getUrl() + "</a>");
    driverLink.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    driverLink.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            WebUtils.openWebBrowser(driver.getDriverFileSources().get(sourceCombo.getSelectionIndex()).getUrl());
        }
    });
    filesTable = new Table(filesGroup, SWT.BORDER | SWT.FULL_SELECTION);
    filesTable.setHeaderVisible(true);
    filesTable.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    UIUtils.createTableColumn(filesTable, SWT.LEFT, "File");
    UIUtils.createTableColumn(filesTable, SWT.LEFT, "Required");
    UIUtils.createTableColumn(filesTable, SWT.LEFT, "Description");
    sourceCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            selectFileSource(driver.getDriverFileSources().get(sourceCombo.getSelectionIndex()));
            driverLink.setText("<a>" + driver.getDriverFileSources().get(sourceCombo.getSelectionIndex()).getUrl() + "</a>");
        }
    });
    sourceCombo.select(0);
    selectFileSource(driver.getDriverFileSources().get(0));
    UIUtils.packColumns(filesTable, true);
    createLinksPanel(composite);
    composite.setTabList(ArrayUtils.remove(Control.class, composite.getTabList(), infoText));
    setControl(composite);
}
Also used : DriverFileSource(org.jkiss.dbeaver.registry.driver.DriverFileSource) DriverDescriptor(org.jkiss.dbeaver.registry.driver.DriverDescriptor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 45 with GridData

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

the class DriverEditDialog method createLibrariesTab.

private void createLibrariesTab(TabFolder group) {
    GridData gd;
    Composite libsGroup = new Composite(group, SWT.NONE);
    libsGroup.setLayout(new GridLayout(2, false));
    {
        Composite libsListGroup = new Composite(libsGroup, SWT.NONE);
        gd = new GridData(GridData.FILL_BOTH);
        libsListGroup.setLayoutData(gd);
        GridLayout layout = new GridLayout(1, false);
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        libsListGroup.setLayout(layout);
        // Additional libraries list
        libTable = new TreeViewer(libsListGroup, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
        libTable.setContentProvider(new LibContentProvider());
        libTable.setLabelProvider(new CellLabelProvider() {

            @Override
            public void update(ViewerCell cell) {
                final Object element = cell.getElement();
                if (element instanceof DBPDriverLibrary) {
                    DBPDriverLibrary lib = (DBPDriverLibrary) element;
                    String displayName = lib.getDisplayName();
                    if (lib.getPreferredVersion() != null) {
                        displayName += " [" + lib.getPreferredVersion() + "]";
                    }
                    cell.setText(displayName);
                    File localFile = lib.getLocalFile();
                    if (localFile != null && !localFile.exists()) {
                        cell.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
                    } else if (!driver.isLibraryResolved(lib)) {
                        cell.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
                    } else {
                        cell.setForeground(null);
                    }
                    cell.setImage(DBeaverIcons.getImage(lib.getIcon()));
                } else {
                    cell.setText(element.toString());
                    cell.setImage(DBeaverIcons.getImage(UIIcon.JAR));
                }
            }
        });
        libTable.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
        libTable.getControl().addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {
                changeLibSelection();
            }
        });
        // Find driver class
        boolean isReadOnly = !provider.isDriversManagable();
        Composite findClassGroup = new Composite(libsListGroup, SWT.TOP);
        findClassGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        layout = new GridLayout(3, false);
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        findClassGroup.setLayout(layout);
        UIUtils.createControlLabel(findClassGroup, CoreMessages.dialog_edit_driver_label_driver_class);
        classListCombo = new Combo(findClassGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
        classListCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        classListCombo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                int selIndex = classListCombo.getSelectionIndex();
                if (selIndex >= 0) {
                    driverClassText.setText(classListCombo.getItem(selIndex));
                }
            }
        });
        classListCombo.setEnabled(!isReadOnly);
        findClassButton = new Button(findClassGroup, SWT.PUSH);
        findClassButton.setText(CoreMessages.dialog_edit_driver_button_bind_class);
        findClassButton.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {
                try {
                    DriverClassFindJob classFinder = new DriverClassFindJob(driver, "java/sql/Driver", true);
                    new ProgressMonitorDialog(getShell()).run(true, true, classFinder);
                    if (classListCombo != null && !classListCombo.isDisposed()) {
                        java.util.List<String> classNames = classFinder.getDriverClassNames();
                        classListCombo.setItems(classNames.toArray(new String[classNames.size()]));
                        classListCombo.setListVisible(true);
                    }
                } catch (InvocationTargetException e) {
                    log.error(e.getTargetException());
                } catch (InterruptedException e) {
                    log.error(e);
                }
            }
        });
        findClassButton.setEnabled(!isReadOnly);
    }
    Composite libsControlGroup = new Composite(libsGroup, SWT.TOP);
    libsControlGroup.setLayout(new GridLayout(1, true));
    libsControlGroup.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    UIUtils.createToolButton(libsControlGroup, CoreMessages.dialog_edit_driver_button_add_file, new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            addLibraryFiles();
        }
    });
    UIUtils.createToolButton(libsControlGroup, CoreMessages.dialog_edit_driver_button_add_folder, new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            addLibraryFolder();
        }
    });
    UIUtils.createToolButton(libsControlGroup, CoreMessages.dialog_edit_driver_button_add_artifact, new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            addMavenArtifact();
        }
    });
    updateVersionButton = UIUtils.createToolButton(libsControlGroup, CoreMessages.dialog_edit_driver_button_update_version, new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            driver.updateFiles();
            changeLibContent();
        }
    });
    detailsButton = UIUtils.createToolButton(libsControlGroup, CoreMessages.dialog_edit_driver_button_details, new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            new DriverLibraryDetailsDialog(getShell(), driver, getSelectedLibrary()).open();
        }
    });
    detailsButton.setEnabled(false);
    deleteButton = UIUtils.createToolButton(libsControlGroup, CoreMessages.dialog_edit_driver_button_delete, new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) libTable.getSelection();
            if (selection != null && !selection.isEmpty()) {
                if (UIUtils.confirmAction(getShell(), "Delete library", "Are you sure you want to delete selected libraries?")) {
                    for (Object obj : selection.toArray()) {
                        if (obj instanceof DriverLibraryAbstract) {
                            driver.removeDriverLibrary((DriverLibraryAbstract) obj);
                        }
                    }
                }
            }
            changeLibContent();
        }
    });
    deleteButton.setEnabled(false);
    /*
        upButton = UIUtils.createToolButton(libsControlGroup, CoreMessages.dialog_edit_driver_button_up, new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e)
            {
                DriverLibraryAbstract selectedLib = getSelectedLibrary();
                int selIndex = libList.indexOf(selectedLib);
                Collections.swap(libList, selIndex, selIndex - 1);
                changeLibContent();
                changeLibSelection();
            }
        });
        upButton.setEnabled(false);

        downButton = UIUtils.createToolButton(libsControlGroup, CoreMessages.dialog_edit_driver_button_down, new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e)
            {
                DriverLibraryAbstract selectedLib = getSelectedLibrary();
                int selIndex = libList.indexOf(selectedLib);
                Collections.swap(libList, selIndex, selIndex + 1);
                changeLibContent();
                changeLibSelection();
            }
        });
        downButton.setEnabled(false);
*/
    UIUtils.createHorizontalLine(libsControlGroup);
    UIUtils.createToolButton(libsControlGroup, CoreMessages.dialog_edit_driver_button_classpath, new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ViewClasspathDialog cpDialog = new ViewClasspathDialog(getShell());
            cpDialog.open();
        }
    });
    changeLibContent();
    TabItem libsTab = new TabItem(group, SWT.NONE);
    libsTab.setText(CoreMessages.dialog_edit_driver_tab_name_driver_libraries);
    libsTab.setToolTipText(CoreMessages.dialog_edit_driver_tab_tooltip_driver_libraries);
    libsTab.setControl(libsGroup);
}
Also used : PropertyTreeViewer(org.jkiss.dbeaver.ui.properties.PropertyTreeViewer) CSmartCombo(org.jkiss.dbeaver.ui.controls.CSmartCombo) DriverClassFindJob(org.jkiss.dbeaver.registry.driver.DriverClassFindJob) DriverLibraryAbstract(org.jkiss.dbeaver.registry.driver.DriverLibraryAbstract) GridLayout(org.eclipse.swt.layout.GridLayout) DBPDriverLibrary(org.jkiss.dbeaver.model.connection.DBPDriverLibrary) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) java.util(java.util) GridData(org.eclipse.swt.layout.GridData) File(java.io.File)

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