org.eclipse.xtext.ui.editor.ISourceViewerAware Java Examples
The following examples show how to use
org.eclipse.xtext.ui.editor.ISourceViewerAware.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: N4JSHyperlinkDetector.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Method copied from super class with only a minor change: call to "readOnly" changed to "tryReadOnly". */ @Override public IHyperlink[] detectHyperlinks(final ITextViewer textViewer, final IRegion region, final boolean canShowMultipleHyperlinks) { final IDocument xtextDocument = textViewer.getDocument(); if (!(xtextDocument instanceof N4JSDocument)) { return super.detectHyperlinks(textViewer, region, canShowMultipleHyperlinks); } final IHyperlinkHelper helper = getHelper(); return ((N4JSDocument) xtextDocument).tryReadOnly(new IUnitOfWork<IHyperlink[], XtextResource>() { @Override public IHyperlink[] exec(XtextResource resource) throws Exception { resource = tryConvertToFileResource(resource); if (resource == null) { return null; } if (helper instanceof ISourceViewerAware && textViewer instanceof ISourceViewer) { ((ISourceViewerAware) helper).setSourceViewer((ISourceViewer) textViewer); } return helper.createHyperlinksByOffset(resource, region.getOffset(), canShowMultipleHyperlinks); } }, (IHyperlink[]) null); }
Example #2
Source File: AbstractEditStrategyProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
public List<IAutoEditStrategy> getStrategies(final ISourceViewer sourceViewer,final String contentType) { final List<IAutoEditStrategy> strategies = Lists.newArrayList(); configure(new IEditStrategyAcceptor() { @Override public void accept(IAutoEditStrategy strategy, String type) { if (type == null || contentType.equals(type)) { if (strategy instanceof ISourceViewerAware) { ((ISourceViewerAware) strategy).setSourceViewer(sourceViewer); } if (strategy instanceof VerifyKeyListener) { sourceViewer.getTextWidget().addVerifyKeyListener((VerifyKeyListener) strategy); } strategies.add(strategy); } } }); return strategies; }
Example #3
Source File: XtextReconciler.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public void install(ITextViewer textViewer) { if (!isInstalled) { this.textViewer = textViewer; textInputListener = new TextInputListener(); textViewer.addTextInputListener(textInputListener); handleInputDocumentChanged(null, textViewer.getDocument()); if (textViewer instanceof ISourceViewerExtension4) { ContentAssistantFacade facade = ((ISourceViewerExtension4) textViewer).getContentAssistantFacade(); if (facade == null) { shouldInstallCompletionListener = true; } else { facade.addCompletionListener(documentListener); } if (strategy instanceof ISourceViewerAware) { ((ISourceViewerAware) strategy).setSourceViewer((ISourceViewer) textViewer); } } isInstalled = true; } }
Example #4
Source File: AbstractCompositeHover.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void setSourceViewer(ISourceViewer sourceViewer) { if (getHovers() != null) { for (ITextHover hover : getHovers()) { if (hover instanceof ISourceViewerAware) ((ISourceViewerAware) hover).setSourceViewer(sourceViewer); } } }
Example #5
Source File: DefaultHyperlinkDetector.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public IHyperlink[] detectHyperlinks(final ITextViewer textViewer, final IRegion region, final boolean canShowMultipleHyperlinks) { return xtextDocumentUtil.getXtextDocument(textViewer).tryReadOnly(new IUnitOfWork<IHyperlink[],XtextResource>() { @Override public IHyperlink[] exec(XtextResource resource) throws Exception { if (helper instanceof ISourceViewerAware && textViewer instanceof ISourceViewer) { ((ISourceViewerAware) helper).setSourceViewer((ISourceViewer) textViewer); } return helper.createHyperlinksByOffset(resource, region.getOffset(), canShowMultipleHyperlinks); } }); }
Example #6
Source File: DotHtmlLabelAdaptingTextHover.java From gef with Eclipse Public License 2.0 | 5 votes |
public DotHtmlLabelAdaptingTextHover() { IEObjectHover hover = injector.getInstance(IEObjectHover.class); if (hover instanceof ISourceViewerAware) { ((ISourceViewerAware) hover).setSourceViewer(sourceViewer); } this.hover = hover; }
Example #7
Source File: DotSourceViewerConfiguration.java From gef with Eclipse Public License 2.0 | 5 votes |
@Override public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { if (contentType.equals( DotTerminalsTokenTypeToPartitionMapper.HTML_STRING_PARTITION)) { ITextHover hover = htmlHoverProvider.get(); if (hover instanceof ISourceViewerAware) { ((ISourceViewerAware) hover).setSourceViewer(sourceViewer); } return hover; } return super.getTextHover(sourceViewer, contentType); }