Search in sources :

Example 11 with GridData

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

the class TargetPrefPage method createDescriptionLabel.

@Override
protected Label createDescriptionLabel(Composite parent) {
    if (isDataSourcePreferencePage()) {
        Composite composite = UIUtils.createPlaceholder(parent, 2);
        composite.setFont(parent.getFont());
        composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
        dataSourceSettingsButton = new Button(composite, SWT.CHECK);
        dataSourceSettingsButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean enabled = dataSourceSettingsButton.getSelection();
                enableDataSourceSpecificSettings(enabled);
            }
        });
        String dataSourceName = containerNode.getDataSourceContainer().getName();
        dataSourceSettingsButton.setText(NLS.bind(CoreMessages.pref_page_target_button_use_datasource_settings, dataSourceName));
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        dataSourceSettingsButton.setLayoutData(gd);
        changeSettingsTargetLink = createLink(composite, CoreMessages.pref_page_target_link_show_global_settings);
        changeSettingsTargetLink.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
    } else if (supportsDataSourceSpecificOptions()) {
        changeSettingsTargetLink = createLink(parent, CoreMessages.pref_page_target_link_show_datasource_settings);
        changeSettingsTargetLink.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false));
    }
    Label horizontalLine = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
    horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
    horizontalLine.setFont(parent.getFont());
    createPreferenceHeader(parent);
    return super.createDescriptionLabel(parent);
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 12 with GridData

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

the class PrefPageProjectSettings method createContents.

@Override
protected Control createContents(final Composite parent) {
    Composite composite = UIUtils.createPlaceholder(parent, 1, 5);
    {
        UIUtils.createControlLabel(composite, "Resource locations");
        resourceTable = new Table(composite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
        resourceTable.setLayoutData(new GridData(GridData.FILL_BOTH));
        resourceTable.setHeaderVisible(true);
        resourceTable.setLinesVisible(true);
        UIUtils.createTableColumn(resourceTable, SWT.LEFT, "Resource");
        UIUtils.createTableColumn(resourceTable, SWT.LEFT, "Folder");
        resourceTable.setHeaderVisible(true);
        resourceTable.setLayoutData(new GridData(GridData.FILL_BOTH));
        handlerTableEditor = new TableEditor(resourceTable);
        handlerTableEditor.verticalAlignment = SWT.TOP;
        handlerTableEditor.horizontalAlignment = SWT.RIGHT;
        handlerTableEditor.grabHorizontal = true;
        handlerTableEditor.grabVertical = true;
        resourceTable.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseUp(MouseEvent e) {
                disposeOldEditor();
                final TableItem item = resourceTable.getItem(new Point(0, e.y));
                if (item == null) {
                    return;
                }
                int columnIndex = UIUtils.getColumnAtPos(item, e.x, e.y);
                if (columnIndex <= 0) {
                    return;
                }
                if (columnIndex == 1) {
                    final String resourcePath = item.getText(1);
                    if (project != null) {
                        final IFolder folder = project.getFolder(resourcePath);
                        ContainerSelectionDialog dialog = new ContainerSelectionDialog(resourceTable.getShell(), folder, true, "Select " + item.getText(0) + " root folder");
                        dialog.showClosedProjects(false);
                        dialog.setValidator(new ISelectionValidator() {

                            @Override
                            public String isValid(Object selection) {
                                if (selection instanceof IPath) {
                                    final File file = ((IPath) selection).toFile();
                                    if (file.isHidden() || file.getName().startsWith(".")) {
                                        return "Can't use hidden folders";
                                    }
                                    final String[] segments = ((IPath) selection).segments();
                                    if (!project.getName().equals(segments[0])) {
                                        return "Can't store resources in another project";
                                    }
                                }
                                return null;
                            }
                        });
                        if (dialog.open() == IDialogConstants.OK_ID) {
                            final Object[] result = dialog.getResult();
                            if (result.length == 1 && result[0] instanceof IPath) {
                                final IPath plainPath = ((IPath) result[0]).removeFirstSegments(1).removeTrailingSeparator();
                                item.setText(1, plainPath.toString());
                            }
                        }
                    } else {
                        final Text editor = new Text(resourceTable, SWT.NONE);
                        editor.setText(resourcePath);
                        editor.selectAll();
                        handlerTableEditor.setEditor(editor, item, 1);
                        editor.setFocus();
                        editor.addFocusListener(new FocusAdapter() {

                            @Override
                            public void focusLost(FocusEvent e) {
                                item.setText(1, editor.getText());
                            }
                        });
                    }
                }
            }
        });
    }
    performDefaults();
    return composite;
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) MouseEvent(org.eclipse.swt.events.MouseEvent) IPath(org.eclipse.core.runtime.IPath) MouseAdapter(org.eclipse.swt.events.MouseAdapter) ISelectionValidator(org.eclipse.ui.dialogs.ISelectionValidator) Point(org.eclipse.swt.graphics.Point) TableEditor(org.eclipse.swt.custom.TableEditor) FocusEvent(org.eclipse.swt.events.FocusEvent) Point(org.eclipse.swt.graphics.Point) ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog) GridData(org.eclipse.swt.layout.GridData) File(java.io.File) IFolder(org.eclipse.core.resources.IFolder)

Example 13 with GridData

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

the class PrefPageQueryManager method createContents.

@Override
protected Control createContents(Composite parent) {
    Composite composite = UIUtils.createPlaceholder(parent, 1);
    Composite filterSettings = UIUtils.createPlaceholder(composite, 2, 5);
    Group groupObjects = UIUtils.createControlGroup(filterSettings, CoreMessages.pref_page_query_manager_group_object_types, 1, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, 170);
    checkObjectTypeSessions = UIUtils.createCheckbox(groupObjects, CoreMessages.pref_page_query_manager_checkbox_sessions, false);
    checkObjectTypeTxn = UIUtils.createCheckbox(groupObjects, CoreMessages.pref_page_query_manager_checkbox_transactions, false);
    //checkObjectTypeScripts = UIUtils.createCheckbox(groupObjects, CoreMessages.pref_page_query_manager_checkbox_scripts, false);
    checkObjectTypeQueries = UIUtils.createCheckbox(groupObjects, CoreMessages.pref_page_query_manager_checkbox_queries, false);
    Group groupQueryTypes = UIUtils.createControlGroup(filterSettings, CoreMessages.pref_page_query_manager_group_query_types, 1, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, 170);
    checkQueryTypeUser = UIUtils.createCheckbox(groupQueryTypes, CoreMessages.pref_page_query_manager_checkbox_user_queries, false);
    checkQueryTypeUserFiltered = UIUtils.createCheckbox(groupQueryTypes, CoreMessages.pref_page_query_manager_checkbox_user_filtered, false);
    checkQueryTypeScript = UIUtils.createCheckbox(groupQueryTypes, CoreMessages.pref_page_query_manager_checkbox_user_scripts, false);
    checkQueryTypeUtil = UIUtils.createCheckbox(groupQueryTypes, CoreMessages.pref_page_query_manager_checkbox_utility_functions, false);
    checkQueryTypeMeta = UIUtils.createCheckbox(groupQueryTypes, CoreMessages.pref_page_query_manager_checkbox_metadata_read, false);
    checkQueryTypeDDL = UIUtils.createCheckbox(groupQueryTypes, CoreMessages.pref_page_query_manager_checkbox_metadata_write, false);
    {
        Group viewSettings = UIUtils.createControlGroup(composite, CoreMessages.pref_page_query_manager_group_settings, 2, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, 0);
        //$NON-NLS-2$
        textEntriesPerPage = UIUtils.createLabelText(viewSettings, CoreMessages.pref_page_query_manager_label_entries_per_page, "", SWT.BORDER, new GridData(50, SWT.DEFAULT));
    }
    {
        Group storageSettings = UIUtils.createControlGroup(composite, CoreMessages.pref_page_query_manager_group_storage, 2, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, 0);
        checkStoreLog = UIUtils.createCheckbox(storageSettings, CoreMessages.pref_page_query_manager_checkbox_store_log_file, false);
        GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
        gd.horizontalSpan = 2;
        checkStoreLog.setLayoutData(gd);
        checkStoreLog.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                UIUtils.enableWithChildren(textOutputFolder.getParent(), checkStoreLog.getSelection());
            }
        });
        textOutputFolder = DialogUtils.createOutputFolderChooser(storageSettings, CoreMessages.pref_page_query_manager_logs_folder, null);
        //$NON-NLS-2$
        textHistoryDays = UIUtils.createLabelText(storageSettings, CoreMessages.pref_page_query_manager_label_days_to_store_log, "", SWT.BORDER, new GridData(50, SWT.DEFAULT));
        textHistoryDays.setEnabled(false);
    }
    performDefaults();
    return composite;
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 14 with GridData

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

the class PrefPageConnectionTypes method createContents.

@Override
protected Control createContents(final Composite parent) {
    Composite composite = UIUtils.createPlaceholder(parent, 1, 5);
    {
        typeTable = new Table(composite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
        typeTable.setLayoutData(new GridData(GridData.FILL_BOTH));
        UIUtils.createTableColumn(typeTable, SWT.LEFT, "Name");
        UIUtils.createTableColumn(typeTable, SWT.LEFT, "Description");
        typeTable.setHeaderVisible(true);
        typeTable.setLayoutData(new GridData(GridData.FILL_BOTH));
        typeTable.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                showSelectedType(getSelectedType());
            }
        });
        ToolBar toolbar = new ToolBar(composite, SWT.FLAT | SWT.HORIZONTAL);
        final ToolItem newButton = new ToolItem(toolbar, SWT.NONE);
        newButton.setImage(DBeaverIcons.getImage(UIIcon.ROW_ADD));
        deleteButton = new ToolItem(toolbar, SWT.NONE);
        deleteButton.setImage(DBeaverIcons.getImage(UIIcon.ROW_DELETE));
        newButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                String name;
                for (int i = 1; ; i++) {
                    name = "Type" + i;
                    boolean hasName = false;
                    for (DBPConnectionType type : changedInfo.keySet()) {
                        if (type.getName().equals(name)) {
                            hasName = true;
                            break;
                        }
                    }
                    if (!hasName) {
                        break;
                    }
                }
                DBPConnectionType newType = new DBPConnectionType(SecurityUtils.generateUniqueId(), name, "255,255,255", "New type", true, false);
                addTypeToTable(newType, newType);
                typeTable.select(typeTable.getItemCount() - 1);
                typeTable.showSelection();
                showSelectedType(newType);
            }
        });
        this.deleteButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                DBPConnectionType connectionType = getSelectedType();
                if (!UIUtils.confirmAction(getShell(), "Delete connection type", "Are you sure you want to delete connection type '" + connectionType.getName() + "'?\n" + "All connections of this type will be reset to default type (" + DBPConnectionType.DEFAULT_TYPE.getName() + ")")) {
                    return;
                }
                changedInfo.remove(connectionType);
                int index = typeTable.getSelectionIndex();
                typeTable.remove(index);
                if (index > 0)
                    index--;
                typeTable.select(index);
                showSelectedType(getSelectedType());
            }
        });
    }
    {
        Group groupSettings = UIUtils.createControlGroup(composite, "Settings", 2, GridData.VERTICAL_ALIGN_BEGINNING, 300);
        groupSettings.setLayoutData(new GridData(GridData.FILL_BOTH));
        typeName = UIUtils.createLabelText(groupSettings, "Name", null);
        typeName.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                getSelectedType().setName(typeName.getText());
                updateTableInfo();
            }
        });
        typeDescription = UIUtils.createLabelText(groupSettings, "Description", null);
        typeDescription.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                getSelectedType().setDescription(typeDescription.getText());
                updateTableInfo();
            }
        });
        {
            UIUtils.createControlLabel(groupSettings, "Color");
            //                Composite colorGroup = UIUtils.createPlaceholder(groupSettings, 2, 5);
            //                colorGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            colorPicker = new ColorSelector(groupSettings);
            //                colorPicker.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            colorPicker.addListener(new IPropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent event) {
                    getSelectedType().setColor(StringConverter.asString(colorPicker.getColorValue()));
                    updateTableInfo();
                }
            });
        /*
                Button pickerButton = new Button(colorGroup, SWT.PUSH);
                pickerButton.setText("...");
                pickerButton.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e)
                    {
                        DBPConnectionType connectionType = getSelectedType();
                        ColorDialog colorDialog = new ColorDialog(parent.getShell());
                        colorDialog.setRGB(StringConverter.asRGB(connectionType.getColor()));
                        RGB rgb = colorDialog.open();
                        if (rgb != null) {
                            Color color = null;
                            int count = colorPicker.getItemCount();
                            for (int i = 0; i < count; i++) {
                                Color item = colorPicker.getColorItem(i);
                                if (item != null && item.getRGB().equals(rgb)) {
                                    color = item;
                                    break;
                                }
                            }
                            if (color == null) {
                                color = new Color(colorPicker.getDisplay(), rgb);
                                colorPicker.addColor(color);
                            }
                            colorPicker.select(color);
                            getSelectedType().setColor(StringConverter.asString(color.getRGB()));
                            updateTableInfo();
                        }
                    }
                });
*/
        }
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        autocommitCheck = UIUtils.createCheckbox(groupSettings, "Auto-commit by default", false);
        autocommitCheck.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                getSelectedType().setAutocommit(autocommitCheck.getSelection());
            }
        });
        autocommitCheck.setLayoutData(gd);
        confirmCheck = UIUtils.createCheckbox(groupSettings, "Confirm SQL execution", false);
        confirmCheck.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                getSelectedType().setConfirmExecute(confirmCheck.getSelection());
            }
        });
        confirmCheck.setLayoutData(gd);
    }
    performDefaults();
    return composite;
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) DBPConnectionType(org.jkiss.dbeaver.model.connection.DBPConnectionType) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) GridData(org.eclipse.swt.layout.GridData) ColorSelector(org.eclipse.jface.preference.ColorSelector)

Example 15 with GridData

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

the class PrefPageDataFormat method createPreferenceHeader.

@Override
protected void createPreferenceHeader(Composite composite) {
    if (!isDataSourcePreferencePage()) {
        Composite profileGroup = UIUtils.createPlaceholder(composite, 3);
        profileGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        UIUtils.createControlLabel(profileGroup, CoreMessages.pref_page_data_format_label_profile);
        profilesCombo = new Combo(profileGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
        profilesCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        profilesCombo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                changeProfile();
            }
        });
        Button editButton = new Button(profileGroup, SWT.PUSH);
        editButton.setText(CoreMessages.pref_page_data_format_button_manage_profiles);
        editButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                manageProfiles();
            }
        });
    }
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

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