1 11 package org.eclipse.core.resources.ant; 12 13 import java.util.Hashtable ; 14 import org.apache.tools.ant.*; 15 import org.eclipse.ant.core.AntCorePlugin; 16 import org.eclipse.core.resources.IResource; 17 import org.eclipse.core.resources.ResourcesPlugin; 18 import org.eclipse.core.runtime.*; 19 20 25 public class RefreshLocalTask extends Task { 26 31 public static final String DEPTH_ZERO = "zero"; 33 38 public static final String DEPTH_ONE = "one"; 40 45 public static final String DEPTH_INFINITE = "infinite"; 47 50 protected IResource resource; 51 52 55 protected int depth = IResource.DEPTH_INFINITE; 56 57 60 public RefreshLocalTask() { 61 super(); 62 } 63 64 69 public void execute() throws BuildException { 70 if (resource == null) 71 throw new BuildException(Policy.bind("exception.resourceNotSpecified")); try { 73 IProgressMonitor monitor = null; 74 Hashtable references = getProject().getReferences(); 75 if (references != null) 76 monitor = (IProgressMonitor) references.get(AntCorePlugin.ECLIPSE_PROGRESS_MONITOR); 77 resource.refreshLocal(depth, monitor); 78 } catch (CoreException e) { 79 throw new BuildException(e); 80 } 81 } 82 83 90 public void setDepth(String value) { 91 if (DEPTH_ZERO.equalsIgnoreCase(value)) 92 depth = IResource.DEPTH_ZERO; 93 else if (DEPTH_ONE.equalsIgnoreCase(value)) 94 depth = IResource.DEPTH_ONE; 95 else if (DEPTH_INFINITE.equalsIgnoreCase(value)) 96 depth = IResource.DEPTH_INFINITE; 97 } 98 99 104 public void setResource(String value) { 105 IPath path = new Path(value); 106 resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path); 107 if (resource == null) { 108 if (path.segmentCount() > 1) 110 resource = ResourcesPlugin.getWorkspace().getRoot().getFolder(path); 111 else { 112 resource = ResourcesPlugin.getWorkspace().getRoot().getProject(value); 113 if (!resource.exists()) 114 log(Policy.bind("warning.projectDoesNotExist", value), Project.MSG_WARN); } 116 } 117 } 118 119 } 120 | Popular Tags |