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);
}
});
}
use of org.eclipse.swt.events.TraverseEvent in project cubrid-manager by CUBRID.
the class FavoriteQueryNavigatorView method focusCell.
public void focusCell(final TableItem item, final int row, final int col) {
final StyledText text = new StyledText(tv.getTable(), SWT.SINGLE);
Listener textListener = new TableItemEditor(text, item, row, col);
text.addListener(SWT.FocusOut, textListener);
text.addListener(SWT.Traverse, textListener);
text.addListener(SWT.FocusIn, textListener);
text.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
e.doit = false;
int newColumn = col == 0 ? 1 : 0;
focusCell(item, row, newColumn);
} else if (e.detail == SWT.TRAVERSE_RETURN) {
e.doit = false;
addButton.setFocus();
}
}
});
text.setEditable(true);
editor.setEditor(text, item, col);
text.setText(item.getText(col));
text.selectAll();
try {
text.setFocus();
} catch (Exception e) {
}
}
use of org.eclipse.swt.events.TraverseEvent in project cubrid-manager by CUBRID.
the class ProductInfoDialog method addListeners.
/**
* Adds listeners to the given styled text
*
* @param styledText the StyledText object
*/
protected void addListeners(StyledText styledText) {
styledText.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent event) {
if (event.button != 1) {
return;
}
mouseDown = true;
}
public void mouseUp(MouseEvent event) {
mouseDown = false;
StyledText text = (StyledText) event.widget;
int offset = text.getCaretOffset();
if (dragEvent) {
// don't activate a link during a drag/mouse up operation
dragEvent = false;
if (item != null && item.isLinkAt(offset)) {
text.setCursor(handCursor);
}
} else if (item != null && item.isLinkAt(offset)) {
text.setCursor(busyCursor);
String url = item.getLinkAt(offset);
if (StringUtil.isEmpty(url)) {
LOGGER.warn("The url is a null or empty string : {}.", url);
} else {
openLink(url);
}
StyleRange selectionRange = getCurrentRange(text);
if (selectionRange == null) {
LOGGER.warn("The selectionRange is a null.");
} else {
text.setSelectionRange(selectionRange.start, selectionRange.length);
text.setCursor(null);
}
}
}
});
styledText.addMouseMoveListener(new MouseMoveListener() {
public void mouseMove(MouseEvent event) {
if (mouseDown) {
if (!dragEvent) {
StyledText text = (StyledText) event.widget;
text.setCursor(null);
}
dragEvent = true;
return;
}
StyledText text = (StyledText) event.widget;
int offset = -1;
try {
offset = text.getOffsetAtLocation(new Point(event.x, event.y));
} catch (IllegalArgumentException ex) {
offset = -1;
}
if (offset == -1) {
text.setCursor(null);
} else if (item != null && item.isLinkAt(offset)) {
text.setCursor(handCursor);
} else {
text.setCursor(null);
}
}
});
styledText.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent event) {
StyledText text = (StyledText) event.widget;
switch(event.detail) {
case SWT.TRAVERSE_ESCAPE:
event.doit = true;
break;
case SWT.TRAVERSE_TAB_NEXT:
// Previously traverse out in the backward direction?
Point nextSelection = text.getSelection();
int charCount = text.getCharCount();
if ((nextSelection.x == charCount) && (nextSelection.y == charCount)) {
text.setSelection(0);
}
StyleRange nextRange = findNextRange(text);
if (nextRange == null) {
// Next time in start at beginning, also used by
// TRAVERSE_TAB_PREVIOUS to indicate we traversed out
// in the forward direction
text.setSelection(0);
event.doit = true;
} else {
text.setSelectionRange(nextRange.start, nextRange.length);
event.doit = true;
event.detail = SWT.TRAVERSE_NONE;
}
break;
case SWT.TRAVERSE_TAB_PREVIOUS:
// Previously traverse out in the forward direction?
Point previousSelection = text.getSelection();
if ((previousSelection.x == 0) && (previousSelection.y == 0)) {
text.setSelection(text.getCharCount());
}
StyleRange previousRange = findPreviousRange(text);
if (previousRange == null) {
// Next time in start at the end, also used by
// TRAVERSE_TAB_NEXT to indicate we traversed out
// in the backward direction
text.setSelection(text.getCharCount());
event.doit = true;
} else {
text.setSelectionRange(previousRange.start, previousRange.length);
event.doit = true;
event.detail = SWT.TRAVERSE_NONE;
}
break;
default:
break;
}
}
});
// Listen for Tab and Space to allow keyboard navigation
styledText.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
StyledText text = (StyledText) event.widget;
if (event.character == ' ' || event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
if (item == null) {
LOGGER.warn("AboutItem is a null.");
return;
}
// Be sure we are in the selection
int offset = text.getSelection().x + 1;
if (item.isLinkAt(offset)) {
text.setCursor(busyCursor);
String url = item.getLinkAt(offset);
if (StringUtil.isEmpty(url)) {
LOGGER.warn("The url is a null or empty string : {}.", url);
} else {
openLink(url);
}
StyleRange selectionRange = getCurrentRange(text);
if (selectionRange == null) {
LOGGER.warn("The selectionRange is a null.");
} else {
text.setSelectionRange(selectionRange.start, selectionRange.length);
text.setCursor(null);
}
}
}
}
});
}
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;
}
use of org.eclipse.swt.events.TraverseEvent in project cubrid-manager by CUBRID.
the class BatchRunComposite method focusCell.
public void focusCell(final TableItem item, final int row, final int col) {
final StyledText text = new StyledText(tv.getTable(), SWT.SINGLE);
Listener textListener = new TableItemEditor(text, item, row, col);
text.addListener(SWT.FocusOut, textListener);
text.addListener(SWT.Traverse, textListener);
text.addListener(SWT.FocusIn, textListener);
text.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
e.doit = false;
int newColumn = col == 0 ? 1 : 0;
focusCell(item, row, newColumn);
} else if (e.detail == SWT.TRAVERSE_RETURN) {
e.doit = false;
addButton.setFocus();
}
}
});
text.setEditable(true);
editor.setEditor(text, item, col);
text.setText(item.getText(col));
text.selectAll();
try {
text.setFocus();
} catch (Exception e) {
}
}
Aggregations