use of net.sourceforge.nattable.widget.NatCombo 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;
}
Aggregations