KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > text > ReconcilingStrategy


1 /*******************************************************************************
2  * Copyright (c) 2003, 2006 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 package org.eclipse.pde.internal.ui.editor.text;
12
13 import java.util.ArrayList JavaDoc;
14
15 import org.eclipse.jface.text.IDocument;
16 import org.eclipse.jface.text.IRegion;
17 import org.eclipse.jface.text.reconciler.DirtyRegion;
18 import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
19 import org.eclipse.pde.internal.core.text.IReconcilingParticipant;
20
21 public class ReconcilingStrategy implements IReconcilingStrategy {
22     
23     private IDocument fDocument;
24     private ArrayList JavaDoc fParticipants = new ArrayList JavaDoc();
25     
26     public ReconcilingStrategy () {
27     }
28     /* (non-Javadoc)
29      * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
30      */

31     public void setDocument(IDocument document) {
32         fDocument = document;
33     }
34     /* (non-Javadoc)
35      * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
36      */

37     public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
38         if (fDocument != null)
39             notifyParticipants();
40     }
41     /* (non-Javadoc)
42      * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
43      */

44     public void reconcile(IRegion partition) {
45         if (fDocument != null)
46             notifyParticipants();
47     }
48     
49     private synchronized void notifyParticipants() {
50         for (int i = 0; i < fParticipants.size(); i++) {
51             ((IReconcilingParticipant)fParticipants.get(i)).reconciled(fDocument);
52         }
53     }
54     
55     public void addParticipant(IReconcilingParticipant participant) {
56         fParticipants.add(participant);
57     }
58     
59     public void removeParticipant(IReconcilingParticipant participant) {
60         fParticipants.remove(participant);
61     }
62 }
63
Popular Tags