protected ISourceViewer getSourceViewer(Shell shell, final IXtextDocument xtextDocument, XtextSourceViewerConfiguration configuration) { XtextSourceViewer.Factory factory = get(XtextSourceViewer.Factory.class); ISourceViewer sourceViewer = factory.createSourceViewer(shell, null, null, false, 0); sourceViewer.configure(configuration); sourceViewer.setDocument(xtextDocument); return sourceViewer; }
protected ISourceViewer getSourceViewer(Shell shell, final IXtextDocument xtextDocument, XtextSourceViewerConfiguration configuration) { XtextSourceViewer.Factory factory = get(XtextSourceViewer.Factory.class); ISourceViewer sourceViewer = factory.createSourceViewer(shell, null, null, false, 0); sourceViewer.configure(configuration); sourceViewer.setDocument(xtextDocument); return sourceViewer; }
/** Configures annotation model for spell checking. */ private void configureAsEditor(ISourceViewer viewer, Document document) { IAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess(); final SourceViewerDecorationSupport support = new SourceViewerDecorationSupport(viewer, null, annotationAccess, EditorsUI.getSharedTextColors()); Iterator<?> e = new MarkerAnnotationPreferences().getAnnotationPreferences().iterator(); while (e.hasNext()) { support.setAnnotationPreference((AnnotationPreference) e.next()); } support.install(EditorsUI.getPreferenceStore()); viewer.getTextWidget().addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { support.uninstall(); } }); AnnotationModel annotationModel = new AnnotationModel(); viewer.setDocument(document, annotationModel); }
@Override public void setInput(Object input) { documentProvider.disconnect(getInput()); super.setInput(input); if (input != null) { try { documentProvider.connect(input); sourceViewer.setDocument(documentProvider.getDocument(input)); } catch (CoreException coreException) { throw new WrappedException(coreException); } } }
@Override public void setInformation(String content) { super.setInformation(content); IDocument doc= getViewer().getDocument(); if (doc == null) return; // ensure that we can scroll enough ensureScrollable(); String start= null; if (IJavaPartitions.JAVA_DOC.equals(fPartition)) { start= "/**" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$ } else if (IJavaPartitions.JAVA_MULTI_LINE_COMMENT.equals(fPartition)) { start= "/*" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$ } if (start != null) { try { doc.replace(0, 0, start); int startLen= start.length(); getViewer().setDocument(doc, startLen, doc.getLength() - startLen); } catch (BadLocationException e) { // impossible Assert.isTrue(false); } } getViewer().getTextWidget().setHorizontalPixel(fHorizontalScrollPixel); }
public void setInformation(String content) { super.setInformation(content); IDocument doc= getViewer().getDocument(); if (doc == null) return; // ensure that we can scroll enough ensureScrollable(); String start= null; if (IJavaPartitions.JAVA_DOC.equals(fPartition)) { start= "/**" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$ } else if (IJavaPartitions.JAVA_MULTI_LINE_COMMENT.equals(fPartition)) { start= "/*" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$ } if (start != null) { try { doc.replace(0, 0, start); int startLen= start.length(); getViewer().setDocument(doc, startLen, doc.getLength() - startLen); } catch (BadLocationException e) { // impossible Assert.isTrue(false); } } getViewer().getTextWidget().setHorizontalPixel(fHorizontalScrollPixel); }
@Override public void setInformation(String content) { super.setInformation(content); IDocument doc= getViewer().getDocument(); if (doc == null) return; // ensure that we can scroll enough ensureScrollable(); String start= null; if (IJavaPartitions.JAVA_DOC.equals(fPartition)) { start= "/**" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$ } else if (IJavaPartitions.JAVA_MULTI_LINE_COMMENT.equals(fPartition)) { start= "/*" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$ } if (start != null) { try { doc.replace(0, 0, start); int startLen= start.length(); getViewer().setDocument(doc, startLen, doc.getLength() - startLen); } catch (BadLocationException e) { // impossible Assert.isTrue(false); } } getViewer().getTextWidget().setHorizontalPixel(fHorizontalScrollPixel); }
fSourceViewer.setDocument(document, model); fSourceViewer.setEditable(isEditable()); fSourceViewer.showAnnotations(model != null);
public void createPartControl(Composite parent) { super.createPartControl(parent); if(annotationModel != null) { if(annotationModel instanceof CompilationUnitAnnotationModelWrapper) { ((CompilationUnitAnnotationModelWrapper)annotationModel).setDelegate(getSourceViewer().getAnnotationModel()); } if(fGlobalAnnotationModelListener == null) { fGlobalAnnotationModelListener = new CompilationUnitAnnotationModelWrapper.GlobalAnnotationModelListener(); fGlobalAnnotationModelListener.addListener(JavaPlugin.getDefault().getProblemMarkerManager()); } annotationModel.addAnnotationModelListener(fGlobalAnnotationModelListener); IDocument document = getDocumentProvider().getDocument(getEditorInput()); ISourceViewer sourceViewer= getSourceViewer(); sourceViewer.setDocument(document, annotationModel); IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput()); if(model != null) { // this is null in a linked source folder due to an eclipse bug.. model.connect(document); } } }
/** * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument) */ public void setDocument( IDocument document ) { if ( sourceViewer.getAnnotationModel() == null ) { IAnnotationModel model = new AnnotationModel(); sourceViewer.setDocument( sourceViewer.getDocument(), model ); } // add annotation painter if ( paintManager == null && sourceViewer.getAnnotationModel() instanceof IAnnotationModelExtension ) { AnnotationPainter ap = new AnnotationPainter( sourceViewer, null ); ap.addAnnotationType( "DEFAULT" ); //$NON-NLS-1$ ap.setAnnotationTypeColor( "DEFAULT", BrowserCommonActivator.getDefault().getColor( new RGB( 255, 0, 0 ) ) ); //$NON-NLS-1$ sourceViewer.getAnnotationModel().addAnnotationModelListener( ap ); FilterCharacterPairMatcher cpm = new FilterCharacterPairMatcher( sourceViewer, parser ); MatchingCharacterPainter mcp = new MatchingCharacterPainter( sourceViewer, cpm ); mcp.setColor( BrowserCommonActivator.getDefault().getColor( new RGB( 159, 159, 159 ) ) ); paintManager = new PaintManager( sourceViewer ); paintManager.addPainter( ap ); paintManager.addPainter( mcp ); } }
fSourceViewer.setDocument(document, model); fSourceViewer.setEditable(isEditable()); fSourceViewer.showAnnotations(model != null);
fSourceViewer.setDocument(document, model); fSourceViewer.setEditable(isEditable()); fSourceViewer.showAnnotations(model != null);
getSourceViewer().setDocument((AnnotationDocument) getDocument(), getDocumentProvider().getAnnotationModel(getEditorInput())); getSourceViewer().invalidateTextPresentation();