Search in sources :

Example 86 with KeyListener

use of org.eclipse.swt.events.KeyListener in project tmdm-studio-se by Talend.

the class ComplexTableViewer method createViewer.

protected void createViewer() {
    createTable();
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, columns.size(), 1);
    table.setLayoutData(gd);
    gd.heightHint = 80;
    // Up Down Delete button group
    Composite stepUpDownComposite = toolkit.createComposite(mainComposite, SWT.NONE);
    stepUpDownComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
    stepUpDownComposite.setLayout(new GridLayout(1, false));
    // $NON-NLS-1$
    upButton = toolkit.createButton(stepUpDownComposite, "", SWT.PUSH | SWT.CENTER);
    upButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
    upButton.setImage(ImageCache.getCreatedImage(EImage.PREV_NAV.getPath()));
    upButton.setToolTipText(Messages.ComplexTableViewer_UpBtnTip);
    upButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
        }

        @SuppressWarnings("unchecked")
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            int index = viewer.getTable().getSelectionIndex();
            if (index > 0 && index < viewer.getTable().getItemCount()) {
                // commit as we go
                if (mainPage != null) {
                    mainPage.setComitting(true);
                }
                List<Line> items = (List<Line>) viewer.getInput();
                Line line = items.get(index);
                items.remove(index);
                items.add(index - 1, line);
                viewer.refresh();
                if (mainPage != null) {
                    mainPage.setComitting(false);
                }
                markDirty();
            }
        }
    });
    // $NON-NLS-1$
    downButton = toolkit.createButton(stepUpDownComposite, "", SWT.PUSH | SWT.CENTER);
    downButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
    downButton.setImage(ImageCache.getCreatedImage(EImage.NEXT_NAV.getPath()));
    downButton.setToolTipText(Messages.ComplexTableViewer_DownBtnTip);
    downButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
        }

        @SuppressWarnings("unchecked")
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            int index = viewer.getTable().getSelectionIndex();
            if (index >= 0 && index < viewer.getTable().getItemCount() - 1) {
                // commit as we go
                if (mainPage != null) {
                    mainPage.setComitting(true);
                }
                List<Line> items = (List<Line>) viewer.getInput();
                Line line = items.get(index);
                items.remove(index);
                items.add(index + 1, line);
                // viewer.setInput(items);
                viewer.refresh();
                // TODO
                if (mainPage != null) {
                    mainPage.setComitting(false);
                }
                markDirty();
            }
        }
    });
    // $NON-NLS-1$
    deleteButton = toolkit.createButton(stepUpDownComposite, "", SWT.PUSH | SWT.CENTER);
    deleteButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
    deleteButton.setToolTipText(Messages.ComplexTableViewer_DelBtnLabel);
    deleteButton.setImage(ImageCache.getCreatedImage(EImage.DELETE_OBJ.getPath()));
    deleteButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
        }

        @SuppressWarnings("unchecked")
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            int index = viewer.getTable().getSelectionIndex();
            if (index >= 0 && index < viewer.getTable().getItemCount()) {
                List<Line> items = (List<Line>) viewer.getInput();
                items.remove(index);
                viewer.refresh();
                int pos = index - 1;
                if (pos >= 0) {
                    viewer.getTable().select(pos);
                }
                markDirty();
            }
        }
    });
    // Create the cell editors --> We actually discard those later: not natural for an user
    CellEditor[] editors = new CellEditor[columns.size()];
    for (int i = 0; i < columns.size(); i++) {
        if (columns.get(i).isText()) {
            editors[i] = new TextCellEditor(table);
        } else if (columns.get(i).isCombo()) {
            editors[i] = new ComboBoxCellEditor(table, columns.get(i).getComboValues(), SWT.READ_ONLY);
        } else if (columns.get(i).isXPATH()) {
            editors[i] = new XpathCellEditor(table, validators.get(columns.get(i)));
        } else if (columns.get(i).isMultiMessage()) {
            editors[i] = new MultiMessageEditor(table);
            multiMsg.setColumn(table.getColumn(i));
        } else if (columns.get(i).isValidationRule()) {
            editors[i] = new ValidationRuleEditor(table);
            validationRule.setColumn(table.getColumn(i));
        }
    }
    viewer.setCellEditors(editors);
    // set the content provider
    viewer.setContentProvider(new IStructuredContentProvider() {

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        @SuppressWarnings("unchecked")
        public Object[] getElements(Object inputElement) {
            List<Line> lines = (List<Line>) inputElement;
            return lines.toArray(new Line[lines.size()]);
        }
    });
    // set the label provider
    viewer.setLabelProvider(new ITableLabelProvider() {

        public boolean isLabelProperty(Object element, String property) {
            return false;
        }

        public void dispose() {
        }

        public void addListener(ILabelProviderListener listener) {
        }

        public void removeListener(ILabelProviderListener listener) {
        }

        public String getColumnText(Object element, int columnIndex) {
            Line line = (Line) element;
            if (columnIndex >= 0 && columnIndex < columns.size()) {
                for (KeyValue keyvalue : line.keyValues) {
                    if (keyvalue.key.equals(columns.get(columnIndex).getName())) {
                        String val = keyvalue.value;
                        if (columns.get(columnIndex).isNillable()) {
                            if (columns.get(columnIndex).getNillValue().equals(val)) {
                                val = columns.get(columnIndex).getNillDisplay();
                            }
                        }
                        return val;
                    }
                }
            }
            // $NON-NLS-1$
            return "";
        }

        public Image getColumnImage(Object element, int columnIndex) {
            return null;
        }
    });
    // Set the column properties
    ArrayList<String> columnNames = new ArrayList<String>();
    for (ComplexTableViewerColumn column : columns) {
        columnNames.add(column.getName());
    }
    viewer.setColumnProperties(columnNames.toArray(new String[columnNames.size()]));
    // set the Cell Modifier
    viewer.setCellModifier(new ICellModifier() {

        public boolean canModify(Object element, String property) {
            // if (INSTANCE_ACCESS.equals(property)) return true; Deactivated
            return editable;
        }

        @SuppressWarnings("unchecked")
        public void modify(Object element, String property, Object value) {
            if (value instanceof Integer) {
                if (Integer.valueOf(value.toString()) == -1) {
                    return;
                }
            }
            // modify the text and combo cell value
            TableItem item = (TableItem) element;
            Line line = (Line) item.getData();
            int columnIndex = Arrays.asList(viewer.getColumnProperties()).indexOf(property);
            if (!isForceTextCellEditor(columnIndex) && isAColumnWithCombo(columnIndex)) {
                String[] attrs = columns.get(columnIndex).getComboValues();
                value = attrs[Integer.parseInt(value.toString())];
            }
            KeyValue kv = line.keyValues.get(columnIndex);
            boolean noChange = kv.value.equals(value.toString());
            kv.value = value.toString();
            viewer.refresh();
            if (!noChange) {
                markDirty();
            }
        }

        public Object getValue(Object element, String property) {
            int columnIndex = Arrays.asList(viewer.getColumnProperties()).indexOf(property);
            Line line = (Line) element;
            // add getting value from combo
            if (isAColumnWithCombo(columnIndex)) {
                String value = line.keyValues.get(columnIndex).value;
                String[] attrs = columns.get(columnIndex).getComboValues();
                return Arrays.asList(attrs).indexOf(value);
            }
            for (KeyValue keyvalue : line.keyValues) {
                if (property.equals(keyvalue.key)) {
                    if (keyvalue.value.equals("")) {
                        // $NON-NLS-1$
                        return columns.get(columnIndex).getNillDisplay();
                    }
                    return keyvalue.value;
                }
            }
            return null;
        }

        private boolean isAColumnWithCombo(int columnIdx) {
            return columns.get(columnIdx).isCombo();
        }

        private boolean isForceTextCellEditor(int columnIdx) {
            return columns.get(columnIdx).isText();
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            Line line = (Line) ((IStructuredSelection) event.getSelection()).getFirstElement();
            for (int columnIndex = 0; columnIndex < columns.size(); columnIndex++) {
                if (line == null) {
                    Control control = columns.get(columnIndex).getControl();
                    if (control instanceof Text) {
                        // $NON-NLS-1$
                        ((Text) control).setText("");
                    }
                    if (control instanceof CCombo) {
                        ((CCombo) control).select(0);
                    }
                    if (control instanceof Combo) {
                        ((CCombo) control).select(0);
                    }
                } else {
                    for (KeyValue keyvalue : line.keyValues) {
                        if (keyvalue.key.equals(columns.get(columnIndex).getName())) {
                            String val = keyvalue.value;
                            Control control = columns.get(columnIndex).getControl();
                            if (control instanceof Text) {
                                ((Text) control).setText(val);
                            }
                            if (control instanceof CCombo) {
                                ((CCombo) control).setText(val);
                            }
                            if (control instanceof Combo) {
                                ((CCombo) control).setText(val);
                            }
                        }
                    }
                }
            }
        }
    });
    // display for Delete Key events to delete an instance
    viewer.getTable().addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
        }

        @SuppressWarnings("unchecked")
        public void keyReleased(KeyEvent e) {
            if ((e.stateMask == 0) && (e.character == SWT.DEL) && (viewer.getSelection() != null)) {
                Line line = (Line) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
                // update the underlying role and refresh the table
                // update the underlying model
                List<Line> items = (List<Line>) viewer.getInput();
                items.remove(line);
                // refresh
                viewer.refresh();
                // mark for update
                markDirty();
            }
        }
    });
}
Also used : KeyValue(com.amalto.workbench.models.KeyValue) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) CCombo(org.eclipse.swt.custom.CCombo) Combo(org.eclipse.swt.widgets.Combo) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) EImage(com.amalto.workbench.image.EImage) Image(org.eclipse.swt.graphics.Image) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) Control(org.eclipse.swt.widgets.Control) ICellModifier(org.eclipse.jface.viewers.ICellModifier) List(java.util.List) ListenerList(org.eclipse.core.runtime.ListenerList) ArrayList(java.util.ArrayList) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) Text(org.eclipse.swt.widgets.Text) Line(com.amalto.workbench.models.Line) CCombo(org.eclipse.swt.custom.CCombo) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) KeyListener(org.eclipse.swt.events.KeyListener) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 87 with KeyListener

use of org.eclipse.swt.events.KeyListener in project eclipse-integration-commons by spring-projects.

the class ViewerSearchPart method addPart.

/**
 * Adds the text control to the given composite. Must not be null.
 *
 * @param parent
 *           Cannot be null
 */
protected void addPart(Composite parent) {
    searchText = new Text(parent, SWT.SEARCH | SWT.ICON_CANCEL | SWT.ICON_SEARCH);
    searchText.setBackground(null);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(searchText);
    searchText.addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent event) {
            handleSearch(searchText.getText());
        }

        public void keyPressed(KeyEvent event) {
        // nothing
        }
    });
    searchText.addSelectionListener(new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent e) {
            if (e.detail == SWT.CANCEL) {
                String searchString = searchText.getText();
                handleSearch(searchString);
            }
        }
    });
    searchText.setMessage("Type pattern to match");
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) KeyListener(org.eclipse.swt.events.KeyListener)

Example 88 with KeyListener

use of org.eclipse.swt.events.KeyListener in project webtools.sourceediting by eclipse.

the class ConfigurableContentOutlinePage method unconfigure.

/**
 * Unconfigure the content outline page
 */
private void unconfigure() {
    if (getTreeViewer() != null) {
        // remove the key listeners
        if (getControl() != null && !getControl().isDisposed()) {
            KeyListener[] listeners = getConfiguration().getKeyListeners(getTreeViewer());
            if (listeners != null) {
                for (int i = 0; i < listeners.length; i++) {
                    getControl().removeKeyListener(listeners[i]);
                }
            }
        }
        IContributionManager toolbar = getSite().getActionBars().getToolBarManager();
        if (toolbar != null && !toolbar.isEmpty()) {
            IContributionItem[] toolbarItems = getConfiguration().getToolbarContributions(getTreeViewer());
            if (toolbarItems != null && toolbarItems.length > 0) {
                for (int i = 0; i < toolbarItems.length; i++) {
                    toolbar.remove(toolbarItems[i]);
                }
                toolbar.update(false);
            }
        }
        IContributionManager menubar = getSite().getActionBars().getMenuManager();
        if (menubar != null && !menubar.isEmpty()) {
            IContributionItem[] menuItems = getConfiguration().getMenuContributions(getTreeViewer());
            if (menuItems != null && menuItems.length > 0) {
                for (int i = 0; i < menuItems.length; i++) {
                    menubar.remove(menuItems[i]);
                }
                menubar.remove(IWorkbenchActionConstants.MB_ADDITIONS);
                menubar.update(false);
            }
        }
        // clear the DnD listeners and transfer types
        if (fDragAdapter != null && !fDragAdapter.isEmpty() && fDragSource != null && !fDragSource.isDisposed() && fDragSource.getTransfer().length > 0) {
            if (fActiveDragListeners != null) {
                for (int i = 0; i < fActiveDragListeners.length; i++) {
                    fDragAdapter.removeDragSourceListener(fActiveDragListeners[i]);
                }
            }
            fActiveDragListeners = null;
            fDragSource.removeDragListener(fDragAdapter);
            fDragSource.setTransfer(new Transfer[0]);
        }
        if (fDropAdapter != null && !fDropAdapter.isEmpty() && fDropTarget != null && !fDropTarget.isDisposed() && fDropTarget.getTransfer().length > 0) {
            if (fActiveDropListeners != null) {
                for (int i = 0; i < fActiveDropListeners.length; i++) {
                    fDropAdapter.removeDropTargetListener(fActiveDropListeners[i]);
                }
            }
            fActiveDropListeners = null;
            fDropTarget.removeDropListener(fDropAdapter);
            fDropTarget.setTransfer(new Transfer[0]);
        }
        getConfiguration().getContentProvider(getTreeViewer()).inputChanged(getTreeViewer(), fInput, null);
        // release any ties to this tree viewer
        getConfiguration().unconfigure(getTreeViewer());
    }
}
Also used : IContributionItem(org.eclipse.jface.action.IContributionItem) KeyListener(org.eclipse.swt.events.KeyListener) IContributionManager(org.eclipse.jface.action.IContributionManager)

Example 89 with KeyListener

use of org.eclipse.swt.events.KeyListener in project liferay-ide by liferay.

the class LiferayCustomXmlHoverControl method _createResolutionsControl.

private void _createResolutionsControl(Composite parent, IMarker marker, IMarkerResolution[] resolutions) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = 0;
    layout.verticalSpacing = 2;
    layout.marginHeight = 0;
    composite.setLayout(layout);
    Label quickFixLabel = new Label(composite, SWT.NONE);
    GridData layoutData = new GridData(SWT.BEGINNING, SWT.TOP, false, false);
    layoutData.horizontalIndent = 4;
    quickFixLabel.setLayoutData(layoutData);
    String text;
    if (resolutions.length == 1) {
        text = _oneQuickFix;
    } else {
        text = NLS.bind(_multipleQuickFixes, String.valueOf(resolutions.length));
    }
    quickFixLabel.setText(text);
    Composite composite2 = new Composite(parent, SWT.NONE);
    composite2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayout layout2 = new GridLayout(2, false);
    layout2.marginLeft = 5;
    layout2.verticalSpacing = 2;
    composite2.setLayout(layout2);
    List<Link> list = new ArrayList<>();
    for (IMarkerResolution resolution : resolutions) {
        // Original link for single fix, hence pass 1 for count
        list.add(_createCompletionProposalLink(composite2, marker, resolution, 1));
    }
    Link[] links = list.toArray(new Link[0]);
    _focusControl = links[0];
    for (int i = 0; i < links.length; i++) {
        int index = i;
        Link link = links[index];
        link.addKeyListener(new KeyListener() {

            public void keyPressed(KeyEvent e) {
                switch(e.keyCode) {
                    case SWT.ARROW_DOWN:
                        if ((index + 1) < links.length) {
                            links[index + 1].setFocus();
                        }
                        break;
                    case SWT.ARROW_UP:
                        if (index > 0) {
                            links[index - 1].setFocus();
                        }
                        break;
                    default:
                        break;
                }
            }

            public void keyReleased(KeyEvent e) {
            }
        });
    }
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) Point(org.eclipse.swt.graphics.Point) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) IMarkerResolution(org.eclipse.ui.IMarkerResolution) GridData(org.eclipse.swt.layout.GridData) KeyListener(org.eclipse.swt.events.KeyListener) Link(org.eclipse.swt.widgets.Link)

Example 90 with KeyListener

use of org.eclipse.swt.events.KeyListener in project core by jcryptool.

the class IntegratorWizardPage method createRandomGroup.

/**
 * This method initializes randomCombo
 */
private void createRandomGroup(Composite parent) {
    GridLayout randomGroupGridLayout = new GridLayout();
    randomGroupGridLayout.numColumns = 3;
    randomGroupGridLayout.makeColumnsEqualWidth = false;
    GridData randomGroupGridData = new GridData();
    randomGroupGridData.horizontalAlignment = GridData.FILL;
    randomGroupGridData.grabExcessHorizontalSpace = true;
    randomGroupGridData.verticalAlignment = GridData.FILL;
    Group randomGroup = new Group(parent, SWT.NONE);
    randomGroup.setLayoutData(randomGroupGridData);
    randomGroup.setLayout(randomGroupGridLayout);
    // $NON-NLS-1$
    randomGroup.setText(Messages.getString("DummyWizardPage.29"));
    Label label = new Label(randomGroup, SWT.LEFT);
    // $NON-NLS-1$
    label.setText(Messages.getString("DummyWizardPage.30"));
    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = false;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.widthHint = 30;
    final Text randomText = new Text(randomGroup, SWT.BORDER);
    randomText.setLayoutData(gridData);
    // random_text.setOrientation(SWT.RIGHT_TO_LEFT);
    // $NON-NLS-1$
    randomText.setText("128");
    randomText.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            if ((Character.getType(e.character) != Character.DECIMAL_DIGIT_NUMBER) && (e.keyCode != SWT.ARROW_LEFT) && (e.keyCode != SWT.ARROW_RIGHT) && (e.character != SWT.DEL) && (e.character != SWT.BS))
                e.doit = false;
        }

        public void keyReleased(KeyEvent e) {
            random = Integer.parseInt(randomText.getText());
        }
    });
    random = Integer.parseInt(randomText.getText());
    label = new Label(randomGroup, SWT.LEFT);
    // $NON-NLS-1$ // spaces to get the right width for all cells
    label.setText("Bytes");
    GridLayout alphabetGroupGridLayout = new GridLayout();
    alphabetGroupGridLayout.numColumns = 7;
    alphabetGroupGridLayout.makeColumnsEqualWidth = false;
    GridData alphabetGroupGridData = new GridData();
    alphabetGroupGridData.horizontalAlignment = GridData.FILL;
    alphabetGroupGridData.grabExcessHorizontalSpace = true;
    alphabetGroupGridData.verticalAlignment = GridData.FILL;
    Group alphabetGroup = new Group(parent, SWT.NONE);
    alphabetGroup.setLayoutData(alphabetGroupGridData);
    alphabetGroup.setLayout(alphabetGroupGridLayout);
    // $NON-NLS-1$
    alphabetGroup.setText(Messages.getString("DummyWizardPage.27"));
    // All Chars
    gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 7, 1);
    Button alphabet_button = new Button(alphabetGroup, SWT.RADIO);
    // $NON-NLS-1$
    alphabet_button.setText(Messages.getString("DummyWizardPage.28"));
    alphabet_button.setLayoutData(gridData);
    alphabet_button.setSelection(true);
    alphabet_button.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        public void widgetSelected(SelectionEvent e) {
            alphabet_text.setEnabled(alphabet_text_button.getSelection());
            alphabet_range_1.setEnabled(alphabet_range_button.getSelection());
            alphabet_range_2.setEnabled(alphabet_range_button.getSelection());
            alphabet_padding_button.setEnabled(alphabet_range_button.getSelection());
            alphabet_doFilter = false;
            setPageComplete(true);
        }
    });
    // Filter chars
    gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 7, 1);
    alphabet_text_button = new Button(alphabetGroup, SWT.RADIO);
    // $NON-NLS-1$
    alphabet_text_button.setText(Messages.getString("DummyWizardPage.31"));
    alphabet_text_button.setLayoutData(gridData);
    alphabet_text_button.setSelection(false);
    alphabet_text_button.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        public void widgetSelected(SelectionEvent e) {
            alphabet_text.setEnabled(alphabet_text_button.getSelection());
            alphabet_range_1.setEnabled(alphabet_range_button.getSelection());
            alphabet_range_2.setEnabled(alphabet_range_button.getSelection());
            alphabet_padding_button.setEnabled(alphabet_range_button.getSelection());
            alphabet_doFilter = true;
            alphabet = parseAlphabet();
        }
    });
    gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    label = new Label(alphabetGroup, SWT.LEFT);
    label.setLayoutData(gridData);
    // $NON-NLS-1$
    label.setText("");
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, false, 6, 1);
    alphabet_text = new Text(alphabetGroup, SWT.BORDER);
    alphabet_text.setLayoutData(gridData);
    // $NON-NLS-1$
    alphabet_text.setText("0123456789ABCDEF");
    alphabet_text.setEnabled(false);
    alphabet_text.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            if (// $NON-NLS-1$
            alphabet_text.getText().contains("" + e.character))
                e.doit = false;
        }

        public void keyReleased(KeyEvent e) {
            alphabet = parseAlphabet();
        }
    });
    // Filter range
    gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 7, 1);
    alphabet_range_button = new Button(alphabetGroup, SWT.RADIO);
    // $NON-NLS-1$
    alphabet_range_button.setText(Messages.getString("DummyWizardPage.34"));
    alphabet_range_button.setLayoutData(gridData);
    alphabet_range_button.setSelection(false);
    alphabet_range_button.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        public void widgetSelected(SelectionEvent e) {
            alphabet_text.setEnabled(alphabet_text_button.getSelection());
            alphabet_range_1.setEnabled(alphabet_range_button.getSelection());
            alphabet_range_2.setEnabled(alphabet_range_button.getSelection());
            alphabet_padding_button.setEnabled(alphabet_range_button.getSelection());
            alphabet_doFilter = true;
            alphabet = parseAlphabet();
        }
    });
    gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    label = new Label(alphabetGroup, SWT.LEFT);
    label.setLayoutData(gridData);
    // $NON-NLS-1$
    label.setText("");
    gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gridData.widthHint = 40;
    alphabet_range_1 = new Text(alphabetGroup, SWT.BORDER | SWT.CENTER);
    alphabet_range_1.setLayoutData(gridData);
    // $NON-NLS-1$
    alphabet_range_1.setText("0");
    alphabet_range_1.setEnabled(false);
    alphabet_range_1.addKeyListener(new KeyAdapter() {

        public void keyReleased(KeyEvent e) {
            alphabet = parseAlphabet();
        }
    });
    gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
    gridData.widthHint = 8;
    label = new Label(alphabetGroup, SWT.NONE);
    label.setLayoutData(gridData);
    // $NON-NLS-1$
    label.setText("-");
    gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gridData.widthHint = 40;
    alphabet_range_2 = new Text(alphabetGroup, SWT.BORDER | SWT.CENTER);
    alphabet_range_2.setLayoutData(gridData);
    // $NON-NLS-1$
    alphabet_range_2.setText("9");
    alphabet_range_2.setEnabled(false);
    alphabet_range_2.addKeyListener(new KeyAdapter() {

        public void keyReleased(KeyEvent e) {
            alphabet = parseAlphabet();
        }
    });
    // only for space
    gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
    gridData.widthHint = 20;
    label = new Label(alphabetGroup, SWT.NONE);
    label.setLayoutData(gridData);
    // $NON-NLS-1$
    label.setText("");
    gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
    alphabet_padding_button = new Button(alphabetGroup, SWT.CHECK);
    // $NON-NLS-1$
    alphabet_padding_button.setText(Messages.getString("DummyWizardPage.35"));
    alphabet_padding_button.setLayoutData(gridData);
    alphabet_padding_button.setSelection(false);
    alphabet_padding_button.setEnabled(false);
    alphabet_padding_button.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        public void widgetSelected(SelectionEvent e) {
            alphabet = parseAlphabet();
        }
    });
    alphabet_doFilter = false;
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) KeyAdapter(org.eclipse.swt.events.KeyAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) KeyListener(org.eclipse.swt.events.KeyListener) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

KeyListener (org.eclipse.swt.events.KeyListener)99 KeyEvent (org.eclipse.swt.events.KeyEvent)91 GridData (org.eclipse.swt.layout.GridData)39 Composite (org.eclipse.swt.widgets.Composite)37 SelectionEvent (org.eclipse.swt.events.SelectionEvent)36 GridLayout (org.eclipse.swt.layout.GridLayout)33 Text (org.eclipse.swt.widgets.Text)32 Button (org.eclipse.swt.widgets.Button)29 Label (org.eclipse.swt.widgets.Label)29 MouseEvent (org.eclipse.swt.events.MouseEvent)24 Point (org.eclipse.swt.graphics.Point)23 SelectionListener (org.eclipse.swt.events.SelectionListener)22 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)19 ModifyEvent (org.eclipse.swt.events.ModifyEvent)14 ModifyListener (org.eclipse.swt.events.ModifyListener)14 MouseListener (org.eclipse.swt.events.MouseListener)14 Combo (org.eclipse.swt.widgets.Combo)14 Event (org.eclipse.swt.widgets.Event)13 ArrayList (java.util.ArrayList)12 StyledText (org.eclipse.swt.custom.StyledText)9