Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 264338 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/debug/ui/RefreshTab.java (-91 / +5 lines)
Lines 14-39 Link Here
14
import java.io.IOException;
14
import java.io.IOException;
15
import java.io.StringReader;
15
import java.io.StringReader;
16
import java.io.StringWriter;
16
import java.io.StringWriter;
17
import com.ibm.icu.text.MessageFormat;
17
18
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.resources.ResourcesPlugin;
20
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.IAdaptable;
20
import org.eclipse.core.runtime.IAdaptable;
22
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.IProgressMonitor;
23
import org.eclipse.core.runtime.IStatus;
24
import org.eclipse.core.runtime.MultiStatus;
25
import org.eclipse.core.runtime.NullProgressMonitor;
26
import org.eclipse.core.runtime.Path;
27
import org.eclipse.core.runtime.Status;
28
import org.eclipse.debug.core.DebugPlugin;
22
import org.eclipse.debug.core.DebugPlugin;
29
import org.eclipse.debug.core.ILaunchConfiguration;
23
import org.eclipse.debug.core.ILaunchConfiguration;
30
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
24
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
25
import org.eclipse.debug.internal.core.LaunchManager;
31
import org.eclipse.debug.internal.ui.DebugPluginImages;
26
import org.eclipse.debug.internal.ui.DebugPluginImages;
32
import org.eclipse.debug.internal.ui.DebugUIPlugin;
27
import org.eclipse.debug.internal.ui.DebugUIPlugin;
33
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
28
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
34
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
29
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
35
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog;
30
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog;
36
import org.eclipse.debug.internal.ui.stringsubstitution.SelectedResourceManager;
37
import org.eclipse.debug.internal.ui.stringsubstitution.StringSubstitutionMessages;
31
import org.eclipse.debug.internal.ui.stringsubstitution.StringSubstitutionMessages;
38
import org.eclipse.jface.window.Window;
32
import org.eclipse.jface.window.Window;
39
import org.eclipse.jface.wizard.WizardDialog;
33
import org.eclipse.jface.wizard.WizardDialog;
Lines 410-455 Link Here
410
	 * @throws CoreException if an exception occurs while refreshing resources
404
	 * @throws CoreException if an exception occurs while refreshing resources
411
	 */
405
	 */
412
	public static void refreshResources(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
406
	public static void refreshResources(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
413
		if (monitor == null) {
407
		LaunchManager.refreshResources(configuration, monitor);
414
			monitor = new NullProgressMonitor();
415
		}
416
		String scope = getRefreshScope(configuration);
417
		IResource[] resources= null;
418
		if (scope != null) {
419
			resources = getRefreshResources(scope);
420
		}
421
		if (resources == null || resources.length == 0){
422
			return;
423
		}
424
		int depth = IResource.DEPTH_ONE;
425
		if (isRefreshRecursive(configuration))
426
			depth = IResource.DEPTH_INFINITE;
427
	
428
		if (monitor.isCanceled()) {
429
			return;
430
		}
431
	
432
		monitor.beginTask(StringSubstitutionMessages.RefreshTab_7, 
433
			resources.length);
434
	
435
		MultiStatus status = new MultiStatus(DebugUIPlugin.getUniqueIdentifier(), 0, StringSubstitutionMessages.RefreshTab_8, null); 
436
		for (int i = 0; i < resources.length; i++) {
437
			if (monitor.isCanceled())
438
				break;
439
			if (resources[i] != null && resources[i].isAccessible()) {
440
				try {
441
					resources[i].refreshLocal(depth, null);
442
				} catch (CoreException e) {
443
					status.merge(e.getStatus());
444
				}
445
			}
446
			monitor.worked(1);
447
		}
448
	
449
		monitor.done();
450
		if (!status.isOK()) {
451
			throw new CoreException(status);
452
		}
453
	}
408
	}
454
409
455
	/**
410
	/**
Lines 460-507 Link Here
460
	 * @throws CoreException if unable to resolve a set of resources
415
	 * @throws CoreException if unable to resolve a set of resources
461
	 */
416
	 */
462
	public static IResource[] getRefreshResources(String scope) throws CoreException {
417
	public static IResource[] getRefreshResources(String scope) throws CoreException {
463
		if (scope.startsWith("${resource:")) { //$NON-NLS-1$
418
		return LaunchManager.getRefreshResources(scope);
464
			// This is an old format that is replaced with 'working_set'
465
			String pathString = scope.substring(11, scope.length() - 1);
466
			Path path = new Path(pathString);
467
			IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
468
			if (resource == null) {
469
				throw new CoreException(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, MessageFormat.format(StringSubstitutionMessages.RefreshTab_43, new String[]{pathString}), null)); 
470
			} 
471
			return new IResource[]{resource};
472
		} else if (scope.startsWith("${working_set:")) { //$NON-NLS-1$
473
			IWorkingSet workingSet =  getWorkingSet(scope);
474
			if (workingSet == null) {
475
				throw new CoreException(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, StringSubstitutionMessages.RefreshTab_44, null));  
476
			} 
477
			IAdaptable[] elements = workingSet.getElements();
478
			IResource[] resources = new IResource[elements.length];
479
			for (int i = 0; i < elements.length; i++) {
480
				IAdaptable adaptable = elements[i];
481
				if (adaptable instanceof IResource) {
482
					resources[i] = (IResource) adaptable;
483
				} else {
484
					resources[i] = (IResource) adaptable.getAdapter(IResource.class);
485
				}
486
			}
487
			return resources;				
488
		} else if(scope.equals("${workspace}")) { //$NON-NLS-1$
489
			return new IResource[]{ResourcesPlugin.getWorkspace().getRoot()};
490
		} else {
491
			IResource resource = SelectedResourceManager.getDefault().getSelectedResource();
492
			if (resource == null) {
493
				// empty selection
494
				return new IResource[]{};
495
			}
496
			if (scope.equals("${resource}")) { //$NON-NLS-1$
497
				// resource = resource
498
			} else if (scope.equals("${container}")) { //$NON-NLS-1$
499
				resource = resource.getParent();
500
			} else if (scope.equals("${project}")) { //$NON-NLS-1$
501
				resource = resource.getProject();
502
			}
503
			return new IResource[]{resource};
504
		}
505
	}
419
	}
506
	
420
	
507
	/**
421
	/**
Lines 538-544 Link Here
538
	 * @throws CoreException if unable to access the associated attribute
452
	 * @throws CoreException if unable to access the associated attribute
539
	 */
453
	 */
540
	public static String getRefreshScope(ILaunchConfiguration configuration) throws CoreException {
454
	public static String getRefreshScope(ILaunchConfiguration configuration) throws CoreException {
541
		return configuration.getAttribute(ATTR_REFRESH_SCOPE, (String) null);
455
		return LaunchManager.getRefreshScope(configuration);
542
	}
456
	}
543
457
544
	/**
458
	/**
(-)ui/org/eclipse/debug/ui/CommonTab.java (-7 / +2 lines)
Lines 31-36 Link Here
31
import org.eclipse.debug.core.ILaunchConfiguration;
31
import org.eclipse.debug.core.ILaunchConfiguration;
32
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
32
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
33
import org.eclipse.debug.internal.core.IInternalDebugCoreConstants;
33
import org.eclipse.debug.internal.core.IInternalDebugCoreConstants;
34
import org.eclipse.debug.internal.core.LaunchManager;
34
import org.eclipse.debug.internal.ui.DebugUIPlugin;
35
import org.eclipse.debug.internal.ui.DebugUIPlugin;
35
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
36
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
36
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
37
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
Lines 590-602 Link Here
590
	 * @return whether the configuration is configured to launch in the background
591
	 * @return whether the configuration is configured to launch in the background
591
	 */
592
	 */
592
	public static boolean isLaunchInBackground(ILaunchConfiguration configuration) {
593
	public static boolean isLaunchInBackground(ILaunchConfiguration configuration) {
593
		boolean launchInBackground= true;
594
		return LaunchManager.isLaunchInBackground(configuration);
594
		try {
595
			launchInBackground= configuration.getAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true);
596
		} catch (CoreException ce) {
597
			DebugUIPlugin.log(ce);
598
		}
599
		return launchInBackground;
600
	}
595
	}
601
596
602
	/**
597
	/**
(-)core/org/eclipse/debug/internal/core/DebugCoreMessages.java (+3 lines)
Lines 109-114 Link Here
109
	public static String RuntimeProcess_Exit_value_not_available_until_process_terminates__1;
109
	public static String RuntimeProcess_Exit_value_not_available_until_process_terminates__1;
110
	public static String WatchExpression_0;
110
	public static String WatchExpression_0;
111
	public static String NullStreamsProxy_0;
111
	public static String NullStreamsProxy_0;
112
	
113
	public static String RefreshingResources;
114
	public static String RefreshingResourcesError;
112
115
113
	static {
116
	static {
114
		// load message values from bundle file
117
		// load message values from bundle file
(-)core/org/eclipse/debug/internal/core/Preferences.java (-415 / +415 lines)
Lines 1-415 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.core;
11
package org.eclipse.debug.internal.core;
12
12
13
import org.eclipse.core.runtime.preferences.DefaultScope;
13
import org.eclipse.core.runtime.preferences.DefaultScope;
14
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
14
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
15
import org.eclipse.core.runtime.preferences.IScopeContext;
15
import org.eclipse.core.runtime.preferences.IScopeContext;
16
import org.eclipse.core.runtime.preferences.InstanceScope;
16
import org.eclipse.core.runtime.preferences.InstanceScope;
17
import org.eclipse.debug.core.DebugPlugin;
17
import org.eclipse.debug.core.DebugPlugin;
18
import org.osgi.service.prefs.BackingStoreException;
18
import org.osgi.service.prefs.BackingStoreException;
19
19
20
/**
20
/**
21
 * Convenience class to facilitate using the new {@link IEclipsePreferences} story
21
 * Convenience class to facilitate using the new {@link IEclipsePreferences} story
22
 * 
22
 * 
23
 * @since 3.6
23
 * @since 3.6
24
 * @noinstantiate This class is not intended to be instantiated by clients.
24
 * @noinstantiate This class is not intended to be instantiated by clients.
25
 */
25
 */
26
public final class Preferences {
26
public final class Preferences {
27
27
28
	static final IScopeContext[] contexts = new IScopeContext[] {new DefaultScope(), new InstanceScope()}; 
28
	static final IScopeContext[] contexts = new IScopeContext[] {new DefaultScope(), new InstanceScope()}; 
29
	
29
	
30
	static final int DEFAULT_CONTEXT = 0;
30
	static final int DEFAULT_CONTEXT = 0;
31
	static final int INSTANCE_CONTEXT = 1;
31
	static final int INSTANCE_CONTEXT = 1;
32
	
32
	
33
	/**
33
	/**
34
	 * Constructor
34
	 * Constructor
35
	 */
35
	 */
36
	private Preferences() {
36
	private Preferences() {
37
		// no direct instantiation
37
		// no direct instantiation
38
	}
38
	}
39
	
39
	
40
	/**
40
	/**
41
	 * Sets a string preference in the {@link InstanceScope} or the given {@link IScopeContext} if it
41
	 * Sets a string preference in the {@link InstanceScope} or the given {@link IScopeContext} if it
42
	 * is not <code>null</code>. Preferences set in a given context are flushed as they are set.
42
	 * is not <code>null</code>. Preferences set in a given context are flushed as they are set.
43
	 * @param qualifier 
43
	 * @param qualifier 
44
	 * @param key the key
44
	 * @param key the key
45
	 * @param value the value
45
	 * @param value the value
46
	 * @param context
46
	 * @param context
47
	 */
47
	 */
48
	public static synchronized void setString(String qualifier, String key, String value, IScopeContext context) {
48
	public static synchronized void setString(String qualifier, String key, String value, IScopeContext context) {
49
		if(context != null) {
49
		if(context != null) {
50
			try {
50
			try {
51
				IEclipsePreferences node = context.getNode(qualifier);
51
				IEclipsePreferences node = context.getNode(qualifier);
52
				node.put(key, value);
52
				node.put(key, value);
53
				node.flush();
53
				node.flush();
54
			}
54
			}
55
			catch(BackingStoreException bse) {
55
			catch(BackingStoreException bse) {
56
				DebugPlugin.log(bse);
56
				DebugPlugin.log(bse);
57
			}
57
			}
58
		}
58
		}
59
		else {
59
		else {
60
			contexts[INSTANCE_CONTEXT].getNode(qualifier).put(key, value);
60
			contexts[INSTANCE_CONTEXT].getNode(qualifier).put(key, value);
61
		}
61
		}
62
	}
62
	}
63
	
63
	
64
	/**
64
	/**
65
	 * Sets a boolean preference in the {@link InstanceScope} or the given {@link IScopeContext} if it
65
	 * Sets a boolean preference in the {@link InstanceScope} or the given {@link IScopeContext} if it
66
	 * is not <code>null</code>. Preferences set in a given context are flushed as they are set.
66
	 * is not <code>null</code>. Preferences set in a given context are flushed as they are set.
67
	 * @param qualifier 
67
	 * @param qualifier 
68
	 * @param key the key
68
	 * @param key the key
69
	 * @param value the value
69
	 * @param value the value
70
	 * @param context
70
	 * @param context
71
	 */
71
	 */
72
	public static synchronized void setBoolean(String qualifier, String key, boolean value, IScopeContext context) {
72
	public static synchronized void setBoolean(String qualifier, String key, boolean value, IScopeContext context) {
73
		if(context != null) {
73
		if(context != null) {
74
			try {
74
			try {
75
				IEclipsePreferences node = context.getNode(qualifier);
75
				IEclipsePreferences node = context.getNode(qualifier);
76
				node.putBoolean(key, value);
76
				node.putBoolean(key, value);
77
				node.flush();
77
				node.flush();
78
			}
78
			}
79
			catch(BackingStoreException bse) {
79
			catch(BackingStoreException bse) {
80
				DebugPlugin.log(bse);
80
				DebugPlugin.log(bse);
81
			}
81
			}
82
		}
82
		}
83
		else {
83
		else {
84
			contexts[INSTANCE_CONTEXT].getNode(qualifier).putBoolean(key, value);
84
			contexts[INSTANCE_CONTEXT].getNode(qualifier).putBoolean(key, value);
85
		}
85
		}
86
	}
86
	}
87
	
87
	
88
	/**
88
	/**
89
	 * Sets a integer preference in the {@link InstanceScope} or the given {@link IScopeContext} if it
89
	 * Sets a integer preference in the {@link InstanceScope} or the given {@link IScopeContext} if it
90
	 * is not <code>null</code>. Preferences set in a given context are flushed as they are set.
90
	 * is not <code>null</code>. Preferences set in a given context are flushed as they are set.
91
	 * @param qualifier
91
	 * @param qualifier
92
	 * @param key the key
92
	 * @param key the key
93
	 * @param value the value
93
	 * @param value the value
94
	 * @param context
94
	 * @param context
95
	 */
95
	 */
96
	public static synchronized void setInt(String qualifier, String key, int value, IScopeContext context) {
96
	public static synchronized void setInt(String qualifier, String key, int value, IScopeContext context) {
97
		if(context != null) {
97
		if(context != null) {
98
			try {
98
			try {
99
				IEclipsePreferences node = context.getNode(qualifier);
99
				IEclipsePreferences node = context.getNode(qualifier);
100
				node.putInt(key, value);
100
				node.putInt(key, value);
101
				node.flush();
101
				node.flush();
102
			}
102
			}
103
			catch(BackingStoreException bse) {
103
			catch(BackingStoreException bse) {
104
				DebugPlugin.log(bse);
104
				DebugPlugin.log(bse);
105
			}
105
			}
106
		}
106
		}
107
		else {
107
		else {
108
			contexts[INSTANCE_CONTEXT].getNode(qualifier).putInt(key, value);
108
			contexts[INSTANCE_CONTEXT].getNode(qualifier).putInt(key, value);
109
		}
109
		}
110
	}
110
	}
111
	
111
	
112
	/**
112
	/**
113
	 * Sets a long preference in the {@link InstanceScope} or the given {@link IScopeContext} if it
113
	 * Sets a long preference in the {@link InstanceScope} or the given {@link IScopeContext} if it
114
	 * is not <code>null</code>. Preferences set in a given context are flushed as they are set.
114
	 * is not <code>null</code>. Preferences set in a given context are flushed as they are set.
115
	 * @param qualifier
115
	 * @param qualifier
116
	 * @param key the key
116
	 * @param key the key
117
	 * @param value the value
117
	 * @param value the value
118
	 * @param context
118
	 * @param context
119
	 */
119
	 */
120
	public static synchronized void setLong(String qualifier, String key, long value, IScopeContext context) {
120
	public static synchronized void setLong(String qualifier, String key, long value, IScopeContext context) {
121
		if(context != null) {
121
		if(context != null) {
122
			try {
122
			try {
123
				IEclipsePreferences node = context.getNode(qualifier);
123
				IEclipsePreferences node = context.getNode(qualifier);
124
				node.putLong(key, value);
124
				node.putLong(key, value);
125
				node.flush();
125
				node.flush();
126
			}
126
			}
127
			catch(BackingStoreException bse) {
127
			catch(BackingStoreException bse) {
128
				DebugPlugin.log(bse);
128
				DebugPlugin.log(bse);
129
			}
129
			}
130
		}
130
		}
131
		else {
131
		else {
132
			contexts[INSTANCE_CONTEXT].getNode(qualifier).putLong(key, value);
132
			contexts[INSTANCE_CONTEXT].getNode(qualifier).putLong(key, value);
133
		}
133
		}
134
	}
134
	}
135
	
135
	
136
	/**
136
	/**
137
	 * Sets a byte array preference in the {@link InstanceScope} or the given {@link IScopeContext} if it
137
	 * Sets a byte array preference in the {@link InstanceScope} or the given {@link IScopeContext} if it
138
	 * is not <code>null</code>. Preferences set in a given context are flushed as they are set.
138
	 * is not <code>null</code>. Preferences set in a given context are flushed as they are set.
139
	 * @param qualifier
139
	 * @param qualifier
140
	 * @param key the key
140
	 * @param key the key
141
	 * @param value the value
141
	 * @param value the value
142
	 * @param context
142
	 * @param context
143
	 */
143
	 */
144
	public static synchronized void setByteArray(String qualifier, String key, byte[] value, IScopeContext context) {
144
	public static synchronized void setByteArray(String qualifier, String key, byte[] value, IScopeContext context) {
145
		if(context != null) {
145
		if(context != null) {
146
			try {
146
			try {
147
				IEclipsePreferences node = context.getNode(qualifier);
147
				IEclipsePreferences node = context.getNode(qualifier);
148
				node.putByteArray(key, value);
148
				node.putByteArray(key, value);
149
				node.flush();
149
				node.flush();
150
			}
150
			}
151
			catch(BackingStoreException bse) {
151
			catch(BackingStoreException bse) {
152
				DebugPlugin.log(bse);
152
				DebugPlugin.log(bse);
153
			}
153
			}
154
		}
154
		}
155
		else {
155
		else {
156
			contexts[INSTANCE_CONTEXT].getNode(qualifier).putByteArray(key, value);
156
			contexts[INSTANCE_CONTEXT].getNode(qualifier).putByteArray(key, value);
157
		}
157
		}
158
	}
158
	}
159
	
159
	
160
	/**
160
	/**
161
	 * Sets a double preference in the {@link InstanceScope} or the given {@link IScopeContext} if it
161
	 * Sets a double preference in the {@link InstanceScope} or the given {@link IScopeContext} if it
162
	 * is not <code>null</code>. Preferences set in a given context are flushed as they are set.
162
	 * is not <code>null</code>. Preferences set in a given context are flushed as they are set.
163
	 * @param qualifier
163
	 * @param qualifier
164
	 * @param key the key
164
	 * @param key the key
165
	 * @param value the value
165
	 * @param value the value
166
	 * @param context
166
	 * @param context
167
	 */
167
	 */
168
	public static synchronized void setDouble(String qualifier, String key, double value, IScopeContext context) {
168
	public static synchronized void setDouble(String qualifier, String key, double value, IScopeContext context) {
169
		if(context != null) {
169
		if(context != null) {
170
			try {
170
			try {
171
				IEclipsePreferences node = context.getNode(qualifier);
171
				IEclipsePreferences node = context.getNode(qualifier);
172
				node.putDouble(key, value);
172
				node.putDouble(key, value);
173
				node.flush();
173
				node.flush();
174
			}
174
			}
175
			catch(BackingStoreException bse) {
175
			catch(BackingStoreException bse) {
176
				DebugPlugin.log(bse);
176
				DebugPlugin.log(bse);
177
			}
177
			}
178
		}
178
		}
179
		else {
179
		else {
180
			contexts[INSTANCE_CONTEXT].getNode(qualifier).putDouble(key, value);
180
			contexts[INSTANCE_CONTEXT].getNode(qualifier).putDouble(key, value);
181
		}
181
		}
182
	}
182
	}
183
	
183
	
184
	/**
184
	/**
185
	 * Sets a float preference in the {@link InstanceScope} or the given {@link IScopeContext} if it
185
	 * Sets a float preference in the {@link InstanceScope} or the given {@link IScopeContext} if it
186
	 * is not <code>null</code>. Preferences set in a given context are flushed as they are set.
186
	 * is not <code>null</code>. Preferences set in a given context are flushed as they are set.
187
	 * @param qualifier
187
	 * @param qualifier
188
	 * @param key the key
188
	 * @param key the key
189
	 * @param value the value
189
	 * @param value the value
190
	 * @param context
190
	 * @param context
191
	 */
191
	 */
192
	public static synchronized void setFloat(String qualifier, String key, float value, IScopeContext context) {
192
	public static synchronized void setFloat(String qualifier, String key, float value, IScopeContext context) {
193
		if(context != null) {
193
		if(context != null) {
194
			try {
194
			try {
195
				IEclipsePreferences node = context.getNode(qualifier);
195
				IEclipsePreferences node = context.getNode(qualifier);
196
				node.putFloat(key, value);
196
				node.putFloat(key, value);
197
				node.flush();
197
				node.flush();
198
			}
198
			}
199
			catch(BackingStoreException bse) {
199
			catch(BackingStoreException bse) {
200
				DebugPlugin.log(bse);
200
				DebugPlugin.log(bse);
201
			}
201
			}
202
		}
202
		}
203
		else {
203
		else {
204
			contexts[INSTANCE_CONTEXT].getNode(qualifier).putFloat(key, value);
204
			contexts[INSTANCE_CONTEXT].getNode(qualifier).putFloat(key, value);
205
		}
205
		}
206
	}
206
	}
207
	
207
	
208
	/**
208
	/**
209
	 * Sets a string in the {@link DefaultScope}
209
	 * Sets a string in the {@link DefaultScope}
210
	 * @param qualifier
210
	 * @param qualifier
211
	 * @param key the key
211
	 * @param key the key
212
	 * @param value the new value
212
	 * @param value the new value
213
	 */
213
	 */
214
	public static synchronized void setDefaultString(String qualifier, String key, String value) {
214
	public static synchronized void setDefaultString(String qualifier, String key, String value) {
215
		contexts[DEFAULT_CONTEXT].getNode(qualifier).put(key, value);
215
		contexts[DEFAULT_CONTEXT].getNode(qualifier).put(key, value);
216
	}
216
	}
217
	
217
	
218
	/**
218
	/**
219
	 * Sets a boolean in the {@link DefaultScope}
219
	 * Sets a boolean in the {@link DefaultScope}
220
	 * @param qualifier
220
	 * @param qualifier
221
	 * @param key the key
221
	 * @param key the key
222
	 * @param value the new value
222
	 * @param value the new value
223
	 */
223
	 */
224
	public static synchronized void setDefaultBoolean(String qualifier, String key, boolean value) {
224
	public static synchronized void setDefaultBoolean(String qualifier, String key, boolean value) {
225
		contexts[DEFAULT_CONTEXT].getNode(qualifier).putBoolean(key, value);
225
		contexts[DEFAULT_CONTEXT].getNode(qualifier).putBoolean(key, value);
226
	}
226
	}
227
	
227
	
228
	/**
228
	/**
229
	 * Sets a byte array in the {@link DefaultScope}
229
	 * Sets a byte array in the {@link DefaultScope}
230
	 * @param qualifier
230
	 * @param qualifier
231
	 * @param key the key
231
	 * @param key the key
232
	 * @param value the new value
232
	 * @param value the new value
233
	 */
233
	 */
234
	public static synchronized void setDefaultByteArray(String qualifier, String key, byte[] value) {
234
	public static synchronized void setDefaultByteArray(String qualifier, String key, byte[] value) {
235
		contexts[DEFAULT_CONTEXT].getNode(qualifier).putByteArray(key, value);
235
		contexts[DEFAULT_CONTEXT].getNode(qualifier).putByteArray(key, value);
236
	}
236
	}
237
	
237
	
238
	/**
238
	/**
239
	 * Sets a double in the {@link DefaultScope}
239
	 * Sets a double in the {@link DefaultScope}
240
	 * @param qualifier
240
	 * @param qualifier
241
	 * @param key the key
241
	 * @param key the key
242
	 * @param value the new value
242
	 * @param value the new value
243
	 */
243
	 */
244
	public static synchronized void setDefaultDouble(String qualifier, String key, double value) {
244
	public static synchronized void setDefaultDouble(String qualifier, String key, double value) {
245
		contexts[DEFAULT_CONTEXT].getNode(qualifier).putDouble(key, value);
245
		contexts[DEFAULT_CONTEXT].getNode(qualifier).putDouble(key, value);
246
	}
246
	}
247
	
247
	
248
	/**
248
	/**
249
	 * Sets a float in the {@link DefaultScope}
249
	 * Sets a float in the {@link DefaultScope}
250
	 * @param qualifier
250
	 * @param qualifier
251
	 * @param key the key
251
	 * @param key the key
252
	 * @param value the new value
252
	 * @param value the new value
253
	 */
253
	 */
254
	public static synchronized void setDefaultFloat(String qualifier, String key, float value) {
254
	public static synchronized void setDefaultFloat(String qualifier, String key, float value) {
255
		contexts[DEFAULT_CONTEXT].getNode(qualifier).putFloat(key, value);
255
		contexts[DEFAULT_CONTEXT].getNode(qualifier).putFloat(key, value);
256
	}
256
	}
257
	
257
	
258
	/**
258
	/**
259
	 * Sets a integer in the {@link DefaultScope}
259
	 * Sets a integer in the {@link DefaultScope}
260
	 * @param qualifier
260
	 * @param qualifier
261
	 * @param key the key
261
	 * @param key the key
262
	 * @param value the new value
262
	 * @param value the new value
263
	 */
263
	 */
264
	public static synchronized void setDefaultInt(String qualifier, String key, int value) {
264
	public static synchronized void setDefaultInt(String qualifier, String key, int value) {
265
		contexts[DEFAULT_CONTEXT].getNode(qualifier).putInt(key, value);
265
		contexts[DEFAULT_CONTEXT].getNode(qualifier).putInt(key, value);
266
	}
266
	}
267
	
267
	
268
	/**
268
	/**
269
	 * Sets a long in the {@link DefaultScope}
269
	 * Sets a long in the {@link DefaultScope}
270
	 * @param qualifier
270
	 * @param qualifier
271
	 * @param key the key
271
	 * @param key the key
272
	 * @param value the new value
272
	 * @param value the new value
273
	 */
273
	 */
274
	public static synchronized void setDefaultLong(String qualifier, String key, long value) {
274
	public static synchronized void setDefaultLong(String qualifier, String key, long value) {
275
		contexts[DEFAULT_CONTEXT].getNode(qualifier).putLong(key, value);
275
		contexts[DEFAULT_CONTEXT].getNode(qualifier).putLong(key, value);
276
	}
276
	}
277
	
277
	
278
	/**
278
	/**
279
	 * Sets the given preference to its default value. This is done by removing any set value
279
	 * Sets the given preference to its default value. This is done by removing any set value
280
	 * from the {@link InstanceScope}. Has no effect if the given key is <code>null</code>.
280
	 * from the {@link InstanceScope}. Has no effect if the given key is <code>null</code>.
281
	 * @param qualifier
281
	 * @param qualifier
282
	 * @param key the key for the preference
282
	 * @param key the key for the preference
283
	 */
283
	 */
284
	public static synchronized void setToDefault(String qualifier, String key) {
284
	public static synchronized void setToDefault(String qualifier, String key) {
285
		if(key != null) {
285
		if(key != null) {
286
			contexts[INSTANCE_CONTEXT].getNode(qualifier).remove(key);
286
			contexts[INSTANCE_CONTEXT].getNode(qualifier).remove(key);
287
		}
287
		}
288
	}
288
	}
289
	
289
	
290
	/**
290
	/**
291
	 * Returns the default boolean value stored in the {@link DefaultScope} for the given key
291
	 * Returns the default boolean value stored in the {@link DefaultScope} for the given key
292
	 * or the specified default value if the key does not appear in the {@link DefaultScope}
292
	 * or the specified default value if the key does not appear in the {@link DefaultScope}
293
	 * @param qualifier
293
	 * @param qualifier
294
	 * @param key
294
	 * @param key
295
	 * @param defaultvalue
295
	 * @param defaultvalue
296
	 * 
296
	 * 
297
	 * @return the boolean value set in the {@link DefaultScope} for the given key, or the specified default value.
297
	 * @return the boolean value set in the {@link DefaultScope} for the given key, or the specified default value.
298
	 */
298
	 */
299
	public static synchronized boolean getDefaultBoolean(String qualifier, String key, boolean defaultvalue) {
299
	public static synchronized boolean getDefaultBoolean(String qualifier, String key, boolean defaultvalue) {
300
		return contexts[DEFAULT_CONTEXT].getNode(qualifier).getBoolean(key, defaultvalue);
300
		return contexts[DEFAULT_CONTEXT].getNode(qualifier).getBoolean(key, defaultvalue);
301
	}
301
	}
302
	
302
	
303
	/**
303
	/**
304
	 * Returns the default string value stored in the {@link DefaultScope} for the given key
304
	 * Returns the default string value stored in the {@link DefaultScope} for the given key
305
	 * or the specified default value if the key does not appear in the {@link DefaultScope}
305
	 * or the specified default value if the key does not appear in the {@link DefaultScope}
306
	 * @param qualifier
306
	 * @param qualifier
307
	 * @param key
307
	 * @param key
308
	 * @param defaultvalue
308
	 * @param defaultvalue
309
	 * 
309
	 * 
310
	 * @return the string value set in the {@link DefaultScope} for the given key, or the specified default value.
310
	 * @return the string value set in the {@link DefaultScope} for the given key, or the specified default value.
311
	 */
311
	 */
312
	public static synchronized String getDefaultString(String qualifier, String key, String defaultvalue) {
312
	public static synchronized String getDefaultString(String qualifier, String key, String defaultvalue) {
313
		return contexts[DEFAULT_CONTEXT].getNode(qualifier).get(key, defaultvalue);
313
		return contexts[DEFAULT_CONTEXT].getNode(qualifier).get(key, defaultvalue);
314
	}
314
	}
315
	
315
	
316
	/**
316
	/**
317
	 * Returns the default byte array value stored in the {@link DefaultScope} for the given key
317
	 * Returns the default byte array value stored in the {@link DefaultScope} for the given key
318
	 * or the specified default value if the key does not appear in the {@link DefaultScope}
318
	 * or the specified default value if the key does not appear in the {@link DefaultScope}
319
	 * @param qualifier
319
	 * @param qualifier
320
	 * @param key
320
	 * @param key
321
	 * @param defaultvalue
321
	 * @param defaultvalue
322
	 * 
322
	 * 
323
	 * @return the byte array value set in the {@link DefaultScope} for the given key, or the specified default value.
323
	 * @return the byte array value set in the {@link DefaultScope} for the given key, or the specified default value.
324
	 */
324
	 */
325
	public static synchronized byte[] getDefaultByteArray(String qualifier, String key, byte[] defaultvalue) {
325
	public static synchronized byte[] getDefaultByteArray(String qualifier, String key, byte[] defaultvalue) {
326
		return contexts[DEFAULT_CONTEXT].getNode(qualifier).getByteArray(key, defaultvalue);
326
		return contexts[DEFAULT_CONTEXT].getNode(qualifier).getByteArray(key, defaultvalue);
327
	}
327
	}
328
	
328
	
329
	/**
329
	/**
330
	 * Returns the default integer value stored in the {@link DefaultScope} for the given key
330
	 * Returns the default integer value stored in the {@link DefaultScope} for the given key
331
	 * or the specified default value if the key does not appear in the {@link DefaultScope}
331
	 * or the specified default value if the key does not appear in the {@link DefaultScope}
332
	 * @param qualifier
332
	 * @param qualifier
333
	 * @param key
333
	 * @param key
334
	 * @param defaultvalue
334
	 * @param defaultvalue
335
	 * 
335
	 * 
336
	 * @return the integer value set in the {@link DefaultScope} for the given key, or the specified default value.
336
	 * @return the integer value set in the {@link DefaultScope} for the given key, or the specified default value.
337
	 */
337
	 */
338
	public static synchronized int getDefaultInt(String qualifier, String key, int defaultvalue) {
338
	public static synchronized int getDefaultInt(String qualifier, String key, int defaultvalue) {
339
		return contexts[DEFAULT_CONTEXT].getNode(qualifier).getInt(key, defaultvalue);
339
		return contexts[DEFAULT_CONTEXT].getNode(qualifier).getInt(key, defaultvalue);
340
	}
340
	}
341
	
341
	
342
	/**
342
	/**
343
	 * Returns the default long value stored in the {@link DefaultScope} for the given key
343
	 * Returns the default long value stored in the {@link DefaultScope} for the given key
344
	 * or the specified default value if the key does not appear in the {@link DefaultScope}
344
	 * or the specified default value if the key does not appear in the {@link DefaultScope}
345
	 * @param qualifier
345
	 * @param qualifier
346
	 * @param key
346
	 * @param key
347
	 * @param defaultvalue
347
	 * @param defaultvalue
348
	 * 
348
	 * 
349
	 * @return the long value set in the {@link DefaultScope} for the given key, or the specified default value.
349
	 * @return the long value set in the {@link DefaultScope} for the given key, or the specified default value.
350
	 */
350
	 */
351
	public static synchronized long getDefaultLong(String qualifier, String key, long defaultvalue) {
351
	public static synchronized long getDefaultLong(String qualifier, String key, long defaultvalue) {
352
		return contexts[DEFAULT_CONTEXT].getNode(qualifier).getLong(key, defaultvalue);
352
		return contexts[DEFAULT_CONTEXT].getNode(qualifier).getLong(key, defaultvalue);
353
	}
353
	}
354
	
354
	
355
	/**
355
	/**
356
	 * Returns the default double value stored in the {@link DefaultScope} for the given key
356
	 * Returns the default double value stored in the {@link DefaultScope} for the given key
357
	 * or the specified default value if the key does not appear in the {@link DefaultScope}
357
	 * or the specified default value if the key does not appear in the {@link DefaultScope}
358
	 * @param qualifier
358
	 * @param qualifier
359
	 * @param key
359
	 * @param key
360
	 * @param defaultvalue
360
	 * @param defaultvalue
361
	 * 
361
	 * 
362
	 * @return the double value set in the {@link DefaultScope} for the given key, or the specified default value.
362
	 * @return the double value set in the {@link DefaultScope} for the given key, or the specified default value.
363
	 */
363
	 */
364
	public static synchronized double getDefaultDouble(String qualifier, String key, double defaultvalue) {
364
	public static synchronized double getDefaultDouble(String qualifier, String key, double defaultvalue) {
365
		return contexts[DEFAULT_CONTEXT].getNode(qualifier).getDouble(key, defaultvalue);
365
		return contexts[DEFAULT_CONTEXT].getNode(qualifier).getDouble(key, defaultvalue);
366
	}
366
	}
367
	
367
	
368
	/**
368
	/**
369
	 * Returns the default float value stored in the {@link DefaultScope} for the given key
369
	 * Returns the default float value stored in the {@link DefaultScope} for the given key
370
	 * or the specified default value if the key does not appear in the {@link DefaultScope}
370
	 * or the specified default value if the key does not appear in the {@link DefaultScope}
371
	 * @param qualifier
371
	 * @param qualifier
372
	 * @param key
372
	 * @param key
373
	 * @param defaultvalue
373
	 * @param defaultvalue
374
	 * 
374
	 * 
375
	 * @return the float value set in the {@link DefaultScope} for the given key, or the specified default value.
375
	 * @return the float value set in the {@link DefaultScope} for the given key, or the specified default value.
376
	 */
376
	 */
377
	public static synchronized float getDefaultFloat(String qualifier, String key, float defaultvalue) {
377
	public static synchronized float getDefaultFloat(String qualifier, String key, float defaultvalue) {
378
		return contexts[DEFAULT_CONTEXT].getNode(qualifier).getFloat(key, defaultvalue);
378
		return contexts[DEFAULT_CONTEXT].getNode(qualifier).getFloat(key, defaultvalue);
379
	}
379
	}
380
	
380
	
381
	/**
381
	/**
382
	 * Save the preferences for the given plugin identifier.
382
	 * Save the preferences for the given plugin identifier.
383
	 * It should be noted that all pending preference changes will be flushed with this method.
383
	 * It should be noted that all pending preference changes will be flushed with this method.
384
	 * @param qualifier
384
	 * @param qualifier
385
	 */
385
	 */
386
	public static synchronized void savePreferences(String qualifier) {
386
	public static synchronized void savePreferences(String qualifier) {
387
		try {
387
		try {
388
			contexts[DEFAULT_CONTEXT].getNode(qualifier).flush();
388
			contexts[DEFAULT_CONTEXT].getNode(qualifier).flush();
389
			contexts[INSTANCE_CONTEXT].getNode(qualifier).flush();
389
			contexts[INSTANCE_CONTEXT].getNode(qualifier).flush();
390
		}
390
		}
391
		catch(BackingStoreException bse) {
391
		catch(BackingStoreException bse) {
392
			DebugPlugin.log(bse);
392
			DebugPlugin.log(bse);
393
		}
393
		}
394
	}
394
	}
395
	
395
	
396
	/**
396
	/**
397
	 * Adds the given preference listener to the {@link DefaultScope} and the {@link InstanceScope}
397
	 * Adds the given preference listener to the {@link DefaultScope} and the {@link InstanceScope}
398
	 * @param qualifier
398
	 * @param qualifier
399
	 * @param listener
399
	 * @param listener
400
	 */
400
	 */
401
	public static void addPreferenceListener(String qualifier, IEclipsePreferences.IPreferenceChangeListener listener) {
401
	public static void addPreferenceListener(String qualifier, IEclipsePreferences.IPreferenceChangeListener listener) {
402
		contexts[DEFAULT_CONTEXT].getNode(qualifier).addPreferenceChangeListener(listener);
402
		contexts[DEFAULT_CONTEXT].getNode(qualifier).addPreferenceChangeListener(listener);
403
		contexts[INSTANCE_CONTEXT].getNode(qualifier).addPreferenceChangeListener(listener);
403
		contexts[INSTANCE_CONTEXT].getNode(qualifier).addPreferenceChangeListener(listener);
404
	}
404
	}
405
	
405
	
406
	/**
406
	/**
407
	 * Removes the given preference listener from the {@link DefaultScope} and the {@link InstanceScope}
407
	 * Removes the given preference listener from the {@link DefaultScope} and the {@link InstanceScope}
408
	 * @param qualifier
408
	 * @param qualifier
409
	 * @param listener
409
	 * @param listener
410
	 */
410
	 */
411
	public static void removePreferenceListener(String qualifier, IEclipsePreferences.IPreferenceChangeListener listener) {
411
	public static void removePreferenceListener(String qualifier, IEclipsePreferences.IPreferenceChangeListener listener) {
412
		contexts[DEFAULT_CONTEXT].getNode(qualifier).removePreferenceChangeListener(listener);
412
		contexts[DEFAULT_CONTEXT].getNode(qualifier).removePreferenceChangeListener(listener);
413
		contexts[INSTANCE_CONTEXT].getNode(qualifier).removePreferenceChangeListener(listener);
413
		contexts[INSTANCE_CONTEXT].getNode(qualifier).removePreferenceChangeListener(listener);
414
	}
414
	}
415
}
415
}
(-)core/org/eclipse/debug/internal/core/LaunchManager.java (+148 lines)
Lines 2596-2600 Link Here
2596
			}
2596
			}
2597
		}
2597
		}
2598
		return fActiveModes.contains(mode);
2598
		return fActiveModes.contains(mode);
2599
	}
2600
2601
	/**
2602
	 * Returns whether the given configuration should be launched in the background.
2603
	 * 
2604
	 * @param configuration the configuration
2605
	 * @return whether the configuration is configured to launch in the background
2606
	 */
2607
	public static boolean isLaunchInBackground(ILaunchConfiguration configuration) {
2608
		boolean launchInBackground= true;
2609
		try {
2610
			launchInBackground= configuration.getAttribute(ILaunchManager.ATTR_LAUNCH_IN_BACKGROUND, true);
2611
		} catch (CoreException ce) {
2612
			DebugPlugin.log(ce);
2613
		}
2614
		return launchInBackground;
2599
	}	
2615
	}	
2616
	
2617
	/**
2618
	 * Returns the refresh scope attribute specified by the given launch configuration
2619
	 * or <code>null</code> if none.
2620
	 * 
2621
	 * @param configuration launch configuration
2622
	 * @return refresh scope attribute (<code>ATTR_REFRESH_SCOPE</code>)
2623
	 * @throws CoreException if unable to access the associated attribute
2624
	 */
2625
	public static String getRefreshScope(ILaunchConfiguration configuration) throws CoreException {
2626
		return configuration.getAttribute(ATTR_REFRESH_SCOPE, (String) null);
2627
	}
2628
	
2629
	
2630
	/**
2631
	 * Refreshes the resources as specified by the given launch configuration.
2632
	 * 
2633
	 * @param configuration launch configuration
2634
	 * @param monitor progress monitor which may be <code>null</code>
2635
	 * @throws CoreException if an exception occurs while refreshing resources
2636
	 */
2637
	public static void refreshResources(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
2638
		if (monitor == null) {
2639
			monitor = new NullProgressMonitor();
2640
		}
2641
		String scope = getRefreshScope(configuration);
2642
		IResource[] resources= null;
2643
		if (scope != null) {
2644
			resources = getRefreshResources(scope);
2645
		}
2646
		if (resources == null || resources.length == 0){
2647
			return;
2648
		}
2649
		int depth = IResource.DEPTH_ONE;
2650
		if (isRefreshRecursive(configuration))
2651
			depth = IResource.DEPTH_INFINITE;
2652
	
2653
		if (monitor.isCanceled()) {
2654
			return;
2655
		}
2656
	
2657
		monitor.beginTask(DebugCoreMessages.RefreshingResources, 
2658
			resources.length);
2659
	
2660
		MultiStatus status = new MultiStatus(DebugPlugin.getUniqueIdentifier(), 0, DebugCoreMessages.RefreshingResourcesError, null); 
2661
		for (int i = 0; i < resources.length; i++) {
2662
			if (monitor.isCanceled())
2663
				break;
2664
			if (resources[i] != null && resources[i].isAccessible()) {
2665
				try {
2666
					resources[i].refreshLocal(depth, null);
2667
				} catch (CoreException e) {
2668
					status.merge(e.getStatus());
2669
				}
2670
			}
2671
			monitor.worked(1);
2672
		}
2673
	
2674
		monitor.done();
2675
		if (!status.isOK()) {
2676
			throw new CoreException(status);
2677
		}
2678
	}
2679
	
2680
	/**
2681
	 * Returns a collection of resources referred to by a refresh scope attribute.
2682
	 * 
2683
	 * @param scope refresh scope attribute (<code>ATTR_REFRESH_SCOPE</code>)
2684
	 * @return collection of resources referred to by the refresh scope attribute
2685
	 * @throws CoreException if unable to resolve a set of resources
2686
	 */
2687
	public static IResource[] getRefreshResources(String scope) throws CoreException {
2688
//		if (scope.startsWith("${resource:")) { //$NON-NLS-1$
2689
//			// This is an old format that is replaced with 'working_set'
2690
//			String pathString = scope.substring(11, scope.length() - 1);
2691
//			Path path = new Path(pathString);
2692
//			IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
2693
//			if (resource == null) {
2694
//				throw new CoreException(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, MessageFormat.format(StringSubstitutionMessages.RefreshTab_43, new String[]{pathString}), null)); 
2695
//			} 
2696
//			return new IResource[]{resource};
2697
//		} else if (scope.startsWith("${working_set:")) { //$NON-NLS-1$
2698
//			IWorkingSet workingSet =  getWorkingSet(scope);
2699
//			if (workingSet == null) {
2700
//				throw new CoreException(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, StringSubstitutionMessages.RefreshTab_44, null));  
2701
//			} 
2702
//			IAdaptable[] elements = workingSet.getElements();
2703
//			IResource[] resources = new IResource[elements.length];
2704
//			for (int i = 0; i < elements.length; i++) {
2705
//				IAdaptable adaptable = elements[i];
2706
//				if (adaptable instanceof IResource) {
2707
//					resources[i] = (IResource) adaptable;
2708
//				} else {
2709
//					resources[i] = (IResource) adaptable.getAdapter(IResource.class);
2710
//				}
2711
//			}
2712
//			return resources;				
2713
//		} else if(scope.equals("${workspace}")) { //$NON-NLS-1$
2714
//			return new IResource[]{ResourcesPlugin.getWorkspace().getRoot()};
2715
//		} else {
2716
//			IResource resource = SelectedResourceManager.getDefault().getSelectedResource();
2717
//			if (resource == null) {
2718
//				// empty selection
2719
//				return new IResource[]{};
2720
//			}
2721
//			if (scope.equals("${resource}")) { //$NON-NLS-1$
2722
//				// resource = resource
2723
//			} else if (scope.equals("${container}")) { //$NON-NLS-1$
2724
//				resource = resource.getParent();
2725
//			} else if (scope.equals("${project}")) { //$NON-NLS-1$
2726
//				resource = resource.getProject();
2727
//			}
2728
//			return new IResource[]{resource};
2729
//		}
2730
		return null;
2731
	}
2732
	
2733
	/**
2734
	 * Returns whether the refresh scope specified by the given launch
2735
	 * configuration is recursive.
2736
	 * 
2737
	 * @param configuration
2738
	 * @return whether the refresh scope is recursive
2739
	 * @throws CoreException if unable to access the associated attribute
2740
	 */
2741
	public static boolean isRefreshRecursive(ILaunchConfiguration configuration) throws CoreException {
2742
		return configuration.getAttribute(ATTR_REFRESH_RECURSIVE, true);
2743
	}
2744
	
2745
	
2746
	
2747
	
2600
}
2748
}
(-)core/org/eclipse/debug/internal/core/DebugCoreMessages.properties (+2 lines)
Lines 98-100 Link Here
98
LaunchConfigurationType_7=Launch mode not supported: {0}
98
LaunchConfigurationType_7=Launch mode not supported: {0}
99
WatchExpression_0=(Watch expressions not supported)
99
WatchExpression_0=(Watch expressions not supported)
100
NullStreamsProxy_0=Null Stream Monitor
100
NullStreamsProxy_0=Null Stream Monitor
101
RefreshingResources=Refresh resources...
102
RefreshingResourcesError=Exception(s) occurred during refresh.
(-)core/org/eclipse/debug/core/ILaunchManager.java (+32 lines)
Lines 46-51 Link Here
46
	public static final String PROFILE_MODE= "profile"; //$NON-NLS-1$	
46
	public static final String PROFILE_MODE= "profile"; //$NON-NLS-1$	
47
	
47
	
48
	/**
48
	/**
49
	 * Launch configuration attribute - a boolean value indicating whether a
50
	 * configuration should be launched in the background. Default value is <code>true</code>.
51
	 * 
52
	 * @since 3.0
53
	 */
54
	public static final String ATTR_LAUNCH_IN_BACKGROUND = DebugPlugin.getUniqueIdentifier() + ".ATTR_LAUNCH_IN_BACKGROUND"; //$NON-NLS-1$
55
	
56
	
57
	/**
58
	 * String attribute identifying the scope of resources that should be
59
	 * refreshed after an external tool is run. The value is either a refresh
60
	 * variable or the default value, <code>null</code>, indicating no refresh.
61
	 */
62
	public static final String ATTR_REFRESH_SCOPE = DebugPlugin.getUniqueIdentifier() + ".ATTR_REFRESH_SCOPE"; //$NON-NLS-1$
63
	
64
	
65
	/**
66
	 * Boolean attribute indicating if a refresh scope is recursive. Default
67
	 * value is <code>false</code>.
68
	 */
69
	public static final String ATTR_REFRESH_RECURSIVE = DebugPlugin.getUniqueIdentifier() + ".ATTR_REFRESH_RECURSIVE"; //$NON-NLS-1$
70
71
	/**
72
	 * Launch configuration attribute - a boolean value that indicates if the launch configuration
73
	 * is 'private'.  A private configuration is one that does not appear to the user in the launch
74
	 * history or the launch configuration dialog.
75
	 * 
76
	 * @since 2.0
77
	 */
78
	public static final String ATTR_PRIVATE = DebugPlugin.getUniqueIdentifier() + ".private"; //$NON-NLS-1$
79
	
80
	/**
49
	 * Launch configuration attribute name. The value is a map of environment
81
	 * Launch configuration attribute name. The value is a map of environment
50
	 * variables passed into Runtime.exec(...) when a launch configuration is launched.
82
	 * variables passed into Runtime.exec(...) when a launch configuration is launched.
51
	 * Default value is <code>null</code> which indicates the default environment
83
	 * Default value is <code>null</code> which indicates the default environment
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 12-18 Link Here
12
 org.eclipse.debug.core.model,
12
 org.eclipse.debug.core.model,
13
 org.eclipse.debug.core.sourcelookup,
13
 org.eclipse.debug.core.sourcelookup,
14
 org.eclipse.debug.core.sourcelookup.containers,
14
 org.eclipse.debug.core.sourcelookup.containers,
15
 org.eclipse.debug.internal.core;x-friends:="org.eclipse.debug.ui",
15
 org.eclipse.debug.internal.core;x-friends:="org.eclipse.debug.ui,org.eclipse.ant.launching,org.eclipse.core.externaltools",
16
 org.eclipse.debug.internal.core.commands;x-friends:="org.eclipse.debug.ui",
16
 org.eclipse.debug.internal.core.commands;x-friends:="org.eclipse.debug.ui",
17
 org.eclipse.debug.internal.core.sourcelookup;x-friends:="org.eclipse.debug.ui",
17
 org.eclipse.debug.internal.core.sourcelookup;x-friends:="org.eclipse.debug.ui",
18
 org.eclipse.debug.internal.core.sourcelookup.containers;x-friends:="org.eclipse.debug.ui",
18
 org.eclipse.debug.internal.core.sourcelookup.containers;x-friends:="org.eclipse.debug.ui",
(-)src/org/eclipse/ant/internal/launching/AntLaunching.java (+60 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching;
11
package org.eclipse.ant.internal.launching;
12
12
13
import org.eclipse.core.runtime.IStatus;
13
import org.eclipse.core.runtime.Plugin;
14
import org.eclipse.core.runtime.Plugin;
15
import org.eclipse.core.runtime.Status;
16
import org.eclipse.jface.preference.PreferenceStore;
14
import org.osgi.framework.BundleContext;
17
import org.osgi.framework.BundleContext;
15
18
16
/**
19
/**
Lines 20-29 Link Here
20
23
21
	// The plug-in ID
24
	// The plug-in ID
22
	public static final String PLUGIN_ID = "org.eclipse.ant.launching"; //$NON-NLS-1$
25
	public static final String PLUGIN_ID = "org.eclipse.ant.launching"; //$NON-NLS-1$
26
	
27
	private static final String EMPTY_STRING= ""; //$NON-NLS-1$
28
	
29
	/**
30
	 * Status code indicating an unexpected internal error.
31
	 * @since 2.1
32
	 */
33
	public static final int INTERNAL_ERROR = 120;	
23
34
24
	// The shared instance
35
	// The shared instance
25
	private static AntLaunching plugin;
36
	private static AntLaunching plugin;
26
	
37
	
38
	private static PreferenceStore preferenceStore;
39
	
27
	/**
40
	/**
28
	 * The constructor
41
	 * The constructor
29
	 */
42
	 */
Lines 56-60 Link Here
56
	public static AntLaunching getDefault() {
69
	public static AntLaunching getDefault() {
57
		return plugin;
70
		return plugin;
58
	}
71
	}
72
	
73
	public static String getUniqueIdentifier() {
74
		return PLUGIN_ID;
75
	}
76
	
77
	/**
78
	 * Logs the specified throwable with this plug-in's log.
79
	 * 
80
	 * @param t throwable to log 
81
	 */
82
	public static void log(Throwable t) {
83
		IStatus status= new Status(IStatus.ERROR, PLUGIN_ID, INTERNAL_ERROR, "Error logged from Ant UI: ", t); //$NON-NLS-1$
84
		log(status);
85
	}
86
	
87
	/**
88
	 * Logs the specified status with this plug-in's log.
89
	 * 
90
	 * @param status status 
91
	 */
92
	public static void log(IStatus status) {
93
		getDefault().getLog().log(status);
94
	}
95
	
96
	/**
97
	 * Writes the message to the plug-in's log
98
	 * 
99
	 * @param message the text to write to the log
100
	 */
101
	public static void log(String message, Throwable exception) {
102
		IStatus status = newErrorStatus(message, exception);
103
		log(status);
104
	}
105
	
106
	/**
107
	 * Returns a new <code>IStatus</code> for this plug-in
108
	 */
109
	public static IStatus newErrorStatus(String message, Throwable exception) {
110
		if (message == null) {
111
			message= EMPTY_STRING; 
112
		}		
113
		return new Status(IStatus.ERROR, PLUGIN_ID, 0, message, exception);
114
	}
115
	
116
	public static AntLaunching getPlugin() {
117
		return plugin;
118
	}
59
119
60
}
120
}
(-).settings/org.eclipse.jdt.core.prefs (-2 / +2 lines)
Lines 1-6 Link Here
1
#Wed Sep 16 09:44:05 CDT 2009
1
#Sun Sep 20 13:08:07 CEST 2009
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6
org.eclipse.jdt.core.compiler.compliance=1.4
6
org.eclipse.jdt.core.compiler.compliance=1.4
(-)build.properties (-1 / +3 lines)
Lines 1-4 Link Here
1
source.. = src/
1
source.. = src/
2
output.. = bin/
2
output.. = bin/
3
bin.includes = META-INF/,\
3
bin.includes = META-INF/,\
4
               .
4
               .,\
5
               plugin.xml,\
6
               plugin.properties
(-)plugin.properties (-1 / +15 lines)
Lines 10-13 Link Here
10
###############################################################################
10
###############################################################################
11
11
12
pluginName=Ant Launching Support
12
pluginName=Ant Launching Support
13
providerName=Eclipse.org
13
providerName=Eclipse.org
14
15
AntBuild=Ant Build
16
AntBuilder.name=Ant Builder
17
AntLaunchShortcut.label=Ant Build
18
AntLaunchShortcutWithDialog.label=Ant Build...
19
antLaunchConfigurationTabGroup.description=Run an Ant build file.
20
antBuilderLaunchConfigurationTabGroup.description=Create a configuration that will run an Ant build file during a build.
21
22
AntLaunchDelegate.name=Eclipse Ant Launcher
23
AntLaunchDelegate.description=The Eclipse Ant Launcher supports running and debugging Ant build files.
24
AntBuilderLaunchDelegate.name= Eclipse Ant Builder Launcher
25
AntBuilderLaunchDelegate.description=The Eclipse Ant Builder Launcher supports running Ant build files.
26
AntBuild...Shortcut.description=Launches an Ant build and allows it to be configured 
27
AntBuildShortcut.description=Launches an Ant build with default settings
(-)META-INF/MANIFEST.MF (-4 / +13 lines)
Lines 1-16 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.ant.launching
4
Bundle-SymbolicName: org.eclipse.ant.launching;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-Activator: org.eclipse.ant.internal.launching.AntLaunching
6
Bundle-Activator: org.eclipse.ant.internal.launching.AntLaunching
7
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
7
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
8
 org.eclipse.debug.core;bundle-version="[3.6.0,4.0.0)",
8
 org.eclipse.debug.core;bundle-version="[3.5.0,4.0.0)",
9
 org.eclipse.jdt.launching;bundle-version="[3.5.0,4.0.0)",
9
 org.eclipse.jdt.launching;bundle-version="[3.5.0,4.0.0)",
10
 org.eclipse.core.variables;bundle-version="[3.2.0,4.0.0)",
10
 org.eclipse.core.variables;bundle-version="[3.2.0,4.0.0)",
11
 org.eclipse.ant.core;bundle-version="[3.2.0,4.0.0)",
11
 org.eclipse.ant.core;bundle-version="[3.2.0,4.0.0)",
12
 org.apache.ant;bundle-version="1.7.1"
12
 org.apache.ant;bundle-version="1.7.1",
13
 org.eclipse.jdt.core;bundle-version="3.5.0",
14
 org.eclipse.core.commands;bundle-version="3.5.0",
15
 org.eclipse.core.externaltools;bundle-version="1.0.0"
13
Bundle-RequiredExecutionEnvironment: J2SE-1.4
16
Bundle-RequiredExecutionEnvironment: J2SE-1.4
14
Bundle-ActivationPolicy: lazy
17
Bundle-ActivationPolicy: lazy
15
Bundle-Vendor: %providerName
18
Bundle-Vendor: %providerName
16
Export-Package: org.eclipse.ant.internal.launching;x-internal:=true
19
Export-Package: org.eclipse.ant.internal.launching;x-friends:="org.eclipse.ant.ui,org.eclipse.ant.core",
20
 org.eclipse.ant.internal.launching.launchConfigurations;x-friends:="org.eclipse.ant.ui"
21
Import-Package: com.ibm.icu.text,
22
 org.eclipse.ant.internal.launching.launchConfigurations,
23
 org.eclipse.core.filebuffers,
24
 org.eclipse.jface.preference,
25
 org.eclipse.jface.text
(-)src/org/eclipse/ant/internal/launching/debug/model/AntProperties.java (+109 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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.ant.internal.launching.debug.model;
12
13
import org.eclipse.debug.core.DebugException;
14
import org.eclipse.debug.core.model.IValue;
15
import org.eclipse.debug.core.model.IVariable;
16
17
public class AntProperties extends AntDebugElement implements IVariable {
18
	
19
	private IValue fValue;
20
	private String fName;
21
    private boolean fValid= true;
22
23
	public AntProperties(AntDebugTarget target, String name) {
24
		super(target);
25
		fName= name;
26
	}
27
28
	/* (non-Javadoc)
29
	 * @see org.eclipse.debug.core.model.IVariable#getValue()
30
	 */
31
	public synchronized IValue getValue() throws DebugException {
32
        int attempts= 0;
33
        while (!fValid && !getDebugTarget().isTerminated()) {
34
            try {
35
                wait(50);
36
            } catch (InterruptedException e) {
37
            }
38
            if (attempts == 20 && !fValid && !getDebugTarget().isTerminated()) {
39
                throwDebugException(DebugModelMessages.AntProperties_1);
40
            }
41
            attempts++;
42
        }
43
 		return fValue;
44
	}
45
    
46
    protected IValue getLastValue() {
47
        return fValue;
48
    }
49
50
	/* (non-Javadoc)
51
	 * @see org.eclipse.debug.core.model.IVariable#getName()
52
	 */
53
	public String getName() {
54
		return fName;
55
	}
56
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
59
	 */
60
	public String getReferenceTypeName() {
61
		return ""; //$NON-NLS-1$
62
	}
63
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.debug.core.model.IVariable#hasValueChanged()
66
	 */
67
	public boolean hasValueChanged() {
68
		return false;
69
	}
70
71
	/* (non-Javadoc)
72
	 * @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String)
73
	 */
74
	public void setValue(String expression) {
75
	}
76
77
	/* (non-Javadoc)
78
	 * @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue)
79
	 */
80
	public void setValue(IValue value) {
81
		fValue= value;
82
	}
83
84
	/* (non-Javadoc)
85
	 * @see org.eclipse.debug.core.model.IValueModification#supportsValueModification()
86
	 */
87
	public boolean supportsValueModification() {
88
		return false;
89
	}
90
91
	/* (non-Javadoc)
92
	 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String)
93
	 */
94
	public boolean verifyValue(String expression) {
95
		return false;
96
	}
97
98
	/* (non-Javadoc)
99
	 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(org.eclipse.debug.core.model.IValue)
100
	 */
101
	public boolean verifyValue(IValue value) {
102
		return false;
103
	}
104
105
    protected synchronized void setValid(boolean valid) {
106
        fValid= valid;        
107
        notifyAll();
108
    }
109
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/IAntLaunchConfigurationConstants.java (+152 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 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
12
package org.eclipse.ant.internal.launching.launchConfigurations;
13
14
15
import org.eclipse.core.internal.externaltools.model.IExternalToolConstants;
16
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
17
18
19
20
/**
21
 * Constant definitions for Ant launch configurations.
22
 * 
23
 * @since 3.4
24
 * @noimplement This interface is not intended to be implemented by clients.
25
 */
26
public interface IAntLaunchConfigurationConstants {
27
28
	public static final String PLUGIN_ID =  "org.eclipse.ant.launching";  //$NON-NLS-1$
29
	
30
	/**
31
	* String attribute indicating the custom runtime classpath to use for an Ant
32
	* build. Default value is <code>null</code> which indicates that the global
33
	* classpath is to be used. Format is a comma separated listing of URLs.
34
	* @deprecated no longer supported: use {@link IJavaLaunchConfigurationConstants#ATTR_CLASSPATH_PROVIDER}
35
	* @see IJavaLaunchConfigurationConstants#ATTR_DEFAULT_CLASSPATH
36
	*/
37
	public static final String ATTR_ANT_CUSTOM_CLASSPATH = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_CUSTOM_CLASSPATH"; //$NON-NLS-1$
38
	/**
39
	 * String attribute indicating the custom Ant home to use for an Ant build.
40
	 * Default value is <code>null</code> which indicates that no Ant home is to
41
	 * be set 
42
	 * @deprecated no longer supported: use {@link IJavaLaunchConfigurationConstants#ATTR_CLASSPATH_PROVIDER}
43
	 * @see IJavaLaunchConfigurationConstants#ATTR_DEFAULT_CLASSPATH
44
	 */
45
	public static final String ATTR_ANT_HOME = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_HOME"; //$NON-NLS-1$
46
	
47
	/**
48
	 * Ant launch configuration type identifier.
49
	 */
50
	public static final String ID_ANT_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ant.AntLaunchConfigurationType"; //$NON-NLS-1$
51
52
	/**
53
	 * Ant builder launch configuration type identifier. Ant project builders
54
	 * are of this type.
55
	 */
56
	public static final String ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ant.AntBuilderLaunchConfigurationType"; //$NON-NLS-1$
57
	
58
	/**
59
	 * String attribute indicating the Ant targets to execute. Default value is
60
	 * <code>null</code> which indicates that the default target is to be
61
	 * executed. Format is a comma separated listing of targets.
62
	 */
63
	public static final String ATTR_ANT_TARGETS = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_TARGETS"; //$NON-NLS-1$
64
	
65
	/**
66
	 * String attribute indicating the Ant targets to execute after a clean (full build) for an Ant builder. Default value is
67
	 * <code>null</code> which indicates that the default target is to be
68
	 * executed. Format is a comma separated listing of targets.
69
	 */
70
	public static final String ATTR_ANT_AFTER_CLEAN_TARGETS = PLUGIN_ID + ".ATTR_ANT_AFTER_CLEAN_TARGETS"; //$NON-NLS-1$
71
	
72
	/**
73
	 * String attribute indicating the Ant targets to execute during a manual build for an Ant builder. Default value is
74
	 * <code>null</code> which indicates that the default target is to be
75
	 * executed. Format is a comma separated listing of targets.
76
	 */
77
	public static final String ATTR_ANT_MANUAL_TARGETS = PLUGIN_ID + ".ATTR_ANT_MANUAL_TARGETS"; //$NON-NLS-1$
78
	
79
	/**
80
	 * String attribute indicating the Ant targets to execute during an auto build for an Ant builder. Default value is
81
	 * <code>null</code> which indicates that the default target is to be
82
	 * executed. Format is a comma separated listing of targets.
83
	 */
84
	public static final String ATTR_ANT_AUTO_TARGETS = PLUGIN_ID + ".ATTR_ANT_AUTO_TARGETS"; //$NON-NLS-1$
85
	
86
	/**
87
	 * String attribute indicating the Ant targets to execute during a clean for an Ant builder. Default value is
88
	 * <code>null</code> which indicates that the default target is to be
89
	 * executed. Format is a comma separated listing of targets.
90
	 */
91
	public static final String ATTR_ANT_CLEAN_TARGETS = PLUGIN_ID + ".ATTR_ANT_CLEAN_TARGETS"; //$NON-NLS-1$
92
	
93
	/**
94
	 * Boolean attribute indicating whether or not target specification for an Ant builder 
95
	 * has been updated for 3.1 
96
	 */
97
	public static final String ATTR_TARGETS_UPDATED = PLUGIN_ID + ".ATTR_TARGETS_UPDATED"; //$NON-NLS-1$
98
	
99
	/**
100
	 * Map attribute indicating the Ant properties to be defined during the
101
	 * build. Default value is <code>null</code> which indicates no additional
102
	 * properties will be defined.
103
	 */
104
	public static final String ATTR_ANT_PROPERTIES = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_PROPERTIES"; //$NON-NLS-1$					
105
	
106
	/**
107
	 * String attribute indicating the Ant targets to execute. Default value is
108
	 * <code>null</code> which indicates that no additional property files
109
	 * will be defined. Format is a comma separated listing of property files.
110
	 */
111
	public static final String ATTR_ANT_PROPERTY_FILES = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_PROPERTY_FILES"; //$NON-NLS-1$
112
	
113
	/**
114
	 * Boolean attribute indicating whether or not internal targets (targets with no
115
	 * description) should be hidden from the user in the launch configuration dialog.
116
	 * Default value is <code>false</code> which indicates that all targets will be
117
	 * displayed.
118
	 */
119
	public static final String ATTR_HIDE_INTERNAL_TARGETS = IExternalToolConstants.PLUGIN_ID + ".ATTR_HIDE_INTERNAL_TARGETS"; //$NON-NLS-1$
120
	
121
	/**
122
	 * Integer attribute indicating which column targets should be sorted on. A
123
	 * value of 0 indicates target name, 1 indicates target description, and -1
124
	 * indicates no sort. Default value is -1.
125
	 */
126
	public static final String ATTR_SORT_TARGETS = IExternalToolConstants.PLUGIN_ID + "ATTR_SORT_TARGETS"; //$NON-NLS-1$
127
128
	/**
129
	 * Boolean attribute indicating if the default VM install should be used for the separate JRE build
130
	 * Default value is <code>false</code> for backwards compatibility
131
	 */
132
	public static final String ATTR_DEFAULT_VM_INSTALL = PLUGIN_ID + ".DEFAULT_VM_INSTALL"; //$NON-NLS-1$
133
134
	/**
135
	 * Identifier for Ant processes (value <code>org.eclipse.ant.ui.antProcess</code>). This identifier is
136
	 * set as the value for the <code>IProcess.ATTR_PROCESS_TYPE</code>
137
	 * attribute in processes created by the Ant launch delegate.
138
	 */
139
	public static final String ID_ANT_PROCESS_TYPE = "org.eclipse.ant.ui.antProcess"; //$NON-NLS-1$
140
	
141
	/**
142
	 * Boolean attribute indicating if an input handler should be supplied for the build
143
	 * Default value is <code>true</code>.
144
	 */
145
	public static final String SET_INPUTHANDLER= PLUGIN_ID + "SET_INPUTHANDLER"; //$NON-NLS-1$
146
	
147
	/**
148
     * int preference identifier constant which specifies the length of time to wait
149
     * to connect with the socket that communicates with the separate JRE to capture the output
150
     */
151
    public static final String ANT_COMMUNICATION_TIMEOUT= "timeout"; //$NON-NLS-1$
152
}
(-)src/org/eclipse/ant/internal/launching/debug/AntSourceContainer.java (+73 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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
12
package org.eclipse.ant.internal.launching.debug;
13
14
import java.io.File;
15
import java.io.IOException;
16
import java.util.ArrayList;
17
18
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.resources.IWorkspaceRoot;
20
import org.eclipse.core.resources.ResourcesPlugin;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IPath;
23
import org.eclipse.core.runtime.Path;
24
import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
25
import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainer;
26
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
27
28
public class AntSourceContainer extends AbstractSourceContainer {
29
30
	private IWorkspaceRoot fRoot;
31
32
	public AntSourceContainer() {
33
		fRoot = ResourcesPlugin.getWorkspace().getRoot();
34
	}
35
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#findSourceElements(java.lang.String)
38
	 */
39
	public Object[] findSourceElements(String path) throws CoreException {
40
		ArrayList sources = new ArrayList();
41
		File osFile = new File(path);
42
		if (osFile.exists()) {
43
			try {
44
				IPath canonicalPath = new Path(osFile.getCanonicalPath());
45
				IFile[] files = fRoot.findFilesForLocation(canonicalPath);
46
				if (files.length > 0) {
47
					for (int i = 0; i < files.length; i++) {
48
						sources.add(files[i]);
49
					}
50
				} else {
51
					sources.add(new LocalFileStorage(osFile));
52
				}
53
			} catch (IOException e) {
54
			}
55
		}
56
		return sources.toArray();
57
	}
58
59
	/* (non-Javadoc)
60
	 * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getName()
61
	 */
62
	public String getName() {
63
		return AntDebugMessages.AntSourceContainer_0;
64
	}
65
66
	/* (non-Javadoc)
67
	 * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getType()
68
     * Not persisted via the launch configuration
69
	 */
70
	public ISourceContainerType getType() {
71
		return null;
72
	}
73
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java (+245 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 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.ant.internal.launching.launchConfigurations;
12
13
import java.io.File;
14
import java.io.FilenameFilter;
15
import java.io.IOException;
16
import java.net.MalformedURLException;
17
import java.net.URL;
18
import java.util.ArrayList;
19
import java.util.List;
20
21
import org.eclipse.ant.core.AntCorePlugin;
22
import org.eclipse.ant.core.AntCorePreferences;
23
import org.eclipse.ant.core.IAntClasspathEntry;
24
import org.eclipse.ant.internal.launching.AntLaunching;
25
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
26
import org.eclipse.core.runtime.CoreException;
27
import org.eclipse.core.runtime.FileLocator;
28
import org.eclipse.core.runtime.IPath;
29
import org.eclipse.core.runtime.Path;
30
import org.eclipse.core.runtime.Platform;
31
import org.eclipse.debug.core.ILaunchConfiguration;
32
import org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry;
33
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
34
import org.eclipse.jdt.launching.IVMInstall;
35
import org.eclipse.jdt.launching.JavaRuntime;
36
import org.eclipse.osgi.service.resolver.BundleDescription;
37
import org.osgi.framework.Bundle;
38
import org.w3c.dom.Document;
39
import org.w3c.dom.Element;
40
41
/**
42
 * A classpath entry that contains a contributed classpath entries
43
 * via the <code>extraClasspathEntries</code> extension point.
44
 * 
45
 * @since 3.0 
46
 */
47
public class ContributedClasspathEntriesEntry extends AbstractRuntimeClasspathEntry {
48
	
49
	public static final String TYPE_ID = "org.eclipse.ant.ui.classpathentry.extraClasspathEntries"; //$NON-NLS-1$
50
    
51
    public static List fgSWTEntries= null;
52
		
53
	/**
54
	 * Default contructor required to instantiate persisted extensions.
55
	 */
56
	public ContributedClasspathEntriesEntry() {
57
	}
58
	
59
	/* (non-Javadoc)
60
	 * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element)
61
	 */
62
	protected void buildMemento(Document document, Element memento) throws CoreException {
63
	}
64
	
65
	/* (non-Javadoc)
66
	 * @see org.eclipse.jdt.internal.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element)
67
	 */
68
	public void initializeFrom(Element memento) throws CoreException {
69
	}
70
	
71
	/* (non-Javadoc)
72
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId()
73
	 */
74
	public String getTypeId() {
75
		return TYPE_ID;
76
	}
77
	
78
	/* (non-Javadoc)
79
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration)
80
	 */
81
	public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException {
82
		boolean separateVM= AntLaunchingUtil.isSeparateJREAntBuild(configuration);
83
		boolean setInputHandler= configuration.getAttribute(IAntLaunchConfigurationConstants.SET_INPUTHANDLER, true);
84
		AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences();
85
		IAntClasspathEntry[] antClasspathEntries = prefs.getContributedClasspathEntries();
86
		IAntClasspathEntry[] userEntries = prefs.getAdditionalClasspathEntries();
87
		List rtes = new ArrayList(antClasspathEntries.length + userEntries.length);
88
		IAntClasspathEntry entry;
89
		for (int i = 0; i < antClasspathEntries.length; i++) {
90
			 entry= antClasspathEntries[i];
91
			if (!separateVM || (separateVM && !entry.isEclipseRuntimeRequired())) {
92
				rtes.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel()));
93
			}
94
		}
95
		boolean haveToolsEntry= false;
96
		String path;
97
		for (int i = 0; i < userEntries.length; i++) {
98
			entry = userEntries[i];
99
			path= entry.getLabel();
100
            IPath toolsPath= new Path(path);
101
			if (toolsPath.lastSegment().equals("tools.jar")) { //$NON-NLS-1$
102
				haveToolsEntry= true;
103
				// replace with dynamically resolved tools.jar based on
104
				// the JRE being used
105
				addToolsJar(configuration, rtes, path);
106
			} else {
107
				rtes.add(JavaRuntime.newStringVariableClasspathEntry(path));
108
			}
109
		}
110
		if (!haveToolsEntry) {
111
			addToolsJar(configuration, rtes, null);
112
		}
113
		
114
		if (setInputHandler && separateVM) {
115
			addSWTJars(rtes);
116
		}
117
		
118
		return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]);
119
	}
120
	
121
	private void addToolsJar(ILaunchConfiguration configuration, List rtes, String path) {
122
		IRuntimeClasspathEntry tools = getToolsJar(configuration);
123
		if (tools == null) {
124
			if (path != null) {
125
				//use the global entry
126
				rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(path)));
127
			} else {
128
				//use the default vm install to try to find a tools.jar
129
				IVMInstall install= JavaRuntime.getDefaultVMInstall();
130
				if (install != null) {
131
					IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath()));
132
					if (entry != null) {
133
						rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath())));
134
					}
135
				}
136
			}
137
		} else {
138
			rtes.add(tools);
139
		}
140
	}
141
	
142
	private void addSWTJars(List rtes) {
143
        if (fgSWTEntries == null) {
144
            fgSWTEntries= new ArrayList();
145
            Bundle bundle= Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$
146
            BundleDescription description= Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId());
147
            BundleDescription[] fragments= description.getFragments();
148
            for (int i = 0; i < fragments.length; i++) {
149
                Bundle fragmentBundle= Platform.getBundle(fragments[i].getName());
150
                URL bundleURL;
151
                try {
152
                    bundleURL = FileLocator.resolve(fragmentBundle.getEntry("/")); //$NON-NLS-1$
153
                } catch (IOException e) {
154
                    AntLaunching.log(e);
155
                   continue;
156
                }
157
                String urlFileName= bundleURL.getFile();
158
                if (urlFileName.startsWith("file:")) { //$NON-NLS-1$
159
                    try {
160
                        urlFileName= new URL(urlFileName).getFile();
161
                        if (urlFileName.endsWith("!/")) { //$NON-NLS-1$
162
                            urlFileName= urlFileName.substring(0, urlFileName.length() - 2);
163
                        }
164
                    } catch (MalformedURLException e) {
165
                    	 AntLaunching.log(e);
166
                       continue;
167
                    }
168
                }
169
                IPath fragmentPath= new Path(urlFileName);
170
                if (fragmentPath.getFileExtension() != null) { //JAR file
171
                    fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath));
172
                } else { // folder
173
                    File bundleFolder= fragmentPath.toFile();
174
                    if (!bundleFolder.isDirectory()) {
175
                        continue;
176
                    }
177
                    String[] names= bundleFolder.list(new FilenameFilter() {
178
                        public boolean accept(File dir, String name) {
179
                            return name.endsWith(".jar"); //$NON-NLS-1$
180
                        }
181
                    });
182
                    for (int j = 0; j < names.length; j++) {
183
                        String jarName = names[j];
184
                        fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath.append(jarName)));
185
                    }
186
                }
187
            }
188
        }
189
        rtes.addAll(fgSWTEntries);
190
	}
191
    
192
	/**
193
	 * Returns the tools.jar to use for this launch configuration, or <code>null</code>
194
	 * if none.
195
	 * 
196
	 * @param configuration configuration to resolve a tools.jar for
197
	 * @return associated tools.jar archive, or <code>null</code>
198
	 */
199
	private IRuntimeClasspathEntry getToolsJar(ILaunchConfiguration configuration) {
200
		try {
201
			IVMInstall install = JavaRuntime.computeVMInstall(configuration);
202
			if (install != null) {
203
				IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath()));
204
				if (entry != null) {
205
					return JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath()));
206
				}
207
			}
208
		} catch (CoreException ce) {
209
			//likely dealing with a non-Java project
210
		}
211
			
212
		return null;
213
	}
214
	
215
	/* (non-Javadoc)
216
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName()
217
	 */
218
	public String getName() {
219
		return AntLaunchConfigurationMessages.ContributedClasspathEntriesEntry_1;
220
	}
221
	/* (non-Javadoc)
222
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType()
223
	 */
224
	public int getType() {
225
		return IRuntimeClasspathEntry.OTHER;
226
	}
227
	/* (non-Javadoc)
228
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#isComposite()
229
	 */
230
	public boolean isComposite() {
231
		return true;
232
	}
233
	/* (non-Javadoc)
234
	 * @see java.lang.Object#equals(java.lang.Object)
235
	 */
236
	public boolean equals(Object obj) {
237
		return obj instanceof ContributedClasspathEntriesEntry;
238
	}
239
	/* (non-Javadoc)
240
	 * @see java.lang.Object#hashCode()
241
	 */
242
	public int hashCode() {
243
		return getClass().hashCode();
244
	}
245
}
(-)src/org/eclipse/ant/internal/launching/IAntLaunchingPreferenceConstants.java (+24 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 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
 *     John-Mason P. Shackelford (john-mason.shackelford@pearson.com) - bug 53547
11
 *******************************************************************************/
12
package org.eclipse.ant.internal.launching;
13
14
/**
15
 * Constants used to identify user preferences.
16
 */
17
public interface IAntLaunchingPreferenceConstants {
18
19
	 /**
20
     * int preference identifier constant which specifies the length of time to wait
21
     * to connect with the socket that communicates with the separate JRE to capture the output
22
     */
23
    public static final String ANT_COMMUNICATION_TIMEOUT= "timeout"; //$NON-NLS-1$
24
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntMigrationDelegate.java (+76 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 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.ant.internal.launching.launchConfigurations;
12
13
import org.eclipse.core.internal.externaltools.model.IExternalToolConstants;
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.variables.IStringVariableManager;
18
import org.eclipse.core.variables.VariablesPlugin;
19
import org.eclipse.debug.core.ILaunchConfiguration;
20
import org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate;
21
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
22
23
/**
24
 * Delegate for migrating Ant launch configurations.
25
 * The migration process involves a resource mapping being created such that launch configurations
26
 * can be filtered from the launch configuration dialog based on resource availability.
27
 * 
28
 * @since 3.2
29
 */
30
public class AntMigrationDelegate implements ILaunchConfigurationMigrationDelegate {
31
	
32
	/**
33
	 * Method to get the file for the specified launch configuration that should be mapped to the launch configuration  
34
	 * 
35
	 * @param candidate the launch configuration that the file will be mapped to.
36
	 * @return the buildfile or <code>null</code> if not in the workspace
37
	 */
38
	protected IFile getFileForCandidate(ILaunchConfiguration candidate) {
39
		IFile file= null;
40
		String expandedLocation= null;
41
		String location= null;
42
		IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
43
		try {
44
			location= candidate.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String)null);
45
			if (location != null) {
46
				expandedLocation= manager.performStringSubstitution(location);
47
				if (expandedLocation != null) {
48
					//file= AntUtil.getFileForLocation(expandedLocation, null);
49
				}
50
			}
51
		} catch (CoreException e) {
52
		}
53
		return file;
54
	}
55
	
56
	/* (non-Javadoc)
57
	 * @see org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate#isCandidate()
58
	 */
59
	public boolean isCandidate(ILaunchConfiguration candidate) throws CoreException {
60
		IResource[] mappedResources = candidate.getMappedResources();
61
		if (mappedResources != null && mappedResources.length > 0) {
62
			return false;
63
		}
64
		return getFileForCandidate(candidate) != null;
65
	}
66
67
	/* (non-Javadoc)
68
	 * @see org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate#migrate(org.eclipse.debug.core.ILaunchConfiguration)
69
	 */
70
	public void migrate(ILaunchConfiguration candidate) throws CoreException {
71
		IFile file = getFileForCandidate(candidate);
72
		ILaunchConfigurationWorkingCopy wc = candidate.getWorkingCopy();
73
		wc.setMappedResources(new IResource[] {file});
74
		wc.doSave();
75
	}
76
}
(-)src/org/eclipse/ant/internal/launching/debug/model/AntPropertiesValue.java (+71 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 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
 *     Brock Janiczak (brockj@tpg.com.au) - bug 154907
11
 *******************************************************************************/
12
package org.eclipse.ant.internal.launching.debug.model;
13
14
import java.util.ArrayList;
15
import java.util.Collections;
16
import java.util.List;
17
import org.eclipse.debug.core.model.IValue;
18
import org.eclipse.debug.core.model.IVariable;
19
20
public class AntPropertiesValue extends AntDebugElement implements IValue {
21
	
22
	private List fProperties= new ArrayList();
23
	
24
	public AntPropertiesValue(AntDebugTarget target) {
25
		super(target);
26
	}
27
	
28
	/* (non-Javadoc)
29
	 * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
30
	 */
31
	public String getReferenceTypeName() {
32
		return ""; //$NON-NLS-1$
33
	}
34
	
35
	/* (non-Javadoc)
36
	 * @see org.eclipse.debug.core.model.IValue#getValueString()
37
	 */
38
	public String getValueString() {
39
		return ""; //$NON-NLS-1$
40
	}
41
	
42
	/* (non-Javadoc)
43
	 * @see org.eclipse.debug.core.model.IValue#isAllocated()
44
	 */
45
	public boolean isAllocated() {
46
		return true;
47
	}
48
	
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.debug.core.model.IValue#getVariables()
51
	 */
52
	public IVariable[] getVariables() {
53
		Collections.sort(fProperties);
54
		return (IVariable[])fProperties.toArray(new IVariable[fProperties.size()]);
55
	}
56
	
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.debug.core.model.IValue#hasVariables()
59
	 */
60
	public boolean hasVariables() {
61
		return true;
62
	}
63
	
64
	protected void addProperties(List properties) {
65
		fProperties.addAll(properties);
66
	}
67
68
	protected List getProperties() {
69
		return fProperties;
70
	}
71
}
(-)src/org/eclipse/ant/internal/launching/debug/model/AntDebugElement.java (+55 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 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.ant.internal.launching.debug.model;
12
13
14
import org.eclipse.ant.internal.launching.AntLaunching;
15
import org.eclipse.ant.internal.launching.debug.IAntDebugConstants;
16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.Status;
18
import org.eclipse.debug.core.DebugException;
19
import org.eclipse.debug.core.model.DebugElement;
20
21
/**
22
 * Common function of Ant debug model elements
23
 */
24
public abstract class AntDebugElement extends DebugElement {
25
	
26
	/**
27
	 * Constructs a new debug element contained in the given
28
	 * debug target.
29
	 * 
30
	 * @param target debug target
31
	 */
32
	public AntDebugElement(AntDebugTarget target) {
33
		super(target);
34
	}
35
	
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
38
	 */
39
	public String getModelIdentifier() {
40
		return IAntDebugConstants.ID_ANT_DEBUG_MODEL;
41
	}
42
    
43
	/**
44
     * Throws a debug exception with the given message, error code, and underlying
45
     * exception.
46
     */
47
    protected void throwDebugException(String message) throws DebugException {
48
        throw new DebugException(new Status(IStatus.ERROR, AntLaunching.getUniqueIdentifier(),
49
            DebugException.TARGET_REQUEST_FAILED, message, null));
50
    }
51
    
52
    protected AntDebugTarget getAntDebugTarget() {
53
        return (AntDebugTarget)super.getDebugTarget();
54
    }
55
}
(-)src/org/eclipse/ant/internal/launching/debug/model/AntValue.java (+71 lines)
Added Link Here
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 Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug.model;
12
13
import org.eclipse.ant.internal.launching.debug.IAntDebugConstants;
14
import org.eclipse.debug.core.model.IValue;
15
import org.eclipse.debug.core.model.IVariable;
16
17
public class AntValue extends AntDebugElement implements IValue  {
18
19
    private String fValueString;
20
    protected static final IVariable[] EMPTY = new IVariable[0];
21
    
22
    /**
23
     * @param target
24
     */
25
    public AntValue(AntDebugTarget target, String value) {
26
        super(target);
27
        fValueString= value;
28
    }
29
30
    /* (non-Javadoc)
31
     * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
32
     */
33
    public String getReferenceTypeName() {
34
        return ""; //$NON-NLS-1$
35
    }
36
37
    /* (non-Javadoc)
38
     * @see org.eclipse.debug.core.model.IValue#getValueString()
39
     */
40
    public String getValueString() {
41
        return fValueString;
42
    }
43
44
    /* (non-Javadoc)
45
     * @see org.eclipse.debug.core.model.IValue#isAllocated()
46
     */
47
    public boolean isAllocated() {
48
        return true;
49
    }
50
51
    /* (non-Javadoc)
52
     * @see org.eclipse.debug.core.model.IValue#getVariables()
53
     */
54
    public IVariable[] getVariables() {
55
        return EMPTY;
56
    }
57
58
    /* (non-Javadoc)
59
     * @see org.eclipse.debug.core.model.IValue#hasVariables()
60
     */
61
    public boolean hasVariables() {
62
        return false;
63
    }
64
65
    /* (non-Javadoc)
66
     * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
67
     */
68
    public String getModelIdentifier() {
69
        return IAntDebugConstants.ID_ANT_DEBUG_MODEL;
70
    }
71
}
(-)src/org/eclipse/ant/internal/launching/debug/model/AntProperty.java (+121 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2008 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
 *     Brock Janiczak (brockj@tpg.com.au) - bug 154907
11
 *******************************************************************************/
12
package org.eclipse.ant.internal.launching.debug.model;
13
14
import org.eclipse.debug.core.model.IValue;
15
import org.eclipse.debug.core.model.IVariable;
16
17
/**
18
 * A property in an Ant build.
19
 */
20
public class AntProperty extends AntDebugElement implements IVariable, Comparable {
21
22
	private String fName;
23
	private AntValue fValue;
24
    private String fLabel;
25
	
26
	/**
27
	 * Constructs a variable associated with the debug target
28
	 * with the given name and value.
29
	 * 
30
	 * @param target the debug target
31
	 * @param name property name
32
	 * @param value property value
33
	 */
34
	public AntProperty(AntDebugTarget target, String name, String value) {
35
		super(target);
36
		fName = name;
37
		fValue= new AntValue(target, value);
38
	}
39
	
40
	/*
41
	 * @see org.eclipse.debug.core.model.IVariable#getValue()
42
	 */
43
	public IValue getValue() {
44
		return fValue;
45
	}
46
	
47
	/*
48
	 * @see org.eclipse.debug.core.model.IVariable#getName()
49
	 */
50
	public String getName() {
51
		return fName;
52
	}
53
	
54
	/*
55
	 * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
56
	 */
57
	public String getReferenceTypeName() {
58
		return ""; //$NON-NLS-1$
59
	}
60
	
61
	/*
62
	 * @see org.eclipse.debug.core.model.IVariable#hasValueChanged()
63
	 */
64
	public boolean hasValueChanged() {
65
		return false;
66
	}
67
	
68
	/*
69
	 * @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String)
70
	 */
71
	public void setValue(String expression) {
72
	}
73
	
74
	/*
75
	 * @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue)
76
	 */
77
	public void setValue(IValue value) {
78
	}
79
	
80
	/*
81
	 * @see org.eclipse.debug.core.model.IValueModification#supportsValueModification()
82
	 */
83
	public boolean supportsValueModification() {
84
		return false;
85
	}
86
	
87
	/*
88
	 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String)
89
	 */
90
	public boolean verifyValue(String expression) {
91
		return false;
92
	}
93
	
94
	/*
95
	 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(org.eclipse.debug.core.model.IValue)
96
	 */
97
	public boolean verifyValue(IValue value) {
98
		return false;
99
	}
100
101
    /**
102
     * @return the text used to render this property
103
     */
104
    public String getText() {
105
        if (fLabel == null) {
106
            StringBuffer buffer= new StringBuffer(getName());
107
            buffer.append("= "); //$NON-NLS-1$
108
            buffer.append(fValue.getValueString());          
109
            fLabel=  buffer.toString();
110
        } 
111
        return fLabel;
112
    }
113
    
114
    /*
115
     * @see java.lang.Comparable#compareTo(java.lang.Object)
116
     */
117
    public int compareTo(Object other) {
118
    	AntProperty otherProperty = (AntProperty) other;
119
    	return fName.compareToIgnoreCase(otherProperty.getName());
120
    }
121
}
(-)src/org/eclipse/ant/internal/launching/debug/AntSourceLookupParticipant.java (+36 lines)
Added Link Here
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 Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug;
12
13
import org.eclipse.ant.internal.launching.debug.model.AntStackFrame;
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
16
17
/**
18
 * The Ant source lookup participant knows how to translate a 
19
 * Ant stack frame into a source file name 
20
 */
21
public class AntSourceLookupParticipant extends AbstractSourceLookupParticipant {
22
	
23
	/* (non-Javadoc)
24
	 * @see org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant#getSourceName(java.lang.Object)
25
	 */
26
	public String getSourceName(Object object) throws CoreException {
27
		if (object instanceof AntStackFrame) {
28
			return ((AntStackFrame)object).getFilePath();
29
		}
30
        if (object instanceof String) {
31
            // assume it's a file name
32
            return (String)object;
33
        }
34
		return null;
35
	}
36
}
(-)src/org/eclipse/ant/internal/launching/debug/AntSourceLookupDirector.java (+36 lines)
Added Link Here
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 Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
15
import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant;
16
17
/**
18
 * Ant source lookup director. For Ant source lookup there is one source
19
 * lookup participant. 
20
 */
21
public class AntSourceLookupDirector extends AbstractSourceLookupDirector {
22
	
23
	/* (non-Javadoc)
24
	 * @see org.eclipse.debug.core.sourcelookup.ISourceLookupDirector#initializeParticipants()
25
	 */
26
	public void initializeParticipants() {
27
		addParticipants(new ISourceLookupParticipant[]{new AntSourceLookupParticipant()});
28
	}
29
30
    /* (non-Javadoc)
31
     * @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento()
32
     */
33
    public String getMemento() throws CoreException {
34
        return null;
35
    }
36
}
(-)src/org/eclipse/ant/internal/launching/debug/model/AntStackFrame.java (+314 lines)
Added Link Here
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 Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug.model;
12
13
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.runtime.Path;
16
import org.eclipse.debug.core.DebugException;
17
import org.eclipse.debug.core.model.IRegisterGroup;
18
import org.eclipse.debug.core.model.IStackFrame;
19
import org.eclipse.debug.core.model.IThread;
20
import org.eclipse.debug.core.model.IVariable;
21
22
/**
23
 * Ant stack frame.
24
 */
25
public class AntStackFrame extends AntDebugElement implements IStackFrame {
26
	
27
	private AntThread fThread;
28
	private String fName;
29
	private int fLineNumber;
30
	private String fFilePath;
31
	private int fId;
32
    private String fFullPath;
33
	
34
	/**
35
	 * Constructs a stack frame in the given thread with the given id.
36
	 * 
37
	 * @param thread
38
	 * @param id stack frame id (0 is the top of the stack)
39
	 */
40
	public AntStackFrame(AntThread thread, int id, String name, String fullPath, int lineNumber) {
41
		super((AntDebugTarget) thread.getDebugTarget());
42
		fId = id;
43
		fThread = thread;
44
		fLineNumber= lineNumber;
45
		fName= name;
46
		setFilePath(fullPath);
47
	}
48
	
49
	protected void setId(int id) {
50
		fId= id;
51
	}
52
	
53
	/* (non-Javadoc)
54
	 * @see org.eclipse.debug.core.model.IStackFrame#getThread()
55
	 */
56
	public IThread getThread() {
57
		return fThread;
58
	}
59
	
60
	/* (non-Javadoc)
61
	 * @see org.eclipse.debug.core.model.IStackFrame#getVariables()
62
	 */
63
	public IVariable[] getVariables() throws DebugException {
64
	   return fThread.getVariables();
65
	}
66
67
    /* (non-Javadoc)
68
	 * @see org.eclipse.debug.core.model.IStackFrame#hasVariables()
69
	 */
70
	public boolean hasVariables() {
71
		return isSuspended();
72
	}
73
	
74
	/* (non-Javadoc)
75
	 * @see org.eclipse.debug.core.model.IStackFrame#getLineNumber()
76
	 */
77
	public int getLineNumber() {
78
		return fLineNumber;
79
	}
80
	
81
	protected void setLineNumber(int lineNumber) {
82
		fLineNumber= lineNumber;
83
	}
84
	
85
	protected void setFilePath(String fullPath) {
86
        fFullPath= fullPath;
87
        IFile file= AntLaunchingUtil.getFileForLocation(fullPath, null);
88
        if (file != null) {
89
            fFilePath= file.getProjectRelativePath().toString();
90
        } else {
91
            fFilePath= new Path(fullPath).lastSegment();
92
        }
93
	}
94
	
95
	public String getFilePath() {
96
		return fFullPath;
97
	}
98
	
99
	/* (non-Javadoc)
100
	 * @see org.eclipse.debug.core.model.IStackFrame#getCharStart()
101
	 */
102
	public int getCharStart() {
103
		return -1;
104
	}
105
	
106
	/* (non-Javadoc)
107
	 * @see org.eclipse.debug.core.model.IStackFrame#getCharEnd()
108
	 */
109
	public int getCharEnd() {
110
		return -1;
111
	}
112
	
113
	/* (non-Javadoc)
114
	 * @see org.eclipse.debug.core.model.IStackFrame#getName()
115
	 */
116
	public String getName() {
117
		return fName;
118
	}
119
	
120
	protected void setName(String name) {
121
		fName= name;
122
	}
123
	
124
	/* (non-Javadoc)
125
	 * @see org.eclipse.debug.core.model.IStackFrame#getRegisterGroups()
126
	 */
127
	public IRegisterGroup[] getRegisterGroups() {
128
		return null;
129
	}
130
	
131
	/* (non-Javadoc)
132
	 * @see org.eclipse.debug.core.model.IStackFrame#hasRegisterGroups()
133
	 */
134
	public boolean hasRegisterGroups() {
135
		return false;
136
	}
137
	
138
	/* (non-Javadoc)
139
	 * @see org.eclipse.debug.core.model.IStep#canStepInto()
140
	 */
141
	public boolean canStepInto() {
142
		return getThread().canStepInto();
143
	}
144
	
145
	/* (non-Javadoc)
146
	 * @see org.eclipse.debug.core.model.IStep#canStepOver()
147
	 */
148
	public boolean canStepOver() {
149
		return getThread().canStepOver();
150
	}
151
	
152
	/* (non-Javadoc)
153
	 * @see org.eclipse.debug.core.model.IStep#canStepReturn()
154
	 */
155
	public boolean canStepReturn() {
156
		return getThread().canStepReturn();
157
	}
158
	
159
	/* (non-Javadoc)
160
	 * @see org.eclipse.debug.core.model.IStep#isStepping()
161
	 */
162
	public boolean isStepping() {
163
		return getThread().isStepping();
164
	}
165
	
166
	/* (non-Javadoc)
167
	 * @see org.eclipse.debug.core.model.IStep#stepInto()
168
	 */
169
	public void stepInto() throws DebugException {
170
		getThread().stepInto();
171
	}
172
	
173
	/* (non-Javadoc)
174
	 * @see org.eclipse.debug.core.model.IStep#stepOver()
175
	 */
176
	public void stepOver() throws DebugException {
177
		getThread().stepOver();
178
	}
179
	
180
	/* (non-Javadoc)
181
	 * @see org.eclipse.debug.core.model.IStep#stepReturn()
182
	 */
183
	public void stepReturn() throws DebugException {
184
		getThread().stepReturn();
185
	}
186
	
187
	/* (non-Javadoc)
188
	 * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
189
	 */
190
	public boolean canResume() {
191
		return getThread().canResume();
192
	}
193
	
194
	/* (non-Javadoc)
195
	 * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
196
	 */
197
	public boolean canSuspend() {
198
		return getThread().canSuspend();
199
	}
200
	
201
	/* (non-Javadoc)
202
	 * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
203
	 */
204
	public boolean isSuspended() {
205
		return getThread().isSuspended();
206
	}
207
	
208
	/* (non-Javadoc)
209
	 * @see org.eclipse.debug.core.model.ISuspendResume#resume()
210
	 */
211
	public void resume() throws DebugException {
212
		getThread().resume();
213
	}
214
	
215
	/* (non-Javadoc)
216
	 * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
217
	 */
218
	public void suspend() throws DebugException {
219
		getThread().suspend();
220
	}
221
	
222
	/* (non-Javadoc)
223
	 * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
224
	 */
225
	public boolean canTerminate() {
226
		return getThread().canTerminate();
227
	}
228
	
229
	/* (non-Javadoc)
230
	 * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
231
	 */
232
	public boolean isTerminated() {
233
		return getThread().isTerminated();
234
	}
235
	
236
	/* (non-Javadoc)
237
	 * @see org.eclipse.debug.core.model.ITerminate#terminate()
238
	 */
239
	public void terminate() throws DebugException {
240
		getThread().terminate();
241
	}
242
	
243
	/**
244
	 * Returns the name of the buildfile this stack frame is associated
245
	 * with.
246
	 * 
247
	 * @return the name of the buildfile this stack frame is associated
248
	 * with
249
	 */
250
	public String getSourceName() {
251
		return fFilePath;
252
	}
253
	
254
	/* (non-Javadoc)
255
	 * @see java.lang.Object#equals(java.lang.Object)
256
	 */
257
	public boolean equals(Object obj) {
258
		if (obj instanceof AntStackFrame) {
259
			AntStackFrame sf = (AntStackFrame)obj;
260
			if (getSourceName() != null) {
261
				return getSourceName().equals(sf.getSourceName()) &&
262
					sf.getLineNumber() == getLineNumber() &&
263
					sf.fId == fId;
264
			} 
265
			return sf.fId == fId;
266
		}
267
		return false;
268
	}
269
	
270
	/* (non-Javadoc)
271
	 * @see java.lang.Object#hashCode()
272
	 */
273
	public int hashCode() {
274
	    if (getSourceName() == null) {
275
	        return fId;
276
	    }
277
	    return getSourceName().hashCode() + fId;
278
	}
279
	
280
	/**
281
	 * Returns this stack frame's unique identifier within its thread
282
	 * 
283
	 * @return this stack frame's unique identifier within its thread
284
	 */
285
	protected int getIdentifier() {
286
		return fId;
287
	}
288
    
289
    /**
290
     * Returns the system, user or runtime property
291
     * name, or <code>null</code> if unable to resolve a property with the name.
292
     *
293
     * @param propertyName the name of the variable to search for
294
     * @return a property, or <code>null</code> if none
295
     */
296
    public AntProperty findProperty(String propertyName) {
297
        try {
298
            IVariable[] groups= getVariables();
299
            for (int i = 0; i < groups.length; i++) {
300
                AntProperties propertiesGrouping = (AntProperties) groups[i];
301
                AntPropertiesValue value= (AntPropertiesValue) propertiesGrouping.getValue();
302
                IVariable[] properties= value.getVariables();
303
                for (int j = 0; j < properties.length; j++) {
304
                    AntProperty property = (AntProperty) properties[j];
305
                    if (property.getName().equals(propertyName)) {
306
                        return property;
307
                    }
308
                }
309
            }
310
        } catch (DebugException e) {
311
        }
312
        return null;
313
    } 
314
}
(-)src/org/eclipse/ant/internal/launching/debug/model/AntDebugTarget.java (+463 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 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.ant.internal.launching.debug.model;
12
13
import java.util.ArrayList;
14
import java.util.Iterator;
15
import java.util.List;
16
17
import org.eclipse.ant.internal.launching.debug.IAntDebugConstants;
18
import org.eclipse.ant.internal.launching.debug.IAntDebugController;
19
import org.eclipse.core.internal.externaltools.model.IExternalToolConstants;
20
import org.eclipse.core.resources.IMarkerDelta;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.variables.VariablesPlugin;
23
import org.eclipse.debug.core.DebugEvent;
24
import org.eclipse.debug.core.DebugException;
25
import org.eclipse.debug.core.DebugPlugin;
26
import org.eclipse.debug.core.IBreakpointManager;
27
import org.eclipse.debug.core.IBreakpointManagerListener;
28
import org.eclipse.debug.core.IDebugEventSetListener;
29
import org.eclipse.debug.core.ILaunch;
30
import org.eclipse.debug.core.model.IBreakpoint;
31
import org.eclipse.debug.core.model.IDebugTarget;
32
import org.eclipse.debug.core.model.ILineBreakpoint;
33
import org.eclipse.debug.core.model.IMemoryBlock;
34
import org.eclipse.debug.core.model.IProcess;
35
import org.eclipse.debug.core.model.IThread;
36
37
/**
38
 * Ant Debug Target
39
 */
40
public class AntDebugTarget extends AntDebugElement implements IDebugTarget, IDebugEventSetListener, IBreakpointManagerListener {
41
	
42
	// associated system process (Ant Build)
43
	private IProcess fProcess;
44
	
45
	// containing launch object
46
	private ILaunch fLaunch;
47
	
48
	// Build file name
49
	private String fName;
50
51
	// suspend state
52
	private boolean fSuspended= false;
53
	
54
	// terminated state
55
	private boolean fTerminated= false;
56
	
57
	// threads
58
	private AntThread fThread;
59
	private IThread[] fThreads;
60
	
61
	private IAntDebugController fController;
62
    
63
    private List fRunToLineBreakpoints;
64
65
	/**
66
	 * Constructs a new debug target in the given launch for the 
67
	 * associated Ant build process.
68
	 * 
69
	 * @param launch containing launch
70
	 * @param process Ant build process
71
	 * @param controller the controller to communicate to the Ant build
72
	 */
73
	public AntDebugTarget(ILaunch launch, IProcess process, IAntDebugController controller) {
74
		super(null);
75
		fLaunch = launch;
76
		fProcess = process;
77
		
78
		fController= controller;
79
		
80
		fThread = new AntThread(this);
81
		fThreads = new IThread[] {fThread};
82
        
83
        DebugPlugin.getDefault().getBreakpointManager().addBreakpointManagerListener(this);
84
		DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
85
        DebugPlugin.getDefault().addDebugEventListener(this);
86
	}
87
	
88
	/* (non-Javadoc)
89
	 * @see org.eclipse.debug.core.model.IDebugTarget#getProcess()
90
	 */
91
	public IProcess getProcess() {
92
		return fProcess;
93
	}
94
	
95
	/* (non-Javadoc)
96
	 * @see org.eclipse.debug.core.model.IDebugTarget#getThreads()
97
	 */
98
	public IThread[] getThreads() {
99
		return fThreads;
100
	}
101
	
102
	/* (non-Javadoc)
103
	 * @see org.eclipse.debug.core.model.IDebugTarget#hasThreads()
104
	 */
105
	public boolean hasThreads() throws DebugException {
106
		return !fTerminated && fThreads.length > 0;
107
	}
108
	
109
	/* (non-Javadoc)
110
	 * @see org.eclipse.debug.core.model.IDebugTarget#getName()
111
	 */
112
	public String getName() throws DebugException {
113
		if (fName == null) {
114
			try {
115
				fName= getLaunch().getLaunchConfiguration().getAttribute(IExternalToolConstants.ATTR_LOCATION, DebugModelMessages.AntDebugTarget_0);
116
				fName= VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(fName);
117
			} catch (CoreException e) {
118
				fName = DebugModelMessages.AntDebugTarget_0;
119
			}
120
		}
121
		return fName;
122
	}
123
	
124
	/* (non-Javadoc)
125
	 * @see org.eclipse.debug.core.model.IDebugTarget#supportsBreakpoint(org.eclipse.debug.core.model.IBreakpoint)
126
	 */
127
	public boolean supportsBreakpoint(IBreakpoint breakpoint) {
128
		if (breakpoint.getModelIdentifier().equals(IAntDebugConstants.ID_ANT_DEBUG_MODEL)) {
129
		    //need to consider all breakpoints as no way to tell which set
130
		    //of buildfiles will be executed (ant task)
131
		    return true;
132
		}
133
		return false;
134
	}
135
	
136
	/* (non-Javadoc)
137
	 * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
138
	 */
139
	public IDebugTarget getDebugTarget() {
140
		return this;
141
	}
142
	
143
	/* (non-Javadoc)
144
	 * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
145
	 */
146
	public ILaunch getLaunch() {
147
		return fLaunch;
148
	}
149
	
150
	/* (non-Javadoc)
151
	 * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
152
	 */
153
	public boolean canTerminate() {
154
		return !fTerminated;
155
	}
156
	
157
	/* (non-Javadoc)
158
	 * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
159
	 */
160
	public boolean isTerminated() {
161
		return fTerminated;
162
	}
163
	
164
	/* (non-Javadoc)
165
	 * @see org.eclipse.debug.core.model.ITerminate#terminate()
166
	 */
167
	public void terminate() throws DebugException {
168
	    terminated();
169
	}
170
	
171
	/* (non-Javadoc)
172
	 * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
173
	 */
174
	public boolean canResume() {
175
		return !isTerminated() && isSuspended();
176
	}
177
	
178
	/* (non-Javadoc)
179
	 * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
180
	 */
181
	public boolean canSuspend() {
182
		return !isTerminated() && !isSuspended();
183
	}
184
	
185
	/* (non-Javadoc)
186
	 * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
187
	 */
188
	public boolean isSuspended() {
189
		return fSuspended;
190
	}
191
	
192
	/* (non-Javadoc)
193
	 * @see org.eclipse.debug.core.model.ISuspendResume#resume()
194
	 */
195
	public void resume() throws DebugException {
196
	    fSuspended= false;
197
	    fController.resume();
198
	}
199
	
200
	/**
201
	 * Notification the target has suspended for the given reason
202
	 * 
203
	 * @param detail reason for the suspend
204
	 */
205
	public void suspended(int detail) {
206
		fSuspended = true;
207
		fThread.setStepping(false);
208
		fThread.fireSuspendEvent(detail);
209
	}	
210
	
211
	/* (non-Javadoc)
212
	 * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
213
	 */
214
	public void suspend() throws DebugException {
215
		fController.suspend();
216
	}
217
	
218
	/* (non-Javadoc)
219
	 * @see org.eclipse.debug.core.IBreakpointListener#breakpointAdded(org.eclipse.debug.core.model.IBreakpoint)
220
	 */
221
	public void breakpointAdded(IBreakpoint breakpoint) {
222
		fController.handleBreakpoint(breakpoint, true);
223
        if (breakpoint instanceof AntLineBreakpoint) {
224
            if (((AntLineBreakpoint) breakpoint).isRunToLine()) {
225
                if (fRunToLineBreakpoints == null) {
226
                    fRunToLineBreakpoints= new ArrayList();
227
                }
228
                fRunToLineBreakpoints.add(breakpoint);
229
            }
230
        }
231
	}
232
233
    /* (non-Javadoc)
234
	 * @see org.eclipse.debug.core.IBreakpointListener#breakpointRemoved(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
235
	 */
236
	public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
237
		fController.handleBreakpoint(breakpoint, false);
238
        if (fRunToLineBreakpoints != null) {
239
            if (fRunToLineBreakpoints.remove(breakpoint) && fRunToLineBreakpoints.isEmpty()) {
240
                fRunToLineBreakpoints= null;
241
            }
242
        }
243
	}
244
	
245
	/* (non-Javadoc)
246
	 * @see org.eclipse.debug.core.IBreakpointListener#breakpointChanged(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
247
	 */
248
	public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
249
		if (supportsBreakpoint(breakpoint)) {
250
			try {
251
				if (breakpoint.isEnabled() && DebugPlugin.getDefault().getBreakpointManager().isEnabled()) {
252
					breakpointAdded(breakpoint);
253
				} else {
254
					breakpointRemoved(breakpoint, null);
255
				}
256
			} catch (CoreException e) {
257
			}
258
		}
259
	}
260
	
261
	/* (non-Javadoc)
262
	 * @see org.eclipse.debug.core.model.IDisconnect#canDisconnect()
263
	 */
264
	public boolean canDisconnect() {
265
		return false;
266
	}
267
	
268
	/* (non-Javadoc)
269
	 * @see org.eclipse.debug.core.model.IDisconnect#disconnect()
270
	 */
271
	public void disconnect() throws DebugException {
272
	}
273
	
274
	/* (non-Javadoc)
275
	 * @see org.eclipse.debug.core.model.IDisconnect#isDisconnected()
276
	 */
277
	public boolean isDisconnected() {
278
		return false;
279
	}
280
	
281
	/* (non-Javadoc)
282
	 * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#supportsStorageRetrieval()
283
	 */
284
	public boolean supportsStorageRetrieval() {
285
		return false;
286
	}
287
	
288
	/* (non-Javadoc)
289
	 * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#getMemoryBlock(long, long)
290
	 */
291
	public IMemoryBlock getMemoryBlock(long startAddress, long length) throws DebugException {
292
		return null;
293
	}
294
295
	/**
296
	 * Notification we have connected to the Ant build logger and it has started.
297
	 * Resume the build.
298
	 */
299
	public void buildStarted() {
300
		fireCreationEvent();
301
		installDeferredBreakpoints();
302
		try {
303
			resume();
304
		} catch (DebugException e) {
305
		}
306
	}
307
	
308
	/**
309
	 * Install breakpoints that are already registered with the breakpoint
310
	 * manager if the breakpoint manager is enabled and the breakpoint is enabled.
311
	 */
312
	private void installDeferredBreakpoints() {
313
		IBreakpointManager manager= DebugPlugin.getDefault().getBreakpointManager();
314
		if (!manager.isEnabled()) {
315
			return;
316
		}
317
		IBreakpoint[] breakpoints = manager.getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL);
318
		for (int i = 0; i < breakpoints.length; i++) {
319
            IBreakpoint breakpoint= breakpoints[i];
320
            try {
321
                if (breakpoint.isEnabled()) {
322
                    breakpointAdded(breakpoints[i]);
323
                }
324
            } catch (CoreException e) {
325
            }
326
		}
327
	}
328
	
329
	/**
330
	 * Called when this debug target terminates.
331
	 */
332
	protected void terminated() {
333
		fThreads= new IThread[0];
334
		fTerminated = true;
335
		fSuspended = false;
336
		if (DebugPlugin.getDefault() != null) {
337
			DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this);
338
			DebugPlugin.getDefault().removeDebugEventListener(this);
339
			DebugPlugin.getDefault().getBreakpointManager().removeBreakpointManagerListener(this);
340
		}
341
		if (!getProcess().isTerminated()) {
342
		    try {
343
                fProcess.terminate();
344
                resume();
345
		    } catch (DebugException e) {       
346
		    }
347
		}
348
		if (DebugPlugin.getDefault() != null) {
349
			fireTerminateEvent();
350
		}
351
	}
352
	
353
	/**
354
	 * Single step the Ant build.
355
	 * 
356
	 * @throws DebugException if the request fails
357
	 */
358
	protected void stepOver() {
359
	    fSuspended= false;
360
		fController.stepOver();
361
	}
362
	
363
	/**
364
	 * Step-into the Ant build.
365
	 * 
366
	 * @throws DebugException if the request fails
367
	 */
368
	protected void stepInto() {
369
	    fSuspended= false;
370
	    fController.stepInto();
371
	}
372
	
373
	/**
374
	 * Notification a breakpoint was encountered. Determine
375
	 * which breakpoint was hit and fire a suspend event.
376
	 * 
377
	 * @param event debug event
378
	 */
379
	protected void breakpointHit(String event) {
380
		// determine which breakpoint was hit, and set the thread's breakpoint
381
		String[] datum= event.split(DebugMessageIds.MESSAGE_DELIMITER);
382
		String fileName= datum[1];
383
		int lineNumber = Integer.parseInt(datum[2]);
384
		IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL);
385
        boolean found= false;
386
		for (int i = 0; i < breakpoints.length; i++) {
387
           ILineBreakpoint lineBreakpoint = (ILineBreakpoint)breakpoints[i];
388
           if (setThreadBreakpoint(lineBreakpoint, lineNumber, fileName)) {
389
               found= true;
390
               break;
391
           }
392
		}
393
        if (!found && fRunToLineBreakpoints != null) {
394
            Iterator iter= fRunToLineBreakpoints.iterator();
395
            while (iter.hasNext()) {
396
                ILineBreakpoint lineBreakpoint = (ILineBreakpoint) iter.next();
397
                if (setThreadBreakpoint(lineBreakpoint, lineNumber, fileName)) {
398
                    break;
399
                }
400
            }
401
        }
402
		suspended(DebugEvent.BREAKPOINT);
403
	}	
404
    
405
    private boolean setThreadBreakpoint(ILineBreakpoint lineBreakpoint, int lineNumber, String fileName) {
406
        try {
407
            if (lineBreakpoint.getLineNumber() == lineNumber && 
408
                    fileName.equals(lineBreakpoint.getMarker().getResource().getLocation().toOSString())) {
409
                fThread.setBreakpoints(new IBreakpoint[]{lineBreakpoint});
410
                return true;
411
            }
412
        } catch (CoreException e) {
413
        }
414
        return false;
415
    }
416
	
417
    public void breakpointHit (IBreakpoint breakpoint) {
418
        fThread.setBreakpoints(new IBreakpoint[]{breakpoint});
419
        suspended(DebugEvent.BREAKPOINT);
420
    }
421
    
422
	protected void getStackFrames() {
423
		fController.getStackFrames();
424
	}
425
	
426
	protected void getProperties() {
427
		fController.getProperties();
428
	}
429
430
    /* (non-Javadoc)
431
     * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
432
     */
433
    public void handleDebugEvents(DebugEvent[] events) {
434
        for (int i = 0; i < events.length; i++) {
435
            DebugEvent event = events[i];
436
            if (event.getKind() == DebugEvent.TERMINATE && event.getSource().equals(fProcess)) {
437
                terminated();
438
            }
439
        }
440
    }
441
    
442
    /**
443
     * When the breakpoint manager disables, remove all registered breakpoints
444
     * requests from the VM. When it enables, reinstall them.
445
     *
446
     * @see org.eclipse.debug.core.IBreakpointManagerListener#breakpointManagerEnablementChanged(boolean)
447
     */
448
    public void breakpointManagerEnablementChanged(boolean enabled) {
449
        IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL);
450
        for (int i = 0; i < breakpoints.length; i++) {
451
            IBreakpoint breakpoint = breakpoints[i];
452
            if (enabled) {
453
                breakpointAdded(breakpoint);
454
            } else {
455
                breakpointRemoved(breakpoint, null);
456
            }
457
        }
458
    }
459
460
	public IAntDebugController getAntDebugController() {
461
		return fController;
462
	}   
463
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchDelegate.java (+889 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 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
 *     Juan A. Hernandez - bug 89926
11
 *     dakshinamurthy.karra@gmail.com - bug 165371
12
 *******************************************************************************/
13
package org.eclipse.ant.internal.launching.launchConfigurations;
14
15
import java.io.File;
16
import java.io.IOException;
17
import java.net.URL;
18
import java.util.HashMap;
19
import java.util.Iterator;
20
import java.util.List;
21
import java.util.Map;
22
23
import org.apache.tools.ant.ProjectHelper;
24
import org.eclipse.ant.core.AntCorePlugin;
25
import org.eclipse.ant.core.AntCorePreferences;
26
import org.eclipse.ant.core.AntRunner;
27
import org.eclipse.ant.core.Property;
28
import org.eclipse.ant.core.Task;
29
import org.eclipse.ant.core.Type;
30
import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger;
31
import org.eclipse.ant.internal.launching.AntLaunch;
32
import org.eclipse.ant.internal.launching.AntLaunching;
33
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
34
import org.eclipse.ant.internal.launching.debug.IAntDebugConstants;
35
import org.eclipse.ant.internal.launching.debug.model.RemoteAntDebugBuildListener;
36
import org.eclipse.core.internal.externaltools.launchConfigurations.BackgroundResourceRefresher;
37
import org.eclipse.core.internal.externaltools.launchConfigurations.ExternalToolsCoreUtil;
38
import org.eclipse.core.internal.externaltools.model.IExternalToolConstants;
39
import org.eclipse.core.resources.IProject;
40
import org.eclipse.core.runtime.CoreException;
41
import org.eclipse.core.runtime.FileLocator;
42
import org.eclipse.core.runtime.IPath;
43
import org.eclipse.core.runtime.IProgressMonitor;
44
import org.eclipse.core.runtime.IStatus;
45
import org.eclipse.core.runtime.Path;
46
import org.eclipse.core.runtime.Platform;
47
import org.eclipse.core.runtime.Status;
48
import org.eclipse.core.runtime.SubProgressMonitor;
49
import org.eclipse.core.variables.VariablesPlugin;
50
import org.eclipse.debug.core.DebugEvent;
51
import org.eclipse.debug.core.DebugPlugin;
52
import org.eclipse.debug.core.IBreakpointManager;
53
import org.eclipse.debug.core.IDebugEventSetListener;
54
import org.eclipse.debug.core.ILaunch;
55
import org.eclipse.debug.core.ILaunchConfiguration;
56
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
57
import org.eclipse.debug.core.ILaunchManager;
58
import org.eclipse.debug.core.model.IBreakpoint;
59
import org.eclipse.debug.core.model.IProcess;
60
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
61
import org.eclipse.debug.internal.core.LaunchManager;
62
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
63
import org.eclipse.jdt.launching.IVMInstall;
64
import org.eclipse.jdt.launching.JavaRuntime;
65
import org.eclipse.jdt.launching.SocketUtil;
66
import org.eclipse.osgi.service.resolver.BundleDescription;
67
import org.osgi.framework.Bundle;
68
69
import com.ibm.icu.text.MessageFormat;
70
71
/**
72
 * Launch delegate for Ant builds
73
 */
74
public class AntLaunchDelegate extends LaunchConfigurationDelegate {
75
76
	private static final String ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessBuildLogger"; //$NON-NLS-1$
77
	private static final String ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessDebugBuildLogger"; //$NON-NLS-1$
78
	private static final String NULL_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.NullBuildLogger"; //$NON-NLS-1$
79
	private static final String REMOTE_ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.RemoteAntBuildLogger"; //$NON-NLS-1$
80
	private static final String REMOTE_ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.debug.RemoteAntDebugBuildLogger"; //$NON-NLS-1$
81
	private static final String BASE_DIR_PREFIX = "-Dbasedir="; //$NON-NLS-1$
82
	private static final String INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.AntInputHandler"; //$NON-NLS-1$
83
	private static final String REMOTE_INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.ProxyInputHandler"; //$NON-NLS-1$
84
85
	private static final IProject[] NO_PROJECTS = new IProject[0];
86
87
	/**
88
	 * String attribute identifying the build scope for a launch configuration.
89
	 * <code>null</code> indicates the default workspace build.
90
	 */
91
	private static final String ATTR_BUILD_SCOPE = AntLaunching
92
			.getUniqueIdentifier()
93
			+ ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$
94
95
	/**
96
	 * Attribute identifier specifying whether referenced projects should be
97
	 * considered when computing the projects to build. Default value is
98
	 * <code>true</code>.
99
	 */
100
	private static final String ATTR_INCLUDE_REFERENCED_PROJECTS = AntLaunching
101
			.getUniqueIdentifier()
102
			+ ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$
103
104
	private static String fgSWTLibraryLocation;
105
106
	private String fMode;
107
	private boolean fUserSpecifiedLogger = false;
108
109
	private String getProgramArguments(ILaunchConfiguration configuration)
110
			throws CoreException {
111
		String arguments = configuration.getAttribute(
112
				IExternalToolConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$
113
		return VariablesPlugin.getDefault().getStringVariableManager()
114
				.performStringSubstitution(arguments);
115
	}
116
117
	/**
118
	 * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration,
119
	 *      java.lang.String, org.eclipse.debug.core.ILaunch,
120
	 *      org.eclipse.core.runtime.IProgressMonitor)
121
	 */
122
	public void launch(ILaunchConfiguration configuration, String mode,
123
			ILaunch launch, IProgressMonitor monitor) throws CoreException {
124
		if (monitor.isCanceled()) {
125
			return;
126
		}
127
		fUserSpecifiedLogger = false;
128
		fMode = mode;
129
130
		// migrate the config to the new classpath format if required
131
		AntLaunchingUtil.migrateToNewClasspathFormat(configuration);
132
133
		boolean isSeparateJRE = AntLaunchingUtil
134
				.isSeparateJREAntBuild(configuration);
135
136
		if (LaunchManager.isLaunchInBackground(configuration)) {
137
			monitor
138
					.beginTask(
139
							MessageFormat
140
									.format(
141
											AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1,
142
											new String[] { configuration
143
													.getName() }), 10);
144
		} else {
145
			monitor
146
					.beginTask(
147
							MessageFormat
148
									.format(
149
											AntLaunchConfigurationMessages.AntLaunchDelegate_Running__0__2,
150
											new String[] { configuration
151
													.getName() }), 100);
152
		}
153
154
		// resolve location
155
		IPath location = ExternalToolsCoreUtil.getLocation(configuration);
156
		monitor.worked(1);
157
158
		if (monitor.isCanceled()) {
159
			return;
160
		}
161
162
		if (!isSeparateJRE && AntRunner.isBuildRunning()) {
163
			IStatus status = new Status(
164
					IStatus.ERROR,
165
					IAntLaunchConfigurationConstants.PLUGIN_ID,
166
					1,
167
					MessageFormat
168
							.format(
169
									AntLaunchConfigurationMessages.AntLaunchDelegate_Build_In_Progress,
170
									new String[] { location.toOSString() }),
171
					null);
172
			throw new CoreException(status);
173
		}
174
175
		// resolve working directory
176
		IPath workingDirectory = ExternalToolsCoreUtil
177
				.getWorkingDirectory(configuration);
178
		String basedir = null;
179
		if (workingDirectory != null) {
180
			basedir = workingDirectory.toOSString();
181
		}
182
		monitor.worked(1);
183
184
		if (monitor.isCanceled()) {
185
			return;
186
		}
187
188
		// link the process to its build logger via a timestamp
189
		long timeStamp = System.currentTimeMillis();
190
		String idStamp = Long.toString(timeStamp);
191
		StringBuffer idProperty = new StringBuffer("-D"); //$NON-NLS-1$
192
		idProperty.append(AbstractEclipseBuildLogger.ANT_PROCESS_ID);
193
		idProperty.append('=');
194
		idProperty.append(idStamp);
195
196
		// resolve arguments
197
		String[] arguments = null;
198
		if (isSeparateJRE) {
199
			arguments = new String[] { getProgramArguments(configuration) };
200
		} else {
201
			arguments = ExternalToolsCoreUtil.getArguments(configuration);
202
		}
203
204
		Map userProperties = AntLaunchingUtil.getProperties(configuration);
205
		if (userProperties != null) {// create a copy so as to not affect the
206
			// configuration with transient
207
			// properties
208
			userProperties = new HashMap(userProperties);
209
		}
210
		String[] propertyFiles = AntLaunchingUtil
211
				.getPropertyFiles(configuration);
212
		String[] targets = AntLaunchingUtil.getTargetNames(configuration);
213
		URL[] customClasspath = AntLaunchingUtil
214
				.getCustomClasspath(configuration);
215
		String antHome = AntLaunchingUtil.getAntHome(configuration); //$NON-NLS-1$
216
217
		boolean setInputHandler = true;
218
		try {
219
			// check if set specify inputhandler
220
			setInputHandler = configuration.getAttribute(
221
					IAntLaunchConfigurationConstants.SET_INPUTHANDLER, true);
222
		} catch (CoreException ce) {
223
			AntLaunching.log(ce);
224
		}
225
226
		AntRunner runner = null;
227
		if (!isSeparateJRE) {
228
			runner = configureAntRunner(configuration, location, basedir,
229
					idProperty, arguments, userProperties, propertyFiles,
230
					targets, customClasspath, antHome, setInputHandler);
231
		}
232
233
		monitor.worked(1);
234
235
		if (monitor.isCanceled()) {
236
			return;
237
		}
238
		boolean captureOutput = ExternalToolsCoreUtil
239
				.getCaptureOutput(configuration);
240
		int port = -1;
241
		int requestPort = -1;
242
		if (isSeparateJRE && captureOutput) {
243
			if (userProperties == null) {
244
				userProperties = new HashMap();
245
			}
246
			port = SocketUtil.findFreePort();
247
			userProperties.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID,
248
					idStamp);
249
			userProperties.put("eclipse.connect.port", Integer.toString(port)); //$NON-NLS-1$
250
			if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
251
				requestPort = SocketUtil.findFreePort();
252
				userProperties
253
						.put(
254
								"eclipse.connect.request_port", Integer.toString(requestPort)); //$NON-NLS-1$
255
			}
256
		}
257
258
		StringBuffer commandLine = generateCommandLine(location, arguments,
259
				userProperties, propertyFiles, targets, antHome, basedir,
260
				isSeparateJRE, captureOutput, setInputHandler);
261
262
		if (isSeparateJRE) {
263
			monitor
264
					.beginTask(
265
							MessageFormat
266
									.format(
267
											AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1,
268
											new String[] { configuration
269
													.getName() }), 10);
270
			runInSeparateVM(configuration, launch, monitor, idStamp, antHome,
271
					port, requestPort, commandLine, captureOutput,
272
					setInputHandler);
273
		} else {
274
			runInSameVM(configuration, launch, monitor, location, idStamp,
275
					runner, commandLine, captureOutput);
276
		}
277
278
		monitor.done();
279
	}
280
281
	private void runInSameVM(ILaunchConfiguration configuration,
282
			ILaunch launch, IProgressMonitor monitor, IPath location,
283
			String idStamp, AntRunner runner, StringBuffer commandLine,
284
			boolean captureOutput) throws CoreException {
285
		Map attributes = new HashMap(2);
286
		attributes.put(IProcess.ATTR_PROCESS_TYPE,
287
				IAntLaunchConfigurationConstants.ID_ANT_PROCESS_TYPE);
288
		attributes.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp);
289
290
		final AntProcess process = new AntProcess(location.toOSString(),
291
				launch, attributes);
292
		setProcessAttributes(process, idStamp, commandLine, captureOutput);
293
		boolean debug = fMode.equals(ILaunchManager.DEBUG_MODE);
294
		if (debug || LaunchManager.isLaunchInBackground(configuration)) {
295
			final AntRunner finalRunner = runner;
296
			Runnable r = new Runnable() {
297
				public void run() {
298
					try {
299
						finalRunner.run(process);
300
					} catch (CoreException e) {
301
						handleException(
302
								e,
303
								AntLaunchConfigurationMessages.AntLaunchDelegate_Failure);
304
					}
305
					process.terminated();
306
				}
307
			};
308
			Thread background = new Thread(r);
309
			background.setDaemon(true);
310
			background.start();
311
			monitor.worked(1);
312
			// refresh resources after process finishes
313
			if (LaunchManager.getRefreshScope(configuration) != null) {
314
				BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(
315
						configuration, process);
316
				refresher.startBackgroundRefresh();
317
			}
318
		} else {
319
			// execute the build
320
			try {
321
				runner.run(monitor);
322
			} catch (CoreException e) {
323
				process.terminated();
324
				monitor.done();
325
				handleException(e,
326
						AntLaunchConfigurationMessages.AntLaunchDelegate_23);
327
				return;
328
			}
329
			process.terminated();
330
331
			// refresh resources
332
			LaunchManager.refreshResources(configuration, monitor);
333
		}
334
	}
335
336
	private AntRunner configureAntRunner(ILaunchConfiguration configuration,
337
			IPath location, String baseDir, StringBuffer idProperty,
338
			String[] arguments, Map userProperties, String[] propertyFiles,
339
			String[] targets, URL[] customClasspath, String antHome,
340
			boolean setInputHandler) throws CoreException {
341
		int argLength = 1; // at least one user property - timestamp
342
		if (arguments != null) {
343
			argLength += arguments.length;
344
		}
345
		if (baseDir != null && baseDir.length() > 0) {
346
			argLength++;
347
		}
348
		String[] runnerArgs = new String[argLength];
349
		if (arguments != null) {
350
			System.arraycopy(arguments, 0, runnerArgs, 0, arguments.length);
351
		}
352
		if (baseDir != null && baseDir.length() > 0) {
353
			runnerArgs[runnerArgs.length - 2] = BASE_DIR_PREFIX + baseDir;
354
		}
355
		runnerArgs[runnerArgs.length - 1] = idProperty.toString();
356
357
		AntRunner runner = new AntRunner();
358
		runner.setBuildFileLocation(location.toOSString());
359
		boolean captureOutput = ExternalToolsCoreUtil
360
				.getCaptureOutput(configuration);
361
		if (captureOutput) {
362
			if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
363
				runner.addBuildLogger(ANT_DEBUG_LOGGER_CLASS);
364
			} else {
365
				runner.addBuildLogger(ANT_LOGGER_CLASS);
366
			}
367
		} else {
368
			runner.addBuildLogger(NULL_LOGGER_CLASS);
369
		}
370
		if (setInputHandler) {
371
			runner.setInputHandler(INPUT_HANDLER_CLASS);
372
		} else {
373
			runner.setInputHandler(""); //$NON-NLS-1$
374
		}
375
		runner.setArguments(runnerArgs);
376
		if (userProperties != null) {
377
			runner.addUserProperties(userProperties);
378
		}
379
380
		if (propertyFiles != null) {
381
			runner.setPropertyFiles(propertyFiles);
382
		}
383
384
		if (targets != null) {
385
			runner.setExecutionTargets(targets);
386
		}
387
388
		if (customClasspath != null) {
389
			runner.setCustomClasspath(customClasspath);
390
		}
391
392
		if (antHome != null) {
393
			runner.setAntHome(antHome);
394
		}
395
		return runner;
396
	}
397
398
	private void handleException(final CoreException e, final String title) {
399
		AntLaunching.log(title, e);
400
	}
401
402
	private void setProcessAttributes(IProcess process, String idStamp,
403
			StringBuffer commandLine, boolean captureOutput) {
404
		// link the process to the Eclipse build logger via a timestamp
405
		if (!fUserSpecifiedLogger) {
406
			process.setAttribute(AbstractEclipseBuildLogger.ANT_PROCESS_ID,
407
					idStamp);
408
		}
409
410
		// create "fake" command line for the process
411
		if (commandLine != null) {
412
			process.setAttribute(IProcess.ATTR_CMDLINE, commandLine.toString());
413
		}
414
	}
415
416
	private StringBuffer generateCommandLine(IPath location,
417
			String[] arguments, Map userProperties, String[] propertyFiles,
418
			String[] targets, String antHome, String basedir,
419
			boolean separateVM, boolean captureOutput, boolean setInputHandler) {
420
		StringBuffer commandLine = new StringBuffer();
421
422
		if (!separateVM) {
423
			commandLine.append("ant"); //$NON-NLS-1$
424
		}
425
426
		if (arguments != null) {
427
			for (int i = 0; i < arguments.length; i++) {
428
				commandLine.append(' ');
429
				commandLine.append(arguments[i]);
430
			}
431
		}
432
433
		AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
434
		if (propertyFiles == null) { // global
435
			String[] files = prefs.getCustomPropertyFiles();
436
			for (int i = 0; i < files.length; i++) {
437
				String path = files[i];
438
				commandLine.append(" -propertyfile \""); //$NON-NLS-1$
439
				commandLine.append(path);
440
				commandLine.append('\"');
441
			}
442
		} else {// "local" configuration
443
			for (int i = 0; i < propertyFiles.length; i++) {
444
				String path = propertyFiles[i];
445
				commandLine.append(" -propertyfile \""); //$NON-NLS-1$
446
				commandLine.append(path);
447
				commandLine.append('\"');
448
			}
449
		}
450
		// "local" configuration
451
		if (userProperties != null) {
452
			Iterator keys = userProperties.keySet().iterator();
453
			String key;
454
			while (keys.hasNext()) {
455
				key = (String) keys.next();
456
				appendProperty(commandLine, key, (String) userProperties
457
						.get(key));
458
			}
459
		}
460
461
		// global
462
		List properties = null;
463
		if (!separateVM) {
464
			properties = prefs.getProperties();
465
		} else {
466
			properties = prefs.getRemoteAntProperties();
467
		}
468
469
		// if we have user properties this means that the user has chosen to
470
		// override the global properties
471
		// if in a separate VM and have only two (or three if debug) user
472
		// properties these are really only Eclipse generated properties
473
		// and the user is still using the global properties
474
		int numberOfEclipseProperties = 2;
475
		if (userProperties != null
476
				&& userProperties.get("eclipse.connect.request_port") != null) { //$NON-NLS-1$
477
			numberOfEclipseProperties = 3; // debug mode
478
		}
479
		boolean useGlobalProperties = userProperties == null
480
				|| (separateVM && userProperties.size() == numberOfEclipseProperties);
481
		if (useGlobalProperties) {
482
			for (Iterator iter = properties.iterator(); iter.hasNext();) {
483
				Property property = (Property) iter.next();
484
				String key = property.getName();
485
				String value = property.getValue(false);
486
				if (value != null) {
487
					appendProperty(commandLine, key, value);
488
				}
489
			}
490
		}
491
492
		if (basedir != null && basedir.length() > 0) {
493
			appendProperty(commandLine, "basedir", basedir); //$NON-NLS-1$
494
		}
495
496
		if (antHome != null) {
497
			commandLine.append(" \"-Dant.home="); //$NON-NLS-1$
498
			commandLine.append(antHome);
499
			commandLine.append('\"');
500
		}
501
502
		if (separateVM) {
503
			if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$
504
				if (captureOutput) {
505
					commandLine.append(" -logger "); //$NON-NLS-1$
506
					if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
507
						commandLine.append(REMOTE_ANT_DEBUG_LOGGER_CLASS);
508
					} else {
509
						commandLine.append(REMOTE_ANT_LOGGER_CLASS);
510
					}
511
				}
512
			} else {
513
				fUserSpecifiedLogger = true;
514
			}
515
			if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$
516
				commandLine.append(" -inputhandler "); //$NON-NLS-1$
517
				commandLine.append(REMOTE_INPUT_HANDLER_CLASS);
518
			}
519
		} else {
520
			if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$
521
				commandLine.append(" -inputhandler "); //$NON-NLS-1$
522
				commandLine.append(INPUT_HANDLER_CLASS);
523
			}
524
			if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$
525
				commandLine.append(" -logger "); //$NON-NLS-1$
526
				if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
527
					commandLine.append(ANT_DEBUG_LOGGER_CLASS);
528
				} else if (captureOutput) {
529
					commandLine.append(ANT_LOGGER_CLASS);
530
				} else {
531
					commandLine.append(NULL_LOGGER_CLASS);
532
				}
533
			}
534
		}
535
536
		if (separateVM) {
537
			appendTaskAndTypes(prefs, commandLine);
538
		}
539
		commandLine.append(" -buildfile \""); //$NON-NLS-1$
540
		commandLine.append(location.toOSString());
541
		commandLine.append('\"');
542
543
		if (targets != null) {
544
			for (int i = 0; i < targets.length; i++) {
545
				commandLine.append(" \""); //$NON-NLS-1$
546
				commandLine.append(targets[i]);
547
				commandLine.append('\"');
548
			}
549
		}
550
		return commandLine;
551
	}
552
553
	private void appendTaskAndTypes(AntCorePreferences prefs,
554
			StringBuffer commandLine) {
555
		List tasks = prefs.getRemoteTasks();
556
		Iterator itr = tasks.iterator();
557
		while (itr.hasNext()) {
558
			Task task = (Task) itr.next();
559
			commandLine.append(" -eclipseTask "); //$NON-NLS-1$
560
			String name = ProjectHelper.genComponentName(task.getURI(), task
561
					.getTaskName());
562
			commandLine.append(name);
563
			commandLine.append(',');
564
			commandLine.append(task.getClassName());
565
		}
566
567
		List types = prefs.getRemoteTypes();
568
		itr = types.iterator();
569
		while (itr.hasNext()) {
570
			Type type = (Type) itr.next();
571
			commandLine.append(" -eclipseType "); //$NON-NLS-1$
572
			String name = ProjectHelper.genComponentName(type.getURI(), type
573
					.getTypeName());
574
			commandLine.append(name);
575
			commandLine.append(',');
576
			commandLine.append(type.getClassName());
577
		}
578
	}
579
580
	private void appendProperty(StringBuffer commandLine, String name,
581
			String value) {
582
		commandLine.append(" \"-D"); //$NON-NLS-1$
583
		commandLine.append(name);
584
		commandLine.append('=');
585
		commandLine.append(value);
586
		if (value.length() > 0
587
				&& value.charAt(value.length() - 1) == File.separatorChar) {
588
			commandLine.append(File.separatorChar);
589
		}
590
		commandLine.append("\""); //$NON-NLS-1$
591
	}
592
593
	private void runInSeparateVM(ILaunchConfiguration configuration,
594
			ILaunch launch, IProgressMonitor monitor, String idStamp,
595
			String antHome, int port, int requestPort,
596
			StringBuffer commandLine, boolean captureOutput,
597
			boolean setInputHandler) throws CoreException {
598
		boolean debug = fMode.equals(ILaunchManager.DEBUG_MODE);
599
		if (captureOutput) {
600
			if (debug) {
601
				RemoteAntDebugBuildListener listener = new RemoteAntDebugBuildListener(
602
						launch);
603
				if (requestPort != -1) {
604
					listener.startListening(port, requestPort);
605
				}
606
			} else if (!fUserSpecifiedLogger) {
607
				RemoteAntBuildListener client = new RemoteAntBuildListener(
608
						launch);
609
				if (port != -1) {
610
					client.startListening(port);
611
				}
612
			}
613
		}
614
615
		ILaunchConfigurationWorkingCopy copy = configuration.getWorkingCopy();
616
		setDefaultWorkingDirectory(copy);
617
		copy.setAttribute(
618
				IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
619
				commandLine.toString());
620
		StringBuffer vmArgs = generateVMArguments(copy, setInputHandler,
621
				antHome);
622
		copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
623
				vmArgs.toString());
624
		copy.setAttribute(ILaunchManager.ATTR_PRIVATE, true);
625
		if (copy
626
				.getAttribute(
627
						IAntLaunchConfigurationConstants.ATTR_DEFAULT_VM_INSTALL,
628
						false)) {
629
			setDefaultVM(configuration, copy);
630
		}
631
		if (debug) { // do not allow launch in foreground bug 83254
632
			copy.setAttribute(ILaunchManager.ATTR_LAUNCH_IN_BACKGROUND, true);
633
		}
634
635
		// set the ANT_HOME environment variable
636
		if (antHome != null) {
637
			Map vars = copy.getAttribute(
638
					ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, new HashMap(1));
639
			vars.put("ANT_HOME", antHome); //$NON-NLS-1$
640
			copy.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, vars);
641
		}
642
643
		// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
644
		// "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000");
645
		IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 10);
646
		AntJavaLaunchDelegate delegate = new AntJavaLaunchDelegate();
647
		delegate.preLaunchCheck(copy, ILaunchManager.RUN_MODE, subMonitor);
648
		delegate.launch(copy, ILaunchManager.RUN_MODE, launch, subMonitor);
649
		final IProcess[] processes = launch.getProcesses();
650
		for (int i = 0; i < processes.length; i++) {
651
			setProcessAttributes(processes[i], idStamp, null, captureOutput);
652
		}
653
654
		if (LaunchManager.isLaunchInBackground(copy)) {
655
			// refresh resources after process finishes
656
			if (LaunchManager.getRefreshScope(configuration) != null) {
657
				BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(
658
						configuration, processes[0]);
659
				refresher.startBackgroundRefresh();
660
			}
661
		} else {
662
			final boolean[] terminated = new boolean[1];
663
			terminated[0] = launch.isTerminated();
664
			IDebugEventSetListener listener = new IDebugEventSetListener() {
665
				public void handleDebugEvents(DebugEvent[] events) {
666
					for (int i = 0; i < events.length; i++) {
667
						DebugEvent event = events[i];
668
						for (int j = 0, numProcesses = processes.length; j < numProcesses; j++) {
669
							if (event.getSource() == processes[j]
670
									&& event.getKind() == DebugEvent.TERMINATE) {
671
								terminated[0] = true;
672
								break;
673
							}
674
						}
675
					}
676
				}
677
			};
678
			DebugPlugin.getDefault().addDebugEventListener(listener);
679
			monitor
680
					.subTask(AntLaunchConfigurationMessages.AntLaunchDelegate_28);
681
			while (!monitor.isCanceled() && !terminated[0]) {
682
				try {
683
					Thread.sleep(50);
684
				} catch (InterruptedException e) {
685
				}
686
			}
687
			DebugPlugin.getDefault().removeDebugEventListener(listener);
688
			if (!monitor.isCanceled()) {
689
				// refresh resources
690
				LaunchManager.refreshResources(configuration, monitor);
691
			}
692
		}
693
	}
694
695
	private void setDefaultVM(ILaunchConfiguration configuration,
696
			ILaunchConfigurationWorkingCopy copy) {
697
		try {
698
			JavaRuntime.getJavaProject(configuration);
699
			// remove the vm name, install type and jre container path for the
700
			// Java launching concept of default VM
701
			copy.setAttribute(
702
					IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME,
703
					(String) null);
704
			copy.setAttribute(
705
					IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE,
706
					(String) null);
707
			copy.setAttribute(
708
					IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH,
709
					(String) null);
710
		} catch (CoreException ce) {
711
			// not in a Java project
712
			IVMInstall defaultVMInstall = JavaRuntime.getDefaultVMInstall();
713
			copy.setAttribute(
714
					IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME,
715
					defaultVMInstall.getName());
716
			copy.setAttribute(
717
					IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE,
718
					defaultVMInstall.getVMInstallType().getId());
719
		}
720
	}
721
722
	private StringBuffer generateVMArguments(ILaunchConfiguration config,
723
			boolean setInputHandler, String antHome) {
724
		StringBuffer vmArgs = new StringBuffer();
725
		try {
726
			String configArgs = config.getAttribute(
727
					IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
728
					(String) null);
729
			if (configArgs != null) {
730
				vmArgs.append(configArgs);
731
				vmArgs.append(' ');
732
			}
733
		} catch (CoreException e) {
734
		}
735
736
		if (antHome != null) {
737
			vmArgs.append("-Dant.home=\""); //$NON-NLS-1$
738
			vmArgs.append(antHome);
739
			vmArgs.append("\" "); //$NON-NLS-1$
740
741
			File antLibDir = new File(antHome, "lib"); //$NON-NLS-1$
742
			vmArgs.append("-Dant.library.dir=\""); //$NON-NLS-1$
743
			vmArgs.append(antLibDir.getAbsolutePath());
744
			vmArgs.append('\"');
745
		}
746
		if (setInputHandler) {
747
			String swtLocation = getSWTLibraryLocation();
748
			if (swtLocation != null) {
749
				vmArgs.append(" -Djava.library.path=\""); //$NON-NLS-1$
750
				String javaLibPath = System.getProperty("java.library.path"); //$NON-NLS-1$
751
				javaLibPath = stripUnescapedQuotes(javaLibPath);
752
				if (javaLibPath != null) {
753
					vmArgs.append(javaLibPath);
754
					if (vmArgs.charAt(vmArgs.length() - 1) != File.pathSeparatorChar) {
755
						vmArgs.append(File.pathSeparatorChar);
756
					}
757
				}
758
				vmArgs.append(swtLocation);
759
				vmArgs.append('"');
760
			}
761
		}
762
		return vmArgs;
763
	}
764
765
	private String stripUnescapedQuotes(String javaLibPath) {
766
		StringBuffer buf = new StringBuffer(javaLibPath.length());
767
		for (int i = 0; i < javaLibPath.length(); i++) {
768
			char c = javaLibPath.charAt(i);
769
			switch (c) {
770
			case '"':
771
				if (i != 0 && javaLibPath.charAt(i - 1) == '\\') {
772
					buf.append(c);
773
				}
774
				break;
775
			default:
776
				buf.append(c);
777
				break;
778
			}
779
		}
780
		return buf.toString();
781
	}
782
783
	/*
784
	 * (non-Javadoc)
785
	 * 
786
	 * @see
787
	 * org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder
788
	 * (org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
789
	 */
790
	protected IProject[] getBuildOrder(ILaunchConfiguration configuration,
791
			String mode) throws CoreException {
792
		IProject[] projects = ExternalToolsCoreUtil.getBuildProjects(
793
				configuration, ATTR_BUILD_SCOPE);
794
		if (projects == null) {
795
			return NO_PROJECTS;
796
		}
797
		boolean isRef = ExternalToolsCoreUtil.isIncludeReferencedProjects(
798
				configuration, ATTR_INCLUDE_REFERENCED_PROJECTS);
799
		if (isRef) {
800
			return computeReferencedBuildOrder(projects);
801
		}
802
		return computeBuildOrder(projects);
803
	}
804
805
	private String getSWTLibraryLocation() {
806
		if (fgSWTLibraryLocation == null) {
807
			Bundle bundle = Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$
808
			BundleDescription description = Platform.getPlatformAdmin()
809
					.getState(false).getBundle(bundle.getBundleId());
810
			BundleDescription[] fragments = description.getFragments();
811
			if (fragments == null || fragments.length == 0) {
812
				return null;
813
			}
814
			Bundle fragBundle = Platform.getBundle(fragments[0]
815
					.getSymbolicName());
816
			try {
817
				URL url = FileLocator.toFileURL(fragBundle.getEntry("/")); //$NON-NLS-1$
818
				IPath path = new Path(url.getPath());
819
				path = path.removeTrailingSeparator();
820
				fgSWTLibraryLocation = path.toOSString();
821
			} catch (IOException e) {
822
			}
823
		}
824
		return fgSWTLibraryLocation;
825
	}
826
827
	/*
828
	 * (non-Javadoc)
829
	 * 
830
	 * @see
831
	 * org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBreakpoints
832
	 * (org.eclipse.debug.core.ILaunchConfiguration)
833
	 */
834
	protected IBreakpoint[] getBreakpoints(ILaunchConfiguration configuration) {
835
		IBreakpointManager breakpointManager = DebugPlugin.getDefault()
836
				.getBreakpointManager();
837
		if (!breakpointManager.isEnabled()) {
838
			// no need to check breakpoints individually.
839
			return null;
840
		}
841
		return breakpointManager
842
				.getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL);
843
	}
844
845
	/*
846
	 * (non-Javadoc)
847
	 * 
848
	 * @see
849
	 * org.eclipse.debug.core.model.LaunchConfigurationDelegate#saveBeforeLaunch
850
	 * (org.eclipse.debug.core.ILaunchConfiguration, java.lang.String,
851
	 * org.eclipse.core.runtime.IProgressMonitor)
852
	 */
853
	protected boolean saveBeforeLaunch(ILaunchConfiguration configuration,
854
			String mode, IProgressMonitor monitor) throws CoreException {
855
		if (IExternalToolConstants.ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY
856
				.equals(configuration.getType().getCategory())) {
857
			// don't prompt for builders
858
			return true;
859
		}
860
		return super.saveBeforeLaunch(configuration, mode, monitor);
861
	}
862
863
	/**
864
	 * Sets the default working directory to be the parent folder of the
865
	 * buildfile if the user has not explicitly set the working directory.
866
	 */
867
	private void setDefaultWorkingDirectory(ILaunchConfigurationWorkingCopy copy) {
868
		try {
869
			String wd = copy.getAttribute(
870
					IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
871
					(String) null);
872
			if (wd == null) {
873
				wd = ExternalToolsCoreUtil.getLocation(copy)
874
						.removeLastSegments(1).toOSString();
875
				copy
876
						.setAttribute(
877
								IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
878
								wd);
879
			}
880
		} catch (CoreException e) {
881
			AntLaunching.log(e.getStatus());
882
		}
883
	}
884
885
	public ILaunch getLaunch(ILaunchConfiguration configuration, String mode)
886
			throws CoreException {
887
		return new AntLaunch(configuration, mode, null);
888
	}
889
}
(-)src/org/eclipse/ant/internal/launching/debug/model/RemoteAntDebugBuildListener.java (+321 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2006 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
12
package org.eclipse.ant.internal.launching.debug.model;
13
14
import java.io.BufferedReader;
15
import java.io.IOException;
16
import java.io.InputStreamReader;
17
import java.io.PrintWriter;
18
import java.net.Socket;
19
import java.net.UnknownHostException;
20
21
import org.eclipse.ant.internal.launching.AntLaunching;
22
import org.eclipse.ant.internal.launching.debug.IAntDebugController;
23
import org.eclipse.ant.internal.launching.launchConfigurations.RemoteAntBuildListener;
24
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.debug.core.DebugEvent;
26
import org.eclipse.debug.core.DebugPlugin;
27
import org.eclipse.debug.core.ILaunch;
28
import org.eclipse.debug.core.model.IBreakpoint;
29
import org.eclipse.debug.core.model.ILineBreakpoint;
30
import org.eclipse.debug.core.model.IProcess;
31
32
public class RemoteAntDebugBuildListener extends RemoteAntBuildListener implements IAntDebugController {
33
	
34
	// sockets to communicate with the remote Ant debug build logger
35
	private Socket fRequestSocket;
36
	private PrintWriter fRequestWriter;
37
	private BufferedReader fResponseReader;
38
	
39
	private int fRequestPort= -1;
40
	private Thread fReaderThread;
41
	
42
	private AntDebugTarget fTarget;
43
	
44
	/**
45
	 * Reader thread that processes request responses from the remote Ant debug build logger
46
	 */
47
	private class ReaderThread extends Thread {
48
		public ReaderThread() {
49
			super("Ant Request Response Reader Thread"); //$NON-NLS-1$
50
			setDaemon(true);
51
		}
52
53
		public void run(){
54
			try { 
55
				String message= null; 
56
				while (fResponseReader != null) { 
57
				    synchronized (RemoteAntDebugBuildListener.this) {
58
				        if (fResponseReader != null && (message= fResponseReader.readLine()) != null) {
59
				            receiveMessage(message);
60
				        }
61
				    }
62
				} 
63
			} catch (IOException ie) { //the other end has shutdown
64
				RemoteAntDebugBuildListener.this.shutDown();
65
			} catch (Exception e) {
66
				AntLaunching.log("Internal error processing remote response", e); //$NON-NLS-1$
67
				RemoteAntDebugBuildListener.this.shutDown();
68
			}
69
		}
70
	}	
71
	
72
	public RemoteAntDebugBuildListener(ILaunch launch) {
73
		super(launch);
74
		//fDebug= true;
75
	}
76
	
77
	protected void receiveMessage(String message) {
78
		if (message.startsWith(DebugMessageIds.BUILD_STARTED)) {
79
			buildStarted();
80
		} else if (message.startsWith(DebugMessageIds.SUSPENDED)){
81
			handleSuspendMessage(message);
82
		} else if (message.startsWith(DebugMessageIds.TERMINATED)){
83
			fTarget.terminated();
84
		} else if (message.startsWith(DebugMessageIds.STACK)){
85
			AntThread thread= (AntThread) fTarget.getThreads()[0];
86
			thread.buildStack(message);
87
		} else if (message.startsWith(DebugMessageIds.PROPERTIES)){
88
		    AntThread thread= (AntThread) fTarget.getThreads()[0];
89
		    thread.newProperties(message);
90
		} else {
91
			super.receiveMessage(message);
92
		}
93
	}
94
95
    private void handleSuspendMessage(String message) {
96
        if (message.endsWith(DebugMessageIds.CLIENT_REQUEST)) {
97
        	fTarget.suspended(DebugEvent.CLIENT_REQUEST);
98
        } else if (message.endsWith(DebugMessageIds.STEP)) {
99
        	fTarget.suspended(DebugEvent.STEP_END);
100
        } else if (message.indexOf(DebugMessageIds.BREAKPOINT) >= 0) {
101
        	fTarget.breakpointHit(message);
102
        }
103
    }
104
105
    private void buildStarted() {
106
        IProcess process= getProcess();
107
        while(process == null) {
108
        	try {
109
        		synchronized (this) {
110
        			wait(400);
111
        		}
112
        		process= getProcess();
113
        	} catch (InterruptedException ie) {
114
        	}
115
        }
116
        fTarget= new AntDebugTarget(fLaunch, process, this);
117
        fLaunch.addDebugTarget(fTarget);
118
        
119
        if (!connectRequest()) {
120
			RemoteAntDebugBuildListener.this.shutDown();
121
			return;
122
        }
123
        
124
        fTarget.buildStarted();
125
    }
126
127
    private boolean connectRequest() {
128
    	Exception exception= null;
129
    	for (int i= 1; i < 20; i++) {
130
    		try {
131
    			fRequestSocket = new Socket("localhost", fRequestPort); //$NON-NLS-1$
132
    			fRequestWriter = new PrintWriter(fRequestSocket.getOutputStream(), true);
133
    			fResponseReader = new BufferedReader(new InputStreamReader(fRequestSocket.getInputStream()));
134
    			
135
    			fReaderThread= new ReaderThread();
136
    			fReaderThread.start();
137
    			return true;
138
    		} catch (UnknownHostException e) {
139
    			exception= e;
140
    			break;
141
    		} catch (IOException e) {
142
    			exception= e;
143
    		}
144
    		try {
145
				Thread.sleep(500);
146
			} catch(InterruptedException e) {
147
			}
148
    	}
149
    	AntLaunching.log("Internal error attempting to connect to debug target", exception); //$NON-NLS-1$
150
    	return false;
151
	}
152
153
	/**
154
	 * Start listening to an Ant build. Start a server connection that
155
	 * the RemoteAntDebugBuildLogger can connect to.
156
	 * 
157
	 * @param eventPort The port number to create the server connection on
158
     * @param requestPort The port number to use for sending requests to the remote logger
159
	 */
160
	public synchronized void startListening(int eventPort, int requestPort) {
161
		super.startListening(eventPort);
162
		fRequestPort= requestPort;
163
	}
164
	
165
	/**
166
	 * Sends a request to the Ant build
167
	 * 
168
	 * @param request debug command
169
	 */
170
	protected void sendRequest(String request) {
171
		if (fRequestSocket == null) {
172
			return;
173
		}
174
		synchronized (fRequestSocket) {
175
			fRequestWriter.println(request);
176
		}		
177
	}
178
	
179
	protected synchronized void shutDown() {
180
        if (fTarget != null) {
181
            fTarget.terminated();
182
            fTarget= null;
183
        }
184
		fLaunch= null;
185
		if (DebugPlugin.getDefault() != null) {
186
			DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this);
187
		}
188
		try {
189
			if (fReaderThread != null)   {
190
				// interrupt reader thread so that we don't block on close
191
				// on a lock held by the BufferedReader
192
				// see bug: 38955
193
				fReaderThread.interrupt();
194
			}
195
			if (fResponseReader != null) {
196
				fResponseReader.close();
197
				fResponseReader= null;
198
			}
199
		} catch(IOException e) {
200
		}	
201
		if (fRequestWriter != null) {
202
			fRequestWriter.close();
203
			fRequestWriter= null;
204
		}
205
		try{
206
			if(fRequestSocket != null) {
207
				fRequestSocket.close();
208
				fRequestSocket= null;
209
			}
210
		} catch(IOException e) {
211
		}
212
		super.shutDown();
213
	}
214
215
	/* (non-Javadoc)
216
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#resume()
217
	 */
218
	public void resume() {
219
		sendRequest(DebugMessageIds.RESUME);
220
	}
221
222
	/* (non-Javadoc)
223
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#suspend()
224
	 */
225
	public void suspend() {
226
		sendRequest(DebugMessageIds.SUSPEND);
227
	}
228
229
	/* (non-Javadoc)
230
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#stepInto()
231
	 */
232
	public void stepInto() {
233
		sendRequest(DebugMessageIds.STEP_INTO);
234
	}
235
236
	/* (non-Javadoc)
237
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#stepOver()
238
	 */
239
	public void stepOver() {
240
		sendRequest(DebugMessageIds.STEP_OVER);
241
	}
242
243
	/* (non-Javadoc)
244
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#handleBreakpoint(IBreakpoint, boolean)
245
	 */
246
	public void handleBreakpoint(IBreakpoint breakpoint, boolean add) {
247
		if (fTarget == null || !fTarget.supportsBreakpoint(breakpoint)) {
248
			return;
249
		}
250
		StringBuffer message= new StringBuffer();
251
		if (add) {
252
			try {
253
				if (!breakpoint.isEnabled()) {
254
					return;
255
				}
256
			} catch (CoreException e) {
257
				AntLaunching.log(e);
258
				return;
259
			}
260
			message.append(DebugMessageIds.ADD_BREAKPOINT);
261
		} else {
262
			message.append(DebugMessageIds.REMOVE_BREAKPOINT);
263
		}
264
		message.append(DebugMessageIds.MESSAGE_DELIMITER);
265
		message.append(breakpoint.getMarker().getResource().getLocation().toOSString());
266
		message.append(DebugMessageIds.MESSAGE_DELIMITER);
267
		try {
268
			message.append(((ILineBreakpoint)breakpoint).getLineNumber());
269
			sendRequest(message.toString());
270
		} catch (CoreException ce) {
271
			AntLaunching.log(ce);
272
		}
273
	}
274
275
	/* (non-Javadoc)
276
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#getProperties()
277
	 */
278
	public void getProperties() {
279
		sendRequest(DebugMessageIds.PROPERTIES);
280
	}
281
282
	/* (non-Javadoc)
283
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#getStackFrames()
284
	 */
285
	public void getStackFrames() {
286
		sendRequest(DebugMessageIds.STACK);
287
	}
288
289
	/* (non-Javadoc)
290
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#unescapeString(java.lang.StringBuffer)
291
	 */
292
	public StringBuffer unescapeString(StringBuffer property) {
293
		if (property.indexOf("\\r") == -1 && property.indexOf("\\n") == -1) { //$NON-NLS-1$ //$NON-NLS-2$
294
			return property;
295
		}
296
		for (int i= 0; i < property.length(); i++) {
297
			if ('\\' == property.charAt(i)) {
298
				String newString= ""; //$NON-NLS-1$
299
				if ('r' == property.charAt(i + 1)) {
300
					if (i-1 > - 1 && '\\' == property.charAt(i-1)) {
301
						newString= "r"; //$NON-NLS-1$
302
					} else {
303
						newString+= '\r';
304
					}
305
				} else if ('n' == property.charAt(i + 1)) {
306
					if (i-1 > - 1 && '\\' == property.charAt(i-1)) {
307
						newString= "n"; //$NON-NLS-1$
308
					} else {
309
						newString+= '\n';
310
					}
311
					
312
				}
313
				if (newString.length() > 0) {
314
					property.replace(i, i + 2, newString);
315
				}
316
			}
317
		}
318
319
		return property;
320
	}
321
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntCoreModelMessages.properties (+14 lines)
Added Link Here
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
12
AntUtil_6=Invalid property file entry: {0}
13
AntUtil_7=Unable to generate Ant classpath
14
AntUtil_2=Error reading launch configuration
(-)src/org/eclipse/ant/internal/launching/AntLaunchingPreferenceInitializer.java (+37 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 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.ant.internal.launching;
12
13
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
14
import org.eclipse.core.runtime.preferences.DefaultScope;
15
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
16
17
public class AntLaunchingPreferenceInitializer extends
18
		AbstractPreferenceInitializer {
19
20
	public AntLaunchingPreferenceInitializer() {
21
		super();
22
	}
23
24
	/*
25
	 * (non-Javadoc)
26
	 * 
27
	 * @seeorg.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#
28
	 * initializeDefaultPreferences()
29
	 */
30
	public void initializeDefaultPreferences() {
31
32
		IEclipsePreferences node = new DefaultScope()
33
				.getNode("org.eclipse.ant.launching"); //$NON-NLS-1$
34
		node.put(IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT,
35
				"20000"); //$NON-NLS-1$
36
	}
37
}
(-)src/org/eclipse/ant/internal/launching/LinkDescriptor.java (+60 lines)
Added Link Here
1
package org.eclipse.ant.internal.launching;
2
3
public class LinkDescriptor {
4
	String line;
5
	String fileName;
6
	int lineNumber;
7
	int offset;
8
	int length;
9
10
	public LinkDescriptor(String line, String fileName, int lineNumber,
11
			int offset, int length) {
12
		super();
13
		this.line = line;
14
		this.fileName = fileName;
15
		this.lineNumber = lineNumber;
16
		this.offset = offset;
17
		this.length = length;
18
	}
19
20
	public String getLine() {
21
		return line;
22
	}
23
24
	public void setLine(String line) {
25
		this.line = line;
26
	}
27
28
	public String getFileName() {
29
		return fileName;
30
	}
31
32
	public void setFileName(String fileName) {
33
		this.fileName = fileName;
34
	}
35
36
	public int getLineNumber() {
37
		return lineNumber;
38
	}
39
40
	public void setLineNumber(int lineNumber) {
41
		this.lineNumber = lineNumber;
42
	}
43
44
	public int getOffset() {
45
		return offset;
46
	}
47
48
	public void setOffset(int offset) {
49
		this.offset = offset;
50
	}
51
52
	public int getLength() {
53
		return length;
54
	}
55
56
	public void setLength(int length) {
57
		this.length = length;
58
	}
59
60
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntHomeClasspathEntry.java (+209 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 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.ant.internal.launching.launchConfigurations;
12
13
import java.io.File;
14
import com.ibm.icu.text.MessageFormat;
15
import java.util.ArrayList;
16
import java.util.List;
17
18
import org.eclipse.ant.core.AntCorePlugin;
19
import org.eclipse.ant.core.AntCorePreferences;
20
import org.eclipse.ant.core.IAntClasspathEntry;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IPath;
23
import org.eclipse.core.runtime.Path;
24
import org.eclipse.debug.core.ILaunchConfiguration;
25
import org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry;
26
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
27
import org.eclipse.jdt.launching.JavaRuntime;
28
import org.w3c.dom.Document;
29
import org.w3c.dom.Element;
30
31
/**
32
 * A classpath entry that contains a set of archives for a particular
33
 * ANT_HOME.
34
 * 
35
 * @since 3.0 
36
 */
37
public class AntHomeClasspathEntry extends AbstractRuntimeClasspathEntry {
38
	
39
	public static final String TYPE_ID = "org.eclipse.ant.ui.classpathentry.antHome"; //$NON-NLS-1$
40
	
41
	/**
42
	 * Local path on disk where Ant Home is located or <code>null</code>
43
	 * to indicate the use of the default Ant Home.
44
	 */
45
	private String antHomeLocation = null;
46
	
47
	/**
48
	 * Creates an AntHome entry for the default AntHome installation.
49
	 */
50
	public AntHomeClasspathEntry() {
51
		antHomeLocation = null;
52
	}
53
	
54
	/**
55
	 * Constructs an AntHome entry for the Ant installed at the specified
56
	 * root directory.
57
	 * 
58
	 * @param antHome path in the local file system to an Ant installation
59
	 */
60
	public AntHomeClasspathEntry(String antHome) {
61
		antHomeLocation = antHome;
62
	}
63
		
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element)
66
	 */
67
	protected void buildMemento(Document document, Element memento) throws CoreException {
68
		if (antHomeLocation == null) {
69
			memento.setAttribute("default", "true");  //$NON-NLS-1$//$NON-NLS-2$
70
		} else {
71
			memento.setAttribute("antHome", new Path(antHomeLocation).toString()); //$NON-NLS-1$
72
		}
73
	}
74
	/* (non-Javadoc)
75
	 * @see org.eclipse.jdt.internal.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element)
76
	 */
77
	public void initializeFrom(Element memento) throws CoreException {
78
		String antHome = memento.getAttribute("antHome"); //$NON-NLS-1$
79
		if (antHome != null && (antHome.length() > 0)) {
80
			IPath path = new Path(antHome);
81
			antHomeLocation = path.toOSString();
82
		} else {
83
			antHomeLocation = null;
84
		}
85
	}
86
	/* (non-Javadoc)
87
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId()
88
	 */
89
	public String getTypeId() {
90
		return TYPE_ID;
91
	}
92
	/* (non-Javadoc)
93
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration)
94
	 */
95
	public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException {
96
		List libs = new ArrayList(40);
97
		AntCorePreferences preferences = AntCorePlugin.getPlugin().getPreferences();
98
		if (antHomeLocation == null) {
99
			IAntClasspathEntry[] entries = preferences.getAntHomeClasspathEntries();
100
			for (int i = 0; i < entries.length; i++) {
101
				IAntClasspathEntry entry = entries[i];
102
				libs.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel()));
103
			}
104
		} else {
105
			File lib= resolveAntHome();
106
			IPath libDir = new Path(antHomeLocation).append("lib"); //$NON-NLS-1$
107
			String[] fileNames = lib.list();
108
			for (int i = 0; i < fileNames.length; i++) {
109
				String name = fileNames[i];
110
				IPath path = new Path(name);
111
				String fileExtension = path.getFileExtension();
112
				if ("jar".equalsIgnoreCase(fileExtension)) { //$NON-NLS-1$
113
					libs.add(JavaRuntime.newArchiveRuntimeClasspathEntry(libDir.append(path)));
114
				}
115
			}
116
		}
117
		return (IRuntimeClasspathEntry[]) libs.toArray(new IRuntimeClasspathEntry[libs.size()]);
118
	}
119
	
120
	public File resolveAntHome() throws CoreException {
121
		if (antHomeLocation == null) { //using the default ant home
122
			return null;
123
		}
124
		IPath libDir= new Path(antHomeLocation).append("lib"); //$NON-NLS-1$
125
		File lib= libDir.toFile();
126
		File parentDir= lib.getParentFile();
127
		if (parentDir == null || !parentDir.exists()) {
128
			abort(MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_10, new String[] {antHomeLocation}), null);
129
		}
130
		if (!lib.exists() || !lib.isDirectory()) {
131
			abort(MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_11, new String[] {antHomeLocation}), null);
132
		}
133
		return lib;
134
	}
135
	
136
	/* (non-Javadoc)
137
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName()
138
	 */
139
	public String getName() {
140
		if (antHomeLocation == null) {
141
			return AntLaunchConfigurationMessages.AntHomeClasspathEntry_8;
142
		}
143
		return MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_9, new String[]{antHomeLocation});
144
	}
145
	
146
	/* (non-Javadoc)
147
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType()
148
	 */
149
	public int getType() {
150
		return IRuntimeClasspathEntry.OTHER;
151
	}
152
	
153
	/* (non-Javadoc)
154
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#isComposite()
155
	 */
156
	public boolean isComposite() {
157
		return true;
158
	}
159
	
160
	/* (non-Javadoc)
161
	 * @see java.lang.Object#equals(java.lang.Object)
162
	 */
163
	public boolean equals(Object obj) {
164
		return obj instanceof AntHomeClasspathEntry &&
165
		  equalsOrNull(antHomeLocation, ((AntHomeClasspathEntry)obj).antHomeLocation);
166
	}
167
	
168
	/**
169
	 * Return whether s1 is equivalent to s2.
170
	 * 
171
	 * @param s1
172
	 * @param s2
173
	 * @return whether s1 is equivalent to s2
174
	 */
175
	private boolean equalsOrNull(String s1, String s2) {
176
		if (s1 == null || s2 == null) {
177
			return s1 == s2;
178
		} 
179
		return s1.equalsIgnoreCase(s2);
180
	}
181
182
	/* (non-Javadoc)
183
	 * @see java.lang.Object#hashCode()
184
	 */
185
	public int hashCode() {
186
		return getClass().hashCode();
187
	}	
188
	
189
	/**
190
	 * Sets the ant home to use.
191
	 * 
192
	 * @param path path to toor of an ant home installation
193
	 */
194
	public void setAntHome(String path) {
195
		antHomeLocation = path;
196
	}
197
	
198
	/**
199
	 * Returns the ant home location
200
	 * 
201
	 * @return path to root ant installation directory
202
	 */
203
	public String getAntHome() {
204
		if (antHomeLocation == null) {
205
			return AntCorePlugin.getPlugin().getPreferences().getAntHome();
206
		}
207
		return antHomeLocation;
208
	}
209
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchConfigurationMessages.properties (+26 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2000, 2007 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
#     dakshinamurthy.karra@gmail.com - bug 165371
11
###############################################################################
12
13
AntLaunchDelegate_Launching__0__1=Launching {0}
14
AntLaunchDelegate_Running__0__2=Running {0}
15
AntLaunchDelegate_Build_In_Progress=Ant build {0} already in progress. Concurrent Ant builds are possible if you specify to build in a separate JRE.
16
AntLaunchDelegate_Failure=Failure of Background Ant Build
17
AntLaunchDelegate_22=&Do not show error dialog when Ant build fails
18
AntLaunchDelegate_23=Ant Build Failed
19
AntLaunchDelegate_28=Waiting for virtual machine to exit...
20
21
AntHomeClasspathEntry_8=Ant Home (Default)
22
AntHomeClasspathEntry_9=Ant Home ({0})
23
AntHomeClasspathEntry_10=Ant Home {0} does not exist
24
AntHomeClasspathEntry_11=Ant Home {0} does not contain a "lib" directory
25
26
ContributedClasspathEntriesEntry_1=Additional Tasks & Support
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntCoreModelMessages.java (+25 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: 
8
 * IBM - Initial API and implementation
9
 **********************************************************************/
10
package org.eclipse.ant.internal.launching.launchConfigurations;
11
12
import org.eclipse.osgi.util.NLS;
13
14
public class AntCoreModelMessages extends NLS {
15
	private static final String BUNDLE_NAME = "org.eclipse.ant.internal.launching.launchConfigurations.AntCoreModelMessages";//$NON-NLS-1$
16
	
17
	public static String AntUtil_6;
18
	public static String AntUtil_7;
19
	public static String AntUtil_2;
20
21
	static {
22
		// load message values from bundle file
23
		NLS.initializeMessages(BUNDLE_NAME, AntCoreModelMessages.class);
24
	}
25
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java (+410 lines)
Added Link Here
1
/*******************************************************************************
2
 *  Copyright (c) 2003, 2008 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
12
package org.eclipse.ant.internal.launching.launchConfigurations;
13
14
import java.io.BufferedReader;
15
import java.io.File;
16
import java.io.IOException;
17
import java.io.InputStreamReader;
18
import java.net.ServerSocket;
19
import java.net.Socket;
20
import java.net.SocketException;
21
import java.net.SocketTimeoutException;
22
import java.util.ArrayList;
23
import java.util.HashMap;
24
import java.util.Iterator;
25
import java.util.List;
26
import java.util.Map;
27
import java.util.StringTokenizer;
28
29
import org.apache.tools.ant.Project;
30
import org.apache.tools.ant.util.FileUtils;
31
import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger;
32
import org.eclipse.ant.internal.launching.AntLaunch;
33
import org.eclipse.ant.internal.launching.AntLaunching;
34
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
35
import org.eclipse.ant.internal.launching.IAntLaunchingPreferenceConstants;
36
37
import org.eclipse.core.resources.IFile;
38
import org.eclipse.core.runtime.ISafeRunnable;
39
import org.eclipse.core.runtime.Platform;
40
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
41
import org.eclipse.debug.core.DebugPlugin;
42
import org.eclipse.debug.core.ILaunch;
43
import org.eclipse.debug.core.ILaunchesListener;
44
import org.eclipse.debug.core.model.IProcess;
45
import org.eclipse.jface.preference.IPreferenceStore;
46
import org.eclipse.jface.text.Region;
47
48
49
/**
50
 * Parts adapted from org.eclipse.jdt.internal.junit.ui.RemoteTestRunnerClient
51
 * The client side of the RemoteAntBuildLogger. Handles the marshalling of the
52
 * different messages.
53
 */
54
public class RemoteAntBuildListener implements ILaunchesListener {
55
	public abstract class ListenerSafeRunnable implements ISafeRunnable {
56
		public void handleException(Throwable exception) {
57
			AntLaunching.log(exception);
58
		}
59
	}
60
61
	/**
62
	 * The server socket
63
	 */
64
	private ServerSocket fServerSocket;
65
	private Socket fSocket;
66
	private BufferedReader fBufferedReader;
67
	private IProcess fProcess;
68
	private String fProcessId;
69
	private File fBuildFileParent = null;
70
	private List fMessageQueue;
71
	protected ILaunch fLaunch;
72
	private Map fFileNameToIFile = new HashMap();
73
	private String fLastFileName = null;
74
	private String fLastTaskName = null;
75
	private boolean fBuildFailed = false;
76
77
	/**
78
	 * Reads the message stream from the RemoteAntBuildLogger
79
	 */
80
	private class ServerConnection extends Thread {
81
		private int fServerPort;
82
83
		public ServerConnection(int port) {
84
			super("Ant Build Server Connection"); //$NON-NLS-1$
85
			setDaemon(true);
86
			fServerPort = port;
87
		}
88
89
		public void run() {
90
			Exception exception = null;
91
			try {
92
				fServerSocket = new ServerSocket(fServerPort);
93
94
				int socketTimeout = Platform
95
						.getPreferencesService()
96
						.getInt(
97
								AntLaunching.getUniqueIdentifier(),
98
								IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT,
99
								20000, null);
100
				fServerSocket.setSoTimeout(socketTimeout);
101
				fSocket = fServerSocket.accept();
102
				fBufferedReader = new BufferedReader(new InputStreamReader(
103
						fSocket.getInputStream(), "UTF-8")); //$NON-NLS-1$
104
				String message;
105
				while (fBufferedReader != null
106
						&& (message = fBufferedReader.readLine()) != null) {
107
					receiveMessage(message);
108
				}
109
			} catch (SocketException e) {
110
			} catch (SocketTimeoutException e) {
111
				exception = e;
112
			} catch (IOException e) {
113
				// fall through
114
				exception = e;
115
			}
116
			if (exception != null) {
117
				AntLaunching.log(exception);
118
			}
119
			shutDown();
120
		}
121
	}
122
123
	public RemoteAntBuildListener(ILaunch launch) {
124
		super();
125
		fLaunch = launch;
126
		DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
127
	}
128
129
	/**
130
	 * Start listening to an Ant build. Start a server connection that the
131
	 * RemoteAntBuildLogger can connect to.
132
	 * 
133
	 * @param eventPort
134
	 *            The port number to create the server connection on
135
	 */
136
	public synchronized void startListening(int eventPort) {
137
		ServerConnection connection = new ServerConnection(eventPort);
138
		connection.start();
139
	}
140
141
	protected synchronized void shutDown() {
142
		fLaunch = null;
143
		fFileNameToIFile = null;
144
		if (DebugPlugin.getDefault() != null) {
145
			DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(
146
					this);
147
		}
148
		try {
149
			if (fBufferedReader != null) {
150
				fBufferedReader.close();
151
				fBufferedReader = null;
152
			}
153
		} catch (IOException e) {
154
		}
155
		try {
156
			if (fSocket != null) {
157
				fSocket.close();
158
				fSocket = null;
159
			}
160
		} catch (IOException e) {
161
		}
162
		try {
163
			if (fServerSocket != null) {
164
				fServerSocket.close();
165
				fServerSocket = null;
166
			}
167
		} catch (IOException e) {
168
		}
169
	}
170
171
	protected void receiveMessage(String message) {
172
		if (message.startsWith(MessageIds.TASK)) {
173
			receiveTaskMessage(message);
174
		} else if (message.startsWith(MessageIds.TARGET)) {
175
			receiveTargetMessage(message);
176
		} else if (message.startsWith(MessageIds.PROCESS_ID)) {
177
			message = message.substring(MessageIds.PROCESS_ID.length());
178
			fProcessId = message;
179
		} else {
180
			int index = message.indexOf(',');
181
			if (index > 0) {
182
				int priority = Integer.parseInt(message.substring(0, index));
183
				message = message.substring(index + 1);
184
				writeMessage(
185
						message + System.getProperty("line.separator"), priority); //$NON-NLS-1$
186
				if (message.startsWith("BUILD FAILED")) { //$NON-NLS-1$
187
					fBuildFailed = true;
188
				} else if (fBuildFailed) {
189
					if (message.startsWith("Total time:")) { //$NON-NLS-1$
190
						fBuildFailed = false;
191
					} else {
192
						AntLaunchingUtil.linkBuildFailedMessage(message, getProcess());
193
					}
194
				}
195
				
196
			}
197
		}
198
	}
199
200
	private void receiveTargetMessage(String message) {
201
		message = message.substring(MessageIds.TARGET.length());
202
		StringTokenizer tokenizer = new StringTokenizer(message, ","); //$NON-NLS-1$
203
		message = tokenizer.nextToken();
204
		if (tokenizer.hasMoreTokens()) {
205
			int locationLength = Integer.parseInt(tokenizer.nextToken());
206
			String location = tokenizer.nextToken();
207
			while (location.length() < locationLength) { // path with a comma in
208
															// it
209
				location += ","; //$NON-NLS-1$
210
				location += tokenizer.nextToken();
211
			}
212
			int lineNumber = Integer.parseInt(tokenizer.nextToken());
213
			generateLink(message, location, lineNumber, 0, message.length() - 1);
214
		}
215
		writeMessage(
216
				message + System.getProperty("line.separator"), Project.MSG_INFO); //$NON-NLS-1$
217
	}
218
219
	private void receiveTaskMessage(String message) {
220
		message = message.substring(MessageIds.TASK.length());
221
222
		int index = message.indexOf(',');
223
		int priority = Integer.parseInt(message.substring(0, index));
224
		int index2 = message.indexOf(',', index + 1);
225
		String taskName = message.substring(index + 1, index2);
226
		if (taskName.length() == 0) {
227
			taskName = fLastTaskName;
228
		}
229
		int index3 = message.indexOf(',', index2 + 1);
230
		int lineLength = Integer
231
				.parseInt(message.substring(index2 + 1, index3));
232
		int index4 = index3 + 1 + lineLength;
233
234
		String line = message.substring(index3 + 1, index4);
235
		StringBuffer labelBuff = new StringBuffer();
236
		labelBuff.append('[');
237
		labelBuff.append(taskName);
238
		labelBuff.append("] "); //$NON-NLS-1$
239
		labelBuff.append(line);
240
		line = labelBuff.toString();
241
242
		fLastTaskName = taskName;
243
244
		int locationIndex = message.indexOf(',', index4 + 1);
245
		int finalIndex = locationIndex + 1;
246
		String fileName = message.substring(index4 + 1, locationIndex);
247
		int locationLength = 0;
248
		if (fileName.length() == 0) {
249
			fileName = fLastFileName;
250
		} else {
251
			finalIndex = message.indexOf(',', locationIndex) + 1;
252
			locationLength = Integer.parseInt(fileName);
253
			fileName = message.substring(finalIndex, finalIndex
254
					+ locationLength);
255
			locationLength += 1; // set past delimiter
256
		}
257
		fLastFileName = fileName;
258
		int lineNumber = Integer.parseInt(message.substring(finalIndex
259
				+ locationLength));
260
261
		int size = 10;//IAntUIConstants.LEFT_COLUMN_SIZE - (taskName.length() + 3);
262
		int offset = Math.max(size - 2, 1);
263
		int length = 100;//IAntUIConstants.LEFT_COLUMN_SIZE - size - 3;
264
		if (fileName != null) {
265
			generateLink(line, fileName, lineNumber, offset, length);
266
		}
267
268
		StringBuffer fullMessage = new StringBuffer();
269
		adornMessage(taskName, line, fullMessage);
270
		writeMessage(
271
				fullMessage
272
						.append(System.getProperty("line.separator")).toString(), priority); //$NON-NLS-1$
273
	}
274
275
	private void generateLink(String line, String fileName, int lineNumber,
276
			int offset, int length) {
277
		((AntLaunch)fLaunch).addLinkDescriptor(line, fileName, lineNumber, offset, length);
278
	}
279
280
	/**
281
	 * Returns the associated process, finding it if necessary.
282
	 */
283
	protected IProcess getProcess() {
284
		if (fProcess == null) {
285
			if (fProcessId != null) {
286
				IProcess[] all = DebugPlugin.getDefault().getLaunchManager()
287
						.getProcesses();
288
				for (int i = 0; i < all.length; i++) {
289
					IProcess process = all[i];
290
					if (fProcessId
291
							.equals(process
292
									.getAttribute(AbstractEclipseBuildLogger.ANT_PROCESS_ID))) {
293
						fProcess = process;
294
						break;
295
					}
296
				}
297
			}
298
		}
299
		return fProcess;
300
	}
301
302
	private AntStreamMonitor getMonitor(int priority) {
303
		IProcess process = getProcess();
304
		if (process == null) {
305
			return null;
306
		}
307
		AntStreamsProxy proxy = (AntStreamsProxy) process.getStreamsProxy();
308
		if (proxy == null) {
309
			return null;
310
		}
311
		AntStreamMonitor monitor = null;
312
		switch (priority) {
313
		case Project.MSG_INFO:
314
			monitor = (AntStreamMonitor) proxy.getOutputStreamMonitor();
315
			break;
316
		case Project.MSG_ERR:
317
			monitor = (AntStreamMonitor) proxy.getErrorStreamMonitor();
318
			break;
319
		case Project.MSG_DEBUG:
320
			monitor = (AntStreamMonitor) proxy.getDebugStreamMonitor();
321
			break;
322
		case Project.MSG_WARN:
323
			monitor = (AntStreamMonitor) proxy.getWarningStreamMonitor();
324
			break;
325
		case Project.MSG_VERBOSE:
326
			monitor = (AntStreamMonitor) proxy.getVerboseStreamMonitor();
327
			break;
328
		}
329
		return monitor;
330
	}
331
332
	/**
333
	 * Builds a right justified task prefix for the given build event, placing
334
	 * it in the given string buffer.
335
	 * 
336
	 * @param event
337
	 *            build event
338
	 * @param fullMessage
339
	 *            buffer to place task prefix in
340
	 */
341
	private void adornMessage(String taskName, String line,
342
			StringBuffer fullMessage) {
343
//		if (taskName == null) {
344
//			taskName = "null"; //$NON-NLS-1$
345
//		}
346
//
347
//		int size = IAntUIConstants.LEFT_COLUMN_SIZE - (taskName.length() + 6);
348
//		for (int i = 0; i < size; i++) {
349
//			fullMessage.append(' ');
350
//		}
351
//
352
//		fullMessage.append(line);
353
	}
354
355
	protected void writeMessage(String message, int priority) {
356
		AntStreamMonitor monitor = getMonitor(priority);
357
		if (monitor == null) {
358
			if (fMessageQueue == null) {
359
				fMessageQueue = new ArrayList();
360
			}
361
			fMessageQueue.add(message);
362
			return;
363
		}
364
		if (fMessageQueue != null) {
365
			for (Iterator iter = fMessageQueue.iterator(); iter.hasNext();) {
366
				String oldMessage = (String) iter.next();
367
				monitor.append(oldMessage);
368
			}
369
			fMessageQueue = null;
370
		}
371
		monitor.append(message);
372
	}
373
374
	/*
375
	 * (non-Javadoc)
376
	 * 
377
	 * @see
378
	 * org.eclipse.debug.core.ILaunchesListener#launchesAdded(org.eclipse.debug
379
	 * .core.ILaunch[])
380
	 */
381
	public void launchesAdded(ILaunch[] launches) {
382
	}
383
384
	/*
385
	 * (non-Javadoc)
386
	 * 
387
	 * @see
388
	 * org.eclipse.debug.core.ILaunchesListener#launchesChanged(org.eclipse.
389
	 * debug.core.ILaunch[])
390
	 */
391
	public void launchesChanged(ILaunch[] launches) {
392
	}
393
394
	/*
395
	 * (non-Javadoc)
396
	 * 
397
	 * @see
398
	 * org.eclipse.debug.core.ILaunchesListener#launchesRemoved(org.eclipse.
399
	 * debug.core.ILaunch[])
400
	 */
401
	public void launchesRemoved(ILaunch[] launches) {
402
		for (int i = 0; i < launches.length; i++) {
403
			ILaunch launch = launches[i];
404
			if (launch.equals(fLaunch)) {
405
				shutDown();
406
				return;
407
			}
408
		}
409
	}
410
}
(-)plugin.xml (+59 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
   <extension
5
         point="org.eclipse.debug.core.launchConfigurationTypes">
6
      <launchConfigurationType
7
            category="org.eclipse.ui.externaltools"
8
            delegate="org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate"
9
            delegateDescription="%AntLaunchDelegate.description"
10
            delegateName="%AntLaunchDelegate.name"
11
            id="org.eclipse.ant.AntLaunchConfigurationType"
12
            migrationDelegate="org.eclipse.ant.internal.launching.launchConfigurations.AntMigrationDelegate"
13
            modes="run, debug"
14
            name="%AntBuild"
15
            sourceLocatorId="org.eclipse.ant.ui.debug.sourceLookupDirector"
16
            sourcePathComputerId="org.eclipse.ant.ui.debug.sourcePathComputer">
17
      </launchConfigurationType>
18
      <launchConfigurationType
19
            category="org.eclipse.ui.externaltools.builder"
20
            delegate="org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate"
21
            delegateDescription="%AntBuilderLaunchDelegate.description"
22
            delegateName="%AntBuilderLaunchDelegate.name"
23
            id="org.eclipse.ant.AntBuilderLaunchConfigurationType"
24
            modes="run"
25
            name="%AntBuilder.name">
26
      </launchConfigurationType>
27
   </extension>
28
   <extension point="org.eclipse.core.runtime.preferences">
29
		<initializer class="org.eclipse.ant.internal.launching.AntLaunchingPreferenceInitializer"/>
30
	</extension>
31
  <extension
32
         point="org.eclipse.jdt.launching.runtimeClasspathEntries">
33
      <runtimeClasspathEntry
34
            class="org.eclipse.ant.internal.launching.launchConfigurations.AntHomeClasspathEntry"
35
            id="org.eclipse.antui.classpathentry.antHome">
36
      </runtimeClasspathEntry>
37
      <runtimeClasspathEntry
38
            class="org.eclipse.ant.internal.launching.launchConfigurations.ContributedClasspathEntriesEntry"
39
            id="org.eclipse.ant.ui.classpathentry.extraClasspathEntries">
40
      </runtimeClasspathEntry>
41
   </extension>
42
   <extension
43
         point="org.eclipse.jdt.launching.classpathProviders">
44
      <classpathProvider
45
            class="org.eclipse.ant.internal.launching.launchConfigurations.AntClasspathProvider"
46
            id="org.eclipse.ant.ui.AntClasspathProvider">
47
      </classpathProvider>
48
   </extension>
49
   <extension
50
         point="org.eclipse.debug.core.processFactories">
51
      <processFactory
52
            class="org.eclipse.ant.internal.launching.launchConfigurations.RemoteAntProcessFactory"
53
            id="org.eclipse.ant.ui.remoteAntProcessFactory">
54
      </processFactory>
55
   </extension>
56
   <extension point="org.eclipse.core.runtime.preferences">
57
		<initializer class="org.eclipse.ant.internal.launching.AntLaunchingPreferenceInitializer"/>
58
	</extension>
59
</plugin>
(-)src/org/eclipse/ant/internal/launching/debug/IAntDebugConstants.java (+33 lines)
Added Link Here
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 Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.launching.debug;
13
14
public interface IAntDebugConstants {
15
	
16
	/**
17
	 * Unique identifier for the Ant debug model (value 
18
	 * <code>org.eclipse.ant.ui.debug</code>).
19
	 */
20
	public static final String ID_ANT_DEBUG_MODEL = "org.eclipse.ant.ui.debug"; //$NON-NLS-1$
21
	
22
	/**
23
	 * Unique identifier for the Ant line breakpoint markers 
24
	 * (value <code>org.eclipse.ant.ui.antLineBreakpointMarker</code>).
25
	 */
26
	public static final String ID_ANT_LINE_BREAKPOINT_MARKER= "org.eclipse.ant.ui.antLineBreakpointMarker"; //$NON-NLS-1$
27
    
28
    /**
29
     * Unique identifier for the Ant run to line breakpoints 
30
     * (value <code>org.eclipse.ant.ui.runToLineBreakpoint</code>).
31
     */
32
    public static final String ANT_RUN_TO_LINE= "org.eclipse.ant.ui.runToLineBreakpoint"; //$NON-NLS-1$
33
}
(-)src/org/eclipse/ant/internal/launching/debug/model/DebugMessageIds.java (+48 lines)
Added Link Here
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 Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug.model;
12
13
public class DebugMessageIds {
14
	
15
	public final static String MESSAGE_DELIMITER= ","; //$NON-NLS-1$
16
	
17
	public final static String BUILD_STARTED=   "build_started"; //$NON-NLS-1$
18
	public final static String TARGET_STARTED= "target_started"; //$NON-NLS-1$
19
	public final static String TARGET_FINISHED= "target_finished"; //$NON-NLS-1$
20
	public final static String TASK_STARTED= "task_started"; //$NON-NLS-1$
21
	public final static String TASK_FINISHED= "task_finished"; //$NON-NLS-1$
22
	
23
	public final static String STEP= "step"; //$NON-NLS-1$
24
	public final static String STEP_OVER= "step_over"; //$NON-NLS-1$
25
	public final static String STEP_INTO= "step_into"; //$NON-NLS-1$
26
	
27
	public final static String TERMINATE= "terminate"; //$NON-NLS-1$
28
	public final static String TERMINATED= "terminated"; //$NON-NLS-1$
29
	
30
	public final static String SUSPEND= "suspend"; //$NON-NLS-1$
31
	public final static String SUSPENDED= "suspended"; //$NON-NLS-1$
32
	
33
	public final static String RESUME= "resume"; //$NON-NLS-1$
34
	
35
	public final static String STACK= "stack"; //$NON-NLS-1$
36
	
37
	public final static String ADD_BREAKPOINT= "add"; //$NON-NLS-1$
38
	public final static String REMOVE_BREAKPOINT= "remove"; //$NON-NLS-1$
39
	
40
	public final static String CLIENT_REQUEST= "client"; //$NON-NLS-1$
41
	public final static String BREAKPOINT= "breakpoint"; //$NON-NLS-1$
42
	
43
	public final static String PROPERTIES= "prop"; //$NON-NLS-1$
44
	public final static String PROPERTY_VALUE= "value"; //$NON-NLS-1$
45
	public final static int PROPERTY_USER= 0;
46
	public final static int PROPERTY_SYSTEM= 1;
47
	public final static int PROPERTY_RUNTIME= 2;
48
}
(-)src/org/eclipse/ant/internal/launching/debug/IAntDebugController.java (+66 lines)
Added Link Here
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 Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug;
12
13
import org.eclipse.debug.core.model.IBreakpoint;
14
15
public interface IAntDebugController {
16
	
17
    /**
18
     * Resume the Ant build
19
     */
20
	public void resume();
21
    
22
    /**
23
     * Suspend the Ant build
24
     */
25
	public void suspend();
26
    
27
     /**
28
     * Step into the current Ant task
29
     */
30
	public void stepInto();
31
    
32
     /**
33
     * Step over the current Ant task
34
     */
35
	public void stepOver();
36
    
37
    /**
38
     * The provided breakpoint has been added or removed depending on the <code>added</code> parameter.
39
     * Updates the controller for this change.
40
     * 
41
     * @param breakpoint the breakpoint that has been added or removed
42
     * @param added whether or not the breakpoint has been added 
43
     */
44
	public void handleBreakpoint(IBreakpoint breakpoint, boolean added);
45
    
46
     /**
47
     * Retrieve the properties of the Ant build.
48
     * May occur asynchronously depending on implementation.
49
     */
50
	public void getProperties();
51
    
52
    /**
53
     * Retrieve the stack frames of the Ant build.
54
     * May occur asynchronously depending on implementation.
55
     */
56
	public void getStackFrames();
57
58
	/**
59
	 * Some strings are escaped when marshalled for socket communication.
60
	 * The Ant debug controller will properly unescape these Strings if required.
61
	 * 
62
	 * @param value The buffer of the string to unescape
63
	 * @return The unescaped string
64
	 */
65
	public StringBuffer unescapeString(StringBuffer value);
66
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntProcess.java (+192 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 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.ant.internal.launching.launchConfigurations;
12
13
14
import java.util.HashMap;
15
import java.util.Map;
16
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.PlatformObject;
19
import org.eclipse.debug.core.DebugEvent;
20
import org.eclipse.debug.core.DebugPlugin;
21
import org.eclipse.debug.core.ILaunch;
22
import org.eclipse.debug.core.model.IProcess;
23
import org.eclipse.debug.core.model.IStreamsProxy;
24
25
public class AntProcess extends PlatformObject implements IProcess, IProgressMonitor {
26
	
27
	private AntStreamsProxy fProxy;
28
	private String fLabel = null;
29
	private ILaunch fLaunch = null;
30
	private Map fAttributes = null;
31
	private boolean fTerminated = false;
32
	private boolean fCancelled = false;
33
//	private IConsole fConsole = null;
34
	
35
	public AntProcess(String label, ILaunch launch, Map attributes) {
36
		fLabel = label;
37
		fLaunch = launch;
38
		if (attributes == null) {
39
			fAttributes = new HashMap();
40
		} else {
41
			fAttributes = attributes;
42
		}
43
		String captureOutput= launch.getAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT);
44
		if(!("false".equals(captureOutput))) { //$NON-NLS-1$
45
			fProxy= new AntStreamsProxy();
46
		}
47
		launch.addProcess(this);
48
	}
49
50
	/**
51
	 * @see org.eclipse.debug.core.model.IProcess#getLabel()
52
	 */
53
	public String getLabel() {
54
		return fLabel;
55
	}
56
57
	/**
58
	 * @see org.eclipse.debug.core.model.IProcess#getLaunch()
59
	 */
60
	public ILaunch getLaunch() {
61
		return fLaunch;
62
	}
63
64
	/**
65
	 * @see org.eclipse.debug.core.model.IProcess#getStreamsProxy()
66
	 */
67
	public IStreamsProxy getStreamsProxy() {
68
		return fProxy;
69
	}
70
71
	/**
72
	 * @see org.eclipse.debug.core.model.IProcess#setAttribute(java.lang.String, java.lang.String)
73
	 */
74
	public void setAttribute(String key, String value) {
75
		fAttributes.put(key, value);
76
	}
77
78
	/**
79
	 * @see org.eclipse.debug.core.model.IProcess#getAttribute(java.lang.String)
80
	 */
81
	public String getAttribute(String key) {
82
		return (String)fAttributes.get(key);
83
	}
84
85
	/**
86
	 * @see org.eclipse.debug.core.model.IProcess#getExitValue()
87
	 */
88
	public int getExitValue() {
89
		return 0;
90
	}
91
92
	/**
93
	 * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
94
	 */
95
	public boolean canTerminate() {
96
		return !isCanceled() && !isTerminated();
97
	}
98
99
	/**
100
	 * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
101
	 */
102
	public boolean isTerminated() {
103
		return fTerminated;
104
	}
105
	
106
	protected void terminated() {
107
		if (!fTerminated) {
108
			fTerminated = true;
109
			if (DebugPlugin.getDefault() != null) {
110
				DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {new DebugEvent(this, DebugEvent.TERMINATE)});
111
			}
112
		}
113
	}
114
115
	/**
116
	 * @see org.eclipse.debug.core.model.ITerminate#terminate()
117
	 */
118
	public void terminate() {
119
		setCanceled(true);
120
	}
121
122
//	/**
123
//	 * Returns the console associated with this process, or <code>null</code> if
124
//	 * none.
125
//	 * 
126
//	 * @return console, or <code>null</code>
127
//	 */
128
//	public IConsole getConsole() {
129
//		return fConsole;
130
//	}
131
//	
132
//	/**
133
//	 * Sets the console associated with this process.
134
//	 * 
135
//	 * @param console
136
//	 */
137
//	public void setConsole(IConsole console) {
138
//		fConsole = console;
139
//	}
140
	
141
	// IProgressMonitor implemented to support termination.
142
	
143
	/**
144
	 * @see org.eclipse.core.runtime.IProgressMonitor#beginTask(java.lang.String, int)
145
	 */
146
	public void beginTask(String name, int totalWork) {
147
	}
148
149
	/**
150
	 * @see org.eclipse.core.runtime.IProgressMonitor#done()
151
	 */
152
	public void done() {
153
	}
154
155
	/**
156
	 * @see org.eclipse.core.runtime.IProgressMonitor#internalWorked(double)
157
	 */
158
	public void internalWorked(double work) {
159
	}
160
161
	/**
162
	 * @see org.eclipse.core.runtime.IProgressMonitor#isCanceled()
163
	 */
164
	public boolean isCanceled() {
165
		return fCancelled;
166
	}
167
168
	/**
169
	 * @see org.eclipse.core.runtime.IProgressMonitor#setCanceled(boolean)
170
	 */
171
	public void setCanceled(boolean value) {
172
		fCancelled = value;
173
	}
174
175
	/**
176
	 * @see org.eclipse.core.runtime.IProgressMonitor#setTaskName(java.lang.String)
177
	 */
178
	public void setTaskName(String name) {
179
	}
180
181
	/**
182
	 * @see org.eclipse.core.runtime.IProgressMonitor#subTask(java.lang.String)
183
	 */
184
	public void subTask(String name) {
185
	}
186
187
	/**
188
	 * @see org.eclipse.core.runtime.IProgressMonitor#worked(int)
189
	 */
190
	public void worked(int work) {
191
	}
192
}
(-)src/org/eclipse/ant/internal/launching/debug/model/DebugModelMessages.java (+39 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: 
8
 * IBM - Initial API and implementation
9
 **********************************************************************/
10
package org.eclipse.ant.internal.launching.debug.model;
11
12
import org.eclipse.osgi.util.NLS;
13
14
public class DebugModelMessages extends NLS {
15
	private static final String BUNDLE_NAME = "org.eclipse.ant.internal.ui.debug.model.DebugModelMessages";//$NON-NLS-1$
16
17
	public static String AntDebugTarget_0;
18
19
	public static String AntDebugModelPresentation_0;
20
	public static String AntDebugModelPresentation_1;
21
	public static String AntDebugModelPresentation_2;
22
	public static String AntDebugModelPresentation_3;
23
	public static String AntDebugModelPresentation_4;
24
	public static String AntDebugModelPresentation_5;
25
26
	public static String AntLineBreakpoint_0;
27
	public static String AntThread_0;
28
	public static String AntThread_1;
29
	public static String AntThread_2;
30
    public static String AntThread_3;
31
    public static String AntThread_4;
32
    
33
    public static String AntProperties_1;
34
    
35
	static {
36
		// load message values from bundle file
37
		NLS.initializeMessages(BUNDLE_NAME, DebugModelMessages.class);
38
	}
39
}
(-)src/org/eclipse/ant/internal/launching/AntLaunchingUtil.java (+515 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 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.ant.internal.launching;
12
13
import java.io.File;
14
import java.io.IOException;
15
import java.net.MalformedURLException;
16
import java.net.URL;
17
import java.util.ArrayList;
18
import java.util.List;
19
import java.util.Map;
20
import java.util.StringTokenizer;
21
22
import org.apache.tools.ant.BuildException;
23
import org.apache.tools.ant.util.FileUtils;
24
import org.eclipse.ant.internal.launching.launchConfigurations.AntCoreModelMessages;
25
import org.eclipse.ant.internal.launching.launchConfigurations.AntHomeClasspathEntry;
26
import org.eclipse.ant.internal.launching.launchConfigurations.IAntLaunchConfigurationConstants;
27
import org.eclipse.ant.internal.launching.launchConfigurations.RemoteAntRuntimeProcess;
28
import org.eclipse.core.internal.externaltools.model.ExternalToolBuilder;
29
import org.eclipse.core.internal.externaltools.model.IExternalToolConstants;
30
import org.eclipse.core.resources.IFile;
31
import org.eclipse.core.resources.IWorkspaceRoot;
32
import org.eclipse.core.resources.ResourcesPlugin;
33
import org.eclipse.core.runtime.CoreException;
34
import org.eclipse.core.runtime.IPath;
35
import org.eclipse.core.runtime.IStatus;
36
import org.eclipse.core.runtime.Path;
37
import org.eclipse.core.runtime.Status;
38
import org.eclipse.core.variables.VariablesPlugin;
39
import org.eclipse.debug.core.ILaunch;
40
import org.eclipse.debug.core.ILaunchConfiguration;
41
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
42
import org.eclipse.debug.core.model.IProcess;
43
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
44
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
45
import org.eclipse.jdt.launching.IRuntimeClasspathEntry2;
46
import org.eclipse.jdt.launching.JavaRuntime;
47
48
import com.ibm.icu.text.MessageFormat;
49
50
/**
51
 * General utility class dealing with Ant build files
52
 */
53
public final class AntLaunchingUtil {
54
	public static final String ATTRIBUTE_SEPARATOR = ","; //$NON-NLS-1$;
55
	public static final char ANT_CLASSPATH_DELIMITER = '*';
56
	public static final String ANT_HOME_CLASSPATH_PLACEHOLDER = "G"; //$NON-NLS-1$
57
	public static final String ANT_GLOBAL_USER_CLASSPATH_PLACEHOLDER = "UG"; //$NON-NLS-1$
58
59
	/**
60
	 * No instances allowed
61
	 */
62
	private AntLaunchingUtil() {
63
		super();
64
	}
65
66
	/**
67
	 * Returns a single-string of the strings for storage.
68
	 * 
69
	 * @param strings
70
	 *            the array of strings
71
	 * @return a single-string representation of the strings or
72
	 *         <code>null</code> if the array is empty.
73
	 */
74
	public static String combineStrings(String[] strings) {
75
		if (strings.length == 0)
76
			return null;
77
78
		if (strings.length == 1)
79
			return strings[0];
80
81
		StringBuffer buf = new StringBuffer();
82
		for (int i = 0; i < strings.length - 1; i++) {
83
			buf.append(strings[i]);
84
			buf.append(ATTRIBUTE_SEPARATOR);
85
		}
86
		buf.append(strings[strings.length - 1]);
87
		return buf.toString();
88
	}
89
90
	/**
91
	 * Returns an array of targets to be run, or <code>null</code> if none are
92
	 * specified (indicating the default target or implicit target should be
93
	 * run).
94
	 * 
95
	 * @param configuration
96
	 *            launch configuration
97
	 * @return array of target names, or <code>null</code>
98
	 * @throws CoreException
99
	 *             if unable to access the associated attribute
100
	 */
101
	public static String[] getTargetNames(ILaunchConfiguration configuration)
102
			throws CoreException {
103
		String attribute = null;
104
		if (IAntLaunchConfigurationConstants.ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE
105
				.equals(configuration.getType().getIdentifier())) {
106
			attribute = getTargetNamesForAntBuilder(configuration);
107
		}
108
		if (attribute == null) {
109
			attribute = configuration.getAttribute(
110
					IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS,
111
					(String) null);
112
			if (attribute == null) {
113
				return null;
114
			}
115
		}
116
117
		return AntLaunchingUtil.parseRunTargets(attribute);
118
	}
119
120
	private static String getTargetNamesForAntBuilder(
121
			ILaunchConfiguration configuration) throws CoreException {
122
		String buildType = ExternalToolBuilder.getBuildType();
123
		String targets = null;
124
		if (IExternalToolConstants.BUILD_TYPE_AUTO.equals(buildType)) {
125
			targets = configuration.getAttribute(
126
					IAntLaunchConfigurationConstants.ATTR_ANT_AUTO_TARGETS,
127
					(String) null);
128
		} else if (IExternalToolConstants.BUILD_TYPE_CLEAN.equals(buildType)) {
129
			targets = configuration.getAttribute(
130
					IAntLaunchConfigurationConstants.ATTR_ANT_CLEAN_TARGETS,
131
					(String) null);
132
		} else if (IExternalToolConstants.BUILD_TYPE_FULL.equals(buildType)) {
133
			targets = configuration
134
					.getAttribute(
135
							IAntLaunchConfigurationConstants.ATTR_ANT_AFTER_CLEAN_TARGETS,
136
							(String) null);
137
		} else if (IExternalToolConstants.BUILD_TYPE_INCREMENTAL
138
				.equals(buildType)) {
139
			targets = configuration.getAttribute(
140
					IAntLaunchConfigurationConstants.ATTR_ANT_MANUAL_TARGETS,
141
					(String) null);
142
		}
143
144
		return targets;
145
	}
146
147
	/**
148
	 * Returns a map of properties to be defined for the build, or
149
	 * <code>null</code> if none are specified (indicating no additional
150
	 * properties specified for the build).
151
	 * 
152
	 * @param configuration
153
	 *            launch configuration
154
	 * @return map of properties (name --> value), or <code>null</code>
155
	 * @throws CoreException
156
	 *             if unable to access the associated attribute
157
	 */
158
	public static Map getProperties(ILaunchConfiguration configuration)
159
			throws CoreException {
160
		Map map = configuration.getAttribute(
161
				IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTIES,
162
				(Map) null);
163
		return map;
164
	}
165
166
	/**
167
	 * Returns a String specifying the Ant home to use for the build.
168
	 * 
169
	 * @param configuration
170
	 *            launch configuration
171
	 * @return String specifying Ant home to use or <code>null</code>
172
	 * @throws CoreException
173
	 *             if unable to access the associated attribute
174
	 */
175
	public static String getAntHome(ILaunchConfiguration configuration)
176
			throws CoreException {
177
		IRuntimeClasspathEntry[] entries = JavaRuntime
178
				.computeUnresolvedRuntimeClasspath(configuration);
179
		for (int i = 0; i < entries.length; i++) {
180
			IRuntimeClasspathEntry entry = entries[i];
181
			if (entry.getType() == IRuntimeClasspathEntry.OTHER) {
182
				IRuntimeClasspathEntry2 entry2 = (IRuntimeClasspathEntry2) entry;
183
				if (entry2.getTypeId().equals(AntHomeClasspathEntry.TYPE_ID)) {
184
					return ((AntHomeClasspathEntry) entry2).getAntHome();
185
				}
186
			}
187
		}
188
		return null;
189
	}
190
191
	/**
192
	 * Returns an array of property files to be used for the build, or
193
	 * <code>null</code> if none are specified (indicating no additional
194
	 * property files specified for the build).
195
	 * 
196
	 * @param configuration
197
	 *            launch configuration
198
	 * @return array of property file names, or <code>null</code>
199
	 * @throws CoreException
200
	 *             if unable to access the associated attribute
201
	 */
202
	public static String[] getPropertyFiles(ILaunchConfiguration configuration)
203
			throws CoreException {
204
		String attribute = configuration.getAttribute(
205
				IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTY_FILES,
206
				(String) null);
207
		if (attribute == null) {
208
			return null;
209
		}
210
		String[] propertyFiles = AntLaunchingUtil.parseString(attribute, ","); //$NON-NLS-1$
211
		for (int i = 0; i < propertyFiles.length; i++) {
212
			String propertyFile = propertyFiles[i];
213
			propertyFile = expandVariableString(propertyFile,
214
					AntCoreModelMessages.AntUtil_6);
215
			propertyFiles[i] = propertyFile;
216
		}
217
		return propertyFiles;
218
	}
219
220
	/**
221
	 * Returns the list of URLs that define the custom classpath for the Ant
222
	 * build, or <code>null</code> if the global classpath is to be used.
223
	 * 
224
	 * @param config
225
	 *            launch configuration
226
	 * @return a list of <code>URL</code>
227
	 * 
228
	 * @throws CoreException
229
	 *             if file does not exist, IO problems, or invalid format.
230
	 */
231
	public static URL[] getCustomClasspath(ILaunchConfiguration config)
232
			throws CoreException {
233
		boolean useDefault = config.getAttribute(
234
				IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
235
		if (useDefault) {
236
			return null;
237
		}
238
		IRuntimeClasspathEntry[] unresolved = JavaRuntime
239
				.computeUnresolvedRuntimeClasspath(config);
240
		// don't consider bootpath entries
241
		List userEntries = new ArrayList(unresolved.length);
242
		for (int i = 0; i < unresolved.length; i++) {
243
			IRuntimeClasspathEntry entry = unresolved[i];
244
			if (entry.getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES) {
245
				userEntries.add(entry);
246
			}
247
		}
248
		IRuntimeClasspathEntry[] entries = JavaRuntime
249
				.resolveRuntimeClasspath(
250
						(IRuntimeClasspathEntry[]) userEntries
251
								.toArray(new IRuntimeClasspathEntry[userEntries
252
										.size()]), config);
253
		URL[] urls = new URL[entries.length];
254
		for (int i = 0; i < entries.length; i++) {
255
			IRuntimeClasspathEntry entry = entries[i];
256
			try {
257
				urls[i] = new URL("file:" + entry.getLocation()); //$NON-NLS-1$
258
			} catch (MalformedURLException e) {
259
				throw new CoreException(new Status(IStatus.ERROR, AntLaunching
260
						.getUniqueIdentifier(), AntLaunching.INTERNAL_ERROR,
261
						AntCoreModelMessages.AntUtil_7, e));
262
			}
263
		}
264
		return urls;
265
	}
266
267
	private static String expandVariableString(String variableString,
268
			String invalidMessage) throws CoreException {
269
		String expandedString = VariablesPlugin.getDefault()
270
				.getStringVariableManager().performStringSubstitution(
271
						variableString);
272
		if (expandedString == null || expandedString.length() == 0) {
273
			String msg = MessageFormat.format(invalidMessage,
274
					new String[] { variableString });
275
			throw new CoreException(new Status(IStatus.ERROR,
276
					IAntLaunchConfigurationConstants.PLUGIN_ID, 0, msg, null));
277
		}
278
279
		return expandedString;
280
	}
281
282
	/**
283
	 * Returns the list of target names to run
284
	 * 
285
	 * @param extraAttibuteValue
286
	 *            the external tool's extra attribute value for the run targets
287
	 *            key.
288
	 * @return a list of target names
289
	 */
290
	public static String[] parseRunTargets(String extraAttibuteValue) {
291
		return parseString(extraAttibuteValue, ATTRIBUTE_SEPARATOR);
292
	}
293
294
	/**
295
	 * Returns the list of Strings that were delimiter separated.
296
	 * 
297
	 * @param delimString
298
	 *            the String to be tokenized based on the delimiter
299
	 * @return a list of Strings
300
	 */
301
	public static String[] parseString(String delimString, String delim) {
302
		if (delimString == null) {
303
			return new String[0];
304
		}
305
306
		// Need to handle case where separator character is
307
		// actually part of the target name!
308
		StringTokenizer tokenizer = new StringTokenizer(delimString, delim);
309
		String[] results = new String[tokenizer.countTokens()];
310
		for (int i = 0; i < results.length; i++) {
311
			results[i] = tokenizer.nextToken();
312
		}
313
314
		return results;
315
	}
316
317
	/**
318
	 * Returns an IFile with the given fully qualified path (relative to the
319
	 * workspace root). The returned IFile may or may not exist.
320
	 */
321
	public static IFile getFile(String fullPath) {
322
		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
323
		return root.getFile(new Path(fullPath));
324
	}
325
326
	/**
327
	 * Returns the workspace file associated with the given path in the local
328
	 * file system, or <code>null</code> if none. If the path happens to be a
329
	 * relative path, then the path is interpreted as relative to the specified
330
	 * parent file.
331
	 * 
332
	 * Attempts to handle linked files; the first found linked file with the
333
	 * correct path is returned.
334
	 * 
335
	 * @param path
336
	 * @param buildFileParent
337
	 * @return file or <code>null</code>
338
	 * @see org.eclipse.core.resources.IWorkspaceRoot#findFilesForLocation(IPath)
339
	 */
340
	public static IFile getFileForLocation(String path, File buildFileParent) {
341
		if (path == null) {
342
			return null;
343
		}
344
		IPath filePath = new Path(path);
345
		IFile file = null;
346
		IFile[] files = ResourcesPlugin.getWorkspace().getRoot()
347
				.findFilesForLocation(filePath);
348
		if (files.length > 0) {
349
			file = files[0];
350
		}
351
		if (file == null) {
352
			// relative path
353
			File relativeFile = null;
354
			try {
355
				// this call is ok if buildFileParent is null
356
				relativeFile = FileUtils.getFileUtils().resolveFile(
357
						buildFileParent, path);
358
				filePath = new Path(relativeFile.getAbsolutePath());
359
				files = ResourcesPlugin.getWorkspace().getRoot()
360
						.findFilesForLocation(filePath);
361
				if (files.length > 0) {
362
					file = files[0];
363
				} else {
364
					return null;
365
				}
366
			} catch (BuildException be) {
367
				return null;
368
			}
369
		}
370
371
		if (file.exists()) {
372
			return file;
373
		}
374
		File ioFile = file.getLocation().toFile();
375
		if (ioFile.exists()) {// needs to handle case insensitivity on WINOS
376
			try {
377
				files = ResourcesPlugin.getWorkspace().getRoot()
378
						.findFilesForLocation(
379
								new Path(ioFile.getCanonicalPath()));
380
				if (files.length > 0) {
381
					return files[0];
382
				}
383
			} catch (IOException e) {
384
			}
385
		}
386
387
		return null;
388
	}
389
390
	/**
391
	 * Migrates the classpath in the given configuration from the old format to
392
	 * the new format. The old format is not preserved. Instead, the default
393
	 * classpath will be used. However, ANT_HOME settings are preserved.
394
	 * 
395
	 * @param configuration
396
	 *            a configuration to migrate
397
	 * @throws CoreException
398
	 *             if unable to migrate
399
	 * @since 3.0
400
	 */
401
	public static void migrateToNewClasspathFormat(
402
			ILaunchConfiguration configuration) throws CoreException {
403
		String oldClasspath = configuration.getAttribute(
404
				IAntLaunchConfigurationConstants.ATTR_ANT_CUSTOM_CLASSPATH,
405
				(String) null);
406
		String oldAntHome = configuration.getAttribute(
407
				IAntLaunchConfigurationConstants.ATTR_ANT_HOME, (String) null);
408
		String provider = configuration.getAttribute(
409
				IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
410
				(String) null);
411
		if (oldClasspath != null || oldAntHome != null || provider == null) {
412
			ILaunchConfigurationWorkingCopy workingCopy = null;
413
			if (configuration.isWorkingCopy()) {
414
				workingCopy = (ILaunchConfigurationWorkingCopy) configuration;
415
			} else {
416
				workingCopy = configuration.getWorkingCopy();
417
			}
418
			workingCopy
419
					.setAttribute(
420
							org.eclipse.ant.internal.launching.launchConfigurations.IAntLaunchConfigurationConstants.ATTR_ANT_CUSTOM_CLASSPATH,
421
							(String) null);
422
			workingCopy
423
					.setAttribute(
424
							org.eclipse.ant.internal.launching.launchConfigurations.IAntLaunchConfigurationConstants.ATTR_ANT_HOME,
425
							(String) null);
426
			workingCopy.setAttribute(
427
					IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
428
					"org.eclipse.ant.ui.AntClasspathProvider"); //$NON-NLS-1$
429
			workingCopy.setAttribute(
430
					IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,
431
					true);
432
			if (oldAntHome != null) {
433
				IRuntimeClasspathEntry[] entries = JavaRuntime
434
						.computeUnresolvedRuntimeClasspath(workingCopy);
435
				List mementos = new ArrayList(entries.length);
436
				for (int i = 0; i < entries.length; i++) {
437
					IRuntimeClasspathEntry entry = entries[i];
438
					if (entry.getType() == IRuntimeClasspathEntry.OTHER) {
439
						IRuntimeClasspathEntry2 entry2 = (IRuntimeClasspathEntry2) entry;
440
						if (entry2.getTypeId().equals(
441
								AntHomeClasspathEntry.TYPE_ID)) {
442
							AntHomeClasspathEntry homeEntry = new AntHomeClasspathEntry(
443
									oldAntHome);
444
							mementos.add(homeEntry.getMemento());
445
							continue;
446
						}
447
					}
448
					mementos.add(entry.getMemento());
449
				}
450
				workingCopy
451
						.setAttribute(
452
								IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,
453
								false);
454
				workingCopy.setAttribute(
455
						IJavaLaunchConfigurationConstants.ATTR_CLASSPATH,
456
						mementos);
457
			}
458
			workingCopy.doSave();
459
		}
460
	}
461
462
	public static boolean isSeparateJREAntBuild(
463
			ILaunchConfiguration configuration) {
464
		boolean separateJRE = true;
465
		try {
466
			// always null for same JRE
467
			separateJRE = configuration.getAttribute(
468
					IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
469
					(String) null) != null;
470
		} catch (CoreException e) {
471
			AntLaunching.log(AntCoreModelMessages.AntUtil_2, e);
472
		}
473
474
		return separateJRE;
475
	}
476
477
	public static void linkBuildFailedMessage(String message, IProcess process) {
478
		String fileName = null;
479
		String lineNumber = ""; //$NON-NLS-1$
480
		int fileStart = 0;
481
		int index = message.indexOf("xml"); //$NON-NLS-1$
482
		if (index > 0) {
483
			int numberStart = index + 4;
484
			int numberEnd = message.indexOf(':', numberStart);
485
			int fileEnd = index + 3;
486
			if (numberStart > 0 && fileEnd > 0) {
487
				fileName = message.substring(fileStart, fileEnd).trim();
488
				if (numberEnd > 0) {
489
					lineNumber = message.substring(numberStart, numberEnd)
490
							.trim();
491
				}
492
			}
493
		}
494
495
		if (fileName != null) {
496
			int num = -1;
497
			try {
498
				num = Integer.parseInt(lineNumber);
499
			} catch (NumberFormatException e) {
500
			}
501
			IFile[] files = ResourcesPlugin.getWorkspace().getRoot()
502
					.findFilesForLocation(new Path(fileName));
503
			IFile file = null;
504
			if (files.length > 0) {
505
				file = files[0];
506
			}
507
			if (file != null && file.exists()) {
508
				ILaunch launch = ((RemoteAntRuntimeProcess) process)
509
						.getLaunch();
510
				((AntLaunch) launch).addLinkDescriptor(message, fileName, num,
511
						0, message.length());
512
			}
513
		}
514
	}
515
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntProcessFactory.java (+33 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 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
12
package org.eclipse.ant.internal.launching.launchConfigurations;
13
14
import java.util.HashMap;
15
import java.util.Map;
16
17
import org.eclipse.debug.core.ILaunch;
18
import org.eclipse.debug.core.IProcessFactory;
19
import org.eclipse.debug.core.model.IProcess;
20
21
public class RemoteAntProcessFactory implements IProcessFactory {
22
23
	/* (non-Javadoc)
24
	 * @see org.eclipse.debug.core.IProcessFactory#newProcess(org.eclipse.debug.core.ILaunch, java.lang.Process, java.lang.String, java.util.Map)
25
	 */
26
	public IProcess newProcess(ILaunch launch, Process process, String label, Map attributes) {
27
		if (attributes == null) {
28
			attributes= new HashMap(1);
29
		}
30
		attributes.put(IProcess.ATTR_PROCESS_TYPE, IAntLaunchConfigurationConstants.ID_ANT_PROCESS_TYPE);
31
		return new RemoteAntRuntimeProcess(launch, process, label, attributes);
32
	}
33
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/MessageIds.java (+21 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 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
12
package org.eclipse.ant.internal.launching.launchConfigurations;
13
14
public class MessageIds {
15
16
	public final static String PROCESS_ID=   "processID"; //$NON-NLS-1$
17
	public final static String BUILD_CANCELLED= "cancelled"; //$NON-NLS-1$
18
	//constants need to start greater than the Project.MSG_* constants
19
    public final static String TASK= "6"; //$NON-NLS-1$
20
    public final static String TARGET= "7"; //$NON-NLS-1$
21
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntRuntimeProcess.java (+37 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 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
12
package org.eclipse.ant.internal.launching.launchConfigurations;
13
14
import java.util.Map;
15
import org.eclipse.debug.core.ILaunch;
16
import org.eclipse.debug.core.model.IStreamsProxy;
17
import org.eclipse.debug.core.model.RuntimeProcess;
18
19
public class RemoteAntRuntimeProcess extends RuntimeProcess {
20
21
	/**
22
	 * Constructs a RuntimeProcess on the given system process
23
	 * with the given name, adding this process to the given
24
	 * launch.
25
	 * Sets the streams proxy to an AntStreamsProxy if output is captured.
26
	 */
27
	public RemoteAntRuntimeProcess(ILaunch launch, Process process, String name, Map attributes) {
28
		super(launch, process, name, attributes);
29
	}
30
	
31
	/* (non-Javadoc)
32
	 * @see org.eclipse.debug.core.model.RuntimeProcess#createStreamsProxy()
33
	 */
34
	protected IStreamsProxy createStreamsProxy() {
35
		return new AntStreamsProxy();
36
	}
37
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamsProxy.java (+64 lines)
Added Link Here
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.ant.internal.launching.launchConfigurations;
12
13
14
import org.eclipse.debug.core.model.IStreamMonitor;
15
import org.eclipse.debug.core.model.IStreamsProxy;
16
17
/**
18
 * 
19
 */
20
public class AntStreamsProxy implements IStreamsProxy {
21
	
22
	private AntStreamMonitor fErrorMonitor = new AntStreamMonitor();
23
	private AntStreamMonitor fOutputMonitor = new AntStreamMonitor();
24
	
25
	public static final String ANT_DEBUG_STREAM = IAntLaunchConfigurationConstants.PLUGIN_ID + ".ANT_DEBUG_STREAM"; //$NON-NLS-1$
26
	public static final String ANT_VERBOSE_STREAM = IAntLaunchConfigurationConstants.PLUGIN_ID + ".ANT_VERBOSE_STREAM"; //$NON-NLS-1$
27
	public static final String ANT_WARNING_STREAM = IAntLaunchConfigurationConstants.PLUGIN_ID + ".ANT_WARNING_STREAM"; //$NON-NLS-1$
28
	
29
	private AntStreamMonitor fDebugMonitor = new AntStreamMonitor();
30
	private AntStreamMonitor fVerboseMonitor = new AntStreamMonitor();
31
	private AntStreamMonitor fWarningMonitor = new AntStreamMonitor();
32
33
	/**
34
	 * @see org.eclipse.debug.core.model.IStreamsProxy#getErrorStreamMonitor()
35
	 */
36
	public IStreamMonitor getErrorStreamMonitor() {
37
		return fErrorMonitor;
38
	}
39
40
	/**
41
	 * @see org.eclipse.debug.core.model.IStreamsProxy#getOutputStreamMonitor()
42
	 */
43
	public IStreamMonitor getOutputStreamMonitor() {
44
		return fOutputMonitor;
45
	}
46
47
	/**
48
	 * @see org.eclipse.debug.core.model.IStreamsProxy#write(java.lang.String)
49
	 */
50
	public void write(String input) {
51
	}
52
53
	public IStreamMonitor getWarningStreamMonitor() {
54
		return fWarningMonitor;
55
	}
56
	
57
	public IStreamMonitor getDebugStreamMonitor() {
58
		return fDebugMonitor;
59
	}	
60
	
61
	public IStreamMonitor getVerboseStreamMonitor() {
62
		return fVerboseMonitor;
63
	}	
64
}
(-)src/org/eclipse/ant/internal/launching/debug/AntDebugMessages.properties (+12 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 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
12
AntSourceContainer_0=Ant Source Container
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamMonitor.java (+83 lines)
Added Link Here
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.ant.internal.launching.launchConfigurations;
12
13
import org.eclipse.core.runtime.ListenerList;
14
import org.eclipse.debug.core.IStreamListener;
15
import org.eclipse.debug.core.model.IFlushableStreamMonitor;
16
17
/**
18
 * Stream monitor implementation for an Ant build process.
19
 */
20
public class AntStreamMonitor implements IFlushableStreamMonitor {
21
22
	private StringBuffer fContents = new StringBuffer();
23
	private ListenerList fListeners = new ListenerList(1);
24
	private boolean fBuffered = true;
25
	
26
	/**
27
	 * @see org.eclipse.debug.core.model.IStreamMonitor#addListener(org.eclipse.debug.core.IStreamListener)
28
	 */
29
	public void addListener(IStreamListener listener) {
30
		fListeners.add(listener);
31
	}
32
33
	/**
34
	 * @see org.eclipse.debug.core.model.IStreamMonitor#getContents()
35
	 */
36
	public String getContents() {
37
		return fContents.toString();
38
	}
39
40
	/**
41
	 * @see org.eclipse.debug.core.model.IStreamMonitor#removeListener(org.eclipse.debug.core.IStreamListener)
42
	 */
43
	public void removeListener(IStreamListener listener) {
44
		fListeners.remove(listener);
45
	}
46
47
	/**
48
	 * Appends the given message to this stream, and notifies listeners.
49
	 * 
50
	 * @param message
51
	 */
52
	public void append(String message) {
53
		if (isBuffered()) {
54
			fContents.append(message);
55
		}
56
		Object[] listeners = fListeners.getListeners();
57
		for (int i = 0; i < listeners.length; i++) {
58
			IStreamListener listener = (IStreamListener)listeners[i];
59
			listener.streamAppended(message, this);
60
		}
61
	}
62
	/**
63
	 * @see org.eclipse.debug.core.model.IFlushableStreamMonitor#flushContents()
64
	 */
65
	public void flushContents() {
66
		fContents.setLength(0);
67
	}
68
69
	/**
70
	 * @see org.eclipse.debug.core.model.IFlushableStreamMonitor#isBuffered()
71
	 */
72
	public boolean isBuffered() {
73
		return fBuffered;
74
	}
75
76
	/**
77
	 * @see org.eclipse.debug.core.model.IFlushableStreamMonitor#setBuffered(boolean)
78
	 */
79
	public void setBuffered(boolean buffer) {
80
		fBuffered = buffer;
81
	}
82
}
83
(-)src/org/eclipse/ant/internal/launching/debug/model/AntThread.java (+479 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 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.ant.internal.launching.debug.model;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
16
import org.eclipse.debug.core.DebugEvent;
17
import org.eclipse.debug.core.DebugException;
18
import org.eclipse.debug.core.model.IBreakpoint;
19
import org.eclipse.debug.core.model.IStackFrame;
20
import org.eclipse.debug.core.model.IThread;
21
import org.eclipse.debug.core.model.IVariable;
22
23
/**
24
 * An Ant build thread.
25
 */
26
public class AntThread extends AntDebugElement implements IThread {
27
	
28
	/**
29
	 * Breakpoints this thread is suspended at or <code>null</code>
30
	 * if none.
31
	 */
32
	private IBreakpoint[] fBreakpoints;
33
	
34
	/**
35
	 * The stackframes associated with this thread
36
	 */
37
	private List fFrames= new ArrayList(1);
38
	
39
	/**
40
	 * The stackframes to be reused on suspension
41
	 */
42
	private List fOldFrames;
43
	
44
	/**
45
	 * Whether this thread is stepping
46
	 */
47
	private boolean fStepping = false;
48
	
49
	private boolean fRefreshProperties= true;
50
	
51
	/**
52
	 * The user properties associated with this thread
53
	 */
54
	private AntProperties fUserProperties;
55
	
56
	/**
57
	 * The system properties associated with this thread
58
	 */
59
	private AntProperties fSystemProperties;
60
	
61
	/**
62
	 * The properties set during the build associated with this thread
63
	 */
64
	private AntProperties fRuntimeProperties;
65
    
66
    private Object fPropertiesLock= new Object();
67
	
68
	/**
69
	 * Constructs a new thread for the given target
70
	 * 
71
	 * @param target the Ant Build
72
	 */
73
	public AntThread(AntDebugTarget target) {
74
		super(target);
75
	}
76
	
77
	/* (non-Javadoc)
78
	 * @see org.eclipse.debug.core.model.IThread#getStackFrames()
79
	 */
80
	public synchronized IStackFrame[] getStackFrames() throws DebugException {
81
		if (isSuspended()) {
82
			if (fFrames.size() == 0) {
83
				getStackFrames0();
84
			}
85
		} 
86
		
87
		return (IStackFrame[]) fFrames.toArray(new IStackFrame[fFrames.size()]);
88
	}
89
	
90
	/**
91
	 * Retrieves the current stack frames in the thread
92
	 * possibly waiting until the frames are populated
93
     * 
94
	 */
95
	private void getStackFrames0() throws DebugException {
96
        synchronized (fFrames) {
97
    		getAntDebugTarget().getStackFrames();
98
            if (fFrames.size() > 0) {
99
                //frames set..no need to wait
100
                return;
101
            }
102
            int attempts= 0;
103
    		try {
104
                while (fFrames.size() == 0 && !isTerminated()) {
105
                    fFrames.wait(50);
106
                    if (attempts == 20 && fFrames.size() == 0 && !isTerminated()) {
107
                        throwDebugException(DebugModelMessages.AntThread_3);
108
                    }
109
                    attempts++;
110
                }
111
    		} catch (InterruptedException e) {
112
    		}
113
        }
114
	}
115
	
116
	/* (non-Javadoc)
117
	 * @see org.eclipse.debug.core.model.IThread#hasStackFrames()
118
	 */
119
	public boolean hasStackFrames() throws DebugException {
120
		return isSuspended();
121
	}
122
	
123
	/* (non-Javadoc)
124
	 * @see org.eclipse.debug.core.model.IThread#getPriority()
125
	 */
126
	public int getPriority() throws DebugException {
127
		return 0;
128
	}
129
	
130
	/* (non-Javadoc)
131
	 * @see org.eclipse.debug.core.model.IThread#getTopStackFrame()
132
	 */
133
	public synchronized IStackFrame getTopStackFrame() throws DebugException {
134
		if (isSuspended()) {
135
			if (fFrames.size() == 0) {
136
				getStackFrames0();
137
			}
138
			if (fFrames.size() > 0) {
139
				return (IStackFrame)fFrames.get(0);
140
			}
141
		} 
142
		return null;
143
	}
144
	
145
	/* (non-Javadoc)
146
	 * @see org.eclipse.debug.core.model.IThread#getName()
147
	 */
148
	public String getName() {
149
		return "Thread [Ant Build]"; //$NON-NLS-1$
150
	}
151
	
152
	/* (non-Javadoc)
153
	 * @see org.eclipse.debug.core.model.IThread#getBreakpoints()
154
	 */
155
	public IBreakpoint[] getBreakpoints() {
156
		if (fBreakpoints == null) {
157
			return new IBreakpoint[0];
158
		}
159
		return fBreakpoints;
160
	}
161
	
162
	/**
163
	 * Sets the breakpoints this thread is suspended at, or <code>null</code>
164
	 * if none.
165
	 * 
166
	 * @param breakpoints the breakpoints this thread is suspended at, or <code>null</code>
167
	 * if none
168
	 */
169
	protected void setBreakpoints(IBreakpoint[] breakpoints) {
170
		fBreakpoints = breakpoints;
171
	}
172
	
173
	/* (non-Javadoc)
174
	 * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
175
	 */
176
	public boolean canResume() {
177
		return isSuspended();
178
	}
179
	
180
	/* (non-Javadoc)
181
	 * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
182
	 */
183
	public boolean canSuspend() {
184
		return !isSuspended();
185
	}
186
	
187
	/* (non-Javadoc)
188
	 * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
189
	 */
190
	public boolean isSuspended() {
191
		return getDebugTarget().isSuspended();
192
	}
193
	
194
	/* (non-Javadoc)
195
	 * @see org.eclipse.debug.core.model.ISuspendResume#resume()
196
	 */
197
	public synchronized void resume() throws DebugException {
198
		aboutToResume(DebugEvent.CLIENT_REQUEST, false);
199
		getDebugTarget().resume();
200
	}
201
	
202
	/* (non-Javadoc)
203
	 * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
204
	 */
205
	public synchronized void suspend() throws DebugException {
206
		getDebugTarget().suspend();
207
	}
208
	
209
	/* (non-Javadoc)
210
	 * @see org.eclipse.debug.core.model.IStep#canStepInto()
211
	 */
212
	public boolean canStepInto() {
213
	    return isSuspended();
214
	}
215
	
216
	/* (non-Javadoc)
217
	 * @see org.eclipse.debug.core.model.IStep#canStepOver()
218
	 */
219
	public boolean canStepOver() {
220
		return isSuspended();
221
	}
222
	
223
	/* (non-Javadoc)
224
	 * @see org.eclipse.debug.core.model.IStep#canStepReturn()
225
	 */
226
	public boolean canStepReturn() {
227
		return false;
228
	}
229
	
230
	/* (non-Javadoc)
231
	 * @see org.eclipse.debug.core.model.IStep#isStepping()
232
	 */
233
	public boolean isStepping() {
234
		return fStepping;
235
	}
236
	
237
	/* (non-Javadoc)
238
	 * @see org.eclipse.debug.core.model.IStep#stepInto()
239
	 */
240
	public synchronized void stepInto() throws DebugException {
241
	    aboutToResume(DebugEvent.STEP_INTO, true);
242
		((AntDebugTarget)getDebugTarget()).stepInto();
243
	}
244
	
245
	private void aboutToResume(int detail, boolean stepping) {
246
	    fRefreshProperties= true;
247
	    fOldFrames= new ArrayList(fFrames);
248
        fFrames.clear();
249
        setPropertiesValid(false);
250
	    setStepping(stepping);
251
	    setBreakpoints(null);
252
		fireResumeEvent(detail);
253
    }
254
255
    private void setPropertiesValid(boolean valid) {
256
        if (fUserProperties != null) {
257
            fUserProperties.setValid(valid);
258
            fSystemProperties.setValid(valid);
259
            fRuntimeProperties.setValid(valid);
260
        }
261
    }
262
263
    /* (non-Javadoc)
264
	 * @see org.eclipse.debug.core.model.IStep#stepOver()
265
	 */
266
	public synchronized void stepOver() throws DebugException {
267
	    aboutToResume(DebugEvent.STEP_OVER, true);
268
		((AntDebugTarget)getDebugTarget()).stepOver();
269
	}
270
	
271
	/* (non-Javadoc)
272
	 * @see org.eclipse.debug.core.model.IStep#stepReturn()
273
	 */
274
	public synchronized void stepReturn() throws DebugException {
275
	}
276
	
277
	/* (non-Javadoc)
278
	 * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
279
	 */
280
	public boolean canTerminate() {
281
		return !isTerminated();
282
	}
283
	
284
	/* (non-Javadoc)
285
	 * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
286
	 */
287
	public boolean isTerminated() {
288
		return getDebugTarget().isTerminated();
289
	}
290
	
291
	/* (non-Javadoc)
292
	 * @see org.eclipse.debug.core.model.ITerminate#terminate()
293
	 */
294
	public void terminate() throws DebugException {
295
		fFrames.clear();
296
		getDebugTarget().terminate();
297
	}
298
	
299
	/**
300
	 * Sets whether this thread is stepping
301
	 * 
302
	 * @param stepping whether stepping
303
	 */
304
	protected void setStepping(boolean stepping) {
305
		fStepping = stepping;
306
	}
307
308
    public void buildStack(String data) { 
309
        synchronized (fFrames) {
310
            String[] strings= data.split(DebugMessageIds.MESSAGE_DELIMITER);
311
            //0 STACK message
312
            //1 targetName
313
            //2 taskName
314
            //3 filePath
315
            //4 lineNumber
316
            //5 ...
317
            if (fOldFrames != null && (strings.length - 1)/ 4 != fOldFrames.size()) {
318
                fOldFrames= null; //stack size changed..do not preserve
319
            }
320
            StringBuffer name;
321
            String filePath;
322
            int lineNumber;
323
            int stackFrameId= 0;
324
            String taskName;
325
            for (int i = 1; i < strings.length; i++) {
326
                if (strings[i].length() > 0) {
327
                    name= new StringBuffer(strings[i]);
328
                    taskName= strings[++i];
329
                    if (taskName.length() > 0) {
330
                        name.append(": "); //$NON-NLS-1$
331
                        name.append(taskName);
332
                    }
333
                } else {
334
                    name= new StringBuffer(strings[++i]);
335
                }
336
                filePath= strings[++i];
337
                lineNumber= Integer.parseInt(strings[++i]);
338
                addFrame(stackFrameId++, name.toString(), filePath, lineNumber);
339
            }
340
            //wake up the call from getStackFrames
341
            fFrames.notifyAll();
342
        }
343
    }
344
    
345
    private void addFrame(int stackFrameId, String name, String filePath, int lineNumber) {
346
    	AntStackFrame frame= getOldFrame();
347
    	
348
    	if (frame == null || !frame.getFilePath().equals(filePath)) {
349
    		frame= new AntStackFrame(this, stackFrameId, name, filePath, lineNumber);
350
    	} else {
351
    		frame.setFilePath(filePath);
352
    		frame.setId(stackFrameId);
353
    		frame.setLineNumber(lineNumber);
354
    		frame.setName(name);
355
    	}
356
		fFrames.add(frame);
357
    }
358
    
359
    private AntStackFrame getOldFrame() {
360
    	if (fOldFrames == null) {
361
    		return null;
362
    	}
363
    	AntStackFrame frame= (AntStackFrame) fOldFrames.remove(0);
364
    	if (fOldFrames.isEmpty()) {
365
    		fOldFrames= null;
366
    	}
367
    	return frame;
368
    }
369
    
370
    public void newProperties(String data) {
371
        synchronized (fPropertiesLock) {
372
            try {
373
                String[] datum= data.split(DebugMessageIds.MESSAGE_DELIMITER);
374
                if (fUserProperties == null) {
375
                    initializePropertyGroups();
376
                }
377
378
                List userProperties= ((AntPropertiesValue)fUserProperties.getLastValue()).getProperties();
379
                List systemProperties= ((AntPropertiesValue)fSystemProperties.getLastValue()).getProperties();
380
                List runtimeProperties= ((AntPropertiesValue)fRuntimeProperties.getLastValue()).getProperties();
381
                //0 PROPERTIES message
382
                //1 propertyName length
383
                //2 propertyName
384
                //3 propertyValue length
385
                //3 propertyValue
386
                //4 propertyType
387
                //5 ...
388
                if (datum.length > 1) { //new properties
389
                    StringBuffer propertyName;
390
                    StringBuffer propertyValue;
391
                    int propertyNameLength;
392
                    int propertyValueLength;
393
                    for (int i = 1; i < datum.length; i++) {
394
                        propertyNameLength= Integer.parseInt(datum[i]);
395
                        propertyName= new StringBuffer(datum[++i]);
396
                        while (propertyName.length() != propertyNameLength) {
397
                            propertyName.append(DebugMessageIds.MESSAGE_DELIMITER);
398
                            propertyName.append(datum[++i]);
399
                        }
400
401
                        propertyName= getAntDebugTarget().getAntDebugController().unescapeString(propertyName);
402
403
                        propertyValueLength= Integer.parseInt(datum[++i]);
404
                        if (propertyValueLength == 0 && i + 1 == datum.length) { //bug 81299
405
                            propertyValue= new StringBuffer(""); //$NON-NLS-1$
406
                        } else {
407
                            propertyValue= new StringBuffer(datum[++i]);
408
                        }
409
                        while (propertyValue.length() != propertyValueLength) {
410
                            propertyValue.append(DebugMessageIds.MESSAGE_DELIMITER);
411
                            propertyValue.append(datum[++i]);
412
                        }
413
414
                        propertyValue= getAntDebugTarget().getAntDebugController().unescapeString(propertyValue);
415
416
                        int propertyType= Integer.parseInt(datum[++i]);
417
                        addProperty(userProperties, systemProperties, runtimeProperties, propertyName.toString(), propertyValue.toString(), propertyType);
418
                    }
419
                }
420
            } finally {
421
                fRefreshProperties= false;
422
                setPropertiesValid(true);
423
                //wake up the call from getVariables
424
                fPropertiesLock.notifyAll();
425
            }
426
        }
427
	}
428
429
	private void addProperty(List userProperties, List systemProperties, List runtimeProperties, String propertyName, String propertyValue, int propertyType) {
430
		AntProperty property= new AntProperty((AntDebugTarget) getDebugTarget(), propertyName, propertyValue);
431
		switch (propertyType) {
432
			case DebugMessageIds.PROPERTY_SYSTEM:
433
				systemProperties.add(property);
434
				break;
435
			case DebugMessageIds.PROPERTY_USER:
436
				userProperties.add(property);
437
				break;
438
			case DebugMessageIds.PROPERTY_RUNTIME:
439
				runtimeProperties.add(property);
440
				break;
441
		}
442
	}
443
444
	private void initializePropertyGroups() {
445
        AntDebugTarget target= getAntDebugTarget();
446
		fUserProperties= new AntProperties(target, DebugModelMessages.AntThread_0);
447
		fUserProperties.setValue(new AntPropertiesValue(target));
448
		fSystemProperties= new AntProperties(target, DebugModelMessages.AntThread_1);
449
		fSystemProperties.setValue(new AntPropertiesValue(target));
450
		fRuntimeProperties= new AntProperties(target, DebugModelMessages.AntThread_2);
451
		fRuntimeProperties.setValue(new AntPropertiesValue(target));
452
	}
453
    
454
    protected IVariable[] getVariables() throws DebugException {
455
        synchronized (fPropertiesLock) {
456
            if (fRefreshProperties) {
457
                getAntDebugTarget().getProperties();
458
                if (fRefreshProperties) { 
459
                    //properties have not been set; need to wait
460
                    try {
461
                        int attempts= 0;
462
                        while (fRefreshProperties && !isTerminated()) {
463
                            fPropertiesLock.wait(50);
464
                            if (attempts == 20 && fRefreshProperties && !isTerminated()) {
465
                                throwDebugException(DebugModelMessages.AntThread_4);
466
                            }
467
                            attempts++;
468
                        }
469
                    } catch (InterruptedException ie) {
470
                    }
471
                }
472
            }
473
            if (fSystemProperties == null) {
474
                return new IVariable[0];
475
            }
476
            return new IVariable[]{fSystemProperties, fUserProperties, fRuntimeProperties};
477
        }
478
    }
479
}
(-)src/org/eclipse/ant/internal/launching/debug/AntSourcePathComputerDelegate.java (+33 lines)
Added Link Here
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 Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.IProgressMonitor;
15
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
17
import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate;
18
19
/**
20
 * Computes the default source lookup path for an Ant launch configuration.
21
 * The default source lookup is a container that knows how to map the 
22
 * fully qualified file system paths to either the <code>IFile</code> within the workspace or
23
 * a <code>LocalFileStorage</code> for buildfiles not in the workspace.
24
 */
25
public class AntSourcePathComputerDelegate implements ISourcePathComputerDelegate {
26
	
27
	/* (non-Javadoc)
28
	 * @see org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate#computeSourceContainers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor)
29
	 */
30
	public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
31
		return new ISourceContainer[] {new AntSourceContainer()};
32
	}
33
}
(-)src/org/eclipse/ant/internal/launching/AntLaunch.java (+37 lines)
Added Link Here
1
package org.eclipse.ant.internal.launching;
2
3
import java.util.ArrayList;
4
import java.util.List;
5
6
import org.eclipse.debug.core.ILaunchConfiguration;
7
import org.eclipse.debug.core.Launch;
8
import org.eclipse.debug.core.model.ISourceLocator;
9
10
public class AntLaunch extends Launch {
11
	List linkDescriptors;
12
13
	public AntLaunch(ILaunchConfiguration launchConfiguration, String mode,
14
			ISourceLocator locator) {
15
		super(launchConfiguration, mode, locator);
16
		linkDescriptors = new ArrayList();
17
		
18
	}
19
	
20
	public void addLinkDescriptor(String line, String fileName, int lineNumber,
21
			int offset, int length){
22
		linkDescriptors.add(new LinkDescriptor(line, fileName, lineNumber, offset, length));
23
	}
24
	
25
	public void removeLinkDescriptor(LinkDescriptor ld){
26
		linkDescriptors.remove(ld);
27
	}
28
	
29
	public List getLinkDescriptors(){
30
		return linkDescriptors;
31
	}
32
	
33
	public void clearLinkDescriptors(){
34
		linkDescriptors.clear();
35
	}
36
37
}
(-)src/org/eclipse/ant/internal/launching/debug/model/AntLineBreakpoint.java (+112 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 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.ant.internal.launching.debug.model;
12
13
import com.ibm.icu.text.MessageFormat;
14
import java.util.HashMap;
15
import java.util.Map;
16
17
import org.eclipse.ant.internal.launching.debug.IAntDebugConstants;
18
import org.eclipse.core.resources.IMarker;
19
import org.eclipse.core.resources.IResource;
20
import org.eclipse.core.resources.IWorkspaceRunnable;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IProgressMonitor;
23
import org.eclipse.debug.core.DebugException;
24
import org.eclipse.debug.core.DebugPlugin;
25
import org.eclipse.debug.core.model.IBreakpoint;
26
import org.eclipse.debug.core.model.LineBreakpoint;
27
28
/**
29
 * Ant line breakpoint
30
 */
31
public class AntLineBreakpoint extends LineBreakpoint {
32
	
33
	/**
34
	 * Default constructor is required for the breakpoint manager
35
	 * to re-create persisted breakpoints. After instantiating a breakpoint,
36
	 * the <code>setMarker(...)</code> method is called to restore
37
	 * this breakpoint's attributes.
38
	 */
39
	public AntLineBreakpoint() {
40
	}
41
	
42
	/**
43
	 * Constructs a line breakpoint on the given resource at the given
44
	 * line number. The line number is 1-based (i.e. the first line of a
45
	 * file is line number 1).
46
	 * 
47
	 * @param resource file on which to set the breakpoint
48
	 * @param lineNumber 1-based line number of the breakpoint
49
	 * @throws CoreException if unable to create the breakpoint
50
	 */
51
	public AntLineBreakpoint(IResource resource, int lineNumber) throws CoreException {
52
	    this(resource, lineNumber, new HashMap(), true);
53
	}
54
	
55
	/**
56
	 * Constructs a line breakpoint on the given resource at the given
57
	 * line number. The line number is 1-based (i.e. the first line of a
58
	 * file is line number 1).
59
	 * 
60
	 * @param resource file on which to set the breakpoint
61
	 * @param lineNumber 1-based line number of the breakpoint
62
	 * @param attributes the marker attributes to set
63
	 * @param register whether to add this breakpoint to the breakpoint manager
64
	 * @throws CoreException if unable to create the breakpoint
65
	 */
66
	public AntLineBreakpoint(final IResource resource, final int lineNumber, final Map attributes, final boolean register) throws CoreException {
67
	    IWorkspaceRunnable wr= new IWorkspaceRunnable() {
68
			public void run(IProgressMonitor monitor) throws CoreException {
69
			    IMarker marker = resource.createMarker(IAntDebugConstants.ID_ANT_LINE_BREAKPOINT_MARKER);
70
			    setMarker(marker);
71
			    attributes.put(IBreakpoint.ENABLED, Boolean.TRUE);
72
			    attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber));
73
			    attributes.put(IBreakpoint.ID, IAntDebugConstants.ID_ANT_DEBUG_MODEL);
74
                attributes.put(IMarker.MESSAGE, MessageFormat.format(DebugModelMessages.AntLineBreakpoint_0, new String[] {Integer.toString(lineNumber)}));
75
			    ensureMarker().setAttributes(attributes);
76
                
77
                register(register);
78
			}
79
	    };
80
	    run(getMarkerRule(resource), wr);
81
	}
82
	
83
	/* (non-Javadoc)
84
	 * @see org.eclipse.debug.core.model.IBreakpoint#getModelIdentifier()
85
	 */
86
	public String getModelIdentifier() {
87
		return IAntDebugConstants.ID_ANT_DEBUG_MODEL;
88
	}
89
90
    /**
91
     * @return whether this breakpoint is a run to line breakpoint
92
     */
93
    public boolean isRunToLine() {
94
        try {
95
            return ensureMarker().getAttribute(IAntDebugConstants.ANT_RUN_TO_LINE, false);
96
        } catch (DebugException e) {
97
           return false;
98
        }
99
    }
100
    
101
    /**
102
     * Add this breakpoint to the breakpoint manager,
103
     * or sets it as unregistered.
104
     */
105
    private void register(boolean register) throws CoreException {
106
        if (register) {
107
            DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(this);
108
        } else {
109
            setRegistered(false);
110
        }
111
    }
112
}
(-)src/org/eclipse/ant/internal/launching/debug/AntDebugMessages.java (+23 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: 
8
 * IBM - Initial API and implementation
9
 **********************************************************************/
10
package org.eclipse.ant.internal.launching.debug;
11
12
import org.eclipse.osgi.util.NLS;
13
14
public class AntDebugMessages extends NLS {
15
	private static final String BUNDLE_NAME = "org.eclipse.ant.internal.ui.debug.AntDebugMessages";//$NON-NLS-1$
16
    
17
	public static String AntSourceContainer_0;
18
19
	static {
20
		// load message values from bundle file
21
		NLS.initializeMessages(BUNDLE_NAME, AntDebugMessages.class);
22
	}
23
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntClasspathProvider.java (+50 lines)
Added Link Here
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
12
package org.eclipse.ant.internal.launching.launchConfigurations;
13
14
import java.util.ArrayList;
15
import java.util.List;
16
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.debug.core.ILaunchConfiguration;
19
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
20
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
21
import org.eclipse.jdt.launching.JavaRuntime;
22
import org.eclipse.jdt.launching.StandardClasspathProvider;
23
24
public class AntClasspathProvider extends StandardClasspathProvider {
25
26
	/* (non-Javadoc)
27
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathProvider#computeUnresolvedClasspath(org.eclipse.debug.core.ILaunchConfiguration)
28
	 */
29
	public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException {
30
		boolean useDefault = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
31
		if (useDefault) {
32
			List rtes = new ArrayList(10);
33
			IRuntimeClasspathEntry jreEntry = null;
34
			try {
35
				jreEntry = JavaRuntime.computeJREEntry(configuration);
36
			} catch (CoreException e) {
37
				// not a java project
38
			}
39
			if (jreEntry == null) {
40
				jreEntry = JavaRuntime.newRuntimeContainerClasspathEntry(
41
						JavaRuntime.newDefaultJREContainerPath(), IRuntimeClasspathEntry.STANDARD_CLASSES);
42
			}
43
			rtes.add(jreEntry);
44
			rtes.add(new AntHomeClasspathEntry());
45
			rtes.add(new ContributedClasspathEntriesEntry());
46
			return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]);
47
		}
48
		return super.computeUnresolvedClasspath(configuration);
49
	}
50
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchConfigurationMessages.java (+37 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: 
8
 * IBM - Initial API and implementation
9
 * dakshinamurthy.karra@gmail.com - bug 165371
10
 **********************************************************************/
11
package org.eclipse.ant.internal.launching.launchConfigurations;
12
13
import org.eclipse.osgi.util.NLS;
14
15
public class AntLaunchConfigurationMessages extends NLS {
16
	private static final String BUNDLE_NAME = "org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchConfigurationMessages";//$NON-NLS-1$
17
18
	public static String AntLaunchDelegate_Launching__0__1;
19
	public static String AntLaunchDelegate_Running__0__2;
20
	public static String AntLaunchDelegate_Build_In_Progress;
21
	public static String AntLaunchDelegate_Failure;
22
	public static String AntLaunchDelegate_22;
23
	public static String AntLaunchDelegate_23;
24
	public static String AntLaunchDelegate_28;
25
26
	public static String AntHomeClasspathEntry_8;
27
	public static String AntHomeClasspathEntry_9;
28
	public static String AntHomeClasspathEntry_10;
29
	public static String AntHomeClasspathEntry_11;
30
31
	public static String ContributedClasspathEntriesEntry_1;
32
33
	static {
34
		// load message values from bundle file
35
		NLS.initializeMessages(BUNDLE_NAME, AntLaunchConfigurationMessages.class);
36
	}
37
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntJavaLaunchDelegate.java (+47 lines)
Added Link Here
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.ant.internal.launching.launchConfigurations;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.IProgressMonitor;
15
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
17
import org.eclipse.jdt.launching.JavaLaunchDelegate;
18
19
/**
20
 * Used by the AntLaunchDelegate for Ant builds in a separate VM
21
 * The subclassing is needed to be able to launch an Ant build from a non-Java project
22
 */
23
public class AntJavaLaunchDelegate extends JavaLaunchDelegate {
24
	/* (non-Javadoc)
25
	 * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate2#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
26
	 */
27
	public boolean preLaunchCheck(ILaunchConfiguration configuration,String mode, IProgressMonitor monitor) throws CoreException {
28
		try {
29
			return super.preLaunchCheck(configuration, mode, monitor);
30
		} catch (CoreException ce) {
31
			//likely dealing with a non-Java project
32
		}
33
		//no need to check for breakpoints as always in run mode
34
		return true;
35
	}
36
	
37
	/* (non-Javadoc)
38
	 * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getProgramArguments(org.eclipse.debug.core.ILaunchConfiguration)
39
	 */
40
	public String getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
41
		try {
42
			return super.getProgramArguments(configuration);
43
		} catch (CoreException ce) {
44
		}
45
		return configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""); //$NON-NLS-1$
46
	}
47
}
(-)src/org/eclipse/ant/internal/launching/debug/model/DebugModelMessages.properties (+28 lines)
Added Link Here
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 Corporation - initial API and implementation
10
###############################################################################
11
12
AntDebugTarget_0=Ant Build
13
14
AntDebugModelPresentation_0=<not available>
15
AntDebugModelPresentation_1=\ line: {0}
16
AntDebugModelPresentation_2=(breakpoint at line {0} in {1})
17
AntDebugModelPresentation_3=\ (Suspended {0})
18
AntDebugModelPresentation_4=\ (Suspended)
19
AntDebugModelPresentation_5=(run to line {0} in {1})
20
21
AntLineBreakpoint_0=Ant breakpoint [line: {0}]
22
AntThread_0=User Properties
23
AntThread_1=System Properties
24
AntThread_2=Runtime Properties
25
AntThread_3=Request to retrieve Ant stack frames failed
26
AntThread_4=Request to retrieve Ant properties failed
27
28
AntProperties_1=Request to Ant properties value failed
(-)src/org/eclipse/core/internal/externaltools/ExternalToolsCore.java (+59 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.core.internal.externaltools;
11
package org.eclipse.core.internal.externaltools;
12
12
13
import org.eclipse.core.internal.externaltools.model.IExternalToolConstants;
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.IStatus;
13
import org.eclipse.core.runtime.Plugin;
16
import org.eclipse.core.runtime.Plugin;
17
import org.eclipse.core.runtime.Status;
14
import org.osgi.framework.BundleContext;
18
import org.osgi.framework.BundleContext;
15
19
16
/**
20
/**
Lines 20-25 Link Here
20
24
21
	// The plug-in ID
25
	// The plug-in ID
22
	public static final String PLUGIN_ID = "org.eclipse.core.externaltools"; //$NON-NLS-1$
26
	public static final String PLUGIN_ID = "org.eclipse.core.externaltools"; //$NON-NLS-1$
27
	
28
	private static final String EMPTY_STRING= ""; //$NON-NLS-1$
29
	
30
	/**
31
	 * Status code indicating an unexpected internal error.
32
	 * @since 2.1
33
	 */
34
	public static final int INTERNAL_ERROR = 120;	
23
35
24
	// The shared instance
36
	// The shared instance
25
	private static ExternalToolsCore plugin;
37
	private static ExternalToolsCore plugin;
Lines 56-60 Link Here
56
	public static ExternalToolsCore getDefault() {
68
	public static ExternalToolsCore getDefault() {
57
		return plugin;
69
		return plugin;
58
	}
70
	}
71
	
72
	/**
73
	 * Logs the specified throwable with this plug-in's log.
74
	 * 
75
	 * @param t throwable to log 
76
	 */
77
	public static void log(Throwable t) {
78
		IStatus status= new Status(IStatus.ERROR, PLUGIN_ID, INTERNAL_ERROR, "Error logged from Ant UI: ", t); //$NON-NLS-1$
79
		log(status);
80
	}
81
82
	/**
83
	 * Logs the specified status with this plug-in's log.
84
	 * 
85
	 * @param status status 
86
	 */
87
	public static void log(IStatus status) {
88
		getDefault().getLog().log(status);
89
	}
90
	
91
	/**
92
	 * Writes the message to the plug-in's log
93
	 * 
94
	 * @param message the text to write to the log
95
	 */
96
	public static void log(String message, Throwable exception) {
97
		IStatus status = newErrorStatus(message, exception);
98
		log(status);
99
	}
100
	
101
	/**
102
	 * Returns a new <code>IStatus</code> for this plug-in
103
	 */
104
	public static IStatus newErrorStatus(String message, Throwable exception) {
105
		if (message == null) {
106
			message= EMPTY_STRING; 
107
		}		
108
		return new Status(IStatus.ERROR, PLUGIN_ID, 0, message, exception);
109
	}
110
	
111
	/**
112
	 * Returns a new <code>CoreException</code> for this plug-in
113
	 */
114
	public static CoreException newError(String message, Throwable exception) {
115
		return new CoreException(new Status(IStatus.ERROR,
116
				IExternalToolConstants.PLUGIN_ID, 0, message, exception));
117
	}
59
118
60
}
119
}
(-)plugin.properties (-1 / +3 lines)
Lines 10-13 Link Here
10
###############################################################################
10
###############################################################################
11
11
12
pluginName=External Tools Headless Support
12
pluginName=External Tools Headless Support
13
providerName=Eclipse.org
13
providerName=Eclipse.org
14
15
Program.externalTools = Program
(-)build.properties (-1 / +3 lines)
Lines 1-4 Link Here
1
source.. = src/
1
source.. = src/
2
output.. = bin/
2
output.. = bin/
3
bin.includes = META-INF/,\
3
bin.includes = META-INF/,\
4
               .
4
               .,\
5
               plugin.xml,\
6
               plugin.properties
(-)META-INF/MANIFEST.MF (-2 / +4 lines)
Lines 1-7 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.core.externaltools
4
Bundle-SymbolicName: org.eclipse.core.externaltools;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-Activator: org.eclipse.core.internal.externaltools.ExternalToolsCore
6
Bundle-Activator: org.eclipse.core.internal.externaltools.ExternalToolsCore
7
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
7
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
Lines 10-13 Link Here
10
Bundle-RequiredExecutionEnvironment: J2SE-1.4
10
Bundle-RequiredExecutionEnvironment: J2SE-1.4
11
Bundle-ActivationPolicy: lazy
11
Bundle-ActivationPolicy: lazy
12
Bundle-Vendor: %providerName
12
Bundle-Vendor: %providerName
13
Export-Package: org.eclipse.core.internal.externaltools;x-internal:=true
13
Export-Package: org.eclipse.core.internal.externaltools;x-friends:="org.eclipse.ui.externaltools",
14
 org.eclipse.core.internal.externaltools.launchConfigurations,
15
 org.eclipse.core.internal.externaltools.model
(-)src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsCoreUtil.java (+259 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 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
 *     Keith Seitz (keiths@redhat.com) - Bug 27243 (environment variables contribution)
11
 *     dakshinamurthy.karra@gmail.com - bug 165371
12
 *******************************************************************************/
13
package org.eclipse.core.internal.externaltools.launchConfigurations;
14
15
16
import java.io.File;
17
18
import org.eclipse.core.internal.externaltools.model.IExternalToolConstants;
19
import org.eclipse.core.resources.IProject;
20
import org.eclipse.core.resources.IResource;
21
import org.eclipse.core.resources.IWorkspaceRoot;
22
import org.eclipse.core.resources.ResourcesPlugin;
23
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.IPath;
25
import org.eclipse.core.runtime.IStatus;
26
import org.eclipse.core.runtime.Path;
27
import org.eclipse.core.runtime.Status;
28
import org.eclipse.core.variables.IStringVariableManager;
29
import org.eclipse.core.variables.VariablesPlugin;
30
import org.eclipse.debug.core.DebugPlugin;
31
import org.eclipse.debug.core.ILaunchConfiguration;
32
import org.eclipse.debug.internal.core.LaunchManager;
33
import org.eclipse.osgi.util.NLS;
34
35
/**
36
 * Utilities for external tool launch configurations.
37
 * <p>
38
 * This class it not intended to be instantiated.
39
 * </p>
40
 */
41
public class ExternalToolsCoreUtil {
42
43
	/**
44
	 * Throws a core exception with an error status object built from
45
	 * the given message, lower level exception, and error code.
46
	 * 
47
	 * @param message the status message
48
	 * @param exception lower level exception associated with the
49
	 *  error, or <code>null</code> if none
50
	 * @param code error code
51
	 */
52
	protected static void abort(String message, Throwable exception, int code) throws CoreException {
53
		throw new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, code, message, exception));
54
	}
55
	
56
	/**
57
	 * Expands and returns the location attribute of the given launch
58
	 * configuration. The location is
59
	 * verified to point to an existing file, in the local file system.
60
	 * 
61
	 * @param configuration launch configuration
62
	 * @return an absolute path to a file in the local file system  
63
	 * @throws CoreException if unable to retrieve the associated launch
64
	 * configuration attribute, if unable to resolve any variables, or if the
65
	 * resolved location does not point to an existing file in the local file
66
	 * system
67
	 */
68
	public static IPath getLocation(ILaunchConfiguration configuration) throws CoreException {
69
		String location = configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String) null);
70
		if (location == null) {
71
			abort(NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_Location_not_specified_by__0__1, new String[] { configuration.getName()}), null, 0);
72
		} else {
73
			String expandedLocation = getStringVariableManager().performStringSubstitution(location);
74
			if (expandedLocation == null || expandedLocation.length() == 0) {
75
				String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()});
76
				abort(msg, null, 0);
77
			} else {
78
				File file = new File(expandedLocation);
79
				if (file.isFile()) {
80
					return new Path(expandedLocation);
81
				} 
82
				
83
				String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()});
84
				abort(msg, null, 0);
85
			}
86
		}
87
		// execution will not reach here
88
		return null;
89
	}
90
	
91
	/**
92
	 * Returns a boolean specifying whether or not output should be captured for
93
	 * the given configuration
94
	 * 
95
	 * @param configuration the configuration from which the value will be
96
	 * extracted
97
	 * @return boolean specifying whether or not output should be captured
98
	 * @throws CoreException if unable to access the associated attribute
99
	 */
100
	public static boolean getCaptureOutput(ILaunchConfiguration configuration) throws CoreException {
101
	    return configuration.getAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true);
102
	}
103
104
	/**
105
	 * Expands and returns the working directory attribute of the given launch
106
	 * configuration. Returns <code>null</code> if a working directory is not
107
	 * specified. If specified, the working is verified to point to an existing
108
	 * directory in the local file system.
109
	 * 
110
	 * @param configuration launch configuration
111
	 * @return an absolute path to a directory in the local file system, or
112
	 * <code>null</code> if unspecified
113
	 * @throws CoreException if unable to retrieve the associated launch
114
	 * configuration attribute, if unable to resolve any variables, or if the
115
	 * resolved location does not point to an existing directory in the local
116
	 * file system
117
	 */
118
	public static IPath getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
119
		String location = configuration.getAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) null);
120
		if (location != null) {
121
			String expandedLocation = getStringVariableManager().performStringSubstitution(location);
122
			if (expandedLocation.length() > 0) {
123
				File path = new File(expandedLocation);
124
				if (path.isDirectory()) {
125
					return new Path(expandedLocation);
126
				} 
127
				String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidDirectory__0_, new Object[] { expandedLocation, configuration.getName()});
128
				abort(msg, null, 0);
129
			}
130
		}
131
		return null;
132
	}
133
134
	/**
135
	 * Expands and returns the arguments attribute of the given launch
136
	 * configuration. Returns <code>null</code> if arguments are not specified.
137
	 * 
138
	 * @param configuration launch configuration
139
	 * @return an array of resolved arguments, or <code>null</code> if
140
	 * unspecified
141
	 * @throws CoreException if unable to retrieve the associated launch
142
	 * configuration attribute, or if unable to resolve any variables
143
	 */
144
	public static String[] getArguments(ILaunchConfiguration configuration) throws CoreException {
145
		String args = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String) null);
146
		if (args != null) {
147
			String expanded = getStringVariableManager().performStringSubstitution(args);
148
			return parseStringIntoList(expanded);
149
		}
150
		return null;
151
	}
152
153
	private static IStringVariableManager getStringVariableManager() {
154
		return VariablesPlugin.getDefault().getStringVariableManager();
155
	}
156
	
157
	/**
158
	 * Returns whether the given launch configuration is enabled. This property
159
	 * is intended only to apply to external tool builder configurations and
160
	 * determines whether the project builder will launch the configuration
161
	 * when it builds.
162
	 *  
163
	 * @param configuration the configuration for which the enabled state should
164
	 * 		be determined.
165
	 * @return whether the given configuration is enabled to be run when a build occurs.
166
	 * @throws CoreException if unable to access the associated attribute
167
	 */
168
	public static boolean isBuilderEnabled(ILaunchConfiguration configuration) throws CoreException {
169
		return configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_ENABLED, true);
170
	}
171
	
172
	/**
173
	 * Returns the collection of resources for the build scope as specified by the given launch configuration.
174
	 * 
175
	 * @param configuration launch configuration
176
	 * @throws CoreException if an exception occurs while retrieving the resources
177
	 */
178
	public static IResource[] getResourcesForBuildScope(ILaunchConfiguration configuration) throws CoreException {
179
		String scope = configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_SCOPE, (String) null);
180
		if (scope == null) {
181
			return null;
182
		}
183
	
184
		return LaunchManager.getRefreshResources(scope);
185
	}
186
	
187
	/**
188
	 * Parses the argument text into an array of individual
189
	 * strings using the space character as the delimiter.
190
	 * An individual argument containing spaces must have a
191
	 * double quote (") at the start and end. Two double 
192
	 * quotes together is taken to mean an embedded double
193
	 * quote in the argument text.
194
	 * 
195
	 * @param arguments the arguments as one string
196
	 * @return the array of arguments
197
	 */
198
	public static String[] parseStringIntoList(String arguments) {
199
		if (arguments == null || arguments.length() == 0) {
200
			return new String[0];
201
		}
202
		String[] res= DebugPlugin.parseArguments(arguments);
203
		return res;		
204
	}	
205
	/**
206
	 * Returns a collection of projects referenced by a build scope attribute.
207
	 * 
208
	 * @return collection of projects referred to by configuration
209
	 */
210
	public static IProject[] getBuildProjects(ILaunchConfiguration configuration, String buildScopeId) {
211
		
212
		String scope = null;
213
		String id = buildScopeId ;
214
		if (id == null) {
215
			id = IExternalToolConstants.ATTR_BUILD_SCOPE ;
216
		}
217
		try {
218
			scope = configuration.getAttribute(id, (String)null);
219
		} catch (CoreException e) {
220
			return null;
221
		}
222
		if (scope == null) {
223
			return null;
224
		}
225
		if (scope.startsWith("${projects:")) { //$NON-NLS-1$
226
			String pathString = scope.substring(11, scope.length() - 1);
227
			if (pathString.length() > 1) {
228
				String[] names = pathString.split(","); //$NON-NLS-1$
229
				IProject[] projects = new IProject[names.length];
230
				IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
231
				for (int i = 0; i < names.length; i++) {
232
					projects[i] = root.getProject(names[i]);
233
				}
234
				return projects;
235
			}
236
		} else if (scope.equals("${project}")) { //$NON-NLS-1$
237
			if(configuration.getFile()!=null)
238
				return new IProject[]{((IResource)configuration.getFile()).getProject()};
239
		}
240
		return new IProject[0];
241
	}
242
	
243
	/**
244
	 * Whether referenced projects should be considered when building. Only valid
245
	 * when a set of projects is to be built.
246
	 * 
247
	 * @param configuration
248
	 * @return whether referenced projects should be considerd when building
249
	 * @throws CoreException if unable to access the associated attribute
250
	 */
251
	public static boolean isIncludeReferencedProjects(ILaunchConfiguration configuration, String includeReferencedProjectsId) throws CoreException {
252
		String id = includeReferencedProjectsId;
253
		if (id == null) {
254
			id = IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS ;
255
		}
256
		return configuration.getAttribute(id, true);
257
	}
258
	
259
}
(-)src/org/eclipse/core/internal/externaltools/model/ExternalToolBuilder.java (+289 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 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
 *     Matthew Conway  - Bug 175186
11
 *******************************************************************************/
12
package org.eclipse.core.internal.externaltools.model;
13
14
15
import java.util.Map;
16
17
import org.eclipse.core.internal.externaltools.ExternalToolsCore;
18
import org.eclipse.core.internal.externaltools.launchConfigurations.ExternalToolsCoreUtil;
19
import org.eclipse.core.internal.externaltools.registry.ExternalToolMigration;
20
import org.eclipse.core.resources.ICommand;
21
import org.eclipse.core.resources.IFile;
22
import org.eclipse.core.resources.IProject;
23
import org.eclipse.core.resources.IProjectDescription;
24
import org.eclipse.core.resources.IResource;
25
import org.eclipse.core.resources.IResourceDelta;
26
import org.eclipse.core.resources.IResourceDeltaVisitor;
27
import org.eclipse.core.resources.IncrementalProjectBuilder;
28
import org.eclipse.core.runtime.CoreException;
29
import org.eclipse.core.runtime.IPath;
30
import org.eclipse.core.runtime.IProgressMonitor;
31
import org.eclipse.debug.core.ILaunchConfiguration;
32
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
33
import org.eclipse.debug.core.ILaunchManager;
34
import org.eclipse.osgi.util.NLS;
35
import org.osgi.framework.Bundle;
36
37
/**
38
 * This project builder implementation will run an external tool during the
39
 * build process. 
40
 */
41
public final class ExternalToolBuilder extends IncrementalProjectBuilder {
42
	private final class IgnoreTeamPrivateChanges implements IResourceDeltaVisitor {
43
		private boolean[] fTrueChange;
44
		private IgnoreTeamPrivateChanges(boolean[] trueChange) {
45
			super();
46
			fTrueChange= trueChange;
47
		}
48
		public boolean visit(IResourceDelta visitDelta) throws CoreException {
49
			IResource resource= visitDelta.getResource();
50
			if (resource instanceof IFile) {
51
				fTrueChange[0]= true;
52
				return false;
53
			}
54
			return true;
55
		}
56
	}
57
58
	public static final String ID = "org.eclipse.ui.externaltools.ExternalToolBuilder"; //$NON-NLS-1$;
59
60
	private static String buildType = IExternalToolConstants.BUILD_TYPE_NONE;
61
	
62
	private static IProject buildProject= null;
63
    private static IResourceDelta buildDelta= null;
64
	
65
	/* (non-Javadoc)
66
	 * @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
67
	 */
68
	protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {		
69
		if (ExternalToolsCore.getDefault().getBundle().getState() != Bundle.ACTIVE) {
70
			return null;
71
		}
72
		
73
		ILaunchConfiguration config= BuilderUtils.configFromBuildCommandArgs(getProject(), args, new String[1]);
74
        if (config == null) {
75
            throw ExternalToolsCore.newError(ExternalToolsModelMessages.ExternalToolBuilder_0, null);
76
        }
77
		IProject[] projectsWithinScope= null;
78
		IResource[] resources = ExternalToolsCoreUtil.getResourcesForBuildScope(config);
79
		if (resources != null) {
80
			projectsWithinScope= new IProject[resources.length];
81
			for (int i = 0; i < resources.length; i++) {
82
				projectsWithinScope[i]= resources[i].getProject();
83
			}
84
		}
85
        boolean kindCompatible= commandConfiguredForKind(config, kind);
86
        if (kindCompatible && configEnabled(config)) {
87
            doBuildBasedOnScope(resources, kind, config, monitor);
88
        }
89
        
90
		return projectsWithinScope;
91
	}
92
93
    private boolean commandConfiguredForKind(ILaunchConfiguration config, int kind) {
94
        try {
95
            if (!(config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false))) {
96
                ICommand command= getCommand();
97
                //adapt the builder command to make use of the 3.1 support for setting command build kinds
98
                //this will only happen once for builder/command defined before the support existed
99
                BuilderUtils.configureTriggers(config, command);
100
                IProjectDescription desc= getProject().getDescription();
101
                ICommand[] commands= desc.getBuildSpec();
102
                int index= getBuilderCommandIndex(commands, command);
103
                if (index != -1) {
104
                    commands[index]= command;
105
                    desc.setBuildSpec(commands);
106
                    getProject().setDescription(desc, null);
107
                    ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
108
                    copy.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, true);
109
                    copy.doSave();
110
                }
111
                return command.isBuilding(kind);
112
            }
113
        } catch (CoreException e) {
114
           ExternalToolsCore.getDefault().log(e);
115
           return true;
116
        }
117
        return true;
118
    }
119
    
120
    private int getBuilderCommandIndex(ICommand[] buildSpec, ICommand command) {
121
        Map commandArgs= command.getArguments();
122
        if (commandArgs == null) {
123
            return -1;
124
        }
125
        String handle= (String) commandArgs.get(BuilderUtils.LAUNCH_CONFIG_HANDLE);
126
        if (handle == null) {
127
            return -1;
128
        }
129
        for (int i = 0; i < buildSpec.length; ++i) {
130
            ICommand buildSpecCommand= buildSpec[i];
131
            if (ID.equals(buildSpecCommand.getBuilderName())) {
132
                Map buildSpecArgs= buildSpecCommand.getArguments();
133
                if (buildSpecArgs != null) {
134
                    String buildSpecHandle= (String) buildSpecArgs.get(BuilderUtils.LAUNCH_CONFIG_HANDLE);
135
                    if (handle.equals(buildSpecHandle)) {
136
                        return i;
137
                    }
138
                }
139
            }
140
        }
141
        return -1;
142
    }
143
144
	/**
145
	 * Returns whether the given builder config is enabled or not.
146
	 * 
147
	 * @param config the config to examine
148
	 * @return whether the config is enabled
149
	 */
150
	private boolean configEnabled(ILaunchConfiguration config) {
151
		try {
152
			return ExternalToolsCoreUtil.isBuilderEnabled(config);
153
		} catch (CoreException e) {
154
			ExternalToolsCore.getDefault().log(e);
155
		}
156
		return true;
157
	}
158
159
	private void doBuildBasedOnScope(IResource[] resources, int kind, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException {
160
		boolean buildForChange = true;
161
		if (kind != FULL_BUILD) { //scope not applied for full builds
162
			if (resources != null && resources.length > 0) {
163
				buildForChange = buildScopeIndicatesBuild(resources);
164
			}
165
		}
166
167
		if (buildForChange) {
168
			launchBuild(kind, config, monitor);
169
		}
170
	}
171
	
172
	private void launchBuild(int kind, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException {
173
		monitor.subTask(NLS.bind(ExternalToolsModelMessages.ExternalToolBuilder_Running__0_____1, new String[] { config.getName()}));
174
		buildStarted(kind);
175
		// The default value for "launch in background" is true in debug core. If
176
		// the user doesn't go through the UI, the new attribute won't be set. This means
177
		// that existing Ant builders will try to run in the background (and likely conflict with
178
		// each other) without migration.
179
		config= ExternalToolMigration.migrateRunInBackground(config);
180
		config.launch(ILaunchManager.RUN_MODE, monitor);
181
		buildEnded();
182
	}
183
184
	/**
185
	 * Returns the build type being performed if the
186
	 * external tool is being run as a project builder.
187
	 * 
188
	 * @return one of the <code>IExternalToolConstants.BUILD_TYPE_*</code> constants.
189
	 */
190
	public static String getBuildType() {
191
		return buildType;
192
	}
193
	
194
	/**
195
	 * Returns the project that is being built and has triggered the current external
196
	 * tool builder. <code>null</code> is returned if no build is currently occurring.
197
	 * 
198
	 * @return project being built or <code>null</code>.
199
	 */
200
	public static IProject getBuildProject() {
201
		return buildProject;
202
	}
203
204
    /**
205
     * Returns the <code>IResourceDelta</code> that is being built and has triggered the current external
206
     * tool builder. <code>null</code> is returned if no build is currently occurring.
207
     * 
208
     * @return resource delta for the build or <code>null</code>
209
     */
210
    public static IResourceDelta getBuildDelta() {
211
        return buildDelta;
212
    }
213
    
214
	/**
215
	 * Stores the currently active build kind and build project when a build begins
216
	 * @param buildKind
217
	 */
218
	private void buildStarted(int buildKind) {
219
		switch (buildKind) {
220
			case IncrementalProjectBuilder.INCREMENTAL_BUILD :
221
				buildType = IExternalToolConstants.BUILD_TYPE_INCREMENTAL;
222
				buildDelta = getDelta(getProject());
223
				break;
224
			case IncrementalProjectBuilder.FULL_BUILD :
225
				buildType = IExternalToolConstants.BUILD_TYPE_FULL;
226
				break;
227
			case IncrementalProjectBuilder.AUTO_BUILD :
228
				buildType = IExternalToolConstants.BUILD_TYPE_AUTO;
229
				buildDelta = getDelta(getProject());
230
				break;
231
            case IncrementalProjectBuilder.CLEAN_BUILD :
232
                buildType = IExternalToolConstants.BUILD_TYPE_CLEAN;
233
                break;
234
			default :
235
				buildType = IExternalToolConstants.BUILD_TYPE_NONE;
236
				break;
237
		}
238
		buildProject= getProject();
239
	}
240
	
241
	/**
242
	 * Clears the current build kind, build project and build delta when a build finishes.
243
	 */
244
	private void buildEnded() {
245
		buildType= IExternalToolConstants.BUILD_TYPE_NONE;
246
		buildProject= null;
247
        buildDelta= null;
248
	}
249
	
250
	private boolean buildScopeIndicatesBuild(IResource[] resources) {
251
		for (int i = 0; i < resources.length; i++) {
252
			IResourceDelta delta = getDelta(resources[i].getProject());
253
			if (delta == null) {
254
				//project just added to the workspace..no previous build tree
255
				return true;
256
			} 
257
			IPath path= resources[i].getProjectRelativePath();
258
			IResourceDelta change= delta.findMember(path);
259
			if (change != null) {
260
				final boolean[] trueChange= new boolean[1];
261
				trueChange[0]= false;
262
				try {
263
					change.accept(new IgnoreTeamPrivateChanges(trueChange));
264
				} catch (CoreException e) {
265
					ExternalToolsCore.getDefault().log("Internal error resolving changed resources during build", e); //$NON-NLS-1$
266
				}
267
				
268
				return trueChange[0]; //filtered out team private changes
269
			}
270
		}
271
		return false;
272
	}
273
    
274
    protected void clean(IProgressMonitor monitor) throws CoreException {
275
	    ICommand command= getCommand();
276
        ILaunchConfiguration config= BuilderUtils.configFromBuildCommandArgs(getProject(), command.getArguments(), new String[1]);
277
    	if (!configEnabled(config)) {
278
	    	return;
279
	    }
280
        
281
        if ((!config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false))) {
282
            //old behavior
283
            super.clean(monitor);
284
            return;
285
        }
286
	
287
		launchBuild(IncrementalProjectBuilder.CLEAN_BUILD, config, monitor);
288
    }
289
}
(-)src/org/eclipse/core/internal/externaltools/registry/ExternalToolMigration.java (+410 lines)
Added Link Here
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.externaltools.registry;
12
13
14
import java.util.ArrayList;
15
import java.util.Map;
16
import java.util.StringTokenizer;
17
18
import org.eclipse.core.internal.externaltools.ExternalToolsCore;
19
import org.eclipse.core.internal.externaltools.launchConfigurations.ExternalToolsMigrationMessages;
20
import org.eclipse.core.internal.externaltools.model.IExternalToolConstants;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.debug.core.DebugPlugin;
23
import org.eclipse.debug.core.ILaunchConfiguration;
24
import org.eclipse.debug.core.ILaunchConfigurationType;
25
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
26
import org.eclipse.debug.core.ILaunchManager;
27
28
29
/**
30
 * Responsible reading an old external tool format and creating
31
 * and migrating it to create a new external tool.
32
 */
33
public final class ExternalToolMigration {
34
	/**
35
	 * Structure to represent a variable definition within a
36
	 * source string.
37
	 */
38
	public static final class VariableDefinition {
39
		/**
40
		 * Index in the source text where the variable started
41
		 * or <code>-1</code> if no valid variable start tag 
42
		 * identifier found.
43
		 */
44
		public int start = -1;
45
		
46
		/**
47
		 * Index in the source text of the character following
48
		 * the end of the variable or <code>-1</code> if no 
49
		 * valid variable end tag found.
50
		 */
51
		public int end = -1;
52
		
53
		/**
54
		 * The variable's name found in the source text, or
55
		 * <code>null</code> if no valid variable found.
56
		 */
57
		public String name = null;
58
		
59
		/**
60
		 * The variable's argument found in the source text, or
61
		 * <code>null</code> if no valid variable found or if
62
		 * the variable did not specify an argument
63
		 */
64
		public String argument = null;
65
		
66
		/**
67
		 * Create an initialized variable definition.
68
		 */
69
		private VariableDefinition() {
70
			super();
71
		}
72
	}
73
	
74
	/**
75
	 * Variable tag indentifiers
76
	 */
77
	private static final String VAR_TAG_START = "${"; //$NON-NLS-1$
78
	private static final String VAR_TAG_END = "}"; //$NON-NLS-1$
79
	private static final String VAR_TAG_SEP = ":"; //$NON-NLS-1$	
80
	
81
	/**
82
	 * External tool type for Ant build files (value <code>antBuildType</code>).
83
	 */
84
	public static final String TOOL_TYPE_ANT_BUILD = "antBuildType"; //$NON-NLS-1$;
85
	/**
86
	 * Ant builder launch configuration type identifier. Ant project builders
87
	 * are of this type.
88
	 */
89
	public static final String ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ant.AntBuilderLaunchConfigurationType"; //$NON-NLS-1$
90
		
91
	public static final String RUN_TARGETS_ATTRIBUTE = TOOL_TYPE_ANT_BUILD + ".runTargets"; //$NON-NLS-1$;
92
93
	/**
94
	* String attribute indicating the Ant targets to execute. Default value is
95
	 * <code>null</code> which indicates that the default target is to be
96
	 * executed. Format is a comma separated listing of targets.
97
	 * NOTE: This value is copied here from org.eclipse.ant.ui.internal.IAntLaunchConfigurationConstants.
98
	 * 		Ant no longer resides in External Tools and this plug-in. This value is kept here only
99
	 * 		for migration.
100
	 */
101
	public static final String ATTR_ANT_TARGETS = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_TARGETS"; //$NON-NLS-1$
102
	
103
	/*
104
	 * 2.0 External Tool Tags
105
	 */
106
	public static final String TAG_TOOL_TYPE = "!{tool_type}"; //$NON-NLS-1$
107
	public static final String TAG_TOOL_NAME = "!{tool_name}"; //$NON-NLS-1$
108
	public static final String TAG_TOOL_LOCATION = "!{tool_loc}"; //$NON-NLS-1$
109
	public static final String TAG_TOOL_ARGUMENTS = "!{tool_args}"; //$NON-NLS-1$
110
	public static final String TAG_TOOL_DIRECTORY = "!{tool_dir}"; //$NON-NLS-1$
111
	public static final String TAG_TOOL_REFRESH = "!{tool_refresh}"; //$NON-NLS-1$
112
	public static final String TAG_TOOL_SHOW_LOG = "!{tool_show_log}"; //$NON-NLS-1$
113
	public static final String TAG_TOOL_BUILD_TYPES = "!{tool_build_types}"; //$NON-NLS-1$
114
	public static final String TAG_TOOL_BLOCK = "!{tool_block}"; //$NON-NLS-1$
115
116
	// Known kind of tools
117
	private static final String TOOL_TYPE_ANT = "org.eclipse.ui.externaltools.type.ant"; //$NON-NLS-1$
118
	private static final String TOOL_TYPE_PROGRAM = "org.eclipse.ui.externaltools.type.program"; //$NON-NLS-1$
119
120
	/*
121
	 * 2.1 External Tool Keys
122
	 */
123
	public static final String TAG_TYPE = "type"; //$NON-NLS-1$
124
	public static final String TAG_NAME = "name"; //$NON-NLS-1$
125
	public static final String TAG_LOCATION = "location"; //$NON-NLS-1$
126
	public static final String TAG_WORK_DIR = "workDirectory"; //$NON-NLS-1$
127
	public static final String TAG_CAPTURE_OUTPUT = "captureOutput"; //$NON-NLS-1$
128
	public static final String TAG_SHOW_CONSOLE = "showConsole"; //$NON-NLS-1$
129
	public static final String TAG_RUN_BKGRND = "runInBackground"; //$NON-NLS-1$
130
	public static final String TAG_PROMPT_ARGS = "promptForArguments"; //$NON-NLS-1$
131
	public static final String TAG_ARGS = "arguments"; //$NON-NLS-1$
132
	public static final String TAG_REFRESH_SCOPE = "refreshScope"; //$NON-NLS-1$
133
	public static final String TAG_REFRESH_RECURSIVE = "refreshRecursive"; //$NON-NLS-1$
134
	public static final String TAG_RUN_BUILD_KINDS = "runForBuildKinds"; //$NON-NLS-1$
135
	public static final String TAG_EXTRA_ATTR = "extraAttribute"; //$NON-NLS-1$
136
	public static final String TAG_VERSION = "version"; //$NON-NLS-1$
137
138
	private static final String EXTRA_ATTR_SEPARATOR = "="; //$NON-NLS-1$
139
140
	private static final String VERSION_21 = "2.1"; //$NON-NLS-1$;
141
142
	private static final String TRUE = "true"; //$NON-NLS-1$
143
	private static final String FALSE = "false"; //$NON-NLS-1$
144
145
	/**
146
	 * Allows no instances.
147
	 */
148
	private ExternalToolMigration() {
149
		super();
150
	}
151
152
	/**
153
	 * Returns a  launch configuration working copy from the argument map or
154
	 * <code>null</code> if the given map cannot be interpreted as a 2.0 or 2.1
155
	 * branch external tool. The returned working copy will be unsaved and its
156
	 * location will be set to the metadata area.
157
	 */
158
	public static ILaunchConfigurationWorkingCopy configFromArgumentMap(Map args) {
159
		String version = (String) args.get(TAG_VERSION);
160
		if (VERSION_21.equals(version)) {
161
			return configFrom21ArgumentMap(args);
162
		}
163
		return configFrom20ArgumentMap(args);
164
	}
165
166
	public static ILaunchConfigurationWorkingCopy configFrom21ArgumentMap(Map commandArgs) {
167
		String name = (String) commandArgs.get(TAG_NAME);
168
		String type = (String) commandArgs.get(TAG_TYPE);
169
		
170
		ILaunchConfigurationWorkingCopy config = newConfig(type, name);
171
		if (config == null) {
172
			return null;
173
		}
174
		
175
		config.setAttribute(IExternalToolConstants.ATTR_LOCATION, (String) commandArgs.get(TAG_LOCATION));
176
		config.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) commandArgs.get(TAG_WORK_DIR));
177
		config.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, TRUE.equals(commandArgs.get(TAG_CAPTURE_OUTPUT)));
178
		config.setAttribute(IExternalToolConstants.ATTR_SHOW_CONSOLE, TRUE.equals(commandArgs.get(TAG_SHOW_CONSOLE)));
179
		config.setAttribute(ILaunchManager.ATTR_LAUNCH_IN_BACKGROUND, TRUE.equals(commandArgs.get(TAG_RUN_BKGRND)));
180
		config.setAttribute(IExternalToolConstants.ATTR_PROMPT_FOR_ARGUMENTS, TRUE.equals(commandArgs.get(TAG_PROMPT_ARGS)));
181
		config.setAttribute(ILaunchManager.ATTR_REFRESH_SCOPE, (String) commandArgs.get(TAG_REFRESH_SCOPE));
182
		config.setAttribute(ILaunchManager.ATTR_REFRESH_RECURSIVE, TRUE.equals(commandArgs.get(TAG_REFRESH_RECURSIVE)));
183
184
		config.setAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, (String) commandArgs.get(TAG_RUN_BUILD_KINDS));
185
		
186
		String args = (String) commandArgs.get(TAG_ARGS);
187
		if (args != null) {
188
			config.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, args);
189
		}
190
191
		String extraAttributes = (String) commandArgs.get(TAG_EXTRA_ATTR);
192
		if (extraAttributes != null) {
193
			StringTokenizer tokenizer = new StringTokenizer(extraAttributes, EXTRA_ATTR_SEPARATOR);
194
			while (tokenizer.hasMoreTokens()) {
195
				String key = tokenizer.nextToken();
196
				if (!tokenizer.hasMoreTokens())
197
					break;
198
				String value = tokenizer.nextToken();
199
				if (key.equals(RUN_TARGETS_ATTRIBUTE)) {
200
					// 2.1 implementation only defined 1 "extra attribute"
201
					config.setAttribute(ATTR_ANT_TARGETS, value);
202
				}
203
			}
204
		}
205
		return config;
206
	}
207
208
	/**
209
	 * Creates an external tool from the map.
210
	 */
211
	public static ILaunchConfigurationWorkingCopy configFrom20ArgumentMap(Map args) {
212
		// Update the type...
213
		String type = (String) args.get(TAG_TOOL_TYPE);
214
		if (TOOL_TYPE_ANT.equals(type)) {
215
			type = TOOL_TYPE_ANT_BUILD;
216
		} else if (TOOL_TYPE_PROGRAM.equals(type)){
217
			type = IExternalToolConstants.TOOL_TYPE_PROGRAM;
218
		} else {
219
			return null;
220
		}
221
222
		String name = (String) args.get(TAG_TOOL_NAME);
223
		
224
		ILaunchConfigurationWorkingCopy config = newConfig(type, name);
225
		if (config == null) {
226
			return null;
227
		}
228
229
		// Update the location...
230
		String location = (String) args.get(TAG_TOOL_LOCATION);
231
		config.setAttribute(IExternalToolConstants.ATTR_LOCATION, location);
232
233
		// Update the refresh scope...
234
		String refresh = (String) args.get(TAG_TOOL_REFRESH);
235
		if (refresh != null) {
236
			VariableDefinition varDef = extractVariableDefinition(refresh, 0);
237
			if ("none".equals(varDef.name)) { //$NON-NLS-1$
238
				refresh = null;
239
			}
240
			config.setAttribute(ILaunchManager.ATTR_REFRESH_SCOPE, refresh);
241
		}
242
243
		// Update the arguments
244
		String arguments = (String) args.get(TAG_TOOL_ARGUMENTS);
245
		if (type.equals(TOOL_TYPE_ANT_BUILD)) {
246
			String targetNames = null;
247
			if (arguments != null) {
248
				int start = 0;
249
				ArrayList targets = new ArrayList();
250
				StringBuffer buffer = new StringBuffer();
251
				VariableDefinition varDef = extractVariableDefinition(arguments, start);
252
				while (varDef.end != -1) {
253
					if ("ant_target".equals(varDef.name) && varDef.argument != null) { //$NON-NLS-1$
254
						targets.add(varDef.argument);
255
						buffer.append(arguments.substring(start, varDef.start));
256
					} else {
257
						buffer.append(arguments.substring(start, varDef.end));
258
					}
259
					start = varDef.end;
260
					varDef = extractVariableDefinition(arguments, start);
261
				}
262
				buffer.append(arguments.substring(start, arguments.length()));
263
				arguments = buffer.toString();
264
	
265
				buffer.setLength(0);
266
				for (int i = 0; i < targets.size(); i++) {
267
					String target = (String) targets.get(i);
268
					if (target != null && target.length() > 0) {
269
						buffer.append(target);
270
						buffer.append(","); //$NON-NLS-1$
271
					}
272
				}
273
				targetNames = buffer.toString();
274
			}
275
			if (targetNames != null && targetNames.length() > 0) {
276
				config.setAttribute(ATTR_ANT_TARGETS, targetNames);
277
			}
278
		}
279
		config.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, arguments);
280
281
		// Collect the rest of the information
282
		config.setAttribute(IExternalToolConstants.ATTR_SHOW_CONSOLE, TRUE.equals(args.get(TAG_TOOL_SHOW_LOG)));
283
		config.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, TRUE.equals(args.get(TAG_TOOL_SHOW_LOG)));
284
		config.setAttribute(ILaunchManager.ATTR_LAUNCH_IN_BACKGROUND, FALSE.equals(args.get(TAG_TOOL_BLOCK)));
285
		String buildKinds= (String) args.get(TAG_TOOL_BUILD_TYPES);
286
		if (buildKinds != null) {
287
			buildKinds= buildKinds.replace(';', ','); // Replace the old separator with the new
288
		}
289
		config.setAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, buildKinds);
290
		config.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) args.get(TAG_TOOL_DIRECTORY));
291
		return config;
292
	}
293
294
	/**
295
	 * Returns a new working copy with the given external tool name and external
296
	 * tool type or <code>null</code> if no config could be created.
297
	 */
298
	private static ILaunchConfigurationWorkingCopy newConfig(String type, String name) {
299
		if (type == null || name == null) {
300
			return null;
301
		}
302
		ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
303
		ILaunchConfigurationType configType;
304
		if (TOOL_TYPE_ANT_BUILD.equals(type)) {
305
			configType = manager.getLaunchConfigurationType(ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE);
306
		} else if (IExternalToolConstants.TOOL_TYPE_PROGRAM.equals(type)) {
307
			configType = manager.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_BUILDER_LAUNCH_CONFIGURATION_TYPE);
308
		} else {
309
			return null;
310
		}
311
		try {
312
			if (configType != null) {
313
				return configType.newInstance(null, name);
314
			}
315
		} catch (CoreException e) {
316
			ExternalToolsCore.getDefault().log(e);
317
		}
318
		return null;
319
	}
320
	
321
	/**
322
	 * Returns the tool name extracted from the given command argument map.
323
	 * Extraction is attempted using 2.0 and 2.1 external tool formats.
324
	 */
325
	public static String getNameFromCommandArgs(Map commandArgs) {
326
		String name= (String) commandArgs.get(TAG_NAME);
327
		if (name == null) {
328
			name= (String) commandArgs.get(TAG_TOOL_NAME);
329
		}
330
		return name;
331
	}
332
	
333
	/**
334
	 * Migrate the old RUN_IN_BACKGROUND launch config attribute to the new
335
	 * LAUNCH_IN_BACKGROUND attribute provided by the debug ui plugin.
336
	 * 
337
	 * @param config the config to migrate
338
	 * @return the migrated config
339
	 */
340
	public static ILaunchConfiguration migrateRunInBackground(ILaunchConfiguration config) {
341
		String noValueFlag= "NoValue"; //$NON-NLS-1$
342
		String attr= null;
343
		try {
344
			attr = config.getAttribute(ILaunchManager.ATTR_LAUNCH_IN_BACKGROUND, noValueFlag);
345
		} catch (CoreException e) {
346
			// Exception will occur if the attribute is already set because the attribute is actually a boolean.
347
			// No migration necessary.
348
			return config;
349
		}
350
		if (noValueFlag.equals(attr)) {
351
			//the old constant
352
			String ATTR_RUN_IN_BACKGROUND= IExternalToolConstants.PLUGIN_ID + ".ATTR_RUN_IN_BACKGROUND"; //$NON-NLS-1$
353
			boolean runInBackground= false;
354
			try {
355
				runInBackground = config.getAttribute(ATTR_RUN_IN_BACKGROUND, runInBackground);
356
			} catch (CoreException e) {
357
				ExternalToolsCore.getDefault().log(ExternalToolsMigrationMessages.ExternalToolMigration_37, e);
358
			}
359
			try {
360
				ILaunchConfigurationWorkingCopy workingCopy= config.getWorkingCopy();
361
				workingCopy.setAttribute(ILaunchManager.ATTR_LAUNCH_IN_BACKGROUND, runInBackground);
362
				config= workingCopy.doSave();
363
			} catch (CoreException e) {
364
				ExternalToolsCore.getDefault().log(ExternalToolsMigrationMessages.ExternalToolMigration_38, e);
365
			}
366
		}
367
		return config;
368
	}
369
	
370
	/**
371
	 * Extracts a variable name and argument from the given string.
372
	 * 
373
	 * @param text the source text to parse for a variable tag
374
	 * @param start the index in the string to start the search
375
	 * @return the variable definition
376
	 */
377
	public static VariableDefinition extractVariableDefinition(String text, int start) {
378
		VariableDefinition varDef = new VariableDefinition();
379
		
380
		varDef.start = text.indexOf(VAR_TAG_START, start);
381
		if (varDef.start < 0){
382
			return varDef;
383
		}
384
		start = varDef.start + VAR_TAG_START.length();
385
		
386
		int end = text.indexOf(VAR_TAG_END, start);
387
		if (end < 0) {
388
			return varDef;
389
		}
390
		varDef.end = end + VAR_TAG_END.length();
391
		if (end == start) {
392
			return varDef;
393
		}
394
	
395
		int mid = text.indexOf(VAR_TAG_SEP, start);
396
		if (mid < 0 || mid > end) {
397
			varDef.name = text.substring(start, end);
398
		} else {
399
			if (mid > start) {
400
				varDef.name = text.substring(start, mid);
401
			}
402
			mid = mid + VAR_TAG_SEP.length();
403
			if (mid < end) {
404
				varDef.argument = text.substring(mid, end);
405
			}
406
		}
407
		
408
		return varDef;
409
	}	
410
}
(-)src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsLaunchConfigurationMessages.java (+26 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: 
8
 * IBM - Initial API and implementation
9
 * dakshinamurthy.karra@gmail.com - bug 165371
10
 **********************************************************************/
11
package org.eclipse.core.internal.externaltools.launchConfigurations;
12
13
import org.eclipse.osgi.util.NLS;
14
15
public class ExternalToolsLaunchConfigurationMessages extends NLS {
16
	private static final String BUNDLE_NAME = "org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsLaunchConfigurationMessages";//$NON-NLS-1$
17
18
	public static String ExternalToolsUtil_Location_not_specified_by__0__1;
19
	public static String ExternalToolsUtil_invalidLocation__0_;
20
	public static String ExternalToolsUtil_invalidDirectory__0_;
21
22
	static {
23
		// load message values from bundle file
24
		NLS.initializeMessages(BUNDLE_NAME, ExternalToolsLaunchConfigurationMessages.class);
25
	}
26
}
(-)src/org/eclipse/core/internal/externaltools/model/ExternalToolsModelMessages.java (+28 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: 
8
 * IBM - Initial API and implementation
9
 **********************************************************************/
10
package org.eclipse.core.internal.externaltools.model;
11
12
import org.eclipse.osgi.util.NLS;
13
14
public class ExternalToolsModelMessages extends NLS {
15
	private static final String BUNDLE_NAME = "org.eclipse.ui.externaltools.internal.model.ExternalToolsModelMessages";//$NON-NLS-1$
16
    
17
	public static String ImageDescriptorRegistry_Allocating_image_for_wrong_display_1;
18
	public static String ExternalToolBuilder_Running__0_____1;
19
	public static String ExternalToolBuilder_0;
20
	public static String BuilderUtils_5;
21
	public static String BuilderUtils_6;
22
	public static String BuilderUtils_7;
23
24
	static {
25
		// load message values from bundle file
26
		NLS.initializeMessages(BUNDLE_NAME, ExternalToolsModelMessages.class);
27
	}
28
}
(-)src/org/eclipse/core/internal/externaltools/model/ExternalToolsModelMessages.properties (+17 lines)
Added Link Here
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
12
ImageDescriptorRegistry_Allocating_image_for_wrong_display_1=Allocating image for wrong display
13
ExternalToolBuilder_Running__0_____1=Running {0}...
14
ExternalToolBuilder_0=The builder launch configuration could not be found.
15
BuilderUtils_5=Command Error
16
BuilderUtils_6=An error occurred while saving the build commands of the project
17
BuilderUtils_7=\ [Builder]
(-)src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsProgramMessages.properties (+19 lines)
Added Link Here
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
12
BackgroundResourceRefresher_0=Refreshing resources...
13
14
ProgramLaunchDelegate_Workbench_Closing_1=Workbench Closing
15
ProgramLaunchDelegate_The_workbench_is_exiting=The workbench is exiting and a program launched from an external tool appears to still be running. These programs will be terminated when the workbench exits. It is recommended that you exit any external programs launched from the workbench before you proceed.\n\nClick OK to continue exiting the workbench.
16
ProgramLaunchDelegate_3=Running {0}...
17
ProgramLaunchDelegate_4=An IProcess could not be created for the launch
18
19
ProgramMainTab_Select=&Select a program:
(-)src/org/eclipse/core/internal/externaltools/model/IExternalToolConstants.java (+231 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 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
 *     dakshinamurthy.karra@gmail.com - bug 165371
11
 *******************************************************************************/
12
package org.eclipse.core.internal.externaltools.model;
13
14
/**
15
 * Defines the constants available for client use.
16
 * <p>
17
 * This interface is not intended to be extended or implemented by clients.
18
 * </p>
19
 */
20
public interface IExternalToolConstants {
21
	/**
22
	 * Plugin identifier for external tools (value <code>org.eclipse.ui.externaltools</code>).
23
	 */
24
	public static final String PLUGIN_ID = "org.eclipse.ui.externaltools"; //$NON-NLS-1$;
25
26
	// ------- Extensions Points -------
27
	/**
28
	 * Extension point to declare the launch configuration type that should be
29
	 * created when duplicating an existing configuration as a project builder.
30
	 */
31
	public static final String EXTENSION_POINT_CONFIGURATION_DUPLICATION_MAPS = "configurationDuplicationMaps"; //$NON-NLS-1$
32
	// ------- Refresh Variables -------
33
	/**
34
	 * Variable that expands to the workspace root object (value <code>workspace</code>).
35
	 */
36
	public static final String VAR_WORKSPACE = "workspace"; //$NON-NLS-1$
37
	/**
38
	 * Variable that expands to the project resource (value <code>project</code>).
39
	 */
40
	public static final String VAR_PROJECT = "project"; //$NON-NLS-1$
41
	/**
42
	 * Variable that expands to the container resource (value <code>container</code>).
43
	 */
44
	public static final String VAR_CONTAINER = "container"; //$NON-NLS-1$
45
	/**
46
	 * Variable that expands to a resource (value <code>resource</code>).
47
	 */
48
	public static final String VAR_RESOURCE = "resource"; //$NON-NLS-1$
49
	/**
50
	 * Variable that expands to the working set object (value <code>working_set</code>).
51
	 */
52
	public static final String VAR_WORKING_SET = "working_set"; //$NON-NLS-1$
53
	// ------- Tool Types -------
54
	/**
55
	 * External tool type for programs such as executables, batch files, 
56
	 * shell scripts, etc (value <code>programType</code>).
57
	 */
58
	public static final String TOOL_TYPE_PROGRAM = "programType"; //$NON-NLS-1$;
59
60
	// ------- Build Types -------
61
	/**
62
	 * Build type indicating an incremental project build request for
63
	 * the external tool running as a builder (value <code>incremental</code>).
64
	 */
65
	public static final String BUILD_TYPE_INCREMENTAL = "incremental"; //$NON-NLS-1$
66
67
	/**
68
	 * Build type indicating a full project build request for
69
	 * the external tool running as a builder (value <code>full</code>).
70
	 */
71
	public static final String BUILD_TYPE_FULL = "full"; //$NON-NLS-1$
72
73
	/**
74
	 * Build type indicating an automatic project build request for
75
	 * the external tool running as a builder (value <code>auto</code>).
76
	 */
77
	public static final String BUILD_TYPE_AUTO = "auto"; //$NON-NLS-1$
78
	
79
	/**
80
	 * Build type indicating a clean project build request for
81
	 * the external tool running as a builder (value <code>clean</code>).
82
	 */
83
	public static final String BUILD_TYPE_CLEAN = "clean"; //$NON-NLS-1$
84
85
	/**
86
	 * Build type indicating no project build request for
87
	 * the external tool running as a builder (value <code>none</code>).
88
	 */
89
	public static final String BUILD_TYPE_NONE = "none"; //$NON-NLS-1$
90
91
	// ------- Images -------
92
93
	/**
94
	 * Main tab image.
95
	 */
96
	public static final String IMG_TAB_MAIN = PLUGIN_ID + ".IMG_TAB_MAIN"; //$NON-NLS-1$
97
98
	/**
99
	 * Build tab image
100
	 */
101
	public static final String IMG_TAB_BUILD = PLUGIN_ID + ".IMG_TAB_BUILD"; //$NON-NLS-1$
102
103
	// ------- Launch configuration types --------
104
	/**
105
	 * Program launch configuration type identifier.
106
	 */
107
	public static final String ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"; //$NON-NLS-1$
108
	
109
	/**
110
	 * Program builder launch configuration type identifier. Program project
111
	 * builders are of this type.
112
	 */
113
	public static final String ID_PROGRAM_BUILDER_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType"; //$NON-NLS-1$	
114
	
115
	// ------- Launch configuration category --------
116
	/**
117
	 * Identifier for external tools launch configuration category. Launch
118
	 * configuration types for external tools that appear in the external tools
119
	 * launch configuration dialog should belong to this category.
120
	 */
121
	public static final String ID_EXTERNAL_TOOLS_LAUNCH_CATEGORY = "org.eclipse.ui.externaltools"; //$NON-NLS-1$
122
	/**
123
	 * Identifier for external tools launch configuration builders category.
124
	 * Launch configuration types that can be added as project builders should
125
	 * belong to this category.
126
	 */
127
	public static final String ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY = "org.eclipse.ui.externaltools.builder"; //$NON-NLS-1$
128
129
	// ------- Launch configuration groups --------
130
	/**
131
	 * Identifier for external tools launch configuration group. The external
132
	 * tools launch configuration group corresponds to the external tools
133
	 * category in run mode.
134
	 */
135
	public static final String ID_EXTERNAL_TOOLS_LAUNCH_GROUP = "org.eclipse.ui.externaltools.launchGroup"; //$NON-NLS-1$
136
	/**
137
	 * Identifier for external tools launch configuration group
138
	 */
139
	public static final String ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_GROUP = "org.eclipse.ui.externaltools.launchGroup.builder"; //$NON-NLS-1$
140
141
	// ------- Common External Tool Launch Configuration Attributes -------
142
143
	/**
144
	 * Boolean attribute indicating if external tool output should be captured.
145
	 * Default value is <code>false</code>.
146
	 * @deprecated since 3.1 Replaced by <code>org.eclipse.debug.core.DebugPlugin.ATTR_CAPTURE_OUTPUT</code>
147
	 */
148
	public static final String ATTR_CAPTURE_OUTPUT = PLUGIN_ID + ".ATTR_CAPTURE_OUTPUT"; //$NON-NLS-1$
149
	/**
150
	 * String attribute identifying the location of an external. Default value
151
	 * is <code>null</code>. Encoding is tool specific.
152
	 */
153
	public static final String ATTR_LOCATION = PLUGIN_ID + ".ATTR_LOCATION"; //$NON-NLS-1$
154
155
	/**
156
	 * Boolean attribute indicating if the user should be prompted for
157
	 * arguments before running a tool. Default value is <code>false</code>.
158
	 * THIS ATTRIBUTE IS NOT USED.
159
	 */
160
	public static final String ATTR_PROMPT_FOR_ARGUMENTS = PLUGIN_ID + ".ATTR_PROMPT_FOR_ARGUMENTS"; //$NON-NLS-1$
161
	
162
	/**
163
	 * String attribute identifying the scope of resources that should trigger an 
164
	 * external tool to run. Default value is <code>null</code>
165
	 * indicating that the builder will be triggered for all changes.
166
	 */
167
	public static final String ATTR_BUILDER_SCOPE = PLUGIN_ID + ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$
168
		
169
	/**
170
	 * String attribute containing an array of build kinds for which an
171
	 * external tool builder should be run.
172
	 */
173
	public static final String ATTR_RUN_BUILD_KINDS = PLUGIN_ID + ".ATTR_RUN_BUILD_KINDS"; //$NON-NLS-1$
174
	
175
	/**
176
	 * Boolean attribute indicating if the console should be shown on external
177
	 * tool output. Default value is <code>false</code>.
178
	 */
179
	public static final String ATTR_SHOW_CONSOLE = PLUGIN_ID + ".ATTR_SHOW_CONSOLE"; //$NON-NLS-1$
180
181
	/**
182
	 * String attribute containing the arguments that should be passed to the
183
	 * tool. Default value is <code>null</code>, and encoding is tool specific.
184
	 */
185
	public static final String ATTR_TOOL_ARGUMENTS = PLUGIN_ID + ".ATTR_TOOL_ARGUMENTS"; //$NON-NLS-1$
186
187
	/**
188
	 * String attribute identifying the working directory of an external tool.
189
	 * Default value is <code>null</code>, which indicates a default working
190
	 * directory, which is tool specific.
191
	 */
192
	public static final String ATTR_WORKING_DIRECTORY = PLUGIN_ID + ".ATTR_WORKING_DIRECTORY"; //$NON-NLS-1$
193
	
194
	/**
195
	 * String attribute identifying whether an external tool builder configuration
196
	 * is enabled. The default value is <code>true</code>, which indicates
197
	 * that the configuration will be executed as appropriate by the builder.
198
	 */
199
	public static final String ATTR_BUILDER_ENABLED = PLUGIN_ID + ".ATTR_BUILDER_ENABLED"; //$NON-NLS-1$
200
	
201
	/**
202
	 * Status code indicating an unexpected internal error.
203
	 */
204
	public static final int ERR_INTERNAL_ERROR = 150;
205
206
	/**
207
	 * String attribute identifying a non-external tool builder launch configuration that is disabled
208
	 * The value is the name of the disabled builder.
209
	 */
210
	public static final String ATTR_DISABLED_BUILDER = PLUGIN_ID + ".ATTR_DISABLED_BUILDER";		 //$NON-NLS-1$
211
	
212
	/**
213
	 * boolean attribute identifying that an external tool builder has been configured for triggering
214
	 * using the <code>ICommand.setBuilding(int)</code> mechanism
215
	 * @since 3.1
216
	 */
217
	public static final String ATTR_TRIGGERS_CONFIGURED = PLUGIN_ID + ".ATTR_TRIGGERS_CONFIGURED";		 //$NON-NLS-1$
218
219
	/**
220
	 * String attribute identifying the build scope for a launch configuration.
221
	 * <code>null</code> indicates the default workspace build.
222
	 */
223
	public static final String ATTR_BUILD_SCOPE = PLUGIN_ID + ".ATTR_LAUNCH_CONFIGURATION_BUILD_SCOPE"; //$NON-NLS-1$
224
225
	/**
226
	 * Attribute identifier specifying whether referenced projects should be 
227
	 * considered when computing the projects to build. Default value is
228
	 * <code>true</code>.
229
	 */
230
	public static final String ATTR_INCLUDE_REFERENCED_PROJECTS = PLUGIN_ID + ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$
231
}
(-)src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsMigrationMessages.java (+72 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: 
8
 * IBM - Initial API and implementation
9
 **********************************************************************/
10
package org.eclipse.core.internal.externaltools.launchConfigurations;
11
12
import org.eclipse.osgi.util.NLS;
13
14
public class ExternalToolsMigrationMessages extends NLS {
15
	private static final String BUNDLE_NAME = "org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsUIMessages";//$NON-NLS-1$
16
17
	public static String BuilderPropertyPage_description;
18
	public static String BuilderPropertyPage_newButton;
19
	public static String BuilderPropertyPage_editButton;
20
	public static String BuilderPropertyPage_removeButton;
21
	public static String BuilderPropertyPage_upButton;
22
	public static String BuilderPropertyPage_downButton;
23
	public static String BuilderPropertyPage_statusMessage;
24
	public static String BuilderPropertyPage_errorTitle;
25
	public static String BuilderPropertyPage_errorMessage;
26
	public static String BuilderPropertyPage_invalidBuildTool;
27
	public static String BuilderPropertyPage_missingBuilder;
28
	public static String BuilderPropertyPage_Exists;
29
	public static String BuilderPropertyPage_External_Tool_Builder__0__Not_Added_2;
30
	public static String BuilderPropertyPage__Import____3;
31
	public static String BuilderPropertyPage_New_Builder_7;
32
	public static String BuilderPropertyPage_Choose_configuration_type_8;
33
	public static String BuilderPropertyPage_Choose_an_external_tool_type_to_create_9;
34
	public static String BuilderPropertyPage_Migrate_project_builder_10;
35
	public static String BuilderPropertyPage_Not_Support;
36
	public static String BuilderPropertyPage_Prompt;
37
	public static String BuilderPropertyPage_error;
38
	public static String BuilderPropertyPage_0;
39
	public static String BuilderPropertyPage_2;
40
	public static String BuilderPropertyPage_1;
41
	public static String BuilderPropertyPage_4;
42
	public static String BuilderPropertyPage_5;
43
	public static String BuilderPropertyPage_13;
44
	public static String BuilderPropertyPage_39;
45
	public static String BuilderPropertyPage_3;
46
	public static String BuilderPropertyPage_6;
47
	public static String BuilderPropertyPage_7;
48
	public static String BuilderPropertyPage_40;
49
50
	public static String FileSelectionDialog_Choose_Location_1;
51
	public static String FileSelectionDialog_Ok_2;
52
	public static String FileSelectionDialog_Cancel_3;
53
54
	public static String ExternalToolsPreferencePage_External_tool_project_builders_migration_2;
55
	public static String ExternalToolsPreferencePage_Prompt_before_migrating_3;
56
	public static String ExternalToolsPreferencePage_1;
57
58
	public static String ExternalToolMigration_37;
59
	public static String ExternalToolMigration_38;
60
	public static String EditCommandDialog_0;
61
	public static String EditCommandDialog_1;
62
	public static String EditCommandDialog_2;
63
	public static String EditCommandDialog_3;
64
	public static String EditCommandDialog_4;
65
	public static String EditCommandDialog_5;
66
67
	static {
68
		// load message values from bundle file
69
		NLS.initializeMessages(BUNDLE_NAME,
70
				ExternalToolsMigrationMessages.class);
71
	}
72
}
(-)src/org/eclipse/core/internal/externaltools/model/BuilderUtils.java (+385 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 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.externaltools.model;
12
13
import java.util.HashMap;
14
import java.util.Map;
15
import java.util.StringTokenizer;
16
17
import org.eclipse.core.internal.externaltools.registry.ExternalToolMigration;
18
import org.eclipse.core.resources.ICommand;
19
import org.eclipse.core.resources.IFile;
20
import org.eclipse.core.resources.IFolder;
21
import org.eclipse.core.resources.IProject;
22
import org.eclipse.core.resources.IResource;
23
import org.eclipse.core.resources.IncrementalProjectBuilder;
24
import org.eclipse.core.resources.ResourcesPlugin;
25
import org.eclipse.core.runtime.CoreException;
26
import org.eclipse.core.runtime.IConfigurationElement;
27
import org.eclipse.core.runtime.IExtensionPoint;
28
import org.eclipse.core.runtime.IPath;
29
import org.eclipse.core.runtime.IStatus;
30
import org.eclipse.core.runtime.NullProgressMonitor;
31
import org.eclipse.core.runtime.Path;
32
import org.eclipse.core.runtime.Platform;
33
import org.eclipse.debug.core.DebugPlugin;
34
import org.eclipse.debug.core.ILaunchConfiguration;
35
import org.eclipse.debug.core.ILaunchConfigurationType;
36
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
37
import org.eclipse.debug.core.ILaunchManager;
38
39
40
/**
41
 * Utility methods for working with external tool project builders.
42
 */
43
public class BuilderUtils {
44
45
	public static final String LAUNCH_CONFIG_HANDLE = "LaunchConfigHandle"; //$NON-NLS-1$
46
47
	/**
48
	 * Constant used to find a builder using the 3.0-interim format
49
	 */
50
	public static final String BUILDER_FOLDER_NAME= ".externalToolBuilders"; //$NON-NLS-1$
51
	/**
52
	 * Constant used to represent the current project in the 3.0-final format.
53
	 */
54
	public static final String PROJECT_TAG= "<project>"; //$NON-NLS-1$
55
	
56
	public static final String VERSION_1_0= "1.0"; //$NON-NLS-1$
57
	public static final String VERSION_2_1= "2.1"; //$NON-NLS-1$
58
	// The format shipped up to and including Eclipse 3.0 RC1
59
	public static final String VERSION_3_0_interim= "3.0.interim"; //$NON-NLS-1$
60
	// The format shipped in Eclipse 3.0 final
61
	public static final String VERSION_3_0_final= "3.0"; //$NON-NLS-1$
62
	
63
	// Extension point constants.
64
	private static final String TAG_CONFIGURATION_MAP= "configurationMap"; //$NON-NLS-1$
65
	private static final String TAG_SOURCE_TYPE= "sourceType"; //$NON-NLS-1$
66
	private static final String TAG_BUILDER_TYPE= "builderType"; //$NON-NLS-1$
67
    
68
    private static final String BUILD_TYPE_SEPARATOR = ","; //$NON-NLS-1$
69
    private static final int[] DEFAULT_BUILD_TYPES= new int[] {
70
                                    IncrementalProjectBuilder.INCREMENTAL_BUILD,
71
                                    IncrementalProjectBuilder.FULL_BUILD};
72
73
	/**
74
	 * Returns a launch configuration from the given ICommand arguments. If the
75
	 * given arguments are from an old-style external tool, an unsaved working
76
	 * copy will be created from the arguments and returned.
77
	 * 
78
	 * @param commandArgs the builder ICommand arguments
79
	 * @return a launch configuration, a launch configuration working copy, or
80
	 * <code>null</code> if not possible.
81
	 */
82
	public static ILaunchConfiguration configFromBuildCommandArgs(IProject project, Map commandArgs, String[] version) {
83
		String configHandle = (String) commandArgs.get(LAUNCH_CONFIG_HANDLE);
84
		if (configHandle == null) {
85
			// Probably an old-style (Eclipse 1.0 or 2.0) external tool. Try to migrate.
86
			version[0]= VERSION_1_0;
87
			return ExternalToolMigration.configFromArgumentMap(commandArgs);
88
		}
89
		ILaunchManager manager= DebugPlugin.getDefault().getLaunchManager();
90
		ILaunchConfiguration configuration= null;
91
		if (configHandle.startsWith(PROJECT_TAG)) {
92
			version[0]= VERSION_3_0_final;
93
			IPath path= new Path(configHandle);
94
			IFile file= project.getFile(path.removeFirstSegments(1));
95
			if (file.exists()) {
96
				configuration= manager.getLaunchConfiguration(file);
97
			}
98
		} else {
99
		    // Try treating the handle as a file name.
100
			// This is the format used in 3.0 RC1.
101
			IPath path= new Path(BUILDER_FOLDER_NAME).append(configHandle);
102
			IFile file= project.getFile(path);
103
			if (file.exists()) {
104
				version[0]= VERSION_3_0_interim;
105
				configuration= manager.getLaunchConfiguration(file);
106
			} else {
107
				try {
108
					// Treat the configHandle as a memento. This is the format
109
					// used in Eclipse 2.1.
110
					configuration = manager.getLaunchConfiguration(configHandle);
111
				} catch (CoreException e) {
112
				}
113
				if (configuration != null) {
114
					version[0]= VERSION_2_1;
115
				}
116
			}
117
		}
118
		return configuration;
119
	}
120
121
//	/**
122
//	 * Returns an <code>ICommand</code> from the given launch configuration.
123
//	 * 
124
//	 * @param project the project the ICommand is relevant to
125
//	 * @param config the launch configuration to create the command from
126
//	 * @return the new command. <code>null</code> can be returned if problems occur during
127
//	 * the translation.
128
//	 */
129
//	public static ICommand commandFromLaunchConfig(IProject project, ILaunchConfiguration config) {
130
//		ICommand newCommand = null;
131
//		try {
132
//			newCommand = project.getDescription().newCommand();
133
//			newCommand = toBuildCommand(project, config, newCommand);
134
//			configureTriggers(config, newCommand);
135
//		} catch (CoreException exception) {
136
//			Shell shell= ExternalToolsPlugin.getActiveWorkbenchShell();
137
//			if (shell != null) {
138
//				MessageDialog.openError(shell, ExternalToolsModelMessages.BuilderUtils_5, ExternalToolsModelMessages.BuilderUtils_6);
139
//			}
140
//			return null;
141
//		}
142
//		return newCommand;
143
//	}
144
	
145
	public static void configureTriggers(ILaunchConfiguration config, ICommand newCommand) throws CoreException {
146
		newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD, false);
147
		newCommand.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, false);
148
		newCommand.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, false);
149
		newCommand.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, false);
150
		String buildKinds= config.getAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, (String)null);
151
		int[] triggers= BuilderUtils.buildTypesToArray(buildKinds);
152
		for (int i = 0; i < triggers.length; i++) {
153
			switch (triggers[i]) {
154
				case IncrementalProjectBuilder.FULL_BUILD:
155
					newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD, true);
156
					break;
157
				case IncrementalProjectBuilder.INCREMENTAL_BUILD:
158
					newCommand.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, true);
159
					break;
160
				case IncrementalProjectBuilder.AUTO_BUILD:
161
					newCommand.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, true);
162
					break;
163
				case IncrementalProjectBuilder.CLEAN_BUILD:
164
					newCommand.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, true);
165
					break;
166
			}
167
		}
168
		if (!config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false)) {
169
			ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
170
			copy.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, true);
171
			copy.doSave();
172
		}
173
	}
174
175
	/**
176
	 * Returns whether the given configuration is an "unmigrated" builder.
177
	 * Unmigrated builders are external tools that are stored in an old format
178
	 * but have not been migrated by the user. Old format builders are always
179
	 * translated into launch config working copies in memory, but they're not
180
	 * considered "migrated" until the config has been saved and the project spec
181
	 * updated.
182
	 * @param config the config to examine
183
	 * @return whether the given config represents an unmigrated builder
184
	 */
185
	public static boolean isUnmigratedConfig(ILaunchConfiguration config) {
186
		return config.isWorkingCopy() && ((ILaunchConfigurationWorkingCopy) config).getOriginal() == null;
187
	}
188
189
	/**
190
	 * Converts the given config to a build command which is stored in the
191
	 * given command.
192
	 *
193
	 * @return the configured build command
194
	 */
195
	public static ICommand toBuildCommand(IProject project, ILaunchConfiguration config, ICommand command) throws CoreException {
196
		Map args= null;
197
		if (isUnmigratedConfig(config)) {
198
			// This config represents an old external tool builder that hasn't
199
			// been edited. Try to find the old ICommand and reuse the arguments.
200
			// The goal here is to not change the storage format of old, unedited builders.
201
			ICommand[] commands= project.getDescription().getBuildSpec();
202
			for (int i = 0; i < commands.length; i++) {
203
				ICommand projectCommand = commands[i];
204
				String name= ExternalToolMigration.getNameFromCommandArgs(projectCommand.getArguments());
205
				if (name != null && name.equals(config.getName())) {
206
					args= projectCommand.getArguments();
207
					break;
208
				}
209
			}
210
		} else {
211
			if (config instanceof ILaunchConfigurationWorkingCopy) {
212
				ILaunchConfigurationWorkingCopy workingCopy= (ILaunchConfigurationWorkingCopy) config;
213
				if (workingCopy.getOriginal() != null) {
214
					config= workingCopy.getOriginal();
215
				}
216
			}
217
			args= new HashMap();
218
			// Launch configuration builders are stored with a project-relative path
219
			StringBuffer buffer= new StringBuffer(PROJECT_TAG);
220
			// Append the project-relative path (workspace path minus first segment)
221
			buffer.append('/').append(config.getFile().getFullPath().removeFirstSegments(1));
222
			args.put(LAUNCH_CONFIG_HANDLE, buffer.toString());
223
		}
224
		command.setBuilderName(ExternalToolBuilder.ID);
225
		command.setArguments(args);
226
		return command;
227
	}
228
	
229
	/**
230
	 * Returns the type of launch configuration that should be created when
231
	 * duplicating the given configuration as a project builder. Queries to see
232
	 * if an extension has been specified to explicitly declare the mapping.
233
	 */
234
	public static ILaunchConfigurationType getConfigurationDuplicationType(ILaunchConfiguration config) throws CoreException {
235
		IExtensionPoint ep= Platform.getExtensionRegistry().getExtensionPoint(IExternalToolConstants.PLUGIN_ID, IExternalToolConstants.EXTENSION_POINT_CONFIGURATION_DUPLICATION_MAPS); 
236
		IConfigurationElement[] elements = ep.getConfigurationElements();
237
		String sourceType= config.getType().getIdentifier();
238
		String builderType= null;
239
		for (int i= 0; i < elements.length; i++) {
240
			IConfigurationElement element= elements[i];
241
			if (element.getName().equals(TAG_CONFIGURATION_MAP) && sourceType.equals(element.getAttribute(TAG_SOURCE_TYPE))) {
242
				builderType= element.getAttribute(TAG_BUILDER_TYPE);
243
				break;
244
			}
245
		}
246
		if (builderType != null) {
247
			ILaunchConfigurationType type= DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(builderType);
248
			if (type != null) {
249
				return type;
250
			}
251
		}
252
		return config.getType();
253
	}
254
255
	/**
256
	 * Returns the folder where project builders should be stored or
257
	 * <code>null</code> if the folder could not be created
258
	 */
259
	public static IFolder getBuilderFolder(IProject project, boolean create) {
260
		IFolder folder = project.getFolder(BUILDER_FOLDER_NAME);
261
		if (!folder.exists() && create) {
262
			try {
263
				folder.create(true, true, new NullProgressMonitor());
264
			} catch (CoreException e) {
265
				return null;
266
			}
267
		}
268
		return folder;
269
	}
270
271
	/**
272
	 * Returns a duplicate of the given configuration. The new configuration
273
	 * will be of the same type as the given configuration or of the duplication
274
	 * type registered for the given configuration via the extension point
275
	 * IExternalToolConstants.EXTENSION_POINT_CONFIGURATION_DUPLICATION_MAPS.
276
	 */
277
	public static ILaunchConfiguration duplicateConfiguration(IProject project, ILaunchConfiguration config) throws CoreException {
278
		Map attributes= config.getAttributes();
279
		String newName= new StringBuffer(config.getName()).append(ExternalToolsModelMessages.BuilderUtils_7).toString();
280
		newName= DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(newName);
281
		ILaunchConfigurationType newType= getConfigurationDuplicationType(config);
282
		ILaunchConfigurationWorkingCopy newWorkingCopy= newType.newInstance(getBuilderFolder(project, true), newName);
283
		newWorkingCopy.setAttributes(attributes);
284
		return newWorkingCopy.doSave();
285
	}
286
287
	/**
288
	 * Migrates the launch configuration working copy, which is based on an old-
289
	 * style external tool builder, to a new, saved launch configuration. The
290
	 * returned launch configuration will contain the same attributes as the
291
	 * given working copy with the exception of the configuration name, which
292
	 * may be changed during the migration. The name of the configuration will
293
	 * only be changed if the current name is not a valid name for a saved
294
	 * config.
295
	 * 
296
	 * @param workingCopy the launch configuration containing attributes from an
297
	 * old-style project builder.
298
	 * @return ILaunchConfiguration a new, saved launch configuration whose
299
	 * attributes match those of the given working copy as well as possible
300
	 * @throws CoreException if an exception occurs while attempting to save the
301
	 * new launch configuration
302
	 */
303
	public static ILaunchConfiguration migrateBuilderConfiguration(IProject project, ILaunchConfigurationWorkingCopy workingCopy) throws CoreException {
304
		workingCopy.setContainer(getBuilderFolder(project, true));
305
		// Before saving, make sure the name is valid
306
		String name= workingCopy.getName();
307
		name= name.replace('/', '.');
308
		if (name.charAt(0) == ('.')) {
309
			name = name.substring(1);
310
		}
311
		IStatus status = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
312
		if (!status.isOK()) {
313
			name = "ExternalTool"; //$NON-NLS-1$
314
		}
315
		name = DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(name);
316
		workingCopy.rename(name);
317
		return workingCopy.doSave();
318
	}
319
320
    /**
321
     * Converts the build types string into an array of
322
     * build kinds.
323
     *
324
     * @param buildTypes the string of built types to convert
325
     * @return the array of build kinds.
326
     */
327
    public static int[] buildTypesToArray(String buildTypes) {
328
    	if (buildTypes == null || buildTypes.length() == 0) {
329
    		return DEFAULT_BUILD_TYPES;
330
    	}
331
    	
332
    	int count = 0;
333
    	boolean incremental = false;
334
    	boolean full = false;
335
    	boolean auto = false;
336
        boolean clean= false;
337
    
338
    	StringTokenizer tokenizer = new StringTokenizer(buildTypes, BUILD_TYPE_SEPARATOR);
339
    	while (tokenizer.hasMoreTokens()) {
340
    		String token = tokenizer.nextToken();
341
    		if (IExternalToolConstants.BUILD_TYPE_INCREMENTAL.equals(token)) {
342
    			if (!incremental) {
343
    				incremental = true;
344
    				count++;
345
    			}
346
    		} else if (IExternalToolConstants.BUILD_TYPE_FULL.equals(token)) {
347
    			if (!full) {
348
    				full = true;
349
    				count++;
350
    			}
351
    		} else if (IExternalToolConstants.BUILD_TYPE_AUTO.equals(token)) {
352
    			if (!auto) {
353
    				auto = true;
354
    				count++;
355
    			}
356
    		} else if (IExternalToolConstants.BUILD_TYPE_CLEAN.equals(token)) {
357
                if (!clean) {
358
                    clean = true;
359
                    count++;
360
                }
361
            }
362
    	}
363
    
364
    	int[] results = new int[count];
365
    	count = 0;
366
    	if (incremental) {
367
    		results[count] = IncrementalProjectBuilder.INCREMENTAL_BUILD;
368
    		count++;
369
    	}
370
    	if (full) {
371
    		results[count] = IncrementalProjectBuilder.FULL_BUILD;
372
    		count++;
373
    	}
374
    	if (auto) {
375
    		results[count] = IncrementalProjectBuilder.AUTO_BUILD;
376
    		count++;
377
    	}
378
        if (clean) {
379
            results[count] = IncrementalProjectBuilder.CLEAN_BUILD;
380
            count++;
381
        }
382
    
383
    	return results;
384
    }
385
}
(-)plugin.xml (+21 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
 <extension
5
         point="org.eclipse.debug.core.launchConfigurationTypes">
6
      <launchConfigurationType
7
            name="%Program.externalTools"
8
            delegate="org.eclipse.core.internal.externaltools.launchConfigurations.ProgramLaunchDelegate"
9
            category="org.eclipse.ui.externaltools"
10
            modes="run"
11
            id="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
12
      </launchConfigurationType>
13
      <launchConfigurationType
14
            name="%Program.externalTools"
15
            delegate="org.eclipse.core.internal.externaltools.launchConfigurations.ProgramLaunchDelegate"
16
            category="org.eclipse.ui.externaltools.builder"
17
            modes="run"
18
            id="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
19
      </launchConfigurationType>
20
   </extension>
21
</plugin>
(-)src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsProgramMessages.java (+26 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others. All rights reserved.   This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: 
8
 * IBM - Initial API and implementation
9
 **********************************************************************/
10
package org.eclipse.core.internal.externaltools.launchConfigurations;
11
12
import org.eclipse.osgi.util.NLS;
13
14
public class ExternalToolsProgramMessages extends NLS {
15
	private static final String BUNDLE_NAME = "org.eclipse.core.externaltools.internal.program.launchConfigurations.ExternalToolsProgramMessages";//$NON-NLS-1$
16
17
	public static String BackgroundResourceRefresher_0;
18
19
	public static String ProgramLaunchDelegate_3;
20
	public static String ProgramLaunchDelegate_4;
21
22
	static {
23
		// load message values from bundle file
24
		NLS.initializeMessages(BUNDLE_NAME, ExternalToolsProgramMessages.class);
25
	}
26
}
(-)src/org/eclipse/core/internal/externaltools/launchConfigurations/ProgramLaunchDelegate.java (+207 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 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
 *     Keith Seitz (keiths@redhat.com) - environment variables contribution (Bug 27243)
11
 *     dakshinamurthy.karra@gmail.com - bug 165371
12
 *******************************************************************************/
13
package org.eclipse.core.internal.externaltools.launchConfigurations;
14
15
import java.io.File;
16
import java.util.HashMap;
17
import java.util.Map;
18
19
import org.eclipse.core.internal.externaltools.model.IExternalToolConstants;
20
import org.eclipse.core.resources.IProject;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IPath;
23
import org.eclipse.core.runtime.IProgressMonitor;
24
import org.eclipse.core.runtime.IStatus;
25
import org.eclipse.core.runtime.Status;
26
import org.eclipse.debug.core.DebugPlugin;
27
import org.eclipse.debug.core.ILaunch;
28
import org.eclipse.debug.core.ILaunchConfiguration;
29
import org.eclipse.debug.core.model.IProcess;
30
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
31
import org.eclipse.debug.internal.core.LaunchManager;
32
import org.eclipse.osgi.util.NLS;
33
34
/**
35
 * Launch delegate for a program.
36
 */
37
public class ProgramLaunchDelegate extends LaunchConfigurationDelegate {
38
39
	/**
40
	 * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration,
41
	 *      java.lang.String, org.eclipse.debug.core.ILaunch,
42
	 *      org.eclipse.core.runtime.IProgressMonitor)
43
	 */
44
	public void launch(ILaunchConfiguration configuration, String mode,
45
			ILaunch launch, IProgressMonitor monitor) throws CoreException {
46
47
		if (monitor.isCanceled()) {
48
			return;
49
		}
50
51
		// resolve location
52
		IPath location = ExternalToolsCoreUtil.getLocation(configuration);
53
54
		if (monitor.isCanceled()) {
55
			return;
56
		}
57
58
		// resolve working directory
59
		IPath workingDirectory = ExternalToolsCoreUtil
60
				.getWorkingDirectory(configuration);
61
62
		if (monitor.isCanceled()) {
63
			return;
64
		}
65
66
		// resolve arguments
67
		String[] arguments = ExternalToolsCoreUtil.getArguments(configuration);
68
69
		if (monitor.isCanceled()) {
70
			return;
71
		}
72
73
		int cmdLineLength = 1;
74
		if (arguments != null) {
75
			cmdLineLength += arguments.length;
76
		}
77
		String[] cmdLine = new String[cmdLineLength];
78
		cmdLine[0] = location.toOSString();
79
		if (arguments != null) {
80
			System.arraycopy(arguments, 0, cmdLine, 1, arguments.length);
81
		}
82
83
		File workingDir = null;
84
		if (workingDirectory != null) {
85
			workingDir = workingDirectory.toFile();
86
		}
87
88
		if (monitor.isCanceled()) {
89
			return;
90
		}
91
92
		String[] envp = DebugPlugin.getDefault().getLaunchManager()
93
				.getEnvironment(configuration);
94
95
		if (monitor.isCanceled()) {
96
			return;
97
		}
98
99
		Process p = DebugPlugin.exec(cmdLine, workingDir, envp);
100
		IProcess process = null;
101
102
		// add process type to process attributes
103
		Map processAttributes = new HashMap();
104
		String programName = location.lastSegment();
105
		String extension = location.getFileExtension();
106
		if (extension != null) {
107
			programName = programName.substring(0, programName.length()
108
					- (extension.length() + 1));
109
		}
110
		programName = programName.toLowerCase();
111
		processAttributes.put(IProcess.ATTR_PROCESS_TYPE, programName);
112
113
		if (p != null) {
114
			monitor.beginTask(NLS.bind(
115
					ExternalToolsProgramMessages.ProgramLaunchDelegate_3,
116
					new String[] { configuration.getName() }),
117
					IProgressMonitor.UNKNOWN);
118
			process = DebugPlugin.newProcess(launch, p, location.toOSString(),
119
					processAttributes);
120
		}
121
		if (p == null || process == null) {
122
			if (p != null)
123
				p.destroy();
124
			throw new CoreException(new Status(IStatus.ERROR,
125
					IExternalToolConstants.PLUGIN_ID,
126
					IExternalToolConstants.ERR_INTERNAL_ERROR,
127
					ExternalToolsProgramMessages.ProgramLaunchDelegate_4, null));
128
		}
129
		process.setAttribute(IProcess.ATTR_CMDLINE,
130
				generateCommandLine(cmdLine));
131
132
		if (LaunchManager.isLaunchInBackground(configuration)) {
133
			// refresh resources after process finishes
134
			if (LaunchManager.getRefreshScope(configuration) != null) {
135
				BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(
136
						configuration, process);
137
				refresher.startBackgroundRefresh();
138
			}
139
		} else {
140
			// wait for process to exit
141
			while (!process.isTerminated()) {
142
				try {
143
					if (monitor.isCanceled()) {
144
						process.terminate();
145
						break;
146
					}
147
					Thread.sleep(50);
148
				} catch (InterruptedException e) {
149
				}
150
			}
151
152
			// refresh resources
153
			LaunchManager.refreshResources(configuration, monitor);
154
		}
155
	}
156
157
	private String generateCommandLine(String[] commandLine) {
158
		if (commandLine.length < 1)
159
			return ""; //$NON-NLS-1$
160
		StringBuffer buf = new StringBuffer();
161
		for (int i = 0; i < commandLine.length; i++) {
162
			buf.append(' ');
163
			char[] characters = commandLine[i].toCharArray();
164
			StringBuffer command = new StringBuffer();
165
			boolean containsSpace = false;
166
			for (int j = 0; j < characters.length; j++) {
167
				char character = characters[j];
168
				if (character == '\"') {
169
					command.append('\\');
170
				} else if (character == ' ') {
171
					containsSpace = true;
172
				}
173
				command.append(character);
174
			}
175
			if (containsSpace) {
176
				buf.append('\"');
177
				buf.append(command);
178
				buf.append('\"');
179
			} else {
180
				buf.append(command);
181
			}
182
		}
183
		return buf.toString();
184
	}
185
186
	/*
187
	 * (non-Javadoc)
188
	 * 
189
	 * @see
190
	 * org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder
191
	 * (org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
192
	 */
193
	protected IProject[] getBuildOrder(ILaunchConfiguration configuration,
194
			String mode) throws CoreException {
195
		IProject[] projects = ExternalToolsCoreUtil.getBuildProjects(configuration,
196
				null);
197
		if (projects == null) {
198
			return null;
199
		}
200
		boolean isRef = ExternalToolsCoreUtil.isIncludeReferencedProjects(
201
				configuration, null);
202
		if (isRef) {
203
			return computeReferencedBuildOrder(projects);
204
		}
205
		return computeBuildOrder(projects);
206
	}
207
}
(-)src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsMigrationMessages.properties (+60 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2000, 2006 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
12
BuilderPropertyPage_description = Configure the builders for the &project:
13
BuilderPropertyPage_newButton = &New...
14
BuilderPropertyPage_editButton = &Edit...
15
BuilderPropertyPage_removeButton = &Remove
16
BuilderPropertyPage_upButton = &Up
17
BuilderPropertyPage_downButton = &Down
18
BuilderPropertyPage_statusMessage = Internal error
19
BuilderPropertyPage_errorTitle = External Tool Builder Problem
20
BuilderPropertyPage_errorMessage = Internal error
21
BuilderPropertyPage_invalidBuildTool = Invalid External Tool Builder
22
BuilderPropertyPage_missingBuilder = Missing builder ({0})
23
BuilderPropertyPage_Exists=Builder launch configuration {0} no longer exists
24
BuilderPropertyPage_External_Tool_Builder__0__Not_Added_2=External Tool Builder {0} Not Added
25
BuilderPropertyPage__Import____3=&Import...
26
BuilderPropertyPage_New_Builder_7=New_Builder
27
BuilderPropertyPage_Choose_configuration_type_8=Choose configuration type
28
BuilderPropertyPage_Choose_an_external_tool_type_to_create_9=&Choose an external tool type to create:
29
BuilderPropertyPage_Migrate_project_builder_10=Migrate project builder
30
BuilderPropertyPage_Not_Support=This project builder is stored in a format that is no longer supported. If you wish to edit this builder, it will first be migrated to a new format. If you proceed, this project builder will not be understood by installations using the old format.\n\nProceed with migration?
31
BuilderPropertyPage_Prompt=&Do not prompt before migrating project builders
32
BuilderPropertyPage_error=An error occurred while saving the project\'s build commands
33
BuilderPropertyPage_0=Project Migration
34
BuilderPropertyPage_2=&Do not prompt before migrating projects
35
BuilderPropertyPage_1=This project stores its builders in a format that is no longer supported. If any changes are made, the project will be migrated to the new format which will not be understood by installations using the old format.\n\nProceed? (Selecting "No" will open the page read-only)
36
BuilderPropertyPage_4=Import launch configuration
37
BuilderPropertyPage_5=&Choose a launch configuration from the workspace to import.\nThis will create a copy of the selected configuration.
38
BuilderPropertyPage_13=Command error
39
BuilderPropertyPage_39=Error Saving Builder
40
BuilderPropertyPage_3=Updating builders...
41
BuilderPropertyPage_6=Confirm Disable Builder
42
BuilderPropertyPage_7=This is an advanced operation. Disabling a project builder can have many side-effects. Continue?
43
BuilderPropertyPage_40=An exception occurred while attempting to save builder {0}
44
45
FileSelectionDialog_Choose_Location_1=Choose Location
46
FileSelectionDialog_Ok_2=OK
47
FileSelectionDialog_Cancel_3=Cancel
48
49
ExternalToolsPreferencePage_External_tool_project_builders_migration_2=External tool project builders stored in an old format will be migrated to a new format when edited. Projects which store builders using an old format will be migrated whenever a change is made. Once migrated, project builders will not be understood by installations using these older formats.
50
ExternalToolsPreferencePage_Prompt_before_migrating_3=&Confirm before migrating external tool project builders for edit
51
ExternalToolsPreferencePage_1=C&onfirm before migrating projects to the new format
52
53
ExternalToolMigration_37=An exception occurred accessing external tool\'s \"run in background\" attribute
54
ExternalToolMigration_38=An exception occurred attempting to migrate external tool\'s \"run in background\" attribute
55
EditCommandDialog_0=Configure Builder
56
EditCommandDialog_1=Run this builder:
57
EditCommandDialog_2=After a "&Clean"
58
EditCommandDialog_3=During &manual builds
59
EditCommandDialog_4=During &auto builds
60
EditCommandDialog_5=&During a "Clean"
(-)src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsLaunchConfigurationMessages.properties (+15 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2000, 2007 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
#     dakshinamurthy.karra@gmail.com - bug 165371
11
###############################################################################
12
13
ExternalToolsUtil_Location_not_specified_by__0__1=Location not specified by {0}
14
ExternalToolsUtil_invalidLocation__0_ = The file does not exist for the external tool named {0}.
15
ExternalToolsUtil_invalidDirectory__0_ = The working directory {0} does not exist for the external tool named {1}.
(-)src/org/eclipse/core/internal/externaltools/launchConfigurations/BackgroundResourceRefresher.java (+89 lines)
Added Link Here
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.externaltools.launchConfigurations;
12
13
14
import org.eclipse.core.internal.externaltools.ExternalToolsCore;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.Status;
19
import org.eclipse.core.runtime.jobs.Job;
20
import org.eclipse.debug.core.DebugEvent;
21
import org.eclipse.debug.core.DebugPlugin;
22
import org.eclipse.debug.core.IDebugEventSetListener;
23
import org.eclipse.debug.core.ILaunchConfiguration;
24
import org.eclipse.debug.core.model.IProcess;
25
import org.eclipse.debug.internal.core.LaunchManager;
26
27
/**
28
 * Refreshes resources as specified by a launch configuration, when 
29
 * an associated process terminates.
30
 */
31
public class BackgroundResourceRefresher implements IDebugEventSetListener  {
32
33
	private ILaunchConfiguration fConfiguration;
34
	private IProcess fProcess;
35
	
36
	
37
	
38
	public BackgroundResourceRefresher(ILaunchConfiguration configuration, IProcess process) {
39
		fConfiguration = configuration;
40
		fProcess = process;
41
	}
42
	
43
	/**
44
	 * If the process has already terminated, resource refreshing is done
45
	 * immediately in the current thread. Otherwise, refreshing is done when the
46
	 * process terminates.
47
	 */
48
	public void startBackgroundRefresh() {
49
		synchronized (fProcess) {
50
			if (fProcess.isTerminated()) {
51
				refresh();
52
			} else {
53
				DebugPlugin.getDefault().addDebugEventListener(this);
54
			}
55
		}
56
	}
57
	
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
60
	 */
61
	public void handleDebugEvents(DebugEvent[] events) {
62
		for (int i = 0; i < events.length; i++) {
63
			DebugEvent event = events[i];
64
			if (event.getSource() == fProcess && event.getKind() == DebugEvent.TERMINATE) {
65
				DebugPlugin.getDefault().removeDebugEventListener(this);
66
				refresh();
67
				break;
68
			}
69
		}
70
	}
71
	
72
	/**
73
	 * Submits a job to do the refresh
74
	 */
75
	protected void refresh() {
76
		Job job= new Job(ExternalToolsProgramMessages.BackgroundResourceRefresher_0) {
77
			public IStatus run(IProgressMonitor monitor) {
78
				try {
79
					LaunchManager.refreshResources(fConfiguration, monitor);
80
				} catch (CoreException e) {
81
					ExternalToolsCore.log(e);
82
					return e.getStatus();
83
				}	
84
				return Status.OK_STATUS;
85
			}
86
		};
87
		job.schedule();
88
	}
89
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/AddBuildFilesAction.java (-2 / +3 lines)
Lines 13-20 Link Here
13
import java.lang.reflect.InvocationTargetException;
13
import java.lang.reflect.InvocationTargetException;
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.List;
15
import java.util.List;
16
17
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
16
import org.eclipse.ant.internal.ui.AntUIImages;
18
import org.eclipse.ant.internal.ui.AntUIImages;
17
import org.eclipse.ant.internal.ui.AntUtil;
18
import org.eclipse.ant.internal.ui.IAntUIConstants;
19
import org.eclipse.ant.internal.ui.IAntUIConstants;
19
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
20
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
20
import org.eclipse.ant.internal.ui.model.AntProjectNode;
21
import org.eclipse.ant.internal.ui.model.AntProjectNode;
Lines 89-95 Link Here
89
		List buildFiles= new ArrayList(existingProjects.length);
90
		List buildFiles= new ArrayList(existingProjects.length);
90
		for (int j = 0; j < existingProjects.length; j++) {
91
		for (int j = 0; j < existingProjects.length; j++) {
91
			AntProjectNode existingProject = existingProjects[j];
92
			AntProjectNode existingProject = existingProjects[j];
92
			buildFiles.add(AntUtil.getFile(existingProject.getBuildFileName()));
93
			buildFiles.add(AntLaunchingUtil.getFile(existingProject.getBuildFileName()));
93
		}
94
		}
94
		return buildFiles;
95
		return buildFiles;
95
	}
96
	}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/model/AntProjectNodeProxy.java (-2 / +3 lines)
Lines 14-19 Link Here
14
import java.util.Collections;
14
import java.util.Collections;
15
import java.util.List;
15
import java.util.List;
16
16
17
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
17
import org.eclipse.ant.internal.ui.AntUtil;
18
import org.eclipse.ant.internal.ui.AntUtil;
18
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.runtime.IPath;
20
import org.eclipse.core.runtime.IPath;
Lines 54-60 Link Here
54
		fChildNodes= null;
55
		fChildNodes= null;
55
		fParsed= true;
56
		fParsed= true;
56
		AntTargetNode[] nodes = null;
57
		AntTargetNode[] nodes = null;
57
		IPath buildFilePath= AntUtil.getFile(getBuildFileName()).getLocation();
58
		IPath buildFilePath= AntLaunchingUtil.getFile(getBuildFileName()).getLocation();
58
		if (buildFilePath == null) {
59
		if (buildFilePath == null) {
59
			setProblemSeverity(AntModelProblem.SEVERITY_ERROR);
60
			setProblemSeverity(AntModelProblem.SEVERITY_ERROR);
60
			setProblemMessage(AntModelMessages.AntProjectNodeProxy_0);
61
			setProblemMessage(AntModelMessages.AntProjectNodeProxy_0);
Lines 256-262 Link Here
256
	public IFile getBuildFileResource() {
257
	public IFile getBuildFileResource() {
257
		if (fProject == null) {
258
		if (fProject == null) {
258
			if (fBuildFileName != null) {
259
			if (fBuildFileName != null) {
259
				return AntUtil.getFile(fBuildFileName);
260
				return AntLaunchingUtil.getFile(fBuildFileName);
260
			}
261
			}
261
		}
262
		}
262
		return super.getBuildFileResource();
263
		return super.getBuildFileResource();
(-)Ant Tools Support/org/eclipse/ant/internal/ui/model/AntImportNode.java (-3 / +3 lines)
Lines 14-21 Link Here
14
import org.apache.tools.ant.BuildException;
14
import org.apache.tools.ant.BuildException;
15
import org.apache.tools.ant.Task;
15
import org.apache.tools.ant.Task;
16
import org.eclipse.ant.core.AntSecurityException;
16
import org.eclipse.ant.core.AntSecurityException;
17
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
17
import org.eclipse.ant.internal.ui.AntUIImages;
18
import org.eclipse.ant.internal.ui.AntUIImages;
18
import org.eclipse.ant.internal.ui.AntUtil;
19
import org.eclipse.ant.internal.ui.IAntUIConstants;
19
import org.eclipse.ant.internal.ui.IAntUIConstants;
20
import org.eclipse.ant.internal.ui.editor.AntEditorCompletionProcessor;
20
import org.eclipse.ant.internal.ui.editor.AntEditorCompletionProcessor;
21
import org.eclipse.ant.internal.ui.preferences.AntEditorPreferenceConstants;
21
import org.eclipse.ant.internal.ui.preferences.AntEditorPreferenceConstants;
Lines 82-91 Link Here
82
	public IFile getIFile() {
82
	public IFile getIFile() {
83
		IFile file;
83
		IFile file;
84
		if (isExternal()) {
84
		if (isExternal()) {
85
			file= AntUtil.getFileForLocation(getFilePath(), null);
85
			file= AntLaunchingUtil.getFileForLocation(getFilePath(), null);
86
		} else {
86
		} else {
87
			String path= getFile();
87
			String path= getFile();
88
			file= AntUtil.getFileForLocation(path, getAntModel().getEditedFile().getParentFile());
88
			file= AntLaunchingUtil.getFileForLocation(path, getAntModel().getEditedFile().getParentFile());
89
		}
89
		}
90
		return file;
90
		return file;
91
	}
91
	}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementNode.java (-3 / +4 lines)
Lines 18-31 Link Here
18
import java.io.File;
18
import java.io.File;
19
import java.net.MalformedURLException;
19
import java.net.MalformedURLException;
20
import java.net.URL;
20
import java.net.URL;
21
import com.ibm.icu.text.MessageFormat;
22
import java.util.ArrayList;
21
import java.util.ArrayList;
23
import java.util.Iterator;
22
import java.util.Iterator;
24
import java.util.List;
23
import java.util.List;
25
24
25
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
26
import org.eclipse.ant.internal.ui.AntImageDescriptor;
26
import org.eclipse.ant.internal.ui.AntImageDescriptor;
27
import org.eclipse.ant.internal.ui.AntUIImages;
27
import org.eclipse.ant.internal.ui.AntUIImages;
28
import org.eclipse.ant.internal.ui.AntUtil;
29
import org.eclipse.ant.internal.ui.IAntUIConstants;
28
import org.eclipse.ant.internal.ui.IAntUIConstants;
30
import org.eclipse.core.resources.IFile;
29
import org.eclipse.core.resources.IFile;
31
import org.eclipse.core.runtime.IAdaptable;
30
import org.eclipse.core.runtime.IAdaptable;
Lines 35-40 Link Here
35
import org.eclipse.jface.text.IRegion;
34
import org.eclipse.jface.text.IRegion;
36
import org.eclipse.swt.graphics.Image;
35
import org.eclipse.swt.graphics.Image;
37
36
37
import com.ibm.icu.text.MessageFormat;
38
38
/**
39
/**
39
 * General representation of an Ant buildfile element.
40
 * General representation of an Ant buildfile element.
40
 * 
41
 * 
Lines 546-552 Link Here
546
     */
547
     */
547
	public IFile getIFile() {
548
	public IFile getIFile() {
548
		if (isExternal()) {
549
		if (isExternal()) {
549
			return AntUtil.getFileForLocation(fFilePath, null);
550
			return AntLaunchingUtil.getFileForLocation(fFilePath, null);
550
		} 
551
		} 
551
		return getBuildFileResource();
552
		return getBuildFileResource();
552
	}
553
	}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModel.java (-2 / +2 lines)
Lines 50-57 Link Here
50
import org.eclipse.ant.internal.core.AntCoreUtil;
50
import org.eclipse.ant.internal.core.AntCoreUtil;
51
import org.eclipse.ant.internal.core.AntSecurityManager;
51
import org.eclipse.ant.internal.core.AntSecurityManager;
52
import org.eclipse.ant.internal.core.IAntCoreConstants;
52
import org.eclipse.ant.internal.core.IAntCoreConstants;
53
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
53
import org.eclipse.ant.internal.ui.AntUIPlugin;
54
import org.eclipse.ant.internal.ui.AntUIPlugin;
54
import org.eclipse.ant.internal.ui.AntUtil;
55
import org.eclipse.ant.internal.ui.editor.DecayCodeCompletionDataStructuresThread;
55
import org.eclipse.ant.internal.ui.editor.DecayCodeCompletionDataStructuresThread;
56
import org.eclipse.ant.internal.ui.editor.outline.AntEditorMarkerUpdater;
56
import org.eclipse.ant.internal.ui.editor.outline.AntEditorMarkerUpdater;
57
import org.eclipse.ant.internal.ui.editor.utils.ProjectHelper;
57
import org.eclipse.ant.internal.ui.editor.utils.ProjectHelper;
Lines 584-590 Link Here
584
        }
584
        }
585
        String buildFileNames= AntUIPlugin.getDefault().getCombinedPreferenceStore().getString(AntEditorPreferenceConstants.BUILDFILE_NAMES_TO_IGNORE);
585
        String buildFileNames= AntUIPlugin.getDefault().getCombinedPreferenceStore().getString(AntEditorPreferenceConstants.BUILDFILE_NAMES_TO_IGNORE);
586
        if (buildFileNames.length() > 0) {
586
        if (buildFileNames.length() > 0) {
587
            String[] names= AntUtil.parseString(buildFileNames, ","); //$NON-NLS-1$
587
            String[] names= AntLaunchingUtil.parseString(buildFileNames, ","); //$NON-NLS-1$
588
            String editedFileName= getEditedFile().getName();
588
            String editedFileName= getEditedFile().getName();
589
            for (int i = 0; i < names.length; i++) {
589
            for (int i = 0; i < names.length; i++) {
590
                String string = names[i];
590
                String string = names[i];
(-)Ant Tools Support/org/eclipse/ant/internal/ui/console/AntConsoleColorProvider.java (-1 / +1 lines)
Lines 10-19 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.console;
11
package org.eclipse.ant.internal.ui.console;
12
12
13
import org.eclipse.ant.internal.launching.launchConfigurations.AntStreamsProxy;
13
import org.eclipse.ant.internal.ui.AntUIPlugin;
14
import org.eclipse.ant.internal.ui.AntUIPlugin;
14
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
15
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
15
import org.eclipse.ant.internal.ui.launchConfigurations.AntProcess;
16
import org.eclipse.ant.internal.ui.launchConfigurations.AntProcess;
16
import org.eclipse.ant.internal.ui.launchConfigurations.AntStreamsProxy;
17
import org.eclipse.debug.core.model.IProcess;
17
import org.eclipse.debug.core.model.IProcess;
18
import org.eclipse.debug.ui.IDebugUIConstants;
18
import org.eclipse.debug.ui.IDebugUIConstants;
19
import org.eclipse.debug.ui.console.ConsoleColorProvider;
19
import org.eclipse.debug.ui.console.ConsoleColorProvider;
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java (-4 / +4 lines)
Lines 17-25 Link Here
17
import org.eclipse.ant.core.AntCorePlugin;
17
import org.eclipse.ant.core.AntCorePlugin;
18
import org.eclipse.ant.core.AntCorePreferences;
18
import org.eclipse.ant.core.AntCorePreferences;
19
import org.eclipse.ant.core.Property;
19
import org.eclipse.ant.core.Property;
20
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
20
import org.eclipse.ant.internal.ui.AntUIImages;
21
import org.eclipse.ant.internal.ui.AntUIImages;
21
import org.eclipse.ant.internal.ui.AntUIPlugin;
22
import org.eclipse.ant.internal.ui.AntUIPlugin;
22
import org.eclipse.ant.internal.ui.AntUtil;
23
import org.eclipse.ant.internal.ui.IAntUIConstants;
23
import org.eclipse.ant.internal.ui.IAntUIConstants;
24
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
24
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
25
import org.eclipse.ant.internal.ui.preferences.AntPropertiesBlock;
25
import org.eclipse.ant.internal.ui.preferences.AntPropertiesBlock;
Lines 111-117 Link Here
111
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
111
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
112
	 */
112
	 */
113
	public void initializeFrom(ILaunchConfiguration configuration) {
113
	public void initializeFrom(ILaunchConfiguration configuration) {
114
        fSeparateJRE= AntUtil.isSeparateJREAntBuild(configuration);
114
        fSeparateJRE= AntLaunchingUtil.isSeparateJREAntBuild(configuration);
115
		setErrorMessage(null);
115
		setErrorMessage(null);
116
		setMessage(null);
116
		setMessage(null);
117
		Map properties= null;
117
		Map properties= null;
Lines 134-140 Link Here
134
			fUseDefaultButton.setSelection(false);
134
			fUseDefaultButton.setSelection(false);
135
			fAntPropertiesBlock.populatePropertyViewer(properties);
135
			fAntPropertiesBlock.populatePropertyViewer(properties);
136
		
136
		
137
			String[] files= AntUtil.parseString(propertyFiles, ","); //$NON-NLS-1$
137
			String[] files= AntLaunchingUtil.parseString(propertyFiles, ","); //$NON-NLS-1$
138
			fAntPropertiesBlock.setPropertyFilesInput(files);
138
			fAntPropertiesBlock.setPropertyFilesInput(files);
139
		}
139
		}
140
		
140
		
Lines 246-252 Link Here
246
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
246
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
247
	 */
247
	 */
248
	public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
248
	public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
249
        if (fSeparateJRE != AntUtil.isSeparateJREAntBuild(workingCopy)) {
249
        if (fSeparateJRE != AntLaunchingUtil.isSeparateJREAntBuild(workingCopy)) {
250
            //update the properties if changed whether build is in separate JRE
250
            //update the properties if changed whether build is in separate JRE
251
            initializeFrom(workingCopy);
251
            initializeFrom(workingCopy);
252
        }
252
        }
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntJRETab.java (-2 / +2 lines)
Lines 34-40 Link Here
34
import org.eclipse.swt.layout.GridData;
34
import org.eclipse.swt.layout.GridData;
35
import org.eclipse.swt.widgets.Composite;
35
import org.eclipse.swt.widgets.Composite;
36
import org.eclipse.ui.PlatformUI;
36
import org.eclipse.ui.PlatformUI;
37
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
37
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil;
38
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
38
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
39
39
40
public class AntJRETab extends JavaJRETab {
40
public class AntJRETab extends JavaJRETab {
Lines 159-165 Link Here
159
    		if (args != null) {
159
    		if (args != null) {
160
    			Pattern pattern = Pattern.compile("\\$\\{.*_prompt.*\\}"); //$NON-NLS-1$
160
    			Pattern pattern = Pattern.compile("\\$\\{.*_prompt.*\\}"); //$NON-NLS-1$
161
    			IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
161
    			IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
162
    			String[] arguments = ExternalToolsUtil.parseStringIntoList(args);
162
    			String[] arguments = ExternalToolsCoreUtil.parseStringIntoList(args);
163
    			if (arguments != null) {
163
    			if (arguments != null) {
164
                    for (int i = 0; i < arguments.length; i++) {
164
                    for (int i = 0; i < arguments.length; i++) {
165
                        String arg = arguments[i];
165
                        String arg = arguments[i];
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMainTab.java (-2 / +2 lines)
Lines 10-17 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.launchConfigurations;
11
package org.eclipse.ant.internal.ui.launchConfigurations;
12
12
13
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
13
import org.eclipse.ant.internal.ui.AntUIPlugin;
14
import org.eclipse.ant.internal.ui.AntUIPlugin;
14
import org.eclipse.ant.internal.ui.AntUtil;
15
import org.eclipse.ant.internal.ui.IAntUIConstants;
15
import org.eclipse.ant.internal.ui.IAntUIConstants;
16
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
16
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
17
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.resources.IFile;
Lines 108-114 Link Here
108
                if (location != null) {
108
                if (location != null) {
109
                    String expandedLocation= manager.performStringSubstitution(location);
109
                    String expandedLocation= manager.performStringSubstitution(location);
110
                    if (expandedLocation != null) {
110
                    if (expandedLocation != null) {
111
                        file= AntUtil.getFileForLocation(expandedLocation, null);
111
                        file= AntLaunchingUtil.getFileForLocation(expandedLocation, null);
112
                    }
112
                    }
113
                }
113
                }
114
            } catch (CoreException e) {
114
            } catch (CoreException e) {
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntTargetsTab.java (-2 / +3 lines)
Lines 18-23 Link Here
18
import java.util.Iterator;
18
import java.util.Iterator;
19
import java.util.List;
19
import java.util.List;
20
20
21
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
21
import org.eclipse.ant.internal.ui.AntUIImages;
22
import org.eclipse.ant.internal.ui.AntUIImages;
22
import org.eclipse.ant.internal.ui.AntUIPlugin;
23
import org.eclipse.ant.internal.ui.AntUIPlugin;
23
import org.eclipse.ant.internal.ui.AntUtil;
24
import org.eclipse.ant.internal.ui.AntUtil;
Lines 532-538 Link Here
532
				ISchedulingRule rule= null;
533
				ISchedulingRule rule= null;
533
				if (!ResourcesPlugin.getWorkspace().isTreeLocked()) {
534
				if (!ResourcesPlugin.getWorkspace().isTreeLocked()) {
534
					//only set a scheduling rule if not in a resource change callback
535
					//only set a scheduling rule if not in a resource change callback
535
					rule= AntUtil.getFileForLocation(expandedLocation, null);
536
					rule= AntLaunchingUtil.getFileForLocation(expandedLocation, null);
536
				}
537
				}
537
				PlatformUI.getWorkbench().getProgressService().runInUI(context, operation, rule);
538
				PlatformUI.getWorkbench().getProgressService().runInUI(context, operation, rule);
538
			} catch (InvocationTargetException e) {
539
			} catch (InvocationTargetException e) {
Lines 649-655 Link Here
649
			return; 
650
			return; 
650
		}
651
		}
651
		
652
		
652
		String[] targetNames= AntUtil.parseRunTargets(configTargets);
653
		String[] targetNames= AntLaunchingUtil.parseRunTargets(configTargets);
653
		if (targetNames.length == 0) {
654
		if (targetNames.length == 0) {
654
			fTableViewer.setAllChecked(false);
655
			fTableViewer.setAllChecked(false);
655
			setExecuteInput(allTargetNodes);
656
			setExecuteInput(allTargetNodes);
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchConfigurationMessages.java (-15 / +1 lines)
Lines 20-33 Link Here
20
	public static String AddVariableStringAction_3;
20
	public static String AddVariableStringAction_3;
21
	public static String AddVariableStringAction_4;
21
	public static String AddVariableStringAction_4;
22
22
23
	public static String AntLaunchDelegate_Launching__0__1;
24
	public static String AntLaunchDelegate_Running__0__2;
25
	public static String AntLaunchDelegate_Build_In_Progress;
26
	public static String AntLaunchDelegate_Failure;
27
	public static String AntLaunchDelegate_22;
28
	public static String AntLaunchDelegate_23;
29
	public static String AntLaunchDelegate_28;
30
31
	public static String AntLaunchShortcut_Unable;
23
	public static String AntLaunchShortcut_Unable;
32
	public static String AntLaunchShortcut_2;
24
	public static String AntLaunchShortcut_2;
33
	public static String AntLaunchShortcut_3;
25
	public static String AntLaunchShortcut_3;
Lines 45-53 Link Here
45
37
46
	public static String AntJRETab_2;
38
	public static String AntJRETab_2;
47
	public static String AntJRETab_3;
39
	public static String AntJRETab_3;
48
40
	
49
	public static String AntHomeClasspathEntry_8;
50
	public static String AntHomeClasspathEntry_9;
51
	public static String AntBuilderTargetsTab_0;
41
	public static String AntBuilderTargetsTab_0;
52
	public static String AntBuilderTargetsTab_1;
42
	public static String AntBuilderTargetsTab_1;
53
	public static String AntBuilderTargetsTab_2;
43
	public static String AntBuilderTargetsTab_2;
Lines 58-65 Link Here
58
	public static String AntBuilderTargetsTab_7;
48
	public static String AntBuilderTargetsTab_7;
59
	public static String AntBuilderTargetsTab_8;
49
	public static String AntBuilderTargetsTab_8;
60
	public static String AntBuilderTargetsTab_10;
50
	public static String AntBuilderTargetsTab_10;
61
	public static String AntHomeClasspathEntry_10;
62
	public static String AntHomeClasspathEntry_11;
63
51
64
	public static String AntMainTab__Select_a_build_file__1;
52
	public static String AntMainTab__Select_a_build_file__1;
65
	public static String AntMainTab_3;
53
	public static String AntMainTab_3;
Lines 86-93 Link Here
86
	public static String AntTargetsTab_1;
74
	public static String AntTargetsTab_1;
87
	public static String AntClasspathTab_0;
75
	public static String AntClasspathTab_0;
88
76
89
	public static String ContributedClasspathEntriesEntry_1;
90
91
	public static String EditAntHomeEntryAction_1;
77
	public static String EditAntHomeEntryAction_1;
92
78
93
	public static String TargetOrderDialog_Order_Targets_1;
79
	public static String TargetOrderDialog_Order_Targets_1;
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntClasspathTab.java (-2 / +3 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.launchConfigurations;
11
package org.eclipse.ant.internal.ui.launchConfigurations;
12
12
13
import org.eclipse.ant.internal.ui.AntUtil;
13
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
14
import org.eclipse.ant.internal.launching.launchConfigurations.AntHomeClasspathEntry;
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.ui.ILaunchConfigurationTab;
17
import org.eclipse.debug.ui.ILaunchConfigurationTab;
Lines 81-87 Link Here
81
	 */
82
	 */
82
	public void initializeFrom(ILaunchConfiguration configuration) {
83
	public void initializeFrom(ILaunchConfiguration configuration) {
83
		try {
84
		try {
84
			AntUtil.migrateToNewClasspathFormat(configuration);
85
			AntLaunchingUtil.migrateToNewClasspathFormat(configuration);
85
		} catch (CoreException e) {
86
		} catch (CoreException e) {
86
		}
87
		}
87
		super.initializeFrom(configuration);
88
		super.initializeFrom(configuration);
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMigrationDelegate.java (-2 / +2 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.launchConfigurations;
11
package org.eclipse.ant.internal.ui.launchConfigurations;
12
12
13
import org.eclipse.ant.internal.ui.AntUtil;
13
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
14
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
Lines 46-52 Link Here
46
			if (location != null) {
46
			if (location != null) {
47
				expandedLocation= manager.performStringSubstitution(location);
47
				expandedLocation= manager.performStringSubstitution(location);
48
				if (expandedLocation != null) {
48
				if (expandedLocation != null) {
49
					file= AntUtil.getFileForLocation(expandedLocation, null);
49
					file= AntLaunchingUtil.getFileForLocation(expandedLocation, null);
50
				}
50
				}
51
			}
51
			}
52
		} catch (CoreException e) {
52
		} catch (CoreException e) {
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java (-761 / +759 lines)
Lines 1-761 Link Here
1
/*******************************************************************************
1
///*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
// * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
// * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
// * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
// * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
// * http://www.eclipse.org/legal/epl-v10.html
7
 * 
7
// * 
8
 * Contributors:
8
// * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
// *     IBM Corporation - initial API and implementation
10
 *     Juan A. Hernandez - bug 89926
10
// *     Juan A. Hernandez - bug 89926
11
 *     dakshinamurthy.karra@gmail.com - bug 165371
11
// *     dakshinamurthy.karra@gmail.com - bug 165371
12
 *******************************************************************************/
12
// *******************************************************************************/
13
package org.eclipse.ant.internal.ui.launchConfigurations;
13
//package org.eclipse.ant.internal.ui.launchConfigurations;
14
14
//
15
import java.io.File;
15
//import java.io.File;
16
import java.io.IOException;
16
//import java.io.IOException;
17
import java.net.URL;
17
//import java.net.URL;
18
import java.util.HashMap;
18
//import java.util.HashMap;
19
import java.util.Iterator;
19
//import java.util.Iterator;
20
import java.util.List;
20
//import java.util.List;
21
import java.util.Map;
21
//import java.util.Map;
22
22
//
23
import org.apache.tools.ant.ProjectHelper;
23
//import org.apache.tools.ant.ProjectHelper;
24
import org.eclipse.ant.core.AntCorePlugin;
24
//import org.eclipse.ant.core.AntCorePlugin;
25
import org.eclipse.ant.core.AntCorePreferences;
25
//import org.eclipse.ant.core.AntCorePreferences;
26
import org.eclipse.ant.core.AntRunner;
26
//import org.eclipse.ant.core.AntRunner;
27
import org.eclipse.ant.core.Property;
27
//import org.eclipse.ant.core.Property;
28
import org.eclipse.ant.core.Task;
28
//import org.eclipse.ant.core.Task;
29
import org.eclipse.ant.core.Type;
29
//import org.eclipse.ant.core.Type;
30
import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger;
30
//import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger;
31
import org.eclipse.ant.internal.ui.AntUIPlugin;
31
//import org.eclipse.ant.internal.launching.AntLaunchingUtil;
32
import org.eclipse.ant.internal.ui.AntUtil;
32
//import org.eclipse.ant.internal.ui.AntUIPlugin;
33
import org.eclipse.ant.internal.ui.IAntUIConstants;
33
//import org.eclipse.ant.internal.ui.AntUtil;
34
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
34
//import org.eclipse.ant.internal.ui.IAntUIConstants;
35
import org.eclipse.ant.internal.ui.debug.IAntDebugConstants;
35
//import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
36
import org.eclipse.ant.internal.ui.debug.model.RemoteAntDebugBuildListener;
36
//import org.eclipse.ant.internal.ui.debug.IAntDebugConstants;
37
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
37
//import org.eclipse.ant.internal.ui.debug.model.RemoteAntDebugBuildListener;
38
import org.eclipse.core.resources.IProject;
38
//import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
39
import org.eclipse.core.runtime.CoreException;
39
//import org.eclipse.core.resources.IProject;
40
import org.eclipse.core.runtime.FileLocator;
40
//import org.eclipse.core.runtime.CoreException;
41
import org.eclipse.core.runtime.IPath;
41
//import org.eclipse.core.runtime.FileLocator;
42
import org.eclipse.core.runtime.IProgressMonitor;
42
//import org.eclipse.core.runtime.IPath;
43
import org.eclipse.core.runtime.IStatus;
43
//import org.eclipse.core.runtime.IProgressMonitor;
44
import org.eclipse.core.runtime.Path;
44
//import org.eclipse.core.runtime.IStatus;
45
import org.eclipse.core.runtime.Platform;
45
//import org.eclipse.core.runtime.Path;
46
import org.eclipse.core.runtime.Status;
46
//import org.eclipse.core.runtime.Platform;
47
import org.eclipse.core.runtime.SubProgressMonitor;
47
//import org.eclipse.core.runtime.Status;
48
import org.eclipse.core.variables.VariablesPlugin;
48
//import org.eclipse.core.runtime.SubProgressMonitor;
49
import org.eclipse.debug.core.DebugEvent;
49
//import org.eclipse.core.variables.VariablesPlugin;
50
import org.eclipse.debug.core.DebugPlugin;
50
//import org.eclipse.debug.core.DebugEvent;
51
import org.eclipse.debug.core.IBreakpointManager;
51
//import org.eclipse.debug.core.DebugPlugin;
52
import org.eclipse.debug.core.IDebugEventSetListener;
52
//import org.eclipse.debug.core.IBreakpointManager;
53
import org.eclipse.debug.core.ILaunch;
53
//import org.eclipse.debug.core.IDebugEventSetListener;
54
import org.eclipse.debug.core.ILaunchConfiguration;
54
//import org.eclipse.debug.core.ILaunch;
55
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
55
//import org.eclipse.debug.core.ILaunchConfiguration;
56
import org.eclipse.debug.core.ILaunchManager;
56
//import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
57
import org.eclipse.debug.core.model.IBreakpoint;
57
//import org.eclipse.debug.core.ILaunchManager;
58
import org.eclipse.debug.core.model.IProcess;
58
//import org.eclipse.debug.core.model.IBreakpoint;
59
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
59
//import org.eclipse.debug.core.model.IProcess;
60
import org.eclipse.debug.ui.CommonTab;
60
//import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
61
import org.eclipse.debug.ui.IDebugUIConstants;
61
//import org.eclipse.debug.ui.CommonTab;
62
import org.eclipse.debug.ui.RefreshTab;
62
//import org.eclipse.debug.ui.IDebugUIConstants;
63
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
63
//import org.eclipse.debug.ui.RefreshTab;
64
import org.eclipse.jdt.launching.IVMInstall;
64
//import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
65
import org.eclipse.jdt.launching.JavaRuntime;
65
//import org.eclipse.jdt.launching.IVMInstall;
66
import org.eclipse.jdt.launching.SocketUtil;
66
//import org.eclipse.jdt.launching.JavaRuntime;
67
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
67
//import org.eclipse.jdt.launching.SocketUtil;
68
import org.eclipse.jface.preference.IPreferenceStore;
68
//import org.eclipse.jface.dialogs.MessageDialogWithToggle;
69
import org.eclipse.osgi.service.resolver.BundleDescription;
69
//import org.eclipse.jface.preference.IPreferenceStore;
70
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab;
70
//import org.eclipse.osgi.service.resolver.BundleDescription;
71
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
71
//import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab;
72
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
72
//import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
73
import org.eclipse.ui.externaltools.internal.program.launchConfigurations.BackgroundResourceRefresher;
73
//import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
74
import org.osgi.framework.Bundle;
74
//import org.eclipse.ui.externaltools.internal.program.launchConfigurations.BackgroundResourceRefresher;
75
75
//import org.osgi.framework.Bundle;
76
import com.ibm.icu.text.MessageFormat;
76
//
77
77
//import com.ibm.icu.text.MessageFormat;
78
/**
78
//
79
 * Launch delegate for Ant builds
79
///**
80
 */
80
// * Launch delegate for Ant builds
81
public class AntLaunchDelegate extends LaunchConfigurationDelegate  {
81
// */
82
	
82
//public class AntLaunchDelegate extends LaunchConfigurationDelegate  {
83
	private static final String ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessBuildLogger"; //$NON-NLS-1$
83
//	
84
	private static final String ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessDebugBuildLogger"; //$NON-NLS-1$
84
//	private static final String ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessBuildLogger"; //$NON-NLS-1$
85
	private static final String NULL_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.NullBuildLogger"; //$NON-NLS-1$
85
//	private static final String ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessDebugBuildLogger"; //$NON-NLS-1$
86
	private static final String REMOTE_ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.RemoteAntBuildLogger"; //$NON-NLS-1$
86
//	private static final String NULL_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.NullBuildLogger"; //$NON-NLS-1$
87
	private static final String REMOTE_ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.debug.RemoteAntDebugBuildLogger"; //$NON-NLS-1$
87
//	private static final String REMOTE_ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.RemoteAntBuildLogger"; //$NON-NLS-1$
88
	private static final String BASE_DIR_PREFIX = "-Dbasedir="; //$NON-NLS-1$
88
//	private static final String REMOTE_ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.debug.RemoteAntDebugBuildLogger"; //$NON-NLS-1$
89
	private static final String INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.AntInputHandler"; //$NON-NLS-1$
89
//	private static final String BASE_DIR_PREFIX = "-Dbasedir="; //$NON-NLS-1$
90
	private static final String REMOTE_INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.ProxyInputHandler"; //$NON-NLS-1$
90
//	private static final String INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.AntInputHandler"; //$NON-NLS-1$
91
	
91
//	private static final String REMOTE_INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.ProxyInputHandler"; //$NON-NLS-1$
92
	private static final IProject[] NO_PROJECTS = new IProject[0];
92
//	
93
    
93
//	private static final IProject[] NO_PROJECTS = new IProject[0];
94
	/**
94
//    
95
	 * String attribute identifying the build scope for a launch configuration.
95
//	/**
96
	 * <code>null</code> indicates the default workspace build.
96
//	 * String attribute identifying the build scope for a launch configuration.
97
	 */
97
//	 * <code>null</code> indicates the default workspace build.
98
	private static final String ATTR_BUILD_SCOPE = AntUIPlugin.getUniqueIdentifier() + ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$
98
//	 */
99
99
//	private static final String ATTR_BUILD_SCOPE = AntUIPlugin.getUniqueIdentifier() + ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$
100
	/**
100
//
101
	 * Attribute identifier specifying whether referenced projects should be 
101
//	/**
102
	 * considered when computing the projects to build. Default value is
102
//	 * Attribute identifier specifying whether referenced projects should be 
103
	 * <code>true</code>.
103
//	 * considered when computing the projects to build. Default value is
104
	 */
104
//	 * <code>true</code>.
105
	private static final String ATTR_INCLUDE_REFERENCED_PROJECTS = AntUIPlugin.getUniqueIdentifier() + ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$
105
//	 */
106
106
//	private static final String ATTR_INCLUDE_REFERENCED_PROJECTS = AntUIPlugin.getUniqueIdentifier() + ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$
107
	
107
//
108
    private static String fgSWTLibraryLocation;
108
//	
109
	
109
//    private static String fgSWTLibraryLocation;
110
	private String fMode;
110
//	
111
    private boolean fUserSpecifiedLogger= false;
111
//	private String fMode;
112
    
112
//    private boolean fUserSpecifiedLogger= false;
113
    private String getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
113
//    
114
		String arguments = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$
114
//    private String getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
115
		return VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(arguments);
115
//		String arguments = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$
116
	}
116
//		return VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(arguments);
117
	
117
//	}
118
	/**
118
//	
119
	 * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration,
119
//	/**
120
	 *      java.lang.String, org.eclipse.debug.core.ILaunch,
120
//	 * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration,
121
	 *      org.eclipse.core.runtime.IProgressMonitor)
121
//	 *      java.lang.String, org.eclipse.debug.core.ILaunch,
122
	 */
122
//	 *      org.eclipse.core.runtime.IProgressMonitor)
123
	public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
123
//	 */
124
		if (monitor.isCanceled()) {
124
//	public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
125
			return;
125
//		if (monitor.isCanceled()) {
126
		}
126
//			return;
127
		fUserSpecifiedLogger= false;
127
//		}
128
		fMode= mode;
128
//		fUserSpecifiedLogger= false;
129
		
129
//		fMode= mode;
130
		// migrate the config to the new classpath format if required
130
//		
131
		AntUtil.migrateToNewClasspathFormat(configuration);
131
//		// migrate the config to the new classpath format if required
132
		
132
//		AntLaunchingUtil.migrateToNewClasspathFormat(configuration);
133
		boolean isSeparateJRE= AntUtil.isSeparateJREAntBuild(configuration);
133
//		
134
		
134
//		boolean isSeparateJRE= AntLaunchingUtil.isSeparateJREAntBuild(configuration);
135
		if (CommonTab.isLaunchInBackground(configuration)) {
135
//		
136
			monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1, new String[] {configuration.getName()}), 10);
136
//		if (CommonTab.isLaunchInBackground(configuration)) {
137
		} else {
137
//			monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1, new String[] {configuration.getName()}), 10);
138
			monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Running__0__2, new String[] {configuration.getName()}), 100);
138
//		} else {
139
		}
139
//			monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Running__0__2, new String[] {configuration.getName()}), 100);
140
		
140
//		}
141
		// resolve location
141
//		
142
		IPath location = ExternalToolsUtil.getLocation(configuration);
142
//		// resolve location
143
		monitor.worked(1);
143
//		IPath location = ExternalToolsUtil.getLocation(configuration);
144
		
144
//		monitor.worked(1);
145
		if (monitor.isCanceled()) {
145
//		
146
			return;
146
//		if (monitor.isCanceled()) {
147
		}
147
//			return;
148
		
148
//		}
149
		if (!isSeparateJRE && AntRunner.isBuildRunning()) {
149
//		
150
			IStatus status= new Status(IStatus.ERROR, IAntUIConstants.PLUGIN_ID, 1, MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Build_In_Progress, new String[]{location.toOSString()}), null);
150
//		if (!isSeparateJRE && AntRunner.isBuildRunning()) {
151
			throw new CoreException(status);
151
//			IStatus status= new Status(IStatus.ERROR, IAntUIConstants.PLUGIN_ID, 1, MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Build_In_Progress, new String[]{location.toOSString()}), null);
152
		}		
152
//			throw new CoreException(status);
153
		
153
//		}		
154
		// resolve working directory
154
//		
155
		IPath workingDirectory = ExternalToolsUtil.getWorkingDirectory(configuration);
155
//		// resolve working directory
156
		String basedir = null;
156
//		IPath workingDirectory = ExternalToolsUtil.getWorkingDirectory(configuration);
157
		if (workingDirectory != null) {
157
//		String basedir = null;
158
			basedir= workingDirectory.toOSString();
158
//		if (workingDirectory != null) {
159
		}
159
//			basedir= workingDirectory.toOSString();
160
		monitor.worked(1);
160
//		}
161
		
161
//		monitor.worked(1);
162
		if (monitor.isCanceled()) {
162
//		
163
			return;
163
//		if (monitor.isCanceled()) {
164
		}
164
//			return;
165
165
//		}
166
		// link the process to its build logger via a timestamp
166
//
167
		long timeStamp = System.currentTimeMillis();
167
//		// link the process to its build logger via a timestamp
168
		String idStamp = Long.toString(timeStamp);
168
//		long timeStamp = System.currentTimeMillis();
169
		StringBuffer idProperty = new StringBuffer("-D"); //$NON-NLS-1$
169
//		String idStamp = Long.toString(timeStamp);
170
		idProperty.append(AbstractEclipseBuildLogger.ANT_PROCESS_ID);
170
//		StringBuffer idProperty = new StringBuffer("-D"); //$NON-NLS-1$
171
		idProperty.append('=');
171
//		idProperty.append(AbstractEclipseBuildLogger.ANT_PROCESS_ID);
172
		idProperty.append(idStamp);
172
//		idProperty.append('=');
173
		
173
//		idProperty.append(idStamp);
174
		// resolve arguments	
174
//		
175
		String[] arguments = null;
175
//		// resolve arguments	
176
		if (isSeparateJRE) {
176
//		String[] arguments = null;
177
			arguments = new String[] {getProgramArguments(configuration)};
177
//		if (isSeparateJRE) {
178
        } else { 
178
//			arguments = new String[] {getProgramArguments(configuration)};
179
			arguments = ExternalToolsUtil.getArguments(configuration);
179
//        } else { 
180
        }
180
//			arguments = ExternalToolsUtil.getArguments(configuration);
181
		
181
//        }
182
		Map userProperties= AntUtil.getProperties(configuration);
182
//		
183
		if (userProperties != null) {//create a copy so as to not affect the configuration with transient properties
183
//		Map userProperties= AntLaunchingUtil.getProperties(configuration);
184
			userProperties= new HashMap(userProperties);
184
//		if (userProperties != null) {//create a copy so as to not affect the configuration with transient properties
185
		}
185
//			userProperties= new HashMap(userProperties);
186
		String[] propertyFiles= AntUtil.getPropertyFiles(configuration);
186
//		}
187
		String[] targets = AntUtil.getTargetNames(configuration);
187
//		String[] propertyFiles= AntUtil.getPropertyFiles(configuration);
188
		URL[] customClasspath= AntUtil.getCustomClasspath(configuration);
188
//		String[] targets = AntLaunchingUtil.getTargetNames(configuration);
189
		String antHome= AntUtil.getAntHome(configuration);
189
//		URL[] customClasspath= AntLaunchingUtil.getCustomClasspath(configuration);
190
		
190
//		String antHome= AntLaunchingUtil.getAntHome(configuration);
191
		boolean setInputHandler= true;
191
//		
192
		try {
192
//		boolean setInputHandler= true;
193
			//check if set specify inputhandler
193
//		try {
194
			setInputHandler = configuration.getAttribute(IAntUIConstants.SET_INPUTHANDLER, true);
194
//			//check if set specify inputhandler
195
		} catch (CoreException ce) {
195
//			setInputHandler = configuration.getAttribute(IAntUIConstants.SET_INPUTHANDLER, true);
196
			AntUIPlugin.log(ce);			
196
//		} catch (CoreException ce) {
197
		}
197
//			AntUIPlugin.log(ce);			
198
		
198
//		}
199
		AntRunner runner= null;
199
//		
200
		if (!isSeparateJRE) {
200
//		AntRunner runner= null;
201
			runner = configureAntRunner(configuration, location, basedir, idProperty, arguments, userProperties, propertyFiles, targets, customClasspath, antHome, setInputHandler);
201
//		if (!isSeparateJRE) {
202
		}
202
//			runner = configureAntRunner(configuration, location, basedir, idProperty, arguments, userProperties, propertyFiles, targets, customClasspath, antHome, setInputHandler);
203
		 
203
//		}
204
		monitor.worked(1);
204
//		 
205
								
205
//		monitor.worked(1);
206
		if (monitor.isCanceled()) {
206
//								
207
			return;
207
//		if (monitor.isCanceled()) {
208
		}
208
//			return;
209
		boolean captureOutput= ExternalToolsUtil.getCaptureOutput(configuration);
209
//		}
210
		int port= -1;
210
//		boolean captureOutput= ExternalToolsUtil.getCaptureOutput(configuration);
211
		int requestPort= -1;
211
//		int port= -1;
212
		if (isSeparateJRE && captureOutput) {
212
//		int requestPort= -1;
213
			if (userProperties == null) {
213
//		if (isSeparateJRE && captureOutput) {
214
				userProperties= new HashMap();
214
//			if (userProperties == null) {
215
			}
215
//				userProperties= new HashMap();
216
			port= SocketUtil.findFreePort();
216
//			}
217
			userProperties.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp);
217
//			port= SocketUtil.findFreePort();
218
			userProperties.put("eclipse.connect.port", Integer.toString(port)); //$NON-NLS-1$
218
//			userProperties.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp);
219
			if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
219
//			userProperties.put("eclipse.connect.port", Integer.toString(port)); //$NON-NLS-1$
220
				requestPort= SocketUtil.findFreePort();
220
//			if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
221
				userProperties.put("eclipse.connect.request_port", Integer.toString(requestPort)); //$NON-NLS-1$
221
//				requestPort= SocketUtil.findFreePort();
222
			}
222
//				userProperties.put("eclipse.connect.request_port", Integer.toString(requestPort)); //$NON-NLS-1$
223
		}
223
//			}
224
		
224
//		}
225
		StringBuffer commandLine= generateCommandLine(location, arguments, userProperties, propertyFiles, targets, antHome, basedir, isSeparateJRE, captureOutput, setInputHandler);
225
//		
226
		
226
//		StringBuffer commandLine= generateCommandLine(location, arguments, userProperties, propertyFiles, targets, antHome, basedir, isSeparateJRE, captureOutput, setInputHandler);
227
		if (isSeparateJRE) {
227
//		
228
			monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1, new String[] {configuration.getName()}), 10);
228
//		if (isSeparateJRE) {
229
			runInSeparateVM(configuration, launch, monitor, idStamp, antHome, port, requestPort, commandLine, captureOutput, setInputHandler);
229
//			monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1, new String[] {configuration.getName()}), 10);
230
		} else {
230
//			runInSeparateVM(configuration, launch, monitor, idStamp, antHome, port, requestPort, commandLine, captureOutput, setInputHandler);
231
			runInSameVM(configuration, launch, monitor, location, idStamp, runner, commandLine, captureOutput);
231
//		} else {
232
		}
232
//			runInSameVM(configuration, launch, monitor, location, idStamp, runner, commandLine, captureOutput);
233
		
233
//		}
234
		monitor.done();	
234
//		
235
	}
235
//		monitor.done();	
236
	
236
//	}
237
	private void runInSameVM(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor, IPath location, String idStamp, AntRunner runner, StringBuffer commandLine, boolean captureOutput) throws CoreException {
237
//	
238
		Map attributes= new HashMap(2);
238
//	private void runInSameVM(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor, IPath location, String idStamp, AntRunner runner, StringBuffer commandLine, boolean captureOutput) throws CoreException {
239
		attributes.put(IProcess.ATTR_PROCESS_TYPE, IAntLaunchConfigurationConstants.ID_ANT_PROCESS_TYPE);
239
//		Map attributes= new HashMap(2);
240
		attributes.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp);
240
//		attributes.put(IProcess.ATTR_PROCESS_TYPE, IAntLaunchConfigurationConstants.ID_ANT_PROCESS_TYPE);
241
				
241
//		attributes.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp);
242
		final AntProcess process = new AntProcess(location.toOSString(), launch, attributes);
242
//				
243
		setProcessAttributes(process, idStamp, commandLine, captureOutput);
243
//		final AntProcess process = new AntProcess(location.toOSString(), launch, attributes);
244
		boolean debug= fMode.equals(ILaunchManager.DEBUG_MODE);
244
//		setProcessAttributes(process, idStamp, commandLine, captureOutput);
245
		if (debug || CommonTab.isLaunchInBackground(configuration)) {
245
//		boolean debug= fMode.equals(ILaunchManager.DEBUG_MODE);
246
			final AntRunner finalRunner= runner;
246
//		if (debug || CommonTab.isLaunchInBackground(configuration)) {
247
			Runnable r = new Runnable() {
247
//			final AntRunner finalRunner= runner;
248
				public void run() {
248
//			Runnable r = new Runnable() {
249
					try {
249
//				public void run() {
250
						finalRunner.run(process);
250
//					try {
251
					} catch (CoreException e) {
251
//						finalRunner.run(process);
252
						handleException(e, AntLaunchConfigurationMessages.AntLaunchDelegate_Failure);
252
//					} catch (CoreException e) {
253
					}
253
//						handleException(e, AntLaunchConfigurationMessages.AntLaunchDelegate_Failure);
254
					process.terminated();
254
//					}
255
				}
255
//					process.terminated();
256
			};
256
//				}
257
			Thread background = new Thread(r);
257
//			};
258
            background.setDaemon(true);
258
//			Thread background = new Thread(r);
259
			background.start();
259
//            background.setDaemon(true);
260
			monitor.worked(1);
260
//			background.start();
261
			//refresh resources after process finishes
261
//			monitor.worked(1);
262
			if (RefreshTab.getRefreshScope(configuration) != null) {
262
//			//refresh resources after process finishes
263
				BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(configuration, process);
263
//			if (RefreshTab.getRefreshScope(configuration) != null) {
264
				refresher.startBackgroundRefresh();
264
//				BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(configuration, process);
265
			}	
265
//				refresher.startBackgroundRefresh();
266
		} else {
266
//			}	
267
			// execute the build 
267
//		} else {
268
			try {
268
//			// execute the build 
269
				runner.run(monitor);
269
//			try {
270
			} catch (CoreException e) {
270
//				runner.run(monitor);
271
				process.terminated();
271
//			} catch (CoreException e) {
272
				monitor.done();
272
//				process.terminated();
273
				handleException(e, AntLaunchConfigurationMessages.AntLaunchDelegate_23);
273
//				monitor.done();
274
				return;
274
//				handleException(e, AntLaunchConfigurationMessages.AntLaunchDelegate_23);
275
			}
275
//				return;
276
			process.terminated();
276
//			}
277
			
277
//			process.terminated();
278
			// refresh resources
278
//			
279
			RefreshTab.refreshResources(configuration, monitor);
279
//			// refresh resources
280
		}
280
//			RefreshTab.refreshResources(configuration, monitor);
281
	}
281
//		}
282
282
//	}
283
	private AntRunner configureAntRunner(ILaunchConfiguration configuration, IPath location, String baseDir, StringBuffer idProperty, String[] arguments, Map userProperties, String[] propertyFiles, String[] targets, URL[] customClasspath, String antHome, boolean setInputHandler) throws CoreException {
283
//
284
		int argLength = 1; // at least one user property - timestamp
284
//	private AntRunner configureAntRunner(ILaunchConfiguration configuration, IPath location, String baseDir, StringBuffer idProperty, String[] arguments, Map userProperties, String[] propertyFiles, String[] targets, URL[] customClasspath, String antHome, boolean setInputHandler) throws CoreException {
285
		if (arguments != null) {
285
//		int argLength = 1; // at least one user property - timestamp
286
			argLength += arguments.length;
286
//		if (arguments != null) {
287
		}		
287
//			argLength += arguments.length;
288
		if (baseDir != null && baseDir.length() > 0) {
288
//		}		
289
			argLength++;
289
//		if (baseDir != null && baseDir.length() > 0) {
290
		}
290
//			argLength++;
291
		String[] runnerArgs = new String[argLength];
291
//		}
292
		if (arguments != null) {
292
//		String[] runnerArgs = new String[argLength];
293
			System.arraycopy(arguments, 0, runnerArgs, 0, arguments.length);
293
//		if (arguments != null) {
294
		}
294
//			System.arraycopy(arguments, 0, runnerArgs, 0, arguments.length);
295
		if (baseDir != null && baseDir.length() > 0) {
295
//		}
296
			runnerArgs[runnerArgs.length - 2] = BASE_DIR_PREFIX + baseDir;
296
//		if (baseDir != null && baseDir.length() > 0) {
297
		}
297
//			runnerArgs[runnerArgs.length - 2] = BASE_DIR_PREFIX + baseDir;
298
		runnerArgs[runnerArgs.length -1] = idProperty.toString();
298
//		}
299
		
299
//		runnerArgs[runnerArgs.length -1] = idProperty.toString();
300
		AntRunner runner= new AntRunner();
300
//		
301
		runner.setBuildFileLocation(location.toOSString());
301
//		AntRunner runner= new AntRunner();
302
		boolean captureOutput= ExternalToolsUtil.getCaptureOutput(configuration);
302
//		runner.setBuildFileLocation(location.toOSString());
303
		if (captureOutput) {
303
//		boolean captureOutput= ExternalToolsUtil.getCaptureOutput(configuration);
304
			if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
304
//		if (captureOutput) {
305
				runner.addBuildLogger(ANT_DEBUG_LOGGER_CLASS);
305
//			if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
306
			} else {
306
//				runner.addBuildLogger(ANT_DEBUG_LOGGER_CLASS);
307
				runner.addBuildLogger(ANT_LOGGER_CLASS);
307
//			} else {
308
			}
308
//				runner.addBuildLogger(ANT_LOGGER_CLASS);
309
		} else {
309
//			}
310
			runner.addBuildLogger(NULL_LOGGER_CLASS);
310
//		} else {
311
		}
311
//			runner.addBuildLogger(NULL_LOGGER_CLASS);
312
		if (setInputHandler) {
312
//		}
313
			runner.setInputHandler(INPUT_HANDLER_CLASS);
313
//		if (setInputHandler) {
314
		} else {
314
//			runner.setInputHandler(INPUT_HANDLER_CLASS);
315
			runner.setInputHandler(""); //$NON-NLS-1$
315
//		} else {
316
		}
316
//			runner.setInputHandler(""); //$NON-NLS-1$
317
		runner.setArguments(runnerArgs);
317
//		}
318
		if (userProperties != null) {
318
//		runner.setArguments(runnerArgs);
319
			runner.addUserProperties(userProperties);
319
//		if (userProperties != null) {
320
		}
320
//			runner.addUserProperties(userProperties);
321
321
//		}
322
		if (propertyFiles != null) {
322
//
323
			runner.setPropertyFiles(propertyFiles);
323
//		if (propertyFiles != null) {
324
		}
324
//			runner.setPropertyFiles(propertyFiles);
325
325
//		}
326
		if (targets != null) {
326
//
327
			runner.setExecutionTargets(targets);
327
//		if (targets != null) {
328
		}
328
//			runner.setExecutionTargets(targets);
329
329
//		}
330
		if (customClasspath != null) {
330
//
331
			runner.setCustomClasspath(customClasspath);
331
//		if (customClasspath != null) {
332
		}
332
//			runner.setCustomClasspath(customClasspath);
333
333
//		}
334
		if (antHome != null) {
334
//
335
			runner.setAntHome(antHome);
335
//		if (antHome != null) {
336
		}
336
//			runner.setAntHome(antHome);
337
		return runner;
337
//		}
338
	}
338
//		return runner;
339
339
//	}
340
	private void handleException(final CoreException e, final String title) {
340
//
341
		IPreferenceStore store= AntUIPlugin.getDefault().getPreferenceStore();
341
//	private void handleException(final CoreException e, final String title) {
342
		if (store.getBoolean(IAntUIPreferenceConstants.ANT_ERROR_DIALOG)) {
342
//		IPreferenceStore store= AntUIPlugin.getDefault().getPreferenceStore();
343
			AntUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
343
//		if (store.getBoolean(IAntUIPreferenceConstants.ANT_ERROR_DIALOG)) {
344
				public void run() {
344
//			AntUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
345
					MessageDialogWithToggle.openError(null, title, e.getMessage(), AntLaunchConfigurationMessages.AntLaunchDelegate_22, false, AntUIPlugin.getDefault().getPreferenceStore(), IAntUIPreferenceConstants.ANT_ERROR_DIALOG);
345
//				public void run() {
346
				}
346
//					MessageDialogWithToggle.openError(null, title, e.getMessage(), AntLaunchConfigurationMessages.AntLaunchDelegate_22, false, AntUIPlugin.getDefault().getPreferenceStore(), IAntUIPreferenceConstants.ANT_ERROR_DIALOG);
347
			});
347
//				}
348
		}
348
//			});
349
	}
349
//		}
350
350
//	}
351
	private void setProcessAttributes(IProcess process, String idStamp, StringBuffer commandLine, boolean captureOutput) {
351
//
352
		// link the process to the Eclipse build logger via a timestamp
352
//	private void setProcessAttributes(IProcess process, String idStamp, StringBuffer commandLine, boolean captureOutput) {
353
        if (!fUserSpecifiedLogger) {
353
//		// link the process to the Eclipse build logger via a timestamp
354
            process.setAttribute(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp);
354
//        if (!fUserSpecifiedLogger) {
355
        }
355
//            process.setAttribute(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp);
356
		
356
//        }
357
		// create "fake" command line for the process
357
//		
358
		if (commandLine != null) {
358
//		// create "fake" command line for the process
359
			process.setAttribute(IProcess.ATTR_CMDLINE, commandLine.toString());
359
//		if (commandLine != null) {
360
		}
360
//			process.setAttribute(IProcess.ATTR_CMDLINE, commandLine.toString());
361
		if (captureOutput && !fUserSpecifiedLogger) {
361
//		}
362
			TaskLinkManager.registerAntBuild(process);
362
//	}
363
		}
363
//
364
	}
364
//	private StringBuffer generateCommandLine(IPath location, String[] arguments, Map userProperties, String[] propertyFiles, String[] targets, String antHome, String basedir, boolean separateVM, boolean captureOutput, boolean setInputHandler) {
365
365
//		StringBuffer commandLine= new StringBuffer();
366
	private StringBuffer generateCommandLine(IPath location, String[] arguments, Map userProperties, String[] propertyFiles, String[] targets, String antHome, String basedir, boolean separateVM, boolean captureOutput, boolean setInputHandler) {
366
//
367
		StringBuffer commandLine= new StringBuffer();
367
//		if (!separateVM) {
368
368
//			commandLine.append("ant"); //$NON-NLS-1$
369
		if (!separateVM) {
369
//		}
370
			commandLine.append("ant"); //$NON-NLS-1$
370
//		
371
		}
371
//		if (arguments != null) {
372
		
372
//			for (int i = 0; i < arguments.length; i++) {
373
		if (arguments != null) {
373
//				commandLine.append(' ');
374
			for (int i = 0; i < arguments.length; i++) {
374
//				commandLine.append(arguments[i]);
375
				commandLine.append(' ');
375
//			}
376
				commandLine.append(arguments[i]);
376
//		}
377
			}
377
//		
378
		}
378
//		AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences();
379
		
379
//		if (propertyFiles == null) { //global
380
		AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences();
380
//			String[] files= prefs.getCustomPropertyFiles();
381
		if (propertyFiles == null) { //global
381
//			for (int i = 0; i < files.length; i++) {
382
			String[] files= prefs.getCustomPropertyFiles();
382
//				String path = files[i];
383
			for (int i = 0; i < files.length; i++) {
383
//				commandLine.append(" -propertyfile \""); //$NON-NLS-1$
384
				String path = files[i];
384
//				commandLine.append(path);
385
				commandLine.append(" -propertyfile \""); //$NON-NLS-1$
385
//				commandLine.append('\"');
386
				commandLine.append(path);
386
//			}
387
				commandLine.append('\"');
387
//		} else {//"local" configuration
388
			}
388
//			for (int i = 0; i < propertyFiles.length; i++) {
389
		} else {//"local" configuration
389
//				String path = propertyFiles[i];
390
			for (int i = 0; i < propertyFiles.length; i++) {
390
//				commandLine.append(" -propertyfile \""); //$NON-NLS-1$
391
				String path = propertyFiles[i];
391
//				commandLine.append(path);
392
				commandLine.append(" -propertyfile \""); //$NON-NLS-1$
392
//				commandLine.append('\"');
393
				commandLine.append(path);
393
//			}
394
				commandLine.append('\"');
394
//		}
395
			}
395
//		//"local" configuration
396
		}
396
//		if (userProperties != null) {
397
		//"local" configuration
397
//			Iterator keys = userProperties.keySet().iterator();
398
		if (userProperties != null) {
398
//			String key;
399
			Iterator keys = userProperties.keySet().iterator();
399
//			while (keys.hasNext()) {
400
			String key;
400
//				key= (String)keys.next();
401
			while (keys.hasNext()) {
401
//				appendProperty(commandLine, key, (String)userProperties.get(key));
402
				key= (String)keys.next();
402
//			}
403
				appendProperty(commandLine, key, (String)userProperties.get(key));
403
//		}
404
			}
404
//		
405
		}
405
//		//global
406
		
406
//		List properties= null;
407
		//global
407
//		if (!separateVM) {
408
		List properties= null;
408
//			properties= prefs.getProperties();
409
		if (!separateVM) {
409
//		} else {
410
			properties= prefs.getProperties();
410
//			properties= prefs.getRemoteAntProperties();
411
		} else {
411
//		}
412
			properties= prefs.getRemoteAntProperties();
412
//		
413
		}
413
//		//if we have user properties this means that the user has chosen to override the global properties
414
		
414
//		//if in a separate VM and have only two (or three if debug) user properties these are really only Eclipse generated properties
415
		//if we have user properties this means that the user has chosen to override the global properties
415
//		//and the user is still using the global properties
416
		//if in a separate VM and have only two (or three if debug) user properties these are really only Eclipse generated properties
416
//		int numberOfEclipseProperties= 2;
417
		//and the user is still using the global properties
417
//		if (userProperties != null && userProperties.get("eclipse.connect.request_port") != null){ //$NON-NLS-1$
418
		int numberOfEclipseProperties= 2;
418
//			numberOfEclipseProperties= 3; //debug mode
419
		if (userProperties != null && userProperties.get("eclipse.connect.request_port") != null){ //$NON-NLS-1$
419
//		}
420
			numberOfEclipseProperties= 3; //debug mode
420
//		boolean useGlobalProperties = userProperties == null || (separateVM && userProperties.size() == numberOfEclipseProperties);
421
		}
421
//		if (useGlobalProperties) {
422
		boolean useGlobalProperties = userProperties == null || (separateVM && userProperties.size() == numberOfEclipseProperties);
422
//			for (Iterator iter = properties.iterator(); iter.hasNext();) {
423
		if (useGlobalProperties) {
423
//				Property property = (Property) iter.next();
424
			for (Iterator iter = properties.iterator(); iter.hasNext();) {
424
//				String key= property.getName();
425
				Property property = (Property) iter.next();
425
//				String value= property.getValue(false);
426
				String key= property.getName();
426
//				if (value != null) {
427
				String value= property.getValue(false);
427
//					appendProperty(commandLine, key, value);
428
				if (value != null) {
428
//				}
429
					appendProperty(commandLine, key, value);
429
//			}
430
				}
430
//		}
431
			}
431
//		
432
		}
432
//		if (basedir != null && basedir.length() > 0) {
433
		
433
//			appendProperty(commandLine, "basedir", basedir); //$NON-NLS-1$
434
		if (basedir != null && basedir.length() > 0) {
434
//		}
435
			appendProperty(commandLine, "basedir", basedir); //$NON-NLS-1$
435
//		
436
		}
436
//		if (antHome != null) {
437
		
437
//			commandLine.append(" \"-Dant.home="); //$NON-NLS-1$
438
		if (antHome != null) {
438
//			commandLine.append(antHome);
439
			commandLine.append(" \"-Dant.home="); //$NON-NLS-1$
439
//			commandLine.append('\"');
440
			commandLine.append(antHome);
440
//		}
441
			commandLine.append('\"');
441
//		
442
		}
442
//		if (separateVM) { 
443
		
443
//			if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$
444
		if (separateVM) { 
444
//				if (captureOutput) {
445
			if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$
445
//				commandLine.append(" -logger "); //$NON-NLS-1$
446
				if (captureOutput) {
446
//				if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
447
				commandLine.append(" -logger "); //$NON-NLS-1$
447
//					commandLine.append(REMOTE_ANT_DEBUG_LOGGER_CLASS);
448
				if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
448
//					} else {
449
					commandLine.append(REMOTE_ANT_DEBUG_LOGGER_CLASS);
449
//					commandLine.append(REMOTE_ANT_LOGGER_CLASS);
450
					} else {
450
//				}
451
					commandLine.append(REMOTE_ANT_LOGGER_CLASS);
451
//				}
452
				}
452
//			} else {
453
				}
453
//			    fUserSpecifiedLogger= true;
454
			} else {
454
//            }
455
			    fUserSpecifiedLogger= true;
455
//			if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$
456
            }
456
//				commandLine.append(" -inputhandler "); //$NON-NLS-1$
457
			if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$
457
//				commandLine.append(REMOTE_INPUT_HANDLER_CLASS);
458
				commandLine.append(" -inputhandler "); //$NON-NLS-1$
458
//			}
459
				commandLine.append(REMOTE_INPUT_HANDLER_CLASS);
459
//		} else {
460
			}
460
//			if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$
461
		} else {
461
//				commandLine.append(" -inputhandler "); //$NON-NLS-1$
462
			if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$
462
//				commandLine.append(INPUT_HANDLER_CLASS);
463
				commandLine.append(" -inputhandler "); //$NON-NLS-1$
463
//			}
464
				commandLine.append(INPUT_HANDLER_CLASS);
464
//            if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$
465
			}
465
//    			commandLine.append(" -logger "); //$NON-NLS-1$
466
            if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$
466
//    			if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
467
    			commandLine.append(" -logger "); //$NON-NLS-1$
467
//    				commandLine.append(ANT_DEBUG_LOGGER_CLASS);
468
    			if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
468
//    			} else if (captureOutput) {
469
    				commandLine.append(ANT_DEBUG_LOGGER_CLASS);
469
//    				commandLine.append(ANT_LOGGER_CLASS);
470
    			} else if (captureOutput) {
470
//    			} else {
471
    				commandLine.append(ANT_LOGGER_CLASS);
471
//    				commandLine.append(NULL_LOGGER_CLASS);
472
    			} else {
472
//    			}
473
    				commandLine.append(NULL_LOGGER_CLASS);
473
//            }
474
    			}
474
//		}
475
            }
475
//		
476
		}
476
//		if (separateVM) {
477
		
477
//			appendTaskAndTypes(prefs, commandLine);
478
		if (separateVM) {
478
//		}
479
			appendTaskAndTypes(prefs, commandLine);
479
//		commandLine.append(" -buildfile \""); //$NON-NLS-1$
480
		}
480
//		commandLine.append(location.toOSString());
481
		commandLine.append(" -buildfile \""); //$NON-NLS-1$
481
//		commandLine.append('\"');
482
		commandLine.append(location.toOSString());
482
//		
483
		commandLine.append('\"');
483
//		if (targets != null) {
484
		
484
//			for (int i = 0; i < targets.length; i++) {
485
		if (targets != null) {
485
//				commandLine.append(" \""); //$NON-NLS-1$
486
			for (int i = 0; i < targets.length; i++) {
486
//				commandLine.append(targets[i]);
487
				commandLine.append(" \""); //$NON-NLS-1$
487
//				commandLine.append('\"');
488
				commandLine.append(targets[i]);
488
//			}
489
				commandLine.append('\"');
489
//		}
490
			}
490
//		return commandLine;
491
		}
491
//	}
492
		return commandLine;
492
//	
493
	}
493
//	private void appendTaskAndTypes(AntCorePreferences prefs, StringBuffer commandLine) {
494
	
494
//		List tasks= prefs.getRemoteTasks();
495
	private void appendTaskAndTypes(AntCorePreferences prefs, StringBuffer commandLine) {
495
//		Iterator itr= tasks.iterator();
496
		List tasks= prefs.getRemoteTasks();
496
//		while (itr.hasNext()) {
497
		Iterator itr= tasks.iterator();
497
//			Task task = (Task) itr.next();
498
		while (itr.hasNext()) {
498
//			commandLine.append(" -eclipseTask "); //$NON-NLS-1$
499
			Task task = (Task) itr.next();
499
//			String name= ProjectHelper.genComponentName(task.getURI(), task.getTaskName());
500
			commandLine.append(" -eclipseTask "); //$NON-NLS-1$
500
//			commandLine.append(name);
501
			String name= ProjectHelper.genComponentName(task.getURI(), task.getTaskName());
501
//			commandLine.append(',');
502
			commandLine.append(name);
502
//			commandLine.append(task.getClassName());
503
			commandLine.append(',');
503
//		}
504
			commandLine.append(task.getClassName());
504
//		
505
		}
505
//		List types= prefs.getRemoteTypes();
506
		
506
//		itr= types.iterator();
507
		List types= prefs.getRemoteTypes();
507
//		while (itr.hasNext()) {
508
		itr= types.iterator();
508
//			Type type = (Type) itr.next();
509
		while (itr.hasNext()) {
509
//			commandLine.append(" -eclipseType "); //$NON-NLS-1$
510
			Type type = (Type) itr.next();
510
//			String name= ProjectHelper.genComponentName(type.getURI(), type.getTypeName());
511
			commandLine.append(" -eclipseType "); //$NON-NLS-1$
511
//			commandLine.append(name);
512
			String name= ProjectHelper.genComponentName(type.getURI(), type.getTypeName());
512
//			commandLine.append(',');
513
			commandLine.append(name);
513
//			commandLine.append(type.getClassName());
514
			commandLine.append(',');
514
//		}
515
			commandLine.append(type.getClassName());
515
//	}
516
		}
516
//
517
	}
517
//	private void appendProperty(StringBuffer commandLine, String name, String value) {
518
518
//		commandLine.append(" \"-D"); //$NON-NLS-1$
519
	private void appendProperty(StringBuffer commandLine, String name, String value) {
519
//		commandLine.append(name);
520
		commandLine.append(" \"-D"); //$NON-NLS-1$
520
//		commandLine.append('=');
521
		commandLine.append(name);
521
//		commandLine.append(value);
522
		commandLine.append('=');
522
//        if (value.length() > 0 && value.charAt(value.length() - 1) == File.separatorChar) {
523
		commandLine.append(value);
523
//            commandLine.append(File.separatorChar);
524
        if (value.length() > 0 && value.charAt(value.length() - 1) == File.separatorChar) {
524
//        }
525
            commandLine.append(File.separatorChar);
525
//		commandLine.append("\""); //$NON-NLS-1$
526
        }
526
//	}
527
		commandLine.append("\""); //$NON-NLS-1$
527
//	
528
	}
528
//	private void runInSeparateVM(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor, String idStamp, String antHome, int port, int requestPort, StringBuffer commandLine, boolean captureOutput, boolean setInputHandler) throws CoreException {
529
	
529
//        boolean debug= fMode.equals(ILaunchManager.DEBUG_MODE);
530
	private void runInSeparateVM(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor, String idStamp, String antHome, int port, int requestPort, StringBuffer commandLine, boolean captureOutput, boolean setInputHandler) throws CoreException {
530
//		if (captureOutput) {
531
        boolean debug= fMode.equals(ILaunchManager.DEBUG_MODE);
531
//			if (debug) {
532
		if (captureOutput) {
532
//				RemoteAntDebugBuildListener listener= new RemoteAntDebugBuildListener(launch);
533
			if (debug) {
533
//				if (requestPort != -1) {
534
				RemoteAntDebugBuildListener listener= new RemoteAntDebugBuildListener(launch);
534
//					listener.startListening(port, requestPort);
535
				if (requestPort != -1) {
535
//				}
536
					listener.startListening(port, requestPort);
536
//			} else if (!fUserSpecifiedLogger) {
537
				}
537
//				RemoteAntBuildListener client= new RemoteAntBuildListener(launch);
538
			} else if (!fUserSpecifiedLogger) {
538
//				if (port != -1) {
539
				RemoteAntBuildListener client= new RemoteAntBuildListener(launch);
539
//					client.startListening(port);
540
				if (port != -1) {
540
//				}
541
					client.startListening(port);
541
//			}
542
				}
542
//		}
543
			}
543
//		
544
		}
544
//		ILaunchConfigurationWorkingCopy copy= configuration.getWorkingCopy();
545
		
545
//		setDefaultWorkingDirectory(copy);
546
		ILaunchConfigurationWorkingCopy copy= configuration.getWorkingCopy();
546
//		copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, commandLine.toString());
547
		setDefaultWorkingDirectory(copy);
547
//		StringBuffer vmArgs= generateVMArguments(copy, setInputHandler, antHome);
548
		copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, commandLine.toString());
548
//		copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs.toString());
549
		StringBuffer vmArgs= generateVMArguments(copy, setInputHandler, antHome);
549
//        copy.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
550
		copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs.toString());
550
//        if (copy.getAttribute(IAntLaunchConfigurationConstants.ATTR_DEFAULT_VM_INSTALL, false)) {
551
        copy.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
551
//        	setDefaultVM(configuration, copy);
552
        if (copy.getAttribute(IAntLaunchConfigurationConstants.ATTR_DEFAULT_VM_INSTALL, false)) {
552
//        }
553
        	setDefaultVM(configuration, copy);
553
//        if (debug) { //do not allow launch in foreground bug 83254
554
        }
554
//            copy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true);
555
        if (debug) { //do not allow launch in foreground bug 83254
555
//        }
556
            copy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true);
556
//        
557
        }
557
//        //set the ANT_HOME environment variable
558
        
558
//        if (antHome != null) {
559
        //set the ANT_HOME environment variable
559
//            Map vars = copy.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, new HashMap(1));
560
        if (antHome != null) {
560
//            vars.put("ANT_HOME", antHome); //$NON-NLS-1$
561
            Map vars = copy.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, new HashMap(1));
561
//            copy.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, vars);
562
            vars.put("ANT_HOME", antHome); //$NON-NLS-1$
562
//        }
563
            copy.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, vars);
563
//
564
        }
564
//		//copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000");
565
565
//		IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 10);
566
		//copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000");
566
//		AntJavaLaunchDelegate delegate= new AntJavaLaunchDelegate();
567
		IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 10);
567
//		delegate.preLaunchCheck(copy, ILaunchManager.RUN_MODE, subMonitor);
568
		AntJavaLaunchDelegate delegate= new AntJavaLaunchDelegate();
568
//		delegate.launch(copy, ILaunchManager.RUN_MODE, launch, subMonitor);
569
		delegate.preLaunchCheck(copy, ILaunchManager.RUN_MODE, subMonitor);
569
//		final IProcess[] processes= launch.getProcesses();
570
		delegate.launch(copy, ILaunchManager.RUN_MODE, launch, subMonitor);
570
//		for (int i = 0; i < processes.length; i++) {
571
		final IProcess[] processes= launch.getProcesses();
571
//			setProcessAttributes(processes[i], idStamp, null, captureOutput);
572
		for (int i = 0; i < processes.length; i++) {
572
//		}
573
			setProcessAttributes(processes[i], idStamp, null, captureOutput);
573
//
574
		}
574
//		if (CommonTab.isLaunchInBackground(copy)) {
575
575
//			// refresh resources after process finishes
576
		if (CommonTab.isLaunchInBackground(copy)) {
576
//			if (RefreshTab.getRefreshScope(configuration) != null) {
577
			// refresh resources after process finishes
577
//				BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(configuration, processes[0]);
578
			if (RefreshTab.getRefreshScope(configuration) != null) {
578
//				refresher.startBackgroundRefresh();
579
				BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(configuration, processes[0]);
579
//			}
580
				refresher.startBackgroundRefresh();
580
//		} else {
581
			}
581
//			final boolean[] terminated= new boolean[1];
582
		} else {
582
//			terminated[0]= launch.isTerminated();
583
			final boolean[] terminated= new boolean[1];
583
//			IDebugEventSetListener listener= new IDebugEventSetListener() {
584
			terminated[0]= launch.isTerminated();
584
//				public void handleDebugEvents(DebugEvent[] events) {
585
			IDebugEventSetListener listener= new IDebugEventSetListener() {
585
//					for (int i = 0; i < events.length; i++) {
586
				public void handleDebugEvents(DebugEvent[] events) {
586
//						DebugEvent event = events[i];
587
					for (int i = 0; i < events.length; i++) {
587
//						for (int j= 0, numProcesses= processes.length; j < numProcesses; j++) {
588
						DebugEvent event = events[i];
588
//							if (event.getSource() == processes[j] && event.getKind() == DebugEvent.TERMINATE) {
589
						for (int j= 0, numProcesses= processes.length; j < numProcesses; j++) {
589
//								terminated[0]= true;
590
							if (event.getSource() == processes[j] && event.getKind() == DebugEvent.TERMINATE) {
590
//								break;
591
								terminated[0]= true;
591
//							}
592
								break;
592
//						}
593
							}
593
//					}
594
						}
594
//				}
595
					}
595
//			};
596
				}
596
//			DebugPlugin.getDefault().addDebugEventListener(listener);
597
			};
597
//			monitor.subTask(AntLaunchConfigurationMessages.AntLaunchDelegate_28);
598
			DebugPlugin.getDefault().addDebugEventListener(listener);
598
//			while (!monitor.isCanceled() && !terminated[0]) {
599
			monitor.subTask(AntLaunchConfigurationMessages.AntLaunchDelegate_28);
599
//				try {
600
			while (!monitor.isCanceled() && !terminated[0]) {
600
//					Thread.sleep(50);
601
				try {
601
//				} catch (InterruptedException e) {
602
					Thread.sleep(50);
602
//				}
603
				} catch (InterruptedException e) {
603
//			}
604
				}
604
//			DebugPlugin.getDefault().removeDebugEventListener(listener);
605
			}
605
//			if (!monitor.isCanceled()) {
606
			DebugPlugin.getDefault().removeDebugEventListener(listener);
606
//				// refresh resources
607
			if (!monitor.isCanceled()) {
607
//				RefreshTab.refreshResources(configuration, monitor);
608
				// refresh resources
608
//			}
609
				RefreshTab.refreshResources(configuration, monitor);
609
//		}
610
			}
610
//	}
611
		}
611
//
612
	}
612
//	private void setDefaultVM(ILaunchConfiguration configuration, ILaunchConfigurationWorkingCopy copy) {
613
613
//		try {
614
	private void setDefaultVM(ILaunchConfiguration configuration, ILaunchConfigurationWorkingCopy copy) {
614
//			JavaRuntime.getJavaProject(configuration);
615
		try {
615
//			//remove the vm name, install type and jre container path for the Java launching concept of default VM
616
			JavaRuntime.getJavaProject(configuration);
616
//			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, (String)null);
617
			//remove the vm name, install type and jre container path for the Java launching concept of default VM
617
//			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, (String)null);
618
			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, (String)null);
618
//			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, (String)null);
619
			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, (String)null);
619
//		} catch (CoreException ce) {
620
			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, (String)null);
620
//			//not in a Java project
621
		} catch (CoreException ce) {
621
//			IVMInstall defaultVMInstall= JavaRuntime.getDefaultVMInstall();
622
			//not in a Java project
622
//			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, defaultVMInstall.getName());
623
			IVMInstall defaultVMInstall= JavaRuntime.getDefaultVMInstall();
623
//			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, defaultVMInstall.getVMInstallType().getId());
624
			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, defaultVMInstall.getName());
624
//		}
625
			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, defaultVMInstall.getVMInstallType().getId());
625
//	}
626
		}
626
//	
627
	}
627
//	private StringBuffer generateVMArguments(ILaunchConfiguration config, boolean setInputHandler, String antHome) {
628
	
628
//		StringBuffer vmArgs= new StringBuffer();
629
	private StringBuffer generateVMArguments(ILaunchConfiguration config, boolean setInputHandler, String antHome) {
629
//		try {
630
		StringBuffer vmArgs= new StringBuffer();
630
//			String configArgs= config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String)null);
631
		try {
631
//			if (configArgs != null) {
632
			String configArgs= config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String)null);
632
//				vmArgs.append(configArgs);
633
			if (configArgs != null) {
633
//				vmArgs.append(' ');
634
				vmArgs.append(configArgs);
634
//			}
635
				vmArgs.append(' ');
635
//		} catch (CoreException e) {
636
			}
636
//		}
637
		} catch (CoreException e) {
637
//	
638
		}
638
//        if (antHome != null) {
639
	
639
//            vmArgs.append("-Dant.home=\""); //$NON-NLS-1$
640
        if (antHome != null) {
640
//            vmArgs.append(antHome);
641
            vmArgs.append("-Dant.home=\""); //$NON-NLS-1$
641
//            vmArgs.append("\" "); //$NON-NLS-1$
642
            vmArgs.append(antHome);
642
//        
643
            vmArgs.append("\" "); //$NON-NLS-1$
643
//            File antLibDir= new File(antHome, "lib"); //$NON-NLS-1$
644
        
644
//            vmArgs.append("-Dant.library.dir=\""); //$NON-NLS-1$
645
            File antLibDir= new File(antHome, "lib"); //$NON-NLS-1$
645
//            vmArgs.append(antLibDir.getAbsolutePath());
646
            vmArgs.append("-Dant.library.dir=\""); //$NON-NLS-1$
646
//            vmArgs.append('\"');
647
            vmArgs.append(antLibDir.getAbsolutePath());
647
//        }
648
            vmArgs.append('\"');
648
//		if (setInputHandler) {
649
        }
649
//			String swtLocation= getSWTLibraryLocation();
650
		if (setInputHandler) {
650
//			if (swtLocation != null) {
651
			String swtLocation= getSWTLibraryLocation();
651
//				vmArgs.append(" -Djava.library.path=\""); //$NON-NLS-1$
652
			if (swtLocation != null) {
652
//				String javaLibPath= System.getProperty("java.library.path"); //$NON-NLS-1$
653
				vmArgs.append(" -Djava.library.path=\""); //$NON-NLS-1$
653
//                javaLibPath= stripUnescapedQuotes(javaLibPath);
654
				String javaLibPath= System.getProperty("java.library.path"); //$NON-NLS-1$
654
//				if (javaLibPath != null) {
655
                javaLibPath= stripUnescapedQuotes(javaLibPath);
655
//					vmArgs.append(javaLibPath);
656
				if (javaLibPath != null) {
656
//					if (vmArgs.charAt(vmArgs.length() - 1) != File.pathSeparatorChar) {
657
					vmArgs.append(javaLibPath);
657
//						vmArgs.append(File.pathSeparatorChar);
658
					if (vmArgs.charAt(vmArgs.length() - 1) != File.pathSeparatorChar) {
658
//					}
659
						vmArgs.append(File.pathSeparatorChar);
659
//				}
660
					}
660
//				vmArgs.append(swtLocation);
661
				}
661
//				vmArgs.append('"');
662
				vmArgs.append(swtLocation);
662
//			}
663
				vmArgs.append('"');
663
//		}
664
			}
664
//		return vmArgs;
665
		}
665
//    }
666
		return vmArgs;
666
//
667
    }
667
//    private String stripUnescapedQuotes(String javaLibPath) {
668
668
//        StringBuffer buf = new StringBuffer(javaLibPath.length());
669
    private String stripUnescapedQuotes(String javaLibPath) {
669
//        for (int i = 0; i < javaLibPath.length(); i++) {
670
        StringBuffer buf = new StringBuffer(javaLibPath.length());
670
//            char c = javaLibPath.charAt(i);
671
        for (int i = 0; i < javaLibPath.length(); i++) {
671
//            switch (c) {
672
            char c = javaLibPath.charAt(i);
672
//                case '"':
673
            switch (c) {
673
//                    if (i != 0 && javaLibPath.charAt(i-1) == '\\') {
674
                case '"':
674
//                        buf.append(c);
675
                    if (i != 0 && javaLibPath.charAt(i-1) == '\\') {
675
//                    }
676
                        buf.append(c);
676
//                    break;
677
                    }
677
//                default:
678
                    break;
678
//                    buf.append(c);
679
                default:
679
//                    break;
680
                    buf.append(c);
680
//            }
681
                    break;
681
//        }
682
            }
682
//        return buf.toString();
683
        }
683
//    }
684
        return buf.toString();
684
//
685
    }
685
//    /* (non-Javadoc)
686
686
//	 * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
687
    /* (non-Javadoc)
687
//	 */
688
	 * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
688
//	protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
689
	 */
689
//		IProject[] projects = ExternalToolsBuildTab.getBuildProjects(configuration, ATTR_BUILD_SCOPE);
690
	protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
690
//		if (projects == null) {
691
		IProject[] projects = ExternalToolsBuildTab.getBuildProjects(configuration, ATTR_BUILD_SCOPE);
691
//			return NO_PROJECTS;
692
		if (projects == null) {
692
//		}
693
			return NO_PROJECTS;
693
//		boolean isRef = ExternalToolsBuildTab.isIncludeReferencedProjects(configuration, ATTR_INCLUDE_REFERENCED_PROJECTS);
694
		}
694
//		if (isRef) {
695
		boolean isRef = ExternalToolsBuildTab.isIncludeReferencedProjects(configuration, ATTR_INCLUDE_REFERENCED_PROJECTS);
695
//			return computeReferencedBuildOrder(projects);
696
		if (isRef) {
696
//		}
697
			return computeReferencedBuildOrder(projects);
697
//		return computeBuildOrder(projects);
698
		}
698
//	}
699
		return computeBuildOrder(projects);
699
//
700
	}
700
//	private String getSWTLibraryLocation() {
701
701
//       if (fgSWTLibraryLocation == null) {
702
	private String getSWTLibraryLocation() {
702
//            Bundle bundle= Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$
703
       if (fgSWTLibraryLocation == null) {
703
//            BundleDescription description= Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId());
704
            Bundle bundle= Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$
704
//            BundleDescription[] fragments= description.getFragments();
705
            BundleDescription description= Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId());
705
//            if (fragments == null || fragments.length == 0) {
706
            BundleDescription[] fragments= description.getFragments();
706
//                return null;
707
            if (fragments == null || fragments.length == 0) {
707
//            }
708
                return null;
708
//            Bundle fragBundle= Platform.getBundle(fragments[0].getSymbolicName());
709
            }
709
//            try {
710
            Bundle fragBundle= Platform.getBundle(fragments[0].getSymbolicName());
710
//                URL url= FileLocator.toFileURL(fragBundle.getEntry("/")); //$NON-NLS-1$
711
            try {
711
//                IPath path= new Path(url.getPath());
712
                URL url= FileLocator.toFileURL(fragBundle.getEntry("/")); //$NON-NLS-1$
712
//                path= path.removeTrailingSeparator();
713
                IPath path= new Path(url.getPath());
713
//                fgSWTLibraryLocation= path.toOSString();
714
                path= path.removeTrailingSeparator();
714
//            } catch (IOException e) {
715
                fgSWTLibraryLocation= path.toOSString();
715
//            }
716
            } catch (IOException e) {
716
//		}
717
            }
717
//        return fgSWTLibraryLocation;
718
		}
718
//	}
719
        return fgSWTLibraryLocation;
719
//    
720
	}
720
//     /* (non-Javadoc)
721
    
721
//     * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBreakpoints(org.eclipse.debug.core.ILaunchConfiguration)
722
     /* (non-Javadoc)
722
//     */
723
     * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBreakpoints(org.eclipse.debug.core.ILaunchConfiguration)
723
//    protected IBreakpoint[] getBreakpoints(ILaunchConfiguration configuration) {
724
     */
724
//         IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
725
    protected IBreakpoint[] getBreakpoints(ILaunchConfiguration configuration) {
725
//         if (!breakpointManager.isEnabled()) {
726
         IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
726
//             // no need to check breakpoints individually.
727
         if (!breakpointManager.isEnabled()) {
727
//             return null;
728
             // no need to check breakpoints individually.
728
//         }
729
             return null;
729
//         return breakpointManager.getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL);
730
         }
730
//     }
731
         return breakpointManager.getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL);
731
//
732
     }
732
//	/* (non-Javadoc)
733
733
//	 * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#saveBeforeLaunch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
734
	/* (non-Javadoc)
734
//	 */
735
	 * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#saveBeforeLaunch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
735
//	protected boolean saveBeforeLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
736
	 */
736
//		if (IExternalToolConstants.ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY.equals(
737
	protected boolean saveBeforeLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
737
//				configuration.getType().getCategory())) {
738
		if (IExternalToolConstants.ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY.equals(
738
//					// don't prompt for builders
739
				configuration.getType().getCategory())) {
739
//					return true;
740
					// don't prompt for builders
740
//		}
741
					return true;
741
//		return super.saveBeforeLaunch(configuration, mode, monitor);
742
		}
742
//	}
743
		return super.saveBeforeLaunch(configuration, mode, monitor);
743
//	
744
	}
744
//	/**
745
	
745
//	 * Sets the default working directory to be the parent folder of the buildfile if
746
	/**
746
//	 * the user has not explicitly set the working directory.
747
	 * Sets the default working directory to be the parent folder of the buildfile if
747
//	 */
748
	 * the user has not explicitly set the working directory.
748
//	private void setDefaultWorkingDirectory(ILaunchConfigurationWorkingCopy copy) {
749
	 */
749
//		try {
750
	private void setDefaultWorkingDirectory(ILaunchConfigurationWorkingCopy copy) {
750
//			String wd = copy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
751
		try {
751
//			if (wd == null) {
752
			String wd = copy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
752
//				wd= ExternalToolsUtil.getLocation(copy).removeLastSegments(1).toOSString();
753
			if (wd == null) {
753
//				copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, wd);
754
				wd= ExternalToolsUtil.getLocation(copy).removeLastSegments(1).toOSString();
754
//			}
755
				copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, wd);
755
//		} catch (CoreException e) {
756
			}
756
//			AntUIPlugin.log(e.getStatus());
757
		} catch (CoreException e) {
757
//		}
758
			AntUIPlugin.log(e.getStatus());
758
//	}
759
		}
759
//}
760
	}
761
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntBuilderTargetsTab.java (-2 / +2 lines)
Lines 13-21 Link Here
13
import java.util.HashMap;
13
import java.util.HashMap;
14
import java.util.Map;
14
import java.util.Map;
15
15
16
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
16
import org.eclipse.ant.internal.ui.AntUIImages;
17
import org.eclipse.ant.internal.ui.AntUIImages;
17
import org.eclipse.ant.internal.ui.AntUIPlugin;
18
import org.eclipse.ant.internal.ui.AntUIPlugin;
18
import org.eclipse.ant.internal.ui.AntUtil;
19
import org.eclipse.ant.internal.ui.IAntUIConstants;
19
import org.eclipse.ant.internal.ui.IAntUIConstants;
20
import org.eclipse.core.resources.IncrementalProjectBuilder;
20
import org.eclipse.core.resources.IncrementalProjectBuilder;
21
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.CoreException;
Lines 182-188 Link Here
182
            }
182
            }
183
            targetsSelected= configTargets;
183
            targetsSelected= configTargets;
184
        }
184
        }
185
        String[] targets= AntUtil.parseRunTargets(targetsSelected);
185
        String[] targets= AntLaunchingUtil.parseRunTargets(targetsSelected);
186
        StringBuffer result= new StringBuffer(targets[0]);
186
        StringBuffer result= new StringBuffer(targets[0]);
187
        for (int i = 1; i < targets.length; i++) {
187
        for (int i = 1; i < targets.length; i++) {
188
             result.append(", "); //$NON-NLS-1$
188
             result.append(", "); //$NON-NLS-1$
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/TaskLinkManager.java (-117 / +103 lines)
Lines 10-29 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.launchConfigurations;
11
package org.eclipse.ant.internal.ui.launchConfigurations;
12
12
13
13
import java.io.File;
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.HashMap;
15
import java.util.HashMap;
16
import java.util.Iterator;
16
import java.util.Iterator;
17
import java.util.List;
17
import java.util.List;
18
import java.util.Map;
18
import java.util.Map;
19
19
20
import org.apache.tools.ant.util.FileUtils;
21
import org.eclipse.ant.internal.launching.AntLaunch;
22
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
23
import org.eclipse.ant.internal.launching.LinkDescriptor;
20
import org.eclipse.ant.internal.ui.AntUtil;
24
import org.eclipse.ant.internal.ui.AntUtil;
25
import org.eclipse.ant.internal.ui.ExternalHyperlink;
21
import org.eclipse.core.resources.IFile;
26
import org.eclipse.core.resources.IFile;
22
import org.eclipse.debug.core.model.IProcess;
27
import org.eclipse.debug.core.model.IProcess;
23
import org.eclipse.debug.ui.console.FileLink;
28
import org.eclipse.debug.ui.console.FileLink;
24
import org.eclipse.debug.ui.console.IConsole;
29
import org.eclipse.debug.ui.console.IConsole;
25
import org.eclipse.jface.text.BadLocationException;
30
import org.eclipse.jface.text.BadLocationException;
26
import org.eclipse.jface.text.IRegion;
31
import org.eclipse.jface.text.IRegion;
32
import org.eclipse.jface.text.Region;
27
import org.eclipse.ui.console.IHyperlink;
33
import org.eclipse.ui.console.IHyperlink;
28
34
29
/**
35
/**
Lines 33-93 Link Here
33
 * each build event associated with a task. When the associated line is later
39
 * each build event associated with a task. When the associated line is later
34
 * appended to the console, the corresponding text region in the console
40
 * appended to the console, the corresponding text region in the console
35
 * document is determined (as the length of a console document can not be
41
 * document is determined (as the length of a console document can not be
36
 * determined beforehand), and the hyperlink is added to the document.
42
 * determined beforehand), and the hyperlink is added to the document. The new
37
 * The new line is added to the console, information from that line 
43
 * line is added to the console, information from that line may be stored to
38
 * may be stored to process future incoming tasks hyperlinks.
44
 * process future incoming tasks hyperlinks.
39
 */
45
 */
40
public class TaskLinkManager {
46
public class TaskLinkManager {
41
	
47
42
	/**
43
	 * A map of processes to lists of queued task hyperlink entries
44
	 */
45
	private static Map fgProcessToLinks;
46
	
47
	/**
48
	/**
48
	 * A map of processes to lists of queued new line regions
49
	 * A map of processes to lists of queued new line regions
49
	 */
50
	 */
50
	private static Map fgProcessToNewLines;
51
	private static Map fgProcessToNewLines;
52
53
	private static Map fFileNameToIFile = new HashMap();
54
55
	private static File fBuildFileParent = null;
51
	
56
	
52
	private static List fgAntBuilds;
57
	private Map links;
53
	
58
54
	private static class HyperlinkEntry {
59
	private static class HyperlinkEntry {
55
		private IHyperlink fLink;
60
		private IHyperlink fLink;
56
		private IRegion fRegion;
61
		private IRegion fRegion;
57
		private String fMessage;
62
		private String fMessage;
58
		
63
59
		public HyperlinkEntry(IHyperlink link, IRegion region, String message) {
64
		public HyperlinkEntry(IHyperlink link, IRegion region, String message) {
60
			fLink = link;
65
			fLink = link;
61
			fRegion = region;	
66
			fRegion = region;
62
			fMessage = message;
67
			fMessage = message;
63
		}
68
		}
64
		
69
65
		public IRegion getRegion() {
70
		public IRegion getRegion() {
66
			return fRegion;
71
			return fRegion;
67
		}
72
		}
68
		
73
69
		public IHyperlink getLink() {
74
		public IHyperlink getLink() {
70
			return fLink;
75
			return fLink;
71
		}
76
		}
72
		
77
73
		public String getMessage() {
78
		public String getMessage() {
74
			return fMessage;
79
			return fMessage;
75
		}
80
		}
76
	}
81
	}
77
	
82
78
	private static class LineEntry {
83
	private static class LineEntry {
79
		private IConsole fConsole;
84
		private IConsole fConsole;
80
		private IRegion fRegion;
85
		private IRegion fRegion;
81
	
86
82
		public LineEntry(IConsole console, IRegion region) {
87
		public LineEntry(IConsole console, IRegion region) {
83
			fConsole = console;
88
			fConsole = console;
84
			fRegion = region;	
89
			fRegion = region;
85
		}
90
		}
86
	
91
87
		public IRegion getRegion() {
92
		public IRegion getRegion() {
88
			return fRegion;
93
			return fRegion;
89
		}
94
		}
90
	
95
91
		public IConsole getConsole() {
96
		public IConsole getConsole() {
92
			return fConsole;
97
			return fConsole;
93
		}
98
		}
Lines 99-148 Link Here
99
	private TaskLinkManager() {
104
	private TaskLinkManager() {
100
		super();
105
		super();
101
	}
106
	}
102
	
107
103
	/**
108
	private static HyperlinkEntry createHyperlink(
104
	 * Registers a hyperlink for the given process and task name. The given
109
			LinkDescriptor linkDescriptor, IProcess process) {
105
	 * region is relative to the beginning of the line (not the document).
110
		String line = linkDescriptor.getLine();
106
	 * 
111
		String fileName = linkDescriptor.getFileName();
107
	 * @param process the process associated with the link
112
		int lineNumber = linkDescriptor.getLineNumber();
108
	 * @param link the link for the process
113
		int offset = linkDescriptor.getOffset();
109
	 * @param region The region within the line
114
		int length = linkDescriptor.getLength();
110
	 * @param message The message related to the link
115
111
	 */
116
		IHyperlink taskLink = null;
112
	public static synchronized void addTaskHyperlink(IProcess process, IHyperlink link, IRegion region, String message) {
117
		if (lineNumber == -1) {
113
		if (fgProcessToNewLines != null) {
118
			// fileName will actually be the String representation of Location
114
			List newLines = (List)fgProcessToNewLines.get(process);
119
			taskLink = AntUtil.getLocationLink(fileName, fBuildFileParent);
115
			if (newLines != null) {
120
		} else {
116
				for (int index= 0; index < newLines.size(); index++) {
121
			IFile file = (IFile) fFileNameToIFile.get(fileName);
117
					LineEntry newLine = (LineEntry) newLines.get(index);
122
			if (file == null) {
118
					if (addLink(newLine.getConsole(), link, newLine.getRegion(), region, message)) {
123
				file = AntLaunchingUtil.getFileForLocation(fileName,
119
						newLines.subList(0, index + 1).clear();
124
						fBuildFileParent);
120
						return;
125
				if (file != null) {
126
					fFileNameToIFile.put(fileName, file);
127
					taskLink = new FileLink(file, null, -1, -1, lineNumber);
128
				} else {
129
					File javaIOFile = FileUtils.getFileUtils().resolveFile(
130
							fBuildFileParent, fileName);
131
					if (javaIOFile.exists()) {
132
						taskLink = new ExternalHyperlink(javaIOFile, lineNumber);
121
					}
133
					}
122
				}
134
				}
135
			} else {
136
				taskLink = new FileLink(file, null, -1, -1, lineNumber);
123
			}
137
			}
124
		}
138
		}
125
				
139
		if (taskLink != null) {
126
		if (fgProcessToLinks == null) {
140
			return new HyperlinkEntry(taskLink, new Region(offset, length),
127
			fgProcessToLinks = new HashMap();
141
					line);
128
			
129
		}
142
		}
130
		List links = (List)fgProcessToLinks.get(process);
143
		return null;
131
		if (links == null) {
144
	}
132
			links = new ArrayList(10);
145
133
			fgProcessToLinks.put(process, links);
146
	public static Map createHyperlinksForLaunch(IProcess process) {
147
		Map links = new HashMap();
148
		AntLaunch antLaunch = (AntLaunch) process.getLaunch();
149
		List linksDescriptors = antLaunch.getLinkDescriptors();
150
		for (int i = 0; i < linksDescriptors.size(); i ++) {
151
			links.put(linksDescriptors.get(i), createHyperlink((LinkDescriptor) linksDescriptors.get(i),
152
					process));
134
		}
153
		}
135
		
154
		return links;
136
		links.add(new HyperlinkEntry(link, region, message));
137
	}
155
	}
138
	
156
139
	private static boolean addLink(IConsole console, IHyperlink link, IRegion lineRegion, IRegion region, String message) {
157
	private static boolean addLink(IConsole console, IHyperlink link,
140
		
158
			IRegion lineRegion, IRegion region, String message) {
141
		int length = region.getLength();
159
		int length = region.getLength();
142
		
143
		String text;
160
		String text;
144
		try {
161
		try {
145
			text = console.getDocument().get(lineRegion.getOffset(), lineRegion.getLength());
162
			text = console.getDocument().get(lineRegion.getOffset(),
163
					lineRegion.getLength());
146
		} catch (BadLocationException e) {
164
		} catch (BadLocationException e) {
147
			return false;
165
			return false;
148
		}
166
		}
Lines 156-204 Link Here
156
174
157
	/**
175
	/**
158
	 * A new line has been added to the given console. Adds any task hyperlink
176
	 * A new line has been added to the given console. Adds any task hyperlink
159
	 * associated with the line, to the console.
177
	 * associated with the line, to the console. The new line may be stored to
160
	 * The new line may be stored to process future incoming tasks hyperlinks.
178
	 * process future incoming tasks hyperlinks.
161
	 * 
179
	 * 
162
	 * @param console
180
	 * @param console
163
	 * @param newLine
181
	 * @param newLine
164
	 */
182
	 */
165
	public static synchronized void processNewLine(IConsole console, IRegion newLine) {
183
	public static synchronized void processNewLine(IConsole console,
184
			IRegion newLine) {
166
		IProcess process = console.getProcess();
185
		IProcess process = console.getProcess();
167
		if (fgAntBuilds != null && fgAntBuilds.contains(process)) {
186
168
			if (linkBuildFileMessage(console, newLine)) {
187
		Map links = createHyperlinksForLaunch(process);
169
				fgAntBuilds.remove(process);
188
170
				return;
189
		if (linkBuildFileMessage(console, newLine)) {
171
			}
172
		}
173
		if (fgProcessToLinks == null) {
174
			addNewLine(console, newLine, process);
175
			return;
190
			return;
176
		}
191
		}
177
		
192
178
		List links = (List)fgProcessToLinks.get(process);
179
		if (links == null) {
193
		if (links == null) {
180
			addNewLine(console, newLine, process);
194
			addNewLine(console, newLine, process);
181
			return;
195
			return;
182
		}
196
		}
183
		
197
184
		for (int index= 0; index < links.size(); index++) {
198
		for (Iterator i = links.keySet().iterator(); i.hasNext();) {
185
			HyperlinkEntry link = (HyperlinkEntry) links.get(index);
199
			LinkDescriptor keyLinkDescriptor = (LinkDescriptor) i.next();
186
			if (addLink(console, link.getLink(), newLine, link.getRegion(), link.getMessage())) {
200
			HyperlinkEntry link = (HyperlinkEntry) links.get(keyLinkDescriptor);
187
				links.subList(0, index + 1).clear();
201
			if (addLink(console, link.getLink(), newLine, link.getRegion(),
202
					link.getMessage())) {
203
				((AntLaunch) process.getLaunch()).removeLinkDescriptor(keyLinkDescriptor);
204
				links.remove(keyLinkDescriptor);
188
				return;
205
				return;
189
			}
206
			}
190
		}
207
		}
191
	}
208
	}
192
	
209
193
	private static void addNewLine(IConsole console, IRegion newLine, IProcess process) {
210
	private static void addNewLine(IConsole console, IRegion newLine,
211
			IProcess process) {
194
		if (fgProcessToNewLines == null) {
212
		if (fgProcessToNewLines == null) {
195
			fgProcessToNewLines = new HashMap();
213
			fgProcessToNewLines = new HashMap();
196
		}
214
		}
197
		List newLines = (List)fgProcessToNewLines.get(process);
215
		List newLines = (List) fgProcessToNewLines.get(process);
198
		if (newLines == null) {
216
		if (newLines == null) {
199
			newLines= new ArrayList();
217
			newLines = new ArrayList();
200
		}
218
		}
201
	
219
202
		newLines.add(new LineEntry(console, newLine));
220
		newLines.add(new LineEntry(console, newLine));
203
		fgProcessToNewLines.put(process, newLines);
221
		fgProcessToNewLines.put(process, newLines);
204
	}
222
	}
Lines 209-264 Link Here
209
	 * @param process
227
	 * @param process
210
	 */
228
	 */
211
	public static void dispose(IProcess process) {
229
	public static void dispose(IProcess process) {
212
		if (fgProcessToLinks != null) {
213
			fgProcessToLinks.remove(process);
214
		}
215
		if (fgProcessToNewLines != null) {
230
		if (fgProcessToNewLines != null) {
216
			fgProcessToNewLines.remove(process);
231
			fgProcessToNewLines.remove(process);
217
		}
232
		}
218
		if (fgAntBuilds != null) {
219
			fgAntBuilds.remove(process);
220
		}
221
	}
233
	}
222
	
234
223
	/**
224
	 * Registers the specified process as an Ant build process.
225
	 * Allows for the generation of the "Buildfile: somefile" link in the 
226
	 * Ant output.
227
	 * 
228
	 * @param process
229
	 */
230
	public static synchronized void registerAntBuild(IProcess process) {
231
		if (fgProcessToNewLines != null) {
232
			List newLines = (List)fgProcessToNewLines.get(process);
233
			if (newLines != null) {
234
				for (Iterator iter = newLines.iterator(); iter.hasNext();) {
235
					LineEntry newLine = (LineEntry) iter.next();
236
					if (linkBuildFileMessage(newLine.getConsole(), newLine.getRegion())){
237
						iter.remove();
238
						return;
239
					}
240
				}
241
			}
242
		}
243
		if (fgAntBuilds == null) {
244
			fgAntBuilds= new ArrayList();
245
		}
246
		fgAntBuilds.add(process);
247
	}
248
	
249
	private static boolean linkBuildFileMessage(IConsole console, IRegion region) {
235
	private static boolean linkBuildFileMessage(IConsole console, IRegion region) {
250
		
236
251
		String message= ""; //$NON-NLS-1$
237
		String message = ""; //$NON-NLS-1$
252
		int offset= region.getOffset();
238
		int offset = region.getOffset();
253
		try {
239
		try {
254
			message = console.getDocument().get(offset, region.getLength());
240
			message = console.getDocument().get(offset, region.getLength());
255
		} catch (BadLocationException e) {
241
		} catch (BadLocationException e) {
256
		}
242
		}
257
		if (message.startsWith("Buildfile:")) { //$NON-NLS-1$
243
		if (message.startsWith("Buildfile:")) { //$NON-NLS-1$
258
			String fileName = message.substring(10).trim();
244
			String fileName = message.substring(10).trim();
259
			IFile file = AntUtil.getFileForLocation(fileName, null);
245
			IFile file = AntLaunchingUtil.getFileForLocation(fileName, null);
260
			if (file != null) {
246
			if (file != null) {
261
				FileLink link = new FileLink(file, null,  -1, -1, -1);
247
				FileLink link = new FileLink(file, null, -1, -1, -1);
262
				console.addLink(link, offset + 11, fileName.length());
248
				console.addLink(link, offset + 11, fileName.length());
263
				return true;
249
				return true;
264
			}
250
			}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchConfigurationMessages.properties (-14 lines)
Lines 15-28 Link Here
15
AddVariableStringAction_3=&Variables...
15
AddVariableStringAction_3=&Variables...
16
AddVariableStringAction_4=Add Variable Classpath Entry
16
AddVariableStringAction_4=Add Variable Classpath Entry
17
17
18
AntLaunchDelegate_Launching__0__1=Launching {0}
19
AntLaunchDelegate_Running__0__2=Running {0}
20
AntLaunchDelegate_Build_In_Progress=Ant build {0} already in progress. Concurrent Ant builds are possible if you specify to build in a separate JRE.
21
AntLaunchDelegate_Failure=Failure of Background Ant Build
22
AntLaunchDelegate_22=&Do not show error dialog when Ant build fails
23
AntLaunchDelegate_23=Ant Build Failed
24
AntLaunchDelegate_28=Waiting for virtual machine to exit...
25
26
AntLaunchShortcut_Unable=Unable to find an Ant file to run.
18
AntLaunchShortcut_Unable=Unable to find an Ant file to run.
27
AntLaunchShortcut_2=An exception occurred while creating a default Ant launch configuration for {0}
19
AntLaunchShortcut_2=An exception occurred while creating a default Ant launch configuration for {0}
28
AntLaunchShortcut_3=An exception occurred while retrieving Ant launch configurations.
20
AntLaunchShortcut_3=An exception occurred while retrieving Ant launch configurations.
Lines 41-48 Link Here
41
AntJRETab_2=Run in the same &JRE as the workspace
33
AntJRETab_2=Run in the same &JRE as the workspace
42
AntJRETab_3=Se&parate JRE:
34
AntJRETab_3=Se&parate JRE:
43
35
44
AntHomeClasspathEntry_8=Ant Home (Default)
45
AntHomeClasspathEntry_9=Ant Home ({0})
46
AntBuilderTargetsTab_0=<Builder is not set to run for this build kind>
36
AntBuilderTargetsTab_0=<Builder is not set to run for this build kind>
47
AntBuilderTargetsTab_1=After a "Clean":
37
AntBuilderTargetsTab_1=After a "Clean":
48
AntBuilderTargetsTab_2=&Set Targets...
38
AntBuilderTargetsTab_2=&Set Targets...
Lines 53-60 Link Here
53
AntBuilderTargetsTab_7=During a "Clean":
43
AntBuilderTargetsTab_7=During a "Clean":
54
AntBuilderTargetsTab_8=Set Tar&gets...
44
AntBuilderTargetsTab_8=Set Tar&gets...
55
AntBuilderTargetsTab_10=<default target selected>
45
AntBuilderTargetsTab_10=<default target selected>
56
AntHomeClasspathEntry_10=Ant Home {0} does not exist
57
AntHomeClasspathEntry_11=Ant Home {0} does not contain a "lib" directory
58
46
59
AntMainTab__Select_a_build_file__1=&Select a buildfile:
47
AntMainTab__Select_a_build_file__1=&Select a buildfile:
60
AntMainTab_3=Base Direct&ory:
48
AntMainTab_3=Base Direct&ory:
Lines 81-88 Link Here
81
AntTargetsTab_1=No targets could be determined for the buildfile
69
AntTargetsTab_1=No targets could be determined for the buildfile
82
AntClasspathTab_0=Add F&olders...
70
AntClasspathTab_0=Add F&olders...
83
71
84
ContributedClasspathEntriesEntry_1=Additional Tasks & Support
85
86
EditAntHomeEntryAction_1=Ant &Home...
72
EditAntHomeEntryAction_1=Ant &Home...
87
73
88
TargetOrderDialog_Order_Targets_1=Order Targets
74
TargetOrderDialog_Order_Targets_1=Order Targets
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntClasspathProvider.java (-50 / +51 lines)
Lines 1-50 Link Here
1
/*******************************************************************************
1
///*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
// * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
// * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
// * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
// * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
// * http://www.eclipse.org/legal/epl-v10.html
7
 * 
7
// * 
8
 * Contributors:
8
// * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
// *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
// *******************************************************************************/
11
11
//
12
package org.eclipse.ant.internal.ui.launchConfigurations;
12
//package org.eclipse.ant.internal.ui.launchConfigurations;
13
13
//
14
import java.util.ArrayList;
14
//import java.util.ArrayList;
15
import java.util.List;
15
//import java.util.List;
16
16
//
17
import org.eclipse.core.runtime.CoreException;
17
//import org.eclipse.ant.internal.launching.launchConfigurations.AntHomeClasspathEntry;
18
import org.eclipse.debug.core.ILaunchConfiguration;
18
//import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
19
//import org.eclipse.debug.core.ILaunchConfiguration;
20
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
20
//import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
21
import org.eclipse.jdt.launching.JavaRuntime;
21
//import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
22
import org.eclipse.jdt.launching.StandardClasspathProvider;
22
//import org.eclipse.jdt.launching.JavaRuntime;
23
23
//import org.eclipse.jdt.launching.StandardClasspathProvider;
24
public class AntClasspathProvider extends StandardClasspathProvider {
24
//
25
25
//public class AntClasspathProvider extends StandardClasspathProvider {
26
	/* (non-Javadoc)
26
//
27
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathProvider#computeUnresolvedClasspath(org.eclipse.debug.core.ILaunchConfiguration)
27
//	/* (non-Javadoc)
28
	 */
28
//	 * @see org.eclipse.jdt.launching.IRuntimeClasspathProvider#computeUnresolvedClasspath(org.eclipse.debug.core.ILaunchConfiguration)
29
	public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException {
29
//	 */
30
		boolean useDefault = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
30
//	public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException {
31
		if (useDefault) {
31
//		boolean useDefault = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
32
			List rtes = new ArrayList(10);
32
//		if (useDefault) {
33
			IRuntimeClasspathEntry jreEntry = null;
33
//			List rtes = new ArrayList(10);
34
			try {
34
//			IRuntimeClasspathEntry jreEntry = null;
35
				jreEntry = JavaRuntime.computeJREEntry(configuration);
35
//			try {
36
			} catch (CoreException e) {
36
//				jreEntry = JavaRuntime.computeJREEntry(configuration);
37
				// not a java project
37
//			} catch (CoreException e) {
38
			}
38
//				// not a java project
39
			if (jreEntry == null) {
39
//			}
40
				jreEntry = JavaRuntime.newRuntimeContainerClasspathEntry(
40
//			if (jreEntry == null) {
41
						JavaRuntime.newDefaultJREContainerPath(), IRuntimeClasspathEntry.STANDARD_CLASSES);
41
//				jreEntry = JavaRuntime.newRuntimeContainerClasspathEntry(
42
			}
42
//						JavaRuntime.newDefaultJREContainerPath(), IRuntimeClasspathEntry.STANDARD_CLASSES);
43
			rtes.add(jreEntry);
43
//			}
44
			rtes.add(new AntHomeClasspathEntry());
44
//			rtes.add(jreEntry);
45
			rtes.add(new ContributedClasspathEntriesEntry());
45
//			rtes.add(new AntHomeClasspathEntry());
46
			return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]);
46
//			rtes.add(new ContributedClasspathEntriesEntry());
47
		}
47
//			return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]);
48
		return super.computeUnresolvedClasspath(configuration);
48
//		}
49
	}
49
//		return super.computeUnresolvedClasspath(configuration);
50
}
50
//	}
51
//}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/ContributedClasspathEntriesEntry.java (-246 / +246 lines)
Lines 1-246 Link Here
1
/*******************************************************************************
1
///*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
// * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
// * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
// * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
// * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
// * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
// *
8
 * Contributors:
8
// * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
// *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
// *******************************************************************************/
11
package org.eclipse.ant.internal.ui.launchConfigurations;
11
//package org.eclipse.ant.internal.ui.launchConfigurations;
12
12
//
13
import java.io.File;
13
//import java.io.File;
14
import java.io.FilenameFilter;
14
//import java.io.FilenameFilter;
15
import java.io.IOException;
15
//import java.io.IOException;
16
import java.net.MalformedURLException;
16
//import java.net.MalformedURLException;
17
import java.net.URL;
17
//import java.net.URL;
18
import java.util.ArrayList;
18
//import java.util.ArrayList;
19
import java.util.List;
19
//import java.util.List;
20
20
//
21
import org.eclipse.ant.core.AntCorePlugin;
21
//import org.eclipse.ant.core.AntCorePlugin;
22
import org.eclipse.ant.core.AntCorePreferences;
22
//import org.eclipse.ant.core.AntCorePreferences;
23
import org.eclipse.ant.core.IAntClasspathEntry;
23
//import org.eclipse.ant.core.IAntClasspathEntry;
24
import org.eclipse.ant.internal.ui.AntUIPlugin;
24
//import org.eclipse.ant.internal.launching.AntLaunchingUtil;
25
import org.eclipse.ant.internal.ui.AntUtil;
25
//import org.eclipse.ant.internal.ui.AntUIPlugin;
26
import org.eclipse.ant.internal.ui.IAntUIConstants;
26
//import org.eclipse.ant.internal.ui.IAntUIConstants;
27
import org.eclipse.core.runtime.CoreException;
27
//import org.eclipse.core.runtime.CoreException;
28
import org.eclipse.core.runtime.FileLocator;
28
//import org.eclipse.core.runtime.FileLocator;
29
import org.eclipse.core.runtime.IPath;
29
//import org.eclipse.core.runtime.IPath;
30
import org.eclipse.core.runtime.Path;
30
//import org.eclipse.core.runtime.Path;
31
import org.eclipse.core.runtime.Platform;
31
//import org.eclipse.core.runtime.Platform;
32
import org.eclipse.debug.core.ILaunchConfiguration;
32
//import org.eclipse.debug.core.ILaunchConfiguration;
33
import org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry;
33
//import org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry;
34
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
34
//import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
35
import org.eclipse.jdt.launching.IVMInstall;
35
//import org.eclipse.jdt.launching.IVMInstall;
36
import org.eclipse.jdt.launching.JavaRuntime;
36
//import org.eclipse.jdt.launching.JavaRuntime;
37
import org.eclipse.osgi.service.resolver.BundleDescription;
37
//import org.eclipse.osgi.service.resolver.BundleDescription;
38
import org.osgi.framework.Bundle;
38
//import org.osgi.framework.Bundle;
39
import org.w3c.dom.Document;
39
//import org.w3c.dom.Document;
40
import org.w3c.dom.Element;
40
//import org.w3c.dom.Element;
41
41
//
42
/**
42
///**
43
 * A classpath entry that contains a contributed classpath entries
43
// * A classpath entry that contains a contributed classpath entries
44
 * via the <code>extraClasspathEntries</code> extension point.
44
// * via the <code>extraClasspathEntries</code> extension point.
45
 * 
45
// * 
46
 * @since 3.0 
46
// * @since 3.0 
47
 */
47
// */
48
public class ContributedClasspathEntriesEntry extends AbstractRuntimeClasspathEntry {
48
//public class ContributedClasspathEntriesEntry extends AbstractRuntimeClasspathEntry {
49
	
49
//	
50
	public static final String TYPE_ID = "org.eclipse.ant.ui.classpathentry.extraClasspathEntries"; //$NON-NLS-1$
50
//	public static final String TYPE_ID = "org.eclipse.ant.ui.classpathentry.extraClasspathEntries"; //$NON-NLS-1$
51
    
51
//    
52
    public static List fgSWTEntries= null;
52
//    public static List fgSWTEntries= null;
53
		
53
//		
54
	/**
54
//	/**
55
	 * Default contructor required to instantiate persisted extensions.
55
//	 * Default contructor required to instantiate persisted extensions.
56
	 */
56
//	 */
57
	public ContributedClasspathEntriesEntry() {
57
//	public ContributedClasspathEntriesEntry() {
58
	}
58
//	}
59
	
59
//	
60
	/* (non-Javadoc)
60
//	/* (non-Javadoc)
61
	 * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element)
61
//	 * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element)
62
	 */
62
//	 */
63
	protected void buildMemento(Document document, Element memento) throws CoreException {
63
//	protected void buildMemento(Document document, Element memento) throws CoreException {
64
	}
64
//	}
65
	
65
//	
66
	/* (non-Javadoc)
66
//	/* (non-Javadoc)
67
	 * @see org.eclipse.jdt.internal.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element)
67
//	 * @see org.eclipse.jdt.internal.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element)
68
	 */
68
//	 */
69
	public void initializeFrom(Element memento) throws CoreException {
69
//	public void initializeFrom(Element memento) throws CoreException {
70
	}
70
//	}
71
	
71
//	
72
	/* (non-Javadoc)
72
//	/* (non-Javadoc)
73
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId()
73
//	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId()
74
	 */
74
//	 */
75
	public String getTypeId() {
75
//	public String getTypeId() {
76
		return TYPE_ID;
76
//		return TYPE_ID;
77
	}
77
//	}
78
	
78
//	
79
	/* (non-Javadoc)
79
//	/* (non-Javadoc)
80
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration)
80
//	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration)
81
	 */
81
//	 */
82
	public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException {
82
//	public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException {
83
		boolean separateVM= AntUtil.isSeparateJREAntBuild(configuration);
83
//		boolean separateVM= AntLaunchingUtil.isSeparateJREAntBuild(configuration);
84
		boolean setInputHandler= configuration.getAttribute(IAntUIConstants.SET_INPUTHANDLER, true);
84
//		boolean setInputHandler= configuration.getAttribute(IAntUIConstants.SET_INPUTHANDLER, true);
85
		AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences();
85
//		AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences();
86
		IAntClasspathEntry[] antClasspathEntries = prefs.getContributedClasspathEntries();
86
//		IAntClasspathEntry[] antClasspathEntries = prefs.getContributedClasspathEntries();
87
		IAntClasspathEntry[] userEntries = prefs.getAdditionalClasspathEntries();
87
//		IAntClasspathEntry[] userEntries = prefs.getAdditionalClasspathEntries();
88
		List rtes = new ArrayList(antClasspathEntries.length + userEntries.length);
88
//		List rtes = new ArrayList(antClasspathEntries.length + userEntries.length);
89
		IAntClasspathEntry entry;
89
//		IAntClasspathEntry entry;
90
		for (int i = 0; i < antClasspathEntries.length; i++) {
90
//		for (int i = 0; i < antClasspathEntries.length; i++) {
91
			 entry= antClasspathEntries[i];
91
//			 entry= antClasspathEntries[i];
92
			if (!separateVM || (separateVM && !entry.isEclipseRuntimeRequired())) {
92
//			if (!separateVM || (separateVM && !entry.isEclipseRuntimeRequired())) {
93
				rtes.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel()));
93
//				rtes.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel()));
94
			}
94
//			}
95
		}
95
//		}
96
		boolean haveToolsEntry= false;
96
//		boolean haveToolsEntry= false;
97
		String path;
97
//		String path;
98
		for (int i = 0; i < userEntries.length; i++) {
98
//		for (int i = 0; i < userEntries.length; i++) {
99
			entry = userEntries[i];
99
//			entry = userEntries[i];
100
			path= entry.getLabel();
100
//			path= entry.getLabel();
101
            IPath toolsPath= new Path(path);
101
//            IPath toolsPath= new Path(path);
102
			if (toolsPath.lastSegment().equals("tools.jar")) { //$NON-NLS-1$
102
//			if (toolsPath.lastSegment().equals("tools.jar")) { //$NON-NLS-1$
103
				haveToolsEntry= true;
103
//				haveToolsEntry= true;
104
				// replace with dynamically resolved tools.jar based on
104
//				// replace with dynamically resolved tools.jar based on
105
				// the JRE being used
105
//				// the JRE being used
106
				addToolsJar(configuration, rtes, path);
106
//				addToolsJar(configuration, rtes, path);
107
			} else {
107
//			} else {
108
				rtes.add(JavaRuntime.newStringVariableClasspathEntry(path));
108
//				rtes.add(JavaRuntime.newStringVariableClasspathEntry(path));
109
			}
109
//			}
110
		}
110
//		}
111
		if (!haveToolsEntry) {
111
//		if (!haveToolsEntry) {
112
			addToolsJar(configuration, rtes, null);
112
//			addToolsJar(configuration, rtes, null);
113
		}
113
//		}
114
		
114
//		
115
		if (setInputHandler && separateVM) {
115
//		if (setInputHandler && separateVM) {
116
			addSWTJars(rtes);
116
//			addSWTJars(rtes);
117
		}
117
//		}
118
		
118
//		
119
		return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]);
119
//		return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]);
120
	}
120
//	}
121
	
121
//	
122
	private void addToolsJar(ILaunchConfiguration configuration, List rtes, String path) {
122
//	private void addToolsJar(ILaunchConfiguration configuration, List rtes, String path) {
123
		IRuntimeClasspathEntry tools = getToolsJar(configuration);
123
//		IRuntimeClasspathEntry tools = getToolsJar(configuration);
124
		if (tools == null) {
124
//		if (tools == null) {
125
			if (path != null) {
125
//			if (path != null) {
126
				//use the global entry
126
//				//use the global entry
127
				rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(path)));
127
//				rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(path)));
128
			} else {
128
//			} else {
129
				//use the default vm install to try to find a tools.jar
129
//				//use the default vm install to try to find a tools.jar
130
				IVMInstall install= JavaRuntime.getDefaultVMInstall();
130
//				IVMInstall install= JavaRuntime.getDefaultVMInstall();
131
				if (install != null) {
131
//				if (install != null) {
132
					IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath()));
132
//					IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath()));
133
					if (entry != null) {
133
//					if (entry != null) {
134
						rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath())));
134
//						rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath())));
135
					}
135
//					}
136
				}
136
//				}
137
			}
137
//			}
138
		} else {
138
//		} else {
139
			rtes.add(tools);
139
//			rtes.add(tools);
140
		}
140
//		}
141
	}
141
//	}
142
	
142
//	
143
	private void addSWTJars(List rtes) {
143
//	private void addSWTJars(List rtes) {
144
        if (fgSWTEntries == null) {
144
//        if (fgSWTEntries == null) {
145
            fgSWTEntries= new ArrayList();
145
//            fgSWTEntries= new ArrayList();
146
            Bundle bundle= Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$
146
//            Bundle bundle= Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$
147
            BundleDescription description= Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId());
147
//            BundleDescription description= Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId());
148
            BundleDescription[] fragments= description.getFragments();
148
//            BundleDescription[] fragments= description.getFragments();
149
            for (int i = 0; i < fragments.length; i++) {
149
//            for (int i = 0; i < fragments.length; i++) {
150
                Bundle fragmentBundle= Platform.getBundle(fragments[i].getName());
150
//                Bundle fragmentBundle= Platform.getBundle(fragments[i].getName());
151
                URL bundleURL;
151
//                URL bundleURL;
152
                try {
152
//                try {
153
                    bundleURL = FileLocator.resolve(fragmentBundle.getEntry("/")); //$NON-NLS-1$
153
//                    bundleURL = FileLocator.resolve(fragmentBundle.getEntry("/")); //$NON-NLS-1$
154
                } catch (IOException e) {
154
//                } catch (IOException e) {
155
                    AntUIPlugin.log(e);
155
//                    AntUIPlugin.log(e);
156
                   continue;
156
//                   continue;
157
                }
157
//                }
158
                String urlFileName= bundleURL.getFile();
158
//                String urlFileName= bundleURL.getFile();
159
                if (urlFileName.startsWith("file:")) { //$NON-NLS-1$
159
//                if (urlFileName.startsWith("file:")) { //$NON-NLS-1$
160
                    try {
160
//                    try {
161
                        urlFileName= new URL(urlFileName).getFile();
161
//                        urlFileName= new URL(urlFileName).getFile();
162
                        if (urlFileName.endsWith("!/")) { //$NON-NLS-1$
162
//                        if (urlFileName.endsWith("!/")) { //$NON-NLS-1$
163
                            urlFileName= urlFileName.substring(0, urlFileName.length() - 2);
163
//                            urlFileName= urlFileName.substring(0, urlFileName.length() - 2);
164
                        }
164
//                        }
165
                    } catch (MalformedURLException e) {
165
//                    } catch (MalformedURLException e) {
166
                        AntUIPlugin.log(e);
166
//                        AntUIPlugin.log(e);
167
                       continue;
167
//                       continue;
168
                    }
168
//                    }
169
                }
169
//                }
170
                IPath fragmentPath= new Path(urlFileName);
170
//                IPath fragmentPath= new Path(urlFileName);
171
                if (fragmentPath.getFileExtension() != null) { //JAR file
171
//                if (fragmentPath.getFileExtension() != null) { //JAR file
172
                    fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath));
172
//                    fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath));
173
                } else { // folder
173
//                } else { // folder
174
                    File bundleFolder= fragmentPath.toFile();
174
//                    File bundleFolder= fragmentPath.toFile();
175
                    if (!bundleFolder.isDirectory()) {
175
//                    if (!bundleFolder.isDirectory()) {
176
                        continue;
176
//                        continue;
177
                    }
177
//                    }
178
                    String[] names= bundleFolder.list(new FilenameFilter() {
178
//                    String[] names= bundleFolder.list(new FilenameFilter() {
179
                        public boolean accept(File dir, String name) {
179
//                        public boolean accept(File dir, String name) {
180
                            return name.endsWith(".jar"); //$NON-NLS-1$
180
//                            return name.endsWith(".jar"); //$NON-NLS-1$
181
                        }
181
//                        }
182
                    });
182
//                    });
183
                    for (int j = 0; j < names.length; j++) {
183
//                    for (int j = 0; j < names.length; j++) {
184
                        String jarName = names[j];
184
//                        String jarName = names[j];
185
                        fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath.append(jarName)));
185
//                        fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath.append(jarName)));
186
                    }
186
//                    }
187
                }
187
//                }
188
            }
188
//            }
189
        }
189
//        }
190
        rtes.addAll(fgSWTEntries);
190
//        rtes.addAll(fgSWTEntries);
191
	}
191
//	}
192
    
192
//    
193
	/**
193
//	/**
194
	 * Returns the tools.jar to use for this launch configuration, or <code>null</code>
194
//	 * Returns the tools.jar to use for this launch configuration, or <code>null</code>
195
	 * if none.
195
//	 * if none.
196
	 * 
196
//	 * 
197
	 * @param configuration configuration to resolve a tools.jar for
197
//	 * @param configuration configuration to resolve a tools.jar for
198
	 * @return associated tools.jar archive, or <code>null</code>
198
//	 * @return associated tools.jar archive, or <code>null</code>
199
	 */
199
//	 */
200
	private IRuntimeClasspathEntry getToolsJar(ILaunchConfiguration configuration) {
200
//	private IRuntimeClasspathEntry getToolsJar(ILaunchConfiguration configuration) {
201
		try {
201
//		try {
202
			IVMInstall install = JavaRuntime.computeVMInstall(configuration);
202
//			IVMInstall install = JavaRuntime.computeVMInstall(configuration);
203
			if (install != null) {
203
//			if (install != null) {
204
				IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath()));
204
//				IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath()));
205
				if (entry != null) {
205
//				if (entry != null) {
206
					return JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath()));
206
//					return JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath()));
207
				}
207
//				}
208
			}
208
//			}
209
		} catch (CoreException ce) {
209
//		} catch (CoreException ce) {
210
			//likely dealing with a non-Java project
210
//			//likely dealing with a non-Java project
211
		}
211
//		}
212
			
212
//			
213
		return null;
213
//		return null;
214
	}
214
//	}
215
	
215
//	
216
	/* (non-Javadoc)
216
//	/* (non-Javadoc)
217
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName()
217
//	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName()
218
	 */
218
//	 */
219
	public String getName() {
219
//	public String getName() {
220
		return AntLaunchConfigurationMessages.ContributedClasspathEntriesEntry_1;
220
//		return AntLaunchConfigurationMessages.ContributedClasspathEntriesEntry_1;
221
	}
221
//	}
222
	/* (non-Javadoc)
222
//	/* (non-Javadoc)
223
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType()
223
//	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType()
224
	 */
224
//	 */
225
	public int getType() {
225
//	public int getType() {
226
		return IRuntimeClasspathEntry.OTHER;
226
//		return IRuntimeClasspathEntry.OTHER;
227
	}
227
//	}
228
	/* (non-Javadoc)
228
//	/* (non-Javadoc)
229
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#isComposite()
229
//	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#isComposite()
230
	 */
230
//	 */
231
	public boolean isComposite() {
231
//	public boolean isComposite() {
232
		return true;
232
//		return true;
233
	}
233
//	}
234
	/* (non-Javadoc)
234
//	/* (non-Javadoc)
235
	 * @see java.lang.Object#equals(java.lang.Object)
235
//	 * @see java.lang.Object#equals(java.lang.Object)
236
	 */
236
//	 */
237
	public boolean equals(Object obj) {
237
//	public boolean equals(Object obj) {
238
		return obj instanceof ContributedClasspathEntriesEntry;
238
//		return obj instanceof ContributedClasspathEntriesEntry;
239
	}
239
//	}
240
	/* (non-Javadoc)
240
//	/* (non-Javadoc)
241
	 * @see java.lang.Object#hashCode()
241
//	 * @see java.lang.Object#hashCode()
242
	 */
242
//	 */
243
	public int hashCode() {
243
//	public int hashCode() {
244
		return getClass().hashCode();
244
//		return getClass().hashCode();
245
	}
245
//	}
246
}
246
//}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/EditAntHomeEntryAction.java (+1 lines)
Lines 12-17 Link Here
12
12
13
import org.eclipse.ant.core.AntCorePlugin;
13
import org.eclipse.ant.core.AntCorePlugin;
14
import org.eclipse.ant.core.AntCorePreferences;
14
import org.eclipse.ant.core.AntCorePreferences;
15
import org.eclipse.ant.internal.launching.launchConfigurations.AntHomeClasspathEntry;
15
import org.eclipse.ant.internal.ui.AntUIPlugin;
16
import org.eclipse.ant.internal.ui.AntUIPlugin;
16
import org.eclipse.ant.internal.ui.IAntUIConstants;
17
import org.eclipse.ant.internal.ui.IAntUIConstants;
17
import org.eclipse.ant.internal.ui.preferences.AntPreferencesMessages;
18
import org.eclipse.ant.internal.ui.preferences.AntPreferencesMessages;
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntWorkingDirectoryBlock.java (-2 / +2 lines)
Lines 16-22 Link Here
16
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.ILaunchConfiguration;
17
import org.eclipse.jdt.internal.debug.ui.launcher.JavaWorkingDirectoryBlock;
17
import org.eclipse.jdt.internal.debug.ui.launcher.JavaWorkingDirectoryBlock;
18
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
18
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
19
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
19
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil;
20
20
21
import com.ibm.icu.text.MessageFormat;
21
import com.ibm.icu.text.MessageFormat;
22
22
Lines 51-57 Link Here
51
		setLaunchConfiguration(configuration);
51
		setLaunchConfiguration(configuration);
52
		try {
52
		try {
53
			try {
53
			try {
54
				fDefaultWorkingDirPath= ExternalToolsUtil.getLocation(configuration).removeLastSegments(1).toOSString();
54
				fDefaultWorkingDirPath= ExternalToolsCoreUtil.getLocation(configuration).removeLastSegments(1).toOSString();
55
			}
55
			}
56
			catch(CoreException ce){}
56
			catch(CoreException ce){}
57
			String wd = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
57
			String wd = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntHomeClasspathEntry.java (-209 / +209 lines)
Lines 1-209 Link Here
1
/*******************************************************************************
1
///*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
// * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
// * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
// * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
// * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
// * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
// *
8
 * Contributors:
8
// * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
// *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
// *******************************************************************************/
11
package org.eclipse.ant.internal.ui.launchConfigurations;
11
//package org.eclipse.ant.internal.ui.launchConfigurations;
12
12
//
13
import java.io.File;
13
//import java.io.File;
14
import com.ibm.icu.text.MessageFormat;
14
//import com.ibm.icu.text.MessageFormat;
15
import java.util.ArrayList;
15
//import java.util.ArrayList;
16
import java.util.List;
16
//import java.util.List;
17
17
//
18
import org.eclipse.ant.core.AntCorePlugin;
18
//import org.eclipse.ant.core.AntCorePlugin;
19
import org.eclipse.ant.core.AntCorePreferences;
19
//import org.eclipse.ant.core.AntCorePreferences;
20
import org.eclipse.ant.core.IAntClasspathEntry;
20
//import org.eclipse.ant.core.IAntClasspathEntry;
21
import org.eclipse.core.runtime.CoreException;
21
//import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IPath;
22
//import org.eclipse.core.runtime.IPath;
23
import org.eclipse.core.runtime.Path;
23
//import org.eclipse.core.runtime.Path;
24
import org.eclipse.debug.core.ILaunchConfiguration;
24
//import org.eclipse.debug.core.ILaunchConfiguration;
25
import org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry;
25
//import org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry;
26
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
26
//import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
27
import org.eclipse.jdt.launching.JavaRuntime;
27
//import org.eclipse.jdt.launching.JavaRuntime;
28
import org.w3c.dom.Document;
28
//import org.w3c.dom.Document;
29
import org.w3c.dom.Element;
29
//import org.w3c.dom.Element;
30
30
//
31
/**
31
///**
32
 * A classpath entry that contains a set of archives for a particular
32
// * A classpath entry that contains a set of archives for a particular
33
 * ANT_HOME.
33
// * ANT_HOME.
34
 * 
34
// * 
35
 * @since 3.0 
35
// * @since 3.0 
36
 */
36
// */
37
public class AntHomeClasspathEntry extends AbstractRuntimeClasspathEntry {
37
//public class AntHomeClasspathEntry extends AbstractRuntimeClasspathEntry {
38
	
38
//	
39
	public static final String TYPE_ID = "org.eclipse.ant.ui.classpathentry.antHome"; //$NON-NLS-1$
39
//	public static final String TYPE_ID = "org.eclipse.ant.ui.classpathentry.antHome"; //$NON-NLS-1$
40
	
40
//	
41
	/**
41
//	/**
42
	 * Local path on disk where Ant Home is located or <code>null</code>
42
//	 * Local path on disk where Ant Home is located or <code>null</code>
43
	 * to indicate the use of the default Ant Home.
43
//	 * to indicate the use of the default Ant Home.
44
	 */
44
//	 */
45
	private String antHomeLocation = null;
45
//	private String antHomeLocation = null;
46
	
46
//	
47
	/**
47
//	/**
48
	 * Creates an AntHome entry for the default AntHome installation.
48
//	 * Creates an AntHome entry for the default AntHome installation.
49
	 */
49
//	 */
50
	public AntHomeClasspathEntry() {
50
//	public AntHomeClasspathEntry() {
51
		antHomeLocation = null;
51
//		antHomeLocation = null;
52
	}
52
//	}
53
	
53
//	
54
	/**
54
//	/**
55
	 * Constructs an AntHome entry for the Ant installed at the specified
55
//	 * Constructs an AntHome entry for the Ant installed at the specified
56
	 * root directory.
56
//	 * root directory.
57
	 * 
57
//	 * 
58
	 * @param antHome path in the local file system to an Ant installation
58
//	 * @param antHome path in the local file system to an Ant installation
59
	 */
59
//	 */
60
	public AntHomeClasspathEntry(String antHome) {
60
//	public AntHomeClasspathEntry(String antHome) {
61
		antHomeLocation = antHome;
61
//		antHomeLocation = antHome;
62
	}
62
//	}
63
		
63
//		
64
	/* (non-Javadoc)
64
//	/* (non-Javadoc)
65
	 * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element)
65
//	 * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element)
66
	 */
66
//	 */
67
	protected void buildMemento(Document document, Element memento) throws CoreException {
67
//	protected void buildMemento(Document document, Element memento) throws CoreException {
68
		if (antHomeLocation == null) {
68
//		if (antHomeLocation == null) {
69
			memento.setAttribute("default", "true");  //$NON-NLS-1$//$NON-NLS-2$
69
//			memento.setAttribute("default", "true");  //$NON-NLS-1$//$NON-NLS-2$
70
		} else {
70
//		} else {
71
			memento.setAttribute("antHome", new Path(antHomeLocation).toString()); //$NON-NLS-1$
71
//			memento.setAttribute("antHome", new Path(antHomeLocation).toString()); //$NON-NLS-1$
72
		}
72
//		}
73
	}
73
//	}
74
	/* (non-Javadoc)
74
//	/* (non-Javadoc)
75
	 * @see org.eclipse.jdt.internal.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element)
75
//	 * @see org.eclipse.jdt.internal.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element)
76
	 */
76
//	 */
77
	public void initializeFrom(Element memento) throws CoreException {
77
//	public void initializeFrom(Element memento) throws CoreException {
78
		String antHome = memento.getAttribute("antHome"); //$NON-NLS-1$
78
//		String antHome = memento.getAttribute("antHome"); //$NON-NLS-1$
79
		if (antHome != null && (antHome.length() > 0)) {
79
//		if (antHome != null && (antHome.length() > 0)) {
80
			IPath path = new Path(antHome);
80
//			IPath path = new Path(antHome);
81
			antHomeLocation = path.toOSString();
81
//			antHomeLocation = path.toOSString();
82
		} else {
82
//		} else {
83
			antHomeLocation = null;
83
//			antHomeLocation = null;
84
		}
84
//		}
85
	}
85
//	}
86
	/* (non-Javadoc)
86
//	/* (non-Javadoc)
87
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId()
87
//	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId()
88
	 */
88
//	 */
89
	public String getTypeId() {
89
//	public String getTypeId() {
90
		return TYPE_ID;
90
//		return TYPE_ID;
91
	}
91
//	}
92
	/* (non-Javadoc)
92
//	/* (non-Javadoc)
93
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration)
93
//	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration)
94
	 */
94
//	 */
95
	public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException {
95
//	public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException {
96
		List libs = new ArrayList(40);
96
//		List libs = new ArrayList(40);
97
		AntCorePreferences preferences = AntCorePlugin.getPlugin().getPreferences();
97
//		AntCorePreferences preferences = AntCorePlugin.getPlugin().getPreferences();
98
		if (antHomeLocation == null) {
98
//		if (antHomeLocation == null) {
99
			IAntClasspathEntry[] entries = preferences.getAntHomeClasspathEntries();
99
//			IAntClasspathEntry[] entries = preferences.getAntHomeClasspathEntries();
100
			for (int i = 0; i < entries.length; i++) {
100
//			for (int i = 0; i < entries.length; i++) {
101
				IAntClasspathEntry entry = entries[i];
101
//				IAntClasspathEntry entry = entries[i];
102
				libs.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel()));
102
//				libs.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel()));
103
			}
103
//			}
104
		} else {
104
//		} else {
105
			File lib= resolveAntHome();
105
//			File lib= resolveAntHome();
106
			IPath libDir = new Path(antHomeLocation).append("lib"); //$NON-NLS-1$
106
//			IPath libDir = new Path(antHomeLocation).append("lib"); //$NON-NLS-1$
107
			String[] fileNames = lib.list();
107
//			String[] fileNames = lib.list();
108
			for (int i = 0; i < fileNames.length; i++) {
108
//			for (int i = 0; i < fileNames.length; i++) {
109
				String name = fileNames[i];
109
//				String name = fileNames[i];
110
				IPath path = new Path(name);
110
//				IPath path = new Path(name);
111
				String fileExtension = path.getFileExtension();
111
//				String fileExtension = path.getFileExtension();
112
				if ("jar".equalsIgnoreCase(fileExtension)) { //$NON-NLS-1$
112
//				if ("jar".equalsIgnoreCase(fileExtension)) { //$NON-NLS-1$
113
					libs.add(JavaRuntime.newArchiveRuntimeClasspathEntry(libDir.append(path)));
113
//					libs.add(JavaRuntime.newArchiveRuntimeClasspathEntry(libDir.append(path)));
114
				}
114
//				}
115
			}
115
//			}
116
		}
116
//		}
117
		return (IRuntimeClasspathEntry[]) libs.toArray(new IRuntimeClasspathEntry[libs.size()]);
117
//		return (IRuntimeClasspathEntry[]) libs.toArray(new IRuntimeClasspathEntry[libs.size()]);
118
	}
118
//	}
119
	
119
//	
120
	public File resolveAntHome() throws CoreException {
120
//	public File resolveAntHome() throws CoreException {
121
		if (antHomeLocation == null) { //using the default ant home
121
//		if (antHomeLocation == null) { //using the default ant home
122
			return null;
122
//			return null;
123
		}
123
//		}
124
		IPath libDir= new Path(antHomeLocation).append("lib"); //$NON-NLS-1$
124
//		IPath libDir= new Path(antHomeLocation).append("lib"); //$NON-NLS-1$
125
		File lib= libDir.toFile();
125
//		File lib= libDir.toFile();
126
		File parentDir= lib.getParentFile();
126
//		File parentDir= lib.getParentFile();
127
		if (parentDir == null || !parentDir.exists()) {
127
//		if (parentDir == null || !parentDir.exists()) {
128
			abort(MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_10, new String[] {antHomeLocation}), null);
128
//			abort(MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_10, new String[] {antHomeLocation}), null);
129
		}
129
//		}
130
		if (!lib.exists() || !lib.isDirectory()) {
130
//		if (!lib.exists() || !lib.isDirectory()) {
131
			abort(MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_11, new String[] {antHomeLocation}), null);
131
//			abort(MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_11, new String[] {antHomeLocation}), null);
132
		}
132
//		}
133
		return lib;
133
//		return lib;
134
	}
134
//	}
135
	
135
//	
136
	/* (non-Javadoc)
136
//	/* (non-Javadoc)
137
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName()
137
//	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName()
138
	 */
138
//	 */
139
	public String getName() {
139
//	public String getName() {
140
		if (antHomeLocation == null) {
140
//		if (antHomeLocation == null) {
141
			return AntLaunchConfigurationMessages.AntHomeClasspathEntry_8;
141
//			return AntLaunchConfigurationMessages.AntHomeClasspathEntry_8;
142
		}
142
//		}
143
		return MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_9, new String[]{antHomeLocation});
143
//		return MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_9, new String[]{antHomeLocation});
144
	}
144
//	}
145
	
145
//	
146
	/* (non-Javadoc)
146
//	/* (non-Javadoc)
147
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType()
147
//	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType()
148
	 */
148
//	 */
149
	public int getType() {
149
//	public int getType() {
150
		return IRuntimeClasspathEntry.OTHER;
150
//		return IRuntimeClasspathEntry.OTHER;
151
	}
151
//	}
152
	
152
//	
153
	/* (non-Javadoc)
153
//	/* (non-Javadoc)
154
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#isComposite()
154
//	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#isComposite()
155
	 */
155
//	 */
156
	public boolean isComposite() {
156
//	public boolean isComposite() {
157
		return true;
157
//		return true;
158
	}
158
//	}
159
	
159
//	
160
	/* (non-Javadoc)
160
//	/* (non-Javadoc)
161
	 * @see java.lang.Object#equals(java.lang.Object)
161
//	 * @see java.lang.Object#equals(java.lang.Object)
162
	 */
162
//	 */
163
	public boolean equals(Object obj) {
163
//	public boolean equals(Object obj) {
164
		return obj instanceof AntHomeClasspathEntry &&
164
//		return obj instanceof AntHomeClasspathEntry &&
165
		  equalsOrNull(antHomeLocation, ((AntHomeClasspathEntry)obj).antHomeLocation);
165
//		  equalsOrNull(antHomeLocation, ((AntHomeClasspathEntry)obj).antHomeLocation);
166
	}
166
//	}
167
	
167
//	
168
	/**
168
//	/**
169
	 * Return whether s1 is equivalent to s2.
169
//	 * Return whether s1 is equivalent to s2.
170
	 * 
170
//	 * 
171
	 * @param s1
171
//	 * @param s1
172
	 * @param s2
172
//	 * @param s2
173
	 * @return whether s1 is equivalent to s2
173
//	 * @return whether s1 is equivalent to s2
174
	 */
174
//	 */
175
	private boolean equalsOrNull(String s1, String s2) {
175
//	private boolean equalsOrNull(String s1, String s2) {
176
		if (s1 == null || s2 == null) {
176
//		if (s1 == null || s2 == null) {
177
			return s1 == s2;
177
//			return s1 == s2;
178
		} 
178
//		} 
179
		return s1.equalsIgnoreCase(s2);
179
//		return s1.equalsIgnoreCase(s2);
180
	}
180
//	}
181
181
//
182
	/* (non-Javadoc)
182
//	/* (non-Javadoc)
183
	 * @see java.lang.Object#hashCode()
183
//	 * @see java.lang.Object#hashCode()
184
	 */
184
//	 */
185
	public int hashCode() {
185
//	public int hashCode() {
186
		return getClass().hashCode();
186
//		return getClass().hashCode();
187
	}	
187
//	}	
188
	
188
//	
189
	/**
189
//	/**
190
	 * Sets the ant home to use.
190
//	 * Sets the ant home to use.
191
	 * 
191
//	 * 
192
	 * @param path path to toor of an ant home installation
192
//	 * @param path path to toor of an ant home installation
193
	 */
193
//	 */
194
	protected void setAntHome(String path) {
194
//	protected void setAntHome(String path) {
195
		antHomeLocation = path;
195
//		antHomeLocation = path;
196
	}
196
//	}
197
	
197
//	
198
	/**
198
//	/**
199
	 * Returns the ant home location
199
//	 * Returns the ant home location
200
	 * 
200
//	 * 
201
	 * @return path to root ant installation directory
201
//	 * @return path to root ant installation directory
202
	 */
202
//	 */
203
	public String getAntHome() {
203
//	public String getAntHome() {
204
		if (antHomeLocation == null) {
204
//		if (antHomeLocation == null) {
205
			return AntCorePlugin.getPlugin().getPreferences().getAntHome();
205
//			return AntCorePlugin.getPlugin().getPreferences().getAntHome();
206
		}
206
//		}
207
		return antHomeLocation;
207
//		return antHomeLocation;
208
	}
208
//	}
209
}
209
//}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntEnvironmentTab.java (-2 / +2 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.launchConfigurations;
11
package org.eclipse.ant.internal.ui.launchConfigurations;
12
12
13
import org.eclipse.ant.internal.ui.AntUtil;
13
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
14
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
14
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
15
import org.eclipse.debug.ui.EnvironmentTab;
15
import org.eclipse.debug.ui.EnvironmentTab;
16
import org.eclipse.jface.dialogs.Dialog;
16
import org.eclipse.jface.dialogs.Dialog;
Lines 60-66 Link Here
60
		if (wrappingComposite == null) {
60
		if (wrappingComposite == null) {
61
			return;
61
			return;
62
		}
62
		}
63
		boolean isSeparateJREBuild= AntUtil.isSeparateJREAntBuild(workingCopy);
63
		boolean isSeparateJREBuild= AntLaunchingUtil.isSeparateJREAntBuild(workingCopy);
64
		
64
		
65
		Color tableColor= isSeparateJREBuild ? null : Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
65
		Color tableColor= isSeparateJREBuild ? null : Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
66
		Color labelColor= isSeparateJREBuild ? null : Display.getDefault().getSystemColor(SWT.COLOR_RED);
66
		Color labelColor= isSeparateJREBuild ? null : Display.getDefault().getSystemColor(SWT.COLOR_RED);
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/RemoteAntBuildListener.java (-6 / +6 lines)
Lines 29-39 Link Here
29
import org.apache.tools.ant.Project;
29
import org.apache.tools.ant.Project;
30
import org.apache.tools.ant.util.FileUtils;
30
import org.apache.tools.ant.util.FileUtils;
31
import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger;
31
import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger;
32
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
33
import org.eclipse.ant.internal.launching.IAntLaunchingPreferenceConstants;
32
import org.eclipse.ant.internal.ui.AntUIPlugin;
34
import org.eclipse.ant.internal.ui.AntUIPlugin;
33
import org.eclipse.ant.internal.ui.AntUtil;
35
import org.eclipse.ant.internal.ui.AntUtil;
34
import org.eclipse.ant.internal.ui.ExternalHyperlink;
36
import org.eclipse.ant.internal.ui.ExternalHyperlink;
35
import org.eclipse.ant.internal.ui.IAntUIConstants;
37
import org.eclipse.ant.internal.ui.IAntUIConstants;
36
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
37
import org.eclipse.core.resources.IFile;
38
import org.eclipse.core.resources.IFile;
38
import org.eclipse.core.runtime.ISafeRunnable;
39
import org.eclipse.core.runtime.ISafeRunnable;
39
import org.eclipse.debug.core.DebugPlugin;
40
import org.eclipse.debug.core.DebugPlugin;
Lines 42-48 Link Here
42
import org.eclipse.debug.core.model.IProcess;
43
import org.eclipse.debug.core.model.IProcess;
43
import org.eclipse.debug.ui.console.FileLink;
44
import org.eclipse.debug.ui.console.FileLink;
44
import org.eclipse.jface.preference.IPreferenceStore;
45
import org.eclipse.jface.preference.IPreferenceStore;
45
import org.eclipse.jface.text.Region;
46
import org.eclipse.ui.console.IHyperlink;
46
import org.eclipse.ui.console.IHyperlink;
47
47
48
/**
48
/**
Lines 90-96 Link Here
90
            try {
90
            try {
91
                fServerSocket= new ServerSocket(fServerPort);
91
                fServerSocket= new ServerSocket(fServerPort);
92
                IPreferenceStore prefs = AntUIPlugin.getDefault().getPreferenceStore();
92
                IPreferenceStore prefs = AntUIPlugin.getDefault().getPreferenceStore();
93
                int socketTimeout= prefs.getInt(IAntUIPreferenceConstants.ANT_COMMUNICATION_TIMEOUT);
93
                int socketTimeout= prefs.getInt(IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT);
94
                fServerSocket.setSoTimeout(socketTimeout);
94
                fServerSocket.setSoTimeout(socketTimeout);
95
                fSocket= fServerSocket.accept();
95
                fSocket= fServerSocket.accept();
96
                fBufferedReader= new BufferedReader(new InputStreamReader(fSocket.getInputStream(), "UTF-8")); //$NON-NLS-1$
96
                fBufferedReader= new BufferedReader(new InputStreamReader(fSocket.getInputStream(), "UTF-8")); //$NON-NLS-1$
Lines 179-185 Link Here
179
                	if (message.startsWith("Total time:")) { //$NON-NLS-1$
179
                	if (message.startsWith("Total time:")) { //$NON-NLS-1$
180
                		fBuildFailed= false;
180
                		fBuildFailed= false;
181
                	} else {
181
                	} else {
182
                		AntUtil.linkBuildFailedMessage(message, getProcess());
182
                		AntLaunchingUtil.linkBuildFailedMessage(message, getProcess());
183
                	}
183
                	}
184
				}
184
				}
185
            }
185
            }
Lines 262-268 Link Here
262
        } else {
262
        } else {
263
            IFile file= (IFile) fFileNameToIFile.get(fileName);
263
            IFile file= (IFile) fFileNameToIFile.get(fileName);
264
            if (file == null) {
264
            if (file == null) {
265
                file= AntUtil.getFileForLocation(fileName, fBuildFileParent);
265
                file= AntLaunchingUtil.getFileForLocation(fileName, fBuildFileParent);
266
                if (file != null) {
266
                if (file != null) {
267
                    fFileNameToIFile.put(fileName, file);
267
                    fFileNameToIFile.put(fileName, file);
268
                    taskLink= new FileLink(file, null, -1, -1, lineNumber);
268
                    taskLink= new FileLink(file, null, -1, -1, lineNumber);
Lines 277-283 Link Here
277
            }
277
            }
278
        }
278
        }
279
        if (taskLink != null) {
279
        if (taskLink != null) {
280
            TaskLinkManager.addTaskHyperlink(getProcess(), taskLink, new Region(offset, length), line);
280
            //TaskLinkManager.addTaskHyperlink(getProcess(), taskLink, new Region(offset, length), line);
281
        }
281
        }
282
    }
282
    }
283
    
283
    
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchShortcut.java (-6 / +6 lines)
Lines 14-21 Link Here
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.List;
15
import java.util.List;
16
16
17
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
17
import org.eclipse.ant.internal.ui.AntUIPlugin;
18
import org.eclipse.ant.internal.ui.AntUIPlugin;
18
import org.eclipse.ant.internal.ui.AntUtil;
19
import org.eclipse.ant.internal.ui.IAntUIConstants;
19
import org.eclipse.ant.internal.ui.IAntUIConstants;
20
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
20
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
21
import org.eclipse.ant.internal.ui.model.AntElementNode;
21
import org.eclipse.ant.internal.ui.model.AntElementNode;
Lines 54-60 Link Here
54
import org.eclipse.ui.IWorkbenchPage;
54
import org.eclipse.ui.IWorkbenchPage;
55
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
55
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
56
import org.eclipse.ui.editors.text.ILocationProvider;
56
import org.eclipse.ui.editors.text.ILocationProvider;
57
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
57
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil;
58
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
58
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
59
59
60
import com.ibm.icu.text.MessageFormat;
60
import com.ibm.icu.text.MessageFormat;
Lines 175-181 Link Here
175
				for(int i = 0; i < configs.length; i++) {
175
				for(int i = 0; i < configs.length; i++) {
176
					if(configs[i].exists()) {
176
					if(configs[i].exists()) {
177
						try {
177
						try {
178
							location = ExternalToolsUtil.getLocation(configs[i]);
178
							location = ExternalToolsCoreUtil.getLocation(configs[i]);
179
							if(location != null && location.equals(filepath)) {
179
							if(location != null && location.equals(filepath)) {
180
								list.add(configs[i]);
180
								list.add(configs[i]);
181
							}
181
							}
Lines 343-349 Link Here
343
			//the user has not specified any names to look for
343
			//the user has not specified any names to look for
344
			return null;
344
			return null;
345
		}
345
		}
346
		return AntUtil.parseString(buildFileNames, ","); //$NON-NLS-1$
346
		return AntLaunchingUtil.parseString(buildFileNames, ","); //$NON-NLS-1$
347
	}
347
	}
348
	
348
	
349
	/**
349
	/**
Lines 393-399 Link Here
393
			jreTab.setDefaults(workingCopy);
393
			jreTab.setDefaults(workingCopy);
394
			jreTab.dispose();
394
			jreTab.dispose();
395
			
395
			
396
			IFile file= AntUtil.getFileForLocation(filePath.toString(), null);
396
			IFile file= AntLaunchingUtil.getFileForLocation(filePath.toString(), null);
397
			workingCopy.setMappedResources(new IResource[] {file});
397
			workingCopy.setMappedResources(new IResource[] {file});
398
			
398
			
399
			return workingCopy.doSave();
399
			return workingCopy.doSave();
Lines 421-427 Link Here
421
						ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
421
						ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
422
						for (int i = 0; i < configs.length; i++) {
422
						for (int i = 0; i < configs.length; i++) {
423
							try {
423
							try {
424
								if (filePath.equals(ExternalToolsUtil.getLocation(configs[i]))) {
424
								if (filePath.equals(ExternalToolsCoreUtil.getLocation(configs[i]))) {
425
									validConfigs.add(configs[i]);
425
									validConfigs.add(configs[i]);
426
								}
426
								}
427
							}
427
							}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/IAntUIPreferenceConstants.java (-6 lines)
Lines 34-45 Link Here
34
	public static final String CONSOLE_DEBUG_COLOR = "org.eclipse.ant.ui.debugColor"; //$NON-NLS-1$	
34
	public static final String CONSOLE_DEBUG_COLOR = "org.eclipse.ant.ui.debugColor"; //$NON-NLS-1$	
35
	
35
	
36
	public static final String ANT_TOOLS_JAR_WARNING= "toolsJAR"; //$NON-NLS-1$
36
	public static final String ANT_TOOLS_JAR_WARNING= "toolsJAR"; //$NON-NLS-1$
37
    
38
    /**
39
     * int preference identifier constant which specifies the length of time to wait
40
     * to connect with the socket that communicates with the separate JRE to capture the output
41
     */
42
    public static final String ANT_COMMUNICATION_TIMEOUT= "timeout"; //$NON-NLS-1$
43
	
37
	
44
	public static final String ANT_ERROR_DIALOG= "errorDialog"; //$NON-NLS-1$
38
	public static final String ANT_ERROR_DIALOG= "errorDialog"; //$NON-NLS-1$
45
	
39
	
(-)Ant Tools Support/org/eclipse/ant/internal/ui/AntUIPreferenceInitializer.java (-3 / +1 lines)
Lines 34-42 Link Here
34
		prefs.setDefault(IAntUIPreferenceConstants.ANT_FIND_BUILD_FILE_NAMES, "build.xml"); //$NON-NLS-1$
34
		prefs.setDefault(IAntUIPreferenceConstants.ANT_FIND_BUILD_FILE_NAMES, "build.xml"); //$NON-NLS-1$
35
		
35
		
36
		prefs.setDefault(IAntUIPreferenceConstants.DOCUMENTATION_URL, "http://ant.apache.org/manual"); //$NON-NLS-1$
36
		prefs.setDefault(IAntUIPreferenceConstants.DOCUMENTATION_URL, "http://ant.apache.org/manual"); //$NON-NLS-1$
37
        
37
	
38
        prefs.setDefault(IAntUIPreferenceConstants.ANT_COMMUNICATION_TIMEOUT, 20000);
39
		
40
		EditorsUI.useAnnotationsPreferencePage(prefs);
38
		EditorsUI.useAnnotationsPreferencePage(prefs);
41
		EditorsUI.useQuickDiffPreferencePage(prefs);
39
		EditorsUI.useQuickDiffPreferencePage(prefs);
42
		if (AntUIPlugin.isMacOS()) {
40
		if (AntUIPlugin.isMacOS()) {
(-)Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java (-563 / +283 lines)
Lines 11-17 Link Here
11
package org.eclipse.ant.internal.ui;
11
package org.eclipse.ant.internal.ui;
12
12
13
import java.io.File;
13
import java.io.File;
14
import java.io.IOException;
15
import java.net.MalformedURLException;
14
import java.net.MalformedURLException;
16
import java.net.URL;
15
import java.net.URL;
17
import java.util.ArrayList;
16
import java.util.ArrayList;
Lines 20-36 Link Here
20
import java.util.Iterator;
19
import java.util.Iterator;
21
import java.util.List;
20
import java.util.List;
22
import java.util.Map;
21
import java.util.Map;
23
import java.util.StringTokenizer;
24
import java.util.regex.Pattern;
22
import java.util.regex.Pattern;
25
23
26
import org.apache.tools.ant.BuildException;
27
import org.apache.tools.ant.Target;
24
import org.apache.tools.ant.Target;
28
import org.apache.tools.ant.util.FileUtils;
29
import org.eclipse.ant.core.AntCorePlugin;
25
import org.eclipse.ant.core.AntCorePlugin;
30
import org.eclipse.ant.internal.core.AntCoreUtil;
26
import org.eclipse.ant.internal.core.AntCoreUtil;
27
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
31
import org.eclipse.ant.internal.ui.editor.AntEditor;
28
import org.eclipse.ant.internal.ui.editor.AntEditor;
32
import org.eclipse.ant.internal.ui.launchConfigurations.AntHomeClasspathEntry;
33
import org.eclipse.ant.internal.ui.launchConfigurations.TaskLinkManager;
34
import org.eclipse.ant.internal.ui.model.AntElementNode;
29
import org.eclipse.ant.internal.ui.model.AntElementNode;
35
import org.eclipse.ant.internal.ui.model.AntModel;
30
import org.eclipse.ant.internal.ui.model.AntModel;
36
import org.eclipse.ant.internal.ui.model.AntProjectNode;
31
import org.eclipse.ant.internal.ui.model.AntProjectNode;
Lines 43-50 Link Here
43
import org.eclipse.core.filebuffers.ITextFileBufferManager;
38
import org.eclipse.core.filebuffers.ITextFileBufferManager;
44
import org.eclipse.core.filebuffers.LocationKind;
39
import org.eclipse.core.filebuffers.LocationKind;
45
import org.eclipse.core.resources.IFile;
40
import org.eclipse.core.resources.IFile;
46
import org.eclipse.core.resources.IWorkspaceRoot;
47
import org.eclipse.core.resources.ResourcesPlugin;
48
import org.eclipse.core.runtime.CoreException;
41
import org.eclipse.core.runtime.CoreException;
49
import org.eclipse.core.runtime.IPath;
42
import org.eclipse.core.runtime.IPath;
50
import org.eclipse.core.runtime.IStatus;
43
import org.eclipse.core.runtime.IStatus;
Lines 54-70 Link Here
54
import org.eclipse.core.variables.IStringVariableManager;
47
import org.eclipse.core.variables.IStringVariableManager;
55
import org.eclipse.core.variables.VariablesPlugin;
48
import org.eclipse.core.variables.VariablesPlugin;
56
import org.eclipse.debug.core.ILaunchConfiguration;
49
import org.eclipse.debug.core.ILaunchConfiguration;
57
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
58
import org.eclipse.debug.core.model.IProcess;
59
import org.eclipse.debug.ui.console.FileLink;
50
import org.eclipse.debug.ui.console.FileLink;
60
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
61
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
62
import org.eclipse.jdt.launching.IRuntimeClasspathEntry2;
63
import org.eclipse.jdt.launching.JavaRuntime;
64
import org.eclipse.jface.dialogs.MessageDialog;
51
import org.eclipse.jface.dialogs.MessageDialog;
65
import org.eclipse.jface.text.BadLocationException;
52
import org.eclipse.jface.text.BadLocationException;
66
import org.eclipse.jface.text.IDocument;
53
import org.eclipse.jface.text.IDocument;
67
import org.eclipse.jface.text.Region;
68
import org.eclipse.swt.SWT;
54
import org.eclipse.swt.SWT;
69
import org.eclipse.swt.program.Program;
55
import org.eclipse.swt.program.Program;
70
import org.eclipse.swt.widgets.Shell;
56
import org.eclipse.swt.widgets.Shell;
Lines 78-85 Link Here
78
import org.eclipse.ui.browser.IWebBrowser;
64
import org.eclipse.ui.browser.IWebBrowser;
79
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
65
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
80
import org.eclipse.ui.console.IHyperlink;
66
import org.eclipse.ui.console.IHyperlink;
81
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
67
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil;
82
import org.eclipse.ui.externaltools.internal.model.ExternalToolBuilder;
83
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
68
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
84
import org.eclipse.ui.ide.IDE;
69
import org.eclipse.ui.ide.IDE;
85
import org.eclipse.ui.part.FileEditorInput;
70
import org.eclipse.ui.part.FileEditorInput;
Lines 93-392 Link Here
93
 */
78
 */
94
public final class AntUtil {
79
public final class AntUtil {
95
	public static final String ATTRIBUTE_SEPARATOR = ","; //$NON-NLS-1$;
80
	public static final String ATTRIBUTE_SEPARATOR = ","; //$NON-NLS-1$;
96
	public static final char ANT_CLASSPATH_DELIMITER= '*';
81
	public static final char ANT_CLASSPATH_DELIMITER = '*';
97
	public static final String ANT_HOME_CLASSPATH_PLACEHOLDER= "G"; //$NON-NLS-1$
82
	public static final String ANT_HOME_CLASSPATH_PLACEHOLDER = "G"; //$NON-NLS-1$
98
	public static final String ANT_GLOBAL_USER_CLASSPATH_PLACEHOLDER= "UG"; //$NON-NLS-1$
83
	public static final String ANT_GLOBAL_USER_CLASSPATH_PLACEHOLDER = "UG"; //$NON-NLS-1$
99
	
84
100
	private static String fgBrowserId;
85
	private static String fgBrowserId;
101
	
86
102
	/**
87
	/**
103
	 * No instances allowed
88
	 * No instances allowed
104
	 */
89
	 */
105
	private AntUtil() {
90
	private AntUtil() {
106
		super();
91
		super();
107
	}
92
	}
108
	
109
	/**
110
	 * Returns a single-string of the strings for storage.
111
	 * 
112
	 * @param strings the array of strings
113
	 * @return a single-string representation of the strings or
114
	 * <code>null</code> if the array is empty.
115
	 */
116
	public static String combineStrings(String[] strings) {
117
		if (strings.length == 0)
118
			return null;
119
120
		if (strings.length == 1)
121
			return strings[0];
122
123
		StringBuffer buf = new StringBuffer();
124
		for (int i = 0; i < strings.length - 1; i++) {
125
			buf.append(strings[i]);
126
			buf.append(ATTRIBUTE_SEPARATOR);
127
		}
128
		buf.append(strings[strings.length - 1]);
129
		return buf.toString();
130
	}
131
132
	/**
133
	 * Returns an array of targets to be run, or <code>null</code> if none are
134
	 * specified (indicating the default target or implicit target should be run).
135
	 *
136
	 * @param configuration launch configuration
137
	 * @return array of target names, or <code>null</code>
138
	 * @throws CoreException if unable to access the associated attribute
139
	 */
140
	public static String[] getTargetNames(ILaunchConfiguration configuration) throws CoreException {
141
        String attribute= null;
142
        if (IAntLaunchConfigurationConstants.ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE.equals(configuration.getType().getIdentifier())) {
143
            attribute= getTargetNamesForAntBuilder(configuration);
144
        }
145
        if (attribute == null) {
146
            attribute = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, (String) null);
147
            if (attribute == null) {
148
                return null;
149
            } 
150
        }
151
		
152
		return AntUtil.parseRunTargets(attribute);
153
	}
154
	
155
	private static String getTargetNamesForAntBuilder(ILaunchConfiguration configuration) throws CoreException {
156
        String buildType= ExternalToolBuilder.getBuildType();
157
        String targets= null;
158
        if (IExternalToolConstants.BUILD_TYPE_AUTO.equals(buildType)) {
159
            targets= configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_AUTO_TARGETS, (String)null);
160
        } else if (IExternalToolConstants.BUILD_TYPE_CLEAN.equals(buildType)) {
161
            targets = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_CLEAN_TARGETS, (String) null);
162
        } else if (IExternalToolConstants.BUILD_TYPE_FULL.equals(buildType)) {
163
            targets = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_AFTER_CLEAN_TARGETS, (String) null);
164
        } else if (IExternalToolConstants.BUILD_TYPE_INCREMENTAL.equals(buildType)) {
165
            targets = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_MANUAL_TARGETS, (String) null);
166
        }
167
       
168
        return targets;
169
    }
170
171
    /**
172
	 * Returns a map of properties to be defined for the build, or
173
	 * <code>null</code> if none are specified (indicating no additional
174
	 * properties specified for the build).
175
	 *
176
	 * @param configuration launch configuration
177
	 * @return map of properties (name --> value), or <code>null</code>
178
	 * @throws CoreException if unable to access the associated attribute
179
	 */
180
	public static Map getProperties(ILaunchConfiguration configuration) throws CoreException {
181
		Map map = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTIES, (Map) null);
182
		return map;
183
	}
184
	
185
	/**
186
	 * Returns a String specifying the Ant home to use for the build.
187
	 *
188
	 * @param configuration launch configuration
189
	 * @return String specifying Ant home to use or <code>null</code>
190
	 * @throws CoreException if unable to access the associated attribute
191
	 */
192
	public static String getAntHome(ILaunchConfiguration configuration) throws CoreException {
193
		IRuntimeClasspathEntry[] entries = JavaRuntime.computeUnresolvedRuntimeClasspath(configuration);
194
		for (int i = 0; i < entries.length; i++) {
195
			IRuntimeClasspathEntry entry = entries[i];
196
			if (entry.getType() == IRuntimeClasspathEntry.OTHER) {
197
				IRuntimeClasspathEntry2 entry2 = (IRuntimeClasspathEntry2)entry;
198
				if (entry2.getTypeId().equals(AntHomeClasspathEntry.TYPE_ID)) {
199
					return ((AntHomeClasspathEntry)entry2).getAntHome();
200
				}
201
			}
202
		}
203
		return null;
204
	}
205
93
206
	/**
94
	/**
207
	 * Returns an array of property files to be used for the build, or
95
	 * Returns an array of property files to be used for the build, or
208
	 * <code>null</code> if none are specified (indicating no additional
96
	 * <code>null</code> if none are specified (indicating no additional
209
	 * property files specified for the build).
97
	 * property files specified for the build).
210
	 *
98
	 * 
211
	 * @param configuration launch configuration
99
	 * @param configuration
100
	 *            launch configuration
212
	 * @return array of property file names, or <code>null</code>
101
	 * @return array of property file names, or <code>null</code>
213
	 * @throws CoreException if unable to access the associated attribute
102
	 * @throws CoreException
103
	 *             if unable to access the associated attribute
214
	 */
104
	 */
215
	public static String[] getPropertyFiles(ILaunchConfiguration configuration) throws CoreException {
105
	public static String[] getPropertyFiles(ILaunchConfiguration configuration)
216
		String attribute = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTY_FILES, (String) null);
106
			throws CoreException {
107
		String attribute = configuration.getAttribute(
108
				IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTY_FILES,
109
				(String) null);
217
		if (attribute == null) {
110
		if (attribute == null) {
218
			return null;
111
			return null;
219
		}
112
		}
220
		String[] propertyFiles= AntUtil.parseString(attribute, ","); //$NON-NLS-1$
113
		String[] propertyFiles = AntLaunchingUtil.parseString(attribute, ","); //$NON-NLS-1$
221
		for (int i = 0; i < propertyFiles.length; i++) {
114
		for (int i = 0; i < propertyFiles.length; i++) {
222
			String propertyFile = propertyFiles[i];
115
			String propertyFile = propertyFiles[i];
223
			propertyFile= expandVariableString(propertyFile, AntUIModelMessages.AntUtil_6);
116
			propertyFile = expandVariableString(propertyFile,
224
			propertyFiles[i]= propertyFile;
117
					AntUIModelMessages.AntUtil_6);
118
			propertyFiles[i] = propertyFile;
225
		}
119
		}
226
		return propertyFiles;
120
		return propertyFiles;
227
	}
121
	}
228
	
122
229
	public static AntTargetNode[] getTargets(String path, ILaunchConfiguration config) throws CoreException {
123
	public static AntTargetNode[] getTargets(String path,
230
		File buildfile= getBuildFile(path);
124
			ILaunchConfiguration config) throws CoreException {
125
		File buildfile = getBuildFile(path);
231
		if (buildfile == null) {
126
		if (buildfile == null) {
232
		    return null;
127
			return null;
233
		}
128
		}
234
		URL[] urls= getCustomClasspath(config);
129
		URL[] urls = AntLaunchingUtil.getCustomClasspath(config);
235
		//no lexical, no position, no task
130
		// no lexical, no position, no task
236
		IAntModel model= getAntModel(buildfile, urls, false, false, false);
131
		IAntModel model = getAntModel(buildfile, urls, false, false, false);
237
		try {
132
		try {
238
			model.setProperties(getAllProperties(config));
133
			model.setProperties(getAllProperties(config));
239
		} catch (CoreException ex){
134
		} catch (CoreException ex) {
240
		}
135
		}
241
		model.setPropertyFiles(getPropertyFiles(config));
136
		model.setPropertyFiles(getPropertyFiles(config));
242
		AntProjectNode project= model.getProjectNode(); //forces a reconcile
137
		AntProjectNode project = model.getProjectNode(); // forces a reconcile
243
		model.dispose();
138
		model.dispose();
244
		return getTargets(project);
139
		return getTargets(project);
245
	}
140
	}
246
	
141
247
    private static Map getAllProperties(ILaunchConfiguration config) throws CoreException {
142
	private static Map getAllProperties(ILaunchConfiguration config)
248
        String allArgs = config.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String) null);
143
			throws CoreException {
249
		Map properties= new HashMap();
144
		String allArgs = config.getAttribute(
145
				IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String) null);
146
		Map properties = new HashMap();
250
		if (allArgs != null) {
147
		if (allArgs != null) {
251
			String[] arguments = ExternalToolsUtil.parseStringIntoList(allArgs);
148
			String[] arguments = ExternalToolsCoreUtil
252
			// filter arguments to avoid resolving variables that will prompt the user
149
					.parseStringIntoList(allArgs);
150
			// filter arguments to avoid resolving variables that will prompt
151
			// the user
253
			List filtered = new ArrayList();
152
			List filtered = new ArrayList();
254
			Pattern pattern = Pattern.compile("\\$\\{.*_prompt.*\\}"); //$NON-NLS-1$
153
			Pattern pattern = Pattern.compile("\\$\\{.*_prompt.*\\}"); //$NON-NLS-1$
255
			IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
154
			IStringVariableManager manager = VariablesPlugin.getDefault()
155
					.getStringVariableManager();
256
			for (int i = 0; i < arguments.length; i++) {
156
			for (int i = 0; i < arguments.length; i++) {
257
				String arg = arguments[i];
157
				String arg = arguments[i];
258
				if (arg.startsWith("-D")) { //$NON-NLS-1$
158
				if (arg.startsWith("-D")) { //$NON-NLS-1$
259
					if (!pattern.matcher(arg).find()) {
159
					if (!pattern.matcher(arg).find()) {
260
						filtered.add(manager.performStringSubstitution(arg, false));
160
						filtered.add(manager.performStringSubstitution(arg,
161
								false));
261
					}
162
					}
262
				}
163
				}
263
			}
164
			}
264
		    AntCoreUtil.processMinusDProperties(filtered, properties);
165
			AntCoreUtil.processMinusDProperties(filtered, properties);
265
		}
166
		}
266
		Map configProperties= getProperties(config);
167
		Map configProperties = AntLaunchingUtil.getProperties(config);
267
		if (configProperties != null) {
168
		if (configProperties != null) {
268
		    Iterator keys= configProperties.keySet().iterator();
169
			Iterator keys = configProperties.keySet().iterator();
269
		    while (keys.hasNext()) {
170
			while (keys.hasNext()) {
270
		        String name = (String) keys.next();
171
				String name = (String) keys.next();
271
		        if (properties.get(name) == null) {
172
				if (properties.get(name) == null) {
272
		            properties.put(name, configProperties.get(name));
173
					properties.put(name, configProperties.get(name));
273
		        }
174
				}
274
		    }
175
			}
275
		}
176
		}
276
		return properties;
177
		return properties;
277
    }
178
	}
278
179
279
    private static AntTargetNode[] getTargets(AntProjectNode project) {
180
	private static AntTargetNode[] getTargets(AntProjectNode project) {
280
        if (project == null || !project.hasChildren()) {
181
		if (project == null || !project.hasChildren()) {
281
		    return null;
182
			return null;
282
		}
183
		}
283
		List targets= new ArrayList();
184
		List targets = new ArrayList();
284
		Iterator possibleTargets= project.getChildNodes().iterator();
185
		Iterator possibleTargets = project.getChildNodes().iterator();
285
		while (possibleTargets.hasNext()) {
186
		while (possibleTargets.hasNext()) {
286
			AntElementNode node= (AntElementNode)possibleTargets.next();
187
			AntElementNode node = (AntElementNode) possibleTargets.next();
287
			if (node instanceof AntTargetNode) {
188
			if (node instanceof AntTargetNode) {
288
				targets.add(node);
189
				targets.add(node);
289
			}
190
			}
290
		}
191
		}
291
		if (targets.size() == 0) {
192
		if (targets.size() == 0) {
292
		    return null;
193
			return null;
293
		}
194
		}
294
		return (AntTargetNode[])targets.toArray(new AntTargetNode[targets.size()]);
195
		return (AntTargetNode[]) targets.toArray(new AntTargetNode[targets
295
    }
196
				.size()]);
197
	}
296
198
297
    public static AntTargetNode[] getTargets(String path) {
199
	public static AntTargetNode[] getTargets(String path) {
298
		File buildfile= getBuildFile(path);
200
		File buildfile = getBuildFile(path);
299
		if (buildfile == null) {
201
		if (buildfile == null) {
300
		    return null;
202
			return null;
301
		}
203
		}
302
		//tasks and position info but no lexical info
204
		// tasks and position info but no lexical info
303
		IAntModel model= getAntModel(buildfile, null, false, true, true);
205
		IAntModel model = getAntModel(buildfile, null, false, true, true);
304
		AntProjectNode project= model.getProjectNode();
206
		AntProjectNode project = model.getProjectNode();
305
		if (project == null) {
207
		if (project == null) {
306
			model.dispose();
208
			model.dispose();
307
			return null;
209
			return null;
308
		}
210
		}
309
		AntTargetNode[] targets= getTargets(project);
211
		AntTargetNode[] targets = getTargets(project);
310
        if (targets == null) {
212
		if (targets == null) {
311
            Hashtable antTargets= project.getProject().getTargets();
213
			Hashtable antTargets = project.getProject().getTargets();
312
            Target implicitTarget= (Target) antTargets.get(""); //$NON-NLS-1$
214
			Target implicitTarget = (Target) antTargets.get(""); //$NON-NLS-1$
313
            if (implicitTarget != null) {
215
			if (implicitTarget != null) {
314
                AntTargetNode implicitTargetNode= new AntTargetNode(implicitTarget);
216
				AntTargetNode implicitTargetNode = new AntTargetNode(
315
                project.addChildNode(implicitTargetNode);
217
						implicitTarget);
316
                return new AntTargetNode[] {implicitTargetNode};
218
				project.addChildNode(implicitTargetNode);
317
            }
219
				return new AntTargetNode[] { implicitTargetNode };
318
        }
220
			}
319
        return targets;
221
		}
320
	}
222
		return targets;
321
	
223
	}
322
	public static IAntModel getAntModel(String buildFilePath, boolean needsLexicalResolution, boolean needsPositionResolution, boolean needsTaskResolution) {
224
323
	    IAntModel model= getAntModel(getBuildFile(buildFilePath), null, needsLexicalResolution, needsPositionResolution, needsTaskResolution);
225
	public static IAntModel getAntModel(String buildFilePath,
324
	    return model;   
226
			boolean needsLexicalResolution, boolean needsPositionResolution,
227
			boolean needsTaskResolution) {
228
		IAntModel model = getAntModel(getBuildFile(buildFilePath), null,
229
				needsLexicalResolution, needsPositionResolution,
230
				needsTaskResolution);
231
		return model;
325
	}
232
	}
326
	
233
327
	/**
234
	/**
328
	 * Return a buildfile from the specified location.
235
	 * Return a buildfile from the specified location. If there isn't one return
329
	 * If there isn't one return null.
236
	 * null.
330
	 */
237
	 */
331
	private static File getBuildFile(String path) {
238
	private static File getBuildFile(String path) {
332
		File buildFile = new File(path);
239
		File buildFile = new File(path);
333
		if (!buildFile.isFile() || !buildFile.exists()) { 
240
		if (!buildFile.isFile() || !buildFile.exists()) {
334
			return null;
241
			return null;
335
		}
242
		}
336
243
337
		return buildFile;
244
		return buildFile;
338
	}
245
	}
339
	
246
340
	private static IAntModel getAntModel(final File buildFile, URL[] urls, boolean needsLexical, boolean needsPosition, boolean needsTask) {
247
	private static IAntModel getAntModel(final File buildFile, URL[] urls,
341
	    if (buildFile == null || !buildFile.exists()) {
248
			boolean needsLexical, boolean needsPosition, boolean needsTask) {
342
	        return null;
249
		if (buildFile == null || !buildFile.exists()) {
343
	    }
250
			return null;
344
		IDocument doc= getDocument(buildFile);
251
		}
252
		IDocument doc = getDocument(buildFile);
345
		if (doc == null) {
253
		if (doc == null) {
346
			return null;
254
			return null;
347
		}
255
		}
348
		final IFile file= getFileForLocation(buildFile.getAbsolutePath(), null);
256
		final IFile file = AntLaunchingUtil.getFileForLocation(buildFile
349
		LocationProvider provider= new LocationProvider(null) {
257
				.getAbsolutePath(), null);
350
		    /* (non-Javadoc)
258
		LocationProvider provider = new LocationProvider(null) {
351
		     * @see org.eclipse.ant.internal.ui.model.LocationProvider#getFile()
259
			/*
352
		     */
260
			 * (non-Javadoc)
353
		    public IFile getFile() {
261
			 * 
354
		        return file;
262
			 * @see org.eclipse.ant.internal.ui.model.LocationProvider#getFile()
355
		    }
263
			 */
356
			/* (non-Javadoc)
264
			public IFile getFile() {
357
			 * @see org.eclipse.ant.internal.ui.model.LocationProvider#getLocation()
265
				return file;
266
			}
267
268
			/*
269
			 * (non-Javadoc)
270
			 * 
271
			 * @see
272
			 * org.eclipse.ant.internal.ui.model.LocationProvider#getLocation()
358
			 */
273
			 */
359
			public IPath getLocation() {
274
			public IPath getLocation() {
360
			    if (file == null) {
275
				if (file == null) {
361
			        return new Path(buildFile.getAbsolutePath());   
276
					return new Path(buildFile.getAbsolutePath());
362
			    } 
277
				}
363
			    return file.getLocation();
278
				return file.getLocation();
364
			}
279
			}
365
		};
280
		};
366
		IAntModel model= new AntModel(doc, null, provider, needsLexical, needsPosition, needsTask);
281
		IAntModel model = new AntModel(doc, null, provider, needsLexical,
367
		
282
				needsPosition, needsTask);
283
368
		if (urls != null) {
284
		if (urls != null) {
369
		    model.setClassLoader(AntCorePlugin.getPlugin().getNewClassLoader(urls));
285
			model.setClassLoader(AntCorePlugin.getPlugin().getNewClassLoader(
286
					urls));
370
		}
287
		}
371
		return model;
288
		return model;
372
	}
289
	}
373
	
290
374
	private static IDocument getDocument(File buildFile) {
291
	private static IDocument getDocument(File buildFile) {
375
		ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
292
		ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
376
		IPath location= new Path(buildFile.getAbsolutePath());
293
		IPath location = new Path(buildFile.getAbsolutePath());
377
		boolean connected= false;
294
		boolean connected = false;
378
		try {
295
		try {
379
			ITextFileBuffer buffer= manager.getTextFileBuffer(location, LocationKind.NORMALIZE);
296
			ITextFileBuffer buffer = manager.getTextFileBuffer(location,
297
					LocationKind.NORMALIZE);
380
			if (buffer == null) {
298
			if (buffer == null) {
381
				//no existing file buffer..create one
299
				// no existing file buffer..create one
382
				manager.connect(location, LocationKind.NORMALIZE, new NullProgressMonitor());
300
				manager.connect(location, LocationKind.NORMALIZE,
383
				connected= true;
301
						new NullProgressMonitor());
384
				buffer= manager.getTextFileBuffer(location, LocationKind.NORMALIZE);
302
				connected = true;
303
				buffer = manager.getTextFileBuffer(location,
304
						LocationKind.NORMALIZE);
385
				if (buffer == null) {
305
				if (buffer == null) {
386
					return null;
306
					return null;
387
				}
307
				}
388
			}
308
			}
389
			
309
390
			return buffer.getDocument();
310
			return buffer.getDocument();
391
		} catch (CoreException ce) {
311
		} catch (CoreException ce) {
392
			AntUIPlugin.log(ce.getStatus());
312
			AntUIPlugin.log(ce.getStatus());
Lines 394-493 Link Here
394
		} finally {
314
		} finally {
395
			if (connected) {
315
			if (connected) {
396
				try {
316
				try {
397
					manager.disconnect(location, LocationKind.NORMALIZE, new NullProgressMonitor());
317
					manager.disconnect(location, LocationKind.NORMALIZE,
318
							new NullProgressMonitor());
398
				} catch (CoreException e) {
319
				} catch (CoreException e) {
399
					AntUIPlugin.log(e.getStatus());
320
					AntUIPlugin.log(e.getStatus());
400
				}
321
				}
401
			}
322
			}
402
		}
323
		}
403
	}
324
	}
404
	
405
	/**
406
	 * Returns the list of URLs that define the custom classpath for the Ant
407
	 * build, or <code>null</code> if the global classpath is to be used.
408
	 *
409
	 * @param config launch configuration
410
	 * @return a list of <code>URL</code>
411
	 *
412
	 * @throws CoreException if file does not exist, IO problems, or invalid format.
413
	 */
414
	public static URL[] getCustomClasspath(ILaunchConfiguration config) throws CoreException {
415
		boolean useDefault = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
416
		if (useDefault) {
417
			return null;
418
		}
419
		IRuntimeClasspathEntry[] unresolved = JavaRuntime.computeUnresolvedRuntimeClasspath(config);
420
		// don't consider bootpath entries
421
		List userEntries = new ArrayList(unresolved.length);
422
		for (int i = 0; i < unresolved.length; i++) {
423
			IRuntimeClasspathEntry entry = unresolved[i];
424
			if (entry.getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES) {
425
				userEntries.add(entry);
426
			}
427
		}
428
		IRuntimeClasspathEntry[] entries = JavaRuntime.resolveRuntimeClasspath((IRuntimeClasspathEntry[])userEntries.toArray(new IRuntimeClasspathEntry[userEntries.size()]), config);
429
		URL[] urls = new URL[entries.length];
430
		for (int i = 0; i < entries.length; i++) {
431
			IRuntimeClasspathEntry entry = entries[i];
432
			try {
433
				urls[i] = new URL("file:"+entry.getLocation()); //$NON-NLS-1$
434
			} catch (MalformedURLException e) {
435
				throw new CoreException(new Status(IStatus.ERROR, AntUIPlugin.getUniqueIdentifier(), AntUIPlugin.INTERNAL_ERROR, AntUIModelMessages.AntUtil_7, e));
436
			}
437
		}
438
		return urls;		
439
	}
440
325
441
	private static String expandVariableString(String variableString, String invalidMessage) throws CoreException {
326
	private static String expandVariableString(String variableString,
442
		String expandedString = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(variableString);
327
			String invalidMessage) throws CoreException {
328
		String expandedString = VariablesPlugin.getDefault()
329
				.getStringVariableManager().performStringSubstitution(
330
						variableString);
443
		if (expandedString == null || expandedString.length() == 0) {
331
		if (expandedString == null || expandedString.length() == 0) {
444
			String msg = MessageFormat.format(invalidMessage, new String[] {variableString});
332
			String msg = MessageFormat.format(invalidMessage,
445
			throw new CoreException(new Status(IStatus.ERROR, IAntUIConstants.PLUGIN_ID, 0, msg, null));
333
					new String[] { variableString });
446
		} 
334
			throw new CoreException(new Status(IStatus.ERROR,
447
		
335
					IAntUIConstants.PLUGIN_ID, 0, msg, null));
448
		return expandedString;
449
	}
450
	
451
	/**
452
	 * Returns the list of target names to run
453
	 * 
454
	 * @param extraAttibuteValue the external tool's extra attribute value
455
	 * 		for the run targets key.
456
	 * @return a list of target names
457
	 */
458
	public static String[] parseRunTargets(String extraAttibuteValue) {
459
		return parseString(extraAttibuteValue, ATTRIBUTE_SEPARATOR);
460
	}
461
	
462
	/**
463
	 * Returns the list of Strings that were delimiter separated.
464
	 * 
465
	 * @param delimString the String to be tokenized based on the delimiter
466
	 * @return a list of Strings
467
	 */
468
	public static String[] parseString(String delimString, String delim) {
469
		if (delimString == null) {
470
			return new String[0];
471
		}
472
		
473
		// Need to handle case where separator character is
474
		// actually part of the target name!
475
		StringTokenizer tokenizer = new StringTokenizer(delimString, delim);
476
		String[] results = new String[tokenizer.countTokens()];
477
		for (int i = 0; i < results.length; i++) {
478
			results[i] = tokenizer.nextToken();
479
		}
336
		}
480
		
337
481
		return results;
338
		return expandedString;
482
	}
483
	
484
	/**
485
	 * Returns an IFile with the given fully qualified path (relative to the workspace root).
486
	 * The returned IFile may or may not exist.
487
	 */
488
	public static IFile getFile(String fullPath) {
489
		IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
490
		return root.getFile(new Path(fullPath));
491
	}
339
	}
492
340
493
	public static IHyperlink getLocationLink(String path, File buildFileParent) {
341
	public static IHyperlink getLocationLink(String path, File buildFileParent) {
Lines 497-508 Link Here
497
		}
345
		}
498
		if (path.startsWith("file:")) { //$NON-NLS-1$
346
		if (path.startsWith("file:")) { //$NON-NLS-1$
499
			// remove "file:"
347
			// remove "file:"
500
			path= path.substring(5, path.length());
348
			path = path.substring(5, path.length());
501
		}
349
		}
502
		// format is file:F:L: where F is file path, and L is line number
350
		// format is file:F:L: where F is file path, and L is line number
503
		int index = path.lastIndexOf(':');
351
		int index = path.lastIndexOf(':');
504
		if (index == -1) {
352
		if (index == -1) {
505
			//incorrect format
353
			// incorrect format
506
			return null;
354
			return null;
507
		}
355
		}
508
		if (index == path.length() - 1) {
356
		if (index == path.length() - 1) {
Lines 515-797 Link Here
515
		try {
363
		try {
516
			String lineNumber = path.substring(index + 1);
364
			String lineNumber = path.substring(index + 1);
517
			int line = Integer.parseInt(lineNumber);
365
			int line = Integer.parseInt(lineNumber);
518
			IFile file = getFileForLocation(fileName, buildFileParent);
366
			IFile file = AntLaunchingUtil.getFileForLocation(fileName,
367
					buildFileParent);
519
			if (file != null) {
368
			if (file != null) {
520
				return new FileLink(file, null, -1, -1, line);
369
				return new FileLink(file, null, -1, -1, line);
521
			}
370
			}
522
		} catch (NumberFormatException e) {
371
		} catch (NumberFormatException e) {
523
		}
372
		}
524
		
373
525
		return null;
374
		return null;
526
	}
375
	}
527
376
528
	/**
377
	private static int getOffset(int line, int column, ITextEditor editor) {
529
	 * Returns the workspace file associated with the given path in the
378
		IDocumentProvider provider = editor.getDocumentProvider();
530
	 * local file system, or <code>null</code> if none.
379
		IEditorInput input = editor.getEditorInput();
531
	 * If the path happens to be a relative path, then the path is interpreted as
380
		try {
532
	 * relative to the specified parent file.
381
			provider.connect(input);
533
	 * 
382
		} catch (CoreException e) {
534
	 * Attempts to handle linked files; the first found linked file with the correct
383
			return -1;
535
	 * path is returned.
536
	 *   
537
	 * @param path
538
	 * @param buildFileParent
539
	 * @return file or <code>null</code>
540
	 * @see org.eclipse.core.resources.IWorkspaceRoot#findFilesForLocation(IPath)
541
	 */
542
	public static IFile getFileForLocation(String path, File buildFileParent) {
543
		if (path == null) {
544
			return null;
545
		}
384
		}
546
		IPath filePath= new Path(path);
385
		try {
547
		IFile file = null;
386
			IDocument document = provider.getDocument(input);
548
		IFile[] files= ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(filePath);
387
			if (document != null) {
549
		if (files.length > 0) {
388
				if (column > -1) {
550
			file= files[0];
389
					// column marks the length..adjust to 0 index and to be
551
		}
390
					// within the element's source range
552
		if (file == null) {
391
					return document.getLineOffset(line - 1) + column - 1 - 2;
553
			//relative path
554
			File relativeFile= null;
555
			try {
556
				//this call is ok if buildFileParent is null
557
				relativeFile= FileUtils.getFileUtils().resolveFile(buildFileParent, path);
558
				filePath= new Path(relativeFile.getAbsolutePath());
559
				files= ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(filePath);
560
				if (files.length > 0) {
561
					file= files[0];
562
				} else {
563
					return null;
564
				}
392
				}
565
			} catch (BuildException be) {
393
				return document.getLineOffset(line - 1);
566
				return null;
567
			}
394
			}
395
		} catch (BadLocationException e) {
396
		} finally {
397
			provider.disconnect(input);
568
		}
398
		}
569
		
399
		return -1;
570
		if (file.exists()) {
571
			return file;
572
		} 
573
		File ioFile= file.getLocation().toFile();
574
		if (ioFile.exists()) {//needs to handle case insensitivity on WINOS
575
			try {
576
				files= ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(ioFile.getCanonicalPath()));
577
				if (files.length > 0) {
578
					return files[0];
579
				}
580
			} catch (IOException e) {
581
			}			
582
		}
583
			
584
		return null;
585
	}
400
	}
586
401
587
	/**
402
	/**
588
	 * Migrates the classpath in the given configuration from the old format
403
	 * Opens the given editor on the buildfile of the provided node and selects
589
	 * to the new format. The old format is not preserved. Instead, the default
404
	 * that node in the editor.
590
	 * classpath will be used. However, ANT_HOME settings are preserved.
591
	 * 
405
	 * 
592
	 * @param configuration a configuration to migrate
406
	 * @param page
593
	 * @throws CoreException if unable to migrate
407
	 *            the page to open the editor in
594
	 * @since 3.0
408
	 * @param editorDescriptor
595
	 */
409
	 *            the editor descriptor, or <code>null</code> for the system
596
	public static void migrateToNewClasspathFormat(ILaunchConfiguration configuration) throws CoreException {
410
	 *            editor
597
		String oldClasspath = configuration.getAttribute(org.eclipse.ant.internal.ui.launchConfigurations.IAntLaunchConfigurationConstants.ATTR_ANT_CUSTOM_CLASSPATH, (String)null);
411
	 * @param node
598
		String oldAntHome = configuration.getAttribute(org.eclipse.ant.internal.ui.launchConfigurations.IAntLaunchConfigurationConstants.ATTR_ANT_HOME, (String)null);
412
	 *            the node from the buildfile to open and then select in the
599
		String provider = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, (String)null);
413
	 *            editor
600
		if (oldClasspath != null || oldAntHome != null || provider == null) {
414
	 */
601
			ILaunchConfigurationWorkingCopy workingCopy = null;
415
	public static void openInEditor(IWorkbenchPage page,
602
			if (configuration.isWorkingCopy()) {
416
			IEditorDescriptor editorDescriptor, AntElementNode node) {
603
				workingCopy = (ILaunchConfigurationWorkingCopy) configuration;
417
		IEditorPart editorPart = null;
418
		IFile fileResource = node.getIFile();
419
		try {
420
			if (editorDescriptor == null) {
421
				editorPart = page.openEditor(new FileEditorInput(fileResource),
422
						IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
604
			} else {
423
			} else {
605
				workingCopy = configuration.getWorkingCopy();
424
				editorPart = page.openEditor(new FileEditorInput(fileResource),
425
						editorDescriptor.getId());
606
			}
426
			}
607
			workingCopy.setAttribute(org.eclipse.ant.internal.ui.launchConfigurations.IAntLaunchConfigurationConstants.ATTR_ANT_CUSTOM_CLASSPATH, (String)null);
427
		} catch (PartInitException e) {
608
			workingCopy.setAttribute(org.eclipse.ant.internal.ui.launchConfigurations.IAntLaunchConfigurationConstants.ATTR_ANT_HOME, (String)null);
428
			AntUIPlugin.log(MessageFormat.format(AntUIModelMessages.AntUtil_0,
609
			workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, "org.eclipse.ant.ui.AntClasspathProvider"); //$NON-NLS-1$
429
					new String[] { fileResource.getLocation().toOSString() }),
610
			workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
430
					e);
611
			if (oldAntHome != null) {
431
		}
612
				IRuntimeClasspathEntry[] entries = JavaRuntime.computeUnresolvedRuntimeClasspath(workingCopy);
432
613
				List mementos = new ArrayList(entries.length);
433
		if (editorPart instanceof AntEditor) {
614
				for (int i = 0; i < entries.length; i++) {
434
			AntEditor editor = (AntEditor) editorPart;
615
					IRuntimeClasspathEntry entry = entries[i];
435
			if (node.getImportNode() != null) {
616
					if (entry.getType() == IRuntimeClasspathEntry.OTHER) {
436
				AntModel model = editor.getAntModel();
617
						IRuntimeClasspathEntry2 entry2 = (IRuntimeClasspathEntry2) entry;
437
				AntProjectNode project = model.getProjectNode();
618
						if (entry2.getTypeId().equals(AntHomeClasspathEntry.TYPE_ID)) {
438
				if (project == null) {
619
							AntHomeClasspathEntry homeEntry = new AntHomeClasspathEntry(oldAntHome);
439
					return;
620
							mementos.add(homeEntry.getMemento());
621
							continue;
622
						}
623
					}
624
					mementos.add(entry.getMemento());
625
				}
440
				}
626
				workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
441
				int[] info = node.getExternalInfo();
627
				workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, mementos);
442
				int offset = getOffset(info[0], info[1], editor);
443
				node = project.getNode(offset);
628
			}
444
			}
629
			workingCopy.doSave();
445
			editor.setSelection(node, true);
630
		}
446
		}
631
	}
447
	}
632
448
633
    private static int getOffset(int line, int column, ITextEditor editor) {
449
	/**
634
    	IDocumentProvider provider= editor.getDocumentProvider();
450
	 * Opens an editor on the buildfile of the provided node and selects that
635
    	IEditorInput input= editor.getEditorInput();
451
	 * node in the editor.
636
    	try {
452
	 * 
637
    		provider.connect(input);
453
	 * @param page
638
    	} catch (CoreException e) {
454
	 *            the page to open the editor in
639
    		return -1;
455
	 * @param node
640
    	}
456
	 *            the node from the buildfile to open and then select in the
641
    	try {
457
	 *            editor
642
    		IDocument document= provider.getDocument(input);
458
	 */
643
    		if (document != null) {
459
	public static void openInEditor(IWorkbenchPage page, AntElementNode node) {
644
    			if (column > -1) {
460
		IFile file = node.getIFile();
645
    				 //column marks the length..adjust to 0 index and to be within the element's source range
461
		IEditorDescriptor editorDesc;
646
    				return document.getLineOffset(line - 1) + column - 1 - 2;
647
    			} 
648
    			return document.getLineOffset(line - 1);
649
    		}
650
    	} catch (BadLocationException e) {
651
    	} finally {
652
    		provider.disconnect(input);
653
    	}
654
    	return -1;
655
    }
656
657
    /**
658
     * Opens the given editor on the buildfile of the provided node and selects that node in the editor.
659
     *
660
     * @param page the page to open the editor in
661
     * @param editorDescriptor the editor descriptor, or <code>null</code> for the system editor
662
     * @param node the node from the buildfile to open and then select in the editor
663
     */
664
    public static void openInEditor(IWorkbenchPage page, IEditorDescriptor editorDescriptor, AntElementNode node) {
665
    	IEditorPart editorPart= null;
666
    	IFile fileResource = node.getIFile();
667
    	try {
668
    		if (editorDescriptor == null) {
669
    			editorPart= page.openEditor(new FileEditorInput(fileResource), IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
670
    		} else {
671
    			editorPart= page.openEditor(new FileEditorInput(fileResource), editorDescriptor.getId());
672
    		}
673
    	} catch (PartInitException e) {
674
    		AntUIPlugin.log(MessageFormat.format(AntUIModelMessages.AntUtil_0, new String[]{fileResource.getLocation().toOSString()}), e);
675
    	}
676
    	
677
    	if (editorPart instanceof AntEditor) {
678
    	    AntEditor editor= (AntEditor)editorPart;
679
    		if (node.getImportNode() != null) {	
680
    			AntModel model= editor.getAntModel();
681
    			AntProjectNode project= model.getProjectNode();
682
    			if (project == null) {
683
    				return;
684
    			}
685
    			int[] info= node.getExternalInfo();
686
    			int offset= getOffset(info[0], info[1], editor);
687
    			node= project.getNode(offset);
688
    		}
689
    		editor.setSelection(node, true);
690
    	}
691
    }
692
693
    /**
694
     * Opens an editor on the buildfile of the provided node and selects that node in the editor.
695
     * 
696
     * @param page the page to open the editor in
697
     * @param node the node from the buildfile to open and then select in the editor
698
     */
699
    public static void openInEditor(IWorkbenchPage page, AntElementNode node) {
700
    	IFile file= node.getIFile();
701
    	IEditorDescriptor editorDesc;
702
        try {
703
            editorDesc = IDE.getEditorDescriptor(file);
704
        } catch (PartInitException e) {
705
           return;
706
        }
707
        openInEditor(page, editorDesc, node);
708
    }
709
    
710
    /**
711
     * Opens an external browser on the provided <code>urlString</code>
712
     * @param urlString The url to open
713
     * @param shell the shell
714
     * @param errorDialogTitle the title of any error dialog
715
     */
716
    public static void openBrowser(final String urlString, final Shell shell, final String errorDialogTitle) {
717
    	shell.getDisplay().syncExec(new Runnable() {
718
    		public void run() {
719
    			IWorkbenchBrowserSupport support= PlatformUI.getWorkbench().getBrowserSupport();
720
    			try {
721
    				IWebBrowser browser= support.createBrowser(fgBrowserId);
722
    				fgBrowserId= browser.getId();
723
    				browser.openURL(new URL(urlString));
724
    				return;
725
    			} catch (PartInitException e) {
726
    				AntUIPlugin.log(e.getStatus());
727
    			} catch (MalformedURLException e) {
728
    				AntUIPlugin.log(e);
729
				}
730
    			
731
    			String platform= SWT.getPlatform();
732
    			boolean succeeded= true;
733
    			if ("motif".equals(platform) || "gtk".equals(platform)) { //$NON-NLS-1$ //$NON-NLS-2$
734
    				Program program= Program.findProgram("html"); //$NON-NLS-1$
735
    				if (program == null) {
736
    					program= Program.findProgram("htm"); //$NON-NLS-1$
737
    				}
738
    				if (program != null) {
739
    					succeeded= program.execute(urlString.toString());
740
    				}
741
    			} else {
742
    				succeeded= Program.launch(urlString.toString());
743
    			}
744
    			if (!succeeded) {
745
    				MessageDialog.openInformation(shell, errorDialogTitle, AntUIModelMessages.AntUtil_1);
746
    			}
747
    		}
748
    	});
749
	}
750
    
751
    public static boolean isSeparateJREAntBuild(ILaunchConfiguration configuration) {
752
    	boolean separateJRE= true;
753
		try {
462
		try {
754
			//always null for same JRE
463
			editorDesc = IDE.getEditorDescriptor(file);
755
			separateJRE = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String)null) != null;
464
		} catch (PartInitException e) {
756
		} catch (CoreException e) {
465
			return;
757
			AntUIPlugin.log(AntUIModelMessages.AntUtil_2, e);
758
		}
466
		}
759
    	
467
		openInEditor(page, editorDesc, node);
760
		return separateJRE;
468
	}
761
    }
469
762
    
470
	/**
763
    public static void linkBuildFailedMessage(String message, IProcess process) {
471
	 * Opens an external browser on the provided <code>urlString</code>
764
        String fileName = null;
472
	 * 
765
        String lineNumber = ""; //$NON-NLS-1$
473
	 * @param urlString
766
        int fileStart = 0;
474
	 *            The url to open
767
        int index = message.indexOf("xml"); //$NON-NLS-1$
475
	 * @param shell
768
        if (index > 0) {
476
	 *            the shell
769
            int numberStart= index + 4;
477
	 * @param errorDialogTitle
770
            int numberEnd= message.indexOf(':', numberStart);
478
	 *            the title of any error dialog
771
            int fileEnd = index + 3;
479
	 */
772
            if (numberStart > 0 && fileEnd > 0) {
480
	public static void openBrowser(final String urlString, final Shell shell,
773
                fileName = message.substring(fileStart, fileEnd).trim();
481
			final String errorDialogTitle) {
774
                if (numberEnd > 0) {
482
		shell.getDisplay().syncExec(new Runnable() {
775
                    lineNumber = message.substring(numberStart, numberEnd).trim();
483
			public void run() {
776
                }
484
				IWorkbenchBrowserSupport support = PlatformUI.getWorkbench()
777
            }
485
						.getBrowserSupport();
778
        }
486
				try {
779
        
487
					IWebBrowser browser = support.createBrowser(fgBrowserId);
780
        if (fileName != null) {
488
					fgBrowserId = browser.getId();
781
            int num = -1;
489
					browser.openURL(new URL(urlString));
782
            try {
490
					return;
783
                num = Integer.parseInt(lineNumber);
491
				} catch (PartInitException e) {
784
            } catch (NumberFormatException e) {
492
					AntUIPlugin.log(e.getStatus());
785
            }
493
				} catch (MalformedURLException e) {
786
            IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(fileName));
494
					AntUIPlugin.log(e);
787
            IFile file= null;
495
				}
788
            if (files.length > 0) {
496
789
                file= files[0];
497
				String platform = SWT.getPlatform();
790
            }
498
				boolean succeeded = true;
791
            if (file != null && file.exists()) {
499
				if ("motif".equals(platform) || "gtk".equals(platform)) { //$NON-NLS-1$ //$NON-NLS-2$
792
                FileLink link = new FileLink(file, null, -1, -1, num);
500
					Program program = Program.findProgram("html"); //$NON-NLS-1$
793
                TaskLinkManager.addTaskHyperlink(process, link, new Region(0, message.length()), message);
501
					if (program == null) {
794
            }
502
						program = Program.findProgram("htm"); //$NON-NLS-1$
795
        }
503
					}
796
    }
504
					if (program != null) {
505
						succeeded = program.execute(urlString.toString());
506
					}
507
				} else {
508
					succeeded = Program.launch(urlString.toString());
509
				}
510
				if (!succeeded) {
511
					MessageDialog.openInformation(shell, errorDialogTitle,
512
							AntUIModelMessages.AntUtil_1);
513
				}
514
			}
515
		});
516
	}
797
}
517
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/RemoteAntDebugBuildListener.java (-1 / +1 lines)
Lines 18-26 Link Here
18
import java.net.Socket;
18
import java.net.Socket;
19
import java.net.UnknownHostException;
19
import java.net.UnknownHostException;
20
20
21
import org.eclipse.ant.internal.launching.launchConfigurations.RemoteAntBuildListener;
21
import org.eclipse.ant.internal.ui.AntUIPlugin;
22
import org.eclipse.ant.internal.ui.AntUIPlugin;
22
import org.eclipse.ant.internal.ui.debug.IAntDebugController;
23
import org.eclipse.ant.internal.ui.debug.IAntDebugController;
23
import org.eclipse.ant.internal.ui.launchConfigurations.RemoteAntBuildListener;
24
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.debug.core.DebugEvent;
25
import org.eclipse.debug.core.DebugEvent;
26
import org.eclipse.debug.core.DebugPlugin;
26
import org.eclipse.debug.core.DebugPlugin;
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/AntStackFrame.java (-2 / +2 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.debug.model;
11
package org.eclipse.ant.internal.ui.debug.model;
12
12
13
import org.eclipse.ant.internal.ui.AntUtil;
13
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
14
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.runtime.Path;
15
import org.eclipse.core.runtime.Path;
16
import org.eclipse.debug.core.DebugException;
16
import org.eclipse.debug.core.DebugException;
Lines 84-90 Link Here
84
	
84
	
85
	protected void setFilePath(String fullPath) {
85
	protected void setFilePath(String fullPath) {
86
        fFullPath= fullPath;
86
        fFullPath= fullPath;
87
        IFile file= AntUtil.getFileForLocation(fullPath, null);
87
        IFile file= AntLaunchingUtil.getFileForLocation(fullPath, null);
88
        if (file != null) {
88
        if (file != null) {
89
            fFilePath= file.getProjectRelativePath().toString();
89
            fFilePath= file.getProjectRelativePath().toString();
90
        } else {
90
        } else {
(-)Ant Tools Support/org/eclipse/ant/internal/ui/refactoring/LaunchConfigurationBuildfileChange.java (-2 / +2 lines)
Lines 14-20 Link Here
14
import java.util.List;
14
import java.util.List;
15
15
16
import org.eclipse.ant.core.AntCorePlugin;
16
import org.eclipse.ant.core.AntCorePlugin;
17
import org.eclipse.ant.internal.ui.AntUtil;
17
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
18
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
18
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
19
import org.eclipse.core.resources.IContainer;
19
import org.eclipse.core.resources.IContainer;
20
import org.eclipse.core.resources.IFile;
20
import org.eclipse.core.resources.IFile;
Lines 277-283 Link Here
277
		try {
277
		try {
278
			String expandedLocation= manager.performStringSubstitution(location);
278
			String expandedLocation= manager.performStringSubstitution(location);
279
			if (expandedLocation != null) {
279
			if (expandedLocation != null) {
280
				file= AntUtil.getFileForLocation(expandedLocation, null);
280
				file= AntLaunchingUtil.getFileForLocation(expandedLocation, null);
281
			}
281
			}
282
		} catch (CoreException e) {
282
		} catch (CoreException e) {
283
		}
283
		}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPropertiesBlock.java (-2 / +2 lines)
Lines 16-23 Link Here
16
import java.util.Map;
16
import java.util.Map;
17
17
18
import org.eclipse.ant.core.Property;
18
import org.eclipse.ant.core.Property;
19
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
19
import org.eclipse.ant.internal.ui.AntUIPlugin;
20
import org.eclipse.ant.internal.ui.AntUIPlugin;
20
import org.eclipse.ant.internal.ui.AntUtil;
21
import org.eclipse.ant.internal.ui.ColumnSorter;
21
import org.eclipse.ant.internal.ui.ColumnSorter;
22
import org.eclipse.ant.internal.ui.IAntUIConstants;
22
import org.eclipse.ant.internal.ui.IAntUIConstants;
23
import org.eclipse.core.resources.IFile;
23
import org.eclipse.core.resources.IFile;
Lines 174-180 Link Here
174
		for (int j = 0; j < existingFiles.length; j++) {
174
		for (int j = 0; j < existingFiles.length; j++) {
175
			String file = (String)existingFiles[j];
175
			String file = (String)existingFiles[j];
176
			try {
176
			try {
177
                propFiles.add(AntUtil.getFileForLocation(VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(file), null));
177
                propFiles.add(AntLaunchingUtil.getFileForLocation(VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(file), null));
178
            } catch (CoreException e) {
178
            } catch (CoreException e) {
179
                AntUIPlugin.log(e.getStatus());
179
                AntUIPlugin.log(e.getStatus());
180
            }
180
            }
(-)Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreferencePage.java (-125 / +192 lines)
Lines 10-21 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.preferences;
11
package org.eclipse.ant.internal.ui.preferences;
12
12
13
13
import org.eclipse.ant.internal.launching.AntLaunching;
14
import com.ibm.icu.text.MessageFormat;
14
import org.eclipse.ant.internal.launching.IAntLaunchingPreferenceConstants;
15
16
import org.eclipse.ant.internal.ui.AntUIPlugin;
15
import org.eclipse.ant.internal.ui.AntUIPlugin;
17
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
16
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
18
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
17
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
18
import org.eclipse.core.runtime.Platform;
19
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
20
import org.eclipse.core.runtime.preferences.InstanceScope;
19
import org.eclipse.jface.preference.BooleanFieldEditor;
21
import org.eclipse.jface.preference.BooleanFieldEditor;
20
import org.eclipse.jface.preference.FieldEditorPreferencePage;
22
import org.eclipse.jface.preference.FieldEditorPreferencePage;
21
import org.eclipse.jface.preference.IPreferenceStore;
23
import org.eclipse.jface.preference.IPreferenceStore;
Lines 40-200 Link Here
40
import org.eclipse.ui.IWorkbenchPreferencePage;
42
import org.eclipse.ui.IWorkbenchPreferencePage;
41
import org.eclipse.ui.PlatformUI;
43
import org.eclipse.ui.PlatformUI;
42
44
43
public class AntPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
45
import com.ibm.icu.text.MessageFormat;
44
	
46
47
public class AntPreferencePage extends FieldEditorPreferencePage implements
48
		IWorkbenchPreferencePage {
49
45
	private List fConsoleColorList;
50
	private List fConsoleColorList;
46
	private ColorEditor fConsoleColorEditor;
51
	private ColorEditor fConsoleColorEditor;
47
	
52
	private IntegerFieldEditor timeout;
48
	private BooleanFieldEditor fToolsWarningEditor= null;
53
49
	
54
	private BooleanFieldEditor fToolsWarningEditor = null;
50
	// Array containing the message to display, the preference key, and the 
55
51
	// default value (initialized in storeInitialValues()) for each color preference
56
	// Array containing the message to display, the preference key, and the
52
	private final String[][] fAppearanceColorListModel= new String[][] {
57
	// default value (initialized in storeInitialValues()) for each color
53
		{AntPreferencesMessages.AntPreferencePage__Error__2, IAntUIPreferenceConstants.CONSOLE_ERROR_COLOR, null},
58
	// preference
54
		{AntPreferencesMessages.AntPreferencePage__Warning__3, IAntUIPreferenceConstants.CONSOLE_WARNING_COLOR, null},
59
	private final String[][] fAppearanceColorListModel = new String[][] {
55
		{AntPreferencesMessages.AntPreferencePage_I_nformation__4, IAntUIPreferenceConstants.CONSOLE_INFO_COLOR, null},
60
			{ AntPreferencesMessages.AntPreferencePage__Error__2,
56
		{AntPreferencesMessages.AntPreferencePage_Ve_rbose__5, IAntUIPreferenceConstants.CONSOLE_VERBOSE_COLOR, null},
61
					IAntUIPreferenceConstants.CONSOLE_ERROR_COLOR, null },
57
		{AntPreferencesMessages.AntPreferencePage_Deb_ug__6, IAntUIPreferenceConstants.CONSOLE_DEBUG_COLOR, null},
62
			{ AntPreferencesMessages.AntPreferencePage__Warning__3,
58
	};
63
					IAntUIPreferenceConstants.CONSOLE_WARNING_COLOR, null },
64
			{ AntPreferencesMessages.AntPreferencePage_I_nformation__4,
65
					IAntUIPreferenceConstants.CONSOLE_INFO_COLOR, null },
66
			{ AntPreferencesMessages.AntPreferencePage_Ve_rbose__5,
67
					IAntUIPreferenceConstants.CONSOLE_VERBOSE_COLOR, null },
68
			{ AntPreferencesMessages.AntPreferencePage_Deb_ug__6,
69
					IAntUIPreferenceConstants.CONSOLE_DEBUG_COLOR, null }, };
59
70
60
	/**
71
	/**
61
 	 * Create the Ant page.
72
	 * Create the Ant page.
62
     */
73
	 */
63
	public AntPreferencePage() {
74
	public AntPreferencePage() {
64
		super(GRID);
75
		super(GRID);
65
		setDescription(AntPreferencesMessages.AntPreferencePage_General);
76
		setDescription(AntPreferencesMessages.AntPreferencePage_General);
66
		setPreferenceStore(AntUIPlugin.getDefault().getPreferenceStore());
77
		setPreferenceStore(AntUIPlugin.getDefault().getPreferenceStore());
67
	}
78
	}
68
	
79
69
	/* (non-Javadoc)
80
	/*
70
	 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
81
	 * (non-Javadoc)
82
	 * 
83
	 * @see
84
	 * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
85
	 * ()
71
	 */
86
	 */
72
	protected void createFieldEditors() {
87
	protected void createFieldEditors() {
73
		storeAppliedValues();
88
		storeAppliedValues();
74
89
75
		Font font= getFieldEditorParent().getFont();
90
		Font font = getFieldEditorParent().getFont();
76
		Label label= new Label(getFieldEditorParent(), SWT.WRAP);
91
		Label label = new Label(getFieldEditorParent(), SWT.WRAP);
77
		label.setText(AntPreferencesMessages.AntPreferencePage_Enter);
92
		label.setText(AntPreferencesMessages.AntPreferencePage_Enter);
78
		GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
93
		GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
79
		gd.horizontalSpan= 3;
94
		gd.horizontalSpan = 3;
80
		gd.widthHint= convertWidthInCharsToPixels(60);
95
		gd.widthHint = convertWidthInCharsToPixels(60);
81
		label.setLayoutData(gd);
96
		label.setLayoutData(gd);
82
		label.setLayoutData(gd);
97
		label.setLayoutData(gd);
83
		label.setFont(font);
98
		label.setFont(font);
84
		
99
85
		StringFieldEditor editor = new StringFieldEditor(IAntUIPreferenceConstants.ANT_FIND_BUILD_FILE_NAMES, AntPreferencesMessages.AntPreferencePage__Names__3, getFieldEditorParent());
100
		StringFieldEditor editor = new StringFieldEditor(
101
				IAntUIPreferenceConstants.ANT_FIND_BUILD_FILE_NAMES,
102
				AntPreferencesMessages.AntPreferencePage__Names__3,
103
				getFieldEditorParent());
86
		addField(editor);
104
		addField(editor);
87
		
105
88
		IntegerFieldEditor timeout = new IntegerFieldEditor(IAntUIPreferenceConstants.ANT_COMMUNICATION_TIMEOUT, AntPreferencesMessages.AntPreferencePage_13, getFieldEditorParent());
106
		timeout = new IntegerFieldEditor(
89
        int minValue= AntUIPlugin.getDefault().getPreferenceStore().getDefaultInt(IAntUIPreferenceConstants.ANT_COMMUNICATION_TIMEOUT);
107
				IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT,
90
        int maxValue = 1200000;
108
				AntPreferencesMessages.AntPreferencePage_13,
91
        timeout.setValidRange(minValue, maxValue);
109
				getFieldEditorParent());
92
        timeout.setErrorMessage(MessageFormat.format(AntPreferencesMessages.AntPreferencePage_14, new Object[] {new Integer(minValue), new Integer(maxValue)})); 
110
		int minValue = Platform.getPreferencesService().getInt(
93
        addField(timeout);
111
				AntLaunching.getUniqueIdentifier(),
94
        
112
				IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT,
95
        editor = new URLFieldEditor(IAntUIPreferenceConstants.DOCUMENTATION_URL, AntPreferencesMessages.AntPreferencePage_2, getFieldEditorParent());
113
				20000, null);
114
		int maxValue = 1200000;
115
		timeout.setValidRange(minValue, maxValue);
116
		timeout.setErrorMessage(MessageFormat.format(
117
				AntPreferencesMessages.AntPreferencePage_14, new Object[] {
118
						new Integer(minValue), new Integer(maxValue) }));
119
		addField(timeout);
120
121
		editor = new URLFieldEditor(
122
				IAntUIPreferenceConstants.DOCUMENTATION_URL,
123
				AntPreferencesMessages.AntPreferencePage_2,
124
				getFieldEditorParent());
96
		addField(editor);
125
		addField(editor);
97
		
126
98
		createSpace();
127
		createSpace();
99
	
128
100
		if (!AntUIPlugin.isMacOS()) {
129
		if (!AntUIPlugin.isMacOS()) {
101
			//the mac does not have a tools.jar Bug 40778
130
			// the mac does not have a tools.jar Bug 40778
102
		    label= new Label(getFieldEditorParent(), SWT.WRAP);
131
			label = new Label(getFieldEditorParent(), SWT.WRAP);
103
			label.setText(AntPreferencesMessages.AntPreferencePage_0);
132
			label.setText(AntPreferencesMessages.AntPreferencePage_0);
104
			gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
133
			gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
105
			gd.horizontalSpan= 3;
134
			gd.horizontalSpan = 3;
106
			gd.widthHint= convertWidthInCharsToPixels(60);
135
			gd.widthHint = convertWidthInCharsToPixels(60);
107
			label.setLayoutData(gd);
136
			label.setLayoutData(gd);
108
			label.setFont(font);
137
			label.setFont(font);
109
			fToolsWarningEditor= new BooleanFieldEditor(IAntUIPreferenceConstants.ANT_TOOLS_JAR_WARNING, AntPreferencesMessages.AntPreferencePage_1, getFieldEditorParent());
138
			fToolsWarningEditor = new BooleanFieldEditor(
139
					IAntUIPreferenceConstants.ANT_TOOLS_JAR_WARNING,
140
					AntPreferencesMessages.AntPreferencePage_1,
141
					getFieldEditorParent());
110
			addField(fToolsWarningEditor);
142
			addField(fToolsWarningEditor);
111
			createSpace();
143
			createSpace();
112
		}
144
		}
113
		
145
114
		addField(new BooleanFieldEditor(IAntUIPreferenceConstants.ANT_ERROR_DIALOG, AntPreferencesMessages.AntPreferencePage_12, getFieldEditorParent()));
146
		addField(new BooleanFieldEditor(
147
				IAntUIPreferenceConstants.ANT_ERROR_DIALOG,
148
				AntPreferencesMessages.AntPreferencePage_12,
149
				getFieldEditorParent()));
115
		createSpace();
150
		createSpace();
116
		
151
117
		
152
		addField(new BooleanFieldEditor(
118
		addField(new BooleanFieldEditor(IAntUIPreferenceConstants.ANT_CREATE_MARKERS, AntPreferencesMessages.AntPreferencePage_15, getFieldEditorParent()));
153
				IAntUIPreferenceConstants.ANT_CREATE_MARKERS,
119
		label= new Label(getFieldEditorParent(), SWT.WRAP);
154
				AntPreferencesMessages.AntPreferencePage_15,
155
				getFieldEditorParent()));
156
		label = new Label(getFieldEditorParent(), SWT.WRAP);
120
		label.setText(AntPreferencesMessages.AntPreferencePage_16);
157
		label.setText(AntPreferencesMessages.AntPreferencePage_16);
121
		gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
158
		gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
122
		gd.horizontalSpan= 3;
159
		gd.horizontalSpan = 3;
123
		gd.widthHint= convertWidthInCharsToPixels(60);
160
		gd.widthHint = convertWidthInCharsToPixels(60);
124
		label.setLayoutData(gd);
161
		label.setLayoutData(gd);
125
		label.setFont(font);
162
		label.setFont(font);
126
		
163
127
        createSpace();
164
		createSpace();
128
		createColorComposite();
165
		createColorComposite();
129
		getPreferenceStore().addPropertyChangeListener(this);
166
		getPreferenceStore().addPropertyChangeListener(this);
130
	}
167
	}
131
	
168
132
	private void createSpace() {
169
	private void createSpace() {
133
		Label label= new Label(getFieldEditorParent(), SWT.NONE);
170
		Label label = new Label(getFieldEditorParent(), SWT.NONE);
134
		GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
171
		GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
135
		gd.horizontalSpan= 3;
172
		gd.horizontalSpan = 3;
136
		label.setLayoutData(gd);
173
		label.setLayoutData(gd);
137
	}
174
	}
138
175
139
	/**
176
	/**
140
	 * Stores the initial values of the color preferences. The preference values are updated 
177
	 * Stores the initial values of the color preferences. The preference values
141
	 * on the fly as the user edits them (instead of only when they press "Apply"). We need
178
	 * are updated on the fly as the user edits them (instead of only when they
142
	 * to store the old values so that we can reset them when the user chooses "Cancel".
179
	 * press "Apply"). We need to store the old values so that we can reset them
180
	 * when the user chooses "Cancel".
143
	 */
181
	 */
144
	private void storeAppliedValues() {
182
	private void storeAppliedValues() {
145
		IPreferenceStore store= getPreferenceStore();
183
		IPreferenceStore store = getPreferenceStore();
146
		for (int i = 0; i < fAppearanceColorListModel.length; i++) {
184
		for (int i = 0; i < fAppearanceColorListModel.length; i++) {
147
			String preference = fAppearanceColorListModel[i][1];
185
			String preference = fAppearanceColorListModel[i][1];
148
			fAppearanceColorListModel[i][2]= store.getString(preference);
186
			fAppearanceColorListModel[i][2] = store.getString(preference);
187
		}
188
189
		IEclipsePreferences node = new InstanceScope()
190
				.getNode(AntLaunching.getUniqueIdentifier());
191
		String t = node.get(
192
				IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT,
193
				"2000");
194
		if (timeout != null) {
195
			t = Integer.valueOf(timeout.getIntValue()).toString();
149
		}
196
		}
197
		node.put(IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT, t); //$NON-NLS-1$
150
	}
198
	}
151
	
199
152
	private void createColorComposite() {
200
	private void createColorComposite() {
153
		Font font= getFieldEditorParent().getFont();
201
		Font font = getFieldEditorParent().getFont();
154
		Label label= new Label(getFieldEditorParent(), SWT.LEFT);
202
		Label label = new Label(getFieldEditorParent(), SWT.LEFT);
155
		label.setText(AntPreferencesMessages.AntPreferencePage_Ant_Color_Options__6); 
203
		label
204
				.setText(AntPreferencesMessages.AntPreferencePage_Ant_Color_Options__6);
156
		label.setFont(font);
205
		label.setFont(font);
157
		GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
206
		GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
158
		gd.horizontalSpan= 2;
207
		gd.horizontalSpan = 2;
159
		label.setLayoutData(gd);
208
		label.setLayoutData(gd);
160
				
209
161
		Composite editorComposite= new Composite(getFieldEditorParent(), SWT.NONE);
210
		Composite editorComposite = new Composite(getFieldEditorParent(),
162
		GridLayout layout= new GridLayout();
211
				SWT.NONE);
163
		layout.numColumns= 2;
212
		GridLayout layout = new GridLayout();
164
		layout.marginHeight= 0;
213
		layout.numColumns = 2;
165
		layout.marginWidth= 0;
214
		layout.marginHeight = 0;
215
		layout.marginWidth = 0;
166
		editorComposite.setLayout(layout);
216
		editorComposite.setLayout(layout);
167
		editorComposite.setFont(font);
217
		editorComposite.setFont(font);
168
		gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
218
		gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL
169
		gd.horizontalSpan= 2;
219
				| GridData.FILL_VERTICAL);
170
		editorComposite.setLayoutData(gd);		
220
		gd.horizontalSpan = 2;
171
221
		editorComposite.setLayoutData(gd);
172
		fConsoleColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
222
173
		gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
223
		fConsoleColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
174
		gd.heightHint= convertHeightInCharsToPixels(8);
224
				| SWT.H_SCROLL | SWT.BORDER);
225
		gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
226
				| GridData.FILL_HORIZONTAL);
227
		gd.heightHint = convertHeightInCharsToPixels(8);
175
		fConsoleColorList.setLayoutData(gd);
228
		fConsoleColorList.setLayoutData(gd);
176
		fConsoleColorList.setFont(font);
229
		fConsoleColorList.setFont(font);
177
				
230
178
		Composite stylesComposite= new Composite(editorComposite, SWT.NONE);
231
		Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
179
		layout= new GridLayout();
232
		layout = new GridLayout();
180
		layout.marginHeight= 0;
233
		layout.marginHeight = 0;
181
		layout.marginWidth= 0;
234
		layout.marginWidth = 0;
182
		layout.numColumns= 2;
235
		layout.numColumns = 2;
183
		stylesComposite.setLayout(layout);
236
		stylesComposite.setLayout(layout);
184
		stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
237
		stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
185
		stylesComposite.setFont(font);
238
		stylesComposite.setFont(font);
186
239
187
		label= new Label(stylesComposite, SWT.LEFT);
240
		label = new Label(stylesComposite, SWT.LEFT);
188
		label.setText(AntPreferencesMessages.AntPreferencePage_Color__7);
241
		label.setText(AntPreferencesMessages.AntPreferencePage_Color__7);
189
		label.setFont(font);
242
		label.setFont(font);
190
		gd= new GridData();
243
		gd = new GridData();
191
		gd.horizontalAlignment= GridData.BEGINNING;
244
		gd.horizontalAlignment = GridData.BEGINNING;
192
		label.setLayoutData(gd);
245
		label.setLayoutData(gd);
193
246
194
		fConsoleColorEditor= new ColorEditor(stylesComposite);
247
		fConsoleColorEditor = new ColorEditor(stylesComposite);
195
		Button foregroundColorButton= fConsoleColorEditor.getButton();
248
		Button foregroundColorButton = fConsoleColorEditor.getButton();
196
		gd= new GridData(GridData.FILL_HORIZONTAL);
249
		gd = new GridData(GridData.FILL_HORIZONTAL);
197
		gd.horizontalAlignment= GridData.BEGINNING;
250
		gd.horizontalAlignment = GridData.BEGINNING;
198
		foregroundColorButton.setLayoutData(gd);
251
		foregroundColorButton.setLayoutData(gd);
199
		foregroundColorButton.setFont(font);
252
		foregroundColorButton.setFont(font);
200
253
Lines 205-231 Link Here
205
		});
258
		});
206
		foregroundColorButton.addSelectionListener(new SelectionAdapter() {
259
		foregroundColorButton.addSelectionListener(new SelectionAdapter() {
207
			public void widgetSelected(SelectionEvent e) {
260
			public void widgetSelected(SelectionEvent e) {
208
				int i= fConsoleColorList.getSelectionIndex();
261
				int i = fConsoleColorList.getSelectionIndex();
209
				if (i == -1) { //bug 85590
262
				if (i == -1) { // bug 85590
210
					return;
263
					return;
211
				}
264
				}
212
				String key= fAppearanceColorListModel[i][1];
265
				String key = fAppearanceColorListModel[i][1];
213
				PreferenceConverter.setValue(getPreferenceStore(), key, fConsoleColorEditor.getColorValue());
266
				PreferenceConverter.setValue(getPreferenceStore(), key,
267
						fConsoleColorEditor.getColorValue());
214
			}
268
			}
215
		});
269
		});
216
	}
270
	}
217
	
271
218
	/**
272
	/**
219
	 * Restore all color preferences to their values when the page was opened.
273
	 * Restore all color preferences to their values when the page was opened.
220
	 */
274
	 */
221
	public boolean performCancel() {
275
	public boolean performCancel() {
222
		for (int i = 0; i < fAppearanceColorListModel.length; i++) {
276
		for (int i = 0; i < fAppearanceColorListModel.length; i++) {
223
			String preference = fAppearanceColorListModel[i][1];
277
			String preference = fAppearanceColorListModel[i][1];
224
			PreferenceConverter.setValue(getPreferenceStore(), preference, StringConverter.asRGB(fAppearanceColorListModel[i][2]));
278
			PreferenceConverter.setValue(getPreferenceStore(), preference,
279
					StringConverter.asRGB(fAppearanceColorListModel[i][2]));
225
		}
280
		}
226
		return super.performCancel();
281
		return super.performCancel();
227
	}
282
	}
228
	
283
229
	/**
284
	/**
230
	 * When the user applies the preferences, update the set of stored
285
	 * When the user applies the preferences, update the set of stored
231
	 * preferences so that we will fall back to the applied values on Cancel.
286
	 * preferences so that we will fall back to the applied values on Cancel.
Lines 234-255 Link Here
234
		storeAppliedValues();
289
		storeAppliedValues();
235
		return super.performOk();
290
		return super.performOk();
236
	}
291
	}
237
	
292
238
	private void handleAppearanceColorListSelection() {	
293
	private void handleAppearanceColorListSelection() {
239
		int i= fConsoleColorList.getSelectionIndex();
294
		int i = fConsoleColorList.getSelectionIndex();
240
		if (i == -1) { //bug 85590
295
		if (i == -1) { // bug 85590
241
			return;
296
			return;
242
		}
297
		}
243
		String key= fAppearanceColorListModel[i][1];
298
		String key = fAppearanceColorListModel[i][1];
244
		RGB rgb= PreferenceConverter.getColor(getPreferenceStore(), key);
299
		RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), key);
245
		fConsoleColorEditor.setColorValue(rgb);		
300
		fConsoleColorEditor.setColorValue(rgb);
246
	}
301
	}
247
	
302
248
	/**
303
	/**
249
	 * @see FieldEditorPreferencePage#createContents(org.eclipse.swt.widgets.Composite)
304
	 * @see FieldEditorPreferencePage#createContents(org.eclipse.swt.widgets.Composite)
250
	 */
305
	 */
251
	protected Control createContents(Composite parent) {
306
	protected Control createContents(Composite parent) {
252
		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IAntUIHelpContextIds.ANT_PREFERENCE_PAGE);
307
		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
308
				IAntUIHelpContextIds.ANT_PREFERENCE_PAGE);
253
		return super.createContents(parent);
309
		return super.createContents(parent);
254
	}
310
	}
255
311
Lines 258-306 Link Here
258
	 */
314
	 */
259
	public void init(IWorkbench workbench) {
315
	public void init(IWorkbench workbench) {
260
	}
316
	}
261
	
317
262
	/**
318
	/**
263
	 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#initialize()
319
	 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#initialize()
264
	 */
320
	 */
265
	protected void initialize() {
321
	protected void initialize() {
266
		super.initialize();
322
		super.initialize();
267
		for (int i= 0; i < fAppearanceColorListModel.length; i++) {
323
		for (int i = 0; i < fAppearanceColorListModel.length; i++) {
268
			fConsoleColorList.add(fAppearanceColorListModel[i][0]);
324
			fConsoleColorList.add(fAppearanceColorListModel[i][0]);
269
		}
325
		}
270
		fConsoleColorList.getDisplay().asyncExec(new Runnable() {
326
		fConsoleColorList.getDisplay().asyncExec(new Runnable() {
271
			public void run() {
327
			public void run() {
272
				if (fConsoleColorList != null && !fConsoleColorList.isDisposed()) {
328
				if (fConsoleColorList != null
329
						&& !fConsoleColorList.isDisposed()) {
273
					fConsoleColorList.select(0);
330
					fConsoleColorList.select(0);
274
					handleAppearanceColorListSelection();
331
					handleAppearanceColorListSelection();
275
				}
332
				}
276
			}
333
			}
277
		});
334
		});
278
	}
335
	}
336
279
	/**
337
	/**
280
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
338
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
281
	 */
339
	 */
282
	protected void performDefaults() {
340
	protected void performDefaults() {
283
		for (int i = 0; i < fAppearanceColorListModel.length; i++) {
341
		for (int i = 0; i < fAppearanceColorListModel.length; i++) {
284
			String key= fAppearanceColorListModel[i][1];
342
			String key = fAppearanceColorListModel[i][1];
285
			PreferenceConverter.setValue(getPreferenceStore(), key, PreferenceConverter.getDefaultColor(getPreferenceStore(), key));
343
			PreferenceConverter.setValue(getPreferenceStore(), key,
344
					PreferenceConverter.getDefaultColor(getPreferenceStore(),
345
							key));
286
		}
346
		}
287
		handleAppearanceColorListSelection();
347
		handleAppearanceColorListSelection();
288
		
348
289
		super.performDefaults();
349
		super.performDefaults();
290
	}
350
	}
291
	
351
292
	/* (non-Javadoc)
352
	/*
353
	 * (non-Javadoc)
354
	 * 
293
	 * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
355
	 * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
294
	 */
356
	 */
295
	public void dispose() {
357
	public void dispose() {
296
		getPreferenceStore().removePropertyChangeListener(this);
358
		getPreferenceStore().removePropertyChangeListener(this);
297
	}
359
	}
298
360
299
	/* (non-Javadoc)
361
	/*
300
	 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
362
	 * (non-Javadoc)
363
	 * 
364
	 * @see
365
	 * org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse
366
	 * .jface.util.PropertyChangeEvent)
301
	 */
367
	 */
302
	public void propertyChange(PropertyChangeEvent event) {
368
	public void propertyChange(PropertyChangeEvent event) {
303
		if (event.getProperty().equals(IAntUIPreferenceConstants.ANT_TOOLS_JAR_WARNING)) {
369
		if (event.getProperty().equals(
370
				IAntUIPreferenceConstants.ANT_TOOLS_JAR_WARNING)) {
304
			if (fToolsWarningEditor != null) {
371
			if (fToolsWarningEditor != null) {
305
				fToolsWarningEditor.load();
372
				fToolsWarningEditor.load();
306
			}
373
			}
(-)Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditor.java (-33 / +23 lines)
Lines 23-30 Link Here
23
import java.util.Map;
23
import java.util.Map;
24
import java.util.ResourceBundle;
24
import java.util.ResourceBundle;
25
25
26
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
26
import org.eclipse.ant.internal.ui.AntUIPlugin;
27
import org.eclipse.ant.internal.ui.AntUIPlugin;
27
import org.eclipse.ant.internal.ui.AntUtil;
28
import org.eclipse.ant.internal.ui.ExternalHyperlink;
28
import org.eclipse.ant.internal.ui.ExternalHyperlink;
29
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
29
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
30
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
30
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
Lines 45-79 Link Here
45
import org.eclipse.ant.internal.ui.model.AntProjectNode;
45
import org.eclipse.ant.internal.ui.model.AntProjectNode;
46
import org.eclipse.ant.internal.ui.model.IAntModelListener;
46
import org.eclipse.ant.internal.ui.model.IAntModelListener;
47
import org.eclipse.ant.internal.ui.preferences.AntEditorPreferenceConstants;
47
import org.eclipse.ant.internal.ui.preferences.AntEditorPreferenceConstants;
48
48
import org.eclipse.core.resources.IFile;
49
import org.eclipse.swt.custom.StyledText;
50
import org.eclipse.swt.events.ShellAdapter;
51
import org.eclipse.swt.events.ShellEvent;
52
import org.eclipse.swt.graphics.Image;
53
import org.eclipse.swt.widgets.Composite;
54
import org.eclipse.swt.widgets.Shell;
55
56
import org.eclipse.core.runtime.CoreException;
49
import org.eclipse.core.runtime.CoreException;
57
import org.eclipse.core.runtime.IProgressMonitor;
50
import org.eclipse.core.runtime.IProgressMonitor;
58
import org.eclipse.core.runtime.IStatus;
51
import org.eclipse.core.runtime.IStatus;
59
import org.eclipse.core.runtime.NullProgressMonitor;
52
import org.eclipse.core.runtime.NullProgressMonitor;
60
import org.eclipse.core.runtime.Status;
53
import org.eclipse.core.runtime.Status;
61
import org.eclipse.core.runtime.jobs.Job;
54
import org.eclipse.core.runtime.jobs.Job;
62
55
import org.eclipse.debug.ui.actions.IRunToLineTarget;
63
import org.eclipse.core.resources.IFile;
56
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
64
57
import org.eclipse.jdt.ui.JavaUI;
58
import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds;
65
import org.eclipse.jface.action.IAction;
59
import org.eclipse.jface.action.IAction;
66
import org.eclipse.jface.action.IMenuManager;
60
import org.eclipse.jface.action.IMenuManager;
67
import org.eclipse.jface.action.Separator;
61
import org.eclipse.jface.action.Separator;
68
import org.eclipse.jface.preference.IPreferenceStore;
62
import org.eclipse.jface.preference.IPreferenceStore;
69
import org.eclipse.jface.util.PropertyChangeEvent;
70
import org.eclipse.jface.viewers.IPostSelectionProvider;
71
import org.eclipse.jface.viewers.ISelection;
72
import org.eclipse.jface.viewers.ISelectionChangedListener;
73
import org.eclipse.jface.viewers.ISelectionProvider;
74
import org.eclipse.jface.viewers.IStructuredSelection;
75
import org.eclipse.jface.viewers.SelectionChangedEvent;
76
77
import org.eclipse.jface.text.BadLocationException;
63
import org.eclipse.jface.text.BadLocationException;
78
import org.eclipse.jface.text.DocumentEvent;
64
import org.eclipse.jface.text.DocumentEvent;
79
import org.eclipse.jface.text.IAutoEditStrategy;
65
import org.eclipse.jface.text.IAutoEditStrategy;
Lines 99-105 Link Here
99
import org.eclipse.jface.text.source.projection.IProjectionListener;
85
import org.eclipse.jface.text.source.projection.IProjectionListener;
100
import org.eclipse.jface.text.source.projection.ProjectionSupport;
86
import org.eclipse.jface.text.source.projection.ProjectionSupport;
101
import org.eclipse.jface.text.source.projection.ProjectionViewer;
87
import org.eclipse.jface.text.source.projection.ProjectionViewer;
102
88
import org.eclipse.jface.util.PropertyChangeEvent;
89
import org.eclipse.jface.viewers.IPostSelectionProvider;
90
import org.eclipse.jface.viewers.ISelection;
91
import org.eclipse.jface.viewers.ISelectionChangedListener;
92
import org.eclipse.jface.viewers.ISelectionProvider;
93
import org.eclipse.jface.viewers.IStructuredSelection;
94
import org.eclipse.jface.viewers.SelectionChangedEvent;
95
import org.eclipse.swt.custom.StyledText;
96
import org.eclipse.swt.events.ShellAdapter;
97
import org.eclipse.swt.events.ShellEvent;
98
import org.eclipse.swt.graphics.Image;
99
import org.eclipse.swt.widgets.Composite;
100
import org.eclipse.swt.widgets.Shell;
103
import org.eclipse.ui.IEditorInput;
101
import org.eclipse.ui.IEditorInput;
104
import org.eclipse.ui.IPageLayout;
102
import org.eclipse.ui.IPageLayout;
105
import org.eclipse.ui.IPartService;
103
import org.eclipse.ui.IPartService;
Lines 107-130 Link Here
107
import org.eclipse.ui.IWorkbenchPart;
105
import org.eclipse.ui.IWorkbenchPart;
108
import org.eclipse.ui.IWorkbenchWindow;
106
import org.eclipse.ui.IWorkbenchWindow;
109
import org.eclipse.ui.PartInitException;
107
import org.eclipse.ui.PartInitException;
108
import org.eclipse.ui.editors.text.TextEditor;
110
import org.eclipse.ui.ide.IDE;
109
import org.eclipse.ui.ide.IDE;
111
import org.eclipse.ui.part.IShowInTargetList;
110
import org.eclipse.ui.part.IShowInTargetList;
112
import org.eclipse.ui.views.contentoutline.ContentOutline;
113
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
114
115
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
111
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
116
import org.eclipse.ui.texteditor.IDocumentProvider;
112
import org.eclipse.ui.texteditor.IDocumentProvider;
117
import org.eclipse.ui.texteditor.IEditorStatusLine;
113
import org.eclipse.ui.texteditor.IEditorStatusLine;
118
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
114
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
119
import org.eclipse.ui.texteditor.TextOperationAction;
115
import org.eclipse.ui.texteditor.TextOperationAction;
120
116
import org.eclipse.ui.views.contentoutline.ContentOutline;
121
import org.eclipse.ui.editors.text.TextEditor;
117
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
122
123
import org.eclipse.debug.ui.actions.IRunToLineTarget;
124
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
125
126
import org.eclipse.jdt.ui.JavaUI;
127
import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds;
128
118
129
/**
119
/**
130
 * The actual editor implementation for Eclipse's Ant integration.
120
 * The actual editor implementation for Eclipse's Ant integration.
Lines 906-912 Link Here
906
		if (buildFile != null) {
896
		if (buildFile != null) {
907
			buildFileParent= buildFile.getParentFile();
897
			buildFileParent= buildFile.getParentFile();
908
		}
898
		}
909
		IFile file= AntUtil.getFileForLocation(path, buildFileParent);
899
		IFile file= AntLaunchingUtil.getFileForLocation(path, buildFileParent);
910
		if (file != null && file.exists()) {
900
		if (file != null && file.exists()) {
911
			try {
901
			try {
912
				IWorkbenchPage p= getEditorSite().getPage();
902
				IWorkbenchPage p= getEditorSite().getPage();
(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 51-57 Link Here
51
 org.eclipse.team.core;bundle-version="[3.2.0,4.0.0)",
51
 org.eclipse.team.core;bundle-version="[3.2.0,4.0.0)",
52
 org.eclipse.ltk.core.refactoring;bundle-version="[3.2.0,4.0.0)",
52
 org.eclipse.ltk.core.refactoring;bundle-version="[3.2.0,4.0.0)",
53
 org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)",
53
 org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)",
54
 org.eclipse.jdt.junit;bundle-version="[3.5.0,4.0.0)"
54
 org.eclipse.jdt.junit;bundle-version="[3.5.0,4.0.0)",
55
 org.eclipse.ant.launching;bundle-version="1.0.0"
55
Bundle-ActivationPolicy: lazy
56
Bundle-ActivationPolicy: lazy
56
Import-Package: com.ibm.icu.text
57
Import-Package: com.ibm.icu.text
57
Bundle-RequiredExecutionEnvironment: J2SE-1.4
58
Bundle-RequiredExecutionEnvironment: J2SE-1.4
(-)Ant Runner Support/org/eclipse/ant/internal/ui/antsupport/logger/AntProcessBuildLogger.java (-5 / +5 lines)
Lines 25-30 Link Here
25
import org.apache.tools.ant.Target;
25
import org.apache.tools.ant.Target;
26
import org.apache.tools.ant.util.FileUtils;
26
import org.apache.tools.ant.util.FileUtils;
27
import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger;
27
import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger;
28
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
28
import org.eclipse.ant.internal.ui.AntUtil;
29
import org.eclipse.ant.internal.ui.AntUtil;
29
import org.eclipse.ant.internal.ui.ExternalHyperlink;
30
import org.eclipse.ant.internal.ui.ExternalHyperlink;
30
import org.eclipse.ant.internal.ui.IAntUIConstants;
31
import org.eclipse.ant.internal.ui.IAntUIConstants;
Lines 33-39 Link Here
33
import org.eclipse.ant.internal.ui.launchConfigurations.AntProcess;
34
import org.eclipse.ant.internal.ui.launchConfigurations.AntProcess;
34
import org.eclipse.ant.internal.ui.launchConfigurations.AntStreamMonitor;
35
import org.eclipse.ant.internal.ui.launchConfigurations.AntStreamMonitor;
35
import org.eclipse.ant.internal.ui.launchConfigurations.AntStreamsProxy;
36
import org.eclipse.ant.internal.ui.launchConfigurations.AntStreamsProxy;
36
import org.eclipse.ant.internal.ui.launchConfigurations.TaskLinkManager;
37
import org.eclipse.core.resources.IFile;
37
import org.eclipse.core.resources.IFile;
38
import org.eclipse.core.runtime.OperationCanceledException;
38
import org.eclipse.core.runtime.OperationCanceledException;
39
import org.eclipse.debug.core.DebugPlugin;
39
import org.eclipse.debug.core.DebugPlugin;
Lines 142-148 Link Here
142
			IRegion region= new Region(offset, label.length() - 3); // only want the name length "[name] "
142
			IRegion region= new Region(offset, label.length() - 3); // only want the name length "[name] "
143
			IHyperlink link= getLocationLink(location);
143
			IHyperlink link= getLocationLink(location);
144
			if (link != null) {
144
			if (link != null) {
145
				TaskLinkManager.addTaskHyperlink(getAntProcess(fProcessId), link, region, newLine);
145
				//TaskLinkManager.addTaskHyperlink(getAntProcess(fProcessId), link, region, newLine);
146
			}
146
			}
147
		}
147
		}
148
	}
148
	}
Lines 194-200 Link Here
194
                if (file != null) {
194
                if (file != null) {
195
                    return new FileLink(file, null, -1, -1, lineNumber);
195
                    return new FileLink(file, null, -1, -1, lineNumber);
196
                } 
196
                } 
197
                file= AntUtil.getFileForLocation(fileName, fBuildFileParent);
197
                file= AntLaunchingUtil.getFileForLocation(fileName, fBuildFileParent);
198
                if (file != null) {
198
                if (file != null) {
199
                    fFileNameToIFile.put(fileName, file);
199
                    fFileNameToIFile.put(fileName, file);
200
                    return new FileLink(file, null, -1, -1, lineNumber);
200
                    return new FileLink(file, null, -1, -1, lineNumber);
Lines 254-260 Link Here
254
    			while (line != null) {
254
    			while (line != null) {
255
    				logMessage(line, event, Project.MSG_ERR);
255
    				logMessage(line, event, Project.MSG_ERR);
256
    				if (!message.startsWith("Total time:")) { //$NON-NLS-1$
256
    				if (!message.startsWith("Total time:")) { //$NON-NLS-1$
257
    					AntUtil.linkBuildFailedMessage(line, antProcess);
257
    					AntLaunchingUtil.linkBuildFailedMessage(line, antProcess);
258
    				}
258
    				}
259
    				line = r.readLine();
259
    				line = r.readLine();
260
    			}
260
    			}
Lines 337-343 Link Here
337
			IRegion region= new Region(0, targetName.length());
337
			IRegion region= new Region(0, targetName.length());
338
			IHyperlink link= getLocationLink(location);
338
			IHyperlink link= getLocationLink(location);
339
			if (link != null) {
339
			if (link != null) {
340
				TaskLinkManager.addTaskHyperlink(getAntProcess(fProcessId), link, region, message.trim());
340
				//TaskLinkManager.addTaskHyperlink(getAntProcess(fProcessId), link, region, message.trim());
341
			}
341
			}
342
		}
342
		}
343
		logMessage(message, event, Project.MSG_INFO);
343
		logMessage(message, event, Project.MSG_INFO);
(-)plugin.xml (-44 / +2 lines)
Lines 24-71 Link Here
24
      </editor>
24
      </editor>
25
   </extension>
25
   </extension>
26
   <extension
26
   <extension
27
         point="org.eclipse.debug.core.launchConfigurationTypes">
28
      <launchConfigurationType
29
            category="org.eclipse.ui.externaltools"
30
            delegate="org.eclipse.ant.internal.ui.launchConfigurations.AntLaunchDelegate"
31
            delegateDescription="%AntLaunchDelegate.description"
32
            delegateName="%AntLaunchDelegate.name"
33
            id="org.eclipse.ant.AntLaunchConfigurationType"
34
            migrationDelegate="org.eclipse.ant.internal.ui.launchConfigurations.AntMigrationDelegate"
35
            modes="run, debug"
36
            name="%AntBuild"
37
            sourceLocatorId="org.eclipse.ant.ui.debug.sourceLookupDirector"
38
            sourcePathComputerId="org.eclipse.ant.ui.debug.sourcePathComputer">
39
      </launchConfigurationType>
40
      <launchConfigurationType
41
            category="org.eclipse.ui.externaltools.builder"
42
            delegate="org.eclipse.ant.internal.ui.launchConfigurations.AntLaunchDelegate"
43
            delegateDescription="%AntBuilderLaunchDelegate.description"
44
            delegateName="%AntBuilderLaunchDelegate.name"
45
            id="org.eclipse.ant.AntBuilderLaunchConfigurationType"
46
            modes="run"
47
            name="%AntBuilder.name">
48
      </launchConfigurationType>
49
   </extension>
50
   <extension
51
         point="org.eclipse.jdt.launching.classpathProviders">
52
      <classpathProvider
53
            class="org.eclipse.ant.internal.ui.launchConfigurations.AntClasspathProvider"
54
            id="org.eclipse.ant.ui.AntClasspathProvider">
55
      </classpathProvider>
56
   </extension>
57
   <extension
58
         point="org.eclipse.jdt.launching.runtimeClasspathEntries">
59
      <runtimeClasspathEntry
60
            class="org.eclipse.ant.internal.ui.launchConfigurations.AntHomeClasspathEntry"
61
            id="org.eclipse.ant.ui.classpathentry.antHome">
62
      </runtimeClasspathEntry>
63
      <runtimeClasspathEntry
64
            class="org.eclipse.ant.internal.ui.launchConfigurations.ContributedClasspathEntriesEntry"
65
            id="org.eclipse.ant.ui.classpathentry.extraClasspathEntries">
66
      </runtimeClasspathEntry>
67
   </extension>
68
   <extension
69
         point="org.eclipse.ui.views">
27
         point="org.eclipse.ui.views">
70
      <category
28
      <category
71
            name="%CategoryView.antViews"
29
            name="%CategoryView.antViews"
Lines 553-565 Link Here
553
            id="org.eclipse.ant.ui.statusHandler.runAntInit">
511
            id="org.eclipse.ant.ui.statusHandler.runAntInit">
554
      </statusHandler>
512
      </statusHandler>
555
   </extension>
513
   </extension>
556
   <extension
514
   <!--extension
557
         point="org.eclipse.debug.core.processFactories">
515
         point="org.eclipse.debug.core.processFactories">
558
      <processFactory
516
      <processFactory
559
            class="org.eclipse.ant.internal.ui.launchConfigurations.RemoteAntProcessFactory"
517
            class="org.eclipse.ant.internal.ui.launchConfigurations.RemoteAntProcessFactory"
560
            id="org.eclipse.ant.ui.remoteAntProcessFactory">
518
            id="org.eclipse.ant.ui.remoteAntProcessFactory">
561
      </processFactory>
519
      </processFactory>
562
   </extension>
520
   </extension-->
563
   
521
   
564
   <extension
522
   <extension
565
         point="org.eclipse.ui.editors.templates">
523
         point="org.eclipse.ui.editors.templates">
(-)Ant Tools Support/org/eclipse/ant/internal/ui/views/AntViewDropAdapter.java (-2 / +2 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.views;
11
package org.eclipse.ant.internal.ui.views;
12
12
13
import org.eclipse.ant.internal.ui.AntUtil;
13
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
14
import org.eclipse.ant.internal.ui.model.AntProjectNode;
14
import org.eclipse.ant.internal.ui.model.AntProjectNode;
15
import org.eclipse.ant.internal.ui.model.AntProjectNodeProxy;
15
import org.eclipse.ant.internal.ui.model.AntProjectNodeProxy;
16
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.resources.IFile;
Lines 60-66 Link Here
60
	 * @param buildFileName the string to process
60
	 * @param buildFileName the string to process
61
	 */
61
	 */
62
	private void processString(String buildFileName) {
62
	private void processString(String buildFileName) {
63
		IFile buildFile = AntUtil.getFileForLocation(buildFileName, null);
63
		IFile buildFile = AntLaunchingUtil.getFileForLocation(buildFileName, null);
64
		if (buildFile == null || !buildFileName.toLowerCase().endsWith(".xml")) { //$NON-NLS-1$
64
		if (buildFile == null || !buildFileName.toLowerCase().endsWith(".xml")) { //$NON-NLS-1$
65
			return;
65
			return;
66
		}
66
		}
(-)Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramLaunchDelegate.java (-4 / +4 lines)
Lines 38-44 Link Here
38
import org.eclipse.ui.IWorkbenchWindow;
38
import org.eclipse.ui.IWorkbenchWindow;
39
import org.eclipse.ui.PlatformUI;
39
import org.eclipse.ui.PlatformUI;
40
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab;
40
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab;
41
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
41
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil;
42
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
42
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
43
43
44
/**
44
/**
Lines 103-123 Link Here
103
		}
103
		}
104
		
104
		
105
		// resolve location
105
		// resolve location
106
		IPath location = ExternalToolsUtil.getLocation(configuration);
106
		IPath location = ExternalToolsCoreUtil.getLocation(configuration);
107
		
107
		
108
		if (monitor.isCanceled()) {
108
		if (monitor.isCanceled()) {
109
			return;
109
			return;
110
		}		
110
		}		
111
		
111
		
112
		// resolve working directory
112
		// resolve working directory
113
		IPath workingDirectory = ExternalToolsUtil.getWorkingDirectory(configuration);
113
		IPath workingDirectory = ExternalToolsCoreUtil.getWorkingDirectory(configuration);
114
		
114
		
115
		if (monitor.isCanceled()) {
115
		if (monitor.isCanceled()) {
116
			return;
116
			return;
117
		}
117
		}
118
		
118
		
119
		// resolve arguments
119
		// resolve arguments
120
		String[] arguments = ExternalToolsUtil.getArguments(configuration);
120
		String[] arguments = ExternalToolsCoreUtil.getArguments(configuration);
121
		
121
		
122
		if (monitor.isCanceled()) {
122
		if (monitor.isCanceled()) {
123
			return;
123
			return;
(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 19-24 Link Here
19
 org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
19
 org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
20
 org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)",
20
 org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)",
21
 org.eclipse.debug.ui;bundle-version="[3.2.0,4.0.0)",
21
 org.eclipse.debug.ui;bundle-version="[3.2.0,4.0.0)",
22
 org.eclipse.core.runtime;bundle-version="[3.1.0,4.0.0)"
22
 org.eclipse.core.runtime;bundle-version="[3.1.0,4.0.0)",
23
 org.eclipse.core.externaltools;bundle-version="1.0.0"
23
Bundle-ActivationPolicy: lazy
24
Bundle-ActivationPolicy: lazy
24
Bundle-RequiredExecutionEnvironment: J2SE-1.4
25
Bundle-RequiredExecutionEnvironment: J2SE-1.4
(-)plugin.xml (-17 lines)
Lines 112-134 Link Here
112
   </extension>
112
   </extension>
113
<!-- Launch Configuration Extensions -->
113
<!-- Launch Configuration Extensions -->
114
   <extension
114
   <extension
115
         point="org.eclipse.debug.core.launchConfigurationTypes">
116
      <launchConfigurationType
117
            name="%Program.externalTools"
118
            delegate="org.eclipse.ui.externaltools.internal.program.launchConfigurations.ProgramLaunchDelegate"
119
            category="org.eclipse.ui.externaltools"
120
            modes="run"
121
            id="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
122
      </launchConfigurationType>
123
      <launchConfigurationType
124
            name="%Program.externalTools"
125
            delegate="org.eclipse.ui.externaltools.internal.program.launchConfigurations.ProgramLaunchDelegate"
126
            category="org.eclipse.ui.externaltools.builder"
127
            modes="run"
128
            id="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
129
      </launchConfigurationType>
130
   </extension>
131
   <extension
132
         point="org.eclipse.ui.externaltools.configurationDuplicationMaps">
115
         point="org.eclipse.ui.externaltools.configurationDuplicationMaps">
133
      <configurationMap
116
      <configurationMap
134
            sourceType="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"
117
            sourceType="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"
(-)External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolBuilder.java (-3 / +3 lines)
Lines 29-35 Link Here
29
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
29
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
30
import org.eclipse.debug.core.ILaunchManager;
30
import org.eclipse.debug.core.ILaunchManager;
31
import org.eclipse.osgi.util.NLS;
31
import org.eclipse.osgi.util.NLS;
32
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
32
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil;
33
import org.eclipse.ui.externaltools.internal.registry.ExternalToolMigration;
33
import org.eclipse.ui.externaltools.internal.registry.ExternalToolMigration;
34
import org.osgi.framework.Bundle;
34
import org.osgi.framework.Bundle;
35
35
Lines 74-80 Link Here
74
            throw ExternalToolsPlugin.newError(ExternalToolsModelMessages.ExternalToolBuilder_0, null);
74
            throw ExternalToolsPlugin.newError(ExternalToolsModelMessages.ExternalToolBuilder_0, null);
75
        }
75
        }
76
		IProject[] projectsWithinScope= null;
76
		IProject[] projectsWithinScope= null;
77
		IResource[] resources = ExternalToolsUtil.getResourcesForBuildScope(config);
77
		IResource[] resources = ExternalToolsCoreUtil.getResourcesForBuildScope(config);
78
		if (resources != null) {
78
		if (resources != null) {
79
			projectsWithinScope= new IProject[resources.length];
79
			projectsWithinScope= new IProject[resources.length];
80
			for (int i = 0; i < resources.length; i++) {
80
			for (int i = 0; i < resources.length; i++) {
Lines 148-154 Link Here
148
	 */
148
	 */
149
	private boolean configEnabled(ILaunchConfiguration config) {
149
	private boolean configEnabled(ILaunchConfiguration config) {
150
		try {
150
		try {
151
			return ExternalToolsUtil.isBuilderEnabled(config);
151
			return ExternalToolsCoreUtil.isBuilderEnabled(config);
152
		} catch (CoreException e) {
152
		} catch (CoreException e) {
153
			ExternalToolsPlugin.getDefault().log(e);
153
			ExternalToolsPlugin.getDefault().log(e);
154
		}
154
		}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java (-25 / +158 lines)
Lines 10-28 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.externaltools.internal.model;
11
package org.eclipse.ui.externaltools.internal.model;
12
12
13
14
import java.net.MalformedURLException;
13
import java.net.MalformedURLException;
15
import java.net.URL;
14
import java.net.URL;
16
15
17
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.Status;
18
import org.eclipse.core.runtime.Status;
19
import org.eclipse.debug.core.DebugPlugin;
20
import org.eclipse.debug.core.ILaunch;
21
import org.eclipse.debug.core.ILaunchConfiguration;
22
import org.eclipse.debug.core.ILaunchConfigurationType;
23
import org.eclipse.debug.core.ILaunchListener;
24
import org.eclipse.debug.core.ILaunchManager;
25
import org.eclipse.debug.internal.ui.views.console.ProcessConsoleManager;
26
import org.eclipse.jface.dialogs.MessageDialog;
20
import org.eclipse.jface.resource.ImageDescriptor;
27
import org.eclipse.jface.resource.ImageDescriptor;
21
import org.eclipse.jface.resource.ImageRegistry;
28
import org.eclipse.jface.resource.ImageRegistry;
22
import org.eclipse.swt.widgets.Display;
29
import org.eclipse.swt.widgets.Display;
23
import org.eclipse.swt.widgets.Shell;
30
import org.eclipse.swt.widgets.Shell;
31
import org.eclipse.ui.IWindowListener;
24
import org.eclipse.ui.IWorkbenchPage;
32
import org.eclipse.ui.IWorkbenchPage;
25
import org.eclipse.ui.IWorkbenchWindow;
33
import org.eclipse.ui.IWorkbenchWindow;
34
import org.eclipse.ui.PlatformUI;
35
import org.eclipse.ui.externaltools.internal.program.launchConfigurations.ExternalToolsProgramMessages;
26
import org.eclipse.ui.plugin.AbstractUIPlugin;
36
import org.eclipse.ui.plugin.AbstractUIPlugin;
27
import org.osgi.framework.Bundle;
37
import org.osgi.framework.Bundle;
28
import org.osgi.framework.BundleContext;
38
import org.osgi.framework.BundleContext;
Lines 30-44 Link Here
30
/**
40
/**
31
 * External tools plug-in class
41
 * External tools plug-in class
32
 */
42
 */
33
public final class ExternalToolsPlugin extends AbstractUIPlugin {
43
public final class ExternalToolsPlugin extends AbstractUIPlugin implements
44
		ILaunchListener {
34
	/**
45
	/**
35
	 * Status representing no problems encountered during operation.
46
	 * Status representing no problems encountered during operation.
36
	 */
47
	 */
37
	public static final IStatus OK_STATUS = new Status(IStatus.OK, IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
48
	public static final IStatus OK_STATUS = new Status(IStatus.OK,
49
			IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
38
50
39
	private static ExternalToolsPlugin plugin;
51
	private static ExternalToolsPlugin plugin;
40
	
52
41
	private static final String EMPTY_STRING= ""; //$NON-NLS-1$
53
	private static final String EMPTY_STRING = ""; //$NON-NLS-1$
54
55
	private static IWindowListener fWindowListener;
56
57
	private static ILaunchManager launchManager;
58
59
	/**
60
	 * Singleton console document manager
61
	 */
62
	private ProcessConsoleManager fProcessConsoleManager = null;
63
64
	/**
65
	 * A window listener that warns the user about any running programs when the
66
	 * workbench closes. Programs are killed when the VM exits.
67
	 */
68
	private class ProgramLaunchWindowListener implements IWindowListener {
69
		public void windowActivated(IWorkbenchWindow window) {
70
		}
71
72
		public void windowDeactivated(IWorkbenchWindow window) {
73
		}
74
75
		public void windowClosed(IWorkbenchWindow window) {
76
			IWorkbenchWindow windows[] = PlatformUI.getWorkbench()
77
					.getWorkbenchWindows();
78
			if (windows.length > 1) {
79
				// There are more windows still open.
80
				return;
81
			}
82
			ILaunchManager manager = DebugPlugin.getDefault()
83
					.getLaunchManager();
84
			ILaunchConfigurationType programType = manager
85
					.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE);
86
			if (programType == null) {
87
				return;
88
			}
89
			ILaunch launches[] = manager.getLaunches();
90
			ILaunchConfigurationType configType;
91
			ILaunchConfiguration config;
92
			for (int i = 0; i < launches.length; i++) {
93
				try {
94
					config = launches[i].getLaunchConfiguration();
95
					if (config == null) {
96
						continue;
97
					}
98
					configType = config.getType();
99
				} catch (CoreException e) {
100
					continue;
101
				}
102
				if (configType.equals(programType)) {
103
					if (!launches[i].isTerminated()) {
104
						MessageDialog
105
								.openWarning(
106
										window.getShell(),
107
										ExternalToolsProgramMessages.ProgramLaunchDelegate_Workbench_Closing_1,
108
										ExternalToolsProgramMessages.ProgramLaunchDelegate_The_workbench_is_exiting);
109
						break;
110
					}
111
				}
112
			}
113
		}
114
115
		public void windowOpened(IWorkbenchWindow window) {
116
		}
117
	}
42
118
43
	/**
119
	/**
44
	 * Create an instance of the External Tools plug-in.
120
	 * Create an instance of the External Tools plug-in.
Lines 49-56 Link Here
49
	}
125
	}
50
126
51
	/**
127
	/**
52
	 * Returns the default instance of the receiver.
128
	 * Returns the default instance of the receiver. This represents the runtime
53
	 * This represents the runtime plugin.
129
	 * plugin.
54
	 */
130
	 */
55
	public static ExternalToolsPlugin getDefault() {
131
	public static ExternalToolsPlugin getDefault() {
56
		return plugin;
132
		return plugin;
Lines 61-92 Link Here
61
	 */
137
	 */
62
	public static IStatus newErrorStatus(String message, Throwable exception) {
138
	public static IStatus newErrorStatus(String message, Throwable exception) {
63
		if (message == null) {
139
		if (message == null) {
64
			message= EMPTY_STRING; 
140
			message = EMPTY_STRING;
65
		}		
141
		}
66
		return new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, message, exception);
142
		return new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0,
143
				message, exception);
67
	}
144
	}
68
145
69
	/**
146
	/**
70
	 * Returns a new <code>CoreException</code> for this plug-in
147
	 * Returns a new <code>CoreException</code> for this plug-in
71
	 */
148
	 */
72
	public static CoreException newError(String message, Throwable exception) {
149
	public static CoreException newError(String message, Throwable exception) {
73
		return new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, message, exception));
150
		return new CoreException(new Status(IStatus.ERROR,
151
				IExternalToolConstants.PLUGIN_ID, 0, message, exception));
74
	}
152
	}
75
153
76
	/**
154
	/**
77
	 * Writes the message to the plug-in's log
155
	 * Writes the message to the plug-in's log
78
	 * 
156
	 * 
79
	 * @param message the text to write to the log
157
	 * @param message
158
	 *            the text to write to the log
80
	 */
159
	 */
81
	public void log(String message, Throwable exception) {
160
	public void log(String message, Throwable exception) {
82
		IStatus status = newErrorStatus(message, exception);
161
		IStatus status = newErrorStatus(message, exception);
83
		getLog().log(status);
162
		getLog().log(status);
84
	}
163
	}
85
	
164
86
	public void log(Throwable exception) {
165
	public void log(Throwable exception) {
87
		//this message is intentionally not internationalized, as an exception may
166
		// this message is intentionally not internationalized, as an exception
167
		// may
88
		// be due to the resource bundle itself
168
		// be due to the resource bundle itself
89
		getLog().log(newErrorStatus("Internal error logged from External Tools UI: ", exception)); //$NON-NLS-1$
169
		getLog()
170
				.log(
171
						newErrorStatus(
172
								"Internal error logged from External Tools UI: ", exception)); //$NON-NLS-1$
90
	}
173
	}
91
174
92
	/**
175
	/**
Lines 96-102 Link Here
96
	 */
179
	 */
97
	public ImageDescriptor getImageDescriptor(String path) {
180
	public ImageDescriptor getImageDescriptor(String path) {
98
		try {
181
		try {
99
			Bundle bundle= getDefault().getBundle();
182
			Bundle bundle = getDefault().getBundle();
100
			URL installURL = bundle.getEntry("/"); //$NON-NLS-1$
183
			URL installURL = bundle.getEntry("/"); //$NON-NLS-1$
101
			URL url = new URL(installURL, path);
184
			URL url = new URL(installURL, path);
102
			return ImageDescriptor.createFromURL(url);
185
			return ImageDescriptor.createFromURL(url);
Lines 111-128 Link Here
111
	public static IWorkbenchWindow getActiveWorkbenchWindow() {
194
	public static IWorkbenchWindow getActiveWorkbenchWindow() {
112
		return getDefault().getWorkbench().getActiveWorkbenchWindow();
195
		return getDefault().getWorkbench().getActiveWorkbenchWindow();
113
	}
196
	}
114
	
197
115
	/**
198
	/**
116
	 * Returns the active workbench page or <code>null</code> if none.
199
	 * Returns the active workbench page or <code>null</code> if none.
117
	 */
200
	 */
118
	public static IWorkbenchPage getActivePage() {
201
	public static IWorkbenchPage getActivePage() {
119
		IWorkbenchWindow window= getActiveWorkbenchWindow();
202
		IWorkbenchWindow window = getActiveWorkbenchWindow();
120
		if (window != null) {
203
		if (window != null) {
121
			return window.getActivePage();
204
			return window.getActivePage();
122
		}
205
		}
123
		return null;
206
		return null;
124
	}
207
	}
125
	
208
126
	/**
209
	/**
127
	 * Returns the active workbench shell or <code>null</code> if none.
210
	 * Returns the active workbench shell or <code>null</code> if none.
128
	 */
211
	 */
Lines 135-143 Link Here
135
	}
218
	}
136
219
137
	/**
220
	/**
138
	 * Returns the standard display to be used. The method first checks, if
221
	 * Returns the standard display to be used. The method first checks, if the
139
	 * the thread calling this method has an associated display. If so, this
222
	 * thread calling this method has an associated display. If so, this display
140
	 * display is returned. Otherwise the method returns the default display.
223
	 * is returned. Otherwise the method returns the default display.
141
	 */
224
	 */
142
	public static Display getStandardDisplay() {
225
	public static Display getStandardDisplay() {
143
		Display display = Display.getCurrent();
226
		Display display = Display.getCurrent();
Lines 147-161 Link Here
147
		return display;
230
		return display;
148
	}
231
	}
149
232
150
	/* (non-Javadoc)
233
	/*
234
	 * (non-Javadoc)
235
	 * 
151
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#createImageRegistry()
236
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#createImageRegistry()
152
	 */
237
	 */
153
	protected ImageRegistry createImageRegistry() {
238
	protected ImageRegistry createImageRegistry() {
154
		return ExternalToolsImages.initializeImageRegistry();
239
		return ExternalToolsImages.initializeImageRegistry();
155
	}
240
	}
156
241
157
	/* (non-Javadoc)
242
	/*
158
	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
243
	 * (non-Javadoc)
244
	 * 
245
	 * @see
246
	 * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
159
	 */
247
	 */
160
	public void stop(BundleContext context) throws Exception {
248
	public void stop(BundleContext context) throws Exception {
161
		try {
249
		try {
Lines 164-167 Link Here
164
			super.stop(context);
252
			super.stop(context);
165
		}
253
		}
166
	}
254
	}
255
256
	public void start(BundleContext context) throws Exception {
257
		super.start(context);
258
		// Listen to launches to lazily create "launch processors"
259
		launchManager = DebugPlugin.getDefault().getLaunchManager();
260
		ILaunch[] launches = launchManager.getLaunches();
261
		if (launches.length > 0) {
262
			if (fWindowListener == null) {
263
				fWindowListener = new ProgramLaunchWindowListener();
264
				PlatformUI.getWorkbench().addWindowListener(fWindowListener);
265
			}
266
		} else {
267
			// if no launches, wait for first launch to initialize processors
268
			launchManager.addLaunchListener(this);
269
		}
270
	}
271
272
	public void launchAdded(ILaunch launch) {
273
		ILaunchConfiguration launchConfiguration = launch
274
				.getLaunchConfiguration();
275
		try {
276
			ILaunchConfigurationType launchConfigurationType = launchConfiguration
277
					.getType();
278
			if (launchConfigurationType
279
					.getIdentifier()
280
					.equals(
281
							IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE)) {
282
				if (fWindowListener == null) {
283
					fWindowListener = new ProgramLaunchWindowListener();
284
					PlatformUI.getWorkbench()
285
							.addWindowListener(fWindowListener);
286
				}
287
			}
288
		} catch (CoreException e) {
289
			log(e);
290
		}
291
	}
292
293
	public void launchChanged(ILaunch launch) {
294
295
	}
296
297
	public void launchRemoved(ILaunch launch) {
298
		launchManager.removeLaunch(launch);
299
	}
167
}
300
}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsUtil.java (-203 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 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
 *     Keith Seitz (keiths@redhat.com) - Bug 27243 (environment variables contribution)
11
 *     dakshinamurthy.karra@gmail.com - bug 165371
12
 *******************************************************************************/
13
package org.eclipse.ui.externaltools.internal.launchConfigurations;
14
15
16
import java.io.File;
17
18
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.Path;
23
import org.eclipse.core.runtime.Status;
24
import org.eclipse.core.variables.IStringVariableManager;
25
import org.eclipse.core.variables.VariablesPlugin;
26
import org.eclipse.debug.core.DebugPlugin;
27
import org.eclipse.debug.core.ILaunchConfiguration;
28
import org.eclipse.debug.ui.RefreshTab;
29
import org.eclipse.osgi.util.NLS;
30
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
31
32
/**
33
 * Utilities for external tool launch configurations.
34
 * <p>
35
 * This class it not intended to be instantiated.
36
 * </p>
37
 */
38
public class ExternalToolsUtil {
39
40
	/**
41
	 * Throws a core exception with an error status object built from
42
	 * the given message, lower level exception, and error code.
43
	 * 
44
	 * @param message the status message
45
	 * @param exception lower level exception associated with the
46
	 *  error, or <code>null</code> if none
47
	 * @param code error code
48
	 */
49
	protected static void abort(String message, Throwable exception, int code) throws CoreException {
50
		throw new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, code, message, exception));
51
	}
52
	
53
	/**
54
	 * Expands and returns the location attribute of the given launch
55
	 * configuration. The location is
56
	 * verified to point to an existing file, in the local file system.
57
	 * 
58
	 * @param configuration launch configuration
59
	 * @return an absolute path to a file in the local file system  
60
	 * @throws CoreException if unable to retrieve the associated launch
61
	 * configuration attribute, if unable to resolve any variables, or if the
62
	 * resolved location does not point to an existing file in the local file
63
	 * system
64
	 */
65
	public static IPath getLocation(ILaunchConfiguration configuration) throws CoreException {
66
		String location = configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String) null);
67
		if (location == null) {
68
			abort(NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_Location_not_specified_by__0__1, new String[] { configuration.getName()}), null, 0);
69
		} else {
70
			String expandedLocation = getStringVariableManager().performStringSubstitution(location);
71
			if (expandedLocation == null || expandedLocation.length() == 0) {
72
				String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()});
73
				abort(msg, null, 0);
74
			} else {
75
				File file = new File(expandedLocation);
76
				if (file.isFile()) {
77
					return new Path(expandedLocation);
78
				} 
79
				
80
				String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()});
81
				abort(msg, null, 0);
82
			}
83
		}
84
		// execution will not reach here
85
		return null;
86
	}
87
	
88
	/**
89
	 * Returns a boolean specifying whether or not output should be captured for
90
	 * the given configuration
91
	 * 
92
	 * @param configuration the configuration from which the value will be
93
	 * extracted
94
	 * @return boolean specifying whether or not output should be captured
95
	 * @throws CoreException if unable to access the associated attribute
96
	 */
97
	public static boolean getCaptureOutput(ILaunchConfiguration configuration) throws CoreException {
98
	    return configuration.getAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true);
99
	}
100
101
	/**
102
	 * Expands and returns the working directory attribute of the given launch
103
	 * configuration. Returns <code>null</code> if a working directory is not
104
	 * specified. If specified, the working is verified to point to an existing
105
	 * directory in the local file system.
106
	 * 
107
	 * @param configuration launch configuration
108
	 * @return an absolute path to a directory in the local file system, or
109
	 * <code>null</code> if unspecified
110
	 * @throws CoreException if unable to retrieve the associated launch
111
	 * configuration attribute, if unable to resolve any variables, or if the
112
	 * resolved location does not point to an existing directory in the local
113
	 * file system
114
	 */
115
	public static IPath getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
116
		String location = configuration.getAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) null);
117
		if (location != null) {
118
			String expandedLocation = getStringVariableManager().performStringSubstitution(location);
119
			if (expandedLocation.length() > 0) {
120
				File path = new File(expandedLocation);
121
				if (path.isDirectory()) {
122
					return new Path(expandedLocation);
123
				} 
124
				String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidDirectory__0_, new Object[] { expandedLocation, configuration.getName()});
125
				abort(msg, null, 0);
126
			}
127
		}
128
		return null;
129
	}
130
131
	/**
132
	 * Expands and returns the arguments attribute of the given launch
133
	 * configuration. Returns <code>null</code> if arguments are not specified.
134
	 * 
135
	 * @param configuration launch configuration
136
	 * @return an array of resolved arguments, or <code>null</code> if
137
	 * unspecified
138
	 * @throws CoreException if unable to retrieve the associated launch
139
	 * configuration attribute, or if unable to resolve any variables
140
	 */
141
	public static String[] getArguments(ILaunchConfiguration configuration) throws CoreException {
142
		String args = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String) null);
143
		if (args != null) {
144
			String expanded = getStringVariableManager().performStringSubstitution(args);
145
			return parseStringIntoList(expanded);
146
		}
147
		return null;
148
	}
149
150
	private static IStringVariableManager getStringVariableManager() {
151
		return VariablesPlugin.getDefault().getStringVariableManager();
152
	}
153
	
154
	/**
155
	 * Returns whether the given launch configuration is enabled. This property
156
	 * is intended only to apply to external tool builder configurations and
157
	 * determines whether the project builder will launch the configuration
158
	 * when it builds.
159
	 *  
160
	 * @param configuration the configuration for which the enabled state should
161
	 * 		be determined.
162
	 * @return whether the given configuration is enabled to be run when a build occurs.
163
	 * @throws CoreException if unable to access the associated attribute
164
	 */
165
	public static boolean isBuilderEnabled(ILaunchConfiguration configuration) throws CoreException {
166
		return configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_ENABLED, true);
167
	}
168
	
169
	/**
170
	 * Returns the collection of resources for the build scope as specified by the given launch configuration.
171
	 * 
172
	 * @param configuration launch configuration
173
	 * @throws CoreException if an exception occurs while retrieving the resources
174
	 */
175
	public static IResource[] getResourcesForBuildScope(ILaunchConfiguration configuration) throws CoreException {
176
		String scope = configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_SCOPE, (String) null);
177
		if (scope == null) {
178
			return null;
179
		}
180
	
181
		return RefreshTab.getRefreshResources(scope);
182
	}
183
	
184
	/**
185
	 * Parses the argument text into an array of individual
186
	 * strings using the space character as the delimiter.
187
	 * An individual argument containing spaces must have a
188
	 * double quote (") at the start and end. Two double 
189
	 * quotes together is taken to mean an embedded double
190
	 * quote in the argument text.
191
	 * 
192
	 * @param arguments the arguments as one string
193
	 * @return the array of arguments
194
	 */
195
	public static String[] parseStringIntoList(String arguments) {
196
		if (arguments == null || arguments.length() == 0) {
197
			return new String[0];
198
		}
199
		String[] res= DebugPlugin.parseArguments(arguments);
200
		return res;		
201
	}	
202
	
203
}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuildTab.java (-112 / +140 lines)
Lines 11-31 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.ui.externaltools.internal.launchConfigurations;
12
package org.eclipse.ui.externaltools.internal.launchConfigurations;
13
13
14
15
import java.util.ArrayList;
14
import java.util.ArrayList;
16
import java.util.Iterator;
15
import java.util.Iterator;
17
import java.util.List;
16
import java.util.List;
18
17
18
import org.eclipse.core.internal.externaltools.launchConfigurations.ExternalToolsCoreUtil;
19
import org.eclipse.core.resources.IProject;
19
import org.eclipse.core.resources.IProject;
20
import org.eclipse.core.resources.IResource;
21
import org.eclipse.core.resources.IWorkspace;
20
import org.eclipse.core.resources.IWorkspace;
22
import org.eclipse.core.resources.IWorkspaceRoot;
23
import org.eclipse.core.resources.ResourcesPlugin;
21
import org.eclipse.core.resources.ResourcesPlugin;
24
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.debug.core.ILaunchConfiguration;
23
import org.eclipse.debug.core.ILaunchConfiguration;
26
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
24
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
27
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
25
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
28
import org.eclipse.debug.ui.DebugUITools;
29
import org.eclipse.jface.viewers.IStructuredContentProvider;
26
import org.eclipse.jface.viewers.IStructuredContentProvider;
30
import org.eclipse.jface.viewers.Viewer;
27
import org.eclipse.jface.viewers.Viewer;
31
import org.eclipse.jface.window.Window;
28
import org.eclipse.jface.window.Window;
Lines 45-123 Link Here
45
import org.eclipse.ui.model.WorkbenchLabelProvider;
42
import org.eclipse.ui.model.WorkbenchLabelProvider;
46
43
47
/**
44
/**
48
 * A launch configuration tab which allows the user to specify
45
 * A launch configuration tab which allows the user to specify which resources
49
 * which resources should be built before a build (a build scope)
46
 * should be built before a build (a build scope)
50
 * <p>
47
 * <p>
51
 * This class may be instantiated; this class is not intended
48
 * This class may be instantiated; this class is not intended to be subclassed.
52
 * to be subclassed.
53
 * </p>
49
 * </p>
54
 * A generalized version of AntBuildTab which was removed after the work of bug 165371
50
 * A generalized version of AntBuildTab which was removed after the work of bug
51
 * 165371
52
 * 
55
 * @since 3.4
53
 * @since 3.4
56
 */
54
 */
57
public class ExternalToolsBuildTab extends AbstractLaunchConfigurationTab {
55
public class ExternalToolsBuildTab extends AbstractLaunchConfigurationTab {
58
	// Check Buttons
56
	// Check Buttons
59
	private Button fBuildButton;
57
	private Button fBuildButton;
60
	
58
61
	// Group box
59
	// Group box
62
	private Group fGroup;
60
	private Group fGroup;
63
	
61
64
	// Radio Buttons
62
	// Radio Buttons
65
	private Button fProjectButton;
63
	private Button fProjectButton;
66
	private Button fSpecificProjectsButton;
64
	private Button fSpecificProjectsButton;
67
	private Button fWorkspaceButton;
65
	private Button fWorkspaceButton;
68
	
66
69
	// Push Button
67
	// Push Button
70
	private Button fSelectButton;
68
	private Button fSelectButton;
71
	
69
72
	// whether to include referenced projects
70
	// whether to include referenced projects
73
	private Button fReferencedProjects;
71
	private Button fReferencedProjects;
74
	
72
75
	// projects to build (empty if none)
73
	// projects to build (empty if none)
76
	private List fProjects = new ArrayList();
74
	private List fProjects = new ArrayList();
77
	
75
78
	class ProjectsContentProvider implements IStructuredContentProvider {
76
	class ProjectsContentProvider implements IStructuredContentProvider {
79
77
80
		/* (non-Javadoc)
78
		/*
81
		 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
79
		 * (non-Javadoc)
80
		 * 
81
		 * @see
82
		 * org.eclipse.jface.viewers.IStructuredContentProvider#getElements(
83
		 * java.lang.Object)
82
		 */
84
		 */
83
		public Object[] getElements(Object inputElement) {
85
		public Object[] getElements(Object inputElement) {
84
			return ((IWorkspace)inputElement).getRoot().getProjects();
86
			return ((IWorkspace) inputElement).getRoot().getProjects();
85
		}
87
		}
86
88
87
		/* (non-Javadoc)
89
		/*
90
		 * (non-Javadoc)
91
		 * 
88
		 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
92
		 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
89
		 */
93
		 */
90
		public void dispose() {
94
		public void dispose() {
91
		}
95
		}
92
96
93
		/* (non-Javadoc)
97
		/*
94
		 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
98
		 * (non-Javadoc)
99
		 * 
100
		 * @see
101
		 * org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse
102
		 * .jface.viewers.Viewer, java.lang.Object, java.lang.Object)
95
		 */
103
		 */
96
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
104
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
97
		}
105
		}
98
		
106
99
	}
107
	}
108
100
	/**
109
	/**
101
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
110
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
102
	 */
111
	 */
103
	public void createControl(Composite parent) {
112
	public void createControl(Composite parent) {
104
		Composite mainComposite = new Composite(parent, SWT.NONE);
113
		Composite mainComposite = new Composite(parent, SWT.NONE);
105
		setControl(mainComposite);
114
		setControl(mainComposite);
106
		
115
107
		GridLayout layout = new GridLayout();
116
		GridLayout layout = new GridLayout();
108
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
117
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
109
		mainComposite.setLayout(layout);
118
		mainComposite.setLayout(layout);
110
		mainComposite.setLayoutData(gd);
119
		mainComposite.setLayoutData(gd);
111
		mainComposite.setFont(parent.getFont());
120
		mainComposite.setFont(parent.getFont());
112
		
121
113
		fBuildButton = createCheckButton(mainComposite, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_1);
122
		fBuildButton = createCheckButton(
123
				mainComposite,
124
				ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_1);
114
		fBuildButton.addSelectionListener(new SelectionAdapter() {
125
		fBuildButton.addSelectionListener(new SelectionAdapter() {
115
			public void widgetSelected(SelectionEvent e) {
126
			public void widgetSelected(SelectionEvent e) {
116
				updateEnabledState();
127
				updateEnabledState();
117
				updateLaunchConfigurationDialog();
128
				updateLaunchConfigurationDialog();
118
			}
129
			}
119
		});
130
		});
120
		
131
121
		fGroup = new Group(mainComposite, SWT.NONE);
132
		fGroup = new Group(mainComposite, SWT.NONE);
122
		fGroup.setFont(mainComposite.getFont());
133
		fGroup.setFont(mainComposite.getFont());
123
		layout = new GridLayout();
134
		layout = new GridLayout();
Lines 130-178 Link Here
130
141
131
		SelectionAdapter adapter = new SelectionAdapter() {
142
		SelectionAdapter adapter = new SelectionAdapter() {
132
			public void widgetSelected(SelectionEvent e) {
143
			public void widgetSelected(SelectionEvent e) {
133
				if (((Button)e.getSource()).getSelection()) {
144
				if (((Button) e.getSource()).getSelection()) {
134
					updateEnabledState();
145
					updateEnabledState();
135
					updateLaunchConfigurationDialog();
146
					updateLaunchConfigurationDialog();
136
				}
147
				}
137
			}
148
			}
138
		};
149
		};
139
		
150
140
		fWorkspaceButton = createRadioButton(fGroup, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_2);
151
		fWorkspaceButton = createRadioButton(
152
				fGroup,
153
				ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_2);
141
		gd = new GridData(GridData.FILL_HORIZONTAL);
154
		gd = new GridData(GridData.FILL_HORIZONTAL);
142
		gd.horizontalSpan = 2;
155
		gd.horizontalSpan = 2;
143
		fWorkspaceButton.setLayoutData(gd);
156
		fWorkspaceButton.setLayoutData(gd);
144
		fWorkspaceButton.addSelectionListener(adapter);
157
		fWorkspaceButton.addSelectionListener(adapter);
145
		
158
146
		fProjectButton = createRadioButton(fGroup, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_3);
159
		fProjectButton = createRadioButton(
160
				fGroup,
161
				ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_3);
147
		gd = new GridData(GridData.FILL_HORIZONTAL);
162
		gd = new GridData(GridData.FILL_HORIZONTAL);
148
		gd.horizontalSpan = 2;
163
		gd.horizontalSpan = 2;
149
		fProjectButton.setLayoutData(gd);		
164
		fProjectButton.setLayoutData(gd);
150
		fProjectButton.addSelectionListener(adapter);
165
		fProjectButton.addSelectionListener(adapter);
151
				
166
152
		fSpecificProjectsButton = createRadioButton(fGroup, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_4);
167
		fSpecificProjectsButton = createRadioButton(
168
				fGroup,
169
				ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_4);
153
		gd = new GridData(GridData.FILL_HORIZONTAL);
170
		gd = new GridData(GridData.FILL_HORIZONTAL);
154
		gd.horizontalSpan = 1;
171
		gd.horizontalSpan = 1;
155
		fSpecificProjectsButton.setLayoutData(gd);
172
		fSpecificProjectsButton.setLayoutData(gd);
156
		fSpecificProjectsButton.addSelectionListener(adapter);		
173
		fSpecificProjectsButton.addSelectionListener(adapter);
157
		
174
158
		fSelectButton = createPushButton(fGroup, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_5, null);
175
		fSelectButton = createPushButton(
159
		gd = (GridData)fSelectButton.getLayoutData();
176
				fGroup,
177
				ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_5,
178
				null);
179
		gd = (GridData) fSelectButton.getLayoutData();
160
		gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END;
180
		gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END;
161
		fSelectButton.addSelectionListener(new SelectionAdapter() {
181
		fSelectButton.addSelectionListener(new SelectionAdapter() {
162
			public void widgetSelected(SelectionEvent e) {
182
			public void widgetSelected(SelectionEvent e) {
163
				selectResources();
183
				selectResources();
164
			}
184
			}
165
		});
185
		});
166
		
186
167
		createVerticalSpacer(mainComposite, 1);
187
		createVerticalSpacer(mainComposite, 1);
168
		fReferencedProjects = createCheckButton(mainComposite, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_6);
188
		fReferencedProjects = createCheckButton(
189
				mainComposite,
190
				ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_6);
169
	}
191
	}
170
192
171
	/**
193
	/**
172
	 * Prompts the user to select the projects to build.
194
	 * Prompts the user to select the projects to build.
173
	 */
195
	 */
174
	private void selectResources() {
196
	private void selectResources() {
175
		ListSelectionDialog dialog = new ListSelectionDialog(getShell(), ResourcesPlugin.getWorkspace(), new ProjectsContentProvider(), new WorkbenchLabelProvider(), ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_7);
197
		ListSelectionDialog dialog = new ListSelectionDialog(
198
				getShell(),
199
				ResourcesPlugin.getWorkspace(),
200
				new ProjectsContentProvider(),
201
				new WorkbenchLabelProvider(),
202
				ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_7);
176
		dialog.setInitialElementSelections(fProjects);
203
		dialog.setInitialElementSelections(fProjects);
177
		if (dialog.open() == Window.CANCEL) {
204
		if (dialog.open() == Window.CANCEL) {
178
			return;
205
			return;
Lines 184-190 Link Here
184
		}
211
		}
185
		updateLaunchConfigurationDialog();
212
		updateLaunchConfigurationDialog();
186
	}
213
	}
187
	
214
188
	/**
215
	/**
189
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
216
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
190
	 */
217
	 */
Lines 197-211 Link Here
197
	public void initializeFrom(ILaunchConfiguration configuration) {
224
	public void initializeFrom(ILaunchConfiguration configuration) {
198
		updateScope(configuration);
225
		updateScope(configuration);
199
		updateReferencedProjects(configuration);
226
		updateReferencedProjects(configuration);
200
		updateEnabledState();		
227
		updateEnabledState();
201
	}
228
	}
202
	
229
203
	private void updateReferencedProjects(ILaunchConfiguration configuration) {
230
	private void updateReferencedProjects(ILaunchConfiguration configuration) {
204
		boolean ref = false;
231
		boolean ref = false;
205
		try {
232
		try {
206
			ref = configuration.getAttribute(IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS, true);
233
			ref = configuration.getAttribute(
234
					IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS,
235
					true);
207
		} catch (CoreException e) {
236
		} catch (CoreException e) {
208
			ExternalToolsPlugin.getDefault().log("Exception reading launch configuration", e); //$NON-NLS-1$
237
			ExternalToolsPlugin.getDefault().log(
238
					"Exception reading launch configuration", e); //$NON-NLS-1$
209
		}
239
		}
210
		fReferencedProjects.setSelection(ref);
240
		fReferencedProjects.setSelection(ref);
211
	}
241
	}
Lines 216-224 Link Here
216
	private void updateScope(ILaunchConfiguration configuration) {
246
	private void updateScope(ILaunchConfiguration configuration) {
217
		String scope = null;
247
		String scope = null;
218
		try {
248
		try {
219
			scope= configuration.getAttribute(IExternalToolConstants.ATTR_BUILD_SCOPE, (String)null);
249
			scope = configuration.getAttribute(
250
					IExternalToolConstants.ATTR_BUILD_SCOPE, (String) null);
220
		} catch (CoreException ce) {
251
		} catch (CoreException ce) {
221
			ExternalToolsPlugin.getDefault().log("Exception reading launch configuration", ce); //$NON-NLS-1$
252
			ExternalToolsPlugin.getDefault().log(
253
					"Exception reading launch configuration", ce); //$NON-NLS-1$
222
		}
254
		}
223
		fBuildButton.setSelection(scope != null);
255
		fBuildButton.setSelection(scope != null);
224
		fWorkspaceButton.setSelection(false);
256
		fWorkspaceButton.setSelection(false);
Lines 236-242 Link Here
236
				fProjectButton.setSelection(true);
268
				fProjectButton.setSelection(true);
237
			} else if (scope.startsWith("${projects:")) { //$NON-NLS-1$
269
			} else if (scope.startsWith("${projects:")) { //$NON-NLS-1$
238
				fSpecificProjectsButton.setSelection(true);
270
				fSpecificProjectsButton.setSelection(true);
239
				IProject[] projects = getBuildProjects(configuration, IExternalToolConstants.ATTR_BUILD_SCOPE);
271
				IProject[] projects = getBuildProjects(configuration,
272
						IExternalToolConstants.ATTR_BUILD_SCOPE);
240
				fProjects = new ArrayList(projects.length);
273
				fProjects = new ArrayList(projects.length);
241
				for (int i = 0; i < projects.length; i++) {
274
				for (int i = 0; i < projects.length; i++) {
242
					fProjects.add(projects[i]);
275
					fProjects.add(projects[i]);
Lines 244-260 Link Here
244
			}
277
			}
245
		}
278
		}
246
	}
279
	}
280
247
	/**
281
	/**
248
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
282
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
249
	 */
283
	 */
250
	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
284
	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
251
		String scope = generateScopeMemento();
285
		String scope = generateScopeMemento();
252
		configuration.setAttribute(IExternalToolConstants.ATTR_BUILD_SCOPE, scope);
286
		configuration.setAttribute(IExternalToolConstants.ATTR_BUILD_SCOPE,
287
				scope);
253
		if (fReferencedProjects.getSelection()) {
288
		if (fReferencedProjects.getSelection()) {
254
			// default is true
289
			// default is true
255
			configuration.setAttribute(IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS, (String)null);
290
			configuration.setAttribute(
291
					IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS,
292
					(String) null);
256
		} else {
293
		} else {
257
			configuration.setAttribute(IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS, false);
294
			configuration.setAttribute(
295
					IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS,
296
					false);
258
		}
297
		}
259
	}
298
	}
260
299
Lines 273-279 Link Here
273
				return getBuildScopeAttribute(fProjects);
312
				return getBuildScopeAttribute(fProjects);
274
			}
313
			}
275
			return null;
314
			return null;
276
			
315
277
		}
316
		}
278
		return "${none}"; //$NON-NLS-1$
317
		return "${none}"; //$NON-NLS-1$
279
	}
318
	}
Lines 284-389 Link Here
284
	public String getName() {
323
	public String getName() {
285
		return ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_8;
324
		return ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_8;
286
	}
325
	}
287
	
326
288
	/**
327
	/**
289
	 * Updates the enablement state of the fields.
328
	 * Updates the enablement state of the fields.
290
	 */
329
	 */
291
	private void updateEnabledState() {
330
	private void updateEnabledState() {
292
		boolean enabled= fBuildButton.getSelection();
331
		boolean enabled = fBuildButton.getSelection();
293
		fGroup.setEnabled(enabled);
332
		fGroup.setEnabled(enabled);
294
		fWorkspaceButton.setEnabled(enabled);
333
		fWorkspaceButton.setEnabled(enabled);
295
		fProjectButton.setEnabled(enabled);
334
		fProjectButton.setEnabled(enabled);
296
		fSpecificProjectsButton.setEnabled(enabled);
335
		fSpecificProjectsButton.setEnabled(enabled);
297
		fSelectButton.setEnabled(enabled && fSpecificProjectsButton.getSelection());
336
		fSelectButton.setEnabled(enabled
337
				&& fSpecificProjectsButton.getSelection());
298
		if (!enabled) {
338
		if (!enabled) {
299
			super.setErrorMessage(null);
339
			super.setErrorMessage(null);
300
		}
340
		}
301
		if (enabled) {
341
		if (enabled) {
302
			if (!fWorkspaceButton.getSelection() && !fProjectButton.getSelection() &&
342
			if (!fWorkspaceButton.getSelection()
303
					!fSpecificProjectsButton.getSelection()) {
343
					&& !fProjectButton.getSelection()
344
					&& !fSpecificProjectsButton.getSelection()) {
304
				fWorkspaceButton.setSelection(true);
345
				fWorkspaceButton.setSelection(true);
305
			}
346
			}
306
		}
347
		}
307
		fReferencedProjects.setEnabled(fBuildButton.getSelection() && (fProjectButton.getSelection() || fSpecificProjectsButton.getSelection()));
348
		fReferencedProjects.setEnabled(fBuildButton.getSelection()
349
				&& (fProjectButton.getSelection() || fSpecificProjectsButton
350
						.getSelection()));
308
	}
351
	}
309
	
352
310
	/**
353
	/**
311
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
354
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
312
	 */
355
	 */
313
	public Image getImage() {
356
	public Image getImage() {
314
		return ExternalToolsImages.getImage(IExternalToolConstants.IMG_TAB_BUILD);
357
		return ExternalToolsImages
358
				.getImage(IExternalToolConstants.IMG_TAB_BUILD);
315
	}
359
	}
316
360
317
	public boolean isValid(ILaunchConfiguration launchConfig) {
361
	public boolean isValid(ILaunchConfiguration launchConfig) {
318
		setErrorMessage(null);
362
		setErrorMessage(null);
319
		setMessage(null);
363
		setMessage(null);
320
		if (fBuildButton.getSelection() && fSpecificProjectsButton.getSelection() && fProjects.isEmpty()) {
364
		if (fBuildButton.getSelection()
365
				&& fSpecificProjectsButton.getSelection()
366
				&& fProjects.isEmpty()) {
321
			setErrorMessage(ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_9);
367
			setErrorMessage(ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_9);
322
			return false;
368
			return false;
323
		}
369
		}
324
		return true;
370
		return true;
325
	}
371
	}
326
	
372
327
	/**
373
	/**
328
	 * Returns a collection of projects referenced by a build scope attribute.
374
	 * Returns a collection of projects referenced by a build scope attribute.
329
	 * 
375
	 * 
330
	 * @return collection of projects referred to by configuration
376
	 * @return collection of projects referred to by configuration
331
	 */
377
	 */
332
	public static IProject[] getBuildProjects(ILaunchConfiguration configuration, String buildScopeId) {
378
	public static IProject[] getBuildProjects(
333
		String scope = null;
379
			ILaunchConfiguration configuration, String buildScopeId) {
334
		String id = buildScopeId ;
380
		return ExternalToolsCoreUtil.getBuildProjects(configuration,
335
		if (id == null) {
381
				buildScopeId);
336
			id = IExternalToolConstants.ATTR_BUILD_SCOPE ;
382
337
		}
338
		try {
339
			scope = configuration.getAttribute(id, (String)null);
340
		} catch (CoreException e) {
341
			return null;
342
		}
343
		if (scope == null) {
344
			return null;
345
		}
346
		if (scope.startsWith("${projects:")) { //$NON-NLS-1$
347
			String pathString = scope.substring(11, scope.length() - 1);
348
			if (pathString.length() > 1) {
349
				String[] names = pathString.split(","); //$NON-NLS-1$
350
				IProject[] projects = new IProject[names.length];
351
				IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
352
				for (int i = 0; i < names.length; i++) {
353
					projects[i] = root.getProject(names[i]);
354
				}
355
				return projects;
356
			}
357
		} else if (scope.equals("${project}")) { //$NON-NLS-1$
358
			IResource resource = DebugUITools.getSelectedResource();
359
			if (resource != null) {
360
				return new IProject[]{resource.getProject()};
361
			}
362
		}
363
		return new IProject[0];
364
	}
383
	}
365
	
384
366
	/**
385
	/**
367
	 * Whether referenced projects should be considered when building. Only valid
386
	 * Whether referenced projects should be considered when building. Only
368
	 * when a set of projects is to be built.
387
	 * valid when a set of projects is to be built.
369
	 * 
388
	 * 
370
	 * @param configuration
389
	 * @param configuration
371
	 * @return whether referenced projects should be considerd when building
390
	 * @return whether referenced projects should be considerd when building
372
	 * @throws CoreException if unable to access the associated attribute
391
	 * @throws CoreException
392
	 *             if unable to access the associated attribute
373
	 */
393
	 */
374
	public static boolean isIncludeReferencedProjects(ILaunchConfiguration configuration, String includeReferencedProjectsId) throws CoreException {
394
	public static boolean isIncludeReferencedProjects(
375
		String id = includeReferencedProjectsId;
395
			ILaunchConfiguration configuration,
376
		if (id == null) {
396
			String includeReferencedProjectsId) throws CoreException {
377
			id = IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS ;
397
		return ExternalToolsCoreUtil.isIncludeReferencedProjects(configuration,
378
		}
398
				includeReferencedProjectsId);
379
		return configuration.getAttribute(id, true);
380
	}
399
	}
381
	
400
382
	/**
401
	/**
383
	 * Creates and returns a memento for the given project set, to be used as a
402
	 * Creates and returns a memento for the given project set, to be used as a
384
	 * build scope attribute.
403
	 * build scope attribute.
385
	 * 
404
	 * 
386
	 * @param projects list of projects
405
	 * @param projects
406
	 *            list of projects
387
	 * @return an equivalent refresh attribute
407
	 * @return an equivalent refresh attribute
388
	 */
408
	 */
389
	public static String getBuildScopeAttribute(List projects) {
409
	public static String getBuildScopeAttribute(List projects) {
Lines 400-415 Link Here
400
		buf.append("}"); //$NON-NLS-1$
420
		buf.append("}"); //$NON-NLS-1$
401
		return buf.toString();
421
		return buf.toString();
402
	}
422
	}
403
	
423
404
	/* (non-Javadoc)
424
	/*
405
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
425
	 * (non-Javadoc)
426
	 * 
427
	 * @see
428
	 * org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug
429
	 * .core.ILaunchConfigurationWorkingCopy)
406
	 */
430
	 */
407
	public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
431
	public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
408
		// do nothing on activation
432
		// do nothing on activation
409
	}
433
	}
410
434
411
	/* (non-Javadoc)
435
	/*
412
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#deactivated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
436
	 * (non-Javadoc)
437
	 * 
438
	 * @see
439
	 * org.eclipse.debug.ui.ILaunchConfigurationTab#deactivated(org.eclipse.
440
	 * debug.core.ILaunchConfigurationWorkingCopy)
413
	 */
441
	 */
414
	public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) {
442
	public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) {
415
		// do nothing on deactivation
443
		// do nothing on deactivation
(-)External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java (-3 / +3 lines)
Lines 75-81 Link Here
75
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
75
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
76
import org.eclipse.ui.dialogs.PropertyPage;
76
import org.eclipse.ui.dialogs.PropertyPage;
77
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsMainTab;
77
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsMainTab;
78
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
78
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil;
79
import org.eclipse.ui.externaltools.internal.launchConfigurations.IgnoreWhiteSpaceComparator;
79
import org.eclipse.ui.externaltools.internal.launchConfigurations.IgnoreWhiteSpaceComparator;
80
import org.eclipse.ui.externaltools.internal.model.BuilderUtils;
80
import org.eclipse.ui.externaltools.internal.model.BuilderUtils;
81
import org.eclipse.ui.externaltools.internal.model.ExternalToolBuilder;
81
import org.eclipse.ui.externaltools.internal.model.ExternalToolBuilder;
Lines 858-864 Link Here
858
			}
858
			}
859
		} else if (element instanceof ILaunchConfiguration) {
859
		} else if (element instanceof ILaunchConfiguration) {
860
			try {
860
			try {
861
				return ExternalToolsUtil.isBuilderEnabled((ILaunchConfiguration) element);
861
				return ExternalToolsCoreUtil.isBuilderEnabled((ILaunchConfiguration) element);
862
			} catch (CoreException e) {
862
			} catch (CoreException e) {
863
			}
863
			}
864
		} else if (element instanceof ErrorConfig) {
864
		} else if (element instanceof ErrorConfig) {
Lines 985-991 Link Here
985
				String disabledBuilderName;
985
				String disabledBuilderName;
986
				try {
986
				try {
987
					disabledBuilderName = config.getAttribute(IExternalToolConstants.ATTR_DISABLED_BUILDER, (String)null);
987
					disabledBuilderName = config.getAttribute(IExternalToolConstants.ATTR_DISABLED_BUILDER, (String)null);
988
					if (disabledBuilderName != null && ExternalToolsUtil.isBuilderEnabled(config)) {
988
					if (disabledBuilderName != null && ExternalToolsCoreUtil.isBuilderEnabled(config)) {
989
						possibleCommands.add(translateBackToCommand(config, project));
989
						possibleCommands.add(translateBackToCommand(config, project));
990
						continue;
990
						continue;
991
					}
991
					}
(-)External (+203 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 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
 *     Keith Seitz (keiths@redhat.com) - Bug 27243 (environment variables contribution)
11
 *     dakshinamurthy.karra@gmail.com - bug 165371
12
 *******************************************************************************/
13
package org.eclipse.ui.externaltools.internal.launchConfigurations;
14
15
16
import java.io.File;
17
18
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.Path;
23
import org.eclipse.core.runtime.Status;
24
import org.eclipse.core.variables.IStringVariableManager;
25
import org.eclipse.core.variables.VariablesPlugin;
26
import org.eclipse.debug.core.DebugPlugin;
27
import org.eclipse.debug.core.ILaunchConfiguration;
28
import org.eclipse.debug.ui.RefreshTab;
29
import org.eclipse.osgi.util.NLS;
30
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
31
32
/**
33
 * Utilities for external tool launch configurations.
34
 * <p>
35
 * This class it not intended to be instantiated.
36
 * </p>
37
 */
38
public class ExternalToolsCoreUtil {
39
40
	/**
41
	 * Throws a core exception with an error status object built from
42
	 * the given message, lower level exception, and error code.
43
	 * 
44
	 * @param message the status message
45
	 * @param exception lower level exception associated with the
46
	 *  error, or <code>null</code> if none
47
	 * @param code error code
48
	 */
49
	protected static void abort(String message, Throwable exception, int code) throws CoreException {
50
		throw new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, code, message, exception));
51
	}
52
	
53
	/**
54
	 * Expands and returns the location attribute of the given launch
55
	 * configuration. The location is
56
	 * verified to point to an existing file, in the local file system.
57
	 * 
58
	 * @param configuration launch configuration
59
	 * @return an absolute path to a file in the local file system  
60
	 * @throws CoreException if unable to retrieve the associated launch
61
	 * configuration attribute, if unable to resolve any variables, or if the
62
	 * resolved location does not point to an existing file in the local file
63
	 * system
64
	 */
65
	public static IPath getLocation(ILaunchConfiguration configuration) throws CoreException {
66
		String location = configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String) null);
67
		if (location == null) {
68
			abort(NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_Location_not_specified_by__0__1, new String[] { configuration.getName()}), null, 0);
69
		} else {
70
			String expandedLocation = getStringVariableManager().performStringSubstitution(location);
71
			if (expandedLocation == null || expandedLocation.length() == 0) {
72
				String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()});
73
				abort(msg, null, 0);
74
			} else {
75
				File file = new File(expandedLocation);
76
				if (file.isFile()) {
77
					return new Path(expandedLocation);
78
				} 
79
				
80
				String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()});
81
				abort(msg, null, 0);
82
			}
83
		}
84
		// execution will not reach here
85
		return null;
86
	}
87
	
88
	/**
89
	 * Returns a boolean specifying whether or not output should be captured for
90
	 * the given configuration
91
	 * 
92
	 * @param configuration the configuration from which the value will be
93
	 * extracted
94
	 * @return boolean specifying whether or not output should be captured
95
	 * @throws CoreException if unable to access the associated attribute
96
	 */
97
	public static boolean getCaptureOutput(ILaunchConfiguration configuration) throws CoreException {
98
	    return configuration.getAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true);
99
	}
100
101
	/**
102
	 * Expands and returns the working directory attribute of the given launch
103
	 * configuration. Returns <code>null</code> if a working directory is not
104
	 * specified. If specified, the working is verified to point to an existing
105
	 * directory in the local file system.
106
	 * 
107
	 * @param configuration launch configuration
108
	 * @return an absolute path to a directory in the local file system, or
109
	 * <code>null</code> if unspecified
110
	 * @throws CoreException if unable to retrieve the associated launch
111
	 * configuration attribute, if unable to resolve any variables, or if the
112
	 * resolved location does not point to an existing directory in the local
113
	 * file system
114
	 */
115
	public static IPath getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
116
		String location = configuration.getAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) null);
117
		if (location != null) {
118
			String expandedLocation = getStringVariableManager().performStringSubstitution(location);
119
			if (expandedLocation.length() > 0) {
120
				File path = new File(expandedLocation);
121
				if (path.isDirectory()) {
122
					return new Path(expandedLocation);
123
				} 
124
				String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidDirectory__0_, new Object[] { expandedLocation, configuration.getName()});
125
				abort(msg, null, 0);
126
			}
127
		}
128
		return null;
129
	}
130
131
	/**
132
	 * Expands and returns the arguments attribute of the given launch
133
	 * configuration. Returns <code>null</code> if arguments are not specified.
134
	 * 
135
	 * @param configuration launch configuration
136
	 * @return an array of resolved arguments, or <code>null</code> if
137
	 * unspecified
138
	 * @throws CoreException if unable to retrieve the associated launch
139
	 * configuration attribute, or if unable to resolve any variables
140
	 */
141
	public static String[] getArguments(ILaunchConfiguration configuration) throws CoreException {
142
		String args = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String) null);
143
		if (args != null) {
144
			String expanded = getStringVariableManager().performStringSubstitution(args);
145
			return parseStringIntoList(expanded);
146
		}
147
		return null;
148
	}
149
150
	private static IStringVariableManager getStringVariableManager() {
151
		return VariablesPlugin.getDefault().getStringVariableManager();
152
	}
153
	
154
	/**
155
	 * Returns whether the given launch configuration is enabled. This property
156
	 * is intended only to apply to external tool builder configurations and
157
	 * determines whether the project builder will launch the configuration
158
	 * when it builds.
159
	 *  
160
	 * @param configuration the configuration for which the enabled state should
161
	 * 		be determined.
162
	 * @return whether the given configuration is enabled to be run when a build occurs.
163
	 * @throws CoreException if unable to access the associated attribute
164
	 */
165
	public static boolean isBuilderEnabled(ILaunchConfiguration configuration) throws CoreException {
166
		return configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_ENABLED, true);
167
	}
168
	
169
	/**
170
	 * Returns the collection of resources for the build scope as specified by the given launch configuration.
171
	 * 
172
	 * @param configuration launch configuration
173
	 * @throws CoreException if an exception occurs while retrieving the resources
174
	 */
175
	public static IResource[] getResourcesForBuildScope(ILaunchConfiguration configuration) throws CoreException {
176
		String scope = configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_SCOPE, (String) null);
177
		if (scope == null) {
178
			return null;
179
		}
180
	
181
		return RefreshTab.getRefreshResources(scope);
182
	}
183
	
184
	/**
185
	 * Parses the argument text into an array of individual
186
	 * strings using the space character as the delimiter.
187
	 * An individual argument containing spaces must have a
188
	 * double quote (") at the start and end. Two double 
189
	 * quotes together is taken to mean an embedded double
190
	 * quote in the argument text.
191
	 * 
192
	 * @param arguments the arguments as one string
193
	 * @return the array of arguments
194
	 */
195
	public static String[] parseStringIntoList(String arguments) {
196
		if (arguments == null || arguments.length() == 0) {
197
			return new String[0];
198
		}
199
		String[] res= DebugPlugin.parseArguments(arguments);
200
		return res;		
201
	}	
202
	
203
}
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 7-13 Link Here
7
Bundle-Vendor: %providerName
7
Bundle-Vendor: %providerName
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
9
Export-Package: org.eclipse.ant.core,
9
Export-Package: org.eclipse.ant.core,
10
 org.eclipse.ant.internal.core;x-friends:="org.eclipse.ant.ui",
10
 org.eclipse.ant.internal.core;x-friends:="org.eclipse.ant.ui,org.eclipse.ant.launching",
11
 org.eclipse.ant.internal.core.contentDescriber;x-internal:=true
11
 org.eclipse.ant.internal.core.contentDescriber;x-internal:=true
12
Require-Bundle: org.eclipse.core.variables;bundle-version="[3.1.0,4.0.0)",
12
Require-Bundle: org.eclipse.core.variables;bundle-version="[3.1.0,4.0.0)",
13
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)"
13
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)"

Return to bug 264338