KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > events > InternalBuilder


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 package org.eclipse.core.internal.events;
12
13 import java.util.Map JavaDoc;
14 import org.eclipse.core.internal.resources.ICoreConstants;
15 import org.eclipse.core.internal.watson.ElementTree;
16 import org.eclipse.core.resources.*;
17 import org.eclipse.core.runtime.*;
18
19 /**
20  * This class is the internal basis for all builders. Plugin developers should not
21  * subclass this class.
22  *
23  * @see IncrementalProjectBuilder
24  */

25 public abstract class InternalBuilder {
26     /**
27      * Hold a direct reference to the build manager as an optimization.
28      * This will be initialized by BuildManager when it is constructed.
29      */

30     static BuildManager buildManager;
31     private ICommand command;
32     private boolean forgetStateRequested = false;
33     private IProject[] interestingProjects = ICoreConstants.EMPTY_PROJECT_ARRAY;
34     /**
35      * Human readable builder name for progress reporting.
36      */

37     private String JavaDoc label;
38     private String JavaDoc natureId;
39     private ElementTree oldState;
40     /**
41      * The symbolic name of the plugin that defines this builder
42      */

43     private String JavaDoc pluginId;
44     private IProject project;
45     
46     /**
47      * The value of the callOnEmptyDelta builder extension attribute.
48      */

49     private boolean callOnEmptyDelta = false;
50
51     /*
52      * @see IncrementalProjectBuilder#build
53      */

54     protected abstract IProject[] build(int kind, Map JavaDoc args, IProgressMonitor monitor) throws CoreException;
55
56     /**
57      * Returns the value of the callOnEmptyDelta builder extension attribute.
58      */

59     final boolean callOnEmptyDelta() {
60         return callOnEmptyDelta;
61     }
62     /*
63      * @see IncrementalProjectBuilder
64      */

65     protected abstract void clean(IProgressMonitor monitor) throws CoreException;
66
67     /**
68      * Clears the request to forget last built states.
69      */

70     final void clearForgetLastBuiltState() {
71         forgetStateRequested = false;
72     }
73
74     /*
75      * @see IncrementalProjectBuilder#forgetLastBuiltState
76      */

77     protected void forgetLastBuiltState() {
78         oldState = null;
79         forgetStateRequested = true;
80     }
81
82     /*
83      * @see IncrementalProjectBuilder#getCommand
84      */

85     protected ICommand getCommand() {
86         return (ICommand)((BuildCommand)command).clone();
87     }
88     
89     /*
90      * @see IncrementalProjectBuilder#forgetLastBuiltState
91      */

92     protected IResourceDelta getDelta(IProject aProject) {
93         return buildManager.getDelta(aProject);
94     }
95
96     final IProject[] getInterestingProjects() {
97         return interestingProjects;
98     }
99
100     final String JavaDoc getLabel() {
101         return label;
102     }
103
104     final ElementTree getLastBuiltTree() {
105         return oldState;
106     }
107
108     /**
109      * Returns the ID of the nature that owns this builder. Returns null if the
110      * builder does not belong to a nature.
111      */

112     final String JavaDoc getNatureId() {
113         return natureId;
114     }
115
116     final String JavaDoc getPluginId() {
117         return pluginId;
118     }
119
120     /**
121      * Returns the project for this builder
122      */

123     protected IProject getProject() {
124         return project;
125     }
126
127     /*
128      * @see IncrementalProjectBuilder#hasBeenBuilt
129      */

130     protected boolean hasBeenBuilt(IProject aProject) {
131         return buildManager.hasBeenBuilt(aProject);
132     }
133
134     /*
135      * @see IncrementalProjectBuilder#isInterrupted
136      */

137     public boolean isInterrupted() {
138         return buildManager.autoBuildJob.isInterrupted();
139     }
140
141     /*
142      * @see IncrementalProjectBuilder#needRebuild
143      */

144     protected void needRebuild() {
145         buildManager.requestRebuild();
146     }
147     
148     final void setCallOnEmptyDelta(boolean value) {
149         this.callOnEmptyDelta = value;
150     }
151
152     final void setCommand(ICommand value) {
153         this.command = value;
154     }
155     
156     final void setInterestingProjects(IProject[] value) {
157         interestingProjects = value;
158     }
159
160     final void setLabel(String JavaDoc value) {
161         this.label = value;
162     }
163
164     final void setLastBuiltTree(ElementTree value) {
165         oldState = value;
166     }
167
168     final void setNatureId(String JavaDoc id) {
169         this.natureId = id;
170     }
171
172     final void setPluginId(String JavaDoc value) {
173         pluginId = value;
174     }
175
176     /**
177      * Sets the project for which this builder operates.
178      * @see #getProject()
179      */

180     final void setProject(IProject value) {
181         Assert.isTrue(project == null);
182         project = value;
183     }
184
185     /*
186      * @see IncrementalProjectBuilder#startupOnInitialize
187      */

188     protected abstract void startupOnInitialize();
189
190     /**
191      * Returns true if the builder requested that its last built state be
192      * forgetten, and false otherwise.
193      */

194     final boolean wasForgetStateRequested() {
195         return forgetStateRequested;
196     }
197 }
198
Popular Tags