use of org.eclipse.jface.text.ITextViewer in project xtext-eclipse by eclipse.
the class TextViewerMoveLinesAction method beginCompoundEdit.
/**
* Ends the compound change.
*/
private void beginCompoundEdit() {
ITextViewer viewer = getTextViewer();
if (fEditInProgress || viewer == null || !(viewer instanceof ITextViewerExtension))
return;
fEditInProgress = true;
fStrategy.arm(viewer);
IRewriteTarget target = ((ITextViewerExtension) viewer).getRewriteTarget();
if (target != null) {
target.beginCompoundChange();
}
}
use of org.eclipse.jface.text.ITextViewer in project xtext-eclipse by eclipse.
the class TextViewerMoveLinesAction method endCompoundEdit.
/**
* Ends the compound change.
*/
private void endCompoundEdit() {
ITextViewer viewer = getTextViewer();
if (!fEditInProgress || viewer == null || !(viewer instanceof ITextViewerExtension))
return;
IRewriteTarget target = ((ITextViewerExtension) viewer).getRewriteTarget();
if (target != null) {
target.endCompoundChange();
}
fEditInProgress = false;
}
use of org.eclipse.jface.text.ITextViewer in project xtext-eclipse by eclipse.
the class CrossReferenceProposalTest method testBug276742_09b.
@Test
public void testBug276742_09b() throws Exception {
String modelAsString = "Foo {}";
ContentAssistProcessorTestBuilder builder = newBuilder();
XtextContentAssistProcessor processor = get(XtextContentAssistProcessor.class);
XtextResource resource = getResourceFromString(modelAsString);
ITextViewer viewer = builder.getSourceViewer(modelAsString, builder.getDocument(resource, modelAsString));
ContentAssistContext[] contexts = processor.getContextFactory().create(viewer, 0, resource);
assertEquals(1, contexts.length);
for (ContentAssistContext context : contexts) {
assertEquals(CrossReferenceProposalTestPackage.Literals.MODEL, context.getCurrentModel().eClass());
}
}
use of org.eclipse.jface.text.ITextViewer in project xtext-eclipse by eclipse.
the class XtextSourceViewerConfiguration method getHyperlinkDetectors.
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
List<IHyperlinkDetector> detectors = new LinkedList<IHyperlinkDetector>();
IHyperlinkDetector[] inheritedDetectors = super.getHyperlinkDetectors(sourceViewer);
if (inheritedDetectors != null) {
for (final IHyperlinkDetector detector : inheritedDetectors) {
detectors.add(new IHyperlinkDetector() {
@Override
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
try {
IHyperlink[] result = detector.detectHyperlinks(textViewer, region, canShowMultipleHyperlinks);
// but null (see org.eclipse.jface.text.hyperlink.HyperlinkManager.findHyperlinks(IRegion))
if (result != null && result.length == 0) {
return null;
}
return result;
} catch (Throwable e) {
// fail safe hyperlink detector - prevent others
// from failing
}
return null;
}
});
}
}
detectors.add(detector);
return detectors.toArray(new IHyperlinkDetector[detectors.size()]);
}
use of org.eclipse.jface.text.ITextViewer in project dbeaver by serge-rider.
the class ToggleBreakpointHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
if (activeEditor != null) {
SQLEditorBase sqlEditor = activeEditor.getAdapter(SQLEditorBase.class);
if (sqlEditor != null) {
ITextViewer textViewer = sqlEditor.getAdapter(ITextViewer.class);
if (textViewer != null) {
IVerticalRulerInfo rulerInfo = sqlEditor.getAdapter(IVerticalRulerInfo.class);
ToggleBreakpointAction action = new ToggleBreakpointAction(sqlEditor, textViewer.getDocument(), rulerInfo);
action.runWithEvent(new Event());
}
}
}
return null;
}
Aggregations