Search in sources :

Example 16 with TraverseEvent

use of org.eclipse.swt.events.TraverseEvent in project eclipse.platform.text by eclipse.

the class CompletionProposalPopup method addCommandSupport.

/**
 * Adds command support to the given control.
 *
 * @param control the control to watch for focus
 * @since 3.2
 */
private void addCommandSupport(final Control control) {
    final KeySequence commandSequence = fContentAssistant.getRepeatedInvocationKeySequence();
    if (commandSequence != null && !commandSequence.isEmpty() && fContentAssistant.isRepeatedInvocationMode()) {
        control.addFocusListener(new FocusListener() {

            private CommandKeyListener fCommandKeyListener;

            @Override
            public void focusGained(FocusEvent e) {
                if (Helper.okToUse(control)) {
                    if (fCommandKeyListener == null) {
                        fCommandKeyListener = new CommandKeyListener(commandSequence);
                        fProposalTable.addKeyListener(fCommandKeyListener);
                    }
                }
            }

            @Override
            public void focusLost(FocusEvent e) {
                if (fCommandKeyListener != null) {
                    control.removeKeyListener(fCommandKeyListener);
                    fCommandKeyListener = null;
                }
            }
        });
    }
    if (fAdditionalInfoController != null) {
        control.addFocusListener(new FocusListener() {

            private TraverseListener fTraverseListener;

            @Override
            public void focusGained(FocusEvent e) {
                if (Helper.okToUse(control)) {
                    if (fTraverseListener == null) {
                        fTraverseListener = new TraverseListener() {

                            @Override
                            public void keyTraversed(TraverseEvent event) {
                                if (event.detail == SWT.TRAVERSE_TAB_NEXT) {
                                    IInformationControl iControl = fAdditionalInfoController.getCurrentInformationControl2();
                                    if (fAdditionalInfoController.getInternalAccessor().canReplace(iControl)) {
                                        fAdditionalInfoController.getInternalAccessor().replaceInformationControl(true);
                                        event.doit = false;
                                    }
                                }
                            }
                        };
                        fProposalTable.addTraverseListener(fTraverseListener);
                    }
                }
            }

            @Override
            public void focusLost(FocusEvent e) {
                if (fTraverseListener != null) {
                    control.removeTraverseListener(fTraverseListener);
                    fTraverseListener = null;
                }
            }
        });
    }
}
Also used : TraverseEvent(org.eclipse.swt.events.TraverseEvent) IInformationControl(org.eclipse.jface.text.IInformationControl) TraverseListener(org.eclipse.swt.events.TraverseListener) KeySequence(org.eclipse.jface.bindings.keys.KeySequence) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 17 with TraverseEvent

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

the class DateCellEditor method createControl.

/**
     * Create the chooser control.
     * 
     * @param table parent table.
     */
private void createControl(JaretTable table) {
    _table = table;
    if (_chooser == null) {
        _chooser = new DateChooser(table, SWT.NULL);
        // TODO locale dependent
        IFieldIdentifier fi = new SimpleFieldIdentifier(".", new int[] { Calendar.DAY_OF_MONTH, Calendar.MONTH, Calendar.YEAR });
        _chooser.setFieldIdentifier(fi);
        _chooser.setSelectAllOnFocusGained(false);
        _chooser.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
        _chooser.addFocusListener(this);
        _chooser.addDateChooserListener(this);
        _chooser.getTextField().addKeyListener(new KeyListener() {

            public void keyPressed(KeyEvent event) {
                if (event.keyCode == SWT.TAB) {
                    _chooser.validateInput();
                    stopEditing(true);
                    // do not further process
                    event.doit = false;
                    _table.forceFocus();
                    _table.focusRight();
                } else if (event.keyCode == SWT.CR) {
                    _chooser.validateInput();
                    stopEditing(true);
                    // do not further process
                    event.doit = false;
                    _table.forceFocus();
                    _table.focusDown();
                } else if (event.keyCode == SWT.ESC) {
                    stopEditing(false);
                    restoreOldVal();
                    // do not further process
                    event.doit = false;
                    _table.forceFocus();
                }
            }

            public void keyReleased(KeyEvent e) {
            }
        });
        // add a traverse listener so the TAB-key won't traverse the focus out of the table
        _chooser.getTextField().addTraverseListener(new TraverseListener() {

            public void keyTraversed(TraverseEvent e) {
                e.doit = false;
            }
        });
    }
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener) SimpleFieldIdentifier(de.jaret.util.ui.datechooser.SimpleFieldIdentifier) IFieldIdentifier(de.jaret.util.ui.datechooser.IFieldIdentifier) KeyListener(org.eclipse.swt.events.KeyListener) DateChooser(de.jaret.util.ui.datechooser.DateChooser)

Example 18 with TraverseEvent

use of org.eclipse.swt.events.TraverseEvent in project cubrid-manager by CUBRID.

the class DataTypeCellEditor method createControl.

protected Control createControl(Composite parent) {
    comboBox = new DataTypeCombo(parent, getStyle());
    comboBox.setFont(parent.getFont());
    populateComboBoxItems();
    //		comboBox.addKeyListener(new KeyAdapter() {
    //			public void keyPressed(KeyEvent event) {
    //				if (event.character == '\r') {
    //					applyEditorValueAndDeactivate();
    //				}
    //				keyReleaseOccured(event);
    //			}
    //
    //			public void keyReleased(KeyEvent event) {
    //			}
    //		});
    comboBox.addModifyListener(getModifyListener());
    comboBox.addSelectionListener(new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent event) {
            applyEditorValueAndDeactivate();
        }

        public void widgetSelected(SelectionEvent event) {
            value = comboBox.getText();
        }
    });
    comboBox.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent event) {
            if (event.detail == SWT.TRAVERSE_ESCAPE || event.detail == SWT.TRAVERSE_RETURN) {
                event.doit = false;
            }
        }
    });
    comboBox.addFocusListener(new FocusAdapter() {

        public void focusLost(FocusEvent event) {
            applyEditorValueAndDeactivate();
            DataTypeCellEditor.this.focusLost();
        }
    });
    return comboBox;
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) TraverseEvent(org.eclipse.swt.events.TraverseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 19 with TraverseEvent

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

the class IntegerCellEditor method createControl.

/**
     * Create the control.
     * 
     * @param table parent table
     */
private void createControl(JaretTable table) {
    if (_spinner == null) {
        _table = table;
        _spinner = new Spinner(table, SWT.BORDER);
        _spinner.setMaximum(_max);
        _spinner.setMinimum(_min);
        _spinner.addTraverseListener(new TraverseListener() {

            public void keyTraversed(TraverseEvent e) {
                e.doit = false;
            }
        });
        _spinner.addKeyListener(new KeyListener() {

            public void keyPressed(KeyEvent event) {
                if (event.keyCode == SWT.TAB) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                    _table.focusRight();
                } else if (event.keyCode == SWT.CR) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                    _table.focusDown();
                } else if (event.keyCode == SWT.ESC) {
                    event.doit = false;
                    stopEditing(false);
                    _column.setValue(_row, _oldVal);
                    _table.forceFocus();
                }
            }

            public void keyReleased(KeyEvent arg0) {
            }
        });
        _spinner.addFocusListener(this);
    }
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener) Spinner(org.eclipse.swt.widgets.Spinner) KeyListener(org.eclipse.swt.events.KeyListener)

Example 20 with TraverseEvent

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

the class Grid method initListeners.

/**
     * Initialize all listeners.
     */
private void initListeners() {
    disposeListener = new Listener() {

        public void handleEvent(Event e) {
            onDispose(e);
        }
    };
    addListener(SWT.Dispose, disposeListener);
    addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent e) {
            onPaint(e);
        }
    });
    addListener(SWT.Resize, new Listener() {

        public void handleEvent(Event e) {
            onResize();
        }
    });
    if (getVerticalBar() != null) {
        getVerticalBar().addListener(SWT.Selection, new Listener() {

            public void handleEvent(Event e) {
                onScrollSelection();
            }
        });
    }
    if (getHorizontalBar() != null) {
        getHorizontalBar().addListener(SWT.Selection, new Listener() {

            public void handleEvent(Event e) {
                onScrollSelection();
            }
        });
    }
    addListener(SWT.KeyDown, new Listener() {

        public void handleEvent(Event e) {
            onKeyDown(e);
        }
    });
    addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent e) {
            e.doit = true;
        }
    });
    addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent e) {
            onMouseDoubleClick(e);
        }

        public void mouseDown(MouseEvent e) {
            onMouseDown(e);
        }

        public void mouseUp(MouseEvent e) {
            onMouseUp(e);
        }
    });
    addMouseMoveListener(new MouseMoveListener() {

        public void mouseMove(MouseEvent e) {
            onMouseMove(e);
        }
    });
    addMouseTrackListener(new MouseTrackListener() {

        public void mouseEnter(MouseEvent e) {
        }

        public void mouseExit(MouseEvent e) {
            onMouseExit(e);
        }

        public void mouseHover(MouseEvent e) {
        }
    });
    addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
            onFocusIn();
            redraw();
        }

        public void focusLost(FocusEvent e) {
            redraw();
        }
    });
    // Special code to reflect mouse wheel events if using an external
    // scroller
    addListener(SWT.MouseWheel, new Listener() {

        public void handleEvent(Event e) {
            onMouseWheel(e);
        }
    });
}
Also used : MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) TraverseListener(org.eclipse.swt.events.TraverseListener) MouseListener(org.eclipse.swt.events.MouseListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) SelectionListener(org.eclipse.swt.events.SelectionListener) PaintListener(org.eclipse.swt.events.PaintListener) FocusListener(org.eclipse.swt.events.FocusListener) TypedListener(org.eclipse.swt.widgets.TypedListener) Listener(org.eclipse.swt.widgets.Listener) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) TreeListener(org.eclipse.swt.events.TreeListener) PaintEvent(org.eclipse.swt.events.PaintEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) MouseListener(org.eclipse.swt.events.MouseListener) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintListener(org.eclipse.swt.events.PaintListener) TraverseListener(org.eclipse.swt.events.TraverseListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) FocusEvent(org.eclipse.swt.events.FocusEvent) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent) Event(org.eclipse.swt.widgets.Event) AccessibleControlEvent(org.eclipse.swt.accessibility.AccessibleControlEvent) TreeEvent(org.eclipse.swt.events.TreeEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Aggregations

TraverseEvent (org.eclipse.swt.events.TraverseEvent)31 TraverseListener (org.eclipse.swt.events.TraverseListener)30 SelectionEvent (org.eclipse.swt.events.SelectionEvent)11 FocusEvent (org.eclipse.swt.events.FocusEvent)10 FocusAdapter (org.eclipse.swt.events.FocusAdapter)9 ModifyEvent (org.eclipse.swt.events.ModifyEvent)8 MouseEvent (org.eclipse.swt.events.MouseEvent)8 Point (org.eclipse.swt.graphics.Point)8 KeyEvent (org.eclipse.swt.events.KeyEvent)7 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)7 Button (org.eclipse.swt.widgets.Button)7 Text (org.eclipse.swt.widgets.Text)7 StyledText (org.eclipse.swt.custom.StyledText)6 ModifyListener (org.eclipse.swt.events.ModifyListener)6 Composite (org.eclipse.swt.widgets.Composite)6 MouseAdapter (org.eclipse.swt.events.MouseAdapter)5 Listener (org.eclipse.swt.widgets.Listener)5 GridData (org.eclipse.swt.layout.GridData)4 Label (org.eclipse.swt.widgets.Label)4 ComboWithEnableFix (edu.cmu.cs.hcii.cogtool.util.ComboWithEnableFix)3