1 20 21 package org.apache.directory.ldapstudio.ldifeditor.editor.reconciler; 22 23 24 import org.apache.directory.ldapstudio.ldifeditor.editor.ILdifEditor; 25 import org.apache.directory.ldapstudio.ldifeditor.editor.LdifOutlinePage; 26 import org.eclipse.core.runtime.IProgressMonitor; 27 import org.eclipse.jface.text.IDocument; 28 import org.eclipse.jface.text.IRegion; 29 import org.eclipse.jface.text.reconciler.DirtyRegion; 30 import org.eclipse.jface.text.reconciler.IReconcilingStrategy; 31 import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension; 32 import org.eclipse.swt.widgets.Display; 33 import org.eclipse.ui.views.contentoutline.IContentOutlinePage; 34 35 36 public class LdifReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension 37 { 38 39 private ILdifEditor editor; 40 41 44 private LdifFoldingRegionUpdater foldingUpdater; 45 46 private LdifAnnotationUpdater annotationUpdater; 47 48 49 public LdifReconcilingStrategy( ILdifEditor editor ) 50 { 51 this.editor = editor; 52 53 this.annotationUpdater = new LdifAnnotationUpdater( this.editor ); 54 this.foldingUpdater = new LdifFoldingRegionUpdater( this.editor ); 55 56 } 57 58 59 public void dispose() 60 { 61 this.annotationUpdater.dispose(); 62 this.foldingUpdater.dispose(); 63 } 64 65 66 public void setDocument( IDocument document ) 67 { 68 } 70 71 72 public void setProgressMonitor( IProgressMonitor monitor ) 73 { 74 } 76 77 78 public void reconcile( DirtyRegion dirtyRegion, IRegion subRegion ) 79 { 80 reconcile(); 81 } 82 83 84 public void reconcile( IRegion partition ) 85 { 86 reconcile(); 87 } 88 89 90 public void initialReconcile() 91 { 92 reconcile(); 93 } 94 95 96 private void reconcile() 97 { 98 notifyEnvironment(); 99 } 100 101 102 private void notifyEnvironment() 103 { 104 105 Display.getDefault().asyncExec( new Runnable () 106 { 107 public void run() 108 { 109 110 IContentOutlinePage outline = ( IContentOutlinePage ) editor.getAdapter( IContentOutlinePage.class ); 112 if ( outline != null && outline instanceof LdifOutlinePage ) 113 { 114 ( ( LdifOutlinePage ) outline ).refresh(); 115 } 116 117 annotationUpdater.updateAnnotations(); 119 120 foldingUpdater.updateFoldingRegions(); 122 123 } 124 } ); 125 } 126 127 } 128 | Popular Tags |