KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > ldifeditor > editor > reconciler > LdifReconcilingStrategy


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

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     // private IDocument document;
42
// private IProgressMonitor progressMonitor;
43

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         // this.document = document;
69
}
70
71
72     public void setProgressMonitor( IProgressMonitor monitor )
73     {
74         // this.progressMonitor = monitor;
75
}
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 JavaDoc()
106         {
107             public void run()
108             {
109
110                 // notify outline
111
IContentOutlinePage outline = ( IContentOutlinePage ) editor.getAdapter( IContentOutlinePage.class );
112                 if ( outline != null && outline instanceof LdifOutlinePage )
113                 {
114                     ( ( LdifOutlinePage ) outline ).refresh();
115                 }
116
117                 // notify annotation updater
118
annotationUpdater.updateAnnotations();
119
120                 // notify folding updater
121
foldingUpdater.updateFoldingRegions();
122
123             }
124         } );
125     }
126
127 }
128
Popular Tags