use of org.eclipse.jface.text.BlockTextSelection in project eclipse.platform.text by eclipse.
the class SourceViewer method restoreSelection.
/**
* Restores a previously saved selection in the document.
* <p>
* If no selection was previously saved, nothing happens.
*
* @since 3.0
*/
protected void restoreSelection() {
if (!fSelections.isEmpty()) {
final IDocument document = getDocument();
final Position position = fSelections.pop();
try {
document.removePosition(fSelectionCategory, position);
Point currentSelection = getSelectedRange();
if (currentSelection == null || currentSelection.x != position.getOffset() || currentSelection.y != position.getLength()) {
if (position instanceof ColumnPosition && getTextWidget().getBlockSelection()) {
setSelection(new BlockTextSelection(document, document.getLineOfOffset(position.getOffset()), ((ColumnPosition) position).fStartColumn, document.getLineOfOffset(position.getOffset() + position.getLength()), ((ColumnPosition) position).fEndColumn, getTextWidget().getTabs()));
} else {
setSelectedRange(position.getOffset(), position.getLength());
}
}
if (fSelections.isEmpty())
clearRememberedSelection();
} catch (BadPositionCategoryException exception) {
// Should not happen
} catch (BadLocationException x) {
// Should not happen
}
}
}
Aggregations