1 20 package org.apache.directory.ldapstudio.aciitemeditor.sourceeditor; 21 22 23 import org.apache.directory.ldapstudio.aciitemeditor.Activator; 24 import org.eclipse.jface.text.IDocument; 25 import org.eclipse.jface.text.contentassist.ContentAssistant; 26 import org.eclipse.jface.text.contentassist.IContentAssistProcessor; 27 import org.eclipse.jface.text.contentassist.IContentAssistant; 28 import org.eclipse.jface.text.formatter.ContentFormatter; 29 import org.eclipse.jface.text.formatter.IContentFormatter; 30 import org.eclipse.jface.text.formatter.IFormattingStrategy; 31 import org.eclipse.jface.text.presentation.IPresentationReconciler; 32 import org.eclipse.jface.text.presentation.PresentationReconciler; 33 import org.eclipse.jface.text.rules.DefaultDamagerRepairer; 34 import org.eclipse.jface.text.source.ISourceViewer; 35 import org.eclipse.jface.text.source.SourceViewerConfiguration; 36 37 38 44 public class ACISourceViewerConfiguration extends SourceViewerConfiguration 45 { 46 49 public IPresentationReconciler getPresentationReconciler( ISourceViewer sourceViewer ) 50 { 51 PresentationReconciler reconciler = new PresentationReconciler(); 52 reconciler.setDocumentPartitioning( getConfiguredDocumentPartitioning( sourceViewer ) ); 53 54 DefaultDamagerRepairer dr = new DefaultDamagerRepairer( Activator.getDefault().getAciCodeScanner() ); 56 reconciler.setDamager( dr, IDocument.DEFAULT_CONTENT_TYPE ); 57 reconciler.setRepairer( dr, IDocument.DEFAULT_CONTENT_TYPE ); 58 59 return reconciler; 60 } 61 62 63 66 public IContentAssistant getContentAssistant( ISourceViewer sourceViewer ) 67 { 68 ContentAssistant assistant = new DialogContentAssistant(); 70 IContentAssistProcessor aciContentAssistProcessor = new ACIContentAssistProcessor(); 71 72 assistant.setContentAssistProcessor( aciContentAssistProcessor, IDocument.DEFAULT_CONTENT_TYPE ); 73 assistant.setDocumentPartitioning( "org.apache.directory.ldapstudio.aci" ); assistant.enableAutoActivation( true ); 75 assistant.setAutoActivationDelay( 500 ); 76 assistant.setProposalPopupOrientation( IContentAssistant.PROPOSAL_STACKED ); 77 assistant.setContextInformationPopupOrientation( IContentAssistant.CONTEXT_INFO_ABOVE ); 78 79 return assistant; 80 } 81 82 85 public IContentFormatter getContentFormatter( ISourceViewer sourceViewer ) 86 { 87 ContentFormatter formatter = new ContentFormatter(); 88 IFormattingStrategy formattingStrategy = new ACIFormattingStrategy( sourceViewer ); 89 formatter.enablePartitionAwareFormatting( false ); 90 formatter.setFormattingStrategy( formattingStrategy, IDocument.DEFAULT_CONTENT_TYPE ); 91 return formatter; 92 } 93 94 } 95 | Popular Tags |