use of org.talend.designer.xmlmap.ui.tabs.StyledTextHandler in project tdi-studio-se by Talend.
the class ExpressionCellEditor method highlightLineAndSetSelectionOfStyledTextFromTextControl.
protected void highlightLineAndSetSelectionOfStyledTextFromTextControl(final Control textWidget) {
final StyledTextHandler styledTextHandler = mapperManager.getMapperUI().getTabFolderEditors().getStyledTextHandler();
Runnable runnable = new Runnable() {
public void run() {
StyledText styledText = styledTextHandler.getStyledText();
if (styledText.isDisposed() || textWidget.isDisposed()) {
return;
}
String text = ControlUtils.getText(textWidget);
Point selection = ControlUtils.getSelection(textWidget);
String lineDelimiter = ControlUtils.getLineDelimiter(textWidget);
if (selection.x - 1 > 0) {
while (lineDelimiter.equals(text.charAt(selection.x - 1))) {
selection.x++;
}
}
if (selection.y - 1 > 0) {
while (lineDelimiter.equals(text.charAt(selection.y - 1))) {
selection.y++;
}
}
int length = styledText.getText().length();
if (selection.x < 0) {
selection.x = 0;
}
if (selection.x > length) {
selection.x = length;
}
if (selection.y < 0) {
selection.y = 0;
}
if (selection.y > length) {
selection.y = length;
}
styledText.setSelection(selection);
styledTextHandler.highlightLineOfCursorPosition(selection);
}
};
new AsynchronousThreading(50, true, parent.getDisplay(), runnable).start();
}
Aggregations