Added some examples for context menu on Outline
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / CompositeReconcilingStrategy.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.text;
12
13 import org.eclipse.core.runtime.IProgressMonitor;
14 import org.eclipse.jface.text.IDocument;
15 import org.eclipse.jface.text.IRegion;
16 import org.eclipse.jface.text.reconciler.DirtyRegion;
17 import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
18 import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
19
20 /**
21  * A reconciling strategy consisting of a sequence of internal reconciling strategies.
22  * By default, all requests are passed on to the contained strategies.
23  * 
24  * @since 3.0
25  */
26 public class CompositeReconcilingStrategy  implements IReconcilingStrategy, IReconcilingStrategyExtension {
27         
28         /** The list of internal reconciling strategies. */
29         private IReconcilingStrategy[] fStrategies;
30         
31         /**
32          * Creates a new, empty composite reconciling strategy.
33          */
34         public CompositeReconcilingStrategy() {
35         }
36         
37         /**
38          * Sets the reconciling strategies for this composite strategy.
39          * 
40          * @param strategies the strategies to be set or <code>null</code>
41          */
42         public void setReconcilingStrategies(IReconcilingStrategy[] strategies) {
43                 fStrategies= strategies;
44         }
45         
46         /**
47          * Returns the previously set stratgies or <code>null</code>.
48          * 
49          * @return the contained strategies or <code>null</code>
50          */
51         public IReconcilingStrategy[] getReconcilingStrategies() {
52                 return fStrategies;
53         }
54
55         /*
56          * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
57          */
58         public void setDocument(IDocument document) {
59                 if (fStrategies == null)
60                         return;
61                 
62                 for (int i= 0; i < fStrategies.length; i++)
63                         fStrategies[i].setDocument(document);
64         }
65
66         /*
67          * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
68          */
69         public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
70                 if (fStrategies == null)
71                         return;
72                 
73                 for (int i= 0; i < fStrategies.length; i++)
74                         fStrategies[i].reconcile(dirtyRegion, subRegion);
75         }
76
77         /*
78          * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
79          */
80         public void reconcile(IRegion partition) {
81                 if (fStrategies == null)
82                         return;
83                 
84                 for (int i= 0; i < fStrategies.length; i++)
85                         fStrategies[i].reconcile(partition);
86         }
87
88         /*
89          * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
90          */
91         public void setProgressMonitor(IProgressMonitor monitor) {
92                 if (fStrategies == null)
93                         return;
94                 
95                 for (int i=0; i < fStrategies.length; i++) {
96                         if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
97                                 IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
98                                 extension.setProgressMonitor(monitor);
99                         }
100                 }
101         }
102
103         /*
104          * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile()
105          */
106         public void initialReconcile() {
107                 if (fStrategies == null)
108                         return;
109                 
110                 for (int i=0; i < fStrategies.length; i++) {
111                         if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
112                                 IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
113                                 extension.initialReconcile();
114                         }
115                 }
116         }
117 }