/** * <copyright> * </copyright> * * */ package org.reuseware.air.language.abstractsyntax.resource.as.ui; /** * This class provides the configuration for the generated editor. It registers * content assistance and syntax highlighting. */ public class AsEditorConfiguration extends org.eclipse.jface.text.source.SourceViewerConfiguration { private org.reuseware.air.language.abstractsyntax.resource.as.ui.AsColorManager colorManager; private org.reuseware.air.language.abstractsyntax.resource.as.ui.AsEditor theEditor; /** * Creates a new editor configuration. * * @param editor the editor to configure * @param colorManager the color manager to use */ public AsEditorConfiguration(org.reuseware.air.language.abstractsyntax.resource.as.ui.AsEditor editor, org.reuseware.air.language.abstractsyntax.resource.as.ui.AsColorManager colorManager) { this.theEditor = editor; this.colorManager = colorManager; } public org.eclipse.jface.text.contentassist.IContentAssistant getContentAssistant(org.eclipse.jface.text.source.ISourceViewer sourceViewer) { org.eclipse.jface.text.contentassist.ContentAssistant assistant = new org.eclipse.jface.text.contentassist.ContentAssistant(); assistant.setContentAssistProcessor(new org.reuseware.air.language.abstractsyntax.resource.as.ui.AsCompletionProcessor(theEditor), org.eclipse.jface.text.IDocument.DEFAULT_CONTENT_TYPE); assistant.enableAutoActivation(true); assistant.setAutoActivationDelay(500); assistant.setProposalPopupOrientation(org.eclipse.jface.text.contentassist.IContentAssistant.PROPOSAL_OVERLAY); assistant.setContextInformationPopupOrientation(org.eclipse.jface.text.contentassist.IContentAssistant.CONTEXT_INFO_ABOVE); return assistant; } public String[] getConfiguredContentTypes(org.eclipse.jface.text.source.ISourceViewer sourceViewer) { return new String[] { org.eclipse.jface.text.IDocument.DEFAULT_CONTENT_TYPE, }; } protected org.eclipse.jface.text.rules.ITokenScanner getScanner(String fileName) { return new org.reuseware.air.language.abstractsyntax.resource.as.ui.AsTokenScanner(colorManager); } public org.eclipse.jface.text.presentation.IPresentationReconciler getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer sourceViewer) { org.eclipse.jface.text.presentation.PresentationReconciler reconciler = new org.eclipse.jface.text.presentation.PresentationReconciler(); String fileName = theEditor.getEditorInput().getName(); org.eclipse.jface.text.rules.DefaultDamagerRepairer repairer = new org.eclipse.jface.text.rules.DefaultDamagerRepairer(getScanner(fileName)); reconciler.setDamager(repairer, org.eclipse.jface.text.IDocument.DEFAULT_CONTENT_TYPE); reconciler.setRepairer(repairer, org.eclipse.jface.text.IDocument.DEFAULT_CONTENT_TYPE); return reconciler; } public org.eclipse.jface.text.source.IAnnotationHover getAnnotationHover(org.eclipse.jface.text.source.ISourceViewer sourceViewer) { return new org.eclipse.jface.text.source.DefaultAnnotationHover(); } public org.eclipse.jface.text.ITextHover getTextHover(org.eclipse.jface.text.source.ISourceViewer sourceViewer, String contentType) { return new org.reuseware.air.language.abstractsyntax.resource.as.ui.AsTextHover(theEditor); } public org.eclipse.jface.text.hyperlink.IHyperlinkDetector[] getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer sourceViewer) { if (sourceViewer == null) { return null; } return new org.eclipse.jface.text.hyperlink.IHyperlinkDetector[] { new org.reuseware.air.language.abstractsyntax.resource.as.ui.AsHyperlinkDetector(theEditor.getResource()) }; } }