Search in sources :

Example 46 with KeyEvent

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

the class TermBaseSearchDialog method initListener.

/**
	 * 初始化各控件的监听 ;
	 */
private void initListener() {
    // 当点击添加/删除语言按钮时,菜单要显示在按钮下方
    btnSelectLang.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            Rectangle rect = btnSelectLang.getBounds();
            // Point pt = selLangBar.toDisplay(new Point(event.x + rect.width, event.y + rect.height));
            // menu.setOrientation(SWT.RIGHT_TO_LEFT);
            Point pt = btnSelectLang.toDisplay(new Point(event.x, event.y + rect.height));
            menu.setLocation(pt.x, pt.y);
            menu.setVisible(true);
        }
    });
    btnApplyRegularExpression.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    btnSearch.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    cmbSearch.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            if (e.character == SWT.CR) {
                search();
            }
        }

        public void keyReleased(KeyEvent e) {
        }
    });
    /**
		 * 添加双击插入术语到编辑区
		 */
    grid.addListener(SWT.MouseDoubleClick, new Listener() {

        public void handleEvent(Event event) {
            // TODO Auto-generated method stub
            InsertGridTgtToEditor();
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) DisposeListener(org.eclipse.swt.events.DisposeListener) SelectionListener(org.eclipse.swt.events.SelectionListener) Listener(org.eclipse.swt.widgets.Listener) KeyListener(org.eclipse.swt.events.KeyListener) Rectangle(org.eclipse.swt.graphics.Rectangle) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) KeyListener(org.eclipse.swt.events.KeyListener) Point(org.eclipse.swt.graphics.Point) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 47 with KeyEvent

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

the class ComboBoxCellEditor method activateCell.

@Override
protected Control activateCell(Composite parent, Object originalCanonicalValue, Character initialEditValue) {
    this.originalCanonicalValue = originalCanonicalValue;
    combo = new NatCombo(parent, getCellStyle(), maxVisibleItems);
    combo.setItems(getDisplayValues());
    if (originalCanonicalValue != null) {
        combo.setSelection(new String[] { getDisplayValue() });
    }
    combo.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent event) {
            if ((event.keyCode == SWT.CR && event.stateMask == 0) || (event.keyCode == SWT.KEYPAD_CR && event.stateMask == 0)) {
                commit(MoveDirectionEnum.NONE);
            } else if (event.keyCode == SWT.ESC && event.stateMask == 0) {
                close();
            }
        }
    });
    combo.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent event) {
            if (event.keyCode == SWT.TAB && event.stateMask == SWT.SHIFT) {
                commit(MoveDirectionEnum.LEFT);
            } else if (event.keyCode == SWT.TAB && event.stateMask == 0) {
                commit(MoveDirectionEnum.RIGHT);
            }
        }
    });
    combo.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            commit(MoveDirectionEnum.NONE);
        }
    });
    return combo;
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) NatCombo(net.sourceforge.nattable.widget.NatCombo) TraverseEvent(org.eclipse.swt.events.TraverseEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter)

Example 48 with KeyEvent

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

the class TextCellEditor method createTextControl.

protected Text createTextControl(Composite parent) {
    IStyle cellStyle = getCellStyle();
    final Text textControl = new Text(parent, HorizontalAlignmentEnum.getSWTStyle(cellStyle));
    textControl.setBackground(cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
    textControl.setForeground(cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
    textControl.setFont(cellStyle.getAttributeValue(CellStyleAttributes.FONT));
    textControl.addKeyListener(new KeyAdapter() {

        private final Color originalColor = textControl.getForeground();

        @Override
        public void keyReleased(KeyEvent e) {
            if (!validateCanonicalValue()) {
                textControl.setForeground(GUIHelper.COLOR_RED);
            } else {
                textControl.setForeground(originalColor);
            }
        }

        ;
    });
    return textControl;
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) IStyle(net.sourceforge.nattable.style.IStyle) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Color(org.eclipse.swt.graphics.Color) Text(org.eclipse.swt.widgets.Text)

Example 49 with KeyEvent

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

the class QAResultViewPart method createTable.

public void createTable() {
    table = new KTable(parent, SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWTX.FILL_WITH_LASTCOL | SWT.WRAP);
    tableModel = new KtableModel();
    table.setModel(tableModel);
    table.setLayoutData(new GridData(GridData.FILL_BOTH));
    table.setColorRightBorder(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    table.setColorLeftBorder(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    table.setColorTopBorder(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    table.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            locationRow();
        }
    });
    table.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            if (e.keyCode == QAConstant.QA_CENTERKEY_1 || e.keyCode == QAConstant.QA_CENTERKEY_2) {
                locationRow();
            }
        }
    });
    table.addCellResizeListener(new KTableCellResizeListener() {

        public void rowResized(int arg0, int arg1) {
            tableModel.textRenderer.clearRowHeiMap();
            table.redraw();
        }

        public void columnResized(int arg0, int arg1) {
            tableModel.textRenderer.clearRowHeiMap();
            table.redraw();
        }
    });
    table.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            tableModel.textRenderer.clearRowHeiMap();
            table.redraw();
        }
    });
    table.addMouseWheelListener(new MouseWheelListener() {

        public void mouseScrolled(MouseEvent e) {
            tableModel.textRenderer.clearRowHeiMap();
            table.redraw();
        }
    });
    createPropMenu();
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) KTableCellResizeListener(de.kupzog.ktable.KTableCellResizeListener) ControlAdapter(org.eclipse.swt.events.ControlAdapter) KeyAdapter(org.eclipse.swt.events.KeyAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) MouseWheelListener(org.eclipse.swt.events.MouseWheelListener) KTable(de.kupzog.ktable.KTable) Point(org.eclipse.swt.graphics.Point) KeyEvent(org.eclipse.swt.events.KeyEvent) GridData(org.eclipse.swt.layout.GridData) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 50 with KeyEvent

use of org.eclipse.swt.events.KeyEvent 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)

Aggregations

KeyEvent (org.eclipse.swt.events.KeyEvent)98 KeyAdapter (org.eclipse.swt.events.KeyAdapter)63 GridData (org.eclipse.swt.layout.GridData)54 GridLayout (org.eclipse.swt.layout.GridLayout)42 Composite (org.eclipse.swt.widgets.Composite)42 SelectionEvent (org.eclipse.swt.events.SelectionEvent)41 Text (org.eclipse.swt.widgets.Text)34 KeyListener (org.eclipse.swt.events.KeyListener)32 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)32 Label (org.eclipse.swt.widgets.Label)29 ModifyEvent (org.eclipse.swt.events.ModifyEvent)22 ModifyListener (org.eclipse.swt.events.ModifyListener)22 Point (org.eclipse.swt.graphics.Point)21 Button (org.eclipse.swt.widgets.Button)21 MouseEvent (org.eclipse.swt.events.MouseEvent)20 TableViewer (org.eclipse.jface.viewers.TableViewer)19 StyledText (org.eclipse.swt.custom.StyledText)13 FocusEvent (org.eclipse.swt.events.FocusEvent)13 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)12 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)12