KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > editor > text > XMLReconcilingStrategy


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ant.internal.ui.editor.text;
13
14 import org.eclipse.ant.internal.ui.AntUIPlugin;
15 import org.eclipse.ant.internal.ui.editor.AntEditor;
16 import org.eclipse.ant.internal.ui.model.AntModel;
17 import org.eclipse.ant.internal.ui.model.IAntModel;
18 import org.eclipse.core.runtime.IProgressMonitor;
19 import org.eclipse.jface.text.IDocument;
20 import org.eclipse.jface.text.IRegion;
21 import org.eclipse.jface.text.reconciler.DirtyRegion;
22 import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
23 import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
24
25 public class XMLReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension {
26
27     /**
28      * How long the reconciler will wait for further text changes before
29      * reconciling
30      */

31     public static final int DELAY= 500;
32
33     private AntEditor fEditor;
34
35     public XMLReconcilingStrategy(AntEditor editor) {
36         fEditor= editor;
37     }
38
39     private void internalReconcile() {
40         try {
41             IAntModel model= fEditor.getAntModel();
42             if (model instanceof AntModel) {
43                 ((AntModel)model).reconcile();
44             }
45         } catch (Exception JavaDoc e) {
46             AntUIPlugin.log(e);
47         }
48     }
49
50     /*
51      * (non-Javadoc)
52      *
53      * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
54      */

55     public void reconcile(IRegion partition) {
56         internalReconcile();
57     }
58
59     /*
60      * (non-Javadoc)
61      *
62      * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion,
63      * org.eclipse.jface.text.IRegion)
64      */

65     public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
66         internalReconcile();
67     }
68
69     /*
70      * (non-Javadoc)
71      *
72      * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
73      */

74     public void setDocument(IDocument document) {
75     }
76
77     /*
78      * (non-Javadoc)
79      *
80      * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
81      */

82     public void setProgressMonitor(IProgressMonitor monitor) {
83     }
84
85     /*
86      * (non-Javadoc)
87      *
88      * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile()
89      */

90     public void initialReconcile() {
91         internalReconcile();
92     }
93 }
94
Popular Tags