platform/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/RefreshJob.java
equal
deleted
inserted
replaced
9 * IBM - Initial API and implementation |
9 * IBM - Initial API and implementation |
10 *******************************************************************************/ |
10 *******************************************************************************/ |
11 package org.eclipse.core.internal.refresh; |
11 package org.eclipse.core.internal.refresh; |
12 |
12 |
13 import java.util.*; |
13 import java.util.*; |
|
14 |
14 import org.eclipse.core.internal.localstore.PrefixPool; |
15 import org.eclipse.core.internal.localstore.PrefixPool; |
15 import org.eclipse.core.internal.utils.Messages; |
16 import org.eclipse.core.internal.utils.Messages; |
16 import org.eclipse.core.internal.utils.Policy; |
17 import org.eclipse.core.internal.utils.Policy; |
17 import org.eclipse.core.resources.*; |
18 import org.eclipse.core.resources.*; |
18 import org.eclipse.core.runtime.*; |
19 import org.eclipse.core.runtime.*; |
25 * |
26 * |
26 * @since 3.0 |
27 * @since 3.0 |
27 */ |
28 */ |
28 public class RefreshJob extends WorkspaceJob { |
29 public class RefreshJob extends WorkspaceJob { |
29 private static final long UPDATE_DELAY = 200; |
30 private static final long UPDATE_DELAY = 200; |
|
31 |
|
32 /** |
|
33 * Flag indicating refreshing in progress if > 0 |
|
34 */ |
|
35 private static int refreshingLevel = 0; |
|
36 |
|
37 |
30 /** |
38 /** |
31 * List of refresh requests. Requests are processed in order from |
39 * List of refresh requests. Requests are processed in order from |
32 * the end of the list. Requests can be added to either the beginning |
40 * the end of the list. Requests can be added to either the beginning |
33 * or the end of the list depending on whether they are explicit user |
41 * or the end of the list depending on whether they are explicit user |
34 * requests or background refresh requests. |
42 * requests or background refresh requests. |
149 long start = System.currentTimeMillis(); |
157 long start = System.currentTimeMillis(); |
150 String msg = Messages.refresh_refreshErr; |
158 String msg = Messages.refresh_refreshErr; |
151 MultiStatus errors = new MultiStatus(ResourcesPlugin.PI_RESOURCES, 1, msg, null); |
159 MultiStatus errors = new MultiStatus(ResourcesPlugin.PI_RESOURCES, 1, msg, null); |
152 long longestRefresh = 0; |
160 long longestRefresh = 0; |
153 try { |
161 try { |
|
162 refreshingLevel++; |
|
163 ResourcesPlugin.writeRefreshLog(RefreshManager.DEBUG_PREFIX + " refreshing started..."); //$NON-NLS-1$ |
|
164 for (Iterator iterator = fRequests.iterator(); iterator.hasNext();) { |
|
165 IResource resource = (IResource) iterator.next(); |
|
166 ResourcesPlugin.writeRefreshLog(RefreshManager.DEBUG_PREFIX + " requested resource to refresh: " + resource.getFullPath()); //$NON-NLS-1$ |
|
167 } |
|
168 |
154 if (RefreshManager.DEBUG) |
169 if (RefreshManager.DEBUG) |
155 Policy.debug(RefreshManager.DEBUG_PREFIX + " starting refresh job"); //$NON-NLS-1$ |
170 Policy.debug(RefreshManager.DEBUG_PREFIX + " starting refresh job"); //$NON-NLS-1$ |
156 int refreshCount = 0; |
171 int refreshCount = 0; |
157 int depth = 2; |
172 int depth = 2; |
158 monitor.beginTask("", IProgressMonitor.UNKNOWN); //$NON-NLS-1$ |
173 monitor.beginTask("", IProgressMonitor.UNKNOWN); //$NON-NLS-1$ |
191 pathPrefixHistory = null; |
206 pathPrefixHistory = null; |
192 rootPathHistory = null; |
207 rootPathHistory = null; |
193 monitor.done(); |
208 monitor.done(); |
194 if (RefreshManager.DEBUG) |
209 if (RefreshManager.DEBUG) |
195 System.out.println(RefreshManager.DEBUG_PREFIX + " finished refresh job in: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ |
210 System.out.println(RefreshManager.DEBUG_PREFIX + " finished refresh job in: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
211 |
|
212 ResourcesPlugin.writeRefreshLog(RefreshManager.DEBUG_PREFIX + " finished refresh job in: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
213 refreshingLevel--; |
196 } |
214 } |
197 if (!errors.isOK()) |
215 if (!errors.isOK()) |
198 return errors; |
216 return errors; |
199 return Status.OK_STATUS; |
217 return Status.OK_STATUS; |
200 } |
218 } |
220 public void stop() { |
238 public void stop() { |
221 if (RefreshManager.DEBUG) |
239 if (RefreshManager.DEBUG) |
222 System.out.println(RefreshManager.DEBUG_PREFIX + " disabling auto-refresh"); //$NON-NLS-1$ |
240 System.out.println(RefreshManager.DEBUG_PREFIX + " disabling auto-refresh"); //$NON-NLS-1$ |
223 cancel(); |
241 cancel(); |
224 } |
242 } |
|
243 |
|
244 public static boolean isRefreshing() { |
|
245 return refreshingLevel > 0; |
|
246 } |
225 } |
247 } |