use of net.sourceforge.ehep.events.CursorKeyListener in project core by jcryptool.
the class HexEditorControl method addCursorListeners.
/**
* Adds some cursor listeners
* @param cursor table cursor
* @param editor table editor
*/
private void addCursorListeners(final TableCursor cursor, final ControlEditor editor) {
//
// Add key listener
//
cursorKeyListener = new CursorKeyListener(this, hexEditor, cursor, editor);
cursor.addKeyListener(cursorKeyListener);
//
// Add selection listener
//
cursor.addSelectionListener(new SelectionAdapter() {
//
// When the TableEditor is over a cell, select the corresponding row in the table
//
public void widgetSelected(SelectionEvent e) {
//
if (cursorKeyListener.getText() != null) {
String str = cursorKeyListener.getText().getText().toUpperCase();
if (Utils.isValidHexNumber(str)) {
cursorKeyListener.getCellEditorKeyListener().closeCellEditor(cursorKeyListener.getEventRow(), cursorKeyListener.getEventColumn(), str);
} else {
cursorKeyListener.setSelection();
return;
}
}
table.setSelection(new TableItem[] { cursor.getRow() });
HexTablePointer p = getCursorPosition();
table.setCellSelection(p.getRowIndex(), p.getColumnIndex(), cursorKeyListener.isShiftHold());
updateStatusPanel();
}
//
// When the user hits "ENTER" in the TableCursor, pop up a text editor so that
// they can change the text of the cell
//
public void widgetDefaultSelected(SelectionEvent e) {
table.setSelection(new TableItem[] { cursor.getRow() });
}
});
}
Aggregations