Java Code Examples for org.eclipse.jface.text.source.ISourceViewer#invalidateTextPresentation()

The following examples show how to use org.eclipse.jface.text.source.ISourceViewer#invalidateTextPresentation() . 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: ModulaEditor.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
/**
    * Recomputes partitioning and refreshes editor, in case there are disabled code regions.
    * 
    * @param ast
    */
   private void repartitionAndRefresh(final ModulaAst ast) 
   {
   	InactiveCodeRefresher inactiveCodeRefresher = new InactiveCodeRefresher(ast, new ITextPresentation() {
		@Override
		public boolean isDisposed() {
			return ModulaEditor.this.isDisposed();
		}
		
		@Override
		public void invalidateTextPresentation() {
			ISourceViewer sourceViewer = ModulaEditor.this.getSourceViewer();
			if (sourceViewer != null) {
				sourceViewer.invalidateTextPresentation();
			}
		}
	}, () -> getEditorDocument(this));
   	inactiveCodeRefresher.refresh();
}
 
Example 2
Source File: XtextEditor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
	ISourceViewer sourceViewer = getSourceViewer();
	if (sourceViewer == null || sourceViewer.getTextWidget() == null)
		return;
	super.handlePreferenceStoreChanged(event);
	

	boolean tokenStyleChanged = event.getProperty().contains(".syntaxColorer.tokenStyles");
	if (tokenStyleChanged) {
		textAttributeProvider.propertyChange(event);
		initializeViewerColors(sourceViewer);
		sourceViewer.invalidateTextPresentation();
	}
}
 
Example 3
Source File: AbstractSimpleLangSourceViewerConfiguration.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected void setupPresentationReconciler(PresentationReconciler reconciler, ISourceViewer sourceViewer) {
	// Must be called from UI thread
	assertTrue(Display.getCurrent() != null);
	
	// Create a token registry for given sourceViewer
	TokenRegistry tokenRegistry = new TokenRegistry(colorManager, stylingPrefs) {
		@Override
		protected void handleTokenModified(Token token) {
			sourceViewer.invalidateTextPresentation();
		}
	};
	addConfigurationScopedOwned(sourceViewer, tokenRegistry);
	
	ArrayList2<AbstractLangScanner> scanners = new ArrayList2<>();
	
	for(LangPartitionTypes partitionType : getPartitionTypes()) {
		
		String contentType = partitionType.getId();
		AbstractLangScanner scanner = createScannerFor(Display.getCurrent(), partitionType, tokenRegistry);
		scanners.add(scanner);
		
		DefaultDamagerRepairer dr = getDamagerRepairer(scanner, contentType);
		reconciler.setDamager(dr, contentType);
		reconciler.setRepairer(dr, contentType);
	}
	
}
 
Example 4
Source File: AbstractLangBasicSourceViewerConfiguration.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected void setupPresentationReconciler(PresentationReconciler reconciler, ISourceViewer sourceViewer) {
	// Must be called from UI thread
	assertTrue(Display.getCurrent() != null);
	
	// Create a token registry for given sourceViewer
	TokenRegistry tokenRegistry = new TokenRegistry(colorManager, stylingPrefs) {
		@Override
		protected void handleTokenModified(Token token) {
			sourceViewer.invalidateTextPresentation();
		}
	};
	addConfigurationScopedOwned(sourceViewer, tokenRegistry);
	
	ArrayList2<AbstractLangScanner> scanners = new ArrayList2<>();
	
	for(LangPartitionTypes partitionType : getPartitionTypes()) {
		
		String contentType = partitionType.getId();
		AbstractLangScanner scanner = createScannerFor(Display.getCurrent(), partitionType, tokenRegistry);
		scanners.add(scanner);
		
		DefaultDamagerRepairer dr = getDamagerRepairer(scanner, contentType);
		reconciler.setDamager(dr, contentType);
		reconciler.setRepairer(dr, contentType);
	}
	
}