1 20 21 package org.apache.directory.ldapstudio.ldifeditor.editor; 22 23 24 import org.apache.directory.ldapstudio.ldifeditor.editor.text.LdifPartitionScanner; 25 import org.eclipse.core.filebuffers.IDocumentSetupParticipant; 26 import org.eclipse.jface.text.IDocument; 27 import org.eclipse.jface.text.IDocumentExtension3; 28 import org.eclipse.jface.text.IDocumentPartitioner; 29 import org.eclipse.jface.text.rules.FastPartitioner; 30 31 32 38 public class LdifDocumentSetupParticipant implements IDocumentSetupParticipant 39 { 40 41 public final static String LDIF_PARTITIONING = "org.apache.directory.ldapstudio.ldifeditor.LdifPartitioning"; 43 44 47 public LdifDocumentSetupParticipant() 48 { 49 } 50 51 52 55 public void setup( IDocument document ) 56 { 57 58 if ( document instanceof IDocumentExtension3 ) 59 { 60 IDocumentExtension3 extension3 = ( IDocumentExtension3 ) document; 61 if ( extension3.getDocumentPartitioner( LdifDocumentSetupParticipant.LDIF_PARTITIONING ) == null ) 62 { 63 IDocumentPartitioner partitioner = createDocumentPartitioner(); 64 extension3.setDocumentPartitioner( LDIF_PARTITIONING, partitioner ); 65 partitioner.connect( document ); 66 } 67 } 68 } 69 70 71 77 private IDocumentPartitioner createDocumentPartitioner() 78 { 79 IDocumentPartitioner partitioner = new FastPartitioner( new LdifPartitionScanner(), new String [] 80 { LdifPartitionScanner.LDIF_RECORD } ); 81 return partitioner; 82 } 83 } 84 | Popular Tags |