KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > resources > refresh > RefreshProvider


1 /*******************************************************************************
2  * Copyright (c) 2004, 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 - Initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.core.resources.refresh;
12
13 import org.eclipse.core.internal.refresh.InternalRefreshProvider;
14 import org.eclipse.core.resources.IResource;
15
16 /**
17  * The abstract base class for all auto-refresh providers. This class provides
18  * the infrastructure for defining an auto-refresh provider and fulfills the
19  * contract specified by the <code>org.eclipse.core.resources.refreshProviders</code>
20  * standard extension point.
21  * <p>
22  * All auto-refresh providers must subclass this class. A
23  * <code>RefreshProvider</code> is responsible for creating
24  * <code>IRefreshMonitor</code> objects. The provider must decide if
25  * it is capable of monitoring the file, or folder and subtree under the path that is provided.
26  *
27  * @since 3.0
28  */

29 public abstract class RefreshProvider extends InternalRefreshProvider {
30     /**
31      * Creates a new refresh monitor that performs naive polling of the resource
32      * in the file system to detect changes. The returned monitor will immediately begin
33      * monitoring the specified resource root and report changes back to the workspace.
34      * <p>
35      * This default monitor can be returned by subclasses when
36      * <code>installMonitor</code> is called.
37      * <p>
38      * If the returned monitor is not immediately returned from the <code>installMonitor</code>
39      * method, then clients are responsible for telling the returned monitor to
40      * stop polling when it is no longer needed. The returned monitor can be told to
41      * stop working by invoking <code>IRefreshMonitor.unmonitor(IResource)</code>.
42      *
43      * @param resource The resource to begin monitoring
44      * @return A refresh monitor instance
45      * @see #installMonitor(IResource, IRefreshResult)
46      */

47     protected IRefreshMonitor createPollingMonitor(IResource resource) {
48         return super.createPollingMonitor(resource);
49     }
50
51     /**
52      * Returns an <code>IRefreshMonitor</code> that will monitor a resource. If
53      * the resource is an <code>IContainer</code> the monitor will also
54      * monitor the subtree under the container. Returns <code>null</code> if
55      * this provider cannot create a monitor for the given resource. The
56      * provider may return the same monitor instance that has been provided for
57      * other resources.
58      * <p>
59      * The monitor should send results and failures to the provided refresh
60      * result.
61      *
62      * @param resource the resource to monitor
63      * @param result the result callback for notifying of failure or of resources that need
64      * refreshing
65      * @return a monitor on the resource, or <code>null</code>
66      * if the resource cannot be monitored
67      * @see #createPollingMonitor(IResource)
68      */

69     public abstract IRefreshMonitor installMonitor(IResource resource, IRefreshResult result);
70     
71     /**
72      * Resets the installed monitors for the given resource. This will remove all
73      * existing monitors that are installed on the resource, and then ask all
74      * refresh providers to begin monitoring the resource again.
75      * <p>
76      * This method is intended to be used by refresh providers that need to change
77      * the refresh monitor that they previously used to monitor a resource.
78      *
79      * @param resource The resource to reset the monitors for
80      */

81     public void resetMonitors(IResource resource) {
82         super.resetMonitors(resource);
83     }
84 }
85
Popular Tags