Search in sources :

Example 26 with SelectionEvent

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

the class ExasolExportTableToolDialog method createControls.

@Override
protected void createControls(final Composite parent) {
    Group optionsGroup = UIUtils.createControlGroup(parent, ExasolMessages.dialog_table_tools_options, 1, 0, 0);
    optionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Composite composite = new Composite(optionsGroup, 2);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    // Directory select Button
    btSelectDirectory = UIUtils.createPushButton(composite, ExasolMessages.dialog_table_open_output_directory, null);
    btSelectDirectory.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            final DirectoryDialog dialog = new DirectoryDialog(parent.getShell());
            final String directory = dialog.open();
            if (directory != null) {
                selectedDirectory.setVisible(true);
                selectedDirectory.setText(directory + File.separatorChar);
            } else {
                selectedDirectory.setVisible(false);
            }
            updateSQL();
        }
    });
    //label for selected directory
    selectedDirectory = UIUtils.createLabel(composite, "");
    selectedDirectory.setVisible(false);
    //file template
    filename = "${schema}_${table}_${date}";
    txFileName = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_file_template, filename);
    txFileName.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent arg0) {
            filename = txFileName.getText();
            updateSQL();
        }
    });
    // compress output
    btSelectCompress = UIUtils.createCheckbox(composite, ExasolMessages.dialog_table_tools_export_compress, false);
    btSelectCompress.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateSQL();
        }
    });
    // PlaceHolder
    UIUtils.createPlaceholder(composite, 1);
    // include column headings
    btInclColNames = UIUtils.createCheckbox(composite, ExasolMessages.dialog_table_tools_column_heading, true);
    btInclColNames.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateSQL();
        }
    });
    // PlaceHolder
    UIUtils.createPlaceholder(composite, 1);
    // encoding combo
    cbEncoding = UIUtils.createLabelCombo(composite, ExasolMessages.dialog_table_tools_encoding, SWT.DROP_DOWN | SWT.READ_ONLY);
    for (String enc : ExasolConstants.encodings) {
        cbEncoding.add(enc);
    }
    cbEncoding.select(0);
    encoding = ExasolConstants.encodings.get(0);
    cbEncoding.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            encoding = ExasolConstants.encodings.get(cbEncoding.getSelectionIndex());
            updateSQL();
        }
    });
    //  row seperator
    cbRowSep = UIUtils.createLabelCombo(composite, ExasolMessages.dialog_table_tools_string_sep_mode, SWT.DROP_DOWN | SWT.READ_ONLY);
    for (String mode : ExasolConstants.rowSeperators) {
        cbRowSep.add(mode);
    }
    cbRowSep.select(0);
    rowSep = ExasolConstants.rowSeperators.get(0);
    cbRowSep.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            rowSep = ExasolConstants.rowSeperators.get(cbRowSep.getSelectionIndex());
            updateSQL();
        }
    });
    //  string sep mode
    cbStringSepMode = UIUtils.createLabelCombo(composite, ExasolMessages.dialog_table_tools_string_sep_mode, SWT.DROP_DOWN | SWT.READ_ONLY);
    for (String mode : ExasolConstants.stringSepModes) {
        cbStringSepMode.add(mode);
    }
    cbStringSepMode.select(0);
    sepMode = ExasolConstants.stringSepModes.get(0);
    cbStringSepMode.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            sepMode = ExasolConstants.stringSepModes.get(cbStringSepMode.getSelectionIndex());
            updateSQL();
        }
    });
    // column sep
    txColSep = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_column_sep, ";");
    txColSep.setTextLimit(1);
    txColSep.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent arg0) {
            updateSQL();
        }
    });
    // string sep
    txStringSep = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_string_sep, "\"");
    txStringSep.setTextLimit(1);
    txStringSep.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent arg0) {
            updateSQL();
        }
    });
    createObjectsSelector(parent);
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 27 with SelectionEvent

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

the class ExasolImportTableToolDialog method createControls.

@Override
protected void createControls(final Composite parent) {
    Group optionsGroup = UIUtils.createControlGroup(parent, ExasolMessages.dialog_table_tools_options, 1, 0, 0);
    optionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Composite composite = new Composite(optionsGroup, 2);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    // Directory select Button
    btSelectDirectory = UIUtils.createPushButton(composite, ExasolMessages.dialog_table_open_output_directory, null);
    btSelectDirectory.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            final DirectoryDialog dialog = new DirectoryDialog(parent.getShell());
            final String directory = dialog.open();
            if (directory != null) {
                selectedDirectory.setVisible(true);
                selectedDirectory.setText(directory + File.separatorChar);
            } else {
                selectedDirectory.setVisible(false);
            }
            updateSQL();
        }
    });
    //label for selected directory
    selectedDirectory = UIUtils.createLabel(composite, "");
    selectedDirectory.setVisible(false);
    //file template
    filename = "${schema}_${table}_${date}";
    txFileName = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_file_template, filename);
    txFileName.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent arg0) {
            filename = txFileName.getText();
            updateSQL();
        }
    });
    // compress output
    btSelectCompress = UIUtils.createCheckbox(composite, ExasolMessages.dialog_table_tools_export_compress, false);
    btSelectCompress.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateSQL();
        }
    });
    // PlaceHolder
    UIUtils.createPlaceholder(composite, 1);
    // include column headings
    btInclColNames = UIUtils.createCheckbox(composite, ExasolMessages.dialog_table_tools_column_heading, true);
    btInclColNames.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateSQL();
        }
    });
    // PlaceHolder
    UIUtils.createPlaceholder(composite, 1);
    // encoding combo
    cbEncoding = UIUtils.createLabelCombo(composite, ExasolMessages.dialog_table_tools_encoding, SWT.DROP_DOWN | SWT.READ_ONLY);
    for (String enc : ExasolConstants.encodings) {
        cbEncoding.add(enc);
    }
    cbEncoding.select(0);
    encoding = ExasolConstants.encodings.get(0);
    cbEncoding.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            encoding = ExasolConstants.encodings.get(cbEncoding.getSelectionIndex());
            updateSQL();
        }
    });
    //  row seperator
    cbRowSep = UIUtils.createLabelCombo(composite, ExasolMessages.dialog_table_tools_string_sep_mode, SWT.DROP_DOWN | SWT.READ_ONLY);
    for (String mode : ExasolConstants.rowSeperators) {
        cbRowSep.add(mode);
    }
    cbRowSep.select(0);
    rowSep = ExasolConstants.rowSeperators.get(0);
    cbRowSep.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            rowSep = ExasolConstants.rowSeperators.get(cbRowSep.getSelectionIndex());
            updateSQL();
        }
    });
    // column sep
    txColSep = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_column_sep, ";");
    txColSep.setTextLimit(1);
    txColSep.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent arg0) {
            updateSQL();
        }
    });
    // string sep
    txStringSep = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_string_sep, "\"");
    txStringSep.setTextLimit(1);
    txStringSep.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent arg0) {
            updateSQL();
        }
    });
    createObjectsSelector(parent);
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 28 with SelectionEvent

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

the class ExasolConnectionPage method createControl.

@Override
public void createControl(Composite composite) {
    setImageDescriptor(EXASOL_LOGO_IMG);
    Composite control = new Composite(composite, SWT.NONE);
    control.setLayout(new GridLayout(1, false));
    control.setLayoutData(new GridData(GridData.FILL_BOTH));
    ModifyListener textListener = new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            evaluateURL();
        }
    };
    {
        Composite addrGroup = UIUtils.createControlGroup(control, "Database", 2, 0, 0);
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        addrGroup.setLayoutData(gd);
        Label hostLabel = UIUtils.createControlLabel(addrGroup, "Host List");
        hostLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
        hostText = new Text(addrGroup, SWT.BORDER);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.grabExcessHorizontalSpace = true;
        hostText.setLayoutData(gd);
        hostText.addModifyListener(textListener);
        backupHostLabel = UIUtils.createControlLabel(addrGroup, "Backup Host List");
        gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
        backupHostLabel.setLayoutData(gd);
        backupHostLabel.setEnabled(showBackupHosts);
        backupHostText = new Text(addrGroup, SWT.BORDER);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.grabExcessHorizontalSpace = true;
        backupHostText.setLayoutData(gd);
        backupHostText.addModifyListener(textListener);
        useBackupHostList = UIUtils.createLabelCheckbox(addrGroup, "Use Backup Host List", showBackupHosts);
        useBackupHostList.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                backupHostLabel.setEnabled(useBackupHostList.getSelection());
                backupHostText.setEnabled(useBackupHostList.getSelection());
                //reset text if disabled
                if (!useBackupHostList.getSelection())
                    backupHostText.setText("");
            }
        });
        Label portLabel = UIUtils.createControlLabel(addrGroup, ExasolMessages.dialog_connection_port);
        gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
        portLabel.setLayoutData(gd);
        portText = new Text(addrGroup, SWT.BORDER);
        gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
        gd.widthHint = 40;
        portText.setLayoutData(gd);
        portText.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.getDefault()));
        portText.addModifyListener(textListener);
        encryptCommunication = UIUtils.createLabelCheckbox(addrGroup, "Encrypt Communication", false);
    }
    {
        Composite addrGroup = UIUtils.createControlGroup(control, "Security", 2, 0, 0);
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        addrGroup.setLayoutData(gd);
        Label usernameLabel = UIUtils.createControlLabel(addrGroup, ExasolMessages.dialog_connection_user_name);
        usernameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
        usernameText = new Text(addrGroup, SWT.BORDER);
        gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
        gd.widthHint = 200;
        usernameText.setLayoutData(gd);
        usernameText.addModifyListener(textListener);
        Label passwordLabel = UIUtils.createControlLabel(addrGroup, ExasolMessages.dialog_connection_password);
        passwordLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
        passwordText = new Text(addrGroup, SWT.BORDER | SWT.PASSWORD);
        gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
        gd.widthHint = 200;
        passwordText.setLayoutData(gd);
        passwordText.addModifyListener(textListener);
    }
    createDriverPanel(control);
    setControl(control);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) 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 29 with SelectionEvent

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

the class ScriptsExportWizardPage method createControl.

@Override
public void createControl(Composite parent) {
    String outDir = DBeaverCore.getGlobalPreferenceStore().getString(PREF_SCRIPTS_EXPORT_OUT_DIR);
    if (CommonUtils.isEmpty(outDir)) {
        outDir = RuntimeUtils.getUserHomeDir().getAbsolutePath();
    }
    Composite placeholder = UIUtils.createPlaceholder(parent, 1);
    placeholder.setLayout(new GridLayout(1, false));
    // Project list
    scriptsNavigator = new DatabaseNavigatorTree(placeholder, DBeaverCore.getInstance().getNavigatorModel().getRoot(), SWT.BORDER | SWT.CHECK);
    GridData gd = new GridData(GridData.FILL_BOTH);
    scriptsNavigator.setLayoutData(gd);
    CheckboxTreeViewer viewer = (CheckboxTreeViewer) scriptsNavigator.getViewer();
    viewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            updateState();
        }
    });
    scriptsNavigator.getViewer().addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            return element instanceof DBNResource && ((DBNResource) element).getResource() instanceof IContainer;
        }
    });
    // Output folder
    Composite generalSettings = UIUtils.createPlaceholder(placeholder, 3);
    generalSettings.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    {
        overwriteCheck = UIUtils.createCheckbox(generalSettings, CoreMessages.dialog_project_export_wizard_page_checkbox_overwrite_files, false);
        gd = new GridData(GridData.BEGINNING);
        gd.horizontalSpan = 3;
        overwriteCheck.setLayoutData(gd);
        UIUtils.createControlLabel(generalSettings, CoreMessages.dialog_project_export_wizard_page_label_directory);
        directoryText = new Text(generalSettings, SWT.BORDER);
        directoryText.setText(outDir);
        directoryText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        directoryText.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                updateState();
            }
        });
        Button openFolder = new Button(generalSettings, SWT.PUSH);
        openFolder.setImage(DBeaverIcons.getImage(DBIcon.TREE_FOLDER));
        openFolder.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE);
                dialog.setMessage(CoreMessages.dialog_project_export_wizard_page_dialog_choose_export_dir_message);
                dialog.setText(CoreMessages.dialog_project_export_wizard_page_dialog_choose_export_dir_text);
                String directory = directoryText.getText();
                if (!CommonUtils.isEmpty(directory)) {
                    dialog.setFilterPath(directory);
                }
                directory = dialog.open();
                if (directory != null) {
                    directoryText.setText(directory);
                }
            }
        });
    }
    setControl(placeholder);
    updateState();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree) DBNResource(org.jkiss.dbeaver.model.navigator.DBNResource) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IContainer(org.eclipse.core.resources.IContainer) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 30 with SelectionEvent

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

the class DatabaseConsumerPageLoadSettings method createControl.

@Override
public void createControl(Composite parent) {
    initializeDialogUnits(parent);
    Composite composite = new Composite(parent, SWT.NULL);
    GridLayout gl = new GridLayout();
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    composite.setLayout(gl);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    final DatabaseConsumerSettings settings = getWizard().getPageSettings(this, DatabaseConsumerSettings.class);
    {
        Group performanceSettings = UIUtils.createControlGroup(composite, "Performance", 4, GridData.FILL_HORIZONTAL, 0);
        final Button newConnectionCheckbox = UIUtils.createLabelCheckbox(performanceSettings, CoreMessages.data_transfer_wizard_output_checkbox_new_connection, settings.isOpenNewConnections());
        newConnectionCheckbox.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                settings.setOpenNewConnections(newConnectionCheckbox.getSelection());
            }
        });
        newConnectionCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 3, 1));
        final Button useTransactionsCheck = UIUtils.createLabelCheckbox(performanceSettings, "Use transactions", settings.isUseTransactions());
        useTransactionsCheck.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                settings.setUseTransactions(useTransactionsCheck.getSelection());
            }
        });
        useTransactionsCheck.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 3, 1));
        final Spinner commitAfterEdit = UIUtils.createLabelSpinner(performanceSettings, "Commit after insert of ", settings.getCommitAfterRows(), 1, Integer.MAX_VALUE);
        commitAfterEdit.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                settings.setCommitAfterRows(commitAfterEdit.getSelection());
            }
        });
        commitAfterEdit.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 3, 1));
    }
    {
        Group generalSettings = UIUtils.createControlGroup(composite, "General", 4, GridData.FILL_HORIZONTAL, 0);
        final Button showTableCheckbox = UIUtils.createLabelCheckbox(generalSettings, "Open table editor on finish", settings.isOpenTableOnFinish());
        showTableCheckbox.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                settings.setOpenTableOnFinish(showTableCheckbox.getSelection());
            }
        });
        showTableCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 3, 1));
    }
    setControl(composite);
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) Spinner(org.eclipse.swt.widgets.Spinner) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

SelectionEvent (org.eclipse.swt.events.SelectionEvent)971 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)831 GridData (org.eclipse.swt.layout.GridData)572 GridLayout (org.eclipse.swt.layout.GridLayout)481 Composite (org.eclipse.swt.widgets.Composite)479 Button (org.eclipse.swt.widgets.Button)468 Label (org.eclipse.swt.widgets.Label)314 Text (org.eclipse.swt.widgets.Text)221 SelectionListener (org.eclipse.swt.events.SelectionListener)185 Group (org.eclipse.swt.widgets.Group)168 ModifyEvent (org.eclipse.swt.events.ModifyEvent)143 ModifyListener (org.eclipse.swt.events.ModifyListener)143 Combo (org.eclipse.swt.widgets.Combo)118 MenuItem (org.eclipse.swt.widgets.MenuItem)89 ToolItem (org.eclipse.swt.widgets.ToolItem)89 Menu (org.eclipse.swt.widgets.Menu)88 TableViewer (org.eclipse.jface.viewers.TableViewer)84 Point (org.eclipse.swt.graphics.Point)82 ArrayList (java.util.ArrayList)79 ToolBar (org.eclipse.swt.widgets.ToolBar)76