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();
}
});
}
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;
}
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;
}
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();
}
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;
}
});
}
}
Aggregations