Search in sources :

Example 21 with ModifyEvent

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

the class FilterValueEditDialog method createMultiValueSelector.

private void createMultiValueSelector(Composite composite) {
    table = CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.MULTI | SWT.CHECK | SWT.FULL_SELECTION);
    table.getTable().setLinesVisible(true);
    table.getTable().setHeaderVisible(true);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = 400;
    gd.heightHint = 300;
    table.getTable().setLayoutData(gd);
    table.setContentProvider(new ListContentProvider());
    ViewerColumnController columnController = new ViewerColumnController(getClass().getName(), table);
    columnController.addColumn("Value", "Value", SWT.LEFT, true, true, new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return attr.getValueHandler().getValueDisplayString(attr, ((DBDLabelValuePair) element).getValue(), DBDDisplayFormat.UI);
        }
    });
    columnController.addColumn("Description", "Row description (composed from dictionary columns)", SWT.LEFT, true, true, new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return ((DBDLabelValuePair) element).getLabel();
        }
    });
    columnController.createColumns();
    MenuManager menuMgr = new MenuManager();
    menuMgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager manager) {
            UIUtils.fillDefaultTableContextMenu(manager, table.getTable());
            manager.add(new Separator());
            manager.add(new Action("Select &All") {

                @Override
                public void run() {
                    for (DBDLabelValuePair row : getMultiValues()) {
                        table.setChecked(row, true);
                    }
                }
            });
            manager.add(new Action("Select &None") {

                @Override
                public void run() {
                    for (DBDLabelValuePair row : getMultiValues()) {
                        table.setChecked(row, false);
                    }
                }
            });
        }
    });
    menuMgr.setRemoveAllWhenShown(true);
    table.getTable().setMenu(menuMgr.createContextMenu(table.getTable()));
    if (attr.getDataKind() == DBPDataKind.STRING) {
        // Create filter text
        final Text valueFilterText = new Text(composite, SWT.BORDER);
        valueFilterText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        valueFilterText.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                filterPattern = valueFilterText.getText();
                if (filterPattern.isEmpty()) {
                    filterPattern = null;
                }
                loadValues();
            }
        });
    }
    filterPattern = null;
    loadValues();
}
Also used : ViewerColumnController(org.jkiss.dbeaver.ui.controls.ViewerColumnController) ModifyListener(org.eclipse.swt.events.ModifyListener) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) ListContentProvider(org.jkiss.dbeaver.ui.controls.ListContentProvider) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridData(org.eclipse.swt.layout.GridData) DBDLabelValuePair(org.jkiss.dbeaver.model.data.DBDLabelValuePair)

Example 22 with ModifyEvent

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

the class ConfigImportWizardPageCustomSettings method createControl.

@Override
public void createControl(Composite parent) {
    Composite placeholder = new Composite(parent, SWT.NONE);
    placeholder.setLayout(new GridLayout(1, true));
    Composite typeGroup = UIUtils.createControlGroup(placeholder, "Input type", 2, GridData.FILL_HORIZONTAL, SWT.DEFAULT);
    xmlButton = new Button(typeGroup, SWT.RADIO);
    xmlButton.setText("XML");
    xmlButton.setSelection(true);
    csvButton = new Button(typeGroup, SWT.RADIO);
    csvButton.setText("CSV");
    UIUtils.createControlLabel(placeholder, "Input file");
    filePathText = new TextWithOpenFile(placeholder, "Configuration Input File", new String[] { "*", "*.csv", "*.xml", "*.*" });
    filePathText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    filePathText.getTextControl().addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            inputFile = new File(filePathText.getText());
            if (!inputFile.exists()) {
                setErrorMessage("File '" + inputFile.getAbsolutePath() + "' doesn't exist");
            } else {
                setErrorMessage(null);
            }
            getWizard().getContainer().updateButtons();
        }
    });
    UIUtils.createControlLabel(placeholder, "File encoding");
    encodingCombo = UIUtils.createEncodingCombo(placeholder, GeneralUtils.DEFAULT_ENCODING);
    /*
        final SelectionAdapter typeListener = new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean isCSV = csvButton.getSelection();
            }
        };
        csvButton.addSelectionListener(typeListener);
        xmlButton.addSelectionListener(typeListener);
*/
    setControl(placeholder);
}
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) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) TextWithOpenFile(org.jkiss.dbeaver.ui.controls.TextWithOpenFile) File(java.io.File) TextWithOpenFile(org.jkiss.dbeaver.ui.controls.TextWithOpenFile)

Example 23 with ModifyEvent

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

the class MySQLCreateDatabaseDialog method createDialogArea.

@Override
protected Composite createDialogArea(Composite parent) {
    final Composite composite = super.createDialogArea(parent);
    final Composite group = new Composite(composite, SWT.NONE);
    group.setLayout(new GridLayout(2, false));
    final Text nameText = UIUtils.createLabelText(group, "Database name", "");
    nameText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            name = nameText.getText();
            getButton(IDialogConstants.OK_ID).setEnabled(!name.isEmpty());
        }
    });
    final Combo charsetCombo = UIUtils.createLabelCombo(group, "Charset", SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
    for (MySQLCharset cs : dataSource.getCharsets()) {
        charsetCombo.add(cs.getName());
    }
    charsetCombo.setText(DEFAULT_CHARSET_NAME);
    charset = dataSource.getCharset(DEFAULT_CHARSET_NAME);
    assert charset != null;
    final Combo collationCombo = UIUtils.createLabelCombo(group, "Collation", SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
    for (MySQLCollation col : charset.getCollations()) {
        collationCombo.add(col.getName());
    }
    collation = charset.getDefaultCollation();
    if (collation != null) {
        UIUtils.setComboSelection(collationCombo, collation.getName());
    }
    charsetCombo.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            charset = dataSource.getCharset(charsetCombo.getText());
            assert charset != null;
            collationCombo.removeAll();
            for (MySQLCollation col : charset.getCollations()) {
                collationCombo.add(col.getName());
            }
            collation = charset.getDefaultCollation();
            if (collation != null) {
                UIUtils.setComboSelection(collationCombo, collation.getName());
            }
        }
    });
    collationCombo.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            collation = charset.getCollation(collationCombo.getText());
        }
    });
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) MySQLCharset(org.jkiss.dbeaver.ext.mysql.model.MySQLCharset) MySQLCollation(org.jkiss.dbeaver.ext.mysql.model.MySQLCollation)

Example 24 with ModifyEvent

use of org.eclipse.swt.events.ModifyEvent in project translationstudio8 by heartsome.

the class AddSearchEntryDialog method createDialogArea.

/**
	 * Create contents of the dialog.
	 * @param parent
	 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    container.setLayout(new GridLayout(1, false));
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = SWT.DEFAULT;
    gridData.widthHint = 450;
    container.setLayoutData(gridData);
    Composite nameSetArea = new Composite(container, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    nameSetArea.setLayout(gridLayout);
    nameSetArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Label nameLable = new Label(nameSetArea, SWT.NONE);
    GridData gd_nameLable = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_nameLable.widthHint = 38;
    nameLable.setLayoutData(gd_nameLable);
    nameLable.setText(Messages.getString("Websearch.AddSearchEntryDialog.NameLable"));
    nameText = new Text(nameSetArea, SWT.BORDER);
    nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if (style == EDIT) {
        nameText.setText(searEntry.getSearchName());
    }
    nameText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            setOkState();
        }
    });
    Composite urlSetArea = new Composite(container, SWT.NONE);
    GridLayout gridLayout2 = new GridLayout(2, false);
    urlSetArea.setLayout(gridLayout2);
    urlSetArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Label urlLable = new Label(urlSetArea, SWT.NONE);
    GridData gd_urlLable = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_urlLable.widthHint = 38;
    urlLable.setLayoutData(gd_urlLable);
    urlLable.setText("URL");
    urlText = new Text(urlSetArea, SWT.BORDER);
    if (style == EDIT) {
        urlText.setText(searEntry.getSearchUrl());
    }
    urlText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    urlText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            setOkState();
        }
    });
    Composite setArea = new Composite(container, SWT.NONE);
    setArea.setLayout(new GridLayout(1, true));
    setArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Group group = new Group(setArea, SWT.NONE);
    group.setLayout(new GridLayout(2, true));
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    group.setText(Messages.getString("Websearch.AddSearchEntryDialog.GroupTitle"));
    btnYesRadioButton = new Button(group, SWT.RADIO);
    btnYesRadioButton.setText(Messages.getString("Websearch.AddSearchEntryDialog.GroupYes"));
    btnYesRadioButton.setSelection(true);
    btnYesRadioButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnNoRadioButton = new Button(group, SWT.RADIO);
    btnNoRadioButton.setText(Messages.getString("Websearch.AddSearchEntryDialog.GroupNo"));
    btnNoRadioButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if (style == EDIT) {
        btnYesRadioButton.setSelection(searEntry.isChecked());
        btnNoRadioButton.setSelection(!searEntry.isChecked());
    }
    return container;
}
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) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text)

Example 25 with ModifyEvent

use of org.eclipse.swt.events.ModifyEvent in project translationstudio8 by heartsome.

the class CreateColumnGroupDialog method createInputPanel.

private Composite createInputPanel(final Composite composite) {
    final Composite row = new Composite(composite, SWT.NONE);
    row.setLayout(new GridLayout(2, false));
    final Label createLabel = new Label(row, SWT.NONE);
    createLabel.setText("G&roup Name:");
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(createLabel);
    groupNameText = new Text(row, SWT.SINGLE | SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(groupNameText);
    groupNameText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            createButton.setEnabled(groupNameText.getText().length() > 0);
        }
    });
    groupNameText.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            if (createButton.isEnabled()) {
                doColumnGrouping();
            }
        }
    });
    return row;
}
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) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text)

Aggregations

ModifyEvent (org.eclipse.swt.events.ModifyEvent)269 ModifyListener (org.eclipse.swt.events.ModifyListener)269 GridData (org.eclipse.swt.layout.GridData)179 Text (org.eclipse.swt.widgets.Text)160 GridLayout (org.eclipse.swt.layout.GridLayout)159 Composite (org.eclipse.swt.widgets.Composite)148 SelectionEvent (org.eclipse.swt.events.SelectionEvent)141 Label (org.eclipse.swt.widgets.Label)140 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)120 Button (org.eclipse.swt.widgets.Button)87 Combo (org.eclipse.swt.widgets.Combo)54 Group (org.eclipse.swt.widgets.Group)42 SelectionListener (org.eclipse.swt.events.SelectionListener)30 File (java.io.File)27 KeyEvent (org.eclipse.swt.events.KeyEvent)23 StyledText (org.eclipse.swt.custom.StyledText)21 DirectoryDialog (org.eclipse.swt.widgets.DirectoryDialog)21 FileDialog (org.eclipse.swt.widgets.FileDialog)18 FocusEvent (org.eclipse.swt.events.FocusEvent)17 List (java.util.List)16