Search in sources :

Example 6 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter in project generator by mybatis.

the class SqlScriptComposite method createConnectionGroup.

private void createConnectionGroup(Composite parent) {
    Group group = new Group(parent, SWT.NONE);
    group.setText(Messages.SQL_SCRIPT_TAB_JDBC_CONNECTION_GROUP_TITLE);
    GridLayout groupLayout = new GridLayout(2, false);
    group.setLayout(groupLayout);
    group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    group.setFont(parent.getFont());
    Label lblJdbcDriverClass = new Label(group, SWT.NONE);
    lblJdbcDriverClass.setText(Messages.SQL_SCRIPT_TAB_JDBC_DRIVER_LABEL);
    new Label(group, SWT.NONE);
    txtJdbcDriver = new Text(group, SWT.BORDER);
    txtJdbcDriver.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            sqlScriptTab.updateLaunchConfigurationDialog();
        }
    });
    GridData gd_txtJdbcDriver = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_txtJdbcDriver.horizontalIndent = 30;
    txtJdbcDriver.setLayoutData(gd_txtJdbcDriver);
    new Label(group, SWT.NONE);
    Label lblJdbcUrl = new Label(group, SWT.NONE);
    lblJdbcUrl.setText(Messages.SQL_SCRIPT_TAB_JDBC_URL_LABEL);
    new Label(group, SWT.NONE);
    txtJdbcURL = new Text(group, SWT.BORDER);
    txtJdbcURL.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            sqlScriptTab.updateLaunchConfigurationDialog();
        }
    });
    GridData gd_txtJdbcURL = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_txtJdbcURL.horizontalIndent = 30;
    txtJdbcURL.setLayoutData(gd_txtJdbcURL);
    new Label(group, SWT.NONE);
    Label lblUserId = new Label(group, SWT.NONE);
    lblUserId.setText(Messages.SQL_SCRIPT_TAB_USERID_LABEL);
    new Label(group, SWT.NONE);
    txtUserID = new Text(group, SWT.BORDER);
    txtUserID.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            sqlScriptTab.updateLaunchConfigurationDialog();
        }
    });
    GridData gd_txtUserID = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_txtUserID.horizontalIndent = 30;
    txtUserID.setLayoutData(gd_txtUserID);
    new Label(group, SWT.NONE);
    Label lblPassword = new Label(group, SWT.NONE);
    lblPassword.setText(Messages.SQL_SCRIPT_TAB_PASSWORD_LABEL);
    new Label(group, SWT.NONE);
    txtPassword = new Text(group, SWT.PASSWORD | SWT.BORDER);
    txtPassword.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            sqlScriptTab.updateLaunchConfigurationDialog();
        }
    });
    GridData gd_txtPassword = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_txtPassword.horizontalIndent = 30;
    txtPassword.setLayoutData(gd_txtPassword);
    new Label(group, SWT.NONE);
    btnSecureStorage = new Button(group, SWT.CHECK);
    btnSecureStorage.setText(Messages.SQL_SCRIPT_TAB_SECURE_STORAGE);
    btnSecureStorage.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            sqlScriptTab.updateLaunchConfigurationDialog();
        }
    });
    new Label(group, SWT.NONE);
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text)

Example 7 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter in project dbeaver by serge-rider.

the class NavigatorActiveProjectContributor method createMenu.

private void createMenu(final Menu menu) {
    final IProject activeProject = DBeaverCore.getInstance().getProjectRegistry().getActiveProject();
    for (final IProject project : DBeaverCore.getInstance().getLiveProjects()) {
        MenuItem txnItem = new MenuItem(menu, SWT.RADIO);
        txnItem.setText(project.getName());
        txnItem.setSelection(project == activeProject);
        txnItem.setData(project);
        txnItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                DBeaverCore.getInstance().getProjectRegistry().setActiveProject(project);
            }
        });
    }
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) IProject(org.eclipse.core.resources.IProject)

Example 8 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter in project dbeaver by serge-rider.

the class ProgressLoaderVisualizer method showProgress.

private void showProgress() {
    if (progressOverlay == null) {
        // Start progress visualization
        cancelButton = new Button(progressPane, SWT.PUSH);
        cancelButton.setText("Cancel");
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.verticalIndent = DBeaverIcons.getImage(UIIcon.PROGRESS0).getBounds().height * 2;
        cancelButton.setLayoutData(gd);
        cancelButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                cancelButton.setText("Canceled");
                cancelButton.setEnabled(false);
                Point buttonSize = cancelButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
                progressOverlay.minimumWidth = buttonSize.x;
                progressOverlay.minimumHeight = buttonSize.y;
                progressOverlay.layout();
                try {
                    loadService.cancel();
                } catch (InvocationTargetException e1) {
                    log.error(e1.getTargetException());
                }
            }
        });
        painListener = new PaintListener() {

            @Override
            public void paintControl(PaintEvent e) {
                Image image = DBeaverIcons.getImage(PROGRESS_IMAGES[drawCount % PROGRESS_IMAGES.length]);
                Rectangle buttonBounds = cancelButton.getBounds();
                Rectangle imageBounds = image.getBounds();
                e.gc.drawImage(image, (buttonBounds.x + buttonBounds.width / 2) - imageBounds.width / 2, buttonBounds.y - imageBounds.height - 5);
                long elapsedTime = System.currentTimeMillis() - loadStartTime;
                String elapsedString = elapsedTime > 10000 ? String.valueOf(elapsedTime / 1000) : String.valueOf(((double) (elapsedTime / 100)) / 10);
                String statusMessage = CommonUtils.truncateString(progressMessage.replaceAll("\\s", " "), 64);
                String status = statusMessage + " - " + elapsedString + "s";
                Point statusSize = e.gc.textExtent(status);
                int statusX = (buttonBounds.x + buttonBounds.width / 2) - statusSize.x / 2;
                int statusY = buttonBounds.y - imageBounds.height - 10 - statusSize.y;
                e.gc.setForeground(progressPane.getForeground());
                e.gc.setBackground(progressPane.getBackground());
                e.gc.fillRectangle(statusX - 2, statusY - 2, statusSize.x + 4, statusSize.y + 4);
                e.gc.drawText(status, statusX, statusY, true);
                e.gc.setForeground(shadowColor);
                e.gc.drawRoundRectangle(statusX - 3, statusY - 3, statusSize.x + 5, statusSize.y + 5, 5, 5);
            }
        };
        progressPane.addPaintListener(painListener);
        progressOverlay = new ControlEditor(progressPane);
        Point buttonSize = cancelButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        progressOverlay.minimumWidth = buttonSize.x;
        progressOverlay.minimumHeight = buttonSize.y;
        progressOverlay.setEditor(cancelButton);
    }
    drawCount++;
    progressOverlay.layout();
    progressPane.redraw();
}
Also used : ControlEditor(org.eclipse.swt.custom.ControlEditor) PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) Image(org.eclipse.swt.graphics.Image) InvocationTargetException(java.lang.reflect.InvocationTargetException) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 9 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter in project dbeaver by serge-rider.

the class CustomCheckboxCellEditor method createControl.

@Override
protected Control createControl(Composite parent) {
    checkBox = new Button(parent, SWT.CHECK);
    checkBox.setFont(parent.getFont());
    checkBox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            applyEditorValue();
            // This is needed for MacOS
            fireApplyEditorValue();
        }
    });
    checkBox.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            CustomCheckboxCellEditor.this.focusLost();
        }
    });
    return checkBox;
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 10 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter in project dbeaver by serge-rider.

the class ConnectionPageGeneral method createControl.

@Override
public void createControl(Composite parent) {
    boldFont = UIUtils.makeBoldFont(parent.getFont());
    Composite group = new Composite(parent, SWT.NONE);
    GridLayout gl = new GridLayout(2, false);
    group.setLayout(gl);
    //$NON-NLS-1$
    String connectionName = dataSourceDescriptor == null ? "" : dataSourceDescriptor.getName();
    connectionNameText = UIUtils.createLabelText(group, CoreMessages.dialog_connection_wizard_final_label_connection_name, CommonUtils.toString(connectionName));
    connectionNameText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            connectionNameChanged = true;
            ConnectionPageGeneral.this.getContainer().updateButtons();
        }
    });
    {
        UIUtils.createControlLabel(group, "Connection type");
        Composite ctGroup = UIUtils.createPlaceholder(group, 2, 5);
        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());
                autocommit.setSelection(type.isAutocommit());
            }
        });
        Button pickerButton = new Button(ctGroup, SWT.PUSH);
        pickerButton.setText("Edit");
        pickerButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                DataSourceDescriptor dataSource = getActiveDataSource();
                UIUtils.showPreferencesFor(getControl().getShell(), dataSource.getConnectionConfiguration().getConnectionType(), PrefPageConnectionTypes.PAGE_ID);
                loadConnectionTypes();
                DBPConnectionType connectionType = dataSource.getConnectionConfiguration().getConnectionType();
                connectionTypeCombo.select(connectionType);
                autocommit.setSelection(connectionType.isAutocommit());
            }
        });
    }
    {
        UIUtils.createControlLabel(group, "Connection folder");
        connectionFolderCombo = new CSmartCombo<>(group, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY, new ConnectionFolderLabelProvider());
        //connectionFolderCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        loadConnectionFolders();
        connectionFolderCombo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                dataSourceFolder = connectionFolderCombo.getItem(connectionFolderCombo.getSelectionIndex());
            }
        });
    }
    {
        Composite optionsGroup = new Composite(group, SWT.NONE);
        gl = new GridLayout(2, true);
        gl.verticalSpacing = 0;
        gl.horizontalSpacing = 5;
        gl.marginHeight = 0;
        gl.marginWidth = 0;
        optionsGroup.setLayout(gl);
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        optionsGroup.setLayoutData(gd);
        Composite leftSide = UIUtils.createPlaceholder(optionsGroup, 1, 5);
        leftSide.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
        Composite rightSide = UIUtils.createPlaceholder(optionsGroup, 1, 5);
        rightSide.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
        {
            Group securityGroup = UIUtils.createControlGroup(leftSide, CoreMessages.dialog_connection_wizard_final_group_security, 1, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, 0);
            savePasswordCheck = UIUtils.createCheckbox(securityGroup, CoreMessages.dialog_connection_wizard_final_checkbox_save_password_locally, dataSourceDescriptor == null || dataSourceDescriptor.isSavePassword());
            savePasswordCheck.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        }
        {
            Group txnGroup = UIUtils.createControlGroup(rightSide, "Connection", 2, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, 0);
            autocommit = UIUtils.createLabelCheckbox(txnGroup, CoreMessages.dialog_connection_wizard_final_checkbox_auto_commit, "Sets auto-commit mode for all connections", dataSourceDescriptor != null && dataSourceDescriptor.isDefaultAutoCommit());
            autocommit.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
            autocommit.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (dataSourceDescriptor != null && dataSourceDescriptor.isConnected()) {
                        isolationLevel.setEnabled(!autocommit.getSelection());
                    }
                }
            });
            isolationLevel = UIUtils.createLabelCombo(txnGroup, "Isolation level", "Default transaction isolation level.", SWT.DROP_DOWN | SWT.READ_ONLY);
            defaultSchema = UIUtils.createLabelCombo(txnGroup, "Default schema", "Name of schema or catalog which will be set as default.", SWT.DROP_DOWN);
            keepAliveInterval = UIUtils.createLabelSpinner(txnGroup, "Keep-Alive", "Keep-alive interval (in seconds). Zero turns keep-alive off", 0, 0, Short.MAX_VALUE);
            {
                String bootstrapTooltip = "SQL queries to execute right after connection establishment";
                UIUtils.createControlLabel(txnGroup, "Bootstrap queries").setToolTipText(bootstrapTooltip);
                final Button queriesConfigButton = UIUtils.createPushButton(txnGroup, "Configure ...", DBeaverIcons.getImage(UIIcon.SQL_SCRIPT));
                queriesConfigButton.setToolTipText(bootstrapTooltip);
                if (dataSourceDescriptor != null && !CommonUtils.isEmpty(dataSourceDescriptor.getConnectionConfiguration().getBootstrap().getInitQueries())) {
                    queriesConfigButton.setFont(boldFont);
                }
                queriesConfigButton.addSelectionListener(new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        EditBootstrapQueriesDialog dialog = new EditBootstrapQueriesDialog(getShell(), bootstrapQueries, ignoreBootstrapErrors);
                        if (dialog.open() == IDialogConstants.OK_ID) {
                            bootstrapQueries = dialog.getQueries();
                            ignoreBootstrapErrors = dialog.isIgnoreErrors();
                        }
                    }
                });
            }
            if (getWizard().isNew()) {
                UIUtils.createControlLabel(txnGroup, "Shell Commands");
                eventsButton = new Button(txnGroup, SWT.PUSH);
                eventsButton.setText("Configure ...");
                eventsButton.setImage(DBeaverIcons.getImage(UIIcon.EVENT));
                eventsButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
                eventsButton.addSelectionListener(new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        configureEvents();
                    }
                });
            }
        }
        {
            Group miscGroup = UIUtils.createControlGroup(leftSide, CoreMessages.dialog_connection_wizard_final_group_misc, 1, GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL, 0);
            showSystemObjects = UIUtils.createCheckbox(miscGroup, CoreMessages.dialog_connection_wizard_final_checkbox_show_system_objects, dataSourceDescriptor == null || dataSourceDescriptor.isShowSystemObjects());
            showSystemObjects.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
            showUtilityObjects = UIUtils.createCheckbox(miscGroup, CoreMessages.dialog_connection_wizard_final_checkbox_show_util_objects, dataSourceDescriptor == null || dataSourceDescriptor.isShowUtilityObjects());
            showUtilityObjects.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
            readOnlyConnection = UIUtils.createCheckbox(miscGroup, CoreMessages.dialog_connection_wizard_final_checkbox_connection_readonly, dataSourceDescriptor != null && dataSourceDescriptor.isConnectionReadOnly());
            gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            //gd.horizontalSpan = 2;
            readOnlyConnection.setLayoutData(gd);
        }
        {
            // Filters
            filtersGroup = UIUtils.createControlGroup(leftSide, CoreMessages.dialog_connection_wizard_final_group_filters, 1, GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL, 0);
            for (int i = 0; i < filters.size(); i++) {
                final FilterInfo filterInfo = filters.get(i);
                filterInfo.link = UIUtils.createLink(filtersGroup, "<a>" + filterInfo.title + "</a>", new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        EditObjectFilterDialog dialog = new EditObjectFilterDialog(getShell(), 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());
                            }
                        }
                    }
                });
            }
        }
    }
    {
        final Group descGroup = UIUtils.createControlGroup(group, "Description", 1, GridData.FILL_HORIZONTAL, 0);
        ((GridData) descGroup.getLayoutData()).horizontalSpan = 2;
        descriptionText = new Text(descGroup, SWT.BORDER | SWT.V_SCROLL | SWT.WRAP | SWT.MULTI);
        final GridData gd = new GridData(GridData.FILL_BOTH);
        gd.heightHint = descriptionText.getLineHeight() * 3;
        descriptionText.setLayoutData(gd);
    }
    setControl(group);
    UIUtils.setHelp(group, IHelpContextIds.CTX_CON_WIZARD_FINAL);
}
Also used : DBSObjectFilter(org.jkiss.dbeaver.model.struct.DBSObjectFilter) DBPConnectionType(org.jkiss.dbeaver.model.connection.DBPConnectionType) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) 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)

Aggregations

SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)833 SelectionEvent (org.eclipse.swt.events.SelectionEvent)832 GridData (org.eclipse.swt.layout.GridData)511 GridLayout (org.eclipse.swt.layout.GridLayout)429 Composite (org.eclipse.swt.widgets.Composite)421 Button (org.eclipse.swt.widgets.Button)405 Label (org.eclipse.swt.widgets.Label)266 Text (org.eclipse.swt.widgets.Text)196 Group (org.eclipse.swt.widgets.Group)138 ModifyEvent (org.eclipse.swt.events.ModifyEvent)123 ModifyListener (org.eclipse.swt.events.ModifyListener)123 Combo (org.eclipse.swt.widgets.Combo)98 ToolItem (org.eclipse.swt.widgets.ToolItem)79 TableViewer (org.eclipse.jface.viewers.TableViewer)78 MenuItem (org.eclipse.swt.widgets.MenuItem)77 Menu (org.eclipse.swt.widgets.Menu)76 ToolBar (org.eclipse.swt.widgets.ToolBar)68 Table (org.eclipse.swt.widgets.Table)67 ArrayList (java.util.ArrayList)63 Point (org.eclipse.swt.graphics.Point)63