use of org.eclipse.titan.designer.editors.asn1editor.PairMatcher in project titan.EclipsePlug-ins by eclipse.
the class GotoMatchingBracketAction method run.
@Override
public final void run(final IAction action) {
if (targetEditor == null) {
return;
}
if (!selection.isEmpty()) {
if (selection instanceof TextSelection) {
TextSelection tSelection = (TextSelection) selection;
if (tSelection.getLength() != 0) {
return;
}
}
}
IDocument document = targetEditor.getDocument();
int carretOffset = targetEditor.getCarretOffset();
PairMatcher pairMatcher = new PairMatcher();
IRegion region = pairMatcher.match(document, carretOffset);
if (region == null) {
return;
}
int targetOffset;
if (region.getOffset() + 1 == carretOffset) {
targetOffset = region.getOffset() + region.getLength();
} else {
targetOffset = region.getOffset() + 1;
}
targetEditor.setCarretOffset(targetOffset);
targetEditor.selectAndReveal(targetOffset, 0);
}
use of org.eclipse.titan.designer.editors.asn1editor.PairMatcher in project titan.EclipsePlug-ins by eclipse.
the class GotoMatchingBracketAction method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (activeEditor instanceof ASN1Editor) {
this.targetEditor = (ASN1Editor) activeEditor;
} else {
this.targetEditor = null;
}
if (activeEditor == null) {
return null;
}
if (!selection.isEmpty()) {
if (selection instanceof TextSelection) {
TextSelection tSelection = (TextSelection) selection;
if (tSelection.getLength() != 0) {
return null;
}
}
}
IDocument document = this.targetEditor.getDocument();
int carretOffset = this.targetEditor.getCarretOffset();
PairMatcher pairMatcher = new PairMatcher();
IRegion region = pairMatcher.match(document, carretOffset);
if (region == null) {
return null;
}
int targetOffset;
if (region.getOffset() + 1 == carretOffset) {
targetOffset = region.getOffset() + region.getLength();
} else {
targetOffset = region.getOffset() + 1;
}
this.targetEditor.setCarretOffset(targetOffset);
this.targetEditor.selectAndReveal(targetOffset, 0);
return null;
}
Aggregations