use of org.eclipse.titan.designer.editors.configeditor.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 (targetEditor.getActiveEditor() != targetEditor.getEditor()) {
return;
}
if (!selection.isEmpty()) {
if (selection instanceof TextSelection) {
TextSelection tSelection = (TextSelection) selection;
if (tSelection.getLength() != 0) {
return;
}
}
}
ConfigTextEditor textEditor = targetEditor.getEditor();
IDocument document = textEditor.getDocument();
int carretOffset = textEditor.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;
}
textEditor.setCarretOffset(targetOffset);
textEditor.selectAndReveal(targetOffset, 0);
}
use of org.eclipse.titan.designer.editors.configeditor.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 ConfigEditor) {
this.targetEditor = (ConfigEditor) activeEditor;
} else {
this.targetEditor = null;
}
if (activeEditor == null) {
return null;
}
if (this.targetEditor.getActiveEditor() != this.targetEditor.getEditor()) {
return null;
}
if (!selection.isEmpty()) {
if (selection instanceof TextSelection) {
TextSelection tSelection = (TextSelection) selection;
if (tSelection.getLength() != 0) {
return null;
}
}
}
ConfigTextEditor textEditor = this.targetEditor.getEditor();
IDocument document = textEditor.getDocument();
int carretOffset = textEditor.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;
}
textEditor.setCarretOffset(targetOffset);
textEditor.selectAndReveal(targetOffset, 0);
return null;
}
Aggregations