View | Details | Raw Unified | Return to bug 30440
Collapse All | Expand All

(-)plugin.xml (+5 lines)
Lines 134-139 Link Here
134
            name="eclipse.refreshLocal"
134
            name="eclipse.refreshLocal"
135
            class="org.eclipse.core.resources.ant.RefreshLocalTask">
135
            class="org.eclipse.core.resources.ant.RefreshLocalTask">
136
      </antTask>
136
      </antTask>
137
      <antTask
138
            library="ant_tasks/resources-ant.jar"
139
            name="eclipse.setDerived"
140
            class="org.eclipse.core.resources.ant.SetDerived">
141
      </antTask>
137
   </extension>
142
   </extension>
138
<!-- Extra Classpath -->
143
<!-- Extra Classpath -->
139
   <extension
144
   <extension
(-)src_ant/org/eclipse/core/resources/ant/RefreshLocalTask.java (-1 / +1 lines)
Lines 68-74 Link Here
68
	 */
68
	 */
69
	public void execute() throws BuildException {
69
	public void execute() throws BuildException {
70
		if (resource == null)
70
		if (resource == null)
71
			throw new BuildException(Policy.bind("exception.resourceNotSpecified")); //$NON-NLS-1$
71
			throw new BuildException(Policy.bind("exception.resourceNotSpecified", "eclipse.refreshLocal")); //$NON-NLS-1$ //$NON-NLS-2$
72
		try {
72
		try {
73
			IProgressMonitor monitor = null;
73
			IProgressMonitor monitor = null;
74
			Hashtable references = getProject().getReferences();
74
			Hashtable references = getProject().getReferences();
(-)src_ant/org/eclipse/core/resources/ant/SetDerived.java (+90 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 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.resources.ant;
12
13
import java.util.Hashtable;
14
import org.apache.tools.ant.BuildException;
15
import org.apache.tools.ant.Task;
16
import org.eclipse.ant.core.AntCorePlugin;
17
import org.eclipse.core.resources.*;
18
import org.eclipse.core.runtime.*;
19
20
/**
21
 * An Ant task which sets derived flag for the given resource.
22
 * 
23
 * @see IResource#setDerived(boolean, IProgressMonitor)
24
 */
25
public class SetDerived extends Task {
26
	private boolean derived = true;
27
	private boolean recurse = false;
28
	private IPath resourcePath = null;
29
30
	public SetDerived() {
31
		super();
32
	}
33
34
	private void setDerived(IResource resource, IProgressMonitor monitor) throws CoreException {
35
		resource.setDerived(derived, monitor);
36
		if (recurse && (resource instanceof IContainer)) {
37
			IResource members[] = ((IContainer) resource).members();
38
			for (int i = 0; i < members.length; i++) {
39
				setDerived(members[i], monitor);
40
			}
41
		}
42
	}
43
44
	/**
45
	 * Executes this task.
46
	 * 
47
	 * @exception BuildException thrown if a problem occurs during execution.
48
	 */
49
	public void execute() throws BuildException {
50
		IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(resourcePath);
51
		if (resource == null)
52
			throw new BuildException(Policy.bind("exception.resourceNotSpecified", "eclipse.setDerived")); //$NON-NLS-1$ //$NON-NLS-2$
53
		try {
54
			IProgressMonitor monitor = null;
55
			Hashtable references = getProject().getReferences();
56
			if (references != null)
57
				monitor = (IProgressMonitor) references.get(AntCorePlugin.ECLIPSE_PROGRESS_MONITOR);
58
			setDerived(resource, monitor);
59
		} catch (CoreException e) {
60
			throw new BuildException(e);
61
		}
62
	}
63
64
	/**
65
	 * Sets the derived flag to be used in this task.
66
	 * 
67
	 * @param value the derived value
68
	 */
69
	public void setDerived(String value) {
70
		derived = Boolean.parseBoolean(value);
71
	}
72
73
	/**
74
	 * Sets the recurse flag. If <code>true</code> then derived flag will be set for the given resource and all its children. If <code>false</code> then it will be set only for the given resource.
75
	 * 
76
	 * @param value the recurse value
77
	 */
78
	public void setRecurse(String value) {
79
		recurse = Boolean.parseBoolean(value);
80
	}
81
82
	/**
83
	 * Sets the resource path for which {@link IResource#setDerived(boolean, IProgressMonitor)} will be called.
84
	 * 
85
	 * @param value the resource path
86
	 */
87
	public void setResourcePath(String value) {
88
		resourcePath = new Path(value);
89
	}
90
}
(-)src_ant/org/eclipse/core/resources/ant/messages.properties (-1 / +1 lines)
Lines 18-22 Link Here
18
exception.noProjectMatchThePath=The path {0} does not match any existing project.
18
exception.noProjectMatchThePath=The path {0} does not match any existing project.
19
exception.pathNotValid=The path {0} for the resource is not a valid path as the first segment does not represent a project.
19
exception.pathNotValid=The path {0} for the resource is not a valid path as the first segment does not represent a project.
20
exception.propertyAndPathIdNotSpecified=At least one of the "property" or "pathId" attributes must be specified.
20
exception.propertyAndPathIdNotSpecified=At least one of the "property" or "pathId" attributes must be specified.
21
exception.resourceNotSpecified=A resource name must be specified for the eclipse.refreshLocal task.
21
exception.resourceNotSpecified=A resource name must be specified for the {0} task.
22
warning.projectDoesNotExist=Warning: project {0} does not exist and cannot be refreshed.
22
warning.projectDoesNotExist=Warning: project {0} does not exist and cannot be refreshed.

Return to bug 30440