Package xvrengine.editors

Source Code of xvrengine.editors.XVRConfiguration

package xvrengine.editors;

import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.presentation.PresentationReconciler;
import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;

public class XVRConfiguration extends SourceViewerConfiguration {
  private XVRScanner xvrScanner;
  private ColorManager colorManager;

  public XVRConfiguration(ColorManager colorManager) {
    this.colorManager = colorManager;
  }
  public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
    return new String[] {
      IDocument.DEFAULT_CONTENT_TYPE,
      XVRPartitionScanner.COMMENT,
      XVRPartitionScanner.PREPROCESSOR};
  }

  protected XVRScanner getXVRScanner(){
    if(xvrScanner == null){
      xvrScanner = new XVRScanner(colorManager);
      xvrScanner.setDefaultReturnToken(new Token(new TextAttribute(colorManager.getColor(IXVRColorConstants.DEFAULT))));
    }
    return xvrScanner;
  }
 
  public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
    PresentationReconciler reconciler = new PresentationReconciler();

    NonRuleBasedDamagerRepairer ndr = new NonRuleBasedDamagerRepairer(new TextAttribute(colorManager.getColor(IXVRColorConstants.COMMENT)));
    reconciler.setDamager(ndr, XVRPartitionScanner.COMMENT);
    reconciler.setRepairer(ndr, XVRPartitionScanner.COMMENT);
   
    NonRuleBasedDamagerRepairer pp = new NonRuleBasedDamagerRepairer(new TextAttribute(colorManager.getColor(IXVRColorConstants.PREPROCESSOR)));
    reconciler.setDamager(pp, XVRPartitionScanner.PREPROCESSOR);
    reconciler.setRepairer(pp, XVRPartitionScanner.PREPROCESSOR);
   
    DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getXVRScanner());
    reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
    reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);

    return reconciler;
  }

}
TOP

Related Classes of xvrengine.editors.XVRConfiguration

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.