/******************************************************************************* | |
* Copyright (c) 2004-2008 Istvan Rath and Daniel Varro | |
* All rights reserved. This program and the accompanying materials | |
* are made available under the terms of the Eclipse Public License v1.0 | |
* which accompanies this distribution, and is available at | |
* http://www.eclipse.org/legal/epl-v10.html | |
* | |
* Contributors: | |
* Istvan Rath - initial API and implementation | |
*******************************************************************************/ | |
package org.eclipse.viatra2.editor.text.light.vtml; | |
import org.eclipse.viatra2.editor.text.Activator; | |
import org.eclipse.viatra2.editor.text.light.IVTEConstants; | |
import org.eclipse.viatra2.editor.text.light.VTEAutoIndentStrategy; | |
import org.eclipse.viatra2.editor.text.light.VTEColorProvider; | |
import org.eclipse.viatra2.editor.text.light.VTEColorToken; | |
import org.eclipse.jface.text.IAutoEditStrategy; | |
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; | |
import org.eclipse.swt.SWT; | |
public class VTMLConfiguration extends SourceViewerConfiguration | |
{ | |
private VTMLCodeScanner iCodeScanner = null; | |
private VTEColorProvider iColorProvider = null; | |
private VTEColorToken iColorToken = null; | |
@SuppressWarnings("static-access") | |
public VTMLConfiguration(VTEColorProvider cm) | |
{ | |
iColorProvider = cm; | |
iColorProvider.initializeDefaults(Activator.getDefault().getPreferenceStore()); | |
iColorToken = new VTEColorToken(); | |
iColorToken.COMMENT = new Token(new TextAttribute(iColorProvider.getColor(IVTEConstants.COMMENT))); | |
iColorToken.KEYWORD = new Token(new TextAttribute(iColorProvider.getColor(IVTEConstants.KEYWORD),null,SWT.BOLD)); | |
iColorToken.STRING = new Token(new TextAttribute(iColorProvider.getColor(IVTEConstants.STRING))); | |
iColorToken.OTHER = new Token(new TextAttribute(iColorProvider.getColor(IVTEConstants.DEFAULT))); | |
iCodeScanner = new VTMLCodeScanner(iColorProvider,iColorToken); | |
} | |
/** | |
* Define reconciler for VTMLEditor | |
*/ | |
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) { | |
PresentationReconciler reconciler = new PresentationReconciler(); | |
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(iCodeScanner); | |
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); | |
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE); | |
return reconciler; | |
} | |
@Override | |
public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) | |
{ | |
return new IAutoEditStrategy[]{new VTEAutoIndentStrategy()}; | |
} | |
} |