Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 148142 Details for
Bug 264338
External tool builder fails in headless mode because of dependencies to UI
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
HeadlessPluginsMigration(inProgress)
HeadlessMigrationPatch(inProgress).txt (text/plain), 670.20 KB, created by
Natalia Bartol
on 2009-09-25 12:34:50 EDT
(
hide
)
Description:
HeadlessPluginsMigration(inProgress)
Filename:
MIME Type:
Creator:
Natalia Bartol
Created:
2009-09-25 12:34:50 EDT
Size:
670.20 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.debug.ui >Index: ui/org/eclipse/debug/ui/RefreshTab.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/RefreshTab.java,v >retrieving revision 1.26 >diff -u -r1.26 RefreshTab.java >--- ui/org/eclipse/debug/ui/RefreshTab.java 31 Mar 2009 20:46:31 -0000 1.26 >+++ ui/org/eclipse/debug/ui/RefreshTab.java 25 Sep 2009 16:23:08 -0000 >@@ -14,26 +14,20 @@ > import java.io.IOException; > import java.io.StringReader; > import java.io.StringWriter; >-import com.ibm.icu.text.MessageFormat; >+ > import org.eclipse.core.resources.IResource; >-import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.MultiStatus; >-import org.eclipse.core.runtime.NullProgressMonitor; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.core.runtime.Status; > import org.eclipse.debug.core.DebugPlugin; > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.debug.internal.core.LaunchManager; > import org.eclipse.debug.internal.ui.DebugPluginImages; > import org.eclipse.debug.internal.ui.DebugUIPlugin; > import org.eclipse.debug.internal.ui.IDebugHelpContextIds; > import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; > import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog; >-import org.eclipse.debug.internal.ui.stringsubstitution.SelectedResourceManager; > import org.eclipse.debug.internal.ui.stringsubstitution.StringSubstitutionMessages; > import org.eclipse.jface.window.Window; > import org.eclipse.jface.wizard.WizardDialog; >@@ -410,46 +404,7 @@ > * @throws CoreException if an exception occurs while refreshing resources > */ > public static void refreshResources(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { >- if (monitor == null) { >- monitor = new NullProgressMonitor(); >- } >- String scope = getRefreshScope(configuration); >- IResource[] resources= null; >- if (scope != null) { >- resources = getRefreshResources(scope); >- } >- if (resources == null || resources.length == 0){ >- return; >- } >- int depth = IResource.DEPTH_ONE; >- if (isRefreshRecursive(configuration)) >- depth = IResource.DEPTH_INFINITE; >- >- if (monitor.isCanceled()) { >- return; >- } >- >- monitor.beginTask(StringSubstitutionMessages.RefreshTab_7, >- resources.length); >- >- MultiStatus status = new MultiStatus(DebugUIPlugin.getUniqueIdentifier(), 0, StringSubstitutionMessages.RefreshTab_8, null); >- for (int i = 0; i < resources.length; i++) { >- if (monitor.isCanceled()) >- break; >- if (resources[i] != null && resources[i].isAccessible()) { >- try { >- resources[i].refreshLocal(depth, null); >- } catch (CoreException e) { >- status.merge(e.getStatus()); >- } >- } >- monitor.worked(1); >- } >- >- monitor.done(); >- if (!status.isOK()) { >- throw new CoreException(status); >- } >+ LaunchManager.refreshResources(configuration, monitor); > } > > /** >@@ -460,48 +415,7 @@ > * @throws CoreException if unable to resolve a set of resources > */ > public static IResource[] getRefreshResources(String scope) throws CoreException { >- if (scope.startsWith("${resource:")) { //$NON-NLS-1$ >- // This is an old format that is replaced with 'working_set' >- String pathString = scope.substring(11, scope.length() - 1); >- Path path = new Path(pathString); >- IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path); >- if (resource == null) { >- throw new CoreException(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, MessageFormat.format(StringSubstitutionMessages.RefreshTab_43, new String[]{pathString}), null)); >- } >- return new IResource[]{resource}; >- } else if (scope.startsWith("${working_set:")) { //$NON-NLS-1$ >- IWorkingSet workingSet = getWorkingSet(scope); >- if (workingSet == null) { >- throw new CoreException(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, StringSubstitutionMessages.RefreshTab_44, null)); >- } >- IAdaptable[] elements = workingSet.getElements(); >- IResource[] resources = new IResource[elements.length]; >- for (int i = 0; i < elements.length; i++) { >- IAdaptable adaptable = elements[i]; >- if (adaptable instanceof IResource) { >- resources[i] = (IResource) adaptable; >- } else { >- resources[i] = (IResource) adaptable.getAdapter(IResource.class); >- } >- } >- return resources; >- } else if(scope.equals("${workspace}")) { //$NON-NLS-1$ >- return new IResource[]{ResourcesPlugin.getWorkspace().getRoot()}; >- } else { >- IResource resource = SelectedResourceManager.getDefault().getSelectedResource(); >- if (resource == null) { >- // empty selection >- return new IResource[]{}; >- } >- if (scope.equals("${resource}")) { //$NON-NLS-1$ >- // resource = resource >- } else if (scope.equals("${container}")) { //$NON-NLS-1$ >- resource = resource.getParent(); >- } else if (scope.equals("${project}")) { //$NON-NLS-1$ >- resource = resource.getProject(); >- } >- return new IResource[]{resource}; >- } >+ return LaunchManager.getRefreshResources(scope); > } > > /** >@@ -538,7 +452,7 @@ > * @throws CoreException if unable to access the associated attribute > */ > public static String getRefreshScope(ILaunchConfiguration configuration) throws CoreException { >- return configuration.getAttribute(ATTR_REFRESH_SCOPE, (String) null); >+ return LaunchManager.getRefreshScope(configuration); > } > > /** >Index: ui/org/eclipse/debug/ui/CommonTab.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java,v >retrieving revision 1.98 >diff -u -r1.98 CommonTab.java >--- ui/org/eclipse/debug/ui/CommonTab.java 21 Jul 2009 14:27:29 -0000 1.98 >+++ ui/org/eclipse/debug/ui/CommonTab.java 25 Sep 2009 16:23:08 -0000 >@@ -31,6 +31,7 @@ > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; > import org.eclipse.debug.internal.core.IInternalDebugCoreConstants; >+import org.eclipse.debug.internal.core.LaunchManager; > import org.eclipse.debug.internal.ui.DebugUIPlugin; > import org.eclipse.debug.internal.ui.IDebugHelpContextIds; > import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; >@@ -590,13 +591,7 @@ > * @return whether the configuration is configured to launch in the background > */ > public static boolean isLaunchInBackground(ILaunchConfiguration configuration) { >- boolean launchInBackground= true; >- try { >- launchInBackground= configuration.getAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true); >- } catch (CoreException ce) { >- DebugUIPlugin.log(ce); >- } >- return launchInBackground; >+ return LaunchManager.isLaunchInBackground(configuration); > } > > /** >#P org.eclipse.debug.core >Index: core/org/eclipse/debug/internal/core/DebugCoreMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java,v >retrieving revision 1.38 >diff -u -r1.38 DebugCoreMessages.java >--- core/org/eclipse/debug/internal/core/DebugCoreMessages.java 20 Apr 2009 15:38:03 -0000 1.38 >+++ core/org/eclipse/debug/internal/core/DebugCoreMessages.java 25 Sep 2009 16:23:09 -0000 >@@ -109,6 +109,9 @@ > public static String RuntimeProcess_Exit_value_not_available_until_process_terminates__1; > public static String WatchExpression_0; > public static String NullStreamsProxy_0; >+ >+ public static String RefreshingResources; >+ public static String RefreshingResourcesError; > > static { > // load message values from bundle file >Index: core/org/eclipse/debug/internal/core/Preferences.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/Preferences.java,v >retrieving revision 1.1 >diff -u -r1.1 Preferences.java >--- core/org/eclipse/debug/internal/core/Preferences.java 2 Sep 2009 15:43:12 -0000 1.1 >+++ core/org/eclipse/debug/internal/core/Preferences.java 25 Sep 2009 16:23:13 -0000 >@@ -1,415 +1,415 @@ >-/******************************************************************************* >- * Copyright (c) 2009 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.debug.internal.core; >- >-import org.eclipse.core.runtime.preferences.DefaultScope; >-import org.eclipse.core.runtime.preferences.IEclipsePreferences; >-import org.eclipse.core.runtime.preferences.IScopeContext; >-import org.eclipse.core.runtime.preferences.InstanceScope; >-import org.eclipse.debug.core.DebugPlugin; >-import org.osgi.service.prefs.BackingStoreException; >- >-/** >- * Convenience class to facilitate using the new {@link IEclipsePreferences} story >- * >- * @since 3.6 >- * @noinstantiate This class is not intended to be instantiated by clients. >- */ >-public final class Preferences { >- >- static final IScopeContext[] contexts = new IScopeContext[] {new DefaultScope(), new InstanceScope()}; >- >- static final int DEFAULT_CONTEXT = 0; >- static final int INSTANCE_CONTEXT = 1; >- >- /** >- * Constructor >- */ >- private Preferences() { >- // no direct instantiation >- } >- >- /** >- * Sets a string preference in the {@link InstanceScope} or the given {@link IScopeContext} if it >- * is not <code>null</code>. Preferences set in a given context are flushed as they are set. >- * @param qualifier >- * @param key the key >- * @param value the value >- * @param context >- */ >- public static synchronized void setString(String qualifier, String key, String value, IScopeContext context) { >- if(context != null) { >- try { >- IEclipsePreferences node = context.getNode(qualifier); >- node.put(key, value); >- node.flush(); >- } >- catch(BackingStoreException bse) { >- DebugPlugin.log(bse); >- } >- } >- else { >- contexts[INSTANCE_CONTEXT].getNode(qualifier).put(key, value); >- } >- } >- >- /** >- * Sets a boolean preference in the {@link InstanceScope} or the given {@link IScopeContext} if it >- * is not <code>null</code>. Preferences set in a given context are flushed as they are set. >- * @param qualifier >- * @param key the key >- * @param value the value >- * @param context >- */ >- public static synchronized void setBoolean(String qualifier, String key, boolean value, IScopeContext context) { >- if(context != null) { >- try { >- IEclipsePreferences node = context.getNode(qualifier); >- node.putBoolean(key, value); >- node.flush(); >- } >- catch(BackingStoreException bse) { >- DebugPlugin.log(bse); >- } >- } >- else { >- contexts[INSTANCE_CONTEXT].getNode(qualifier).putBoolean(key, value); >- } >- } >- >- /** >- * Sets a integer preference in the {@link InstanceScope} or the given {@link IScopeContext} if it >- * is not <code>null</code>. Preferences set in a given context are flushed as they are set. >- * @param qualifier >- * @param key the key >- * @param value the value >- * @param context >- */ >- public static synchronized void setInt(String qualifier, String key, int value, IScopeContext context) { >- if(context != null) { >- try { >- IEclipsePreferences node = context.getNode(qualifier); >- node.putInt(key, value); >- node.flush(); >- } >- catch(BackingStoreException bse) { >- DebugPlugin.log(bse); >- } >- } >- else { >- contexts[INSTANCE_CONTEXT].getNode(qualifier).putInt(key, value); >- } >- } >- >- /** >- * Sets a long preference in the {@link InstanceScope} or the given {@link IScopeContext} if it >- * is not <code>null</code>. Preferences set in a given context are flushed as they are set. >- * @param qualifier >- * @param key the key >- * @param value the value >- * @param context >- */ >- public static synchronized void setLong(String qualifier, String key, long value, IScopeContext context) { >- if(context != null) { >- try { >- IEclipsePreferences node = context.getNode(qualifier); >- node.putLong(key, value); >- node.flush(); >- } >- catch(BackingStoreException bse) { >- DebugPlugin.log(bse); >- } >- } >- else { >- contexts[INSTANCE_CONTEXT].getNode(qualifier).putLong(key, value); >- } >- } >- >- /** >- * Sets a byte array preference in the {@link InstanceScope} or the given {@link IScopeContext} if it >- * is not <code>null</code>. Preferences set in a given context are flushed as they are set. >- * @param qualifier >- * @param key the key >- * @param value the value >- * @param context >- */ >- public static synchronized void setByteArray(String qualifier, String key, byte[] value, IScopeContext context) { >- if(context != null) { >- try { >- IEclipsePreferences node = context.getNode(qualifier); >- node.putByteArray(key, value); >- node.flush(); >- } >- catch(BackingStoreException bse) { >- DebugPlugin.log(bse); >- } >- } >- else { >- contexts[INSTANCE_CONTEXT].getNode(qualifier).putByteArray(key, value); >- } >- } >- >- /** >- * Sets a double preference in the {@link InstanceScope} or the given {@link IScopeContext} if it >- * is not <code>null</code>. Preferences set in a given context are flushed as they are set. >- * @param qualifier >- * @param key the key >- * @param value the value >- * @param context >- */ >- public static synchronized void setDouble(String qualifier, String key, double value, IScopeContext context) { >- if(context != null) { >- try { >- IEclipsePreferences node = context.getNode(qualifier); >- node.putDouble(key, value); >- node.flush(); >- } >- catch(BackingStoreException bse) { >- DebugPlugin.log(bse); >- } >- } >- else { >- contexts[INSTANCE_CONTEXT].getNode(qualifier).putDouble(key, value); >- } >- } >- >- /** >- * Sets a float preference in the {@link InstanceScope} or the given {@link IScopeContext} if it >- * is not <code>null</code>. Preferences set in a given context are flushed as they are set. >- * @param qualifier >- * @param key the key >- * @param value the value >- * @param context >- */ >- public static synchronized void setFloat(String qualifier, String key, float value, IScopeContext context) { >- if(context != null) { >- try { >- IEclipsePreferences node = context.getNode(qualifier); >- node.putFloat(key, value); >- node.flush(); >- } >- catch(BackingStoreException bse) { >- DebugPlugin.log(bse); >- } >- } >- else { >- contexts[INSTANCE_CONTEXT].getNode(qualifier).putFloat(key, value); >- } >- } >- >- /** >- * Sets a string in the {@link DefaultScope} >- * @param qualifier >- * @param key the key >- * @param value the new value >- */ >- public static synchronized void setDefaultString(String qualifier, String key, String value) { >- contexts[DEFAULT_CONTEXT].getNode(qualifier).put(key, value); >- } >- >- /** >- * Sets a boolean in the {@link DefaultScope} >- * @param qualifier >- * @param key the key >- * @param value the new value >- */ >- public static synchronized void setDefaultBoolean(String qualifier, String key, boolean value) { >- contexts[DEFAULT_CONTEXT].getNode(qualifier).putBoolean(key, value); >- } >- >- /** >- * Sets a byte array in the {@link DefaultScope} >- * @param qualifier >- * @param key the key >- * @param value the new value >- */ >- public static synchronized void setDefaultByteArray(String qualifier, String key, byte[] value) { >- contexts[DEFAULT_CONTEXT].getNode(qualifier).putByteArray(key, value); >- } >- >- /** >- * Sets a double in the {@link DefaultScope} >- * @param qualifier >- * @param key the key >- * @param value the new value >- */ >- public static synchronized void setDefaultDouble(String qualifier, String key, double value) { >- contexts[DEFAULT_CONTEXT].getNode(qualifier).putDouble(key, value); >- } >- >- /** >- * Sets a float in the {@link DefaultScope} >- * @param qualifier >- * @param key the key >- * @param value the new value >- */ >- public static synchronized void setDefaultFloat(String qualifier, String key, float value) { >- contexts[DEFAULT_CONTEXT].getNode(qualifier).putFloat(key, value); >- } >- >- /** >- * Sets a integer in the {@link DefaultScope} >- * @param qualifier >- * @param key the key >- * @param value the new value >- */ >- public static synchronized void setDefaultInt(String qualifier, String key, int value) { >- contexts[DEFAULT_CONTEXT].getNode(qualifier).putInt(key, value); >- } >- >- /** >- * Sets a long in the {@link DefaultScope} >- * @param qualifier >- * @param key the key >- * @param value the new value >- */ >- public static synchronized void setDefaultLong(String qualifier, String key, long value) { >- contexts[DEFAULT_CONTEXT].getNode(qualifier).putLong(key, value); >- } >- >- /** >- * Sets the given preference to its default value. This is done by removing any set value >- * from the {@link InstanceScope}. Has no effect if the given key is <code>null</code>. >- * @param qualifier >- * @param key the key for the preference >- */ >- public static synchronized void setToDefault(String qualifier, String key) { >- if(key != null) { >- contexts[INSTANCE_CONTEXT].getNode(qualifier).remove(key); >- } >- } >- >- /** >- * Returns the default boolean value stored in the {@link DefaultScope} for the given key >- * or the specified default value if the key does not appear in the {@link DefaultScope} >- * @param qualifier >- * @param key >- * @param defaultvalue >- * >- * @return the boolean value set in the {@link DefaultScope} for the given key, or the specified default value. >- */ >- public static synchronized boolean getDefaultBoolean(String qualifier, String key, boolean defaultvalue) { >- return contexts[DEFAULT_CONTEXT].getNode(qualifier).getBoolean(key, defaultvalue); >- } >- >- /** >- * Returns the default string value stored in the {@link DefaultScope} for the given key >- * or the specified default value if the key does not appear in the {@link DefaultScope} >- * @param qualifier >- * @param key >- * @param defaultvalue >- * >- * @return the string value set in the {@link DefaultScope} for the given key, or the specified default value. >- */ >- public static synchronized String getDefaultString(String qualifier, String key, String defaultvalue) { >- return contexts[DEFAULT_CONTEXT].getNode(qualifier).get(key, defaultvalue); >- } >- >- /** >- * Returns the default byte array value stored in the {@link DefaultScope} for the given key >- * or the specified default value if the key does not appear in the {@link DefaultScope} >- * @param qualifier >- * @param key >- * @param defaultvalue >- * >- * @return the byte array value set in the {@link DefaultScope} for the given key, or the specified default value. >- */ >- public static synchronized byte[] getDefaultByteArray(String qualifier, String key, byte[] defaultvalue) { >- return contexts[DEFAULT_CONTEXT].getNode(qualifier).getByteArray(key, defaultvalue); >- } >- >- /** >- * Returns the default integer value stored in the {@link DefaultScope} for the given key >- * or the specified default value if the key does not appear in the {@link DefaultScope} >- * @param qualifier >- * @param key >- * @param defaultvalue >- * >- * @return the integer value set in the {@link DefaultScope} for the given key, or the specified default value. >- */ >- public static synchronized int getDefaultInt(String qualifier, String key, int defaultvalue) { >- return contexts[DEFAULT_CONTEXT].getNode(qualifier).getInt(key, defaultvalue); >- } >- >- /** >- * Returns the default long value stored in the {@link DefaultScope} for the given key >- * or the specified default value if the key does not appear in the {@link DefaultScope} >- * @param qualifier >- * @param key >- * @param defaultvalue >- * >- * @return the long value set in the {@link DefaultScope} for the given key, or the specified default value. >- */ >- public static synchronized long getDefaultLong(String qualifier, String key, long defaultvalue) { >- return contexts[DEFAULT_CONTEXT].getNode(qualifier).getLong(key, defaultvalue); >- } >- >- /** >- * Returns the default double value stored in the {@link DefaultScope} for the given key >- * or the specified default value if the key does not appear in the {@link DefaultScope} >- * @param qualifier >- * @param key >- * @param defaultvalue >- * >- * @return the double value set in the {@link DefaultScope} for the given key, or the specified default value. >- */ >- public static synchronized double getDefaultDouble(String qualifier, String key, double defaultvalue) { >- return contexts[DEFAULT_CONTEXT].getNode(qualifier).getDouble(key, defaultvalue); >- } >- >- /** >- * Returns the default float value stored in the {@link DefaultScope} for the given key >- * or the specified default value if the key does not appear in the {@link DefaultScope} >- * @param qualifier >- * @param key >- * @param defaultvalue >- * >- * @return the float value set in the {@link DefaultScope} for the given key, or the specified default value. >- */ >- public static synchronized float getDefaultFloat(String qualifier, String key, float defaultvalue) { >- return contexts[DEFAULT_CONTEXT].getNode(qualifier).getFloat(key, defaultvalue); >- } >- >- /** >- * Save the preferences for the given plugin identifier. >- * It should be noted that all pending preference changes will be flushed with this method. >- * @param qualifier >- */ >- public static synchronized void savePreferences(String qualifier) { >- try { >- contexts[DEFAULT_CONTEXT].getNode(qualifier).flush(); >- contexts[INSTANCE_CONTEXT].getNode(qualifier).flush(); >- } >- catch(BackingStoreException bse) { >- DebugPlugin.log(bse); >- } >- } >- >- /** >- * Adds the given preference listener to the {@link DefaultScope} and the {@link InstanceScope} >- * @param qualifier >- * @param listener >- */ >- public static void addPreferenceListener(String qualifier, IEclipsePreferences.IPreferenceChangeListener listener) { >- contexts[DEFAULT_CONTEXT].getNode(qualifier).addPreferenceChangeListener(listener); >- contexts[INSTANCE_CONTEXT].getNode(qualifier).addPreferenceChangeListener(listener); >- } >- >- /** >- * Removes the given preference listener from the {@link DefaultScope} and the {@link InstanceScope} >- * @param qualifier >- * @param listener >- */ >- public static void removePreferenceListener(String qualifier, IEclipsePreferences.IPreferenceChangeListener listener) { >- contexts[DEFAULT_CONTEXT].getNode(qualifier).removePreferenceChangeListener(listener); >- contexts[INSTANCE_CONTEXT].getNode(qualifier).removePreferenceChangeListener(listener); >- } >-} >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.debug.internal.core; >+ >+import org.eclipse.core.runtime.preferences.DefaultScope; >+import org.eclipse.core.runtime.preferences.IEclipsePreferences; >+import org.eclipse.core.runtime.preferences.IScopeContext; >+import org.eclipse.core.runtime.preferences.InstanceScope; >+import org.eclipse.debug.core.DebugPlugin; >+import org.osgi.service.prefs.BackingStoreException; >+ >+/** >+ * Convenience class to facilitate using the new {@link IEclipsePreferences} story >+ * >+ * @since 3.6 >+ * @noinstantiate This class is not intended to be instantiated by clients. >+ */ >+public final class Preferences { >+ >+ static final IScopeContext[] contexts = new IScopeContext[] {new DefaultScope(), new InstanceScope()}; >+ >+ static final int DEFAULT_CONTEXT = 0; >+ static final int INSTANCE_CONTEXT = 1; >+ >+ /** >+ * Constructor >+ */ >+ private Preferences() { >+ // no direct instantiation >+ } >+ >+ /** >+ * Sets a string preference in the {@link InstanceScope} or the given {@link IScopeContext} if it >+ * is not <code>null</code>. Preferences set in a given context are flushed as they are set. >+ * @param qualifier >+ * @param key the key >+ * @param value the value >+ * @param context >+ */ >+ public static synchronized void setString(String qualifier, String key, String value, IScopeContext context) { >+ if(context != null) { >+ try { >+ IEclipsePreferences node = context.getNode(qualifier); >+ node.put(key, value); >+ node.flush(); >+ } >+ catch(BackingStoreException bse) { >+ DebugPlugin.log(bse); >+ } >+ } >+ else { >+ contexts[INSTANCE_CONTEXT].getNode(qualifier).put(key, value); >+ } >+ } >+ >+ /** >+ * Sets a boolean preference in the {@link InstanceScope} or the given {@link IScopeContext} if it >+ * is not <code>null</code>. Preferences set in a given context are flushed as they are set. >+ * @param qualifier >+ * @param key the key >+ * @param value the value >+ * @param context >+ */ >+ public static synchronized void setBoolean(String qualifier, String key, boolean value, IScopeContext context) { >+ if(context != null) { >+ try { >+ IEclipsePreferences node = context.getNode(qualifier); >+ node.putBoolean(key, value); >+ node.flush(); >+ } >+ catch(BackingStoreException bse) { >+ DebugPlugin.log(bse); >+ } >+ } >+ else { >+ contexts[INSTANCE_CONTEXT].getNode(qualifier).putBoolean(key, value); >+ } >+ } >+ >+ /** >+ * Sets a integer preference in the {@link InstanceScope} or the given {@link IScopeContext} if it >+ * is not <code>null</code>. Preferences set in a given context are flushed as they are set. >+ * @param qualifier >+ * @param key the key >+ * @param value the value >+ * @param context >+ */ >+ public static synchronized void setInt(String qualifier, String key, int value, IScopeContext context) { >+ if(context != null) { >+ try { >+ IEclipsePreferences node = context.getNode(qualifier); >+ node.putInt(key, value); >+ node.flush(); >+ } >+ catch(BackingStoreException bse) { >+ DebugPlugin.log(bse); >+ } >+ } >+ else { >+ contexts[INSTANCE_CONTEXT].getNode(qualifier).putInt(key, value); >+ } >+ } >+ >+ /** >+ * Sets a long preference in the {@link InstanceScope} or the given {@link IScopeContext} if it >+ * is not <code>null</code>. Preferences set in a given context are flushed as they are set. >+ * @param qualifier >+ * @param key the key >+ * @param value the value >+ * @param context >+ */ >+ public static synchronized void setLong(String qualifier, String key, long value, IScopeContext context) { >+ if(context != null) { >+ try { >+ IEclipsePreferences node = context.getNode(qualifier); >+ node.putLong(key, value); >+ node.flush(); >+ } >+ catch(BackingStoreException bse) { >+ DebugPlugin.log(bse); >+ } >+ } >+ else { >+ contexts[INSTANCE_CONTEXT].getNode(qualifier).putLong(key, value); >+ } >+ } >+ >+ /** >+ * Sets a byte array preference in the {@link InstanceScope} or the given {@link IScopeContext} if it >+ * is not <code>null</code>. Preferences set in a given context are flushed as they are set. >+ * @param qualifier >+ * @param key the key >+ * @param value the value >+ * @param context >+ */ >+ public static synchronized void setByteArray(String qualifier, String key, byte[] value, IScopeContext context) { >+ if(context != null) { >+ try { >+ IEclipsePreferences node = context.getNode(qualifier); >+ node.putByteArray(key, value); >+ node.flush(); >+ } >+ catch(BackingStoreException bse) { >+ DebugPlugin.log(bse); >+ } >+ } >+ else { >+ contexts[INSTANCE_CONTEXT].getNode(qualifier).putByteArray(key, value); >+ } >+ } >+ >+ /** >+ * Sets a double preference in the {@link InstanceScope} or the given {@link IScopeContext} if it >+ * is not <code>null</code>. Preferences set in a given context are flushed as they are set. >+ * @param qualifier >+ * @param key the key >+ * @param value the value >+ * @param context >+ */ >+ public static synchronized void setDouble(String qualifier, String key, double value, IScopeContext context) { >+ if(context != null) { >+ try { >+ IEclipsePreferences node = context.getNode(qualifier); >+ node.putDouble(key, value); >+ node.flush(); >+ } >+ catch(BackingStoreException bse) { >+ DebugPlugin.log(bse); >+ } >+ } >+ else { >+ contexts[INSTANCE_CONTEXT].getNode(qualifier).putDouble(key, value); >+ } >+ } >+ >+ /** >+ * Sets a float preference in the {@link InstanceScope} or the given {@link IScopeContext} if it >+ * is not <code>null</code>. Preferences set in a given context are flushed as they are set. >+ * @param qualifier >+ * @param key the key >+ * @param value the value >+ * @param context >+ */ >+ public static synchronized void setFloat(String qualifier, String key, float value, IScopeContext context) { >+ if(context != null) { >+ try { >+ IEclipsePreferences node = context.getNode(qualifier); >+ node.putFloat(key, value); >+ node.flush(); >+ } >+ catch(BackingStoreException bse) { >+ DebugPlugin.log(bse); >+ } >+ } >+ else { >+ contexts[INSTANCE_CONTEXT].getNode(qualifier).putFloat(key, value); >+ } >+ } >+ >+ /** >+ * Sets a string in the {@link DefaultScope} >+ * @param qualifier >+ * @param key the key >+ * @param value the new value >+ */ >+ public static synchronized void setDefaultString(String qualifier, String key, String value) { >+ contexts[DEFAULT_CONTEXT].getNode(qualifier).put(key, value); >+ } >+ >+ /** >+ * Sets a boolean in the {@link DefaultScope} >+ * @param qualifier >+ * @param key the key >+ * @param value the new value >+ */ >+ public static synchronized void setDefaultBoolean(String qualifier, String key, boolean value) { >+ contexts[DEFAULT_CONTEXT].getNode(qualifier).putBoolean(key, value); >+ } >+ >+ /** >+ * Sets a byte array in the {@link DefaultScope} >+ * @param qualifier >+ * @param key the key >+ * @param value the new value >+ */ >+ public static synchronized void setDefaultByteArray(String qualifier, String key, byte[] value) { >+ contexts[DEFAULT_CONTEXT].getNode(qualifier).putByteArray(key, value); >+ } >+ >+ /** >+ * Sets a double in the {@link DefaultScope} >+ * @param qualifier >+ * @param key the key >+ * @param value the new value >+ */ >+ public static synchronized void setDefaultDouble(String qualifier, String key, double value) { >+ contexts[DEFAULT_CONTEXT].getNode(qualifier).putDouble(key, value); >+ } >+ >+ /** >+ * Sets a float in the {@link DefaultScope} >+ * @param qualifier >+ * @param key the key >+ * @param value the new value >+ */ >+ public static synchronized void setDefaultFloat(String qualifier, String key, float value) { >+ contexts[DEFAULT_CONTEXT].getNode(qualifier).putFloat(key, value); >+ } >+ >+ /** >+ * Sets a integer in the {@link DefaultScope} >+ * @param qualifier >+ * @param key the key >+ * @param value the new value >+ */ >+ public static synchronized void setDefaultInt(String qualifier, String key, int value) { >+ contexts[DEFAULT_CONTEXT].getNode(qualifier).putInt(key, value); >+ } >+ >+ /** >+ * Sets a long in the {@link DefaultScope} >+ * @param qualifier >+ * @param key the key >+ * @param value the new value >+ */ >+ public static synchronized void setDefaultLong(String qualifier, String key, long value) { >+ contexts[DEFAULT_CONTEXT].getNode(qualifier).putLong(key, value); >+ } >+ >+ /** >+ * Sets the given preference to its default value. This is done by removing any set value >+ * from the {@link InstanceScope}. Has no effect if the given key is <code>null</code>. >+ * @param qualifier >+ * @param key the key for the preference >+ */ >+ public static synchronized void setToDefault(String qualifier, String key) { >+ if(key != null) { >+ contexts[INSTANCE_CONTEXT].getNode(qualifier).remove(key); >+ } >+ } >+ >+ /** >+ * Returns the default boolean value stored in the {@link DefaultScope} for the given key >+ * or the specified default value if the key does not appear in the {@link DefaultScope} >+ * @param qualifier >+ * @param key >+ * @param defaultvalue >+ * >+ * @return the boolean value set in the {@link DefaultScope} for the given key, or the specified default value. >+ */ >+ public static synchronized boolean getDefaultBoolean(String qualifier, String key, boolean defaultvalue) { >+ return contexts[DEFAULT_CONTEXT].getNode(qualifier).getBoolean(key, defaultvalue); >+ } >+ >+ /** >+ * Returns the default string value stored in the {@link DefaultScope} for the given key >+ * or the specified default value if the key does not appear in the {@link DefaultScope} >+ * @param qualifier >+ * @param key >+ * @param defaultvalue >+ * >+ * @return the string value set in the {@link DefaultScope} for the given key, or the specified default value. >+ */ >+ public static synchronized String getDefaultString(String qualifier, String key, String defaultvalue) { >+ return contexts[DEFAULT_CONTEXT].getNode(qualifier).get(key, defaultvalue); >+ } >+ >+ /** >+ * Returns the default byte array value stored in the {@link DefaultScope} for the given key >+ * or the specified default value if the key does not appear in the {@link DefaultScope} >+ * @param qualifier >+ * @param key >+ * @param defaultvalue >+ * >+ * @return the byte array value set in the {@link DefaultScope} for the given key, or the specified default value. >+ */ >+ public static synchronized byte[] getDefaultByteArray(String qualifier, String key, byte[] defaultvalue) { >+ return contexts[DEFAULT_CONTEXT].getNode(qualifier).getByteArray(key, defaultvalue); >+ } >+ >+ /** >+ * Returns the default integer value stored in the {@link DefaultScope} for the given key >+ * or the specified default value if the key does not appear in the {@link DefaultScope} >+ * @param qualifier >+ * @param key >+ * @param defaultvalue >+ * >+ * @return the integer value set in the {@link DefaultScope} for the given key, or the specified default value. >+ */ >+ public static synchronized int getDefaultInt(String qualifier, String key, int defaultvalue) { >+ return contexts[DEFAULT_CONTEXT].getNode(qualifier).getInt(key, defaultvalue); >+ } >+ >+ /** >+ * Returns the default long value stored in the {@link DefaultScope} for the given key >+ * or the specified default value if the key does not appear in the {@link DefaultScope} >+ * @param qualifier >+ * @param key >+ * @param defaultvalue >+ * >+ * @return the long value set in the {@link DefaultScope} for the given key, or the specified default value. >+ */ >+ public static synchronized long getDefaultLong(String qualifier, String key, long defaultvalue) { >+ return contexts[DEFAULT_CONTEXT].getNode(qualifier).getLong(key, defaultvalue); >+ } >+ >+ /** >+ * Returns the default double value stored in the {@link DefaultScope} for the given key >+ * or the specified default value if the key does not appear in the {@link DefaultScope} >+ * @param qualifier >+ * @param key >+ * @param defaultvalue >+ * >+ * @return the double value set in the {@link DefaultScope} for the given key, or the specified default value. >+ */ >+ public static synchronized double getDefaultDouble(String qualifier, String key, double defaultvalue) { >+ return contexts[DEFAULT_CONTEXT].getNode(qualifier).getDouble(key, defaultvalue); >+ } >+ >+ /** >+ * Returns the default float value stored in the {@link DefaultScope} for the given key >+ * or the specified default value if the key does not appear in the {@link DefaultScope} >+ * @param qualifier >+ * @param key >+ * @param defaultvalue >+ * >+ * @return the float value set in the {@link DefaultScope} for the given key, or the specified default value. >+ */ >+ public static synchronized float getDefaultFloat(String qualifier, String key, float defaultvalue) { >+ return contexts[DEFAULT_CONTEXT].getNode(qualifier).getFloat(key, defaultvalue); >+ } >+ >+ /** >+ * Save the preferences for the given plugin identifier. >+ * It should be noted that all pending preference changes will be flushed with this method. >+ * @param qualifier >+ */ >+ public static synchronized void savePreferences(String qualifier) { >+ try { >+ contexts[DEFAULT_CONTEXT].getNode(qualifier).flush(); >+ contexts[INSTANCE_CONTEXT].getNode(qualifier).flush(); >+ } >+ catch(BackingStoreException bse) { >+ DebugPlugin.log(bse); >+ } >+ } >+ >+ /** >+ * Adds the given preference listener to the {@link DefaultScope} and the {@link InstanceScope} >+ * @param qualifier >+ * @param listener >+ */ >+ public static void addPreferenceListener(String qualifier, IEclipsePreferences.IPreferenceChangeListener listener) { >+ contexts[DEFAULT_CONTEXT].getNode(qualifier).addPreferenceChangeListener(listener); >+ contexts[INSTANCE_CONTEXT].getNode(qualifier).addPreferenceChangeListener(listener); >+ } >+ >+ /** >+ * Removes the given preference listener from the {@link DefaultScope} and the {@link InstanceScope} >+ * @param qualifier >+ * @param listener >+ */ >+ public static void removePreferenceListener(String qualifier, IEclipsePreferences.IPreferenceChangeListener listener) { >+ contexts[DEFAULT_CONTEXT].getNode(qualifier).removePreferenceChangeListener(listener); >+ contexts[INSTANCE_CONTEXT].getNode(qualifier).removePreferenceChangeListener(listener); >+ } >+} >Index: core/org/eclipse/debug/internal/core/LaunchManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java,v >retrieving revision 1.223 >diff -u -r1.223 LaunchManager.java >--- core/org/eclipse/debug/internal/core/LaunchManager.java 2 Sep 2009 15:43:12 -0000 1.223 >+++ core/org/eclipse/debug/internal/core/LaunchManager.java 25 Sep 2009 16:23:11 -0000 >@@ -2596,5 +2596,153 @@ > } > } > return fActiveModes.contains(mode); >+ } >+ >+ /** >+ * Returns whether the given configuration should be launched in the background. >+ * >+ * @param configuration the configuration >+ * @return whether the configuration is configured to launch in the background >+ */ >+ public static boolean isLaunchInBackground(ILaunchConfiguration configuration) { >+ boolean launchInBackground= true; >+ try { >+ launchInBackground= configuration.getAttribute(ILaunchManager.ATTR_LAUNCH_IN_BACKGROUND, true); >+ } catch (CoreException ce) { >+ DebugPlugin.log(ce); >+ } >+ return launchInBackground; > } >+ >+ /** >+ * Returns the refresh scope attribute specified by the given launch configuration >+ * or <code>null</code> if none. >+ * >+ * @param configuration launch configuration >+ * @return refresh scope attribute (<code>ATTR_REFRESH_SCOPE</code>) >+ * @throws CoreException if unable to access the associated attribute >+ */ >+ public static String getRefreshScope(ILaunchConfiguration configuration) throws CoreException { >+ return configuration.getAttribute(ATTR_REFRESH_SCOPE, (String) null); >+ } >+ >+ >+ /** >+ * Refreshes the resources as specified by the given launch configuration. >+ * >+ * @param configuration launch configuration >+ * @param monitor progress monitor which may be <code>null</code> >+ * @throws CoreException if an exception occurs while refreshing resources >+ */ >+ public static void refreshResources(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { >+ if (monitor == null) { >+ monitor = new NullProgressMonitor(); >+ } >+ String scope = getRefreshScope(configuration); >+ IResource[] resources= null; >+ if (scope != null) { >+ resources = getRefreshResources(scope); >+ } >+ if (resources == null || resources.length == 0){ >+ return; >+ } >+ int depth = IResource.DEPTH_ONE; >+ if (isRefreshRecursive(configuration)) >+ depth = IResource.DEPTH_INFINITE; >+ >+ if (monitor.isCanceled()) { >+ return; >+ } >+ >+ monitor.beginTask(DebugCoreMessages.RefreshingResources, >+ resources.length); >+ >+ MultiStatus status = new MultiStatus(DebugPlugin.getUniqueIdentifier(), 0, DebugCoreMessages.RefreshingResourcesError, null); >+ for (int i = 0; i < resources.length; i++) { >+ if (monitor.isCanceled()) >+ break; >+ if (resources[i] != null && resources[i].isAccessible()) { >+ try { >+ resources[i].refreshLocal(depth, null); >+ } catch (CoreException e) { >+ status.merge(e.getStatus()); >+ } >+ } >+ monitor.worked(1); >+ } >+ >+ monitor.done(); >+ if (!status.isOK()) { >+ throw new CoreException(status); >+ } >+ } >+ >+ /** >+ * Returns a collection of resources referred to by a refresh scope attribute. >+ * >+ * @param scope refresh scope attribute (<code>ATTR_REFRESH_SCOPE</code>) >+ * @return collection of resources referred to by the refresh scope attribute >+ * @throws CoreException if unable to resolve a set of resources >+ */ >+ public static IResource[] getRefreshResources(String scope) throws CoreException { >+// if (scope.startsWith("${resource:")) { //$NON-NLS-1$ >+// // This is an old format that is replaced with 'working_set' >+// String pathString = scope.substring(11, scope.length() - 1); >+// Path path = new Path(pathString); >+// IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path); >+// if (resource == null) { >+// throw new CoreException(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, MessageFormat.format(StringSubstitutionMessages.RefreshTab_43, new String[]{pathString}), null)); >+// } >+// return new IResource[]{resource}; >+// } else if (scope.startsWith("${working_set:")) { //$NON-NLS-1$ >+// IWorkingSet workingSet = getWorkingSet(scope); >+// if (workingSet == null) { >+// throw new CoreException(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, StringSubstitutionMessages.RefreshTab_44, null)); >+// } >+// IAdaptable[] elements = workingSet.getElements(); >+// IResource[] resources = new IResource[elements.length]; >+// for (int i = 0; i < elements.length; i++) { >+// IAdaptable adaptable = elements[i]; >+// if (adaptable instanceof IResource) { >+// resources[i] = (IResource) adaptable; >+// } else { >+// resources[i] = (IResource) adaptable.getAdapter(IResource.class); >+// } >+// } >+// return resources; >+// } else if(scope.equals("${workspace}")) { //$NON-NLS-1$ >+// return new IResource[]{ResourcesPlugin.getWorkspace().getRoot()}; >+// } else { >+// IResource resource = SelectedResourceManager.getDefault().getSelectedResource(); >+// if (resource == null) { >+// // empty selection >+// return new IResource[]{}; >+// } >+// if (scope.equals("${resource}")) { //$NON-NLS-1$ >+// // resource = resource >+// } else if (scope.equals("${container}")) { //$NON-NLS-1$ >+// resource = resource.getParent(); >+// } else if (scope.equals("${project}")) { //$NON-NLS-1$ >+// resource = resource.getProject(); >+// } >+// return new IResource[]{resource}; >+// } >+ return null; >+ } >+ >+ /** >+ * Returns whether the refresh scope specified by the given launch >+ * configuration is recursive. >+ * >+ * @param configuration >+ * @return whether the refresh scope is recursive >+ * @throws CoreException if unable to access the associated attribute >+ */ >+ public static boolean isRefreshRecursive(ILaunchConfiguration configuration) throws CoreException { >+ return configuration.getAttribute(ATTR_REFRESH_RECURSIVE, true); >+ } >+ >+ >+ >+ > } >Index: core/org/eclipse/debug/internal/core/DebugCoreMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties,v >retrieving revision 1.90 >diff -u -r1.90 DebugCoreMessages.properties >--- core/org/eclipse/debug/internal/core/DebugCoreMessages.properties 20 Apr 2009 15:38:03 -0000 1.90 >+++ core/org/eclipse/debug/internal/core/DebugCoreMessages.properties 25 Sep 2009 16:23:09 -0000 >@@ -98,3 +98,5 @@ > LaunchConfigurationType_7=Launch mode not supported: {0} > WatchExpression_0=(Watch expressions not supported) > NullStreamsProxy_0=Null Stream Monitor >+RefreshingResources=Refresh resources... >+RefreshingResourcesError=Exception(s) occurred during refresh. >Index: core/org/eclipse/debug/core/ILaunchManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java,v >retrieving revision 1.75 >diff -u -r1.75 ILaunchManager.java >--- core/org/eclipse/debug/core/ILaunchManager.java 18 Nov 2008 21:51:10 -0000 1.75 >+++ core/org/eclipse/debug/core/ILaunchManager.java 25 Sep 2009 16:23:09 -0000 >@@ -46,6 +46,38 @@ > public static final String PROFILE_MODE= "profile"; //$NON-NLS-1$ > > /** >+ * Launch configuration attribute - a boolean value indicating whether a >+ * configuration should be launched in the background. Default value is <code>true</code>. >+ * >+ * @since 3.0 >+ */ >+ public static final String ATTR_LAUNCH_IN_BACKGROUND = DebugPlugin.getUniqueIdentifier() + ".ATTR_LAUNCH_IN_BACKGROUND"; //$NON-NLS-1$ >+ >+ >+ /** >+ * String attribute identifying the scope of resources that should be >+ * refreshed after an external tool is run. The value is either a refresh >+ * variable or the default value, <code>null</code>, indicating no refresh. >+ */ >+ public static final String ATTR_REFRESH_SCOPE = DebugPlugin.getUniqueIdentifier() + ".ATTR_REFRESH_SCOPE"; //$NON-NLS-1$ >+ >+ >+ /** >+ * Boolean attribute indicating if a refresh scope is recursive. Default >+ * value is <code>false</code>. >+ */ >+ public static final String ATTR_REFRESH_RECURSIVE = DebugPlugin.getUniqueIdentifier() + ".ATTR_REFRESH_RECURSIVE"; //$NON-NLS-1$ >+ >+ /** >+ * Launch configuration attribute - a boolean value that indicates if the launch configuration >+ * is 'private'. A private configuration is one that does not appear to the user in the launch >+ * history or the launch configuration dialog. >+ * >+ * @since 2.0 >+ */ >+ public static final String ATTR_PRIVATE = DebugPlugin.getUniqueIdentifier() + ".private"; //$NON-NLS-1$ >+ >+ /** > * Launch configuration attribute name. The value is a map of environment > * variables passed into Runtime.exec(...) when a launch configuration is launched. > * Default value is <code>null</code> which indicates the default environment >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.core/META-INF/MANIFEST.MF,v >retrieving revision 1.22 >diff -u -r1.22 MANIFEST.MF >--- META-INF/MANIFEST.MF 10 Sep 2009 04:29:54 -0000 1.22 >+++ META-INF/MANIFEST.MF 25 Sep 2009 16:23:09 -0000 >@@ -12,7 +12,7 @@ > org.eclipse.debug.core.model, > org.eclipse.debug.core.sourcelookup, > org.eclipse.debug.core.sourcelookup.containers, >- org.eclipse.debug.internal.core;x-friends:="org.eclipse.debug.ui", >+ org.eclipse.debug.internal.core;x-friends:="org.eclipse.debug.ui,org.eclipse.ant.launching,org.eclipse.core.externaltools", > org.eclipse.debug.internal.core.commands;x-friends:="org.eclipse.debug.ui", > org.eclipse.debug.internal.core.sourcelookup;x-friends:="org.eclipse.debug.ui", > org.eclipse.debug.internal.core.sourcelookup.containers;x-friends:="org.eclipse.debug.ui", >#P org.eclipse.ant.launching >Index: src/org/eclipse/ant/internal/launching/AntLaunching.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/AntLaunching.java,v >retrieving revision 1.2 >diff -u -r1.2 AntLaunching.java >--- src/org/eclipse/ant/internal/launching/AntLaunching.java 16 Sep 2009 14:39:43 -0000 1.2 >+++ src/org/eclipse/ant/internal/launching/AntLaunching.java 25 Sep 2009 16:23:20 -0000 >@@ -10,7 +10,10 @@ > *******************************************************************************/ > package org.eclipse.ant.internal.launching; > >+import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Plugin; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jface.preference.PreferenceStore; > import org.osgi.framework.BundleContext; > > /** >@@ -20,10 +23,20 @@ > > // The plug-in ID > public static final String PLUGIN_ID = "org.eclipse.ant.launching"; //$NON-NLS-1$ >+ >+ private static final String EMPTY_STRING= ""; //$NON-NLS-1$ >+ >+ /** >+ * Status code indicating an unexpected internal error. >+ * @since 2.1 >+ */ >+ public static final int INTERNAL_ERROR = 120; > > // The shared instance > private static AntLaunching plugin; > >+ private static PreferenceStore preferenceStore; >+ > /** > * The constructor > */ >@@ -56,5 +69,52 @@ > public static AntLaunching getDefault() { > return plugin; > } >+ >+ public static String getUniqueIdentifier() { >+ return PLUGIN_ID; >+ } >+ >+ /** >+ * Logs the specified throwable with this plug-in's log. >+ * >+ * @param t throwable to log >+ */ >+ public static void log(Throwable t) { >+ IStatus status= new Status(IStatus.ERROR, PLUGIN_ID, INTERNAL_ERROR, "Error logged from Ant UI: ", t); //$NON-NLS-1$ >+ log(status); >+ } >+ >+ /** >+ * Logs the specified status with this plug-in's log. >+ * >+ * @param status status >+ */ >+ public static void log(IStatus status) { >+ getDefault().getLog().log(status); >+ } >+ >+ /** >+ * Writes the message to the plug-in's log >+ * >+ * @param message the text to write to the log >+ */ >+ public static void log(String message, Throwable exception) { >+ IStatus status = newErrorStatus(message, exception); >+ log(status); >+ } >+ >+ /** >+ * Returns a new <code>IStatus</code> for this plug-in >+ */ >+ public static IStatus newErrorStatus(String message, Throwable exception) { >+ if (message == null) { >+ message= EMPTY_STRING; >+ } >+ return new Status(IStatus.ERROR, PLUGIN_ID, 0, message, exception); >+ } >+ >+ public static AntLaunching getPlugin() { >+ return plugin; >+ } > > } >Index: .settings/org.eclipse.jdt.core.prefs >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.launching/.settings/org.eclipse.jdt.core.prefs,v >retrieving revision 1.2 >diff -u -r1.2 org.eclipse.jdt.core.prefs >--- .settings/org.eclipse.jdt.core.prefs 16 Sep 2009 14:44:24 -0000 1.2 >+++ .settings/org.eclipse.jdt.core.prefs 25 Sep 2009 16:23:20 -0000 >@@ -1,6 +1,6 @@ >-#Wed Sep 16 09:44:05 CDT 2009 >+#Sun Sep 20 13:08:07 CEST 2009 > eclipse.preferences.version=1 >-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled >+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled > org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 > org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve > org.eclipse.jdt.core.compiler.compliance=1.4 >Index: build.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.launching/build.properties,v >retrieving revision 1.1 >diff -u -r1.1 build.properties >--- build.properties 16 Sep 2009 14:34:09 -0000 1.1 >+++ build.properties 25 Sep 2009 16:23:20 -0000 >@@ -1,4 +1,6 @@ > source.. = src/ > output.. = bin/ > bin.includes = META-INF/,\ >- . >+ .,\ >+ plugin.xml,\ >+ plugin.properties >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.launching/plugin.properties,v >retrieving revision 1.1 >diff -u -r1.1 plugin.properties >--- plugin.properties 16 Sep 2009 14:34:09 -0000 1.1 >+++ plugin.properties 25 Sep 2009 16:23:20 -0000 >@@ -10,4 +10,18 @@ > ############################################################################### > > pluginName=Ant Launching Support >-providerName=Eclipse.org >\ No newline at end of file >+providerName=Eclipse.org >+ >+AntBuild=Ant Build >+AntBuilder.name=Ant Builder >+AntLaunchShortcut.label=Ant Build >+AntLaunchShortcutWithDialog.label=Ant Build... >+antLaunchConfigurationTabGroup.description=Run an Ant build file. >+antBuilderLaunchConfigurationTabGroup.description=Create a configuration that will run an Ant build file during a build. >+ >+AntLaunchDelegate.name=Eclipse Ant Launcher >+AntLaunchDelegate.description=The Eclipse Ant Launcher supports running and debugging Ant build files. >+AntBuilderLaunchDelegate.name= Eclipse Ant Builder Launcher >+AntBuilderLaunchDelegate.description=The Eclipse Ant Builder Launcher supports running Ant build files. >+AntBuild...Shortcut.description=Launches an Ant build and allows it to be configured >+AntBuildShortcut.description=Launches an Ant build with default settings >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.launching/META-INF/MANIFEST.MF,v >retrieving revision 1.2 >diff -u -r1.2 MANIFEST.MF >--- META-INF/MANIFEST.MF 16 Sep 2009 14:48:25 -0000 1.2 >+++ META-INF/MANIFEST.MF 25 Sep 2009 16:23:20 -0000 >@@ -1,16 +1,25 @@ > Manifest-Version: 1.0 > Bundle-ManifestVersion: 2 > Bundle-Name: %pluginName >-Bundle-SymbolicName: org.eclipse.ant.launching >+Bundle-SymbolicName: org.eclipse.ant.launching;singleton:=true > Bundle-Version: 1.0.0.qualifier > Bundle-Activator: org.eclipse.ant.internal.launching.AntLaunching > Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)", >- org.eclipse.debug.core;bundle-version="[3.6.0,4.0.0)", >+ org.eclipse.debug.core;bundle-version="[3.5.0,4.0.0)", > org.eclipse.jdt.launching;bundle-version="[3.5.0,4.0.0)", > org.eclipse.core.variables;bundle-version="[3.2.0,4.0.0)", > org.eclipse.ant.core;bundle-version="[3.2.0,4.0.0)", >- org.apache.ant;bundle-version="1.7.1" >+ org.apache.ant;bundle-version="1.7.1", >+ org.eclipse.jdt.core;bundle-version="3.5.0", >+ org.eclipse.core.commands;bundle-version="3.5.0", >+ org.eclipse.core.externaltools;bundle-version="1.0.0" > Bundle-RequiredExecutionEnvironment: J2SE-1.4 > Bundle-ActivationPolicy: lazy > Bundle-Vendor: %providerName >-Export-Package: org.eclipse.ant.internal.launching;x-internal:=true >+Export-Package: org.eclipse.ant.internal.launching;x-friends:="org.eclipse.ant.ui,org.eclipse.ant.core", >+ org.eclipse.ant.internal.launching.launchConfigurations;x-friends:="org.eclipse.ant.ui" >+Import-Package: com.ibm.icu.text, >+ org.eclipse.ant.internal.launching.launchConfigurations, >+ org.eclipse.core.filebuffers, >+ org.eclipse.jface.preference, >+ org.eclipse.jface.text >Index: src/org/eclipse/ant/internal/launching/debug/model/AntProperties.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/model/AntProperties.java >diff -N src/org/eclipse/ant/internal/launching/debug/model/AntProperties.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/model/AntProperties.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,109 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.debug.model; >+ >+import org.eclipse.debug.core.DebugException; >+import org.eclipse.debug.core.model.IValue; >+import org.eclipse.debug.core.model.IVariable; >+ >+public class AntProperties extends AntDebugElement implements IVariable { >+ >+ private IValue fValue; >+ private String fName; >+ private boolean fValid= true; >+ >+ public AntProperties(AntDebugTarget target, String name) { >+ super(target); >+ fName= name; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IVariable#getValue() >+ */ >+ public synchronized IValue getValue() throws DebugException { >+ int attempts= 0; >+ while (!fValid && !getDebugTarget().isTerminated()) { >+ try { >+ wait(50); >+ } catch (InterruptedException e) { >+ } >+ if (attempts == 20 && !fValid && !getDebugTarget().isTerminated()) { >+ throwDebugException(DebugModelMessages.AntProperties_1); >+ } >+ attempts++; >+ } >+ return fValue; >+ } >+ >+ protected IValue getLastValue() { >+ return fValue; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IVariable#getName() >+ */ >+ public String getName() { >+ return fName; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName() >+ */ >+ public String getReferenceTypeName() { >+ return ""; //$NON-NLS-1$ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IVariable#hasValueChanged() >+ */ >+ public boolean hasValueChanged() { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String) >+ */ >+ public void setValue(String expression) { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue) >+ */ >+ public void setValue(IValue value) { >+ fValue= value; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IValueModification#supportsValueModification() >+ */ >+ public boolean supportsValueModification() { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String) >+ */ >+ public boolean verifyValue(String expression) { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IValueModification#verifyValue(org.eclipse.debug.core.model.IValue) >+ */ >+ public boolean verifyValue(IValue value) { >+ return false; >+ } >+ >+ protected synchronized void setValid(boolean valid) { >+ fValid= valid; >+ notifyAll(); >+ } >+} >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/IAntLaunchConfigurationConstants.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/IAntLaunchConfigurationConstants.java >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/IAntLaunchConfigurationConstants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/IAntLaunchConfigurationConstants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,152 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.ant.internal.launching.launchConfigurations; >+ >+ >+import org.eclipse.core.internal.externaltools.model.IExternalToolConstants; >+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+ >+ >+ >+/** >+ * Constant definitions for Ant launch configurations. >+ * >+ * @since 3.4 >+ * @noimplement This interface is not intended to be implemented by clients. >+ */ >+public interface IAntLaunchConfigurationConstants { >+ >+ public static final String PLUGIN_ID = "org.eclipse.ant.launching"; //$NON-NLS-1$ >+ >+ /** >+ * String attribute indicating the custom runtime classpath to use for an Ant >+ * build. Default value is <code>null</code> which indicates that the global >+ * classpath is to be used. Format is a comma separated listing of URLs. >+ * @deprecated no longer supported: use {@link IJavaLaunchConfigurationConstants#ATTR_CLASSPATH_PROVIDER} >+ * @see IJavaLaunchConfigurationConstants#ATTR_DEFAULT_CLASSPATH >+ */ >+ public static final String ATTR_ANT_CUSTOM_CLASSPATH = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_CUSTOM_CLASSPATH"; //$NON-NLS-1$ >+ /** >+ * String attribute indicating the custom Ant home to use for an Ant build. >+ * Default value is <code>null</code> which indicates that no Ant home is to >+ * be set >+ * @deprecated no longer supported: use {@link IJavaLaunchConfigurationConstants#ATTR_CLASSPATH_PROVIDER} >+ * @see IJavaLaunchConfigurationConstants#ATTR_DEFAULT_CLASSPATH >+ */ >+ public static final String ATTR_ANT_HOME = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_HOME"; //$NON-NLS-1$ >+ >+ /** >+ * Ant launch configuration type identifier. >+ */ >+ public static final String ID_ANT_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ant.AntLaunchConfigurationType"; //$NON-NLS-1$ >+ >+ /** >+ * Ant builder launch configuration type identifier. Ant project builders >+ * are of this type. >+ */ >+ public static final String ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ant.AntBuilderLaunchConfigurationType"; //$NON-NLS-1$ >+ >+ /** >+ * String attribute indicating the Ant targets to execute. Default value is >+ * <code>null</code> which indicates that the default target is to be >+ * executed. Format is a comma separated listing of targets. >+ */ >+ public static final String ATTR_ANT_TARGETS = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_TARGETS"; //$NON-NLS-1$ >+ >+ /** >+ * String attribute indicating the Ant targets to execute after a clean (full build) for an Ant builder. Default value is >+ * <code>null</code> which indicates that the default target is to be >+ * executed. Format is a comma separated listing of targets. >+ */ >+ public static final String ATTR_ANT_AFTER_CLEAN_TARGETS = PLUGIN_ID + ".ATTR_ANT_AFTER_CLEAN_TARGETS"; //$NON-NLS-1$ >+ >+ /** >+ * String attribute indicating the Ant targets to execute during a manual build for an Ant builder. Default value is >+ * <code>null</code> which indicates that the default target is to be >+ * executed. Format is a comma separated listing of targets. >+ */ >+ public static final String ATTR_ANT_MANUAL_TARGETS = PLUGIN_ID + ".ATTR_ANT_MANUAL_TARGETS"; //$NON-NLS-1$ >+ >+ /** >+ * String attribute indicating the Ant targets to execute during an auto build for an Ant builder. Default value is >+ * <code>null</code> which indicates that the default target is to be >+ * executed. Format is a comma separated listing of targets. >+ */ >+ public static final String ATTR_ANT_AUTO_TARGETS = PLUGIN_ID + ".ATTR_ANT_AUTO_TARGETS"; //$NON-NLS-1$ >+ >+ /** >+ * String attribute indicating the Ant targets to execute during a clean for an Ant builder. Default value is >+ * <code>null</code> which indicates that the default target is to be >+ * executed. Format is a comma separated listing of targets. >+ */ >+ public static final String ATTR_ANT_CLEAN_TARGETS = PLUGIN_ID + ".ATTR_ANT_CLEAN_TARGETS"; //$NON-NLS-1$ >+ >+ /** >+ * Boolean attribute indicating whether or not target specification for an Ant builder >+ * has been updated for 3.1 >+ */ >+ public static final String ATTR_TARGETS_UPDATED = PLUGIN_ID + ".ATTR_TARGETS_UPDATED"; //$NON-NLS-1$ >+ >+ /** >+ * Map attribute indicating the Ant properties to be defined during the >+ * build. Default value is <code>null</code> which indicates no additional >+ * properties will be defined. >+ */ >+ public static final String ATTR_ANT_PROPERTIES = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_PROPERTIES"; //$NON-NLS-1$ >+ >+ /** >+ * String attribute indicating the Ant targets to execute. Default value is >+ * <code>null</code> which indicates that no additional property files >+ * will be defined. Format is a comma separated listing of property files. >+ */ >+ public static final String ATTR_ANT_PROPERTY_FILES = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_PROPERTY_FILES"; //$NON-NLS-1$ >+ >+ /** >+ * Boolean attribute indicating whether or not internal targets (targets with no >+ * description) should be hidden from the user in the launch configuration dialog. >+ * Default value is <code>false</code> which indicates that all targets will be >+ * displayed. >+ */ >+ public static final String ATTR_HIDE_INTERNAL_TARGETS = IExternalToolConstants.PLUGIN_ID + ".ATTR_HIDE_INTERNAL_TARGETS"; //$NON-NLS-1$ >+ >+ /** >+ * Integer attribute indicating which column targets should be sorted on. A >+ * value of 0 indicates target name, 1 indicates target description, and -1 >+ * indicates no sort. Default value is -1. >+ */ >+ public static final String ATTR_SORT_TARGETS = IExternalToolConstants.PLUGIN_ID + "ATTR_SORT_TARGETS"; //$NON-NLS-1$ >+ >+ /** >+ * Boolean attribute indicating if the default VM install should be used for the separate JRE build >+ * Default value is <code>false</code> for backwards compatibility >+ */ >+ public static final String ATTR_DEFAULT_VM_INSTALL = PLUGIN_ID + ".DEFAULT_VM_INSTALL"; //$NON-NLS-1$ >+ >+ /** >+ * Identifier for Ant processes (value <code>org.eclipse.ant.ui.antProcess</code>). This identifier is >+ * set as the value for the <code>IProcess.ATTR_PROCESS_TYPE</code> >+ * attribute in processes created by the Ant launch delegate. >+ */ >+ public static final String ID_ANT_PROCESS_TYPE = "org.eclipse.ant.ui.antProcess"; //$NON-NLS-1$ >+ >+ /** >+ * Boolean attribute indicating if an input handler should be supplied for the build >+ * Default value is <code>true</code>. >+ */ >+ public static final String SET_INPUTHANDLER= PLUGIN_ID + "SET_INPUTHANDLER"; //$NON-NLS-1$ >+ >+ /** >+ * int preference identifier constant which specifies the length of time to wait >+ * to connect with the socket that communicates with the separate JRE to capture the output >+ */ >+ public static final String ANT_COMMUNICATION_TIMEOUT= "timeout"; //$NON-NLS-1$ >+} >Index: src/org/eclipse/ant/internal/launching/debug/AntSourceContainer.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/AntSourceContainer.java >diff -N src/org/eclipse/ant/internal/launching/debug/AntSourceContainer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/AntSourceContainer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,73 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.ant.internal.launching.debug; >+ >+import java.io.File; >+import java.io.IOException; >+import java.util.ArrayList; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.debug.core.sourcelookup.ISourceContainerType; >+import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainer; >+import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage; >+ >+public class AntSourceContainer extends AbstractSourceContainer { >+ >+ private IWorkspaceRoot fRoot; >+ >+ public AntSourceContainer() { >+ fRoot = ResourcesPlugin.getWorkspace().getRoot(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#findSourceElements(java.lang.String) >+ */ >+ public Object[] findSourceElements(String path) throws CoreException { >+ ArrayList sources = new ArrayList(); >+ File osFile = new File(path); >+ if (osFile.exists()) { >+ try { >+ IPath canonicalPath = new Path(osFile.getCanonicalPath()); >+ IFile[] files = fRoot.findFilesForLocation(canonicalPath); >+ if (files.length > 0) { >+ for (int i = 0; i < files.length; i++) { >+ sources.add(files[i]); >+ } >+ } else { >+ sources.add(new LocalFileStorage(osFile)); >+ } >+ } catch (IOException e) { >+ } >+ } >+ return sources.toArray(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getName() >+ */ >+ public String getName() { >+ return AntDebugMessages.AntSourceContainer_0; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getType() >+ * Not persisted via the launch configuration >+ */ >+ public ISourceContainerType getType() { >+ return null; >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,245 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.launchConfigurations; >+ >+import java.io.File; >+import java.io.FilenameFilter; >+import java.io.IOException; >+import java.net.MalformedURLException; >+import java.net.URL; >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.ant.core.AntCorePlugin; >+import org.eclipse.ant.core.AntCorePreferences; >+import org.eclipse.ant.core.IAntClasspathEntry; >+import org.eclipse.ant.internal.launching.AntLaunching; >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.FileLocator; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry; >+import org.eclipse.jdt.launching.IRuntimeClasspathEntry; >+import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.JavaRuntime; >+import org.eclipse.osgi.service.resolver.BundleDescription; >+import org.osgi.framework.Bundle; >+import org.w3c.dom.Document; >+import org.w3c.dom.Element; >+ >+/** >+ * A classpath entry that contains a contributed classpath entries >+ * via the <code>extraClasspathEntries</code> extension point. >+ * >+ * @since 3.0 >+ */ >+public class ContributedClasspathEntriesEntry extends AbstractRuntimeClasspathEntry { >+ >+ public static final String TYPE_ID = "org.eclipse.ant.ui.classpathentry.extraClasspathEntries"; //$NON-NLS-1$ >+ >+ public static List fgSWTEntries= null; >+ >+ /** >+ * Default contructor required to instantiate persisted extensions. >+ */ >+ public ContributedClasspathEntriesEntry() { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element) >+ */ >+ protected void buildMemento(Document document, Element memento) throws CoreException { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element) >+ */ >+ public void initializeFrom(Element memento) throws CoreException { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId() >+ */ >+ public String getTypeId() { >+ return TYPE_ID; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration) >+ */ >+ public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException { >+ boolean separateVM= AntLaunchingUtil.isSeparateJREAntBuild(configuration); >+ boolean setInputHandler= configuration.getAttribute(IAntLaunchConfigurationConstants.SET_INPUTHANDLER, true); >+ AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences(); >+ IAntClasspathEntry[] antClasspathEntries = prefs.getContributedClasspathEntries(); >+ IAntClasspathEntry[] userEntries = prefs.getAdditionalClasspathEntries(); >+ List rtes = new ArrayList(antClasspathEntries.length + userEntries.length); >+ IAntClasspathEntry entry; >+ for (int i = 0; i < antClasspathEntries.length; i++) { >+ entry= antClasspathEntries[i]; >+ if (!separateVM || (separateVM && !entry.isEclipseRuntimeRequired())) { >+ rtes.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel())); >+ } >+ } >+ boolean haveToolsEntry= false; >+ String path; >+ for (int i = 0; i < userEntries.length; i++) { >+ entry = userEntries[i]; >+ path= entry.getLabel(); >+ IPath toolsPath= new Path(path); >+ if (toolsPath.lastSegment().equals("tools.jar")) { //$NON-NLS-1$ >+ haveToolsEntry= true; >+ // replace with dynamically resolved tools.jar based on >+ // the JRE being used >+ addToolsJar(configuration, rtes, path); >+ } else { >+ rtes.add(JavaRuntime.newStringVariableClasspathEntry(path)); >+ } >+ } >+ if (!haveToolsEntry) { >+ addToolsJar(configuration, rtes, null); >+ } >+ >+ if (setInputHandler && separateVM) { >+ addSWTJars(rtes); >+ } >+ >+ return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]); >+ } >+ >+ private void addToolsJar(ILaunchConfiguration configuration, List rtes, String path) { >+ IRuntimeClasspathEntry tools = getToolsJar(configuration); >+ if (tools == null) { >+ if (path != null) { >+ //use the global entry >+ rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(path))); >+ } else { >+ //use the default vm install to try to find a tools.jar >+ IVMInstall install= JavaRuntime.getDefaultVMInstall(); >+ if (install != null) { >+ IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath())); >+ if (entry != null) { >+ rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath()))); >+ } >+ } >+ } >+ } else { >+ rtes.add(tools); >+ } >+ } >+ >+ private void addSWTJars(List rtes) { >+ if (fgSWTEntries == null) { >+ fgSWTEntries= new ArrayList(); >+ Bundle bundle= Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$ >+ BundleDescription description= Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId()); >+ BundleDescription[] fragments= description.getFragments(); >+ for (int i = 0; i < fragments.length; i++) { >+ Bundle fragmentBundle= Platform.getBundle(fragments[i].getName()); >+ URL bundleURL; >+ try { >+ bundleURL = FileLocator.resolve(fragmentBundle.getEntry("/")); //$NON-NLS-1$ >+ } catch (IOException e) { >+ AntLaunching.log(e); >+ continue; >+ } >+ String urlFileName= bundleURL.getFile(); >+ if (urlFileName.startsWith("file:")) { //$NON-NLS-1$ >+ try { >+ urlFileName= new URL(urlFileName).getFile(); >+ if (urlFileName.endsWith("!/")) { //$NON-NLS-1$ >+ urlFileName= urlFileName.substring(0, urlFileName.length() - 2); >+ } >+ } catch (MalformedURLException e) { >+ AntLaunching.log(e); >+ continue; >+ } >+ } >+ IPath fragmentPath= new Path(urlFileName); >+ if (fragmentPath.getFileExtension() != null) { //JAR file >+ fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath)); >+ } else { // folder >+ File bundleFolder= fragmentPath.toFile(); >+ if (!bundleFolder.isDirectory()) { >+ continue; >+ } >+ String[] names= bundleFolder.list(new FilenameFilter() { >+ public boolean accept(File dir, String name) { >+ return name.endsWith(".jar"); //$NON-NLS-1$ >+ } >+ }); >+ for (int j = 0; j < names.length; j++) { >+ String jarName = names[j]; >+ fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath.append(jarName))); >+ } >+ } >+ } >+ } >+ rtes.addAll(fgSWTEntries); >+ } >+ >+ /** >+ * Returns the tools.jar to use for this launch configuration, or <code>null</code> >+ * if none. >+ * >+ * @param configuration configuration to resolve a tools.jar for >+ * @return associated tools.jar archive, or <code>null</code> >+ */ >+ private IRuntimeClasspathEntry getToolsJar(ILaunchConfiguration configuration) { >+ try { >+ IVMInstall install = JavaRuntime.computeVMInstall(configuration); >+ if (install != null) { >+ IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath())); >+ if (entry != null) { >+ return JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath())); >+ } >+ } >+ } catch (CoreException ce) { >+ //likely dealing with a non-Java project >+ } >+ >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName() >+ */ >+ public String getName() { >+ return AntLaunchConfigurationMessages.ContributedClasspathEntriesEntry_1; >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType() >+ */ >+ public int getType() { >+ return IRuntimeClasspathEntry.OTHER; >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#isComposite() >+ */ >+ public boolean isComposite() { >+ return true; >+ } >+ /* (non-Javadoc) >+ * @see java.lang.Object#equals(java.lang.Object) >+ */ >+ public boolean equals(Object obj) { >+ return obj instanceof ContributedClasspathEntriesEntry; >+ } >+ /* (non-Javadoc) >+ * @see java.lang.Object#hashCode() >+ */ >+ public int hashCode() { >+ return getClass().hashCode(); >+ } >+} >Index: src/org/eclipse/ant/internal/launching/IAntLaunchingPreferenceConstants.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/IAntLaunchingPreferenceConstants.java >diff -N src/org/eclipse/ant/internal/launching/IAntLaunchingPreferenceConstants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/IAntLaunchingPreferenceConstants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,24 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * John-Mason P. Shackelford (john-mason.shackelford@pearson.com) - bug 53547 >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching; >+ >+/** >+ * Constants used to identify user preferences. >+ */ >+public interface IAntLaunchingPreferenceConstants { >+ >+ /** >+ * int preference identifier constant which specifies the length of time to wait >+ * to connect with the socket that communicates with the separate JRE to capture the output >+ */ >+ public static final String ANT_COMMUNICATION_TIMEOUT= "timeout"; //$NON-NLS-1$ >+} >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/AntMigrationDelegate.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/AntMigrationDelegate.java >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/AntMigrationDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/AntMigrationDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.launchConfigurations; >+ >+import org.eclipse.core.internal.externaltools.model.IExternalToolConstants; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.variables.IStringVariableManager; >+import org.eclipse.core.variables.VariablesPlugin; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate; >+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+ >+/** >+ * Delegate for migrating Ant launch configurations. >+ * The migration process involves a resource mapping being created such that launch configurations >+ * can be filtered from the launch configuration dialog based on resource availability. >+ * >+ * @since 3.2 >+ */ >+public class AntMigrationDelegate implements ILaunchConfigurationMigrationDelegate { >+ >+ /** >+ * Method to get the file for the specified launch configuration that should be mapped to the launch configuration >+ * >+ * @param candidate the launch configuration that the file will be mapped to. >+ * @return the buildfile or <code>null</code> if not in the workspace >+ */ >+ protected IFile getFileForCandidate(ILaunchConfiguration candidate) { >+ IFile file= null; >+ String expandedLocation= null; >+ String location= null; >+ IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); >+ try { >+ location= candidate.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String)null); >+ if (location != null) { >+ expandedLocation= manager.performStringSubstitution(location); >+ if (expandedLocation != null) { >+ //file= AntUtil.getFileForLocation(expandedLocation, null); >+ } >+ } >+ } catch (CoreException e) { >+ } >+ return file; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate#isCandidate() >+ */ >+ public boolean isCandidate(ILaunchConfiguration candidate) throws CoreException { >+ IResource[] mappedResources = candidate.getMappedResources(); >+ if (mappedResources != null && mappedResources.length > 0) { >+ return false; >+ } >+ return getFileForCandidate(candidate) != null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate#migrate(org.eclipse.debug.core.ILaunchConfiguration) >+ */ >+ public void migrate(ILaunchConfiguration candidate) throws CoreException { >+ IFile file = getFileForCandidate(candidate); >+ ILaunchConfigurationWorkingCopy wc = candidate.getWorkingCopy(); >+ wc.setMappedResources(new IResource[] {file}); >+ wc.doSave(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/ant/internal/launching/debug/model/AntPropertiesValue.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/model/AntPropertiesValue.java >diff -N src/org/eclipse/ant/internal/launching/debug/model/AntPropertiesValue.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/model/AntPropertiesValue.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,71 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Brock Janiczak (brockj@tpg.com.au) - bug 154907 >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.debug.model; >+ >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.List; >+import org.eclipse.debug.core.model.IValue; >+import org.eclipse.debug.core.model.IVariable; >+ >+public class AntPropertiesValue extends AntDebugElement implements IValue { >+ >+ private List fProperties= new ArrayList(); >+ >+ public AntPropertiesValue(AntDebugTarget target) { >+ super(target); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName() >+ */ >+ public String getReferenceTypeName() { >+ return ""; //$NON-NLS-1$ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IValue#getValueString() >+ */ >+ public String getValueString() { >+ return ""; //$NON-NLS-1$ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IValue#isAllocated() >+ */ >+ public boolean isAllocated() { >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IValue#getVariables() >+ */ >+ public IVariable[] getVariables() { >+ Collections.sort(fProperties); >+ return (IVariable[])fProperties.toArray(new IVariable[fProperties.size()]); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IValue#hasVariables() >+ */ >+ public boolean hasVariables() { >+ return true; >+ } >+ >+ protected void addProperties(List properties) { >+ fProperties.addAll(properties); >+ } >+ >+ protected List getProperties() { >+ return fProperties; >+ } >+} >Index: src/org/eclipse/ant/internal/launching/debug/model/AntDebugElement.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/model/AntDebugElement.java >diff -N src/org/eclipse/ant/internal/launching/debug/model/AntDebugElement.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/model/AntDebugElement.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,55 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.debug.model; >+ >+ >+import org.eclipse.ant.internal.launching.AntLaunching; >+import org.eclipse.ant.internal.launching.debug.IAntDebugConstants; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.debug.core.DebugException; >+import org.eclipse.debug.core.model.DebugElement; >+ >+/** >+ * Common function of Ant debug model elements >+ */ >+public abstract class AntDebugElement extends DebugElement { >+ >+ /** >+ * Constructs a new debug element contained in the given >+ * debug target. >+ * >+ * @param target debug target >+ */ >+ public AntDebugElement(AntDebugTarget target) { >+ super(target); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier() >+ */ >+ public String getModelIdentifier() { >+ return IAntDebugConstants.ID_ANT_DEBUG_MODEL; >+ } >+ >+ /** >+ * Throws a debug exception with the given message, error code, and underlying >+ * exception. >+ */ >+ protected void throwDebugException(String message) throws DebugException { >+ throw new DebugException(new Status(IStatus.ERROR, AntLaunching.getUniqueIdentifier(), >+ DebugException.TARGET_REQUEST_FAILED, message, null)); >+ } >+ >+ protected AntDebugTarget getAntDebugTarget() { >+ return (AntDebugTarget)super.getDebugTarget(); >+ } >+} >Index: src/org/eclipse/ant/internal/launching/debug/model/AntValue.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/model/AntValue.java >diff -N src/org/eclipse/ant/internal/launching/debug/model/AntValue.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/model/AntValue.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,71 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.debug.model; >+ >+import org.eclipse.ant.internal.launching.debug.IAntDebugConstants; >+import org.eclipse.debug.core.model.IValue; >+import org.eclipse.debug.core.model.IVariable; >+ >+public class AntValue extends AntDebugElement implements IValue { >+ >+ private String fValueString; >+ protected static final IVariable[] EMPTY = new IVariable[0]; >+ >+ /** >+ * @param target >+ */ >+ public AntValue(AntDebugTarget target, String value) { >+ super(target); >+ fValueString= value; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName() >+ */ >+ public String getReferenceTypeName() { >+ return ""; //$NON-NLS-1$ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IValue#getValueString() >+ */ >+ public String getValueString() { >+ return fValueString; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IValue#isAllocated() >+ */ >+ public boolean isAllocated() { >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IValue#getVariables() >+ */ >+ public IVariable[] getVariables() { >+ return EMPTY; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IValue#hasVariables() >+ */ >+ public boolean hasVariables() { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier() >+ */ >+ public String getModelIdentifier() { >+ return IAntDebugConstants.ID_ANT_DEBUG_MODEL; >+ } >+} >Index: src/org/eclipse/ant/internal/launching/debug/model/AntProperty.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/model/AntProperty.java >diff -N src/org/eclipse/ant/internal/launching/debug/model/AntProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/model/AntProperty.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,121 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Brock Janiczak (brockj@tpg.com.au) - bug 154907 >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.debug.model; >+ >+import org.eclipse.debug.core.model.IValue; >+import org.eclipse.debug.core.model.IVariable; >+ >+/** >+ * A property in an Ant build. >+ */ >+public class AntProperty extends AntDebugElement implements IVariable, Comparable { >+ >+ private String fName; >+ private AntValue fValue; >+ private String fLabel; >+ >+ /** >+ * Constructs a variable associated with the debug target >+ * with the given name and value. >+ * >+ * @param target the debug target >+ * @param name property name >+ * @param value property value >+ */ >+ public AntProperty(AntDebugTarget target, String name, String value) { >+ super(target); >+ fName = name; >+ fValue= new AntValue(target, value); >+ } >+ >+ /* >+ * @see org.eclipse.debug.core.model.IVariable#getValue() >+ */ >+ public IValue getValue() { >+ return fValue; >+ } >+ >+ /* >+ * @see org.eclipse.debug.core.model.IVariable#getName() >+ */ >+ public String getName() { >+ return fName; >+ } >+ >+ /* >+ * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName() >+ */ >+ public String getReferenceTypeName() { >+ return ""; //$NON-NLS-1$ >+ } >+ >+ /* >+ * @see org.eclipse.debug.core.model.IVariable#hasValueChanged() >+ */ >+ public boolean hasValueChanged() { >+ return false; >+ } >+ >+ /* >+ * @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String) >+ */ >+ public void setValue(String expression) { >+ } >+ >+ /* >+ * @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue) >+ */ >+ public void setValue(IValue value) { >+ } >+ >+ /* >+ * @see org.eclipse.debug.core.model.IValueModification#supportsValueModification() >+ */ >+ public boolean supportsValueModification() { >+ return false; >+ } >+ >+ /* >+ * @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String) >+ */ >+ public boolean verifyValue(String expression) { >+ return false; >+ } >+ >+ /* >+ * @see org.eclipse.debug.core.model.IValueModification#verifyValue(org.eclipse.debug.core.model.IValue) >+ */ >+ public boolean verifyValue(IValue value) { >+ return false; >+ } >+ >+ /** >+ * @return the text used to render this property >+ */ >+ public String getText() { >+ if (fLabel == null) { >+ StringBuffer buffer= new StringBuffer(getName()); >+ buffer.append("= "); //$NON-NLS-1$ >+ buffer.append(fValue.getValueString()); >+ fLabel= buffer.toString(); >+ } >+ return fLabel; >+ } >+ >+ /* >+ * @see java.lang.Comparable#compareTo(java.lang.Object) >+ */ >+ public int compareTo(Object other) { >+ AntProperty otherProperty = (AntProperty) other; >+ return fName.compareToIgnoreCase(otherProperty.getName()); >+ } >+} >Index: src/org/eclipse/ant/internal/launching/debug/AntSourceLookupParticipant.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/AntSourceLookupParticipant.java >diff -N src/org/eclipse/ant/internal/launching/debug/AntSourceLookupParticipant.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/AntSourceLookupParticipant.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,36 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.debug; >+ >+import org.eclipse.ant.internal.launching.debug.model.AntStackFrame; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant; >+ >+/** >+ * The Ant source lookup participant knows how to translate a >+ * Ant stack frame into a source file name >+ */ >+public class AntSourceLookupParticipant extends AbstractSourceLookupParticipant { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant#getSourceName(java.lang.Object) >+ */ >+ public String getSourceName(Object object) throws CoreException { >+ if (object instanceof AntStackFrame) { >+ return ((AntStackFrame)object).getFilePath(); >+ } >+ if (object instanceof String) { >+ // assume it's a file name >+ return (String)object; >+ } >+ return null; >+ } >+} >Index: src/org/eclipse/ant/internal/launching/debug/AntSourceLookupDirector.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/AntSourceLookupDirector.java >diff -N src/org/eclipse/ant/internal/launching/debug/AntSourceLookupDirector.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/AntSourceLookupDirector.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,36 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.debug; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector; >+import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant; >+ >+/** >+ * Ant source lookup director. For Ant source lookup there is one source >+ * lookup participant. >+ */ >+public class AntSourceLookupDirector extends AbstractSourceLookupDirector { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.sourcelookup.ISourceLookupDirector#initializeParticipants() >+ */ >+ public void initializeParticipants() { >+ addParticipants(new ISourceLookupParticipant[]{new AntSourceLookupParticipant()}); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento() >+ */ >+ public String getMemento() throws CoreException { >+ return null; >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/ant/internal/launching/debug/model/AntStackFrame.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/model/AntStackFrame.java >diff -N src/org/eclipse/ant/internal/launching/debug/model/AntStackFrame.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/model/AntStackFrame.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,314 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.debug.model; >+ >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.debug.core.DebugException; >+import org.eclipse.debug.core.model.IRegisterGroup; >+import org.eclipse.debug.core.model.IStackFrame; >+import org.eclipse.debug.core.model.IThread; >+import org.eclipse.debug.core.model.IVariable; >+ >+/** >+ * Ant stack frame. >+ */ >+public class AntStackFrame extends AntDebugElement implements IStackFrame { >+ >+ private AntThread fThread; >+ private String fName; >+ private int fLineNumber; >+ private String fFilePath; >+ private int fId; >+ private String fFullPath; >+ >+ /** >+ * Constructs a stack frame in the given thread with the given id. >+ * >+ * @param thread >+ * @param id stack frame id (0 is the top of the stack) >+ */ >+ public AntStackFrame(AntThread thread, int id, String name, String fullPath, int lineNumber) { >+ super((AntDebugTarget) thread.getDebugTarget()); >+ fId = id; >+ fThread = thread; >+ fLineNumber= lineNumber; >+ fName= name; >+ setFilePath(fullPath); >+ } >+ >+ protected void setId(int id) { >+ fId= id; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStackFrame#getThread() >+ */ >+ public IThread getThread() { >+ return fThread; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStackFrame#getVariables() >+ */ >+ public IVariable[] getVariables() throws DebugException { >+ return fThread.getVariables(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStackFrame#hasVariables() >+ */ >+ public boolean hasVariables() { >+ return isSuspended(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStackFrame#getLineNumber() >+ */ >+ public int getLineNumber() { >+ return fLineNumber; >+ } >+ >+ protected void setLineNumber(int lineNumber) { >+ fLineNumber= lineNumber; >+ } >+ >+ protected void setFilePath(String fullPath) { >+ fFullPath= fullPath; >+ IFile file= AntLaunchingUtil.getFileForLocation(fullPath, null); >+ if (file != null) { >+ fFilePath= file.getProjectRelativePath().toString(); >+ } else { >+ fFilePath= new Path(fullPath).lastSegment(); >+ } >+ } >+ >+ public String getFilePath() { >+ return fFullPath; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStackFrame#getCharStart() >+ */ >+ public int getCharStart() { >+ return -1; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStackFrame#getCharEnd() >+ */ >+ public int getCharEnd() { >+ return -1; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStackFrame#getName() >+ */ >+ public String getName() { >+ return fName; >+ } >+ >+ protected void setName(String name) { >+ fName= name; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStackFrame#getRegisterGroups() >+ */ >+ public IRegisterGroup[] getRegisterGroups() { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStackFrame#hasRegisterGroups() >+ */ >+ public boolean hasRegisterGroups() { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStep#canStepInto() >+ */ >+ public boolean canStepInto() { >+ return getThread().canStepInto(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStep#canStepOver() >+ */ >+ public boolean canStepOver() { >+ return getThread().canStepOver(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStep#canStepReturn() >+ */ >+ public boolean canStepReturn() { >+ return getThread().canStepReturn(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStep#isStepping() >+ */ >+ public boolean isStepping() { >+ return getThread().isStepping(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStep#stepInto() >+ */ >+ public void stepInto() throws DebugException { >+ getThread().stepInto(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStep#stepOver() >+ */ >+ public void stepOver() throws DebugException { >+ getThread().stepOver(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStep#stepReturn() >+ */ >+ public void stepReturn() throws DebugException { >+ getThread().stepReturn(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ISuspendResume#canResume() >+ */ >+ public boolean canResume() { >+ return getThread().canResume(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend() >+ */ >+ public boolean canSuspend() { >+ return getThread().canSuspend(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended() >+ */ >+ public boolean isSuspended() { >+ return getThread().isSuspended(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ISuspendResume#resume() >+ */ >+ public void resume() throws DebugException { >+ getThread().resume(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ISuspendResume#suspend() >+ */ >+ public void suspend() throws DebugException { >+ getThread().suspend(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ITerminate#canTerminate() >+ */ >+ public boolean canTerminate() { >+ return getThread().canTerminate(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ITerminate#isTerminated() >+ */ >+ public boolean isTerminated() { >+ return getThread().isTerminated(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ITerminate#terminate() >+ */ >+ public void terminate() throws DebugException { >+ getThread().terminate(); >+ } >+ >+ /** >+ * Returns the name of the buildfile this stack frame is associated >+ * with. >+ * >+ * @return the name of the buildfile this stack frame is associated >+ * with >+ */ >+ public String getSourceName() { >+ return fFilePath; >+ } >+ >+ /* (non-Javadoc) >+ * @see java.lang.Object#equals(java.lang.Object) >+ */ >+ public boolean equals(Object obj) { >+ if (obj instanceof AntStackFrame) { >+ AntStackFrame sf = (AntStackFrame)obj; >+ if (getSourceName() != null) { >+ return getSourceName().equals(sf.getSourceName()) && >+ sf.getLineNumber() == getLineNumber() && >+ sf.fId == fId; >+ } >+ return sf.fId == fId; >+ } >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see java.lang.Object#hashCode() >+ */ >+ public int hashCode() { >+ if (getSourceName() == null) { >+ return fId; >+ } >+ return getSourceName().hashCode() + fId; >+ } >+ >+ /** >+ * Returns this stack frame's unique identifier within its thread >+ * >+ * @return this stack frame's unique identifier within its thread >+ */ >+ protected int getIdentifier() { >+ return fId; >+ } >+ >+ /** >+ * Returns the system, user or runtime property >+ * name, or <code>null</code> if unable to resolve a property with the name. >+ * >+ * @param propertyName the name of the variable to search for >+ * @return a property, or <code>null</code> if none >+ */ >+ public AntProperty findProperty(String propertyName) { >+ try { >+ IVariable[] groups= getVariables(); >+ for (int i = 0; i < groups.length; i++) { >+ AntProperties propertiesGrouping = (AntProperties) groups[i]; >+ AntPropertiesValue value= (AntPropertiesValue) propertiesGrouping.getValue(); >+ IVariable[] properties= value.getVariables(); >+ for (int j = 0; j < properties.length; j++) { >+ AntProperty property = (AntProperty) properties[j]; >+ if (property.getName().equals(propertyName)) { >+ return property; >+ } >+ } >+ } >+ } catch (DebugException e) { >+ } >+ return null; >+ } >+} >Index: src/org/eclipse/ant/internal/launching/debug/model/AntDebugTarget.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/model/AntDebugTarget.java >diff -N src/org/eclipse/ant/internal/launching/debug/model/AntDebugTarget.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/model/AntDebugTarget.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,463 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.debug.model; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.ant.internal.launching.debug.IAntDebugConstants; >+import org.eclipse.ant.internal.launching.debug.IAntDebugController; >+import org.eclipse.core.internal.externaltools.model.IExternalToolConstants; >+import org.eclipse.core.resources.IMarkerDelta; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.variables.VariablesPlugin; >+import org.eclipse.debug.core.DebugEvent; >+import org.eclipse.debug.core.DebugException; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.IBreakpointManager; >+import org.eclipse.debug.core.IBreakpointManagerListener; >+import org.eclipse.debug.core.IDebugEventSetListener; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.model.IBreakpoint; >+import org.eclipse.debug.core.model.IDebugTarget; >+import org.eclipse.debug.core.model.ILineBreakpoint; >+import org.eclipse.debug.core.model.IMemoryBlock; >+import org.eclipse.debug.core.model.IProcess; >+import org.eclipse.debug.core.model.IThread; >+ >+/** >+ * Ant Debug Target >+ */ >+public class AntDebugTarget extends AntDebugElement implements IDebugTarget, IDebugEventSetListener, IBreakpointManagerListener { >+ >+ // associated system process (Ant Build) >+ private IProcess fProcess; >+ >+ // containing launch object >+ private ILaunch fLaunch; >+ >+ // Build file name >+ private String fName; >+ >+ // suspend state >+ private boolean fSuspended= false; >+ >+ // terminated state >+ private boolean fTerminated= false; >+ >+ // threads >+ private AntThread fThread; >+ private IThread[] fThreads; >+ >+ private IAntDebugController fController; >+ >+ private List fRunToLineBreakpoints; >+ >+ /** >+ * Constructs a new debug target in the given launch for the >+ * associated Ant build process. >+ * >+ * @param launch containing launch >+ * @param process Ant build process >+ * @param controller the controller to communicate to the Ant build >+ */ >+ public AntDebugTarget(ILaunch launch, IProcess process, IAntDebugController controller) { >+ super(null); >+ fLaunch = launch; >+ fProcess = process; >+ >+ fController= controller; >+ >+ fThread = new AntThread(this); >+ fThreads = new IThread[] {fThread}; >+ >+ DebugPlugin.getDefault().getBreakpointManager().addBreakpointManagerListener(this); >+ DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this); >+ DebugPlugin.getDefault().addDebugEventListener(this); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IDebugTarget#getProcess() >+ */ >+ public IProcess getProcess() { >+ return fProcess; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IDebugTarget#getThreads() >+ */ >+ public IThread[] getThreads() { >+ return fThreads; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IDebugTarget#hasThreads() >+ */ >+ public boolean hasThreads() throws DebugException { >+ return !fTerminated && fThreads.length > 0; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IDebugTarget#getName() >+ */ >+ public String getName() throws DebugException { >+ if (fName == null) { >+ try { >+ fName= getLaunch().getLaunchConfiguration().getAttribute(IExternalToolConstants.ATTR_LOCATION, DebugModelMessages.AntDebugTarget_0); >+ fName= VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(fName); >+ } catch (CoreException e) { >+ fName = DebugModelMessages.AntDebugTarget_0; >+ } >+ } >+ return fName; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IDebugTarget#supportsBreakpoint(org.eclipse.debug.core.model.IBreakpoint) >+ */ >+ public boolean supportsBreakpoint(IBreakpoint breakpoint) { >+ if (breakpoint.getModelIdentifier().equals(IAntDebugConstants.ID_ANT_DEBUG_MODEL)) { >+ //need to consider all breakpoints as no way to tell which set >+ //of buildfiles will be executed (ant task) >+ return true; >+ } >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget() >+ */ >+ public IDebugTarget getDebugTarget() { >+ return this; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IDebugElement#getLaunch() >+ */ >+ public ILaunch getLaunch() { >+ return fLaunch; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ITerminate#canTerminate() >+ */ >+ public boolean canTerminate() { >+ return !fTerminated; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ITerminate#isTerminated() >+ */ >+ public boolean isTerminated() { >+ return fTerminated; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ITerminate#terminate() >+ */ >+ public void terminate() throws DebugException { >+ terminated(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ISuspendResume#canResume() >+ */ >+ public boolean canResume() { >+ return !isTerminated() && isSuspended(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend() >+ */ >+ public boolean canSuspend() { >+ return !isTerminated() && !isSuspended(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended() >+ */ >+ public boolean isSuspended() { >+ return fSuspended; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ISuspendResume#resume() >+ */ >+ public void resume() throws DebugException { >+ fSuspended= false; >+ fController.resume(); >+ } >+ >+ /** >+ * Notification the target has suspended for the given reason >+ * >+ * @param detail reason for the suspend >+ */ >+ public void suspended(int detail) { >+ fSuspended = true; >+ fThread.setStepping(false); >+ fThread.fireSuspendEvent(detail); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ISuspendResume#suspend() >+ */ >+ public void suspend() throws DebugException { >+ fController.suspend(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.IBreakpointListener#breakpointAdded(org.eclipse.debug.core.model.IBreakpoint) >+ */ >+ public void breakpointAdded(IBreakpoint breakpoint) { >+ fController.handleBreakpoint(breakpoint, true); >+ if (breakpoint instanceof AntLineBreakpoint) { >+ if (((AntLineBreakpoint) breakpoint).isRunToLine()) { >+ if (fRunToLineBreakpoints == null) { >+ fRunToLineBreakpoints= new ArrayList(); >+ } >+ fRunToLineBreakpoints.add(breakpoint); >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.IBreakpointListener#breakpointRemoved(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta) >+ */ >+ public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) { >+ fController.handleBreakpoint(breakpoint, false); >+ if (fRunToLineBreakpoints != null) { >+ if (fRunToLineBreakpoints.remove(breakpoint) && fRunToLineBreakpoints.isEmpty()) { >+ fRunToLineBreakpoints= null; >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.IBreakpointListener#breakpointChanged(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta) >+ */ >+ public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) { >+ if (supportsBreakpoint(breakpoint)) { >+ try { >+ if (breakpoint.isEnabled() && DebugPlugin.getDefault().getBreakpointManager().isEnabled()) { >+ breakpointAdded(breakpoint); >+ } else { >+ breakpointRemoved(breakpoint, null); >+ } >+ } catch (CoreException e) { >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IDisconnect#canDisconnect() >+ */ >+ public boolean canDisconnect() { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IDisconnect#disconnect() >+ */ >+ public void disconnect() throws DebugException { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IDisconnect#isDisconnected() >+ */ >+ public boolean isDisconnected() { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#supportsStorageRetrieval() >+ */ >+ public boolean supportsStorageRetrieval() { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#getMemoryBlock(long, long) >+ */ >+ public IMemoryBlock getMemoryBlock(long startAddress, long length) throws DebugException { >+ return null; >+ } >+ >+ /** >+ * Notification we have connected to the Ant build logger and it has started. >+ * Resume the build. >+ */ >+ public void buildStarted() { >+ fireCreationEvent(); >+ installDeferredBreakpoints(); >+ try { >+ resume(); >+ } catch (DebugException e) { >+ } >+ } >+ >+ /** >+ * Install breakpoints that are already registered with the breakpoint >+ * manager if the breakpoint manager is enabled and the breakpoint is enabled. >+ */ >+ private void installDeferredBreakpoints() { >+ IBreakpointManager manager= DebugPlugin.getDefault().getBreakpointManager(); >+ if (!manager.isEnabled()) { >+ return; >+ } >+ IBreakpoint[] breakpoints = manager.getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL); >+ for (int i = 0; i < breakpoints.length; i++) { >+ IBreakpoint breakpoint= breakpoints[i]; >+ try { >+ if (breakpoint.isEnabled()) { >+ breakpointAdded(breakpoints[i]); >+ } >+ } catch (CoreException e) { >+ } >+ } >+ } >+ >+ /** >+ * Called when this debug target terminates. >+ */ >+ protected void terminated() { >+ fThreads= new IThread[0]; >+ fTerminated = true; >+ fSuspended = false; >+ if (DebugPlugin.getDefault() != null) { >+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this); >+ DebugPlugin.getDefault().removeDebugEventListener(this); >+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpointManagerListener(this); >+ } >+ if (!getProcess().isTerminated()) { >+ try { >+ fProcess.terminate(); >+ resume(); >+ } catch (DebugException e) { >+ } >+ } >+ if (DebugPlugin.getDefault() != null) { >+ fireTerminateEvent(); >+ } >+ } >+ >+ /** >+ * Single step the Ant build. >+ * >+ * @throws DebugException if the request fails >+ */ >+ protected void stepOver() { >+ fSuspended= false; >+ fController.stepOver(); >+ } >+ >+ /** >+ * Step-into the Ant build. >+ * >+ * @throws DebugException if the request fails >+ */ >+ protected void stepInto() { >+ fSuspended= false; >+ fController.stepInto(); >+ } >+ >+ /** >+ * Notification a breakpoint was encountered. Determine >+ * which breakpoint was hit and fire a suspend event. >+ * >+ * @param event debug event >+ */ >+ protected void breakpointHit(String event) { >+ // determine which breakpoint was hit, and set the thread's breakpoint >+ String[] datum= event.split(DebugMessageIds.MESSAGE_DELIMITER); >+ String fileName= datum[1]; >+ int lineNumber = Integer.parseInt(datum[2]); >+ IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL); >+ boolean found= false; >+ for (int i = 0; i < breakpoints.length; i++) { >+ ILineBreakpoint lineBreakpoint = (ILineBreakpoint)breakpoints[i]; >+ if (setThreadBreakpoint(lineBreakpoint, lineNumber, fileName)) { >+ found= true; >+ break; >+ } >+ } >+ if (!found && fRunToLineBreakpoints != null) { >+ Iterator iter= fRunToLineBreakpoints.iterator(); >+ while (iter.hasNext()) { >+ ILineBreakpoint lineBreakpoint = (ILineBreakpoint) iter.next(); >+ if (setThreadBreakpoint(lineBreakpoint, lineNumber, fileName)) { >+ break; >+ } >+ } >+ } >+ suspended(DebugEvent.BREAKPOINT); >+ } >+ >+ private boolean setThreadBreakpoint(ILineBreakpoint lineBreakpoint, int lineNumber, String fileName) { >+ try { >+ if (lineBreakpoint.getLineNumber() == lineNumber && >+ fileName.equals(lineBreakpoint.getMarker().getResource().getLocation().toOSString())) { >+ fThread.setBreakpoints(new IBreakpoint[]{lineBreakpoint}); >+ return true; >+ } >+ } catch (CoreException e) { >+ } >+ return false; >+ } >+ >+ public void breakpointHit (IBreakpoint breakpoint) { >+ fThread.setBreakpoints(new IBreakpoint[]{breakpoint}); >+ suspended(DebugEvent.BREAKPOINT); >+ } >+ >+ protected void getStackFrames() { >+ fController.getStackFrames(); >+ } >+ >+ protected void getProperties() { >+ fController.getProperties(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[]) >+ */ >+ public void handleDebugEvents(DebugEvent[] events) { >+ for (int i = 0; i < events.length; i++) { >+ DebugEvent event = events[i]; >+ if (event.getKind() == DebugEvent.TERMINATE && event.getSource().equals(fProcess)) { >+ terminated(); >+ } >+ } >+ } >+ >+ /** >+ * When the breakpoint manager disables, remove all registered breakpoints >+ * requests from the VM. When it enables, reinstall them. >+ * >+ * @see org.eclipse.debug.core.IBreakpointManagerListener#breakpointManagerEnablementChanged(boolean) >+ */ >+ public void breakpointManagerEnablementChanged(boolean enabled) { >+ IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL); >+ for (int i = 0; i < breakpoints.length; i++) { >+ IBreakpoint breakpoint = breakpoints[i]; >+ if (enabled) { >+ breakpointAdded(breakpoint); >+ } else { >+ breakpointRemoved(breakpoint, null); >+ } >+ } >+ } >+ >+ public IAntDebugController getAntDebugController() { >+ return fController; >+ } >+} >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchDelegate.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchDelegate.java >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,889 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Juan A. Hernandez - bug 89926 >+ * dakshinamurthy.karra@gmail.com - bug 165371 >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.launchConfigurations; >+ >+import java.io.File; >+import java.io.IOException; >+import java.net.URL; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import org.apache.tools.ant.ProjectHelper; >+import org.eclipse.ant.core.AntCorePlugin; >+import org.eclipse.ant.core.AntCorePreferences; >+import org.eclipse.ant.core.AntRunner; >+import org.eclipse.ant.core.Property; >+import org.eclipse.ant.core.Task; >+import org.eclipse.ant.core.Type; >+import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger; >+import org.eclipse.ant.internal.launching.AntLaunch; >+import org.eclipse.ant.internal.launching.AntLaunching; >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; >+import org.eclipse.ant.internal.launching.debug.IAntDebugConstants; >+import org.eclipse.ant.internal.launching.debug.model.RemoteAntDebugBuildListener; >+import org.eclipse.core.internal.externaltools.launchConfigurations.BackgroundResourceRefresher; >+import org.eclipse.core.internal.externaltools.launchConfigurations.ExternalToolsCoreUtil; >+import org.eclipse.core.internal.externaltools.model.IExternalToolConstants; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.FileLocator; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.core.variables.VariablesPlugin; >+import org.eclipse.debug.core.DebugEvent; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.IBreakpointManager; >+import org.eclipse.debug.core.IDebugEventSetListener; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.debug.core.ILaunchManager; >+import org.eclipse.debug.core.model.IBreakpoint; >+import org.eclipse.debug.core.model.IProcess; >+import org.eclipse.debug.core.model.LaunchConfigurationDelegate; >+import org.eclipse.debug.internal.core.LaunchManager; >+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.JavaRuntime; >+import org.eclipse.jdt.launching.SocketUtil; >+import org.eclipse.osgi.service.resolver.BundleDescription; >+import org.osgi.framework.Bundle; >+ >+import com.ibm.icu.text.MessageFormat; >+ >+/** >+ * Launch delegate for Ant builds >+ */ >+public class AntLaunchDelegate extends LaunchConfigurationDelegate { >+ >+ private static final String ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessBuildLogger"; //$NON-NLS-1$ >+ private static final String ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessDebugBuildLogger"; //$NON-NLS-1$ >+ private static final String NULL_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.NullBuildLogger"; //$NON-NLS-1$ >+ private static final String REMOTE_ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.RemoteAntBuildLogger"; //$NON-NLS-1$ >+ private static final String REMOTE_ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.debug.RemoteAntDebugBuildLogger"; //$NON-NLS-1$ >+ private static final String BASE_DIR_PREFIX = "-Dbasedir="; //$NON-NLS-1$ >+ private static final String INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.AntInputHandler"; //$NON-NLS-1$ >+ private static final String REMOTE_INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.ProxyInputHandler"; //$NON-NLS-1$ >+ >+ private static final IProject[] NO_PROJECTS = new IProject[0]; >+ >+ /** >+ * String attribute identifying the build scope for a launch configuration. >+ * <code>null</code> indicates the default workspace build. >+ */ >+ private static final String ATTR_BUILD_SCOPE = AntLaunching >+ .getUniqueIdentifier() >+ + ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$ >+ >+ /** >+ * Attribute identifier specifying whether referenced projects should be >+ * considered when computing the projects to build. Default value is >+ * <code>true</code>. >+ */ >+ private static final String ATTR_INCLUDE_REFERENCED_PROJECTS = AntLaunching >+ .getUniqueIdentifier() >+ + ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$ >+ >+ private static String fgSWTLibraryLocation; >+ >+ private String fMode; >+ private boolean fUserSpecifiedLogger = false; >+ >+ private String getProgramArguments(ILaunchConfiguration configuration) >+ throws CoreException { >+ String arguments = configuration.getAttribute( >+ IExternalToolConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$ >+ return VariablesPlugin.getDefault().getStringVariableManager() >+ .performStringSubstitution(arguments); >+ } >+ >+ /** >+ * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, >+ * java.lang.String, org.eclipse.debug.core.ILaunch, >+ * org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ public void launch(ILaunchConfiguration configuration, String mode, >+ ILaunch launch, IProgressMonitor monitor) throws CoreException { >+ if (monitor.isCanceled()) { >+ return; >+ } >+ fUserSpecifiedLogger = false; >+ fMode = mode; >+ >+ // migrate the config to the new classpath format if required >+ AntLaunchingUtil.migrateToNewClasspathFormat(configuration); >+ >+ boolean isSeparateJRE = AntLaunchingUtil >+ .isSeparateJREAntBuild(configuration); >+ >+ if (LaunchManager.isLaunchInBackground(configuration)) { >+ monitor >+ .beginTask( >+ MessageFormat >+ .format( >+ AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1, >+ new String[] { configuration >+ .getName() }), 10); >+ } else { >+ monitor >+ .beginTask( >+ MessageFormat >+ .format( >+ AntLaunchConfigurationMessages.AntLaunchDelegate_Running__0__2, >+ new String[] { configuration >+ .getName() }), 100); >+ } >+ >+ // resolve location >+ IPath location = ExternalToolsCoreUtil.getLocation(configuration); >+ monitor.worked(1); >+ >+ if (monitor.isCanceled()) { >+ return; >+ } >+ >+ if (!isSeparateJRE && AntRunner.isBuildRunning()) { >+ IStatus status = new Status( >+ IStatus.ERROR, >+ IAntLaunchConfigurationConstants.PLUGIN_ID, >+ 1, >+ MessageFormat >+ .format( >+ AntLaunchConfigurationMessages.AntLaunchDelegate_Build_In_Progress, >+ new String[] { location.toOSString() }), >+ null); >+ throw new CoreException(status); >+ } >+ >+ // resolve working directory >+ IPath workingDirectory = ExternalToolsCoreUtil >+ .getWorkingDirectory(configuration); >+ String basedir = null; >+ if (workingDirectory != null) { >+ basedir = workingDirectory.toOSString(); >+ } >+ monitor.worked(1); >+ >+ if (monitor.isCanceled()) { >+ return; >+ } >+ >+ // link the process to its build logger via a timestamp >+ long timeStamp = System.currentTimeMillis(); >+ String idStamp = Long.toString(timeStamp); >+ StringBuffer idProperty = new StringBuffer("-D"); //$NON-NLS-1$ >+ idProperty.append(AbstractEclipseBuildLogger.ANT_PROCESS_ID); >+ idProperty.append('='); >+ idProperty.append(idStamp); >+ >+ // resolve arguments >+ String[] arguments = null; >+ if (isSeparateJRE) { >+ arguments = new String[] { getProgramArguments(configuration) }; >+ } else { >+ arguments = ExternalToolsCoreUtil.getArguments(configuration); >+ } >+ >+ Map userProperties = AntLaunchingUtil.getProperties(configuration); >+ if (userProperties != null) {// create a copy so as to not affect the >+ // configuration with transient >+ // properties >+ userProperties = new HashMap(userProperties); >+ } >+ String[] propertyFiles = AntLaunchingUtil >+ .getPropertyFiles(configuration); >+ String[] targets = AntLaunchingUtil.getTargetNames(configuration); >+ URL[] customClasspath = AntLaunchingUtil >+ .getCustomClasspath(configuration); >+ String antHome = AntLaunchingUtil.getAntHome(configuration); //$NON-NLS-1$ >+ >+ boolean setInputHandler = true; >+ try { >+ // check if set specify inputhandler >+ setInputHandler = configuration.getAttribute( >+ IAntLaunchConfigurationConstants.SET_INPUTHANDLER, true); >+ } catch (CoreException ce) { >+ AntLaunching.log(ce); >+ } >+ >+ AntRunner runner = null; >+ if (!isSeparateJRE) { >+ runner = configureAntRunner(configuration, location, basedir, >+ idProperty, arguments, userProperties, propertyFiles, >+ targets, customClasspath, antHome, setInputHandler); >+ } >+ >+ monitor.worked(1); >+ >+ if (monitor.isCanceled()) { >+ return; >+ } >+ boolean captureOutput = ExternalToolsCoreUtil >+ .getCaptureOutput(configuration); >+ int port = -1; >+ int requestPort = -1; >+ if (isSeparateJRE && captureOutput) { >+ if (userProperties == null) { >+ userProperties = new HashMap(); >+ } >+ port = SocketUtil.findFreePort(); >+ userProperties.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, >+ idStamp); >+ userProperties.put("eclipse.connect.port", Integer.toString(port)); //$NON-NLS-1$ >+ if (fMode.equals(ILaunchManager.DEBUG_MODE)) { >+ requestPort = SocketUtil.findFreePort(); >+ userProperties >+ .put( >+ "eclipse.connect.request_port", Integer.toString(requestPort)); //$NON-NLS-1$ >+ } >+ } >+ >+ StringBuffer commandLine = generateCommandLine(location, arguments, >+ userProperties, propertyFiles, targets, antHome, basedir, >+ isSeparateJRE, captureOutput, setInputHandler); >+ >+ if (isSeparateJRE) { >+ monitor >+ .beginTask( >+ MessageFormat >+ .format( >+ AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1, >+ new String[] { configuration >+ .getName() }), 10); >+ runInSeparateVM(configuration, launch, monitor, idStamp, antHome, >+ port, requestPort, commandLine, captureOutput, >+ setInputHandler); >+ } else { >+ runInSameVM(configuration, launch, monitor, location, idStamp, >+ runner, commandLine, captureOutput); >+ } >+ >+ monitor.done(); >+ } >+ >+ private void runInSameVM(ILaunchConfiguration configuration, >+ ILaunch launch, IProgressMonitor monitor, IPath location, >+ String idStamp, AntRunner runner, StringBuffer commandLine, >+ boolean captureOutput) throws CoreException { >+ Map attributes = new HashMap(2); >+ attributes.put(IProcess.ATTR_PROCESS_TYPE, >+ IAntLaunchConfigurationConstants.ID_ANT_PROCESS_TYPE); >+ attributes.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp); >+ >+ final AntProcess process = new AntProcess(location.toOSString(), >+ launch, attributes); >+ setProcessAttributes(process, idStamp, commandLine, captureOutput); >+ boolean debug = fMode.equals(ILaunchManager.DEBUG_MODE); >+ if (debug || LaunchManager.isLaunchInBackground(configuration)) { >+ final AntRunner finalRunner = runner; >+ Runnable r = new Runnable() { >+ public void run() { >+ try { >+ finalRunner.run(process); >+ } catch (CoreException e) { >+ handleException( >+ e, >+ AntLaunchConfigurationMessages.AntLaunchDelegate_Failure); >+ } >+ process.terminated(); >+ } >+ }; >+ Thread background = new Thread(r); >+ background.setDaemon(true); >+ background.start(); >+ monitor.worked(1); >+ // refresh resources after process finishes >+ if (LaunchManager.getRefreshScope(configuration) != null) { >+ BackgroundResourceRefresher refresher = new BackgroundResourceRefresher( >+ configuration, process); >+ refresher.startBackgroundRefresh(); >+ } >+ } else { >+ // execute the build >+ try { >+ runner.run(monitor); >+ } catch (CoreException e) { >+ process.terminated(); >+ monitor.done(); >+ handleException(e, >+ AntLaunchConfigurationMessages.AntLaunchDelegate_23); >+ return; >+ } >+ process.terminated(); >+ >+ // refresh resources >+ LaunchManager.refreshResources(configuration, monitor); >+ } >+ } >+ >+ 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 { >+ int argLength = 1; // at least one user property - timestamp >+ if (arguments != null) { >+ argLength += arguments.length; >+ } >+ if (baseDir != null && baseDir.length() > 0) { >+ argLength++; >+ } >+ String[] runnerArgs = new String[argLength]; >+ if (arguments != null) { >+ System.arraycopy(arguments, 0, runnerArgs, 0, arguments.length); >+ } >+ if (baseDir != null && baseDir.length() > 0) { >+ runnerArgs[runnerArgs.length - 2] = BASE_DIR_PREFIX + baseDir; >+ } >+ runnerArgs[runnerArgs.length - 1] = idProperty.toString(); >+ >+ AntRunner runner = new AntRunner(); >+ runner.setBuildFileLocation(location.toOSString()); >+ boolean captureOutput = ExternalToolsCoreUtil >+ .getCaptureOutput(configuration); >+ if (captureOutput) { >+ if (fMode.equals(ILaunchManager.DEBUG_MODE)) { >+ runner.addBuildLogger(ANT_DEBUG_LOGGER_CLASS); >+ } else { >+ runner.addBuildLogger(ANT_LOGGER_CLASS); >+ } >+ } else { >+ runner.addBuildLogger(NULL_LOGGER_CLASS); >+ } >+ if (setInputHandler) { >+ runner.setInputHandler(INPUT_HANDLER_CLASS); >+ } else { >+ runner.setInputHandler(""); //$NON-NLS-1$ >+ } >+ runner.setArguments(runnerArgs); >+ if (userProperties != null) { >+ runner.addUserProperties(userProperties); >+ } >+ >+ if (propertyFiles != null) { >+ runner.setPropertyFiles(propertyFiles); >+ } >+ >+ if (targets != null) { >+ runner.setExecutionTargets(targets); >+ } >+ >+ if (customClasspath != null) { >+ runner.setCustomClasspath(customClasspath); >+ } >+ >+ if (antHome != null) { >+ runner.setAntHome(antHome); >+ } >+ return runner; >+ } >+ >+ private void handleException(final CoreException e, final String title) { >+ AntLaunching.log(title, e); >+ } >+ >+ private void setProcessAttributes(IProcess process, String idStamp, >+ StringBuffer commandLine, boolean captureOutput) { >+ // link the process to the Eclipse build logger via a timestamp >+ if (!fUserSpecifiedLogger) { >+ process.setAttribute(AbstractEclipseBuildLogger.ANT_PROCESS_ID, >+ idStamp); >+ } >+ >+ // create "fake" command line for the process >+ if (commandLine != null) { >+ process.setAttribute(IProcess.ATTR_CMDLINE, commandLine.toString()); >+ } >+ } >+ >+ private StringBuffer generateCommandLine(IPath location, >+ String[] arguments, Map userProperties, String[] propertyFiles, >+ String[] targets, String antHome, String basedir, >+ boolean separateVM, boolean captureOutput, boolean setInputHandler) { >+ StringBuffer commandLine = new StringBuffer(); >+ >+ if (!separateVM) { >+ commandLine.append("ant"); //$NON-NLS-1$ >+ } >+ >+ if (arguments != null) { >+ for (int i = 0; i < arguments.length; i++) { >+ commandLine.append(' '); >+ commandLine.append(arguments[i]); >+ } >+ } >+ >+ AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences(); >+ if (propertyFiles == null) { // global >+ String[] files = prefs.getCustomPropertyFiles(); >+ for (int i = 0; i < files.length; i++) { >+ String path = files[i]; >+ commandLine.append(" -propertyfile \""); //$NON-NLS-1$ >+ commandLine.append(path); >+ commandLine.append('\"'); >+ } >+ } else {// "local" configuration >+ for (int i = 0; i < propertyFiles.length; i++) { >+ String path = propertyFiles[i]; >+ commandLine.append(" -propertyfile \""); //$NON-NLS-1$ >+ commandLine.append(path); >+ commandLine.append('\"'); >+ } >+ } >+ // "local" configuration >+ if (userProperties != null) { >+ Iterator keys = userProperties.keySet().iterator(); >+ String key; >+ while (keys.hasNext()) { >+ key = (String) keys.next(); >+ appendProperty(commandLine, key, (String) userProperties >+ .get(key)); >+ } >+ } >+ >+ // global >+ List properties = null; >+ if (!separateVM) { >+ properties = prefs.getProperties(); >+ } else { >+ properties = prefs.getRemoteAntProperties(); >+ } >+ >+ // if we have user properties this means that the user has chosen to >+ // override the global properties >+ // if in a separate VM and have only two (or three if debug) user >+ // properties these are really only Eclipse generated properties >+ // and the user is still using the global properties >+ int numberOfEclipseProperties = 2; >+ if (userProperties != null >+ && userProperties.get("eclipse.connect.request_port") != null) { //$NON-NLS-1$ >+ numberOfEclipseProperties = 3; // debug mode >+ } >+ boolean useGlobalProperties = userProperties == null >+ || (separateVM && userProperties.size() == numberOfEclipseProperties); >+ if (useGlobalProperties) { >+ for (Iterator iter = properties.iterator(); iter.hasNext();) { >+ Property property = (Property) iter.next(); >+ String key = property.getName(); >+ String value = property.getValue(false); >+ if (value != null) { >+ appendProperty(commandLine, key, value); >+ } >+ } >+ } >+ >+ if (basedir != null && basedir.length() > 0) { >+ appendProperty(commandLine, "basedir", basedir); //$NON-NLS-1$ >+ } >+ >+ if (antHome != null) { >+ commandLine.append(" \"-Dant.home="); //$NON-NLS-1$ >+ commandLine.append(antHome); >+ commandLine.append('\"'); >+ } >+ >+ if (separateVM) { >+ if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$ >+ if (captureOutput) { >+ commandLine.append(" -logger "); //$NON-NLS-1$ >+ if (fMode.equals(ILaunchManager.DEBUG_MODE)) { >+ commandLine.append(REMOTE_ANT_DEBUG_LOGGER_CLASS); >+ } else { >+ commandLine.append(REMOTE_ANT_LOGGER_CLASS); >+ } >+ } >+ } else { >+ fUserSpecifiedLogger = true; >+ } >+ if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$ >+ commandLine.append(" -inputhandler "); //$NON-NLS-1$ >+ commandLine.append(REMOTE_INPUT_HANDLER_CLASS); >+ } >+ } else { >+ if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$ >+ commandLine.append(" -inputhandler "); //$NON-NLS-1$ >+ commandLine.append(INPUT_HANDLER_CLASS); >+ } >+ if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$ >+ commandLine.append(" -logger "); //$NON-NLS-1$ >+ if (fMode.equals(ILaunchManager.DEBUG_MODE)) { >+ commandLine.append(ANT_DEBUG_LOGGER_CLASS); >+ } else if (captureOutput) { >+ commandLine.append(ANT_LOGGER_CLASS); >+ } else { >+ commandLine.append(NULL_LOGGER_CLASS); >+ } >+ } >+ } >+ >+ if (separateVM) { >+ appendTaskAndTypes(prefs, commandLine); >+ } >+ commandLine.append(" -buildfile \""); //$NON-NLS-1$ >+ commandLine.append(location.toOSString()); >+ commandLine.append('\"'); >+ >+ if (targets != null) { >+ for (int i = 0; i < targets.length; i++) { >+ commandLine.append(" \""); //$NON-NLS-1$ >+ commandLine.append(targets[i]); >+ commandLine.append('\"'); >+ } >+ } >+ return commandLine; >+ } >+ >+ private void appendTaskAndTypes(AntCorePreferences prefs, >+ StringBuffer commandLine) { >+ List tasks = prefs.getRemoteTasks(); >+ Iterator itr = tasks.iterator(); >+ while (itr.hasNext()) { >+ Task task = (Task) itr.next(); >+ commandLine.append(" -eclipseTask "); //$NON-NLS-1$ >+ String name = ProjectHelper.genComponentName(task.getURI(), task >+ .getTaskName()); >+ commandLine.append(name); >+ commandLine.append(','); >+ commandLine.append(task.getClassName()); >+ } >+ >+ List types = prefs.getRemoteTypes(); >+ itr = types.iterator(); >+ while (itr.hasNext()) { >+ Type type = (Type) itr.next(); >+ commandLine.append(" -eclipseType "); //$NON-NLS-1$ >+ String name = ProjectHelper.genComponentName(type.getURI(), type >+ .getTypeName()); >+ commandLine.append(name); >+ commandLine.append(','); >+ commandLine.append(type.getClassName()); >+ } >+ } >+ >+ private void appendProperty(StringBuffer commandLine, String name, >+ String value) { >+ commandLine.append(" \"-D"); //$NON-NLS-1$ >+ commandLine.append(name); >+ commandLine.append('='); >+ commandLine.append(value); >+ if (value.length() > 0 >+ && value.charAt(value.length() - 1) == File.separatorChar) { >+ commandLine.append(File.separatorChar); >+ } >+ commandLine.append("\""); //$NON-NLS-1$ >+ } >+ >+ 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 { >+ boolean debug = fMode.equals(ILaunchManager.DEBUG_MODE); >+ if (captureOutput) { >+ if (debug) { >+ RemoteAntDebugBuildListener listener = new RemoteAntDebugBuildListener( >+ launch); >+ if (requestPort != -1) { >+ listener.startListening(port, requestPort); >+ } >+ } else if (!fUserSpecifiedLogger) { >+ RemoteAntBuildListener client = new RemoteAntBuildListener( >+ launch); >+ if (port != -1) { >+ client.startListening(port); >+ } >+ } >+ } >+ >+ ILaunchConfigurationWorkingCopy copy = configuration.getWorkingCopy(); >+ setDefaultWorkingDirectory(copy); >+ copy.setAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, >+ commandLine.toString()); >+ StringBuffer vmArgs = generateVMArguments(copy, setInputHandler, >+ antHome); >+ copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, >+ vmArgs.toString()); >+ copy.setAttribute(ILaunchManager.ATTR_PRIVATE, true); >+ if (copy >+ .getAttribute( >+ IAntLaunchConfigurationConstants.ATTR_DEFAULT_VM_INSTALL, >+ false)) { >+ setDefaultVM(configuration, copy); >+ } >+ if (debug) { // do not allow launch in foreground bug 83254 >+ copy.setAttribute(ILaunchManager.ATTR_LAUNCH_IN_BACKGROUND, true); >+ } >+ >+ // set the ANT_HOME environment variable >+ if (antHome != null) { >+ Map vars = copy.getAttribute( >+ ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, new HashMap(1)); >+ vars.put("ANT_HOME", antHome); //$NON-NLS-1$ >+ copy.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, vars); >+ } >+ >+ // copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, >+ // "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"); >+ IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 10); >+ AntJavaLaunchDelegate delegate = new AntJavaLaunchDelegate(); >+ delegate.preLaunchCheck(copy, ILaunchManager.RUN_MODE, subMonitor); >+ delegate.launch(copy, ILaunchManager.RUN_MODE, launch, subMonitor); >+ final IProcess[] processes = launch.getProcesses(); >+ for (int i = 0; i < processes.length; i++) { >+ setProcessAttributes(processes[i], idStamp, null, captureOutput); >+ } >+ >+ if (LaunchManager.isLaunchInBackground(copy)) { >+ // refresh resources after process finishes >+ if (LaunchManager.getRefreshScope(configuration) != null) { >+ BackgroundResourceRefresher refresher = new BackgroundResourceRefresher( >+ configuration, processes[0]); >+ refresher.startBackgroundRefresh(); >+ } >+ } else { >+ final boolean[] terminated = new boolean[1]; >+ terminated[0] = launch.isTerminated(); >+ IDebugEventSetListener listener = new IDebugEventSetListener() { >+ public void handleDebugEvents(DebugEvent[] events) { >+ for (int i = 0; i < events.length; i++) { >+ DebugEvent event = events[i]; >+ for (int j = 0, numProcesses = processes.length; j < numProcesses; j++) { >+ if (event.getSource() == processes[j] >+ && event.getKind() == DebugEvent.TERMINATE) { >+ terminated[0] = true; >+ break; >+ } >+ } >+ } >+ } >+ }; >+ DebugPlugin.getDefault().addDebugEventListener(listener); >+ monitor >+ .subTask(AntLaunchConfigurationMessages.AntLaunchDelegate_28); >+ while (!monitor.isCanceled() && !terminated[0]) { >+ try { >+ Thread.sleep(50); >+ } catch (InterruptedException e) { >+ } >+ } >+ DebugPlugin.getDefault().removeDebugEventListener(listener); >+ if (!monitor.isCanceled()) { >+ // refresh resources >+ LaunchManager.refreshResources(configuration, monitor); >+ } >+ } >+ } >+ >+ private void setDefaultVM(ILaunchConfiguration configuration, >+ ILaunchConfigurationWorkingCopy copy) { >+ try { >+ JavaRuntime.getJavaProject(configuration); >+ // remove the vm name, install type and jre container path for the >+ // Java launching concept of default VM >+ copy.setAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, >+ (String) null); >+ copy.setAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, >+ (String) null); >+ copy.setAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, >+ (String) null); >+ } catch (CoreException ce) { >+ // not in a Java project >+ IVMInstall defaultVMInstall = JavaRuntime.getDefaultVMInstall(); >+ copy.setAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, >+ defaultVMInstall.getName()); >+ copy.setAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, >+ defaultVMInstall.getVMInstallType().getId()); >+ } >+ } >+ >+ private StringBuffer generateVMArguments(ILaunchConfiguration config, >+ boolean setInputHandler, String antHome) { >+ StringBuffer vmArgs = new StringBuffer(); >+ try { >+ String configArgs = config.getAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, >+ (String) null); >+ if (configArgs != null) { >+ vmArgs.append(configArgs); >+ vmArgs.append(' '); >+ } >+ } catch (CoreException e) { >+ } >+ >+ if (antHome != null) { >+ vmArgs.append("-Dant.home=\""); //$NON-NLS-1$ >+ vmArgs.append(antHome); >+ vmArgs.append("\" "); //$NON-NLS-1$ >+ >+ File antLibDir = new File(antHome, "lib"); //$NON-NLS-1$ >+ vmArgs.append("-Dant.library.dir=\""); //$NON-NLS-1$ >+ vmArgs.append(antLibDir.getAbsolutePath()); >+ vmArgs.append('\"'); >+ } >+ if (setInputHandler) { >+ String swtLocation = getSWTLibraryLocation(); >+ if (swtLocation != null) { >+ vmArgs.append(" -Djava.library.path=\""); //$NON-NLS-1$ >+ String javaLibPath = System.getProperty("java.library.path"); //$NON-NLS-1$ >+ javaLibPath = stripUnescapedQuotes(javaLibPath); >+ if (javaLibPath != null) { >+ vmArgs.append(javaLibPath); >+ if (vmArgs.charAt(vmArgs.length() - 1) != File.pathSeparatorChar) { >+ vmArgs.append(File.pathSeparatorChar); >+ } >+ } >+ vmArgs.append(swtLocation); >+ vmArgs.append('"'); >+ } >+ } >+ return vmArgs; >+ } >+ >+ private String stripUnescapedQuotes(String javaLibPath) { >+ StringBuffer buf = new StringBuffer(javaLibPath.length()); >+ for (int i = 0; i < javaLibPath.length(); i++) { >+ char c = javaLibPath.charAt(i); >+ switch (c) { >+ case '"': >+ if (i != 0 && javaLibPath.charAt(i - 1) == '\\') { >+ buf.append(c); >+ } >+ break; >+ default: >+ buf.append(c); >+ break; >+ } >+ } >+ return buf.toString(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder >+ * (org.eclipse.debug.core.ILaunchConfiguration, java.lang.String) >+ */ >+ protected IProject[] getBuildOrder(ILaunchConfiguration configuration, >+ String mode) throws CoreException { >+ IProject[] projects = ExternalToolsCoreUtil.getBuildProjects( >+ configuration, ATTR_BUILD_SCOPE); >+ if (projects == null) { >+ return NO_PROJECTS; >+ } >+ boolean isRef = ExternalToolsCoreUtil.isIncludeReferencedProjects( >+ configuration, ATTR_INCLUDE_REFERENCED_PROJECTS); >+ if (isRef) { >+ return computeReferencedBuildOrder(projects); >+ } >+ return computeBuildOrder(projects); >+ } >+ >+ private String getSWTLibraryLocation() { >+ if (fgSWTLibraryLocation == null) { >+ Bundle bundle = Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$ >+ BundleDescription description = Platform.getPlatformAdmin() >+ .getState(false).getBundle(bundle.getBundleId()); >+ BundleDescription[] fragments = description.getFragments(); >+ if (fragments == null || fragments.length == 0) { >+ return null; >+ } >+ Bundle fragBundle = Platform.getBundle(fragments[0] >+ .getSymbolicName()); >+ try { >+ URL url = FileLocator.toFileURL(fragBundle.getEntry("/")); //$NON-NLS-1$ >+ IPath path = new Path(url.getPath()); >+ path = path.removeTrailingSeparator(); >+ fgSWTLibraryLocation = path.toOSString(); >+ } catch (IOException e) { >+ } >+ } >+ return fgSWTLibraryLocation; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBreakpoints >+ * (org.eclipse.debug.core.ILaunchConfiguration) >+ */ >+ protected IBreakpoint[] getBreakpoints(ILaunchConfiguration configuration) { >+ IBreakpointManager breakpointManager = DebugPlugin.getDefault() >+ .getBreakpointManager(); >+ if (!breakpointManager.isEnabled()) { >+ // no need to check breakpoints individually. >+ return null; >+ } >+ return breakpointManager >+ .getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.debug.core.model.LaunchConfigurationDelegate#saveBeforeLaunch >+ * (org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, >+ * org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ protected boolean saveBeforeLaunch(ILaunchConfiguration configuration, >+ String mode, IProgressMonitor monitor) throws CoreException { >+ if (IExternalToolConstants.ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY >+ .equals(configuration.getType().getCategory())) { >+ // don't prompt for builders >+ return true; >+ } >+ return super.saveBeforeLaunch(configuration, mode, monitor); >+ } >+ >+ /** >+ * Sets the default working directory to be the parent folder of the >+ * buildfile if the user has not explicitly set the working directory. >+ */ >+ private void setDefaultWorkingDirectory(ILaunchConfigurationWorkingCopy copy) { >+ try { >+ String wd = copy.getAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, >+ (String) null); >+ if (wd == null) { >+ wd = ExternalToolsCoreUtil.getLocation(copy) >+ .removeLastSegments(1).toOSString(); >+ copy >+ .setAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, >+ wd); >+ } >+ } catch (CoreException e) { >+ AntLaunching.log(e.getStatus()); >+ } >+ } >+ >+ public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) >+ throws CoreException { >+ return new AntLaunch(configuration, mode, null); >+ } >+} >Index: src/org/eclipse/ant/internal/launching/debug/model/RemoteAntDebugBuildListener.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/model/RemoteAntDebugBuildListener.java >diff -N src/org/eclipse/ant/internal/launching/debug/model/RemoteAntDebugBuildListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/model/RemoteAntDebugBuildListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,321 @@ >+/******************************************************************************* >+ * Copyright (c) 2003, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.ant.internal.launching.debug.model; >+ >+import java.io.BufferedReader; >+import java.io.IOException; >+import java.io.InputStreamReader; >+import java.io.PrintWriter; >+import java.net.Socket; >+import java.net.UnknownHostException; >+ >+import org.eclipse.ant.internal.launching.AntLaunching; >+import org.eclipse.ant.internal.launching.debug.IAntDebugController; >+import org.eclipse.ant.internal.launching.launchConfigurations.RemoteAntBuildListener; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.DebugEvent; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.model.IBreakpoint; >+import org.eclipse.debug.core.model.ILineBreakpoint; >+import org.eclipse.debug.core.model.IProcess; >+ >+public class RemoteAntDebugBuildListener extends RemoteAntBuildListener implements IAntDebugController { >+ >+ // sockets to communicate with the remote Ant debug build logger >+ private Socket fRequestSocket; >+ private PrintWriter fRequestWriter; >+ private BufferedReader fResponseReader; >+ >+ private int fRequestPort= -1; >+ private Thread fReaderThread; >+ >+ private AntDebugTarget fTarget; >+ >+ /** >+ * Reader thread that processes request responses from the remote Ant debug build logger >+ */ >+ private class ReaderThread extends Thread { >+ public ReaderThread() { >+ super("Ant Request Response Reader Thread"); //$NON-NLS-1$ >+ setDaemon(true); >+ } >+ >+ public void run(){ >+ try { >+ String message= null; >+ while (fResponseReader != null) { >+ synchronized (RemoteAntDebugBuildListener.this) { >+ if (fResponseReader != null && (message= fResponseReader.readLine()) != null) { >+ receiveMessage(message); >+ } >+ } >+ } >+ } catch (IOException ie) { //the other end has shutdown >+ RemoteAntDebugBuildListener.this.shutDown(); >+ } catch (Exception e) { >+ AntLaunching.log("Internal error processing remote response", e); //$NON-NLS-1$ >+ RemoteAntDebugBuildListener.this.shutDown(); >+ } >+ } >+ } >+ >+ public RemoteAntDebugBuildListener(ILaunch launch) { >+ super(launch); >+ //fDebug= true; >+ } >+ >+ protected void receiveMessage(String message) { >+ if (message.startsWith(DebugMessageIds.BUILD_STARTED)) { >+ buildStarted(); >+ } else if (message.startsWith(DebugMessageIds.SUSPENDED)){ >+ handleSuspendMessage(message); >+ } else if (message.startsWith(DebugMessageIds.TERMINATED)){ >+ fTarget.terminated(); >+ } else if (message.startsWith(DebugMessageIds.STACK)){ >+ AntThread thread= (AntThread) fTarget.getThreads()[0]; >+ thread.buildStack(message); >+ } else if (message.startsWith(DebugMessageIds.PROPERTIES)){ >+ AntThread thread= (AntThread) fTarget.getThreads()[0]; >+ thread.newProperties(message); >+ } else { >+ super.receiveMessage(message); >+ } >+ } >+ >+ private void handleSuspendMessage(String message) { >+ if (message.endsWith(DebugMessageIds.CLIENT_REQUEST)) { >+ fTarget.suspended(DebugEvent.CLIENT_REQUEST); >+ } else if (message.endsWith(DebugMessageIds.STEP)) { >+ fTarget.suspended(DebugEvent.STEP_END); >+ } else if (message.indexOf(DebugMessageIds.BREAKPOINT) >= 0) { >+ fTarget.breakpointHit(message); >+ } >+ } >+ >+ private void buildStarted() { >+ IProcess process= getProcess(); >+ while(process == null) { >+ try { >+ synchronized (this) { >+ wait(400); >+ } >+ process= getProcess(); >+ } catch (InterruptedException ie) { >+ } >+ } >+ fTarget= new AntDebugTarget(fLaunch, process, this); >+ fLaunch.addDebugTarget(fTarget); >+ >+ if (!connectRequest()) { >+ RemoteAntDebugBuildListener.this.shutDown(); >+ return; >+ } >+ >+ fTarget.buildStarted(); >+ } >+ >+ private boolean connectRequest() { >+ Exception exception= null; >+ for (int i= 1; i < 20; i++) { >+ try { >+ fRequestSocket = new Socket("localhost", fRequestPort); //$NON-NLS-1$ >+ fRequestWriter = new PrintWriter(fRequestSocket.getOutputStream(), true); >+ fResponseReader = new BufferedReader(new InputStreamReader(fRequestSocket.getInputStream())); >+ >+ fReaderThread= new ReaderThread(); >+ fReaderThread.start(); >+ return true; >+ } catch (UnknownHostException e) { >+ exception= e; >+ break; >+ } catch (IOException e) { >+ exception= e; >+ } >+ try { >+ Thread.sleep(500); >+ } catch(InterruptedException e) { >+ } >+ } >+ AntLaunching.log("Internal error attempting to connect to debug target", exception); //$NON-NLS-1$ >+ return false; >+ } >+ >+ /** >+ * Start listening to an Ant build. Start a server connection that >+ * the RemoteAntDebugBuildLogger can connect to. >+ * >+ * @param eventPort The port number to create the server connection on >+ * @param requestPort The port number to use for sending requests to the remote logger >+ */ >+ public synchronized void startListening(int eventPort, int requestPort) { >+ super.startListening(eventPort); >+ fRequestPort= requestPort; >+ } >+ >+ /** >+ * Sends a request to the Ant build >+ * >+ * @param request debug command >+ */ >+ protected void sendRequest(String request) { >+ if (fRequestSocket == null) { >+ return; >+ } >+ synchronized (fRequestSocket) { >+ fRequestWriter.println(request); >+ } >+ } >+ >+ protected synchronized void shutDown() { >+ if (fTarget != null) { >+ fTarget.terminated(); >+ fTarget= null; >+ } >+ fLaunch= null; >+ if (DebugPlugin.getDefault() != null) { >+ DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this); >+ } >+ try { >+ if (fReaderThread != null) { >+ // interrupt reader thread so that we don't block on close >+ // on a lock held by the BufferedReader >+ // see bug: 38955 >+ fReaderThread.interrupt(); >+ } >+ if (fResponseReader != null) { >+ fResponseReader.close(); >+ fResponseReader= null; >+ } >+ } catch(IOException e) { >+ } >+ if (fRequestWriter != null) { >+ fRequestWriter.close(); >+ fRequestWriter= null; >+ } >+ try{ >+ if(fRequestSocket != null) { >+ fRequestSocket.close(); >+ fRequestSocket= null; >+ } >+ } catch(IOException e) { >+ } >+ super.shutDown(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#resume() >+ */ >+ public void resume() { >+ sendRequest(DebugMessageIds.RESUME); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#suspend() >+ */ >+ public void suspend() { >+ sendRequest(DebugMessageIds.SUSPEND); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#stepInto() >+ */ >+ public void stepInto() { >+ sendRequest(DebugMessageIds.STEP_INTO); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#stepOver() >+ */ >+ public void stepOver() { >+ sendRequest(DebugMessageIds.STEP_OVER); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#handleBreakpoint(IBreakpoint, boolean) >+ */ >+ public void handleBreakpoint(IBreakpoint breakpoint, boolean add) { >+ if (fTarget == null || !fTarget.supportsBreakpoint(breakpoint)) { >+ return; >+ } >+ StringBuffer message= new StringBuffer(); >+ if (add) { >+ try { >+ if (!breakpoint.isEnabled()) { >+ return; >+ } >+ } catch (CoreException e) { >+ AntLaunching.log(e); >+ return; >+ } >+ message.append(DebugMessageIds.ADD_BREAKPOINT); >+ } else { >+ message.append(DebugMessageIds.REMOVE_BREAKPOINT); >+ } >+ message.append(DebugMessageIds.MESSAGE_DELIMITER); >+ message.append(breakpoint.getMarker().getResource().getLocation().toOSString()); >+ message.append(DebugMessageIds.MESSAGE_DELIMITER); >+ try { >+ message.append(((ILineBreakpoint)breakpoint).getLineNumber()); >+ sendRequest(message.toString()); >+ } catch (CoreException ce) { >+ AntLaunching.log(ce); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#getProperties() >+ */ >+ public void getProperties() { >+ sendRequest(DebugMessageIds.PROPERTIES); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#getStackFrames() >+ */ >+ public void getStackFrames() { >+ sendRequest(DebugMessageIds.STACK); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#unescapeString(java.lang.StringBuffer) >+ */ >+ public StringBuffer unescapeString(StringBuffer property) { >+ if (property.indexOf("\\r") == -1 && property.indexOf("\\n") == -1) { //$NON-NLS-1$ //$NON-NLS-2$ >+ return property; >+ } >+ for (int i= 0; i < property.length(); i++) { >+ if ('\\' == property.charAt(i)) { >+ String newString= ""; //$NON-NLS-1$ >+ if ('r' == property.charAt(i + 1)) { >+ if (i-1 > - 1 && '\\' == property.charAt(i-1)) { >+ newString= "r"; //$NON-NLS-1$ >+ } else { >+ newString+= '\r'; >+ } >+ } else if ('n' == property.charAt(i + 1)) { >+ if (i-1 > - 1 && '\\' == property.charAt(i-1)) { >+ newString= "n"; //$NON-NLS-1$ >+ } else { >+ newString+= '\n'; >+ } >+ >+ } >+ if (newString.length() > 0) { >+ property.replace(i, i + 2, newString); >+ } >+ } >+ } >+ >+ return property; >+ } >+} >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/AntCoreModelMessages.properties >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/AntCoreModelMessages.properties >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/AntCoreModelMessages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/AntCoreModelMessages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,14 @@ >+############################################################################### >+# Copyright (c) 2000, 2005 IBM Corporation and others. >+# All rights reserved. This program and the accompanying materials >+# are made available under the terms of the Eclipse Public License v1.0 >+# which accompanies this distribution, and is available at >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# IBM Corporation - initial API and implementation >+############################################################################### >+ >+AntUtil_6=Invalid property file entry: {0} >+AntUtil_7=Unable to generate Ant classpath >+AntUtil_2=Error reading launch configuration >Index: src/org/eclipse/ant/internal/launching/AntLaunchingPreferenceInitializer.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/AntLaunchingPreferenceInitializer.java >diff -N src/org/eclipse/ant/internal/launching/AntLaunchingPreferenceInitializer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/AntLaunchingPreferenceInitializer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching; >+ >+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; >+import org.eclipse.core.runtime.preferences.DefaultScope; >+import org.eclipse.core.runtime.preferences.IEclipsePreferences; >+ >+public class AntLaunchingPreferenceInitializer extends >+ AbstractPreferenceInitializer { >+ >+ public AntLaunchingPreferenceInitializer() { >+ super(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @seeorg.eclipse.core.runtime.preferences.AbstractPreferenceInitializer# >+ * initializeDefaultPreferences() >+ */ >+ public void initializeDefaultPreferences() { >+ >+ IEclipsePreferences node = new DefaultScope() >+ .getNode("org.eclipse.ant.launching"); //$NON-NLS-1$ >+ node.put(IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT, >+ "20000"); //$NON-NLS-1$ >+ } >+} >Index: src/org/eclipse/ant/internal/launching/LinkDescriptor.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/LinkDescriptor.java >diff -N src/org/eclipse/ant/internal/launching/LinkDescriptor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/LinkDescriptor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,60 @@ >+package org.eclipse.ant.internal.launching; >+ >+public class LinkDescriptor { >+ String line; >+ String fileName; >+ int lineNumber; >+ int offset; >+ int length; >+ >+ public LinkDescriptor(String line, String fileName, int lineNumber, >+ int offset, int length) { >+ super(); >+ this.line = line; >+ this.fileName = fileName; >+ this.lineNumber = lineNumber; >+ this.offset = offset; >+ this.length = length; >+ } >+ >+ public String getLine() { >+ return line; >+ } >+ >+ public void setLine(String line) { >+ this.line = line; >+ } >+ >+ public String getFileName() { >+ return fileName; >+ } >+ >+ public void setFileName(String fileName) { >+ this.fileName = fileName; >+ } >+ >+ public int getLineNumber() { >+ return lineNumber; >+ } >+ >+ public void setLineNumber(int lineNumber) { >+ this.lineNumber = lineNumber; >+ } >+ >+ public int getOffset() { >+ return offset; >+ } >+ >+ public void setOffset(int offset) { >+ this.offset = offset; >+ } >+ >+ public int getLength() { >+ return length; >+ } >+ >+ public void setLength(int length) { >+ this.length = length; >+ } >+ >+} >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/AntHomeClasspathEntry.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/AntHomeClasspathEntry.java >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/AntHomeClasspathEntry.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/AntHomeClasspathEntry.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,209 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.launchConfigurations; >+ >+import java.io.File; >+import com.ibm.icu.text.MessageFormat; >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.ant.core.AntCorePlugin; >+import org.eclipse.ant.core.AntCorePreferences; >+import org.eclipse.ant.core.IAntClasspathEntry; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry; >+import org.eclipse.jdt.launching.IRuntimeClasspathEntry; >+import org.eclipse.jdt.launching.JavaRuntime; >+import org.w3c.dom.Document; >+import org.w3c.dom.Element; >+ >+/** >+ * A classpath entry that contains a set of archives for a particular >+ * ANT_HOME. >+ * >+ * @since 3.0 >+ */ >+public class AntHomeClasspathEntry extends AbstractRuntimeClasspathEntry { >+ >+ public static final String TYPE_ID = "org.eclipse.ant.ui.classpathentry.antHome"; //$NON-NLS-1$ >+ >+ /** >+ * Local path on disk where Ant Home is located or <code>null</code> >+ * to indicate the use of the default Ant Home. >+ */ >+ private String antHomeLocation = null; >+ >+ /** >+ * Creates an AntHome entry for the default AntHome installation. >+ */ >+ public AntHomeClasspathEntry() { >+ antHomeLocation = null; >+ } >+ >+ /** >+ * Constructs an AntHome entry for the Ant installed at the specified >+ * root directory. >+ * >+ * @param antHome path in the local file system to an Ant installation >+ */ >+ public AntHomeClasspathEntry(String antHome) { >+ antHomeLocation = antHome; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element) >+ */ >+ protected void buildMemento(Document document, Element memento) throws CoreException { >+ if (antHomeLocation == null) { >+ memento.setAttribute("default", "true"); //$NON-NLS-1$//$NON-NLS-2$ >+ } else { >+ memento.setAttribute("antHome", new Path(antHomeLocation).toString()); //$NON-NLS-1$ >+ } >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element) >+ */ >+ public void initializeFrom(Element memento) throws CoreException { >+ String antHome = memento.getAttribute("antHome"); //$NON-NLS-1$ >+ if (antHome != null && (antHome.length() > 0)) { >+ IPath path = new Path(antHome); >+ antHomeLocation = path.toOSString(); >+ } else { >+ antHomeLocation = null; >+ } >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId() >+ */ >+ public String getTypeId() { >+ return TYPE_ID; >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration) >+ */ >+ public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException { >+ List libs = new ArrayList(40); >+ AntCorePreferences preferences = AntCorePlugin.getPlugin().getPreferences(); >+ if (antHomeLocation == null) { >+ IAntClasspathEntry[] entries = preferences.getAntHomeClasspathEntries(); >+ for (int i = 0; i < entries.length; i++) { >+ IAntClasspathEntry entry = entries[i]; >+ libs.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel())); >+ } >+ } else { >+ File lib= resolveAntHome(); >+ IPath libDir = new Path(antHomeLocation).append("lib"); //$NON-NLS-1$ >+ String[] fileNames = lib.list(); >+ for (int i = 0; i < fileNames.length; i++) { >+ String name = fileNames[i]; >+ IPath path = new Path(name); >+ String fileExtension = path.getFileExtension(); >+ if ("jar".equalsIgnoreCase(fileExtension)) { //$NON-NLS-1$ >+ libs.add(JavaRuntime.newArchiveRuntimeClasspathEntry(libDir.append(path))); >+ } >+ } >+ } >+ return (IRuntimeClasspathEntry[]) libs.toArray(new IRuntimeClasspathEntry[libs.size()]); >+ } >+ >+ public File resolveAntHome() throws CoreException { >+ if (antHomeLocation == null) { //using the default ant home >+ return null; >+ } >+ IPath libDir= new Path(antHomeLocation).append("lib"); //$NON-NLS-1$ >+ File lib= libDir.toFile(); >+ File parentDir= lib.getParentFile(); >+ if (parentDir == null || !parentDir.exists()) { >+ abort(MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_10, new String[] {antHomeLocation}), null); >+ } >+ if (!lib.exists() || !lib.isDirectory()) { >+ abort(MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_11, new String[] {antHomeLocation}), null); >+ } >+ return lib; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName() >+ */ >+ public String getName() { >+ if (antHomeLocation == null) { >+ return AntLaunchConfigurationMessages.AntHomeClasspathEntry_8; >+ } >+ return MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_9, new String[]{antHomeLocation}); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType() >+ */ >+ public int getType() { >+ return IRuntimeClasspathEntry.OTHER; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#isComposite() >+ */ >+ public boolean isComposite() { >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see java.lang.Object#equals(java.lang.Object) >+ */ >+ public boolean equals(Object obj) { >+ return obj instanceof AntHomeClasspathEntry && >+ equalsOrNull(antHomeLocation, ((AntHomeClasspathEntry)obj).antHomeLocation); >+ } >+ >+ /** >+ * Return whether s1 is equivalent to s2. >+ * >+ * @param s1 >+ * @param s2 >+ * @return whether s1 is equivalent to s2 >+ */ >+ private boolean equalsOrNull(String s1, String s2) { >+ if (s1 == null || s2 == null) { >+ return s1 == s2; >+ } >+ return s1.equalsIgnoreCase(s2); >+ } >+ >+ /* (non-Javadoc) >+ * @see java.lang.Object#hashCode() >+ */ >+ public int hashCode() { >+ return getClass().hashCode(); >+ } >+ >+ /** >+ * Sets the ant home to use. >+ * >+ * @param path path to toor of an ant home installation >+ */ >+ public void setAntHome(String path) { >+ antHomeLocation = path; >+ } >+ >+ /** >+ * Returns the ant home location >+ * >+ * @return path to root ant installation directory >+ */ >+ public String getAntHome() { >+ if (antHomeLocation == null) { >+ return AntCorePlugin.getPlugin().getPreferences().getAntHome(); >+ } >+ return antHomeLocation; >+ } >+} >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchConfigurationMessages.properties >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchConfigurationMessages.properties >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchConfigurationMessages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchConfigurationMessages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,26 @@ >+############################################################################### >+# Copyright (c) 2000, 2007 IBM Corporation and others. >+# All rights reserved. This program and the accompanying materials >+# are made available under the terms of the Eclipse Public License v1.0 >+# which accompanies this distribution, and is available at >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# IBM Corporation - initial API and implementation >+# dakshinamurthy.karra@gmail.com - bug 165371 >+############################################################################### >+ >+AntLaunchDelegate_Launching__0__1=Launching {0} >+AntLaunchDelegate_Running__0__2=Running {0} >+AntLaunchDelegate_Build_In_Progress=Ant build {0} already in progress. Concurrent Ant builds are possible if you specify to build in a separate JRE. >+AntLaunchDelegate_Failure=Failure of Background Ant Build >+AntLaunchDelegate_22=&Do not show error dialog when Ant build fails >+AntLaunchDelegate_23=Ant Build Failed >+AntLaunchDelegate_28=Waiting for virtual machine to exit... >+ >+AntHomeClasspathEntry_8=Ant Home (Default) >+AntHomeClasspathEntry_9=Ant Home ({0}) >+AntHomeClasspathEntry_10=Ant Home {0} does not exist >+AntHomeClasspathEntry_11=Ant Home {0} does not contain a "lib" directory >+ >+ContributedClasspathEntriesEntry_1=Additional Tasks & Support >\ No newline at end of file >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/AntCoreModelMessages.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/AntCoreModelMessages.java >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/AntCoreModelMessages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/AntCoreModelMessages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+/********************************************************************** >+ * Copyright (c) 2000, 2005 IBM Corporation and others. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.ant.internal.launching.launchConfigurations; >+ >+import org.eclipse.osgi.util.NLS; >+ >+public class AntCoreModelMessages extends NLS { >+ private static final String BUNDLE_NAME = "org.eclipse.ant.internal.launching.launchConfigurations.AntCoreModelMessages";//$NON-NLS-1$ >+ >+ public static String AntUtil_6; >+ public static String AntUtil_7; >+ public static String AntUtil_2; >+ >+ static { >+ // load message values from bundle file >+ NLS.initializeMessages(BUNDLE_NAME, AntCoreModelMessages.class); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,410 @@ >+/******************************************************************************* >+ * Copyright (c) 2003, 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.ant.internal.launching.launchConfigurations; >+ >+import java.io.BufferedReader; >+import java.io.File; >+import java.io.IOException; >+import java.io.InputStreamReader; >+import java.net.ServerSocket; >+import java.net.Socket; >+import java.net.SocketException; >+import java.net.SocketTimeoutException; >+import java.util.ArrayList; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+import java.util.StringTokenizer; >+ >+import org.apache.tools.ant.Project; >+import org.apache.tools.ant.util.FileUtils; >+import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger; >+import org.eclipse.ant.internal.launching.AntLaunch; >+import org.eclipse.ant.internal.launching.AntLaunching; >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; >+import org.eclipse.ant.internal.launching.IAntLaunchingPreferenceConstants; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.ISafeRunnable; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.preferences.IEclipsePreferences; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.ILaunchesListener; >+import org.eclipse.debug.core.model.IProcess; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.text.Region; >+ >+ >+/** >+ * Parts adapted from org.eclipse.jdt.internal.junit.ui.RemoteTestRunnerClient >+ * The client side of the RemoteAntBuildLogger. Handles the marshalling of the >+ * different messages. >+ */ >+public class RemoteAntBuildListener implements ILaunchesListener { >+ public abstract class ListenerSafeRunnable implements ISafeRunnable { >+ public void handleException(Throwable exception) { >+ AntLaunching.log(exception); >+ } >+ } >+ >+ /** >+ * The server socket >+ */ >+ private ServerSocket fServerSocket; >+ private Socket fSocket; >+ private BufferedReader fBufferedReader; >+ private IProcess fProcess; >+ private String fProcessId; >+ private File fBuildFileParent = null; >+ private List fMessageQueue; >+ protected ILaunch fLaunch; >+ private Map fFileNameToIFile = new HashMap(); >+ private String fLastFileName = null; >+ private String fLastTaskName = null; >+ private boolean fBuildFailed = false; >+ >+ /** >+ * Reads the message stream from the RemoteAntBuildLogger >+ */ >+ private class ServerConnection extends Thread { >+ private int fServerPort; >+ >+ public ServerConnection(int port) { >+ super("Ant Build Server Connection"); //$NON-NLS-1$ >+ setDaemon(true); >+ fServerPort = port; >+ } >+ >+ public void run() { >+ Exception exception = null; >+ try { >+ fServerSocket = new ServerSocket(fServerPort); >+ >+ int socketTimeout = Platform >+ .getPreferencesService() >+ .getInt( >+ AntLaunching.getUniqueIdentifier(), >+ IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT, >+ 20000, null); >+ fServerSocket.setSoTimeout(socketTimeout); >+ fSocket = fServerSocket.accept(); >+ fBufferedReader = new BufferedReader(new InputStreamReader( >+ fSocket.getInputStream(), "UTF-8")); //$NON-NLS-1$ >+ String message; >+ while (fBufferedReader != null >+ && (message = fBufferedReader.readLine()) != null) { >+ receiveMessage(message); >+ } >+ } catch (SocketException e) { >+ } catch (SocketTimeoutException e) { >+ exception = e; >+ } catch (IOException e) { >+ // fall through >+ exception = e; >+ } >+ if (exception != null) { >+ AntLaunching.log(exception); >+ } >+ shutDown(); >+ } >+ } >+ >+ public RemoteAntBuildListener(ILaunch launch) { >+ super(); >+ fLaunch = launch; >+ DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this); >+ } >+ >+ /** >+ * Start listening to an Ant build. Start a server connection that the >+ * RemoteAntBuildLogger can connect to. >+ * >+ * @param eventPort >+ * The port number to create the server connection on >+ */ >+ public synchronized void startListening(int eventPort) { >+ ServerConnection connection = new ServerConnection(eventPort); >+ connection.start(); >+ } >+ >+ protected synchronized void shutDown() { >+ fLaunch = null; >+ fFileNameToIFile = null; >+ if (DebugPlugin.getDefault() != null) { >+ DebugPlugin.getDefault().getLaunchManager().removeLaunchListener( >+ this); >+ } >+ try { >+ if (fBufferedReader != null) { >+ fBufferedReader.close(); >+ fBufferedReader = null; >+ } >+ } catch (IOException e) { >+ } >+ try { >+ if (fSocket != null) { >+ fSocket.close(); >+ fSocket = null; >+ } >+ } catch (IOException e) { >+ } >+ try { >+ if (fServerSocket != null) { >+ fServerSocket.close(); >+ fServerSocket = null; >+ } >+ } catch (IOException e) { >+ } >+ } >+ >+ protected void receiveMessage(String message) { >+ if (message.startsWith(MessageIds.TASK)) { >+ receiveTaskMessage(message); >+ } else if (message.startsWith(MessageIds.TARGET)) { >+ receiveTargetMessage(message); >+ } else if (message.startsWith(MessageIds.PROCESS_ID)) { >+ message = message.substring(MessageIds.PROCESS_ID.length()); >+ fProcessId = message; >+ } else { >+ int index = message.indexOf(','); >+ if (index > 0) { >+ int priority = Integer.parseInt(message.substring(0, index)); >+ message = message.substring(index + 1); >+ writeMessage( >+ message + System.getProperty("line.separator"), priority); //$NON-NLS-1$ >+ if (message.startsWith("BUILD FAILED")) { //$NON-NLS-1$ >+ fBuildFailed = true; >+ } else if (fBuildFailed) { >+ if (message.startsWith("Total time:")) { //$NON-NLS-1$ >+ fBuildFailed = false; >+ } else { >+ AntLaunchingUtil.linkBuildFailedMessage(message, getProcess()); >+ } >+ } >+ >+ } >+ } >+ } >+ >+ private void receiveTargetMessage(String message) { >+ message = message.substring(MessageIds.TARGET.length()); >+ StringTokenizer tokenizer = new StringTokenizer(message, ","); //$NON-NLS-1$ >+ message = tokenizer.nextToken(); >+ if (tokenizer.hasMoreTokens()) { >+ int locationLength = Integer.parseInt(tokenizer.nextToken()); >+ String location = tokenizer.nextToken(); >+ while (location.length() < locationLength) { // path with a comma in >+ // it >+ location += ","; //$NON-NLS-1$ >+ location += tokenizer.nextToken(); >+ } >+ int lineNumber = Integer.parseInt(tokenizer.nextToken()); >+ generateLink(message, location, lineNumber, 0, message.length() - 1); >+ } >+ writeMessage( >+ message + System.getProperty("line.separator"), Project.MSG_INFO); //$NON-NLS-1$ >+ } >+ >+ private void receiveTaskMessage(String message) { >+ message = message.substring(MessageIds.TASK.length()); >+ >+ int index = message.indexOf(','); >+ int priority = Integer.parseInt(message.substring(0, index)); >+ int index2 = message.indexOf(',', index + 1); >+ String taskName = message.substring(index + 1, index2); >+ if (taskName.length() == 0) { >+ taskName = fLastTaskName; >+ } >+ int index3 = message.indexOf(',', index2 + 1); >+ int lineLength = Integer >+ .parseInt(message.substring(index2 + 1, index3)); >+ int index4 = index3 + 1 + lineLength; >+ >+ String line = message.substring(index3 + 1, index4); >+ StringBuffer labelBuff = new StringBuffer(); >+ labelBuff.append('['); >+ labelBuff.append(taskName); >+ labelBuff.append("] "); //$NON-NLS-1$ >+ labelBuff.append(line); >+ line = labelBuff.toString(); >+ >+ fLastTaskName = taskName; >+ >+ int locationIndex = message.indexOf(',', index4 + 1); >+ int finalIndex = locationIndex + 1; >+ String fileName = message.substring(index4 + 1, locationIndex); >+ int locationLength = 0; >+ if (fileName.length() == 0) { >+ fileName = fLastFileName; >+ } else { >+ finalIndex = message.indexOf(',', locationIndex) + 1; >+ locationLength = Integer.parseInt(fileName); >+ fileName = message.substring(finalIndex, finalIndex >+ + locationLength); >+ locationLength += 1; // set past delimiter >+ } >+ fLastFileName = fileName; >+ int lineNumber = Integer.parseInt(message.substring(finalIndex >+ + locationLength)); >+ >+ int size = 10;//IAntUIConstants.LEFT_COLUMN_SIZE - (taskName.length() + 3); >+ int offset = Math.max(size - 2, 1); >+ int length = 100;//IAntUIConstants.LEFT_COLUMN_SIZE - size - 3; >+ if (fileName != null) { >+ generateLink(line, fileName, lineNumber, offset, length); >+ } >+ >+ StringBuffer fullMessage = new StringBuffer(); >+ adornMessage(taskName, line, fullMessage); >+ writeMessage( >+ fullMessage >+ .append(System.getProperty("line.separator")).toString(), priority); //$NON-NLS-1$ >+ } >+ >+ private void generateLink(String line, String fileName, int lineNumber, >+ int offset, int length) { >+ ((AntLaunch)fLaunch).addLinkDescriptor(line, fileName, lineNumber, offset, length); >+ } >+ >+ /** >+ * Returns the associated process, finding it if necessary. >+ */ >+ protected IProcess getProcess() { >+ if (fProcess == null) { >+ if (fProcessId != null) { >+ IProcess[] all = DebugPlugin.getDefault().getLaunchManager() >+ .getProcesses(); >+ for (int i = 0; i < all.length; i++) { >+ IProcess process = all[i]; >+ if (fProcessId >+ .equals(process >+ .getAttribute(AbstractEclipseBuildLogger.ANT_PROCESS_ID))) { >+ fProcess = process; >+ break; >+ } >+ } >+ } >+ } >+ return fProcess; >+ } >+ >+ private AntStreamMonitor getMonitor(int priority) { >+ IProcess process = getProcess(); >+ if (process == null) { >+ return null; >+ } >+ AntStreamsProxy proxy = (AntStreamsProxy) process.getStreamsProxy(); >+ if (proxy == null) { >+ return null; >+ } >+ AntStreamMonitor monitor = null; >+ switch (priority) { >+ case Project.MSG_INFO: >+ monitor = (AntStreamMonitor) proxy.getOutputStreamMonitor(); >+ break; >+ case Project.MSG_ERR: >+ monitor = (AntStreamMonitor) proxy.getErrorStreamMonitor(); >+ break; >+ case Project.MSG_DEBUG: >+ monitor = (AntStreamMonitor) proxy.getDebugStreamMonitor(); >+ break; >+ case Project.MSG_WARN: >+ monitor = (AntStreamMonitor) proxy.getWarningStreamMonitor(); >+ break; >+ case Project.MSG_VERBOSE: >+ monitor = (AntStreamMonitor) proxy.getVerboseStreamMonitor(); >+ break; >+ } >+ return monitor; >+ } >+ >+ /** >+ * Builds a right justified task prefix for the given build event, placing >+ * it in the given string buffer. >+ * >+ * @param event >+ * build event >+ * @param fullMessage >+ * buffer to place task prefix in >+ */ >+ private void adornMessage(String taskName, String line, >+ StringBuffer fullMessage) { >+// if (taskName == null) { >+// taskName = "null"; //$NON-NLS-1$ >+// } >+// >+// int size = IAntUIConstants.LEFT_COLUMN_SIZE - (taskName.length() + 6); >+// for (int i = 0; i < size; i++) { >+// fullMessage.append(' '); >+// } >+// >+// fullMessage.append(line); >+ } >+ >+ protected void writeMessage(String message, int priority) { >+ AntStreamMonitor monitor = getMonitor(priority); >+ if (monitor == null) { >+ if (fMessageQueue == null) { >+ fMessageQueue = new ArrayList(); >+ } >+ fMessageQueue.add(message); >+ return; >+ } >+ if (fMessageQueue != null) { >+ for (Iterator iter = fMessageQueue.iterator(); iter.hasNext();) { >+ String oldMessage = (String) iter.next(); >+ monitor.append(oldMessage); >+ } >+ fMessageQueue = null; >+ } >+ monitor.append(message); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.debug.core.ILaunchesListener#launchesAdded(org.eclipse.debug >+ * .core.ILaunch[]) >+ */ >+ public void launchesAdded(ILaunch[] launches) { >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.debug.core.ILaunchesListener#launchesChanged(org.eclipse. >+ * debug.core.ILaunch[]) >+ */ >+ public void launchesChanged(ILaunch[] launches) { >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.debug.core.ILaunchesListener#launchesRemoved(org.eclipse. >+ * debug.core.ILaunch[]) >+ */ >+ public void launchesRemoved(ILaunch[] launches) { >+ for (int i = 0; i < launches.length; i++) { >+ ILaunch launch = launches[i]; >+ if (launch.equals(fLaunch)) { >+ shutDown(); >+ return; >+ } >+ } >+ } >+} >\ No newline at end of file >Index: plugin.xml >=================================================================== >RCS file: plugin.xml >diff -N plugin.xml >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ plugin.xml 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,59 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<?eclipse version="3.4"?> >+<plugin> >+ <extension >+ point="org.eclipse.debug.core.launchConfigurationTypes"> >+ <launchConfigurationType >+ category="org.eclipse.ui.externaltools" >+ delegate="org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate" >+ delegateDescription="%AntLaunchDelegate.description" >+ delegateName="%AntLaunchDelegate.name" >+ id="org.eclipse.ant.AntLaunchConfigurationType" >+ migrationDelegate="org.eclipse.ant.internal.launching.launchConfigurations.AntMigrationDelegate" >+ modes="run, debug" >+ name="%AntBuild" >+ sourceLocatorId="org.eclipse.ant.ui.debug.sourceLookupDirector" >+ sourcePathComputerId="org.eclipse.ant.ui.debug.sourcePathComputer"> >+ </launchConfigurationType> >+ <launchConfigurationType >+ category="org.eclipse.ui.externaltools.builder" >+ delegate="org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate" >+ delegateDescription="%AntBuilderLaunchDelegate.description" >+ delegateName="%AntBuilderLaunchDelegate.name" >+ id="org.eclipse.ant.AntBuilderLaunchConfigurationType" >+ modes="run" >+ name="%AntBuilder.name"> >+ </launchConfigurationType> >+ </extension> >+ <extension point="org.eclipse.core.runtime.preferences"> >+ <initializer class="org.eclipse.ant.internal.launching.AntLaunchingPreferenceInitializer"/> >+ </extension> >+ <extension >+ point="org.eclipse.jdt.launching.runtimeClasspathEntries"> >+ <runtimeClasspathEntry >+ class="org.eclipse.ant.internal.launching.launchConfigurations.AntHomeClasspathEntry" >+ id="org.eclipse.antui.classpathentry.antHome"> >+ </runtimeClasspathEntry> >+ <runtimeClasspathEntry >+ class="org.eclipse.ant.internal.launching.launchConfigurations.ContributedClasspathEntriesEntry" >+ id="org.eclipse.ant.ui.classpathentry.extraClasspathEntries"> >+ </runtimeClasspathEntry> >+ </extension> >+ <extension >+ point="org.eclipse.jdt.launching.classpathProviders"> >+ <classpathProvider >+ class="org.eclipse.ant.internal.launching.launchConfigurations.AntClasspathProvider" >+ id="org.eclipse.ant.ui.AntClasspathProvider"> >+ </classpathProvider> >+ </extension> >+ <extension >+ point="org.eclipse.debug.core.processFactories"> >+ <processFactory >+ class="org.eclipse.ant.internal.launching.launchConfigurations.RemoteAntProcessFactory" >+ id="org.eclipse.ant.ui.remoteAntProcessFactory"> >+ </processFactory> >+ </extension> >+ <extension point="org.eclipse.core.runtime.preferences"> >+ <initializer class="org.eclipse.ant.internal.launching.AntLaunchingPreferenceInitializer"/> >+ </extension> >+</plugin> >Index: src/org/eclipse/ant/internal/launching/debug/IAntDebugConstants.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/IAntDebugConstants.java >diff -N src/org/eclipse/ant/internal/launching/debug/IAntDebugConstants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/IAntDebugConstants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,33 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.ant.internal.launching.debug; >+ >+public interface IAntDebugConstants { >+ >+ /** >+ * Unique identifier for the Ant debug model (value >+ * <code>org.eclipse.ant.ui.debug</code>). >+ */ >+ public static final String ID_ANT_DEBUG_MODEL = "org.eclipse.ant.ui.debug"; //$NON-NLS-1$ >+ >+ /** >+ * Unique identifier for the Ant line breakpoint markers >+ * (value <code>org.eclipse.ant.ui.antLineBreakpointMarker</code>). >+ */ >+ public static final String ID_ANT_LINE_BREAKPOINT_MARKER= "org.eclipse.ant.ui.antLineBreakpointMarker"; //$NON-NLS-1$ >+ >+ /** >+ * Unique identifier for the Ant run to line breakpoints >+ * (value <code>org.eclipse.ant.ui.runToLineBreakpoint</code>). >+ */ >+ public static final String ANT_RUN_TO_LINE= "org.eclipse.ant.ui.runToLineBreakpoint"; //$NON-NLS-1$ >+} >Index: src/org/eclipse/ant/internal/launching/debug/model/DebugMessageIds.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/model/DebugMessageIds.java >diff -N src/org/eclipse/ant/internal/launching/debug/model/DebugMessageIds.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/model/DebugMessageIds.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,48 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.debug.model; >+ >+public class DebugMessageIds { >+ >+ public final static String MESSAGE_DELIMITER= ","; //$NON-NLS-1$ >+ >+ public final static String BUILD_STARTED= "build_started"; //$NON-NLS-1$ >+ public final static String TARGET_STARTED= "target_started"; //$NON-NLS-1$ >+ public final static String TARGET_FINISHED= "target_finished"; //$NON-NLS-1$ >+ public final static String TASK_STARTED= "task_started"; //$NON-NLS-1$ >+ public final static String TASK_FINISHED= "task_finished"; //$NON-NLS-1$ >+ >+ public final static String STEP= "step"; //$NON-NLS-1$ >+ public final static String STEP_OVER= "step_over"; //$NON-NLS-1$ >+ public final static String STEP_INTO= "step_into"; //$NON-NLS-1$ >+ >+ public final static String TERMINATE= "terminate"; //$NON-NLS-1$ >+ public final static String TERMINATED= "terminated"; //$NON-NLS-1$ >+ >+ public final static String SUSPEND= "suspend"; //$NON-NLS-1$ >+ public final static String SUSPENDED= "suspended"; //$NON-NLS-1$ >+ >+ public final static String RESUME= "resume"; //$NON-NLS-1$ >+ >+ public final static String STACK= "stack"; //$NON-NLS-1$ >+ >+ public final static String ADD_BREAKPOINT= "add"; //$NON-NLS-1$ >+ public final static String REMOVE_BREAKPOINT= "remove"; //$NON-NLS-1$ >+ >+ public final static String CLIENT_REQUEST= "client"; //$NON-NLS-1$ >+ public final static String BREAKPOINT= "breakpoint"; //$NON-NLS-1$ >+ >+ public final static String PROPERTIES= "prop"; //$NON-NLS-1$ >+ public final static String PROPERTY_VALUE= "value"; //$NON-NLS-1$ >+ public final static int PROPERTY_USER= 0; >+ public final static int PROPERTY_SYSTEM= 1; >+ public final static int PROPERTY_RUNTIME= 2; >+} >Index: src/org/eclipse/ant/internal/launching/debug/IAntDebugController.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/IAntDebugController.java >diff -N src/org/eclipse/ant/internal/launching/debug/IAntDebugController.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/IAntDebugController.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,66 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.debug; >+ >+import org.eclipse.debug.core.model.IBreakpoint; >+ >+public interface IAntDebugController { >+ >+ /** >+ * Resume the Ant build >+ */ >+ public void resume(); >+ >+ /** >+ * Suspend the Ant build >+ */ >+ public void suspend(); >+ >+ /** >+ * Step into the current Ant task >+ */ >+ public void stepInto(); >+ >+ /** >+ * Step over the current Ant task >+ */ >+ public void stepOver(); >+ >+ /** >+ * The provided breakpoint has been added or removed depending on the <code>added</code> parameter. >+ * Updates the controller for this change. >+ * >+ * @param breakpoint the breakpoint that has been added or removed >+ * @param added whether or not the breakpoint has been added >+ */ >+ public void handleBreakpoint(IBreakpoint breakpoint, boolean added); >+ >+ /** >+ * Retrieve the properties of the Ant build. >+ * May occur asynchronously depending on implementation. >+ */ >+ public void getProperties(); >+ >+ /** >+ * Retrieve the stack frames of the Ant build. >+ * May occur asynchronously depending on implementation. >+ */ >+ public void getStackFrames(); >+ >+ /** >+ * Some strings are escaped when marshalled for socket communication. >+ * The Ant debug controller will properly unescape these Strings if required. >+ * >+ * @param value The buffer of the string to unescape >+ * @return The unescaped string >+ */ >+ public StringBuffer unescapeString(StringBuffer value); >+} >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/AntProcess.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/AntProcess.java >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/AntProcess.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/AntProcess.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,192 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.launchConfigurations; >+ >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.PlatformObject; >+import org.eclipse.debug.core.DebugEvent; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.model.IProcess; >+import org.eclipse.debug.core.model.IStreamsProxy; >+ >+public class AntProcess extends PlatformObject implements IProcess, IProgressMonitor { >+ >+ private AntStreamsProxy fProxy; >+ private String fLabel = null; >+ private ILaunch fLaunch = null; >+ private Map fAttributes = null; >+ private boolean fTerminated = false; >+ private boolean fCancelled = false; >+// private IConsole fConsole = null; >+ >+ public AntProcess(String label, ILaunch launch, Map attributes) { >+ fLabel = label; >+ fLaunch = launch; >+ if (attributes == null) { >+ fAttributes = new HashMap(); >+ } else { >+ fAttributes = attributes; >+ } >+ String captureOutput= launch.getAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT); >+ if(!("false".equals(captureOutput))) { //$NON-NLS-1$ >+ fProxy= new AntStreamsProxy(); >+ } >+ launch.addProcess(this); >+ } >+ >+ /** >+ * @see org.eclipse.debug.core.model.IProcess#getLabel() >+ */ >+ public String getLabel() { >+ return fLabel; >+ } >+ >+ /** >+ * @see org.eclipse.debug.core.model.IProcess#getLaunch() >+ */ >+ public ILaunch getLaunch() { >+ return fLaunch; >+ } >+ >+ /** >+ * @see org.eclipse.debug.core.model.IProcess#getStreamsProxy() >+ */ >+ public IStreamsProxy getStreamsProxy() { >+ return fProxy; >+ } >+ >+ /** >+ * @see org.eclipse.debug.core.model.IProcess#setAttribute(java.lang.String, java.lang.String) >+ */ >+ public void setAttribute(String key, String value) { >+ fAttributes.put(key, value); >+ } >+ >+ /** >+ * @see org.eclipse.debug.core.model.IProcess#getAttribute(java.lang.String) >+ */ >+ public String getAttribute(String key) { >+ return (String)fAttributes.get(key); >+ } >+ >+ /** >+ * @see org.eclipse.debug.core.model.IProcess#getExitValue() >+ */ >+ public int getExitValue() { >+ return 0; >+ } >+ >+ /** >+ * @see org.eclipse.debug.core.model.ITerminate#canTerminate() >+ */ >+ public boolean canTerminate() { >+ return !isCanceled() && !isTerminated(); >+ } >+ >+ /** >+ * @see org.eclipse.debug.core.model.ITerminate#isTerminated() >+ */ >+ public boolean isTerminated() { >+ return fTerminated; >+ } >+ >+ protected void terminated() { >+ if (!fTerminated) { >+ fTerminated = true; >+ if (DebugPlugin.getDefault() != null) { >+ DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {new DebugEvent(this, DebugEvent.TERMINATE)}); >+ } >+ } >+ } >+ >+ /** >+ * @see org.eclipse.debug.core.model.ITerminate#terminate() >+ */ >+ public void terminate() { >+ setCanceled(true); >+ } >+ >+// /** >+// * Returns the console associated with this process, or <code>null</code> if >+// * none. >+// * >+// * @return console, or <code>null</code> >+// */ >+// public IConsole getConsole() { >+// return fConsole; >+// } >+// >+// /** >+// * Sets the console associated with this process. >+// * >+// * @param console >+// */ >+// public void setConsole(IConsole console) { >+// fConsole = console; >+// } >+ >+ // IProgressMonitor implemented to support termination. >+ >+ /** >+ * @see org.eclipse.core.runtime.IProgressMonitor#beginTask(java.lang.String, int) >+ */ >+ public void beginTask(String name, int totalWork) { >+ } >+ >+ /** >+ * @see org.eclipse.core.runtime.IProgressMonitor#done() >+ */ >+ public void done() { >+ } >+ >+ /** >+ * @see org.eclipse.core.runtime.IProgressMonitor#internalWorked(double) >+ */ >+ public void internalWorked(double work) { >+ } >+ >+ /** >+ * @see org.eclipse.core.runtime.IProgressMonitor#isCanceled() >+ */ >+ public boolean isCanceled() { >+ return fCancelled; >+ } >+ >+ /** >+ * @see org.eclipse.core.runtime.IProgressMonitor#setCanceled(boolean) >+ */ >+ public void setCanceled(boolean value) { >+ fCancelled = value; >+ } >+ >+ /** >+ * @see org.eclipse.core.runtime.IProgressMonitor#setTaskName(java.lang.String) >+ */ >+ public void setTaskName(String name) { >+ } >+ >+ /** >+ * @see org.eclipse.core.runtime.IProgressMonitor#subTask(java.lang.String) >+ */ >+ public void subTask(String name) { >+ } >+ >+ /** >+ * @see org.eclipse.core.runtime.IProgressMonitor#worked(int) >+ */ >+ public void worked(int work) { >+ } >+} >Index: src/org/eclipse/ant/internal/launching/debug/model/DebugModelMessages.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/model/DebugModelMessages.java >diff -N src/org/eclipse/ant/internal/launching/debug/model/DebugModelMessages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/model/DebugModelMessages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+/********************************************************************** >+ * Copyright (c) 2004, 2005 IBM Corporation and others. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.ant.internal.launching.debug.model; >+ >+import org.eclipse.osgi.util.NLS; >+ >+public class DebugModelMessages extends NLS { >+ private static final String BUNDLE_NAME = "org.eclipse.ant.internal.ui.debug.model.DebugModelMessages";//$NON-NLS-1$ >+ >+ public static String AntDebugTarget_0; >+ >+ public static String AntDebugModelPresentation_0; >+ public static String AntDebugModelPresentation_1; >+ public static String AntDebugModelPresentation_2; >+ public static String AntDebugModelPresentation_3; >+ public static String AntDebugModelPresentation_4; >+ public static String AntDebugModelPresentation_5; >+ >+ public static String AntLineBreakpoint_0; >+ public static String AntThread_0; >+ public static String AntThread_1; >+ public static String AntThread_2; >+ public static String AntThread_3; >+ public static String AntThread_4; >+ >+ public static String AntProperties_1; >+ >+ static { >+ // load message values from bundle file >+ NLS.initializeMessages(BUNDLE_NAME, DebugModelMessages.class); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/ant/internal/launching/AntLaunchingUtil.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/AntLaunchingUtil.java >diff -N src/org/eclipse/ant/internal/launching/AntLaunchingUtil.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/AntLaunchingUtil.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,515 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching; >+ >+import java.io.File; >+import java.io.IOException; >+import java.net.MalformedURLException; >+import java.net.URL; >+import java.util.ArrayList; >+import java.util.List; >+import java.util.Map; >+import java.util.StringTokenizer; >+ >+import org.apache.tools.ant.BuildException; >+import org.apache.tools.ant.util.FileUtils; >+import org.eclipse.ant.internal.launching.launchConfigurations.AntCoreModelMessages; >+import org.eclipse.ant.internal.launching.launchConfigurations.AntHomeClasspathEntry; >+import org.eclipse.ant.internal.launching.launchConfigurations.IAntLaunchConfigurationConstants; >+import org.eclipse.ant.internal.launching.launchConfigurations.RemoteAntRuntimeProcess; >+import org.eclipse.core.internal.externaltools.model.ExternalToolBuilder; >+import org.eclipse.core.internal.externaltools.model.IExternalToolConstants; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.variables.VariablesPlugin; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.debug.core.model.IProcess; >+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+import org.eclipse.jdt.launching.IRuntimeClasspathEntry; >+import org.eclipse.jdt.launching.IRuntimeClasspathEntry2; >+import org.eclipse.jdt.launching.JavaRuntime; >+ >+import com.ibm.icu.text.MessageFormat; >+ >+/** >+ * General utility class dealing with Ant build files >+ */ >+public final class AntLaunchingUtil { >+ public static final String ATTRIBUTE_SEPARATOR = ","; //$NON-NLS-1$; >+ public static final char ANT_CLASSPATH_DELIMITER = '*'; >+ public static final String ANT_HOME_CLASSPATH_PLACEHOLDER = "G"; //$NON-NLS-1$ >+ public static final String ANT_GLOBAL_USER_CLASSPATH_PLACEHOLDER = "UG"; //$NON-NLS-1$ >+ >+ /** >+ * No instances allowed >+ */ >+ private AntLaunchingUtil() { >+ super(); >+ } >+ >+ /** >+ * Returns a single-string of the strings for storage. >+ * >+ * @param strings >+ * the array of strings >+ * @return a single-string representation of the strings or >+ * <code>null</code> if the array is empty. >+ */ >+ public static String combineStrings(String[] strings) { >+ if (strings.length == 0) >+ return null; >+ >+ if (strings.length == 1) >+ return strings[0]; >+ >+ StringBuffer buf = new StringBuffer(); >+ for (int i = 0; i < strings.length - 1; i++) { >+ buf.append(strings[i]); >+ buf.append(ATTRIBUTE_SEPARATOR); >+ } >+ buf.append(strings[strings.length - 1]); >+ return buf.toString(); >+ } >+ >+ /** >+ * Returns an array of targets to be run, or <code>null</code> if none are >+ * specified (indicating the default target or implicit target should be >+ * run). >+ * >+ * @param configuration >+ * launch configuration >+ * @return array of target names, or <code>null</code> >+ * @throws CoreException >+ * if unable to access the associated attribute >+ */ >+ public static String[] getTargetNames(ILaunchConfiguration configuration) >+ throws CoreException { >+ String attribute = null; >+ if (IAntLaunchConfigurationConstants.ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE >+ .equals(configuration.getType().getIdentifier())) { >+ attribute = getTargetNamesForAntBuilder(configuration); >+ } >+ if (attribute == null) { >+ attribute = configuration.getAttribute( >+ IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, >+ (String) null); >+ if (attribute == null) { >+ return null; >+ } >+ } >+ >+ return AntLaunchingUtil.parseRunTargets(attribute); >+ } >+ >+ private static String getTargetNamesForAntBuilder( >+ ILaunchConfiguration configuration) throws CoreException { >+ String buildType = ExternalToolBuilder.getBuildType(); >+ String targets = null; >+ if (IExternalToolConstants.BUILD_TYPE_AUTO.equals(buildType)) { >+ targets = configuration.getAttribute( >+ IAntLaunchConfigurationConstants.ATTR_ANT_AUTO_TARGETS, >+ (String) null); >+ } else if (IExternalToolConstants.BUILD_TYPE_CLEAN.equals(buildType)) { >+ targets = configuration.getAttribute( >+ IAntLaunchConfigurationConstants.ATTR_ANT_CLEAN_TARGETS, >+ (String) null); >+ } else if (IExternalToolConstants.BUILD_TYPE_FULL.equals(buildType)) { >+ targets = configuration >+ .getAttribute( >+ IAntLaunchConfigurationConstants.ATTR_ANT_AFTER_CLEAN_TARGETS, >+ (String) null); >+ } else if (IExternalToolConstants.BUILD_TYPE_INCREMENTAL >+ .equals(buildType)) { >+ targets = configuration.getAttribute( >+ IAntLaunchConfigurationConstants.ATTR_ANT_MANUAL_TARGETS, >+ (String) null); >+ } >+ >+ return targets; >+ } >+ >+ /** >+ * Returns a map of properties to be defined for the build, or >+ * <code>null</code> if none are specified (indicating no additional >+ * properties specified for the build). >+ * >+ * @param configuration >+ * launch configuration >+ * @return map of properties (name --> value), or <code>null</code> >+ * @throws CoreException >+ * if unable to access the associated attribute >+ */ >+ public static Map getProperties(ILaunchConfiguration configuration) >+ throws CoreException { >+ Map map = configuration.getAttribute( >+ IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTIES, >+ (Map) null); >+ return map; >+ } >+ >+ /** >+ * Returns a String specifying the Ant home to use for the build. >+ * >+ * @param configuration >+ * launch configuration >+ * @return String specifying Ant home to use or <code>null</code> >+ * @throws CoreException >+ * if unable to access the associated attribute >+ */ >+ public static String getAntHome(ILaunchConfiguration configuration) >+ throws CoreException { >+ IRuntimeClasspathEntry[] entries = JavaRuntime >+ .computeUnresolvedRuntimeClasspath(configuration); >+ for (int i = 0; i < entries.length; i++) { >+ IRuntimeClasspathEntry entry = entries[i]; >+ if (entry.getType() == IRuntimeClasspathEntry.OTHER) { >+ IRuntimeClasspathEntry2 entry2 = (IRuntimeClasspathEntry2) entry; >+ if (entry2.getTypeId().equals(AntHomeClasspathEntry.TYPE_ID)) { >+ return ((AntHomeClasspathEntry) entry2).getAntHome(); >+ } >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * Returns an array of property files to be used for the build, or >+ * <code>null</code> if none are specified (indicating no additional >+ * property files specified for the build). >+ * >+ * @param configuration >+ * launch configuration >+ * @return array of property file names, or <code>null</code> >+ * @throws CoreException >+ * if unable to access the associated attribute >+ */ >+ public static String[] getPropertyFiles(ILaunchConfiguration configuration) >+ throws CoreException { >+ String attribute = configuration.getAttribute( >+ IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTY_FILES, >+ (String) null); >+ if (attribute == null) { >+ return null; >+ } >+ String[] propertyFiles = AntLaunchingUtil.parseString(attribute, ","); //$NON-NLS-1$ >+ for (int i = 0; i < propertyFiles.length; i++) { >+ String propertyFile = propertyFiles[i]; >+ propertyFile = expandVariableString(propertyFile, >+ AntCoreModelMessages.AntUtil_6); >+ propertyFiles[i] = propertyFile; >+ } >+ return propertyFiles; >+ } >+ >+ /** >+ * Returns the list of URLs that define the custom classpath for the Ant >+ * build, or <code>null</code> if the global classpath is to be used. >+ * >+ * @param config >+ * launch configuration >+ * @return a list of <code>URL</code> >+ * >+ * @throws CoreException >+ * if file does not exist, IO problems, or invalid format. >+ */ >+ public static URL[] getCustomClasspath(ILaunchConfiguration config) >+ throws CoreException { >+ boolean useDefault = config.getAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true); >+ if (useDefault) { >+ return null; >+ } >+ IRuntimeClasspathEntry[] unresolved = JavaRuntime >+ .computeUnresolvedRuntimeClasspath(config); >+ // don't consider bootpath entries >+ List userEntries = new ArrayList(unresolved.length); >+ for (int i = 0; i < unresolved.length; i++) { >+ IRuntimeClasspathEntry entry = unresolved[i]; >+ if (entry.getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES) { >+ userEntries.add(entry); >+ } >+ } >+ IRuntimeClasspathEntry[] entries = JavaRuntime >+ .resolveRuntimeClasspath( >+ (IRuntimeClasspathEntry[]) userEntries >+ .toArray(new IRuntimeClasspathEntry[userEntries >+ .size()]), config); >+ URL[] urls = new URL[entries.length]; >+ for (int i = 0; i < entries.length; i++) { >+ IRuntimeClasspathEntry entry = entries[i]; >+ try { >+ urls[i] = new URL("file:" + entry.getLocation()); //$NON-NLS-1$ >+ } catch (MalformedURLException e) { >+ throw new CoreException(new Status(IStatus.ERROR, AntLaunching >+ .getUniqueIdentifier(), AntLaunching.INTERNAL_ERROR, >+ AntCoreModelMessages.AntUtil_7, e)); >+ } >+ } >+ return urls; >+ } >+ >+ private static String expandVariableString(String variableString, >+ String invalidMessage) throws CoreException { >+ String expandedString = VariablesPlugin.getDefault() >+ .getStringVariableManager().performStringSubstitution( >+ variableString); >+ if (expandedString == null || expandedString.length() == 0) { >+ String msg = MessageFormat.format(invalidMessage, >+ new String[] { variableString }); >+ throw new CoreException(new Status(IStatus.ERROR, >+ IAntLaunchConfigurationConstants.PLUGIN_ID, 0, msg, null)); >+ } >+ >+ return expandedString; >+ } >+ >+ /** >+ * Returns the list of target names to run >+ * >+ * @param extraAttibuteValue >+ * the external tool's extra attribute value for the run targets >+ * key. >+ * @return a list of target names >+ */ >+ public static String[] parseRunTargets(String extraAttibuteValue) { >+ return parseString(extraAttibuteValue, ATTRIBUTE_SEPARATOR); >+ } >+ >+ /** >+ * Returns the list of Strings that were delimiter separated. >+ * >+ * @param delimString >+ * the String to be tokenized based on the delimiter >+ * @return a list of Strings >+ */ >+ public static String[] parseString(String delimString, String delim) { >+ if (delimString == null) { >+ return new String[0]; >+ } >+ >+ // Need to handle case where separator character is >+ // actually part of the target name! >+ StringTokenizer tokenizer = new StringTokenizer(delimString, delim); >+ String[] results = new String[tokenizer.countTokens()]; >+ for (int i = 0; i < results.length; i++) { >+ results[i] = tokenizer.nextToken(); >+ } >+ >+ return results; >+ } >+ >+ /** >+ * Returns an IFile with the given fully qualified path (relative to the >+ * workspace root). The returned IFile may or may not exist. >+ */ >+ public static IFile getFile(String fullPath) { >+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >+ return root.getFile(new Path(fullPath)); >+ } >+ >+ /** >+ * Returns the workspace file associated with the given path in the local >+ * file system, or <code>null</code> if none. If the path happens to be a >+ * relative path, then the path is interpreted as relative to the specified >+ * parent file. >+ * >+ * Attempts to handle linked files; the first found linked file with the >+ * correct path is returned. >+ * >+ * @param path >+ * @param buildFileParent >+ * @return file or <code>null</code> >+ * @see org.eclipse.core.resources.IWorkspaceRoot#findFilesForLocation(IPath) >+ */ >+ public static IFile getFileForLocation(String path, File buildFileParent) { >+ if (path == null) { >+ return null; >+ } >+ IPath filePath = new Path(path); >+ IFile file = null; >+ IFile[] files = ResourcesPlugin.getWorkspace().getRoot() >+ .findFilesForLocation(filePath); >+ if (files.length > 0) { >+ file = files[0]; >+ } >+ if (file == null) { >+ // relative path >+ File relativeFile = null; >+ try { >+ // this call is ok if buildFileParent is null >+ relativeFile = FileUtils.getFileUtils().resolveFile( >+ buildFileParent, path); >+ filePath = new Path(relativeFile.getAbsolutePath()); >+ files = ResourcesPlugin.getWorkspace().getRoot() >+ .findFilesForLocation(filePath); >+ if (files.length > 0) { >+ file = files[0]; >+ } else { >+ return null; >+ } >+ } catch (BuildException be) { >+ return null; >+ } >+ } >+ >+ if (file.exists()) { >+ return file; >+ } >+ File ioFile = file.getLocation().toFile(); >+ if (ioFile.exists()) {// needs to handle case insensitivity on WINOS >+ try { >+ files = ResourcesPlugin.getWorkspace().getRoot() >+ .findFilesForLocation( >+ new Path(ioFile.getCanonicalPath())); >+ if (files.length > 0) { >+ return files[0]; >+ } >+ } catch (IOException e) { >+ } >+ } >+ >+ return null; >+ } >+ >+ /** >+ * Migrates the classpath in the given configuration from the old format to >+ * the new format. The old format is not preserved. Instead, the default >+ * classpath will be used. However, ANT_HOME settings are preserved. >+ * >+ * @param configuration >+ * a configuration to migrate >+ * @throws CoreException >+ * if unable to migrate >+ * @since 3.0 >+ */ >+ public static void migrateToNewClasspathFormat( >+ ILaunchConfiguration configuration) throws CoreException { >+ String oldClasspath = configuration.getAttribute( >+ IAntLaunchConfigurationConstants.ATTR_ANT_CUSTOM_CLASSPATH, >+ (String) null); >+ String oldAntHome = configuration.getAttribute( >+ IAntLaunchConfigurationConstants.ATTR_ANT_HOME, (String) null); >+ String provider = configuration.getAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, >+ (String) null); >+ if (oldClasspath != null || oldAntHome != null || provider == null) { >+ ILaunchConfigurationWorkingCopy workingCopy = null; >+ if (configuration.isWorkingCopy()) { >+ workingCopy = (ILaunchConfigurationWorkingCopy) configuration; >+ } else { >+ workingCopy = configuration.getWorkingCopy(); >+ } >+ workingCopy >+ .setAttribute( >+ org.eclipse.ant.internal.launching.launchConfigurations.IAntLaunchConfigurationConstants.ATTR_ANT_CUSTOM_CLASSPATH, >+ (String) null); >+ workingCopy >+ .setAttribute( >+ org.eclipse.ant.internal.launching.launchConfigurations.IAntLaunchConfigurationConstants.ATTR_ANT_HOME, >+ (String) null); >+ workingCopy.setAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, >+ "org.eclipse.ant.ui.AntClasspathProvider"); //$NON-NLS-1$ >+ workingCopy.setAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, >+ true); >+ if (oldAntHome != null) { >+ IRuntimeClasspathEntry[] entries = JavaRuntime >+ .computeUnresolvedRuntimeClasspath(workingCopy); >+ List mementos = new ArrayList(entries.length); >+ for (int i = 0; i < entries.length; i++) { >+ IRuntimeClasspathEntry entry = entries[i]; >+ if (entry.getType() == IRuntimeClasspathEntry.OTHER) { >+ IRuntimeClasspathEntry2 entry2 = (IRuntimeClasspathEntry2) entry; >+ if (entry2.getTypeId().equals( >+ AntHomeClasspathEntry.TYPE_ID)) { >+ AntHomeClasspathEntry homeEntry = new AntHomeClasspathEntry( >+ oldAntHome); >+ mementos.add(homeEntry.getMemento()); >+ continue; >+ } >+ } >+ mementos.add(entry.getMemento()); >+ } >+ workingCopy >+ .setAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, >+ false); >+ workingCopy.setAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, >+ mementos); >+ } >+ workingCopy.doSave(); >+ } >+ } >+ >+ public static boolean isSeparateJREAntBuild( >+ ILaunchConfiguration configuration) { >+ boolean separateJRE = true; >+ try { >+ // always null for same JRE >+ separateJRE = configuration.getAttribute( >+ IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, >+ (String) null) != null; >+ } catch (CoreException e) { >+ AntLaunching.log(AntCoreModelMessages.AntUtil_2, e); >+ } >+ >+ return separateJRE; >+ } >+ >+ public static void linkBuildFailedMessage(String message, IProcess process) { >+ String fileName = null; >+ String lineNumber = ""; //$NON-NLS-1$ >+ int fileStart = 0; >+ int index = message.indexOf("xml"); //$NON-NLS-1$ >+ if (index > 0) { >+ int numberStart = index + 4; >+ int numberEnd = message.indexOf(':', numberStart); >+ int fileEnd = index + 3; >+ if (numberStart > 0 && fileEnd > 0) { >+ fileName = message.substring(fileStart, fileEnd).trim(); >+ if (numberEnd > 0) { >+ lineNumber = message.substring(numberStart, numberEnd) >+ .trim(); >+ } >+ } >+ } >+ >+ if (fileName != null) { >+ int num = -1; >+ try { >+ num = Integer.parseInt(lineNumber); >+ } catch (NumberFormatException e) { >+ } >+ IFile[] files = ResourcesPlugin.getWorkspace().getRoot() >+ .findFilesForLocation(new Path(fileName)); >+ IFile file = null; >+ if (files.length > 0) { >+ file = files[0]; >+ } >+ if (file != null && file.exists()) { >+ ILaunch launch = ((RemoteAntRuntimeProcess) process) >+ .getLaunch(); >+ ((AntLaunch) launch).addLinkDescriptor(message, fileName, num, >+ 0, message.length()); >+ } >+ } >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntProcessFactory.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntProcessFactory.java >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntProcessFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntProcessFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,33 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.ant.internal.launching.launchConfigurations; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.IProcessFactory; >+import org.eclipse.debug.core.model.IProcess; >+ >+public class RemoteAntProcessFactory implements IProcessFactory { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.IProcessFactory#newProcess(org.eclipse.debug.core.ILaunch, java.lang.Process, java.lang.String, java.util.Map) >+ */ >+ public IProcess newProcess(ILaunch launch, Process process, String label, Map attributes) { >+ if (attributes == null) { >+ attributes= new HashMap(1); >+ } >+ attributes.put(IProcess.ATTR_PROCESS_TYPE, IAntLaunchConfigurationConstants.ID_ANT_PROCESS_TYPE); >+ return new RemoteAntRuntimeProcess(launch, process, label, attributes); >+ } >+} >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/MessageIds.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/MessageIds.java >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/MessageIds.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/MessageIds.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+/******************************************************************************* >+ * Copyright (c) 2003, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.ant.internal.launching.launchConfigurations; >+ >+public class MessageIds { >+ >+ public final static String PROCESS_ID= "processID"; //$NON-NLS-1$ >+ public final static String BUILD_CANCELLED= "cancelled"; //$NON-NLS-1$ >+ //constants need to start greater than the Project.MSG_* constants >+ public final static String TASK= "6"; //$NON-NLS-1$ >+ public final static String TARGET= "7"; //$NON-NLS-1$ >+} >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntRuntimeProcess.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntRuntimeProcess.java >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntRuntimeProcess.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntRuntimeProcess.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.ant.internal.launching.launchConfigurations; >+ >+import java.util.Map; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.model.IStreamsProxy; >+import org.eclipse.debug.core.model.RuntimeProcess; >+ >+public class RemoteAntRuntimeProcess extends RuntimeProcess { >+ >+ /** >+ * Constructs a RuntimeProcess on the given system process >+ * with the given name, adding this process to the given >+ * launch. >+ * Sets the streams proxy to an AntStreamsProxy if output is captured. >+ */ >+ public RemoteAntRuntimeProcess(ILaunch launch, Process process, String name, Map attributes) { >+ super(launch, process, name, attributes); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.RuntimeProcess#createStreamsProxy() >+ */ >+ protected IStreamsProxy createStreamsProxy() { >+ return new AntStreamsProxy(); >+ } >+} >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamsProxy.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamsProxy.java >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamsProxy.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamsProxy.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,64 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.launchConfigurations; >+ >+ >+import org.eclipse.debug.core.model.IStreamMonitor; >+import org.eclipse.debug.core.model.IStreamsProxy; >+ >+/** >+ * >+ */ >+public class AntStreamsProxy implements IStreamsProxy { >+ >+ private AntStreamMonitor fErrorMonitor = new AntStreamMonitor(); >+ private AntStreamMonitor fOutputMonitor = new AntStreamMonitor(); >+ >+ public static final String ANT_DEBUG_STREAM = IAntLaunchConfigurationConstants.PLUGIN_ID + ".ANT_DEBUG_STREAM"; //$NON-NLS-1$ >+ public static final String ANT_VERBOSE_STREAM = IAntLaunchConfigurationConstants.PLUGIN_ID + ".ANT_VERBOSE_STREAM"; //$NON-NLS-1$ >+ public static final String ANT_WARNING_STREAM = IAntLaunchConfigurationConstants.PLUGIN_ID + ".ANT_WARNING_STREAM"; //$NON-NLS-1$ >+ >+ private AntStreamMonitor fDebugMonitor = new AntStreamMonitor(); >+ private AntStreamMonitor fVerboseMonitor = new AntStreamMonitor(); >+ private AntStreamMonitor fWarningMonitor = new AntStreamMonitor(); >+ >+ /** >+ * @see org.eclipse.debug.core.model.IStreamsProxy#getErrorStreamMonitor() >+ */ >+ public IStreamMonitor getErrorStreamMonitor() { >+ return fErrorMonitor; >+ } >+ >+ /** >+ * @see org.eclipse.debug.core.model.IStreamsProxy#getOutputStreamMonitor() >+ */ >+ public IStreamMonitor getOutputStreamMonitor() { >+ return fOutputMonitor; >+ } >+ >+ /** >+ * @see org.eclipse.debug.core.model.IStreamsProxy#write(java.lang.String) >+ */ >+ public void write(String input) { >+ } >+ >+ public IStreamMonitor getWarningStreamMonitor() { >+ return fWarningMonitor; >+ } >+ >+ public IStreamMonitor getDebugStreamMonitor() { >+ return fDebugMonitor; >+ } >+ >+ public IStreamMonitor getVerboseStreamMonitor() { >+ return fVerboseMonitor; >+ } >+} >Index: src/org/eclipse/ant/internal/launching/debug/AntDebugMessages.properties >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/AntDebugMessages.properties >diff -N src/org/eclipse/ant/internal/launching/debug/AntDebugMessages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/AntDebugMessages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,12 @@ >+############################################################################### >+# Copyright (c) 2005 IBM Corporation and others. >+# All rights reserved. This program and the accompanying materials >+# are made available under the terms of the Eclipse Public License v1.0 >+# which accompanies this distribution, and is available at >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# IBM Corporation - initial API and implementation >+############################################################################### >+ >+AntSourceContainer_0=Ant Source Container >\ No newline at end of file >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamMonitor.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamMonitor.java >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamMonitor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamMonitor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,83 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.launchConfigurations; >+ >+import org.eclipse.core.runtime.ListenerList; >+import org.eclipse.debug.core.IStreamListener; >+import org.eclipse.debug.core.model.IFlushableStreamMonitor; >+ >+/** >+ * Stream monitor implementation for an Ant build process. >+ */ >+public class AntStreamMonitor implements IFlushableStreamMonitor { >+ >+ private StringBuffer fContents = new StringBuffer(); >+ private ListenerList fListeners = new ListenerList(1); >+ private boolean fBuffered = true; >+ >+ /** >+ * @see org.eclipse.debug.core.model.IStreamMonitor#addListener(org.eclipse.debug.core.IStreamListener) >+ */ >+ public void addListener(IStreamListener listener) { >+ fListeners.add(listener); >+ } >+ >+ /** >+ * @see org.eclipse.debug.core.model.IStreamMonitor#getContents() >+ */ >+ public String getContents() { >+ return fContents.toString(); >+ } >+ >+ /** >+ * @see org.eclipse.debug.core.model.IStreamMonitor#removeListener(org.eclipse.debug.core.IStreamListener) >+ */ >+ public void removeListener(IStreamListener listener) { >+ fListeners.remove(listener); >+ } >+ >+ /** >+ * Appends the given message to this stream, and notifies listeners. >+ * >+ * @param message >+ */ >+ public void append(String message) { >+ if (isBuffered()) { >+ fContents.append(message); >+ } >+ Object[] listeners = fListeners.getListeners(); >+ for (int i = 0; i < listeners.length; i++) { >+ IStreamListener listener = (IStreamListener)listeners[i]; >+ listener.streamAppended(message, this); >+ } >+ } >+ /** >+ * @see org.eclipse.debug.core.model.IFlushableStreamMonitor#flushContents() >+ */ >+ public void flushContents() { >+ fContents.setLength(0); >+ } >+ >+ /** >+ * @see org.eclipse.debug.core.model.IFlushableStreamMonitor#isBuffered() >+ */ >+ public boolean isBuffered() { >+ return fBuffered; >+ } >+ >+ /** >+ * @see org.eclipse.debug.core.model.IFlushableStreamMonitor#setBuffered(boolean) >+ */ >+ public void setBuffered(boolean buffer) { >+ fBuffered = buffer; >+ } >+} >+ >Index: src/org/eclipse/ant/internal/launching/debug/model/AntThread.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/model/AntThread.java >diff -N src/org/eclipse/ant/internal/launching/debug/model/AntThread.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/model/AntThread.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,479 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.debug.model; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.debug.core.DebugEvent; >+import org.eclipse.debug.core.DebugException; >+import org.eclipse.debug.core.model.IBreakpoint; >+import org.eclipse.debug.core.model.IStackFrame; >+import org.eclipse.debug.core.model.IThread; >+import org.eclipse.debug.core.model.IVariable; >+ >+/** >+ * An Ant build thread. >+ */ >+public class AntThread extends AntDebugElement implements IThread { >+ >+ /** >+ * Breakpoints this thread is suspended at or <code>null</code> >+ * if none. >+ */ >+ private IBreakpoint[] fBreakpoints; >+ >+ /** >+ * The stackframes associated with this thread >+ */ >+ private List fFrames= new ArrayList(1); >+ >+ /** >+ * The stackframes to be reused on suspension >+ */ >+ private List fOldFrames; >+ >+ /** >+ * Whether this thread is stepping >+ */ >+ private boolean fStepping = false; >+ >+ private boolean fRefreshProperties= true; >+ >+ /** >+ * The user properties associated with this thread >+ */ >+ private AntProperties fUserProperties; >+ >+ /** >+ * The system properties associated with this thread >+ */ >+ private AntProperties fSystemProperties; >+ >+ /** >+ * The properties set during the build associated with this thread >+ */ >+ private AntProperties fRuntimeProperties; >+ >+ private Object fPropertiesLock= new Object(); >+ >+ /** >+ * Constructs a new thread for the given target >+ * >+ * @param target the Ant Build >+ */ >+ public AntThread(AntDebugTarget target) { >+ super(target); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IThread#getStackFrames() >+ */ >+ public synchronized IStackFrame[] getStackFrames() throws DebugException { >+ if (isSuspended()) { >+ if (fFrames.size() == 0) { >+ getStackFrames0(); >+ } >+ } >+ >+ return (IStackFrame[]) fFrames.toArray(new IStackFrame[fFrames.size()]); >+ } >+ >+ /** >+ * Retrieves the current stack frames in the thread >+ * possibly waiting until the frames are populated >+ * >+ */ >+ private void getStackFrames0() throws DebugException { >+ synchronized (fFrames) { >+ getAntDebugTarget().getStackFrames(); >+ if (fFrames.size() > 0) { >+ //frames set..no need to wait >+ return; >+ } >+ int attempts= 0; >+ try { >+ while (fFrames.size() == 0 && !isTerminated()) { >+ fFrames.wait(50); >+ if (attempts == 20 && fFrames.size() == 0 && !isTerminated()) { >+ throwDebugException(DebugModelMessages.AntThread_3); >+ } >+ attempts++; >+ } >+ } catch (InterruptedException e) { >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IThread#hasStackFrames() >+ */ >+ public boolean hasStackFrames() throws DebugException { >+ return isSuspended(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IThread#getPriority() >+ */ >+ public int getPriority() throws DebugException { >+ return 0; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IThread#getTopStackFrame() >+ */ >+ public synchronized IStackFrame getTopStackFrame() throws DebugException { >+ if (isSuspended()) { >+ if (fFrames.size() == 0) { >+ getStackFrames0(); >+ } >+ if (fFrames.size() > 0) { >+ return (IStackFrame)fFrames.get(0); >+ } >+ } >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IThread#getName() >+ */ >+ public String getName() { >+ return "Thread [Ant Build]"; //$NON-NLS-1$ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IThread#getBreakpoints() >+ */ >+ public IBreakpoint[] getBreakpoints() { >+ if (fBreakpoints == null) { >+ return new IBreakpoint[0]; >+ } >+ return fBreakpoints; >+ } >+ >+ /** >+ * Sets the breakpoints this thread is suspended at, or <code>null</code> >+ * if none. >+ * >+ * @param breakpoints the breakpoints this thread is suspended at, or <code>null</code> >+ * if none >+ */ >+ protected void setBreakpoints(IBreakpoint[] breakpoints) { >+ fBreakpoints = breakpoints; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ISuspendResume#canResume() >+ */ >+ public boolean canResume() { >+ return isSuspended(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend() >+ */ >+ public boolean canSuspend() { >+ return !isSuspended(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended() >+ */ >+ public boolean isSuspended() { >+ return getDebugTarget().isSuspended(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ISuspendResume#resume() >+ */ >+ public synchronized void resume() throws DebugException { >+ aboutToResume(DebugEvent.CLIENT_REQUEST, false); >+ getDebugTarget().resume(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ISuspendResume#suspend() >+ */ >+ public synchronized void suspend() throws DebugException { >+ getDebugTarget().suspend(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStep#canStepInto() >+ */ >+ public boolean canStepInto() { >+ return isSuspended(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStep#canStepOver() >+ */ >+ public boolean canStepOver() { >+ return isSuspended(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStep#canStepReturn() >+ */ >+ public boolean canStepReturn() { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStep#isStepping() >+ */ >+ public boolean isStepping() { >+ return fStepping; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStep#stepInto() >+ */ >+ public synchronized void stepInto() throws DebugException { >+ aboutToResume(DebugEvent.STEP_INTO, true); >+ ((AntDebugTarget)getDebugTarget()).stepInto(); >+ } >+ >+ private void aboutToResume(int detail, boolean stepping) { >+ fRefreshProperties= true; >+ fOldFrames= new ArrayList(fFrames); >+ fFrames.clear(); >+ setPropertiesValid(false); >+ setStepping(stepping); >+ setBreakpoints(null); >+ fireResumeEvent(detail); >+ } >+ >+ private void setPropertiesValid(boolean valid) { >+ if (fUserProperties != null) { >+ fUserProperties.setValid(valid); >+ fSystemProperties.setValid(valid); >+ fRuntimeProperties.setValid(valid); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStep#stepOver() >+ */ >+ public synchronized void stepOver() throws DebugException { >+ aboutToResume(DebugEvent.STEP_OVER, true); >+ ((AntDebugTarget)getDebugTarget()).stepOver(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IStep#stepReturn() >+ */ >+ public synchronized void stepReturn() throws DebugException { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ITerminate#canTerminate() >+ */ >+ public boolean canTerminate() { >+ return !isTerminated(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ITerminate#isTerminated() >+ */ >+ public boolean isTerminated() { >+ return getDebugTarget().isTerminated(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ITerminate#terminate() >+ */ >+ public void terminate() throws DebugException { >+ fFrames.clear(); >+ getDebugTarget().terminate(); >+ } >+ >+ /** >+ * Sets whether this thread is stepping >+ * >+ * @param stepping whether stepping >+ */ >+ protected void setStepping(boolean stepping) { >+ fStepping = stepping; >+ } >+ >+ public void buildStack(String data) { >+ synchronized (fFrames) { >+ String[] strings= data.split(DebugMessageIds.MESSAGE_DELIMITER); >+ //0 STACK message >+ //1 targetName >+ //2 taskName >+ //3 filePath >+ //4 lineNumber >+ //5 ... >+ if (fOldFrames != null && (strings.length - 1)/ 4 != fOldFrames.size()) { >+ fOldFrames= null; //stack size changed..do not preserve >+ } >+ StringBuffer name; >+ String filePath; >+ int lineNumber; >+ int stackFrameId= 0; >+ String taskName; >+ for (int i = 1; i < strings.length; i++) { >+ if (strings[i].length() > 0) { >+ name= new StringBuffer(strings[i]); >+ taskName= strings[++i]; >+ if (taskName.length() > 0) { >+ name.append(": "); //$NON-NLS-1$ >+ name.append(taskName); >+ } >+ } else { >+ name= new StringBuffer(strings[++i]); >+ } >+ filePath= strings[++i]; >+ lineNumber= Integer.parseInt(strings[++i]); >+ addFrame(stackFrameId++, name.toString(), filePath, lineNumber); >+ } >+ //wake up the call from getStackFrames >+ fFrames.notifyAll(); >+ } >+ } >+ >+ private void addFrame(int stackFrameId, String name, String filePath, int lineNumber) { >+ AntStackFrame frame= getOldFrame(); >+ >+ if (frame == null || !frame.getFilePath().equals(filePath)) { >+ frame= new AntStackFrame(this, stackFrameId, name, filePath, lineNumber); >+ } else { >+ frame.setFilePath(filePath); >+ frame.setId(stackFrameId); >+ frame.setLineNumber(lineNumber); >+ frame.setName(name); >+ } >+ fFrames.add(frame); >+ } >+ >+ private AntStackFrame getOldFrame() { >+ if (fOldFrames == null) { >+ return null; >+ } >+ AntStackFrame frame= (AntStackFrame) fOldFrames.remove(0); >+ if (fOldFrames.isEmpty()) { >+ fOldFrames= null; >+ } >+ return frame; >+ } >+ >+ public void newProperties(String data) { >+ synchronized (fPropertiesLock) { >+ try { >+ String[] datum= data.split(DebugMessageIds.MESSAGE_DELIMITER); >+ if (fUserProperties == null) { >+ initializePropertyGroups(); >+ } >+ >+ List userProperties= ((AntPropertiesValue)fUserProperties.getLastValue()).getProperties(); >+ List systemProperties= ((AntPropertiesValue)fSystemProperties.getLastValue()).getProperties(); >+ List runtimeProperties= ((AntPropertiesValue)fRuntimeProperties.getLastValue()).getProperties(); >+ //0 PROPERTIES message >+ //1 propertyName length >+ //2 propertyName >+ //3 propertyValue length >+ //3 propertyValue >+ //4 propertyType >+ //5 ... >+ if (datum.length > 1) { //new properties >+ StringBuffer propertyName; >+ StringBuffer propertyValue; >+ int propertyNameLength; >+ int propertyValueLength; >+ for (int i = 1; i < datum.length; i++) { >+ propertyNameLength= Integer.parseInt(datum[i]); >+ propertyName= new StringBuffer(datum[++i]); >+ while (propertyName.length() != propertyNameLength) { >+ propertyName.append(DebugMessageIds.MESSAGE_DELIMITER); >+ propertyName.append(datum[++i]); >+ } >+ >+ propertyName= getAntDebugTarget().getAntDebugController().unescapeString(propertyName); >+ >+ propertyValueLength= Integer.parseInt(datum[++i]); >+ if (propertyValueLength == 0 && i + 1 == datum.length) { //bug 81299 >+ propertyValue= new StringBuffer(""); //$NON-NLS-1$ >+ } else { >+ propertyValue= new StringBuffer(datum[++i]); >+ } >+ while (propertyValue.length() != propertyValueLength) { >+ propertyValue.append(DebugMessageIds.MESSAGE_DELIMITER); >+ propertyValue.append(datum[++i]); >+ } >+ >+ propertyValue= getAntDebugTarget().getAntDebugController().unescapeString(propertyValue); >+ >+ int propertyType= Integer.parseInt(datum[++i]); >+ addProperty(userProperties, systemProperties, runtimeProperties, propertyName.toString(), propertyValue.toString(), propertyType); >+ } >+ } >+ } finally { >+ fRefreshProperties= false; >+ setPropertiesValid(true); >+ //wake up the call from getVariables >+ fPropertiesLock.notifyAll(); >+ } >+ } >+ } >+ >+ private void addProperty(List userProperties, List systemProperties, List runtimeProperties, String propertyName, String propertyValue, int propertyType) { >+ AntProperty property= new AntProperty((AntDebugTarget) getDebugTarget(), propertyName, propertyValue); >+ switch (propertyType) { >+ case DebugMessageIds.PROPERTY_SYSTEM: >+ systemProperties.add(property); >+ break; >+ case DebugMessageIds.PROPERTY_USER: >+ userProperties.add(property); >+ break; >+ case DebugMessageIds.PROPERTY_RUNTIME: >+ runtimeProperties.add(property); >+ break; >+ } >+ } >+ >+ private void initializePropertyGroups() { >+ AntDebugTarget target= getAntDebugTarget(); >+ fUserProperties= new AntProperties(target, DebugModelMessages.AntThread_0); >+ fUserProperties.setValue(new AntPropertiesValue(target)); >+ fSystemProperties= new AntProperties(target, DebugModelMessages.AntThread_1); >+ fSystemProperties.setValue(new AntPropertiesValue(target)); >+ fRuntimeProperties= new AntProperties(target, DebugModelMessages.AntThread_2); >+ fRuntimeProperties.setValue(new AntPropertiesValue(target)); >+ } >+ >+ protected IVariable[] getVariables() throws DebugException { >+ synchronized (fPropertiesLock) { >+ if (fRefreshProperties) { >+ getAntDebugTarget().getProperties(); >+ if (fRefreshProperties) { >+ //properties have not been set; need to wait >+ try { >+ int attempts= 0; >+ while (fRefreshProperties && !isTerminated()) { >+ fPropertiesLock.wait(50); >+ if (attempts == 20 && fRefreshProperties && !isTerminated()) { >+ throwDebugException(DebugModelMessages.AntThread_4); >+ } >+ attempts++; >+ } >+ } catch (InterruptedException ie) { >+ } >+ } >+ } >+ if (fSystemProperties == null) { >+ return new IVariable[0]; >+ } >+ return new IVariable[]{fSystemProperties, fUserProperties, fRuntimeProperties}; >+ } >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/ant/internal/launching/debug/AntSourcePathComputerDelegate.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/AntSourcePathComputerDelegate.java >diff -N src/org/eclipse/ant/internal/launching/debug/AntSourcePathComputerDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/AntSourcePathComputerDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,33 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.debug; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.sourcelookup.ISourceContainer; >+import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate; >+ >+/** >+ * Computes the default source lookup path for an Ant launch configuration. >+ * The default source lookup is a container that knows how to map the >+ * fully qualified file system paths to either the <code>IFile</code> within the workspace or >+ * a <code>LocalFileStorage</code> for buildfiles not in the workspace. >+ */ >+public class AntSourcePathComputerDelegate implements ISourcePathComputerDelegate { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate#computeSourceContainers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { >+ return new ISourceContainer[] {new AntSourceContainer()}; >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/ant/internal/launching/AntLaunch.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/AntLaunch.java >diff -N src/org/eclipse/ant/internal/launching/AntLaunch.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/AntLaunch.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+package org.eclipse.ant.internal.launching; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.Launch; >+import org.eclipse.debug.core.model.ISourceLocator; >+ >+public class AntLaunch extends Launch { >+ List linkDescriptors; >+ >+ public AntLaunch(ILaunchConfiguration launchConfiguration, String mode, >+ ISourceLocator locator) { >+ super(launchConfiguration, mode, locator); >+ linkDescriptors = new ArrayList(); >+ >+ } >+ >+ public void addLinkDescriptor(String line, String fileName, int lineNumber, >+ int offset, int length){ >+ linkDescriptors.add(new LinkDescriptor(line, fileName, lineNumber, offset, length)); >+ } >+ >+ public void removeLinkDescriptor(LinkDescriptor ld){ >+ linkDescriptors.remove(ld); >+ } >+ >+ public List getLinkDescriptors(){ >+ return linkDescriptors; >+ } >+ >+ public void clearLinkDescriptors(){ >+ linkDescriptors.clear(); >+ } >+ >+} >Index: src/org/eclipse/ant/internal/launching/debug/model/AntLineBreakpoint.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/model/AntLineBreakpoint.java >diff -N src/org/eclipse/ant/internal/launching/debug/model/AntLineBreakpoint.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/model/AntLineBreakpoint.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,112 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.debug.model; >+ >+import com.ibm.icu.text.MessageFormat; >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.ant.internal.launching.debug.IAntDebugConstants; >+import org.eclipse.core.resources.IMarker; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IWorkspaceRunnable; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.debug.core.DebugException; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.model.IBreakpoint; >+import org.eclipse.debug.core.model.LineBreakpoint; >+ >+/** >+ * Ant line breakpoint >+ */ >+public class AntLineBreakpoint extends LineBreakpoint { >+ >+ /** >+ * Default constructor is required for the breakpoint manager >+ * to re-create persisted breakpoints. After instantiating a breakpoint, >+ * the <code>setMarker(...)</code> method is called to restore >+ * this breakpoint's attributes. >+ */ >+ public AntLineBreakpoint() { >+ } >+ >+ /** >+ * Constructs a line breakpoint on the given resource at the given >+ * line number. The line number is 1-based (i.e. the first line of a >+ * file is line number 1). >+ * >+ * @param resource file on which to set the breakpoint >+ * @param lineNumber 1-based line number of the breakpoint >+ * @throws CoreException if unable to create the breakpoint >+ */ >+ public AntLineBreakpoint(IResource resource, int lineNumber) throws CoreException { >+ this(resource, lineNumber, new HashMap(), true); >+ } >+ >+ /** >+ * Constructs a line breakpoint on the given resource at the given >+ * line number. The line number is 1-based (i.e. the first line of a >+ * file is line number 1). >+ * >+ * @param resource file on which to set the breakpoint >+ * @param lineNumber 1-based line number of the breakpoint >+ * @param attributes the marker attributes to set >+ * @param register whether to add this breakpoint to the breakpoint manager >+ * @throws CoreException if unable to create the breakpoint >+ */ >+ public AntLineBreakpoint(final IResource resource, final int lineNumber, final Map attributes, final boolean register) throws CoreException { >+ IWorkspaceRunnable wr= new IWorkspaceRunnable() { >+ public void run(IProgressMonitor monitor) throws CoreException { >+ IMarker marker = resource.createMarker(IAntDebugConstants.ID_ANT_LINE_BREAKPOINT_MARKER); >+ setMarker(marker); >+ attributes.put(IBreakpoint.ENABLED, Boolean.TRUE); >+ attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber)); >+ attributes.put(IBreakpoint.ID, IAntDebugConstants.ID_ANT_DEBUG_MODEL); >+ attributes.put(IMarker.MESSAGE, MessageFormat.format(DebugModelMessages.AntLineBreakpoint_0, new String[] {Integer.toString(lineNumber)})); >+ ensureMarker().setAttributes(attributes); >+ >+ register(register); >+ } >+ }; >+ run(getMarkerRule(resource), wr); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IBreakpoint#getModelIdentifier() >+ */ >+ public String getModelIdentifier() { >+ return IAntDebugConstants.ID_ANT_DEBUG_MODEL; >+ } >+ >+ /** >+ * @return whether this breakpoint is a run to line breakpoint >+ */ >+ public boolean isRunToLine() { >+ try { >+ return ensureMarker().getAttribute(IAntDebugConstants.ANT_RUN_TO_LINE, false); >+ } catch (DebugException e) { >+ return false; >+ } >+ } >+ >+ /** >+ * Add this breakpoint to the breakpoint manager, >+ * or sets it as unregistered. >+ */ >+ private void register(boolean register) throws CoreException { >+ if (register) { >+ DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(this); >+ } else { >+ setRegistered(false); >+ } >+ } >+} >Index: src/org/eclipse/ant/internal/launching/debug/AntDebugMessages.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/AntDebugMessages.java >diff -N src/org/eclipse/ant/internal/launching/debug/AntDebugMessages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/AntDebugMessages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,23 @@ >+/********************************************************************** >+ * Copyright (c) 2005 IBM Corporation and others. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.ant.internal.launching.debug; >+ >+import org.eclipse.osgi.util.NLS; >+ >+public class AntDebugMessages extends NLS { >+ private static final String BUNDLE_NAME = "org.eclipse.ant.internal.ui.debug.AntDebugMessages";//$NON-NLS-1$ >+ >+ public static String AntSourceContainer_0; >+ >+ static { >+ // load message values from bundle file >+ NLS.initializeMessages(BUNDLE_NAME, AntDebugMessages.class); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/AntClasspathProvider.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/AntClasspathProvider.java >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/AntClasspathProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/AntClasspathProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,50 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.ant.internal.launching.launchConfigurations; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+import org.eclipse.jdt.launching.IRuntimeClasspathEntry; >+import org.eclipse.jdt.launching.JavaRuntime; >+import org.eclipse.jdt.launching.StandardClasspathProvider; >+ >+public class AntClasspathProvider extends StandardClasspathProvider { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IRuntimeClasspathProvider#computeUnresolvedClasspath(org.eclipse.debug.core.ILaunchConfiguration) >+ */ >+ public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException { >+ boolean useDefault = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true); >+ if (useDefault) { >+ List rtes = new ArrayList(10); >+ IRuntimeClasspathEntry jreEntry = null; >+ try { >+ jreEntry = JavaRuntime.computeJREEntry(configuration); >+ } catch (CoreException e) { >+ // not a java project >+ } >+ if (jreEntry == null) { >+ jreEntry = JavaRuntime.newRuntimeContainerClasspathEntry( >+ JavaRuntime.newDefaultJREContainerPath(), IRuntimeClasspathEntry.STANDARD_CLASSES); >+ } >+ rtes.add(jreEntry); >+ rtes.add(new AntHomeClasspathEntry()); >+ rtes.add(new ContributedClasspathEntriesEntry()); >+ return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]); >+ } >+ return super.computeUnresolvedClasspath(configuration); >+ } >+} >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchConfigurationMessages.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchConfigurationMessages.java >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchConfigurationMessages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchConfigurationMessages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+/********************************************************************** >+ * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ * dakshinamurthy.karra@gmail.com - bug 165371 >+ **********************************************************************/ >+package org.eclipse.ant.internal.launching.launchConfigurations; >+ >+import org.eclipse.osgi.util.NLS; >+ >+public class AntLaunchConfigurationMessages extends NLS { >+ private static final String BUNDLE_NAME = "org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchConfigurationMessages";//$NON-NLS-1$ >+ >+ public static String AntLaunchDelegate_Launching__0__1; >+ public static String AntLaunchDelegate_Running__0__2; >+ public static String AntLaunchDelegate_Build_In_Progress; >+ public static String AntLaunchDelegate_Failure; >+ public static String AntLaunchDelegate_22; >+ public static String AntLaunchDelegate_23; >+ public static String AntLaunchDelegate_28; >+ >+ public static String AntHomeClasspathEntry_8; >+ public static String AntHomeClasspathEntry_9; >+ public static String AntHomeClasspathEntry_10; >+ public static String AntHomeClasspathEntry_11; >+ >+ public static String ContributedClasspathEntriesEntry_1; >+ >+ static { >+ // load message values from bundle file >+ NLS.initializeMessages(BUNDLE_NAME, AntLaunchConfigurationMessages.class); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/ant/internal/launching/launchConfigurations/AntJavaLaunchDelegate.java >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/launchConfigurations/AntJavaLaunchDelegate.java >diff -N src/org/eclipse/ant/internal/launching/launchConfigurations/AntJavaLaunchDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/launchConfigurations/AntJavaLaunchDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,47 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ant.internal.launching.launchConfigurations; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+import org.eclipse.jdt.launching.JavaLaunchDelegate; >+ >+/** >+ * Used by the AntLaunchDelegate for Ant builds in a separate VM >+ * The subclassing is needed to be able to launch an Ant build from a non-Java project >+ */ >+public class AntJavaLaunchDelegate extends JavaLaunchDelegate { >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate2#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ public boolean preLaunchCheck(ILaunchConfiguration configuration,String mode, IProgressMonitor monitor) throws CoreException { >+ try { >+ return super.preLaunchCheck(configuration, mode, monitor); >+ } catch (CoreException ce) { >+ //likely dealing with a non-Java project >+ } >+ //no need to check for breakpoints as always in run mode >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getProgramArguments(org.eclipse.debug.core.ILaunchConfiguration) >+ */ >+ public String getProgramArguments(ILaunchConfiguration configuration) throws CoreException { >+ try { >+ return super.getProgramArguments(configuration); >+ } catch (CoreException ce) { >+ } >+ return configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""); //$NON-NLS-1$ >+ } >+} >Index: src/org/eclipse/ant/internal/launching/debug/model/DebugModelMessages.properties >=================================================================== >RCS file: src/org/eclipse/ant/internal/launching/debug/model/DebugModelMessages.properties >diff -N src/org/eclipse/ant/internal/launching/debug/model/DebugModelMessages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ant/internal/launching/debug/model/DebugModelMessages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,28 @@ >+############################################################################### >+# Copyright (c) 2004, 2005 IBM Corporation and others. >+# All rights reserved. This program and the accompanying materials >+# are made available under the terms of the Eclipse Public License v1.0 >+# which accompanies this distribution, and is available at >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# IBM Corporation - initial API and implementation >+############################################################################### >+ >+AntDebugTarget_0=Ant Build >+ >+AntDebugModelPresentation_0=<not available> >+AntDebugModelPresentation_1=\ line: {0} >+AntDebugModelPresentation_2=(breakpoint at line {0} in {1}) >+AntDebugModelPresentation_3=\ (Suspended {0}) >+AntDebugModelPresentation_4=\ (Suspended) >+AntDebugModelPresentation_5=(run to line {0} in {1}) >+ >+AntLineBreakpoint_0=Ant breakpoint [line: {0}] >+AntThread_0=User Properties >+AntThread_1=System Properties >+AntThread_2=Runtime Properties >+AntThread_3=Request to retrieve Ant stack frames failed >+AntThread_4=Request to retrieve Ant properties failed >+ >+AntProperties_1=Request to Ant properties value failed >#P org.eclipse.core.externaltools >Index: src/org/eclipse/core/internal/externaltools/ExternalToolsCore.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.externaltools/src/org/eclipse/core/internal/externaltools/ExternalToolsCore.java,v >retrieving revision 1.1 >diff -u -r1.1 ExternalToolsCore.java >--- src/org/eclipse/core/internal/externaltools/ExternalToolsCore.java 16 Sep 2009 14:58:41 -0000 1.1 >+++ src/org/eclipse/core/internal/externaltools/ExternalToolsCore.java 25 Sep 2009 16:23:26 -0000 >@@ -10,7 +10,11 @@ > *******************************************************************************/ > package org.eclipse.core.internal.externaltools; > >+import org.eclipse.core.internal.externaltools.model.IExternalToolConstants; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Plugin; >+import org.eclipse.core.runtime.Status; > import org.osgi.framework.BundleContext; > > /** >@@ -20,6 +24,14 @@ > > // The plug-in ID > public static final String PLUGIN_ID = "org.eclipse.core.externaltools"; //$NON-NLS-1$ >+ >+ private static final String EMPTY_STRING= ""; //$NON-NLS-1$ >+ >+ /** >+ * Status code indicating an unexpected internal error. >+ * @since 2.1 >+ */ >+ public static final int INTERNAL_ERROR = 120; > > // The shared instance > private static ExternalToolsCore plugin; >@@ -56,5 +68,52 @@ > public static ExternalToolsCore getDefault() { > return plugin; > } >+ >+ /** >+ * Logs the specified throwable with this plug-in's log. >+ * >+ * @param t throwable to log >+ */ >+ public static void log(Throwable t) { >+ IStatus status= new Status(IStatus.ERROR, PLUGIN_ID, INTERNAL_ERROR, "Error logged from Ant UI: ", t); //$NON-NLS-1$ >+ log(status); >+ } >+ >+ /** >+ * Logs the specified status with this plug-in's log. >+ * >+ * @param status status >+ */ >+ public static void log(IStatus status) { >+ getDefault().getLog().log(status); >+ } >+ >+ /** >+ * Writes the message to the plug-in's log >+ * >+ * @param message the text to write to the log >+ */ >+ public static void log(String message, Throwable exception) { >+ IStatus status = newErrorStatus(message, exception); >+ log(status); >+ } >+ >+ /** >+ * Returns a new <code>IStatus</code> for this plug-in >+ */ >+ public static IStatus newErrorStatus(String message, Throwable exception) { >+ if (message == null) { >+ message= EMPTY_STRING; >+ } >+ return new Status(IStatus.ERROR, PLUGIN_ID, 0, message, exception); >+ } >+ >+ /** >+ * Returns a new <code>CoreException</code> for this plug-in >+ */ >+ public static CoreException newError(String message, Throwable exception) { >+ return new CoreException(new Status(IStatus.ERROR, >+ IExternalToolConstants.PLUGIN_ID, 0, message, exception)); >+ } > > } >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.externaltools/plugin.properties,v >retrieving revision 1.1 >diff -u -r1.1 plugin.properties >--- plugin.properties 16 Sep 2009 14:50:42 -0000 1.1 >+++ plugin.properties 25 Sep 2009 16:23:26 -0000 >@@ -10,4 +10,6 @@ > ############################################################################### > > pluginName=External Tools Headless Support >-providerName=Eclipse.org >\ No newline at end of file >+providerName=Eclipse.org >+ >+Program.externalTools = Program >\ No newline at end of file >Index: build.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.externaltools/build.properties,v >retrieving revision 1.1 >diff -u -r1.1 build.properties >--- build.properties 16 Sep 2009 14:50:42 -0000 1.1 >+++ build.properties 25 Sep 2009 16:23:26 -0000 >@@ -1,4 +1,6 @@ > source.. = src/ > output.. = bin/ > bin.includes = META-INF/,\ >- . >+ .,\ >+ plugin.xml,\ >+ plugin.properties >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.externaltools/META-INF/MANIFEST.MF,v >retrieving revision 1.1 >diff -u -r1.1 MANIFEST.MF >--- META-INF/MANIFEST.MF 16 Sep 2009 14:58:41 -0000 1.1 >+++ META-INF/MANIFEST.MF 25 Sep 2009 16:23:26 -0000 >@@ -1,7 +1,7 @@ > Manifest-Version: 1.0 > Bundle-ManifestVersion: 2 > Bundle-Name: %pluginName >-Bundle-SymbolicName: org.eclipse.core.externaltools >+Bundle-SymbolicName: org.eclipse.core.externaltools;singleton:=true > Bundle-Version: 1.0.0.qualifier > Bundle-Activator: org.eclipse.core.internal.externaltools.ExternalToolsCore > Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)", >@@ -10,4 +10,6 @@ > Bundle-RequiredExecutionEnvironment: J2SE-1.4 > Bundle-ActivationPolicy: lazy > Bundle-Vendor: %providerName >-Export-Package: org.eclipse.core.internal.externaltools;x-internal:=true >+Export-Package: org.eclipse.core.internal.externaltools;x-friends:="org.eclipse.ui.externaltools", >+ org.eclipse.core.internal.externaltools.launchConfigurations, >+ org.eclipse.core.internal.externaltools.model >Index: src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsCoreUtil.java >=================================================================== >RCS file: src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsCoreUtil.java >diff -N src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsCoreUtil.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsCoreUtil.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,259 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Keith Seitz (keiths@redhat.com) - Bug 27243 (environment variables contribution) >+ * dakshinamurthy.karra@gmail.com - bug 165371 >+ *******************************************************************************/ >+package org.eclipse.core.internal.externaltools.launchConfigurations; >+ >+ >+import java.io.File; >+ >+import org.eclipse.core.internal.externaltools.model.IExternalToolConstants; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.variables.IStringVariableManager; >+import org.eclipse.core.variables.VariablesPlugin; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.internal.core.LaunchManager; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * Utilities for external tool launch configurations. >+ * <p> >+ * This class it not intended to be instantiated. >+ * </p> >+ */ >+public class ExternalToolsCoreUtil { >+ >+ /** >+ * Throws a core exception with an error status object built from >+ * the given message, lower level exception, and error code. >+ * >+ * @param message the status message >+ * @param exception lower level exception associated with the >+ * error, or <code>null</code> if none >+ * @param code error code >+ */ >+ protected static void abort(String message, Throwable exception, int code) throws CoreException { >+ throw new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, code, message, exception)); >+ } >+ >+ /** >+ * Expands and returns the location attribute of the given launch >+ * configuration. The location is >+ * verified to point to an existing file, in the local file system. >+ * >+ * @param configuration launch configuration >+ * @return an absolute path to a file in the local file system >+ * @throws CoreException if unable to retrieve the associated launch >+ * configuration attribute, if unable to resolve any variables, or if the >+ * resolved location does not point to an existing file in the local file >+ * system >+ */ >+ public static IPath getLocation(ILaunchConfiguration configuration) throws CoreException { >+ String location = configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String) null); >+ if (location == null) { >+ abort(NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_Location_not_specified_by__0__1, new String[] { configuration.getName()}), null, 0); >+ } else { >+ String expandedLocation = getStringVariableManager().performStringSubstitution(location); >+ if (expandedLocation == null || expandedLocation.length() == 0) { >+ String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()}); >+ abort(msg, null, 0); >+ } else { >+ File file = new File(expandedLocation); >+ if (file.isFile()) { >+ return new Path(expandedLocation); >+ } >+ >+ String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()}); >+ abort(msg, null, 0); >+ } >+ } >+ // execution will not reach here >+ return null; >+ } >+ >+ /** >+ * Returns a boolean specifying whether or not output should be captured for >+ * the given configuration >+ * >+ * @param configuration the configuration from which the value will be >+ * extracted >+ * @return boolean specifying whether or not output should be captured >+ * @throws CoreException if unable to access the associated attribute >+ */ >+ public static boolean getCaptureOutput(ILaunchConfiguration configuration) throws CoreException { >+ return configuration.getAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true); >+ } >+ >+ /** >+ * Expands and returns the working directory attribute of the given launch >+ * configuration. Returns <code>null</code> if a working directory is not >+ * specified. If specified, the working is verified to point to an existing >+ * directory in the local file system. >+ * >+ * @param configuration launch configuration >+ * @return an absolute path to a directory in the local file system, or >+ * <code>null</code> if unspecified >+ * @throws CoreException if unable to retrieve the associated launch >+ * configuration attribute, if unable to resolve any variables, or if the >+ * resolved location does not point to an existing directory in the local >+ * file system >+ */ >+ public static IPath getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException { >+ String location = configuration.getAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) null); >+ if (location != null) { >+ String expandedLocation = getStringVariableManager().performStringSubstitution(location); >+ if (expandedLocation.length() > 0) { >+ File path = new File(expandedLocation); >+ if (path.isDirectory()) { >+ return new Path(expandedLocation); >+ } >+ String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidDirectory__0_, new Object[] { expandedLocation, configuration.getName()}); >+ abort(msg, null, 0); >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * Expands and returns the arguments attribute of the given launch >+ * configuration. Returns <code>null</code> if arguments are not specified. >+ * >+ * @param configuration launch configuration >+ * @return an array of resolved arguments, or <code>null</code> if >+ * unspecified >+ * @throws CoreException if unable to retrieve the associated launch >+ * configuration attribute, or if unable to resolve any variables >+ */ >+ public static String[] getArguments(ILaunchConfiguration configuration) throws CoreException { >+ String args = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String) null); >+ if (args != null) { >+ String expanded = getStringVariableManager().performStringSubstitution(args); >+ return parseStringIntoList(expanded); >+ } >+ return null; >+ } >+ >+ private static IStringVariableManager getStringVariableManager() { >+ return VariablesPlugin.getDefault().getStringVariableManager(); >+ } >+ >+ /** >+ * Returns whether the given launch configuration is enabled. This property >+ * is intended only to apply to external tool builder configurations and >+ * determines whether the project builder will launch the configuration >+ * when it builds. >+ * >+ * @param configuration the configuration for which the enabled state should >+ * be determined. >+ * @return whether the given configuration is enabled to be run when a build occurs. >+ * @throws CoreException if unable to access the associated attribute >+ */ >+ public static boolean isBuilderEnabled(ILaunchConfiguration configuration) throws CoreException { >+ return configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_ENABLED, true); >+ } >+ >+ /** >+ * Returns the collection of resources for the build scope as specified by the given launch configuration. >+ * >+ * @param configuration launch configuration >+ * @throws CoreException if an exception occurs while retrieving the resources >+ */ >+ public static IResource[] getResourcesForBuildScope(ILaunchConfiguration configuration) throws CoreException { >+ String scope = configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_SCOPE, (String) null); >+ if (scope == null) { >+ return null; >+ } >+ >+ return LaunchManager.getRefreshResources(scope); >+ } >+ >+ /** >+ * Parses the argument text into an array of individual >+ * strings using the space character as the delimiter. >+ * An individual argument containing spaces must have a >+ * double quote (") at the start and end. Two double >+ * quotes together is taken to mean an embedded double >+ * quote in the argument text. >+ * >+ * @param arguments the arguments as one string >+ * @return the array of arguments >+ */ >+ public static String[] parseStringIntoList(String arguments) { >+ if (arguments == null || arguments.length() == 0) { >+ return new String[0]; >+ } >+ String[] res= DebugPlugin.parseArguments(arguments); >+ return res; >+ } >+ /** >+ * Returns a collection of projects referenced by a build scope attribute. >+ * >+ * @return collection of projects referred to by configuration >+ */ >+ public static IProject[] getBuildProjects(ILaunchConfiguration configuration, String buildScopeId) { >+ >+ String scope = null; >+ String id = buildScopeId ; >+ if (id == null) { >+ id = IExternalToolConstants.ATTR_BUILD_SCOPE ; >+ } >+ try { >+ scope = configuration.getAttribute(id, (String)null); >+ } catch (CoreException e) { >+ return null; >+ } >+ if (scope == null) { >+ return null; >+ } >+ if (scope.startsWith("${projects:")) { //$NON-NLS-1$ >+ String pathString = scope.substring(11, scope.length() - 1); >+ if (pathString.length() > 1) { >+ String[] names = pathString.split(","); //$NON-NLS-1$ >+ IProject[] projects = new IProject[names.length]; >+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >+ for (int i = 0; i < names.length; i++) { >+ projects[i] = root.getProject(names[i]); >+ } >+ return projects; >+ } >+ } else if (scope.equals("${project}")) { //$NON-NLS-1$ >+ if(configuration.getFile()!=null) >+ return new IProject[]{((IResource)configuration.getFile()).getProject()}; >+ } >+ return new IProject[0]; >+ } >+ >+ /** >+ * Whether referenced projects should be considered when building. Only valid >+ * when a set of projects is to be built. >+ * >+ * @param configuration >+ * @return whether referenced projects should be considerd when building >+ * @throws CoreException if unable to access the associated attribute >+ */ >+ public static boolean isIncludeReferencedProjects(ILaunchConfiguration configuration, String includeReferencedProjectsId) throws CoreException { >+ String id = includeReferencedProjectsId; >+ if (id == null) { >+ id = IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS ; >+ } >+ return configuration.getAttribute(id, true); >+ } >+ >+} >Index: src/org/eclipse/core/internal/externaltools/model/ExternalToolBuilder.java >=================================================================== >RCS file: src/org/eclipse/core/internal/externaltools/model/ExternalToolBuilder.java >diff -N src/org/eclipse/core/internal/externaltools/model/ExternalToolBuilder.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/externaltools/model/ExternalToolBuilder.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,289 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Matthew Conway - Bug 175186 >+ *******************************************************************************/ >+package org.eclipse.core.internal.externaltools.model; >+ >+ >+import java.util.Map; >+ >+import org.eclipse.core.internal.externaltools.ExternalToolsCore; >+import org.eclipse.core.internal.externaltools.launchConfigurations.ExternalToolsCoreUtil; >+import org.eclipse.core.internal.externaltools.registry.ExternalToolMigration; >+import org.eclipse.core.resources.ICommand; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IProjectDescription; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IResourceDelta; >+import org.eclipse.core.resources.IResourceDeltaVisitor; >+import org.eclipse.core.resources.IncrementalProjectBuilder; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.debug.core.ILaunchManager; >+import org.eclipse.osgi.util.NLS; >+import org.osgi.framework.Bundle; >+ >+/** >+ * This project builder implementation will run an external tool during the >+ * build process. >+ */ >+public final class ExternalToolBuilder extends IncrementalProjectBuilder { >+ private final class IgnoreTeamPrivateChanges implements IResourceDeltaVisitor { >+ private boolean[] fTrueChange; >+ private IgnoreTeamPrivateChanges(boolean[] trueChange) { >+ super(); >+ fTrueChange= trueChange; >+ } >+ public boolean visit(IResourceDelta visitDelta) throws CoreException { >+ IResource resource= visitDelta.getResource(); >+ if (resource instanceof IFile) { >+ fTrueChange[0]= true; >+ return false; >+ } >+ return true; >+ } >+ } >+ >+ public static final String ID = "org.eclipse.ui.externaltools.ExternalToolBuilder"; //$NON-NLS-1$; >+ >+ private static String buildType = IExternalToolConstants.BUILD_TYPE_NONE; >+ >+ private static IProject buildProject= null; >+ private static IResourceDelta buildDelta= null; >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { >+ if (ExternalToolsCore.getDefault().getBundle().getState() != Bundle.ACTIVE) { >+ return null; >+ } >+ >+ ILaunchConfiguration config= BuilderUtils.configFromBuildCommandArgs(getProject(), args, new String[1]); >+ if (config == null) { >+ throw ExternalToolsCore.newError(ExternalToolsModelMessages.ExternalToolBuilder_0, null); >+ } >+ IProject[] projectsWithinScope= null; >+ IResource[] resources = ExternalToolsCoreUtil.getResourcesForBuildScope(config); >+ if (resources != null) { >+ projectsWithinScope= new IProject[resources.length]; >+ for (int i = 0; i < resources.length; i++) { >+ projectsWithinScope[i]= resources[i].getProject(); >+ } >+ } >+ boolean kindCompatible= commandConfiguredForKind(config, kind); >+ if (kindCompatible && configEnabled(config)) { >+ doBuildBasedOnScope(resources, kind, config, monitor); >+ } >+ >+ return projectsWithinScope; >+ } >+ >+ private boolean commandConfiguredForKind(ILaunchConfiguration config, int kind) { >+ try { >+ if (!(config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false))) { >+ ICommand command= getCommand(); >+ //adapt the builder command to make use of the 3.1 support for setting command build kinds >+ //this will only happen once for builder/command defined before the support existed >+ BuilderUtils.configureTriggers(config, command); >+ IProjectDescription desc= getProject().getDescription(); >+ ICommand[] commands= desc.getBuildSpec(); >+ int index= getBuilderCommandIndex(commands, command); >+ if (index != -1) { >+ commands[index]= command; >+ desc.setBuildSpec(commands); >+ getProject().setDescription(desc, null); >+ ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy(); >+ copy.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, true); >+ copy.doSave(); >+ } >+ return command.isBuilding(kind); >+ } >+ } catch (CoreException e) { >+ ExternalToolsCore.getDefault().log(e); >+ return true; >+ } >+ return true; >+ } >+ >+ private int getBuilderCommandIndex(ICommand[] buildSpec, ICommand command) { >+ Map commandArgs= command.getArguments(); >+ if (commandArgs == null) { >+ return -1; >+ } >+ String handle= (String) commandArgs.get(BuilderUtils.LAUNCH_CONFIG_HANDLE); >+ if (handle == null) { >+ return -1; >+ } >+ for (int i = 0; i < buildSpec.length; ++i) { >+ ICommand buildSpecCommand= buildSpec[i]; >+ if (ID.equals(buildSpecCommand.getBuilderName())) { >+ Map buildSpecArgs= buildSpecCommand.getArguments(); >+ if (buildSpecArgs != null) { >+ String buildSpecHandle= (String) buildSpecArgs.get(BuilderUtils.LAUNCH_CONFIG_HANDLE); >+ if (handle.equals(buildSpecHandle)) { >+ return i; >+ } >+ } >+ } >+ } >+ return -1; >+ } >+ >+ /** >+ * Returns whether the given builder config is enabled or not. >+ * >+ * @param config the config to examine >+ * @return whether the config is enabled >+ */ >+ private boolean configEnabled(ILaunchConfiguration config) { >+ try { >+ return ExternalToolsCoreUtil.isBuilderEnabled(config); >+ } catch (CoreException e) { >+ ExternalToolsCore.getDefault().log(e); >+ } >+ return true; >+ } >+ >+ private void doBuildBasedOnScope(IResource[] resources, int kind, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException { >+ boolean buildForChange = true; >+ if (kind != FULL_BUILD) { //scope not applied for full builds >+ if (resources != null && resources.length > 0) { >+ buildForChange = buildScopeIndicatesBuild(resources); >+ } >+ } >+ >+ if (buildForChange) { >+ launchBuild(kind, config, monitor); >+ } >+ } >+ >+ private void launchBuild(int kind, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException { >+ monitor.subTask(NLS.bind(ExternalToolsModelMessages.ExternalToolBuilder_Running__0_____1, new String[] { config.getName()})); >+ buildStarted(kind); >+ // The default value for "launch in background" is true in debug core. If >+ // the user doesn't go through the UI, the new attribute won't be set. This means >+ // that existing Ant builders will try to run in the background (and likely conflict with >+ // each other) without migration. >+ config= ExternalToolMigration.migrateRunInBackground(config); >+ config.launch(ILaunchManager.RUN_MODE, monitor); >+ buildEnded(); >+ } >+ >+ /** >+ * Returns the build type being performed if the >+ * external tool is being run as a project builder. >+ * >+ * @return one of the <code>IExternalToolConstants.BUILD_TYPE_*</code> constants. >+ */ >+ public static String getBuildType() { >+ return buildType; >+ } >+ >+ /** >+ * Returns the project that is being built and has triggered the current external >+ * tool builder. <code>null</code> is returned if no build is currently occurring. >+ * >+ * @return project being built or <code>null</code>. >+ */ >+ public static IProject getBuildProject() { >+ return buildProject; >+ } >+ >+ /** >+ * Returns the <code>IResourceDelta</code> that is being built and has triggered the current external >+ * tool builder. <code>null</code> is returned if no build is currently occurring. >+ * >+ * @return resource delta for the build or <code>null</code> >+ */ >+ public static IResourceDelta getBuildDelta() { >+ return buildDelta; >+ } >+ >+ /** >+ * Stores the currently active build kind and build project when a build begins >+ * @param buildKind >+ */ >+ private void buildStarted(int buildKind) { >+ switch (buildKind) { >+ case IncrementalProjectBuilder.INCREMENTAL_BUILD : >+ buildType = IExternalToolConstants.BUILD_TYPE_INCREMENTAL; >+ buildDelta = getDelta(getProject()); >+ break; >+ case IncrementalProjectBuilder.FULL_BUILD : >+ buildType = IExternalToolConstants.BUILD_TYPE_FULL; >+ break; >+ case IncrementalProjectBuilder.AUTO_BUILD : >+ buildType = IExternalToolConstants.BUILD_TYPE_AUTO; >+ buildDelta = getDelta(getProject()); >+ break; >+ case IncrementalProjectBuilder.CLEAN_BUILD : >+ buildType = IExternalToolConstants.BUILD_TYPE_CLEAN; >+ break; >+ default : >+ buildType = IExternalToolConstants.BUILD_TYPE_NONE; >+ break; >+ } >+ buildProject= getProject(); >+ } >+ >+ /** >+ * Clears the current build kind, build project and build delta when a build finishes. >+ */ >+ private void buildEnded() { >+ buildType= IExternalToolConstants.BUILD_TYPE_NONE; >+ buildProject= null; >+ buildDelta= null; >+ } >+ >+ private boolean buildScopeIndicatesBuild(IResource[] resources) { >+ for (int i = 0; i < resources.length; i++) { >+ IResourceDelta delta = getDelta(resources[i].getProject()); >+ if (delta == null) { >+ //project just added to the workspace..no previous build tree >+ return true; >+ } >+ IPath path= resources[i].getProjectRelativePath(); >+ IResourceDelta change= delta.findMember(path); >+ if (change != null) { >+ final boolean[] trueChange= new boolean[1]; >+ trueChange[0]= false; >+ try { >+ change.accept(new IgnoreTeamPrivateChanges(trueChange)); >+ } catch (CoreException e) { >+ ExternalToolsCore.getDefault().log("Internal error resolving changed resources during build", e); //$NON-NLS-1$ >+ } >+ >+ return trueChange[0]; //filtered out team private changes >+ } >+ } >+ return false; >+ } >+ >+ protected void clean(IProgressMonitor monitor) throws CoreException { >+ ICommand command= getCommand(); >+ ILaunchConfiguration config= BuilderUtils.configFromBuildCommandArgs(getProject(), command.getArguments(), new String[1]); >+ if (!configEnabled(config)) { >+ return; >+ } >+ >+ if ((!config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false))) { >+ //old behavior >+ super.clean(monitor); >+ return; >+ } >+ >+ launchBuild(IncrementalProjectBuilder.CLEAN_BUILD, config, monitor); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/core/internal/externaltools/registry/ExternalToolMigration.java >=================================================================== >RCS file: src/org/eclipse/core/internal/externaltools/registry/ExternalToolMigration.java >diff -N src/org/eclipse/core/internal/externaltools/registry/ExternalToolMigration.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/externaltools/registry/ExternalToolMigration.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,410 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.core.internal.externaltools.registry; >+ >+ >+import java.util.ArrayList; >+import java.util.Map; >+import java.util.StringTokenizer; >+ >+import org.eclipse.core.internal.externaltools.ExternalToolsCore; >+import org.eclipse.core.internal.externaltools.launchConfigurations.ExternalToolsMigrationMessages; >+import org.eclipse.core.internal.externaltools.model.IExternalToolConstants; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationType; >+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.debug.core.ILaunchManager; >+ >+ >+/** >+ * Responsible reading an old external tool format and creating >+ * and migrating it to create a new external tool. >+ */ >+public final class ExternalToolMigration { >+ /** >+ * Structure to represent a variable definition within a >+ * source string. >+ */ >+ public static final class VariableDefinition { >+ /** >+ * Index in the source text where the variable started >+ * or <code>-1</code> if no valid variable start tag >+ * identifier found. >+ */ >+ public int start = -1; >+ >+ /** >+ * Index in the source text of the character following >+ * the end of the variable or <code>-1</code> if no >+ * valid variable end tag found. >+ */ >+ public int end = -1; >+ >+ /** >+ * The variable's name found in the source text, or >+ * <code>null</code> if no valid variable found. >+ */ >+ public String name = null; >+ >+ /** >+ * The variable's argument found in the source text, or >+ * <code>null</code> if no valid variable found or if >+ * the variable did not specify an argument >+ */ >+ public String argument = null; >+ >+ /** >+ * Create an initialized variable definition. >+ */ >+ private VariableDefinition() { >+ super(); >+ } >+ } >+ >+ /** >+ * Variable tag indentifiers >+ */ >+ private static final String VAR_TAG_START = "${"; //$NON-NLS-1$ >+ private static final String VAR_TAG_END = "}"; //$NON-NLS-1$ >+ private static final String VAR_TAG_SEP = ":"; //$NON-NLS-1$ >+ >+ /** >+ * External tool type for Ant build files (value <code>antBuildType</code>). >+ */ >+ public static final String TOOL_TYPE_ANT_BUILD = "antBuildType"; //$NON-NLS-1$; >+ /** >+ * Ant builder launch configuration type identifier. Ant project builders >+ * are of this type. >+ */ >+ public static final String ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ant.AntBuilderLaunchConfigurationType"; //$NON-NLS-1$ >+ >+ public static final String RUN_TARGETS_ATTRIBUTE = TOOL_TYPE_ANT_BUILD + ".runTargets"; //$NON-NLS-1$; >+ >+ /** >+ * String attribute indicating the Ant targets to execute. Default value is >+ * <code>null</code> which indicates that the default target is to be >+ * executed. Format is a comma separated listing of targets. >+ * NOTE: This value is copied here from org.eclipse.ant.ui.internal.IAntLaunchConfigurationConstants. >+ * Ant no longer resides in External Tools and this plug-in. This value is kept here only >+ * for migration. >+ */ >+ public static final String ATTR_ANT_TARGETS = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_TARGETS"; //$NON-NLS-1$ >+ >+ /* >+ * 2.0 External Tool Tags >+ */ >+ public static final String TAG_TOOL_TYPE = "!{tool_type}"; //$NON-NLS-1$ >+ public static final String TAG_TOOL_NAME = "!{tool_name}"; //$NON-NLS-1$ >+ public static final String TAG_TOOL_LOCATION = "!{tool_loc}"; //$NON-NLS-1$ >+ public static final String TAG_TOOL_ARGUMENTS = "!{tool_args}"; //$NON-NLS-1$ >+ public static final String TAG_TOOL_DIRECTORY = "!{tool_dir}"; //$NON-NLS-1$ >+ public static final String TAG_TOOL_REFRESH = "!{tool_refresh}"; //$NON-NLS-1$ >+ public static final String TAG_TOOL_SHOW_LOG = "!{tool_show_log}"; //$NON-NLS-1$ >+ public static final String TAG_TOOL_BUILD_TYPES = "!{tool_build_types}"; //$NON-NLS-1$ >+ public static final String TAG_TOOL_BLOCK = "!{tool_block}"; //$NON-NLS-1$ >+ >+ // Known kind of tools >+ private static final String TOOL_TYPE_ANT = "org.eclipse.ui.externaltools.type.ant"; //$NON-NLS-1$ >+ private static final String TOOL_TYPE_PROGRAM = "org.eclipse.ui.externaltools.type.program"; //$NON-NLS-1$ >+ >+ /* >+ * 2.1 External Tool Keys >+ */ >+ public static final String TAG_TYPE = "type"; //$NON-NLS-1$ >+ public static final String TAG_NAME = "name"; //$NON-NLS-1$ >+ public static final String TAG_LOCATION = "location"; //$NON-NLS-1$ >+ public static final String TAG_WORK_DIR = "workDirectory"; //$NON-NLS-1$ >+ public static final String TAG_CAPTURE_OUTPUT = "captureOutput"; //$NON-NLS-1$ >+ public static final String TAG_SHOW_CONSOLE = "showConsole"; //$NON-NLS-1$ >+ public static final String TAG_RUN_BKGRND = "runInBackground"; //$NON-NLS-1$ >+ public static final String TAG_PROMPT_ARGS = "promptForArguments"; //$NON-NLS-1$ >+ public static final String TAG_ARGS = "arguments"; //$NON-NLS-1$ >+ public static final String TAG_REFRESH_SCOPE = "refreshScope"; //$NON-NLS-1$ >+ public static final String TAG_REFRESH_RECURSIVE = "refreshRecursive"; //$NON-NLS-1$ >+ public static final String TAG_RUN_BUILD_KINDS = "runForBuildKinds"; //$NON-NLS-1$ >+ public static final String TAG_EXTRA_ATTR = "extraAttribute"; //$NON-NLS-1$ >+ public static final String TAG_VERSION = "version"; //$NON-NLS-1$ >+ >+ private static final String EXTRA_ATTR_SEPARATOR = "="; //$NON-NLS-1$ >+ >+ private static final String VERSION_21 = "2.1"; //$NON-NLS-1$; >+ >+ private static final String TRUE = "true"; //$NON-NLS-1$ >+ private static final String FALSE = "false"; //$NON-NLS-1$ >+ >+ /** >+ * Allows no instances. >+ */ >+ private ExternalToolMigration() { >+ super(); >+ } >+ >+ /** >+ * Returns a launch configuration working copy from the argument map or >+ * <code>null</code> if the given map cannot be interpreted as a 2.0 or 2.1 >+ * branch external tool. The returned working copy will be unsaved and its >+ * location will be set to the metadata area. >+ */ >+ public static ILaunchConfigurationWorkingCopy configFromArgumentMap(Map args) { >+ String version = (String) args.get(TAG_VERSION); >+ if (VERSION_21.equals(version)) { >+ return configFrom21ArgumentMap(args); >+ } >+ return configFrom20ArgumentMap(args); >+ } >+ >+ public static ILaunchConfigurationWorkingCopy configFrom21ArgumentMap(Map commandArgs) { >+ String name = (String) commandArgs.get(TAG_NAME); >+ String type = (String) commandArgs.get(TAG_TYPE); >+ >+ ILaunchConfigurationWorkingCopy config = newConfig(type, name); >+ if (config == null) { >+ return null; >+ } >+ >+ config.setAttribute(IExternalToolConstants.ATTR_LOCATION, (String) commandArgs.get(TAG_LOCATION)); >+ config.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) commandArgs.get(TAG_WORK_DIR)); >+ config.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, TRUE.equals(commandArgs.get(TAG_CAPTURE_OUTPUT))); >+ config.setAttribute(IExternalToolConstants.ATTR_SHOW_CONSOLE, TRUE.equals(commandArgs.get(TAG_SHOW_CONSOLE))); >+ config.setAttribute(ILaunchManager.ATTR_LAUNCH_IN_BACKGROUND, TRUE.equals(commandArgs.get(TAG_RUN_BKGRND))); >+ config.setAttribute(IExternalToolConstants.ATTR_PROMPT_FOR_ARGUMENTS, TRUE.equals(commandArgs.get(TAG_PROMPT_ARGS))); >+ config.setAttribute(ILaunchManager.ATTR_REFRESH_SCOPE, (String) commandArgs.get(TAG_REFRESH_SCOPE)); >+ config.setAttribute(ILaunchManager.ATTR_REFRESH_RECURSIVE, TRUE.equals(commandArgs.get(TAG_REFRESH_RECURSIVE))); >+ >+ config.setAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, (String) commandArgs.get(TAG_RUN_BUILD_KINDS)); >+ >+ String args = (String) commandArgs.get(TAG_ARGS); >+ if (args != null) { >+ config.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, args); >+ } >+ >+ String extraAttributes = (String) commandArgs.get(TAG_EXTRA_ATTR); >+ if (extraAttributes != null) { >+ StringTokenizer tokenizer = new StringTokenizer(extraAttributes, EXTRA_ATTR_SEPARATOR); >+ while (tokenizer.hasMoreTokens()) { >+ String key = tokenizer.nextToken(); >+ if (!tokenizer.hasMoreTokens()) >+ break; >+ String value = tokenizer.nextToken(); >+ if (key.equals(RUN_TARGETS_ATTRIBUTE)) { >+ // 2.1 implementation only defined 1 "extra attribute" >+ config.setAttribute(ATTR_ANT_TARGETS, value); >+ } >+ } >+ } >+ return config; >+ } >+ >+ /** >+ * Creates an external tool from the map. >+ */ >+ public static ILaunchConfigurationWorkingCopy configFrom20ArgumentMap(Map args) { >+ // Update the type... >+ String type = (String) args.get(TAG_TOOL_TYPE); >+ if (TOOL_TYPE_ANT.equals(type)) { >+ type = TOOL_TYPE_ANT_BUILD; >+ } else if (TOOL_TYPE_PROGRAM.equals(type)){ >+ type = IExternalToolConstants.TOOL_TYPE_PROGRAM; >+ } else { >+ return null; >+ } >+ >+ String name = (String) args.get(TAG_TOOL_NAME); >+ >+ ILaunchConfigurationWorkingCopy config = newConfig(type, name); >+ if (config == null) { >+ return null; >+ } >+ >+ // Update the location... >+ String location = (String) args.get(TAG_TOOL_LOCATION); >+ config.setAttribute(IExternalToolConstants.ATTR_LOCATION, location); >+ >+ // Update the refresh scope... >+ String refresh = (String) args.get(TAG_TOOL_REFRESH); >+ if (refresh != null) { >+ VariableDefinition varDef = extractVariableDefinition(refresh, 0); >+ if ("none".equals(varDef.name)) { //$NON-NLS-1$ >+ refresh = null; >+ } >+ config.setAttribute(ILaunchManager.ATTR_REFRESH_SCOPE, refresh); >+ } >+ >+ // Update the arguments >+ String arguments = (String) args.get(TAG_TOOL_ARGUMENTS); >+ if (type.equals(TOOL_TYPE_ANT_BUILD)) { >+ String targetNames = null; >+ if (arguments != null) { >+ int start = 0; >+ ArrayList targets = new ArrayList(); >+ StringBuffer buffer = new StringBuffer(); >+ VariableDefinition varDef = extractVariableDefinition(arguments, start); >+ while (varDef.end != -1) { >+ if ("ant_target".equals(varDef.name) && varDef.argument != null) { //$NON-NLS-1$ >+ targets.add(varDef.argument); >+ buffer.append(arguments.substring(start, varDef.start)); >+ } else { >+ buffer.append(arguments.substring(start, varDef.end)); >+ } >+ start = varDef.end; >+ varDef = extractVariableDefinition(arguments, start); >+ } >+ buffer.append(arguments.substring(start, arguments.length())); >+ arguments = buffer.toString(); >+ >+ buffer.setLength(0); >+ for (int i = 0; i < targets.size(); i++) { >+ String target = (String) targets.get(i); >+ if (target != null && target.length() > 0) { >+ buffer.append(target); >+ buffer.append(","); //$NON-NLS-1$ >+ } >+ } >+ targetNames = buffer.toString(); >+ } >+ if (targetNames != null && targetNames.length() > 0) { >+ config.setAttribute(ATTR_ANT_TARGETS, targetNames); >+ } >+ } >+ config.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, arguments); >+ >+ // Collect the rest of the information >+ config.setAttribute(IExternalToolConstants.ATTR_SHOW_CONSOLE, TRUE.equals(args.get(TAG_TOOL_SHOW_LOG))); >+ config.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, TRUE.equals(args.get(TAG_TOOL_SHOW_LOG))); >+ config.setAttribute(ILaunchManager.ATTR_LAUNCH_IN_BACKGROUND, FALSE.equals(args.get(TAG_TOOL_BLOCK))); >+ String buildKinds= (String) args.get(TAG_TOOL_BUILD_TYPES); >+ if (buildKinds != null) { >+ buildKinds= buildKinds.replace(';', ','); // Replace the old separator with the new >+ } >+ config.setAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, buildKinds); >+ config.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) args.get(TAG_TOOL_DIRECTORY)); >+ return config; >+ } >+ >+ /** >+ * Returns a new working copy with the given external tool name and external >+ * tool type or <code>null</code> if no config could be created. >+ */ >+ private static ILaunchConfigurationWorkingCopy newConfig(String type, String name) { >+ if (type == null || name == null) { >+ return null; >+ } >+ ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); >+ ILaunchConfigurationType configType; >+ if (TOOL_TYPE_ANT_BUILD.equals(type)) { >+ configType = manager.getLaunchConfigurationType(ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE); >+ } else if (IExternalToolConstants.TOOL_TYPE_PROGRAM.equals(type)) { >+ configType = manager.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_BUILDER_LAUNCH_CONFIGURATION_TYPE); >+ } else { >+ return null; >+ } >+ try { >+ if (configType != null) { >+ return configType.newInstance(null, name); >+ } >+ } catch (CoreException e) { >+ ExternalToolsCore.getDefault().log(e); >+ } >+ return null; >+ } >+ >+ /** >+ * Returns the tool name extracted from the given command argument map. >+ * Extraction is attempted using 2.0 and 2.1 external tool formats. >+ */ >+ public static String getNameFromCommandArgs(Map commandArgs) { >+ String name= (String) commandArgs.get(TAG_NAME); >+ if (name == null) { >+ name= (String) commandArgs.get(TAG_TOOL_NAME); >+ } >+ return name; >+ } >+ >+ /** >+ * Migrate the old RUN_IN_BACKGROUND launch config attribute to the new >+ * LAUNCH_IN_BACKGROUND attribute provided by the debug ui plugin. >+ * >+ * @param config the config to migrate >+ * @return the migrated config >+ */ >+ public static ILaunchConfiguration migrateRunInBackground(ILaunchConfiguration config) { >+ String noValueFlag= "NoValue"; //$NON-NLS-1$ >+ String attr= null; >+ try { >+ attr = config.getAttribute(ILaunchManager.ATTR_LAUNCH_IN_BACKGROUND, noValueFlag); >+ } catch (CoreException e) { >+ // Exception will occur if the attribute is already set because the attribute is actually a boolean. >+ // No migration necessary. >+ return config; >+ } >+ if (noValueFlag.equals(attr)) { >+ //the old constant >+ String ATTR_RUN_IN_BACKGROUND= IExternalToolConstants.PLUGIN_ID + ".ATTR_RUN_IN_BACKGROUND"; //$NON-NLS-1$ >+ boolean runInBackground= false; >+ try { >+ runInBackground = config.getAttribute(ATTR_RUN_IN_BACKGROUND, runInBackground); >+ } catch (CoreException e) { >+ ExternalToolsCore.getDefault().log(ExternalToolsMigrationMessages.ExternalToolMigration_37, e); >+ } >+ try { >+ ILaunchConfigurationWorkingCopy workingCopy= config.getWorkingCopy(); >+ workingCopy.setAttribute(ILaunchManager.ATTR_LAUNCH_IN_BACKGROUND, runInBackground); >+ config= workingCopy.doSave(); >+ } catch (CoreException e) { >+ ExternalToolsCore.getDefault().log(ExternalToolsMigrationMessages.ExternalToolMigration_38, e); >+ } >+ } >+ return config; >+ } >+ >+ /** >+ * Extracts a variable name and argument from the given string. >+ * >+ * @param text the source text to parse for a variable tag >+ * @param start the index in the string to start the search >+ * @return the variable definition >+ */ >+ public static VariableDefinition extractVariableDefinition(String text, int start) { >+ VariableDefinition varDef = new VariableDefinition(); >+ >+ varDef.start = text.indexOf(VAR_TAG_START, start); >+ if (varDef.start < 0){ >+ return varDef; >+ } >+ start = varDef.start + VAR_TAG_START.length(); >+ >+ int end = text.indexOf(VAR_TAG_END, start); >+ if (end < 0) { >+ return varDef; >+ } >+ varDef.end = end + VAR_TAG_END.length(); >+ if (end == start) { >+ return varDef; >+ } >+ >+ int mid = text.indexOf(VAR_TAG_SEP, start); >+ if (mid < 0 || mid > end) { >+ varDef.name = text.substring(start, end); >+ } else { >+ if (mid > start) { >+ varDef.name = text.substring(start, mid); >+ } >+ mid = mid + VAR_TAG_SEP.length(); >+ if (mid < end) { >+ varDef.argument = text.substring(mid, end); >+ } >+ } >+ >+ return varDef; >+ } >+} >Index: src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsLaunchConfigurationMessages.java >=================================================================== >RCS file: src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsLaunchConfigurationMessages.java >diff -N src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsLaunchConfigurationMessages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsLaunchConfigurationMessages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,26 @@ >+/********************************************************************** >+ * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ * dakshinamurthy.karra@gmail.com - bug 165371 >+ **********************************************************************/ >+package org.eclipse.core.internal.externaltools.launchConfigurations; >+ >+import org.eclipse.osgi.util.NLS; >+ >+public class ExternalToolsLaunchConfigurationMessages extends NLS { >+ private static final String BUNDLE_NAME = "org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsLaunchConfigurationMessages";//$NON-NLS-1$ >+ >+ public static String ExternalToolsUtil_Location_not_specified_by__0__1; >+ public static String ExternalToolsUtil_invalidLocation__0_; >+ public static String ExternalToolsUtil_invalidDirectory__0_; >+ >+ static { >+ // load message values from bundle file >+ NLS.initializeMessages(BUNDLE_NAME, ExternalToolsLaunchConfigurationMessages.class); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/core/internal/externaltools/model/ExternalToolsModelMessages.java >=================================================================== >RCS file: src/org/eclipse/core/internal/externaltools/model/ExternalToolsModelMessages.java >diff -N src/org/eclipse/core/internal/externaltools/model/ExternalToolsModelMessages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/externaltools/model/ExternalToolsModelMessages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,28 @@ >+/********************************************************************** >+ * Copyright (c) 2000, 2005 IBM Corporation and others. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.core.internal.externaltools.model; >+ >+import org.eclipse.osgi.util.NLS; >+ >+public class ExternalToolsModelMessages extends NLS { >+ private static final String BUNDLE_NAME = "org.eclipse.ui.externaltools.internal.model.ExternalToolsModelMessages";//$NON-NLS-1$ >+ >+ public static String ImageDescriptorRegistry_Allocating_image_for_wrong_display_1; >+ public static String ExternalToolBuilder_Running__0_____1; >+ public static String ExternalToolBuilder_0; >+ public static String BuilderUtils_5; >+ public static String BuilderUtils_6; >+ public static String BuilderUtils_7; >+ >+ static { >+ // load message values from bundle file >+ NLS.initializeMessages(BUNDLE_NAME, ExternalToolsModelMessages.class); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/core/internal/externaltools/model/ExternalToolsModelMessages.properties >=================================================================== >RCS file: src/org/eclipse/core/internal/externaltools/model/ExternalToolsModelMessages.properties >diff -N src/org/eclipse/core/internal/externaltools/model/ExternalToolsModelMessages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/externaltools/model/ExternalToolsModelMessages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,17 @@ >+############################################################################### >+# Copyright (c) 2000, 2005 IBM Corporation and others. >+# All rights reserved. This program and the accompanying materials >+# are made available under the terms of the Eclipse Public License v1.0 >+# which accompanies this distribution, and is available at >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# IBM Corporation - initial API and implementation >+############################################################################### >+ >+ImageDescriptorRegistry_Allocating_image_for_wrong_display_1=Allocating image for wrong display >+ExternalToolBuilder_Running__0_____1=Running {0}... >+ExternalToolBuilder_0=The builder launch configuration could not be found. >+BuilderUtils_5=Command Error >+BuilderUtils_6=An error occurred while saving the build commands of the project >+BuilderUtils_7=\ [Builder] >Index: src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsProgramMessages.properties >=================================================================== >RCS file: src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsProgramMessages.properties >diff -N src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsProgramMessages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsProgramMessages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,19 @@ >+############################################################################### >+# Copyright (c) 2000, 2005 IBM Corporation and others. >+# All rights reserved. This program and the accompanying materials >+# are made available under the terms of the Eclipse Public License v1.0 >+# which accompanies this distribution, and is available at >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# IBM Corporation - initial API and implementation >+############################################################################### >+ >+BackgroundResourceRefresher_0=Refreshing resources... >+ >+ProgramLaunchDelegate_Workbench_Closing_1=Workbench Closing >+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. >+ProgramLaunchDelegate_3=Running {0}... >+ProgramLaunchDelegate_4=An IProcess could not be created for the launch >+ >+ProgramMainTab_Select=&Select a program: >Index: src/org/eclipse/core/internal/externaltools/model/IExternalToolConstants.java >=================================================================== >RCS file: src/org/eclipse/core/internal/externaltools/model/IExternalToolConstants.java >diff -N src/org/eclipse/core/internal/externaltools/model/IExternalToolConstants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/externaltools/model/IExternalToolConstants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,231 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * dakshinamurthy.karra@gmail.com - bug 165371 >+ *******************************************************************************/ >+package org.eclipse.core.internal.externaltools.model; >+ >+/** >+ * Defines the constants available for client use. >+ * <p> >+ * This interface is not intended to be extended or implemented by clients. >+ * </p> >+ */ >+public interface IExternalToolConstants { >+ /** >+ * Plugin identifier for external tools (value <code>org.eclipse.ui.externaltools</code>). >+ */ >+ public static final String PLUGIN_ID = "org.eclipse.ui.externaltools"; //$NON-NLS-1$; >+ >+ // ------- Extensions Points ------- >+ /** >+ * Extension point to declare the launch configuration type that should be >+ * created when duplicating an existing configuration as a project builder. >+ */ >+ public static final String EXTENSION_POINT_CONFIGURATION_DUPLICATION_MAPS = "configurationDuplicationMaps"; //$NON-NLS-1$ >+ // ------- Refresh Variables ------- >+ /** >+ * Variable that expands to the workspace root object (value <code>workspace</code>). >+ */ >+ public static final String VAR_WORKSPACE = "workspace"; //$NON-NLS-1$ >+ /** >+ * Variable that expands to the project resource (value <code>project</code>). >+ */ >+ public static final String VAR_PROJECT = "project"; //$NON-NLS-1$ >+ /** >+ * Variable that expands to the container resource (value <code>container</code>). >+ */ >+ public static final String VAR_CONTAINER = "container"; //$NON-NLS-1$ >+ /** >+ * Variable that expands to a resource (value <code>resource</code>). >+ */ >+ public static final String VAR_RESOURCE = "resource"; //$NON-NLS-1$ >+ /** >+ * Variable that expands to the working set object (value <code>working_set</code>). >+ */ >+ public static final String VAR_WORKING_SET = "working_set"; //$NON-NLS-1$ >+ // ------- Tool Types ------- >+ /** >+ * External tool type for programs such as executables, batch files, >+ * shell scripts, etc (value <code>programType</code>). >+ */ >+ public static final String TOOL_TYPE_PROGRAM = "programType"; //$NON-NLS-1$; >+ >+ // ------- Build Types ------- >+ /** >+ * Build type indicating an incremental project build request for >+ * the external tool running as a builder (value <code>incremental</code>). >+ */ >+ public static final String BUILD_TYPE_INCREMENTAL = "incremental"; //$NON-NLS-1$ >+ >+ /** >+ * Build type indicating a full project build request for >+ * the external tool running as a builder (value <code>full</code>). >+ */ >+ public static final String BUILD_TYPE_FULL = "full"; //$NON-NLS-1$ >+ >+ /** >+ * Build type indicating an automatic project build request for >+ * the external tool running as a builder (value <code>auto</code>). >+ */ >+ public static final String BUILD_TYPE_AUTO = "auto"; //$NON-NLS-1$ >+ >+ /** >+ * Build type indicating a clean project build request for >+ * the external tool running as a builder (value <code>clean</code>). >+ */ >+ public static final String BUILD_TYPE_CLEAN = "clean"; //$NON-NLS-1$ >+ >+ /** >+ * Build type indicating no project build request for >+ * the external tool running as a builder (value <code>none</code>). >+ */ >+ public static final String BUILD_TYPE_NONE = "none"; //$NON-NLS-1$ >+ >+ // ------- Images ------- >+ >+ /** >+ * Main tab image. >+ */ >+ public static final String IMG_TAB_MAIN = PLUGIN_ID + ".IMG_TAB_MAIN"; //$NON-NLS-1$ >+ >+ /** >+ * Build tab image >+ */ >+ public static final String IMG_TAB_BUILD = PLUGIN_ID + ".IMG_TAB_BUILD"; //$NON-NLS-1$ >+ >+ // ------- Launch configuration types -------- >+ /** >+ * Program launch configuration type identifier. >+ */ >+ public static final String ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"; //$NON-NLS-1$ >+ >+ /** >+ * Program builder launch configuration type identifier. Program project >+ * builders are of this type. >+ */ >+ public static final String ID_PROGRAM_BUILDER_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType"; //$NON-NLS-1$ >+ >+ // ------- Launch configuration category -------- >+ /** >+ * Identifier for external tools launch configuration category. Launch >+ * configuration types for external tools that appear in the external tools >+ * launch configuration dialog should belong to this category. >+ */ >+ public static final String ID_EXTERNAL_TOOLS_LAUNCH_CATEGORY = "org.eclipse.ui.externaltools"; //$NON-NLS-1$ >+ /** >+ * Identifier for external tools launch configuration builders category. >+ * Launch configuration types that can be added as project builders should >+ * belong to this category. >+ */ >+ public static final String ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY = "org.eclipse.ui.externaltools.builder"; //$NON-NLS-1$ >+ >+ // ------- Launch configuration groups -------- >+ /** >+ * Identifier for external tools launch configuration group. The external >+ * tools launch configuration group corresponds to the external tools >+ * category in run mode. >+ */ >+ public static final String ID_EXTERNAL_TOOLS_LAUNCH_GROUP = "org.eclipse.ui.externaltools.launchGroup"; //$NON-NLS-1$ >+ /** >+ * Identifier for external tools launch configuration group >+ */ >+ public static final String ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_GROUP = "org.eclipse.ui.externaltools.launchGroup.builder"; //$NON-NLS-1$ >+ >+ // ------- Common External Tool Launch Configuration Attributes ------- >+ >+ /** >+ * Boolean attribute indicating if external tool output should be captured. >+ * Default value is <code>false</code>. >+ * @deprecated since 3.1 Replaced by <code>org.eclipse.debug.core.DebugPlugin.ATTR_CAPTURE_OUTPUT</code> >+ */ >+ public static final String ATTR_CAPTURE_OUTPUT = PLUGIN_ID + ".ATTR_CAPTURE_OUTPUT"; //$NON-NLS-1$ >+ /** >+ * String attribute identifying the location of an external. Default value >+ * is <code>null</code>. Encoding is tool specific. >+ */ >+ public static final String ATTR_LOCATION = PLUGIN_ID + ".ATTR_LOCATION"; //$NON-NLS-1$ >+ >+ /** >+ * Boolean attribute indicating if the user should be prompted for >+ * arguments before running a tool. Default value is <code>false</code>. >+ * THIS ATTRIBUTE IS NOT USED. >+ */ >+ public static final String ATTR_PROMPT_FOR_ARGUMENTS = PLUGIN_ID + ".ATTR_PROMPT_FOR_ARGUMENTS"; //$NON-NLS-1$ >+ >+ /** >+ * String attribute identifying the scope of resources that should trigger an >+ * external tool to run. Default value is <code>null</code> >+ * indicating that the builder will be triggered for all changes. >+ */ >+ public static final String ATTR_BUILDER_SCOPE = PLUGIN_ID + ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$ >+ >+ /** >+ * String attribute containing an array of build kinds for which an >+ * external tool builder should be run. >+ */ >+ public static final String ATTR_RUN_BUILD_KINDS = PLUGIN_ID + ".ATTR_RUN_BUILD_KINDS"; //$NON-NLS-1$ >+ >+ /** >+ * Boolean attribute indicating if the console should be shown on external >+ * tool output. Default value is <code>false</code>. >+ */ >+ public static final String ATTR_SHOW_CONSOLE = PLUGIN_ID + ".ATTR_SHOW_CONSOLE"; //$NON-NLS-1$ >+ >+ /** >+ * String attribute containing the arguments that should be passed to the >+ * tool. Default value is <code>null</code>, and encoding is tool specific. >+ */ >+ public static final String ATTR_TOOL_ARGUMENTS = PLUGIN_ID + ".ATTR_TOOL_ARGUMENTS"; //$NON-NLS-1$ >+ >+ /** >+ * String attribute identifying the working directory of an external tool. >+ * Default value is <code>null</code>, which indicates a default working >+ * directory, which is tool specific. >+ */ >+ public static final String ATTR_WORKING_DIRECTORY = PLUGIN_ID + ".ATTR_WORKING_DIRECTORY"; //$NON-NLS-1$ >+ >+ /** >+ * String attribute identifying whether an external tool builder configuration >+ * is enabled. The default value is <code>true</code>, which indicates >+ * that the configuration will be executed as appropriate by the builder. >+ */ >+ public static final String ATTR_BUILDER_ENABLED = PLUGIN_ID + ".ATTR_BUILDER_ENABLED"; //$NON-NLS-1$ >+ >+ /** >+ * Status code indicating an unexpected internal error. >+ */ >+ public static final int ERR_INTERNAL_ERROR = 150; >+ >+ /** >+ * String attribute identifying a non-external tool builder launch configuration that is disabled >+ * The value is the name of the disabled builder. >+ */ >+ public static final String ATTR_DISABLED_BUILDER = PLUGIN_ID + ".ATTR_DISABLED_BUILDER"; //$NON-NLS-1$ >+ >+ /** >+ * boolean attribute identifying that an external tool builder has been configured for triggering >+ * using the <code>ICommand.setBuilding(int)</code> mechanism >+ * @since 3.1 >+ */ >+ public static final String ATTR_TRIGGERS_CONFIGURED = PLUGIN_ID + ".ATTR_TRIGGERS_CONFIGURED"; //$NON-NLS-1$ >+ >+ /** >+ * String attribute identifying the build scope for a launch configuration. >+ * <code>null</code> indicates the default workspace build. >+ */ >+ public static final String ATTR_BUILD_SCOPE = PLUGIN_ID + ".ATTR_LAUNCH_CONFIGURATION_BUILD_SCOPE"; //$NON-NLS-1$ >+ >+ /** >+ * Attribute identifier specifying whether referenced projects should be >+ * considered when computing the projects to build. Default value is >+ * <code>true</code>. >+ */ >+ public static final String ATTR_INCLUDE_REFERENCED_PROJECTS = PLUGIN_ID + ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$ >+} >Index: src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsMigrationMessages.java >=================================================================== >RCS file: src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsMigrationMessages.java >diff -N src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsMigrationMessages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsMigrationMessages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,72 @@ >+/********************************************************************** >+ * Copyright (c) 2000, 2005 IBM Corporation and others. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.core.internal.externaltools.launchConfigurations; >+ >+import org.eclipse.osgi.util.NLS; >+ >+public class ExternalToolsMigrationMessages extends NLS { >+ private static final String BUNDLE_NAME = "org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsUIMessages";//$NON-NLS-1$ >+ >+ public static String BuilderPropertyPage_description; >+ public static String BuilderPropertyPage_newButton; >+ public static String BuilderPropertyPage_editButton; >+ public static String BuilderPropertyPage_removeButton; >+ public static String BuilderPropertyPage_upButton; >+ public static String BuilderPropertyPage_downButton; >+ public static String BuilderPropertyPage_statusMessage; >+ public static String BuilderPropertyPage_errorTitle; >+ public static String BuilderPropertyPage_errorMessage; >+ public static String BuilderPropertyPage_invalidBuildTool; >+ public static String BuilderPropertyPage_missingBuilder; >+ public static String BuilderPropertyPage_Exists; >+ public static String BuilderPropertyPage_External_Tool_Builder__0__Not_Added_2; >+ public static String BuilderPropertyPage__Import____3; >+ public static String BuilderPropertyPage_New_Builder_7; >+ public static String BuilderPropertyPage_Choose_configuration_type_8; >+ public static String BuilderPropertyPage_Choose_an_external_tool_type_to_create_9; >+ public static String BuilderPropertyPage_Migrate_project_builder_10; >+ public static String BuilderPropertyPage_Not_Support; >+ public static String BuilderPropertyPage_Prompt; >+ public static String BuilderPropertyPage_error; >+ public static String BuilderPropertyPage_0; >+ public static String BuilderPropertyPage_2; >+ public static String BuilderPropertyPage_1; >+ public static String BuilderPropertyPage_4; >+ public static String BuilderPropertyPage_5; >+ public static String BuilderPropertyPage_13; >+ public static String BuilderPropertyPage_39; >+ public static String BuilderPropertyPage_3; >+ public static String BuilderPropertyPage_6; >+ public static String BuilderPropertyPage_7; >+ public static String BuilderPropertyPage_40; >+ >+ public static String FileSelectionDialog_Choose_Location_1; >+ public static String FileSelectionDialog_Ok_2; >+ public static String FileSelectionDialog_Cancel_3; >+ >+ public static String ExternalToolsPreferencePage_External_tool_project_builders_migration_2; >+ public static String ExternalToolsPreferencePage_Prompt_before_migrating_3; >+ public static String ExternalToolsPreferencePage_1; >+ >+ public static String ExternalToolMigration_37; >+ public static String ExternalToolMigration_38; >+ public static String EditCommandDialog_0; >+ public static String EditCommandDialog_1; >+ public static String EditCommandDialog_2; >+ public static String EditCommandDialog_3; >+ public static String EditCommandDialog_4; >+ public static String EditCommandDialog_5; >+ >+ static { >+ // load message values from bundle file >+ NLS.initializeMessages(BUNDLE_NAME, >+ ExternalToolsMigrationMessages.class); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/core/internal/externaltools/model/BuilderUtils.java >=================================================================== >RCS file: src/org/eclipse/core/internal/externaltools/model/BuilderUtils.java >diff -N src/org/eclipse/core/internal/externaltools/model/BuilderUtils.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/externaltools/model/BuilderUtils.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,385 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.core.internal.externaltools.model; >+ >+import java.util.HashMap; >+import java.util.Map; >+import java.util.StringTokenizer; >+ >+import org.eclipse.core.internal.externaltools.registry.ExternalToolMigration; >+import org.eclipse.core.resources.ICommand; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IncrementalProjectBuilder; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationType; >+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.debug.core.ILaunchManager; >+ >+ >+/** >+ * Utility methods for working with external tool project builders. >+ */ >+public class BuilderUtils { >+ >+ public static final String LAUNCH_CONFIG_HANDLE = "LaunchConfigHandle"; //$NON-NLS-1$ >+ >+ /** >+ * Constant used to find a builder using the 3.0-interim format >+ */ >+ public static final String BUILDER_FOLDER_NAME= ".externalToolBuilders"; //$NON-NLS-1$ >+ /** >+ * Constant used to represent the current project in the 3.0-final format. >+ */ >+ public static final String PROJECT_TAG= "<project>"; //$NON-NLS-1$ >+ >+ public static final String VERSION_1_0= "1.0"; //$NON-NLS-1$ >+ public static final String VERSION_2_1= "2.1"; //$NON-NLS-1$ >+ // The format shipped up to and including Eclipse 3.0 RC1 >+ public static final String VERSION_3_0_interim= "3.0.interim"; //$NON-NLS-1$ >+ // The format shipped in Eclipse 3.0 final >+ public static final String VERSION_3_0_final= "3.0"; //$NON-NLS-1$ >+ >+ // Extension point constants. >+ private static final String TAG_CONFIGURATION_MAP= "configurationMap"; //$NON-NLS-1$ >+ private static final String TAG_SOURCE_TYPE= "sourceType"; //$NON-NLS-1$ >+ private static final String TAG_BUILDER_TYPE= "builderType"; //$NON-NLS-1$ >+ >+ private static final String BUILD_TYPE_SEPARATOR = ","; //$NON-NLS-1$ >+ private static final int[] DEFAULT_BUILD_TYPES= new int[] { >+ IncrementalProjectBuilder.INCREMENTAL_BUILD, >+ IncrementalProjectBuilder.FULL_BUILD}; >+ >+ /** >+ * Returns a launch configuration from the given ICommand arguments. If the >+ * given arguments are from an old-style external tool, an unsaved working >+ * copy will be created from the arguments and returned. >+ * >+ * @param commandArgs the builder ICommand arguments >+ * @return a launch configuration, a launch configuration working copy, or >+ * <code>null</code> if not possible. >+ */ >+ public static ILaunchConfiguration configFromBuildCommandArgs(IProject project, Map commandArgs, String[] version) { >+ String configHandle = (String) commandArgs.get(LAUNCH_CONFIG_HANDLE); >+ if (configHandle == null) { >+ // Probably an old-style (Eclipse 1.0 or 2.0) external tool. Try to migrate. >+ version[0]= VERSION_1_0; >+ return ExternalToolMigration.configFromArgumentMap(commandArgs); >+ } >+ ILaunchManager manager= DebugPlugin.getDefault().getLaunchManager(); >+ ILaunchConfiguration configuration= null; >+ if (configHandle.startsWith(PROJECT_TAG)) { >+ version[0]= VERSION_3_0_final; >+ IPath path= new Path(configHandle); >+ IFile file= project.getFile(path.removeFirstSegments(1)); >+ if (file.exists()) { >+ configuration= manager.getLaunchConfiguration(file); >+ } >+ } else { >+ // Try treating the handle as a file name. >+ // This is the format used in 3.0 RC1. >+ IPath path= new Path(BUILDER_FOLDER_NAME).append(configHandle); >+ IFile file= project.getFile(path); >+ if (file.exists()) { >+ version[0]= VERSION_3_0_interim; >+ configuration= manager.getLaunchConfiguration(file); >+ } else { >+ try { >+ // Treat the configHandle as a memento. This is the format >+ // used in Eclipse 2.1. >+ configuration = manager.getLaunchConfiguration(configHandle); >+ } catch (CoreException e) { >+ } >+ if (configuration != null) { >+ version[0]= VERSION_2_1; >+ } >+ } >+ } >+ return configuration; >+ } >+ >+// /** >+// * Returns an <code>ICommand</code> from the given launch configuration. >+// * >+// * @param project the project the ICommand is relevant to >+// * @param config the launch configuration to create the command from >+// * @return the new command. <code>null</code> can be returned if problems occur during >+// * the translation. >+// */ >+// public static ICommand commandFromLaunchConfig(IProject project, ILaunchConfiguration config) { >+// ICommand newCommand = null; >+// try { >+// newCommand = project.getDescription().newCommand(); >+// newCommand = toBuildCommand(project, config, newCommand); >+// configureTriggers(config, newCommand); >+// } catch (CoreException exception) { >+// Shell shell= ExternalToolsPlugin.getActiveWorkbenchShell(); >+// if (shell != null) { >+// MessageDialog.openError(shell, ExternalToolsModelMessages.BuilderUtils_5, ExternalToolsModelMessages.BuilderUtils_6); >+// } >+// return null; >+// } >+// return newCommand; >+// } >+ >+ public static void configureTriggers(ILaunchConfiguration config, ICommand newCommand) throws CoreException { >+ newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD, false); >+ newCommand.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, false); >+ newCommand.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, false); >+ newCommand.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, false); >+ String buildKinds= config.getAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, (String)null); >+ int[] triggers= BuilderUtils.buildTypesToArray(buildKinds); >+ for (int i = 0; i < triggers.length; i++) { >+ switch (triggers[i]) { >+ case IncrementalProjectBuilder.FULL_BUILD: >+ newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD, true); >+ break; >+ case IncrementalProjectBuilder.INCREMENTAL_BUILD: >+ newCommand.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, true); >+ break; >+ case IncrementalProjectBuilder.AUTO_BUILD: >+ newCommand.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, true); >+ break; >+ case IncrementalProjectBuilder.CLEAN_BUILD: >+ newCommand.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, true); >+ break; >+ } >+ } >+ if (!config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false)) { >+ ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy(); >+ copy.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, true); >+ copy.doSave(); >+ } >+ } >+ >+ /** >+ * Returns whether the given configuration is an "unmigrated" builder. >+ * Unmigrated builders are external tools that are stored in an old format >+ * but have not been migrated by the user. Old format builders are always >+ * translated into launch config working copies in memory, but they're not >+ * considered "migrated" until the config has been saved and the project spec >+ * updated. >+ * @param config the config to examine >+ * @return whether the given config represents an unmigrated builder >+ */ >+ public static boolean isUnmigratedConfig(ILaunchConfiguration config) { >+ return config.isWorkingCopy() && ((ILaunchConfigurationWorkingCopy) config).getOriginal() == null; >+ } >+ >+ /** >+ * Converts the given config to a build command which is stored in the >+ * given command. >+ * >+ * @return the configured build command >+ */ >+ public static ICommand toBuildCommand(IProject project, ILaunchConfiguration config, ICommand command) throws CoreException { >+ Map args= null; >+ if (isUnmigratedConfig(config)) { >+ // This config represents an old external tool builder that hasn't >+ // been edited. Try to find the old ICommand and reuse the arguments. >+ // The goal here is to not change the storage format of old, unedited builders. >+ ICommand[] commands= project.getDescription().getBuildSpec(); >+ for (int i = 0; i < commands.length; i++) { >+ ICommand projectCommand = commands[i]; >+ String name= ExternalToolMigration.getNameFromCommandArgs(projectCommand.getArguments()); >+ if (name != null && name.equals(config.getName())) { >+ args= projectCommand.getArguments(); >+ break; >+ } >+ } >+ } else { >+ if (config instanceof ILaunchConfigurationWorkingCopy) { >+ ILaunchConfigurationWorkingCopy workingCopy= (ILaunchConfigurationWorkingCopy) config; >+ if (workingCopy.getOriginal() != null) { >+ config= workingCopy.getOriginal(); >+ } >+ } >+ args= new HashMap(); >+ // Launch configuration builders are stored with a project-relative path >+ StringBuffer buffer= new StringBuffer(PROJECT_TAG); >+ // Append the project-relative path (workspace path minus first segment) >+ buffer.append('/').append(config.getFile().getFullPath().removeFirstSegments(1)); >+ args.put(LAUNCH_CONFIG_HANDLE, buffer.toString()); >+ } >+ command.setBuilderName(ExternalToolBuilder.ID); >+ command.setArguments(args); >+ return command; >+ } >+ >+ /** >+ * Returns the type of launch configuration that should be created when >+ * duplicating the given configuration as a project builder. Queries to see >+ * if an extension has been specified to explicitly declare the mapping. >+ */ >+ public static ILaunchConfigurationType getConfigurationDuplicationType(ILaunchConfiguration config) throws CoreException { >+ IExtensionPoint ep= Platform.getExtensionRegistry().getExtensionPoint(IExternalToolConstants.PLUGIN_ID, IExternalToolConstants.EXTENSION_POINT_CONFIGURATION_DUPLICATION_MAPS); >+ IConfigurationElement[] elements = ep.getConfigurationElements(); >+ String sourceType= config.getType().getIdentifier(); >+ String builderType= null; >+ for (int i= 0; i < elements.length; i++) { >+ IConfigurationElement element= elements[i]; >+ if (element.getName().equals(TAG_CONFIGURATION_MAP) && sourceType.equals(element.getAttribute(TAG_SOURCE_TYPE))) { >+ builderType= element.getAttribute(TAG_BUILDER_TYPE); >+ break; >+ } >+ } >+ if (builderType != null) { >+ ILaunchConfigurationType type= DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(builderType); >+ if (type != null) { >+ return type; >+ } >+ } >+ return config.getType(); >+ } >+ >+ /** >+ * Returns the folder where project builders should be stored or >+ * <code>null</code> if the folder could not be created >+ */ >+ public static IFolder getBuilderFolder(IProject project, boolean create) { >+ IFolder folder = project.getFolder(BUILDER_FOLDER_NAME); >+ if (!folder.exists() && create) { >+ try { >+ folder.create(true, true, new NullProgressMonitor()); >+ } catch (CoreException e) { >+ return null; >+ } >+ } >+ return folder; >+ } >+ >+ /** >+ * Returns a duplicate of the given configuration. The new configuration >+ * will be of the same type as the given configuration or of the duplication >+ * type registered for the given configuration via the extension point >+ * IExternalToolConstants.EXTENSION_POINT_CONFIGURATION_DUPLICATION_MAPS. >+ */ >+ public static ILaunchConfiguration duplicateConfiguration(IProject project, ILaunchConfiguration config) throws CoreException { >+ Map attributes= config.getAttributes(); >+ String newName= new StringBuffer(config.getName()).append(ExternalToolsModelMessages.BuilderUtils_7).toString(); >+ newName= DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(newName); >+ ILaunchConfigurationType newType= getConfigurationDuplicationType(config); >+ ILaunchConfigurationWorkingCopy newWorkingCopy= newType.newInstance(getBuilderFolder(project, true), newName); >+ newWorkingCopy.setAttributes(attributes); >+ return newWorkingCopy.doSave(); >+ } >+ >+ /** >+ * Migrates the launch configuration working copy, which is based on an old- >+ * style external tool builder, to a new, saved launch configuration. The >+ * returned launch configuration will contain the same attributes as the >+ * given working copy with the exception of the configuration name, which >+ * may be changed during the migration. The name of the configuration will >+ * only be changed if the current name is not a valid name for a saved >+ * config. >+ * >+ * @param workingCopy the launch configuration containing attributes from an >+ * old-style project builder. >+ * @return ILaunchConfiguration a new, saved launch configuration whose >+ * attributes match those of the given working copy as well as possible >+ * @throws CoreException if an exception occurs while attempting to save the >+ * new launch configuration >+ */ >+ public static ILaunchConfiguration migrateBuilderConfiguration(IProject project, ILaunchConfigurationWorkingCopy workingCopy) throws CoreException { >+ workingCopy.setContainer(getBuilderFolder(project, true)); >+ // Before saving, make sure the name is valid >+ String name= workingCopy.getName(); >+ name= name.replace('/', '.'); >+ if (name.charAt(0) == ('.')) { >+ name = name.substring(1); >+ } >+ IStatus status = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE); >+ if (!status.isOK()) { >+ name = "ExternalTool"; //$NON-NLS-1$ >+ } >+ name = DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(name); >+ workingCopy.rename(name); >+ return workingCopy.doSave(); >+ } >+ >+ /** >+ * Converts the build types string into an array of >+ * build kinds. >+ * >+ * @param buildTypes the string of built types to convert >+ * @return the array of build kinds. >+ */ >+ public static int[] buildTypesToArray(String buildTypes) { >+ if (buildTypes == null || buildTypes.length() == 0) { >+ return DEFAULT_BUILD_TYPES; >+ } >+ >+ int count = 0; >+ boolean incremental = false; >+ boolean full = false; >+ boolean auto = false; >+ boolean clean= false; >+ >+ StringTokenizer tokenizer = new StringTokenizer(buildTypes, BUILD_TYPE_SEPARATOR); >+ while (tokenizer.hasMoreTokens()) { >+ String token = tokenizer.nextToken(); >+ if (IExternalToolConstants.BUILD_TYPE_INCREMENTAL.equals(token)) { >+ if (!incremental) { >+ incremental = true; >+ count++; >+ } >+ } else if (IExternalToolConstants.BUILD_TYPE_FULL.equals(token)) { >+ if (!full) { >+ full = true; >+ count++; >+ } >+ } else if (IExternalToolConstants.BUILD_TYPE_AUTO.equals(token)) { >+ if (!auto) { >+ auto = true; >+ count++; >+ } >+ } else if (IExternalToolConstants.BUILD_TYPE_CLEAN.equals(token)) { >+ if (!clean) { >+ clean = true; >+ count++; >+ } >+ } >+ } >+ >+ int[] results = new int[count]; >+ count = 0; >+ if (incremental) { >+ results[count] = IncrementalProjectBuilder.INCREMENTAL_BUILD; >+ count++; >+ } >+ if (full) { >+ results[count] = IncrementalProjectBuilder.FULL_BUILD; >+ count++; >+ } >+ if (auto) { >+ results[count] = IncrementalProjectBuilder.AUTO_BUILD; >+ count++; >+ } >+ if (clean) { >+ results[count] = IncrementalProjectBuilder.CLEAN_BUILD; >+ count++; >+ } >+ >+ return results; >+ } >+} >Index: plugin.xml >=================================================================== >RCS file: plugin.xml >diff -N plugin.xml >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ plugin.xml 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<?eclipse version="3.4"?> >+<plugin> >+ <extension >+ point="org.eclipse.debug.core.launchConfigurationTypes"> >+ <launchConfigurationType >+ name="%Program.externalTools" >+ delegate="org.eclipse.core.internal.externaltools.launchConfigurations.ProgramLaunchDelegate" >+ category="org.eclipse.ui.externaltools" >+ modes="run" >+ id="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"> >+ </launchConfigurationType> >+ <launchConfigurationType >+ name="%Program.externalTools" >+ delegate="org.eclipse.core.internal.externaltools.launchConfigurations.ProgramLaunchDelegate" >+ category="org.eclipse.ui.externaltools.builder" >+ modes="run" >+ id="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType"> >+ </launchConfigurationType> >+ </extension> >+</plugin> >Index: src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsProgramMessages.java >=================================================================== >RCS file: src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsProgramMessages.java >diff -N src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsProgramMessages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsProgramMessages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,26 @@ >+/********************************************************************** >+ * Copyright (c) 2000, 2005 IBM Corporation and others. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.core.internal.externaltools.launchConfigurations; >+ >+import org.eclipse.osgi.util.NLS; >+ >+public class ExternalToolsProgramMessages extends NLS { >+ private static final String BUNDLE_NAME = "org.eclipse.core.externaltools.internal.program.launchConfigurations.ExternalToolsProgramMessages";//$NON-NLS-1$ >+ >+ public static String BackgroundResourceRefresher_0; >+ >+ public static String ProgramLaunchDelegate_3; >+ public static String ProgramLaunchDelegate_4; >+ >+ static { >+ // load message values from bundle file >+ NLS.initializeMessages(BUNDLE_NAME, ExternalToolsProgramMessages.class); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/core/internal/externaltools/launchConfigurations/ProgramLaunchDelegate.java >=================================================================== >RCS file: src/org/eclipse/core/internal/externaltools/launchConfigurations/ProgramLaunchDelegate.java >diff -N src/org/eclipse/core/internal/externaltools/launchConfigurations/ProgramLaunchDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/externaltools/launchConfigurations/ProgramLaunchDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,207 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Keith Seitz (keiths@redhat.com) - environment variables contribution (Bug 27243) >+ * dakshinamurthy.karra@gmail.com - bug 165371 >+ *******************************************************************************/ >+package org.eclipse.core.internal.externaltools.launchConfigurations; >+ >+import java.io.File; >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.internal.externaltools.model.IExternalToolConstants; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.model.IProcess; >+import org.eclipse.debug.core.model.LaunchConfigurationDelegate; >+import org.eclipse.debug.internal.core.LaunchManager; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * Launch delegate for a program. >+ */ >+public class ProgramLaunchDelegate extends LaunchConfigurationDelegate { >+ >+ /** >+ * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, >+ * java.lang.String, org.eclipse.debug.core.ILaunch, >+ * org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ public void launch(ILaunchConfiguration configuration, String mode, >+ ILaunch launch, IProgressMonitor monitor) throws CoreException { >+ >+ if (monitor.isCanceled()) { >+ return; >+ } >+ >+ // resolve location >+ IPath location = ExternalToolsCoreUtil.getLocation(configuration); >+ >+ if (monitor.isCanceled()) { >+ return; >+ } >+ >+ // resolve working directory >+ IPath workingDirectory = ExternalToolsCoreUtil >+ .getWorkingDirectory(configuration); >+ >+ if (monitor.isCanceled()) { >+ return; >+ } >+ >+ // resolve arguments >+ String[] arguments = ExternalToolsCoreUtil.getArguments(configuration); >+ >+ if (monitor.isCanceled()) { >+ return; >+ } >+ >+ int cmdLineLength = 1; >+ if (arguments != null) { >+ cmdLineLength += arguments.length; >+ } >+ String[] cmdLine = new String[cmdLineLength]; >+ cmdLine[0] = location.toOSString(); >+ if (arguments != null) { >+ System.arraycopy(arguments, 0, cmdLine, 1, arguments.length); >+ } >+ >+ File workingDir = null; >+ if (workingDirectory != null) { >+ workingDir = workingDirectory.toFile(); >+ } >+ >+ if (monitor.isCanceled()) { >+ return; >+ } >+ >+ String[] envp = DebugPlugin.getDefault().getLaunchManager() >+ .getEnvironment(configuration); >+ >+ if (monitor.isCanceled()) { >+ return; >+ } >+ >+ Process p = DebugPlugin.exec(cmdLine, workingDir, envp); >+ IProcess process = null; >+ >+ // add process type to process attributes >+ Map processAttributes = new HashMap(); >+ String programName = location.lastSegment(); >+ String extension = location.getFileExtension(); >+ if (extension != null) { >+ programName = programName.substring(0, programName.length() >+ - (extension.length() + 1)); >+ } >+ programName = programName.toLowerCase(); >+ processAttributes.put(IProcess.ATTR_PROCESS_TYPE, programName); >+ >+ if (p != null) { >+ monitor.beginTask(NLS.bind( >+ ExternalToolsProgramMessages.ProgramLaunchDelegate_3, >+ new String[] { configuration.getName() }), >+ IProgressMonitor.UNKNOWN); >+ process = DebugPlugin.newProcess(launch, p, location.toOSString(), >+ processAttributes); >+ } >+ if (p == null || process == null) { >+ if (p != null) >+ p.destroy(); >+ throw new CoreException(new Status(IStatus.ERROR, >+ IExternalToolConstants.PLUGIN_ID, >+ IExternalToolConstants.ERR_INTERNAL_ERROR, >+ ExternalToolsProgramMessages.ProgramLaunchDelegate_4, null)); >+ } >+ process.setAttribute(IProcess.ATTR_CMDLINE, >+ generateCommandLine(cmdLine)); >+ >+ if (LaunchManager.isLaunchInBackground(configuration)) { >+ // refresh resources after process finishes >+ if (LaunchManager.getRefreshScope(configuration) != null) { >+ BackgroundResourceRefresher refresher = new BackgroundResourceRefresher( >+ configuration, process); >+ refresher.startBackgroundRefresh(); >+ } >+ } else { >+ // wait for process to exit >+ while (!process.isTerminated()) { >+ try { >+ if (monitor.isCanceled()) { >+ process.terminate(); >+ break; >+ } >+ Thread.sleep(50); >+ } catch (InterruptedException e) { >+ } >+ } >+ >+ // refresh resources >+ LaunchManager.refreshResources(configuration, monitor); >+ } >+ } >+ >+ private String generateCommandLine(String[] commandLine) { >+ if (commandLine.length < 1) >+ return ""; //$NON-NLS-1$ >+ StringBuffer buf = new StringBuffer(); >+ for (int i = 0; i < commandLine.length; i++) { >+ buf.append(' '); >+ char[] characters = commandLine[i].toCharArray(); >+ StringBuffer command = new StringBuffer(); >+ boolean containsSpace = false; >+ for (int j = 0; j < characters.length; j++) { >+ char character = characters[j]; >+ if (character == '\"') { >+ command.append('\\'); >+ } else if (character == ' ') { >+ containsSpace = true; >+ } >+ command.append(character); >+ } >+ if (containsSpace) { >+ buf.append('\"'); >+ buf.append(command); >+ buf.append('\"'); >+ } else { >+ buf.append(command); >+ } >+ } >+ return buf.toString(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder >+ * (org.eclipse.debug.core.ILaunchConfiguration, java.lang.String) >+ */ >+ protected IProject[] getBuildOrder(ILaunchConfiguration configuration, >+ String mode) throws CoreException { >+ IProject[] projects = ExternalToolsCoreUtil.getBuildProjects(configuration, >+ null); >+ if (projects == null) { >+ return null; >+ } >+ boolean isRef = ExternalToolsCoreUtil.isIncludeReferencedProjects( >+ configuration, null); >+ if (isRef) { >+ return computeReferencedBuildOrder(projects); >+ } >+ return computeBuildOrder(projects); >+ } >+} >Index: src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsMigrationMessages.properties >=================================================================== >RCS file: src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsMigrationMessages.properties >diff -N src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsMigrationMessages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsMigrationMessages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,60 @@ >+############################################################################### >+# Copyright (c) 2000, 2006 IBM Corporation and others. >+# All rights reserved. This program and the accompanying materials >+# are made available under the terms of the Eclipse Public License v1.0 >+# which accompanies this distribution, and is available at >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# IBM Corporation - initial API and implementation >+############################################################################### >+ >+BuilderPropertyPage_description = Configure the builders for the &project: >+BuilderPropertyPage_newButton = &New... >+BuilderPropertyPage_editButton = &Edit... >+BuilderPropertyPage_removeButton = &Remove >+BuilderPropertyPage_upButton = &Up >+BuilderPropertyPage_downButton = &Down >+BuilderPropertyPage_statusMessage = Internal error >+BuilderPropertyPage_errorTitle = External Tool Builder Problem >+BuilderPropertyPage_errorMessage = Internal error >+BuilderPropertyPage_invalidBuildTool = Invalid External Tool Builder >+BuilderPropertyPage_missingBuilder = Missing builder ({0}) >+BuilderPropertyPage_Exists=Builder launch configuration {0} no longer exists >+BuilderPropertyPage_External_Tool_Builder__0__Not_Added_2=External Tool Builder {0} Not Added >+BuilderPropertyPage__Import____3=&Import... >+BuilderPropertyPage_New_Builder_7=New_Builder >+BuilderPropertyPage_Choose_configuration_type_8=Choose configuration type >+BuilderPropertyPage_Choose_an_external_tool_type_to_create_9=&Choose an external tool type to create: >+BuilderPropertyPage_Migrate_project_builder_10=Migrate project builder >+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? >+BuilderPropertyPage_Prompt=&Do not prompt before migrating project builders >+BuilderPropertyPage_error=An error occurred while saving the project\'s build commands >+BuilderPropertyPage_0=Project Migration >+BuilderPropertyPage_2=&Do not prompt before migrating projects >+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) >+BuilderPropertyPage_4=Import launch configuration >+BuilderPropertyPage_5=&Choose a launch configuration from the workspace to import.\nThis will create a copy of the selected configuration. >+BuilderPropertyPage_13=Command error >+BuilderPropertyPage_39=Error Saving Builder >+BuilderPropertyPage_3=Updating builders... >+BuilderPropertyPage_6=Confirm Disable Builder >+BuilderPropertyPage_7=This is an advanced operation. Disabling a project builder can have many side-effects. Continue? >+BuilderPropertyPage_40=An exception occurred while attempting to save builder {0} >+ >+FileSelectionDialog_Choose_Location_1=Choose Location >+FileSelectionDialog_Ok_2=OK >+FileSelectionDialog_Cancel_3=Cancel >+ >+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. >+ExternalToolsPreferencePage_Prompt_before_migrating_3=&Confirm before migrating external tool project builders for edit >+ExternalToolsPreferencePage_1=C&onfirm before migrating projects to the new format >+ >+ExternalToolMigration_37=An exception occurred accessing external tool\'s \"run in background\" attribute >+ExternalToolMigration_38=An exception occurred attempting to migrate external tool\'s \"run in background\" attribute >+EditCommandDialog_0=Configure Builder >+EditCommandDialog_1=Run this builder: >+EditCommandDialog_2=After a "&Clean" >+EditCommandDialog_3=During &manual builds >+EditCommandDialog_4=During &auto builds >+EditCommandDialog_5=&During a "Clean" >Index: src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsLaunchConfigurationMessages.properties >=================================================================== >RCS file: src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsLaunchConfigurationMessages.properties >diff -N src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsLaunchConfigurationMessages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/externaltools/launchConfigurations/ExternalToolsLaunchConfigurationMessages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,15 @@ >+############################################################################### >+# Copyright (c) 2000, 2007 IBM Corporation and others. >+# All rights reserved. This program and the accompanying materials >+# are made available under the terms of the Eclipse Public License v1.0 >+# which accompanies this distribution, and is available at >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# IBM Corporation - initial API and implementation >+# dakshinamurthy.karra@gmail.com - bug 165371 >+############################################################################### >+ >+ExternalToolsUtil_Location_not_specified_by__0__1=Location not specified by {0} >+ExternalToolsUtil_invalidLocation__0_ = The file does not exist for the external tool named {0}. >+ExternalToolsUtil_invalidDirectory__0_ = The working directory {0} does not exist for the external tool named {1}. >\ No newline at end of file >Index: src/org/eclipse/core/internal/externaltools/launchConfigurations/BackgroundResourceRefresher.java >=================================================================== >RCS file: src/org/eclipse/core/internal/externaltools/launchConfigurations/BackgroundResourceRefresher.java >diff -N src/org/eclipse/core/internal/externaltools/launchConfigurations/BackgroundResourceRefresher.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/externaltools/launchConfigurations/BackgroundResourceRefresher.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,89 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.core.internal.externaltools.launchConfigurations; >+ >+ >+import org.eclipse.core.internal.externaltools.ExternalToolsCore; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.debug.core.DebugEvent; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.IDebugEventSetListener; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.model.IProcess; >+import org.eclipse.debug.internal.core.LaunchManager; >+ >+/** >+ * Refreshes resources as specified by a launch configuration, when >+ * an associated process terminates. >+ */ >+public class BackgroundResourceRefresher implements IDebugEventSetListener { >+ >+ private ILaunchConfiguration fConfiguration; >+ private IProcess fProcess; >+ >+ >+ >+ public BackgroundResourceRefresher(ILaunchConfiguration configuration, IProcess process) { >+ fConfiguration = configuration; >+ fProcess = process; >+ } >+ >+ /** >+ * If the process has already terminated, resource refreshing is done >+ * immediately in the current thread. Otherwise, refreshing is done when the >+ * process terminates. >+ */ >+ public void startBackgroundRefresh() { >+ synchronized (fProcess) { >+ if (fProcess.isTerminated()) { >+ refresh(); >+ } else { >+ DebugPlugin.getDefault().addDebugEventListener(this); >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[]) >+ */ >+ public void handleDebugEvents(DebugEvent[] events) { >+ for (int i = 0; i < events.length; i++) { >+ DebugEvent event = events[i]; >+ if (event.getSource() == fProcess && event.getKind() == DebugEvent.TERMINATE) { >+ DebugPlugin.getDefault().removeDebugEventListener(this); >+ refresh(); >+ break; >+ } >+ } >+ } >+ >+ /** >+ * Submits a job to do the refresh >+ */ >+ protected void refresh() { >+ Job job= new Job(ExternalToolsProgramMessages.BackgroundResourceRefresher_0) { >+ public IStatus run(IProgressMonitor monitor) { >+ try { >+ LaunchManager.refreshResources(fConfiguration, monitor); >+ } catch (CoreException e) { >+ ExternalToolsCore.log(e); >+ return e.getStatus(); >+ } >+ return Status.OK_STATUS; >+ } >+ }; >+ job.schedule(); >+ } >+} >#P org.eclipse.ant.ui >Index: Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/AddBuildFilesAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/AddBuildFilesAction.java,v >retrieving revision 1.10 >diff -u -r1.10 AddBuildFilesAction.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/AddBuildFilesAction.java 11 Aug 2005 16:26:26 -0000 1.10 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/AddBuildFilesAction.java 25 Sep 2009 16:23:43 -0000 >@@ -13,8 +13,9 @@ > import java.lang.reflect.InvocationTargetException; > import java.util.ArrayList; > import java.util.List; >+ >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.ant.internal.ui.AntUIImages; >-import org.eclipse.ant.internal.ui.AntUtil; > import org.eclipse.ant.internal.ui.IAntUIConstants; > import org.eclipse.ant.internal.ui.IAntUIHelpContextIds; > import org.eclipse.ant.internal.ui.model.AntProjectNode; >@@ -89,7 +90,7 @@ > List buildFiles= new ArrayList(existingProjects.length); > for (int j = 0; j < existingProjects.length; j++) { > AntProjectNode existingProject = existingProjects[j]; >- buildFiles.add(AntUtil.getFile(existingProject.getBuildFileName())); >+ buildFiles.add(AntLaunchingUtil.getFile(existingProject.getBuildFileName())); > } > return buildFiles; > } >Index: Ant Tools Support/org/eclipse/ant/internal/ui/model/AntProjectNodeProxy.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntProjectNodeProxy.java,v >retrieving revision 1.17 >diff -u -r1.17 AntProjectNodeProxy.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/model/AntProjectNodeProxy.java 11 Aug 2005 16:30:45 -0000 1.17 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/model/AntProjectNodeProxy.java 25 Sep 2009 16:23:41 -0000 >@@ -14,6 +14,7 @@ > import java.util.Collections; > import java.util.List; > >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.ant.internal.ui.AntUtil; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.IPath; >@@ -54,7 +55,7 @@ > fChildNodes= null; > fParsed= true; > AntTargetNode[] nodes = null; >- IPath buildFilePath= AntUtil.getFile(getBuildFileName()).getLocation(); >+ IPath buildFilePath= AntLaunchingUtil.getFile(getBuildFileName()).getLocation(); > if (buildFilePath == null) { > setProblemSeverity(AntModelProblem.SEVERITY_ERROR); > setProblemMessage(AntModelMessages.AntProjectNodeProxy_0); >@@ -256,7 +257,7 @@ > public IFile getBuildFileResource() { > if (fProject == null) { > if (fBuildFileName != null) { >- return AntUtil.getFile(fBuildFileName); >+ return AntLaunchingUtil.getFile(fBuildFileName); > } > } > return super.getBuildFileResource(); >Index: Ant Tools Support/org/eclipse/ant/internal/ui/model/AntImportNode.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntImportNode.java,v >retrieving revision 1.11 >diff -u -r1.11 AntImportNode.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/model/AntImportNode.java 11 Aug 2005 16:30:45 -0000 1.11 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/model/AntImportNode.java 25 Sep 2009 16:23:40 -0000 >@@ -14,8 +14,8 @@ > import org.apache.tools.ant.BuildException; > import org.apache.tools.ant.Task; > import org.eclipse.ant.core.AntSecurityException; >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.ant.internal.ui.AntUIImages; >-import org.eclipse.ant.internal.ui.AntUtil; > import org.eclipse.ant.internal.ui.IAntUIConstants; > import org.eclipse.ant.internal.ui.editor.AntEditorCompletionProcessor; > import org.eclipse.ant.internal.ui.preferences.AntEditorPreferenceConstants; >@@ -82,10 +82,10 @@ > public IFile getIFile() { > IFile file; > if (isExternal()) { >- file= AntUtil.getFileForLocation(getFilePath(), null); >+ file= AntLaunchingUtil.getFileForLocation(getFilePath(), null); > } else { > String path= getFile(); >- file= AntUtil.getFileForLocation(path, getAntModel().getEditedFile().getParentFile()); >+ file= AntLaunchingUtil.getFileForLocation(path, getAntModel().getEditedFile().getParentFile()); > } > return file; > } >Index: Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementNode.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementNode.java,v >retrieving revision 1.26 >diff -u -r1.26 AntElementNode.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementNode.java 19 Dec 2008 14:12:46 -0000 1.26 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementNode.java 25 Sep 2009 16:23:40 -0000 >@@ -18,14 +18,13 @@ > import java.io.File; > import java.net.MalformedURLException; > import java.net.URL; >-import com.ibm.icu.text.MessageFormat; > import java.util.ArrayList; > import java.util.Iterator; > import java.util.List; > >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.ant.internal.ui.AntImageDescriptor; > import org.eclipse.ant.internal.ui.AntUIImages; >-import org.eclipse.ant.internal.ui.AntUtil; > import org.eclipse.ant.internal.ui.IAntUIConstants; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.IAdaptable; >@@ -35,6 +34,8 @@ > import org.eclipse.jface.text.IRegion; > import org.eclipse.swt.graphics.Image; > >+import com.ibm.icu.text.MessageFormat; >+ > /** > * General representation of an Ant buildfile element. > * >@@ -546,7 +547,7 @@ > */ > public IFile getIFile() { > if (isExternal()) { >- return AntUtil.getFileForLocation(fFilePath, null); >+ return AntLaunchingUtil.getFileForLocation(fFilePath, null); > } > return getBuildFileResource(); > } >Index: Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModel.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModel.java,v >retrieving revision 1.68 >diff -u -r1.68 AntModel.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModel.java 31 Aug 2009 17:56:26 -0000 1.68 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModel.java 25 Sep 2009 16:23:41 -0000 >@@ -50,8 +50,8 @@ > import org.eclipse.ant.internal.core.AntCoreUtil; > import org.eclipse.ant.internal.core.AntSecurityManager; > import org.eclipse.ant.internal.core.IAntCoreConstants; >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.ant.internal.ui.AntUIPlugin; >-import org.eclipse.ant.internal.ui.AntUtil; > import org.eclipse.ant.internal.ui.editor.DecayCodeCompletionDataStructuresThread; > import org.eclipse.ant.internal.ui.editor.outline.AntEditorMarkerUpdater; > import org.eclipse.ant.internal.ui.editor.utils.ProjectHelper; >@@ -584,7 +584,7 @@ > } > String buildFileNames= AntUIPlugin.getDefault().getCombinedPreferenceStore().getString(AntEditorPreferenceConstants.BUILDFILE_NAMES_TO_IGNORE); > if (buildFileNames.length() > 0) { >- String[] names= AntUtil.parseString(buildFileNames, ","); //$NON-NLS-1$ >+ String[] names= AntLaunchingUtil.parseString(buildFileNames, ","); //$NON-NLS-1$ > String editedFileName= getEditedFile().getName(); > for (int i = 0; i < names.length; i++) { > String string = names[i]; >Index: Ant Tools Support/org/eclipse/ant/internal/ui/console/AntConsoleColorProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/console/AntConsoleColorProvider.java,v >retrieving revision 1.7 >diff -u -r1.7 AntConsoleColorProvider.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/console/AntConsoleColorProvider.java 23 Feb 2005 17:31:21 -0000 1.7 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/console/AntConsoleColorProvider.java 25 Sep 2009 16:23:35 -0000 >@@ -10,10 +10,10 @@ > *******************************************************************************/ > package org.eclipse.ant.internal.ui.console; > >+import org.eclipse.ant.internal.launching.launchConfigurations.AntStreamsProxy; > import org.eclipse.ant.internal.ui.AntUIPlugin; > import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants; > import org.eclipse.ant.internal.ui.launchConfigurations.AntProcess; >-import org.eclipse.ant.internal.ui.launchConfigurations.AntStreamsProxy; > import org.eclipse.debug.core.model.IProcess; > import org.eclipse.debug.ui.IDebugUIConstants; > import org.eclipse.debug.ui.console.ConsoleColorProvider; >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java,v >retrieving revision 1.15 >diff -u -r1.15 AntPropertiesTab.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java 24 Feb 2009 16:29:02 -0000 1.15 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java 25 Sep 2009 16:23:39 -0000 >@@ -17,9 +17,9 @@ > import org.eclipse.ant.core.AntCorePlugin; > import org.eclipse.ant.core.AntCorePreferences; > import org.eclipse.ant.core.Property; >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.ant.internal.ui.AntUIImages; > import org.eclipse.ant.internal.ui.AntUIPlugin; >-import org.eclipse.ant.internal.ui.AntUtil; > import org.eclipse.ant.internal.ui.IAntUIConstants; > import org.eclipse.ant.internal.ui.IAntUIHelpContextIds; > import org.eclipse.ant.internal.ui.preferences.AntPropertiesBlock; >@@ -111,7 +111,7 @@ > * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) > */ > public void initializeFrom(ILaunchConfiguration configuration) { >- fSeparateJRE= AntUtil.isSeparateJREAntBuild(configuration); >+ fSeparateJRE= AntLaunchingUtil.isSeparateJREAntBuild(configuration); > setErrorMessage(null); > setMessage(null); > Map properties= null; >@@ -134,7 +134,7 @@ > fUseDefaultButton.setSelection(false); > fAntPropertiesBlock.populatePropertyViewer(properties); > >- String[] files= AntUtil.parseString(propertyFiles, ","); //$NON-NLS-1$ >+ String[] files= AntLaunchingUtil.parseString(propertyFiles, ","); //$NON-NLS-1$ > fAntPropertiesBlock.setPropertyFilesInput(files); > } > >@@ -246,7 +246,7 @@ > * @see org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) > */ > public void activated(ILaunchConfigurationWorkingCopy workingCopy) { >- if (fSeparateJRE != AntUtil.isSeparateJREAntBuild(workingCopy)) { >+ if (fSeparateJRE != AntLaunchingUtil.isSeparateJREAntBuild(workingCopy)) { > //update the properties if changed whether build is in separate JRE > initializeFrom(workingCopy); > } >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntJRETab.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntJRETab.java,v >retrieving revision 1.45 >diff -u -r1.45 AntJRETab.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntJRETab.java 1 Sep 2009 19:44:20 -0000 1.45 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntJRETab.java 25 Sep 2009 16:23:37 -0000 >@@ -34,7 +34,7 @@ > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; >+import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil; > import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants; > > public class AntJRETab extends JavaJRETab { >@@ -159,7 +159,7 @@ > if (args != null) { > Pattern pattern = Pattern.compile("\\$\\{.*_prompt.*\\}"); //$NON-NLS-1$ > IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); >- String[] arguments = ExternalToolsUtil.parseStringIntoList(args); >+ String[] arguments = ExternalToolsCoreUtil.parseStringIntoList(args); > if (arguments != null) { > for (int i = 0; i < arguments.length; i++) { > String arg = arguments[i]; >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMainTab.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMainTab.java,v >retrieving revision 1.24 >diff -u -r1.24 AntMainTab.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMainTab.java 17 Apr 2007 03:34:13 -0000 1.24 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMainTab.java 25 Sep 2009 16:23:39 -0000 >@@ -10,8 +10,8 @@ > *******************************************************************************/ > package org.eclipse.ant.internal.ui.launchConfigurations; > >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.ant.internal.ui.AntUIPlugin; >-import org.eclipse.ant.internal.ui.AntUtil; > import org.eclipse.ant.internal.ui.IAntUIConstants; > import org.eclipse.ant.internal.ui.IAntUIHelpContextIds; > import org.eclipse.core.resources.IFile; >@@ -108,7 +108,7 @@ > if (location != null) { > String expandedLocation= manager.performStringSubstitution(location); > if (expandedLocation != null) { >- file= AntUtil.getFileForLocation(expandedLocation, null); >+ file= AntLaunchingUtil.getFileForLocation(expandedLocation, null); > } > } > } catch (CoreException e) { >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntTargetsTab.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntTargetsTab.java,v >retrieving revision 1.55 >diff -u -r1.55 AntTargetsTab.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntTargetsTab.java 13 Aug 2008 15:32:18 -0000 1.55 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntTargetsTab.java 25 Sep 2009 16:23:40 -0000 >@@ -18,6 +18,7 @@ > import java.util.Iterator; > import java.util.List; > >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.ant.internal.ui.AntUIImages; > import org.eclipse.ant.internal.ui.AntUIPlugin; > import org.eclipse.ant.internal.ui.AntUtil; >@@ -532,7 +533,7 @@ > ISchedulingRule rule= null; > if (!ResourcesPlugin.getWorkspace().isTreeLocked()) { > //only set a scheduling rule if not in a resource change callback >- rule= AntUtil.getFileForLocation(expandedLocation, null); >+ rule= AntLaunchingUtil.getFileForLocation(expandedLocation, null); > } > PlatformUI.getWorkbench().getProgressService().runInUI(context, operation, rule); > } catch (InvocationTargetException e) { >@@ -649,7 +650,7 @@ > return; > } > >- String[] targetNames= AntUtil.parseRunTargets(configTargets); >+ String[] targetNames= AntLaunchingUtil.parseRunTargets(configTargets); > if (targetNames.length == 0) { > fTableViewer.setAllChecked(false); > setExecuteInput(allTargetNodes); >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchConfigurationMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchConfigurationMessages.java,v >retrieving revision 1.8 >diff -u -r1.8 AntLaunchConfigurationMessages.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchConfigurationMessages.java 12 Dec 2007 21:00:26 -0000 1.8 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchConfigurationMessages.java 25 Sep 2009 16:23:37 -0000 >@@ -20,14 +20,6 @@ > public static String AddVariableStringAction_3; > public static String AddVariableStringAction_4; > >- public static String AntLaunchDelegate_Launching__0__1; >- public static String AntLaunchDelegate_Running__0__2; >- public static String AntLaunchDelegate_Build_In_Progress; >- public static String AntLaunchDelegate_Failure; >- public static String AntLaunchDelegate_22; >- public static String AntLaunchDelegate_23; >- public static String AntLaunchDelegate_28; >- > public static String AntLaunchShortcut_Unable; > public static String AntLaunchShortcut_2; > public static String AntLaunchShortcut_3; >@@ -45,9 +37,7 @@ > > public static String AntJRETab_2; > public static String AntJRETab_3; >- >- public static String AntHomeClasspathEntry_8; >- public static String AntHomeClasspathEntry_9; >+ > public static String AntBuilderTargetsTab_0; > public static String AntBuilderTargetsTab_1; > public static String AntBuilderTargetsTab_2; >@@ -58,8 +48,6 @@ > public static String AntBuilderTargetsTab_7; > public static String AntBuilderTargetsTab_8; > public static String AntBuilderTargetsTab_10; >- public static String AntHomeClasspathEntry_10; >- public static String AntHomeClasspathEntry_11; > > public static String AntMainTab__Select_a_build_file__1; > public static String AntMainTab_3; >@@ -86,8 +74,6 @@ > public static String AntTargetsTab_1; > public static String AntClasspathTab_0; > >- public static String ContributedClasspathEntriesEntry_1; >- > public static String EditAntHomeEntryAction_1; > > public static String TargetOrderDialog_Order_Targets_1; >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntClasspathTab.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntClasspathTab.java,v >retrieving revision 1.28 >diff -u -r1.28 AntClasspathTab.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntClasspathTab.java 11 Aug 2005 16:30:00 -0000 1.28 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntClasspathTab.java 25 Sep 2009 16:23:36 -0000 >@@ -10,7 +10,8 @@ > *******************************************************************************/ > package org.eclipse.ant.internal.ui.launchConfigurations; > >-import org.eclipse.ant.internal.ui.AntUtil; >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; >+import org.eclipse.ant.internal.launching.launchConfigurations.AntHomeClasspathEntry; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.debug.ui.ILaunchConfigurationTab; >@@ -81,7 +82,7 @@ > */ > public void initializeFrom(ILaunchConfiguration configuration) { > try { >- AntUtil.migrateToNewClasspathFormat(configuration); >+ AntLaunchingUtil.migrateToNewClasspathFormat(configuration); > } catch (CoreException e) { > } > super.initializeFrom(configuration); >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMigrationDelegate.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMigrationDelegate.java,v >retrieving revision 1.2 >diff -u -r1.2 AntMigrationDelegate.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMigrationDelegate.java 3 Apr 2006 02:12:47 -0000 1.2 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMigrationDelegate.java 25 Sep 2009 16:23:39 -0000 >@@ -10,7 +10,7 @@ > *******************************************************************************/ > package org.eclipse.ant.internal.ui.launchConfigurations; > >-import org.eclipse.ant.internal.ui.AntUtil; >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.runtime.CoreException; >@@ -46,7 +46,7 @@ > if (location != null) { > expandedLocation= manager.performStringSubstitution(location); > if (expandedLocation != null) { >- file= AntUtil.getFileForLocation(expandedLocation, null); >+ file= AntLaunchingUtil.getFileForLocation(expandedLocation, null); > } > } > } catch (CoreException e) { >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java,v >retrieving revision 1.82 >diff -u -r1.82 AntLaunchDelegate.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java 6 Apr 2009 21:06:45 -0000 1.82 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java 25 Sep 2009 16:23:37 -0000 >@@ -1,761 +1,759 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- * Juan A. Hernandez - bug 89926 >- * dakshinamurthy.karra@gmail.com - bug 165371 >- *******************************************************************************/ >-package org.eclipse.ant.internal.ui.launchConfigurations; >- >-import java.io.File; >-import java.io.IOException; >-import java.net.URL; >-import java.util.HashMap; >-import java.util.Iterator; >-import java.util.List; >-import java.util.Map; >- >-import org.apache.tools.ant.ProjectHelper; >-import org.eclipse.ant.core.AntCorePlugin; >-import org.eclipse.ant.core.AntCorePreferences; >-import org.eclipse.ant.core.AntRunner; >-import org.eclipse.ant.core.Property; >-import org.eclipse.ant.core.Task; >-import org.eclipse.ant.core.Type; >-import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger; >-import org.eclipse.ant.internal.ui.AntUIPlugin; >-import org.eclipse.ant.internal.ui.AntUtil; >-import org.eclipse.ant.internal.ui.IAntUIConstants; >-import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants; >-import org.eclipse.ant.internal.ui.debug.IAntDebugConstants; >-import org.eclipse.ant.internal.ui.debug.model.RemoteAntDebugBuildListener; >-import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants; >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.FileLocator; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.core.runtime.Status; >-import org.eclipse.core.runtime.SubProgressMonitor; >-import org.eclipse.core.variables.VariablesPlugin; >-import org.eclipse.debug.core.DebugEvent; >-import org.eclipse.debug.core.DebugPlugin; >-import org.eclipse.debug.core.IBreakpointManager; >-import org.eclipse.debug.core.IDebugEventSetListener; >-import org.eclipse.debug.core.ILaunch; >-import org.eclipse.debug.core.ILaunchConfiguration; >-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >-import org.eclipse.debug.core.ILaunchManager; >-import org.eclipse.debug.core.model.IBreakpoint; >-import org.eclipse.debug.core.model.IProcess; >-import org.eclipse.debug.core.model.LaunchConfigurationDelegate; >-import org.eclipse.debug.ui.CommonTab; >-import org.eclipse.debug.ui.IDebugUIConstants; >-import org.eclipse.debug.ui.RefreshTab; >-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >-import org.eclipse.jdt.launching.IVMInstall; >-import org.eclipse.jdt.launching.JavaRuntime; >-import org.eclipse.jdt.launching.SocketUtil; >-import org.eclipse.jface.dialogs.MessageDialogWithToggle; >-import org.eclipse.jface.preference.IPreferenceStore; >-import org.eclipse.osgi.service.resolver.BundleDescription; >-import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab; >-import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; >-import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants; >-import org.eclipse.ui.externaltools.internal.program.launchConfigurations.BackgroundResourceRefresher; >-import org.osgi.framework.Bundle; >- >-import com.ibm.icu.text.MessageFormat; >- >-/** >- * Launch delegate for Ant builds >- */ >-public class AntLaunchDelegate extends LaunchConfigurationDelegate { >- >- private static final String ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessBuildLogger"; //$NON-NLS-1$ >- private static final String ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessDebugBuildLogger"; //$NON-NLS-1$ >- private static final String NULL_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.NullBuildLogger"; //$NON-NLS-1$ >- private static final String REMOTE_ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.RemoteAntBuildLogger"; //$NON-NLS-1$ >- private static final String REMOTE_ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.debug.RemoteAntDebugBuildLogger"; //$NON-NLS-1$ >- private static final String BASE_DIR_PREFIX = "-Dbasedir="; //$NON-NLS-1$ >- private static final String INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.AntInputHandler"; //$NON-NLS-1$ >- private static final String REMOTE_INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.ProxyInputHandler"; //$NON-NLS-1$ >- >- private static final IProject[] NO_PROJECTS = new IProject[0]; >- >- /** >- * String attribute identifying the build scope for a launch configuration. >- * <code>null</code> indicates the default workspace build. >- */ >- private static final String ATTR_BUILD_SCOPE = AntUIPlugin.getUniqueIdentifier() + ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$ >- >- /** >- * Attribute identifier specifying whether referenced projects should be >- * considered when computing the projects to build. Default value is >- * <code>true</code>. >- */ >- private static final String ATTR_INCLUDE_REFERENCED_PROJECTS = AntUIPlugin.getUniqueIdentifier() + ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$ >- >- >- private static String fgSWTLibraryLocation; >- >- private String fMode; >- private boolean fUserSpecifiedLogger= false; >- >- private String getProgramArguments(ILaunchConfiguration configuration) throws CoreException { >- String arguments = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$ >- return VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(arguments); >- } >- >- /** >- * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, >- * java.lang.String, org.eclipse.debug.core.ILaunch, >- * org.eclipse.core.runtime.IProgressMonitor) >- */ >- public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { >- if (monitor.isCanceled()) { >- return; >- } >- fUserSpecifiedLogger= false; >- fMode= mode; >- >- // migrate the config to the new classpath format if required >- AntUtil.migrateToNewClasspathFormat(configuration); >- >- boolean isSeparateJRE= AntUtil.isSeparateJREAntBuild(configuration); >- >- if (CommonTab.isLaunchInBackground(configuration)) { >- monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1, new String[] {configuration.getName()}), 10); >- } else { >- monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Running__0__2, new String[] {configuration.getName()}), 100); >- } >- >- // resolve location >- IPath location = ExternalToolsUtil.getLocation(configuration); >- monitor.worked(1); >- >- if (monitor.isCanceled()) { >- return; >- } >- >- if (!isSeparateJRE && AntRunner.isBuildRunning()) { >- IStatus status= new Status(IStatus.ERROR, IAntUIConstants.PLUGIN_ID, 1, MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Build_In_Progress, new String[]{location.toOSString()}), null); >- throw new CoreException(status); >- } >- >- // resolve working directory >- IPath workingDirectory = ExternalToolsUtil.getWorkingDirectory(configuration); >- String basedir = null; >- if (workingDirectory != null) { >- basedir= workingDirectory.toOSString(); >- } >- monitor.worked(1); >- >- if (monitor.isCanceled()) { >- return; >- } >- >- // link the process to its build logger via a timestamp >- long timeStamp = System.currentTimeMillis(); >- String idStamp = Long.toString(timeStamp); >- StringBuffer idProperty = new StringBuffer("-D"); //$NON-NLS-1$ >- idProperty.append(AbstractEclipseBuildLogger.ANT_PROCESS_ID); >- idProperty.append('='); >- idProperty.append(idStamp); >- >- // resolve arguments >- String[] arguments = null; >- if (isSeparateJRE) { >- arguments = new String[] {getProgramArguments(configuration)}; >- } else { >- arguments = ExternalToolsUtil.getArguments(configuration); >- } >- >- Map userProperties= AntUtil.getProperties(configuration); >- if (userProperties != null) {//create a copy so as to not affect the configuration with transient properties >- userProperties= new HashMap(userProperties); >- } >- String[] propertyFiles= AntUtil.getPropertyFiles(configuration); >- String[] targets = AntUtil.getTargetNames(configuration); >- URL[] customClasspath= AntUtil.getCustomClasspath(configuration); >- String antHome= AntUtil.getAntHome(configuration); >- >- boolean setInputHandler= true; >- try { >- //check if set specify inputhandler >- setInputHandler = configuration.getAttribute(IAntUIConstants.SET_INPUTHANDLER, true); >- } catch (CoreException ce) { >- AntUIPlugin.log(ce); >- } >- >- AntRunner runner= null; >- if (!isSeparateJRE) { >- runner = configureAntRunner(configuration, location, basedir, idProperty, arguments, userProperties, propertyFiles, targets, customClasspath, antHome, setInputHandler); >- } >- >- monitor.worked(1); >- >- if (monitor.isCanceled()) { >- return; >- } >- boolean captureOutput= ExternalToolsUtil.getCaptureOutput(configuration); >- int port= -1; >- int requestPort= -1; >- if (isSeparateJRE && captureOutput) { >- if (userProperties == null) { >- userProperties= new HashMap(); >- } >- port= SocketUtil.findFreePort(); >- userProperties.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp); >- userProperties.put("eclipse.connect.port", Integer.toString(port)); //$NON-NLS-1$ >- if (fMode.equals(ILaunchManager.DEBUG_MODE)) { >- requestPort= SocketUtil.findFreePort(); >- userProperties.put("eclipse.connect.request_port", Integer.toString(requestPort)); //$NON-NLS-1$ >- } >- } >- >- StringBuffer commandLine= generateCommandLine(location, arguments, userProperties, propertyFiles, targets, antHome, basedir, isSeparateJRE, captureOutput, setInputHandler); >- >- if (isSeparateJRE) { >- monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1, new String[] {configuration.getName()}), 10); >- runInSeparateVM(configuration, launch, monitor, idStamp, antHome, port, requestPort, commandLine, captureOutput, setInputHandler); >- } else { >- runInSameVM(configuration, launch, monitor, location, idStamp, runner, commandLine, captureOutput); >- } >- >- monitor.done(); >- } >- >- private void runInSameVM(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor, IPath location, String idStamp, AntRunner runner, StringBuffer commandLine, boolean captureOutput) throws CoreException { >- Map attributes= new HashMap(2); >- attributes.put(IProcess.ATTR_PROCESS_TYPE, IAntLaunchConfigurationConstants.ID_ANT_PROCESS_TYPE); >- attributes.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp); >- >- final AntProcess process = new AntProcess(location.toOSString(), launch, attributes); >- setProcessAttributes(process, idStamp, commandLine, captureOutput); >- boolean debug= fMode.equals(ILaunchManager.DEBUG_MODE); >- if (debug || CommonTab.isLaunchInBackground(configuration)) { >- final AntRunner finalRunner= runner; >- Runnable r = new Runnable() { >- public void run() { >- try { >- finalRunner.run(process); >- } catch (CoreException e) { >- handleException(e, AntLaunchConfigurationMessages.AntLaunchDelegate_Failure); >- } >- process.terminated(); >- } >- }; >- Thread background = new Thread(r); >- background.setDaemon(true); >- background.start(); >- monitor.worked(1); >- //refresh resources after process finishes >- if (RefreshTab.getRefreshScope(configuration) != null) { >- BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(configuration, process); >- refresher.startBackgroundRefresh(); >- } >- } else { >- // execute the build >- try { >- runner.run(monitor); >- } catch (CoreException e) { >- process.terminated(); >- monitor.done(); >- handleException(e, AntLaunchConfigurationMessages.AntLaunchDelegate_23); >- return; >- } >- process.terminated(); >- >- // refresh resources >- RefreshTab.refreshResources(configuration, monitor); >- } >- } >- >- 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 { >- int argLength = 1; // at least one user property - timestamp >- if (arguments != null) { >- argLength += arguments.length; >- } >- if (baseDir != null && baseDir.length() > 0) { >- argLength++; >- } >- String[] runnerArgs = new String[argLength]; >- if (arguments != null) { >- System.arraycopy(arguments, 0, runnerArgs, 0, arguments.length); >- } >- if (baseDir != null && baseDir.length() > 0) { >- runnerArgs[runnerArgs.length - 2] = BASE_DIR_PREFIX + baseDir; >- } >- runnerArgs[runnerArgs.length -1] = idProperty.toString(); >- >- AntRunner runner= new AntRunner(); >- runner.setBuildFileLocation(location.toOSString()); >- boolean captureOutput= ExternalToolsUtil.getCaptureOutput(configuration); >- if (captureOutput) { >- if (fMode.equals(ILaunchManager.DEBUG_MODE)) { >- runner.addBuildLogger(ANT_DEBUG_LOGGER_CLASS); >- } else { >- runner.addBuildLogger(ANT_LOGGER_CLASS); >- } >- } else { >- runner.addBuildLogger(NULL_LOGGER_CLASS); >- } >- if (setInputHandler) { >- runner.setInputHandler(INPUT_HANDLER_CLASS); >- } else { >- runner.setInputHandler(""); //$NON-NLS-1$ >- } >- runner.setArguments(runnerArgs); >- if (userProperties != null) { >- runner.addUserProperties(userProperties); >- } >- >- if (propertyFiles != null) { >- runner.setPropertyFiles(propertyFiles); >- } >- >- if (targets != null) { >- runner.setExecutionTargets(targets); >- } >- >- if (customClasspath != null) { >- runner.setCustomClasspath(customClasspath); >- } >- >- if (antHome != null) { >- runner.setAntHome(antHome); >- } >- return runner; >- } >- >- private void handleException(final CoreException e, final String title) { >- IPreferenceStore store= AntUIPlugin.getDefault().getPreferenceStore(); >- if (store.getBoolean(IAntUIPreferenceConstants.ANT_ERROR_DIALOG)) { >- AntUIPlugin.getStandardDisplay().asyncExec(new Runnable() { >- public void run() { >- MessageDialogWithToggle.openError(null, title, e.getMessage(), AntLaunchConfigurationMessages.AntLaunchDelegate_22, false, AntUIPlugin.getDefault().getPreferenceStore(), IAntUIPreferenceConstants.ANT_ERROR_DIALOG); >- } >- }); >- } >- } >- >- private void setProcessAttributes(IProcess process, String idStamp, StringBuffer commandLine, boolean captureOutput) { >- // link the process to the Eclipse build logger via a timestamp >- if (!fUserSpecifiedLogger) { >- process.setAttribute(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp); >- } >- >- // create "fake" command line for the process >- if (commandLine != null) { >- process.setAttribute(IProcess.ATTR_CMDLINE, commandLine.toString()); >- } >- if (captureOutput && !fUserSpecifiedLogger) { >- TaskLinkManager.registerAntBuild(process); >- } >- } >- >- private StringBuffer generateCommandLine(IPath location, String[] arguments, Map userProperties, String[] propertyFiles, String[] targets, String antHome, String basedir, boolean separateVM, boolean captureOutput, boolean setInputHandler) { >- StringBuffer commandLine= new StringBuffer(); >- >- if (!separateVM) { >- commandLine.append("ant"); //$NON-NLS-1$ >- } >- >- if (arguments != null) { >- for (int i = 0; i < arguments.length; i++) { >- commandLine.append(' '); >- commandLine.append(arguments[i]); >- } >- } >- >- AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences(); >- if (propertyFiles == null) { //global >- String[] files= prefs.getCustomPropertyFiles(); >- for (int i = 0; i < files.length; i++) { >- String path = files[i]; >- commandLine.append(" -propertyfile \""); //$NON-NLS-1$ >- commandLine.append(path); >- commandLine.append('\"'); >- } >- } else {//"local" configuration >- for (int i = 0; i < propertyFiles.length; i++) { >- String path = propertyFiles[i]; >- commandLine.append(" -propertyfile \""); //$NON-NLS-1$ >- commandLine.append(path); >- commandLine.append('\"'); >- } >- } >- //"local" configuration >- if (userProperties != null) { >- Iterator keys = userProperties.keySet().iterator(); >- String key; >- while (keys.hasNext()) { >- key= (String)keys.next(); >- appendProperty(commandLine, key, (String)userProperties.get(key)); >- } >- } >- >- //global >- List properties= null; >- if (!separateVM) { >- properties= prefs.getProperties(); >- } else { >- properties= prefs.getRemoteAntProperties(); >- } >- >- //if we have user properties this means that the user has chosen to override the global properties >- //if in a separate VM and have only two (or three if debug) user properties these are really only Eclipse generated properties >- //and the user is still using the global properties >- int numberOfEclipseProperties= 2; >- if (userProperties != null && userProperties.get("eclipse.connect.request_port") != null){ //$NON-NLS-1$ >- numberOfEclipseProperties= 3; //debug mode >- } >- boolean useGlobalProperties = userProperties == null || (separateVM && userProperties.size() == numberOfEclipseProperties); >- if (useGlobalProperties) { >- for (Iterator iter = properties.iterator(); iter.hasNext();) { >- Property property = (Property) iter.next(); >- String key= property.getName(); >- String value= property.getValue(false); >- if (value != null) { >- appendProperty(commandLine, key, value); >- } >- } >- } >- >- if (basedir != null && basedir.length() > 0) { >- appendProperty(commandLine, "basedir", basedir); //$NON-NLS-1$ >- } >- >- if (antHome != null) { >- commandLine.append(" \"-Dant.home="); //$NON-NLS-1$ >- commandLine.append(antHome); >- commandLine.append('\"'); >- } >- >- if (separateVM) { >- if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$ >- if (captureOutput) { >- commandLine.append(" -logger "); //$NON-NLS-1$ >- if (fMode.equals(ILaunchManager.DEBUG_MODE)) { >- commandLine.append(REMOTE_ANT_DEBUG_LOGGER_CLASS); >- } else { >- commandLine.append(REMOTE_ANT_LOGGER_CLASS); >- } >- } >- } else { >- fUserSpecifiedLogger= true; >- } >- if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$ >- commandLine.append(" -inputhandler "); //$NON-NLS-1$ >- commandLine.append(REMOTE_INPUT_HANDLER_CLASS); >- } >- } else { >- if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$ >- commandLine.append(" -inputhandler "); //$NON-NLS-1$ >- commandLine.append(INPUT_HANDLER_CLASS); >- } >- if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$ >- commandLine.append(" -logger "); //$NON-NLS-1$ >- if (fMode.equals(ILaunchManager.DEBUG_MODE)) { >- commandLine.append(ANT_DEBUG_LOGGER_CLASS); >- } else if (captureOutput) { >- commandLine.append(ANT_LOGGER_CLASS); >- } else { >- commandLine.append(NULL_LOGGER_CLASS); >- } >- } >- } >- >- if (separateVM) { >- appendTaskAndTypes(prefs, commandLine); >- } >- commandLine.append(" -buildfile \""); //$NON-NLS-1$ >- commandLine.append(location.toOSString()); >- commandLine.append('\"'); >- >- if (targets != null) { >- for (int i = 0; i < targets.length; i++) { >- commandLine.append(" \""); //$NON-NLS-1$ >- commandLine.append(targets[i]); >- commandLine.append('\"'); >- } >- } >- return commandLine; >- } >- >- private void appendTaskAndTypes(AntCorePreferences prefs, StringBuffer commandLine) { >- List tasks= prefs.getRemoteTasks(); >- Iterator itr= tasks.iterator(); >- while (itr.hasNext()) { >- Task task = (Task) itr.next(); >- commandLine.append(" -eclipseTask "); //$NON-NLS-1$ >- String name= ProjectHelper.genComponentName(task.getURI(), task.getTaskName()); >- commandLine.append(name); >- commandLine.append(','); >- commandLine.append(task.getClassName()); >- } >- >- List types= prefs.getRemoteTypes(); >- itr= types.iterator(); >- while (itr.hasNext()) { >- Type type = (Type) itr.next(); >- commandLine.append(" -eclipseType "); //$NON-NLS-1$ >- String name= ProjectHelper.genComponentName(type.getURI(), type.getTypeName()); >- commandLine.append(name); >- commandLine.append(','); >- commandLine.append(type.getClassName()); >- } >- } >- >- private void appendProperty(StringBuffer commandLine, String name, String value) { >- commandLine.append(" \"-D"); //$NON-NLS-1$ >- commandLine.append(name); >- commandLine.append('='); >- commandLine.append(value); >- if (value.length() > 0 && value.charAt(value.length() - 1) == File.separatorChar) { >- commandLine.append(File.separatorChar); >- } >- commandLine.append("\""); //$NON-NLS-1$ >- } >- >- 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 { >- boolean debug= fMode.equals(ILaunchManager.DEBUG_MODE); >- if (captureOutput) { >- if (debug) { >- RemoteAntDebugBuildListener listener= new RemoteAntDebugBuildListener(launch); >- if (requestPort != -1) { >- listener.startListening(port, requestPort); >- } >- } else if (!fUserSpecifiedLogger) { >- RemoteAntBuildListener client= new RemoteAntBuildListener(launch); >- if (port != -1) { >- client.startListening(port); >- } >- } >- } >- >- ILaunchConfigurationWorkingCopy copy= configuration.getWorkingCopy(); >- setDefaultWorkingDirectory(copy); >- copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, commandLine.toString()); >- StringBuffer vmArgs= generateVMArguments(copy, setInputHandler, antHome); >- copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs.toString()); >- copy.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true); >- if (copy.getAttribute(IAntLaunchConfigurationConstants.ATTR_DEFAULT_VM_INSTALL, false)) { >- setDefaultVM(configuration, copy); >- } >- if (debug) { //do not allow launch in foreground bug 83254 >- copy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true); >- } >- >- //set the ANT_HOME environment variable >- if (antHome != null) { >- Map vars = copy.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, new HashMap(1)); >- vars.put("ANT_HOME", antHome); //$NON-NLS-1$ >- copy.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, vars); >- } >- >- //copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"); >- IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 10); >- AntJavaLaunchDelegate delegate= new AntJavaLaunchDelegate(); >- delegate.preLaunchCheck(copy, ILaunchManager.RUN_MODE, subMonitor); >- delegate.launch(copy, ILaunchManager.RUN_MODE, launch, subMonitor); >- final IProcess[] processes= launch.getProcesses(); >- for (int i = 0; i < processes.length; i++) { >- setProcessAttributes(processes[i], idStamp, null, captureOutput); >- } >- >- if (CommonTab.isLaunchInBackground(copy)) { >- // refresh resources after process finishes >- if (RefreshTab.getRefreshScope(configuration) != null) { >- BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(configuration, processes[0]); >- refresher.startBackgroundRefresh(); >- } >- } else { >- final boolean[] terminated= new boolean[1]; >- terminated[0]= launch.isTerminated(); >- IDebugEventSetListener listener= new IDebugEventSetListener() { >- public void handleDebugEvents(DebugEvent[] events) { >- for (int i = 0; i < events.length; i++) { >- DebugEvent event = events[i]; >- for (int j= 0, numProcesses= processes.length; j < numProcesses; j++) { >- if (event.getSource() == processes[j] && event.getKind() == DebugEvent.TERMINATE) { >- terminated[0]= true; >- break; >- } >- } >- } >- } >- }; >- DebugPlugin.getDefault().addDebugEventListener(listener); >- monitor.subTask(AntLaunchConfigurationMessages.AntLaunchDelegate_28); >- while (!monitor.isCanceled() && !terminated[0]) { >- try { >- Thread.sleep(50); >- } catch (InterruptedException e) { >- } >- } >- DebugPlugin.getDefault().removeDebugEventListener(listener); >- if (!monitor.isCanceled()) { >- // refresh resources >- RefreshTab.refreshResources(configuration, monitor); >- } >- } >- } >- >- private void setDefaultVM(ILaunchConfiguration configuration, ILaunchConfigurationWorkingCopy copy) { >- try { >- JavaRuntime.getJavaProject(configuration); >- //remove the vm name, install type and jre container path for the Java launching concept of default VM >- copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, (String)null); >- copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, (String)null); >- copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, (String)null); >- } catch (CoreException ce) { >- //not in a Java project >- IVMInstall defaultVMInstall= JavaRuntime.getDefaultVMInstall(); >- copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, defaultVMInstall.getName()); >- copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, defaultVMInstall.getVMInstallType().getId()); >- } >- } >- >- private StringBuffer generateVMArguments(ILaunchConfiguration config, boolean setInputHandler, String antHome) { >- StringBuffer vmArgs= new StringBuffer(); >- try { >- String configArgs= config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String)null); >- if (configArgs != null) { >- vmArgs.append(configArgs); >- vmArgs.append(' '); >- } >- } catch (CoreException e) { >- } >- >- if (antHome != null) { >- vmArgs.append("-Dant.home=\""); //$NON-NLS-1$ >- vmArgs.append(antHome); >- vmArgs.append("\" "); //$NON-NLS-1$ >- >- File antLibDir= new File(antHome, "lib"); //$NON-NLS-1$ >- vmArgs.append("-Dant.library.dir=\""); //$NON-NLS-1$ >- vmArgs.append(antLibDir.getAbsolutePath()); >- vmArgs.append('\"'); >- } >- if (setInputHandler) { >- String swtLocation= getSWTLibraryLocation(); >- if (swtLocation != null) { >- vmArgs.append(" -Djava.library.path=\""); //$NON-NLS-1$ >- String javaLibPath= System.getProperty("java.library.path"); //$NON-NLS-1$ >- javaLibPath= stripUnescapedQuotes(javaLibPath); >- if (javaLibPath != null) { >- vmArgs.append(javaLibPath); >- if (vmArgs.charAt(vmArgs.length() - 1) != File.pathSeparatorChar) { >- vmArgs.append(File.pathSeparatorChar); >- } >- } >- vmArgs.append(swtLocation); >- vmArgs.append('"'); >- } >- } >- return vmArgs; >- } >- >- private String stripUnescapedQuotes(String javaLibPath) { >- StringBuffer buf = new StringBuffer(javaLibPath.length()); >- for (int i = 0; i < javaLibPath.length(); i++) { >- char c = javaLibPath.charAt(i); >- switch (c) { >- case '"': >- if (i != 0 && javaLibPath.charAt(i-1) == '\\') { >- buf.append(c); >- } >- break; >- default: >- buf.append(c); >- break; >- } >- } >- return buf.toString(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String) >- */ >- protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException { >- IProject[] projects = ExternalToolsBuildTab.getBuildProjects(configuration, ATTR_BUILD_SCOPE); >- if (projects == null) { >- return NO_PROJECTS; >- } >- boolean isRef = ExternalToolsBuildTab.isIncludeReferencedProjects(configuration, ATTR_INCLUDE_REFERENCED_PROJECTS); >- if (isRef) { >- return computeReferencedBuildOrder(projects); >- } >- return computeBuildOrder(projects); >- } >- >- private String getSWTLibraryLocation() { >- if (fgSWTLibraryLocation == null) { >- Bundle bundle= Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$ >- BundleDescription description= Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId()); >- BundleDescription[] fragments= description.getFragments(); >- if (fragments == null || fragments.length == 0) { >- return null; >- } >- Bundle fragBundle= Platform.getBundle(fragments[0].getSymbolicName()); >- try { >- URL url= FileLocator.toFileURL(fragBundle.getEntry("/")); //$NON-NLS-1$ >- IPath path= new Path(url.getPath()); >- path= path.removeTrailingSeparator(); >- fgSWTLibraryLocation= path.toOSString(); >- } catch (IOException e) { >- } >- } >- return fgSWTLibraryLocation; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBreakpoints(org.eclipse.debug.core.ILaunchConfiguration) >- */ >- protected IBreakpoint[] getBreakpoints(ILaunchConfiguration configuration) { >- IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager(); >- if (!breakpointManager.isEnabled()) { >- // no need to check breakpoints individually. >- return null; >- } >- return breakpointManager.getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#saveBeforeLaunch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.core.runtime.IProgressMonitor) >- */ >- protected boolean saveBeforeLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException { >- if (IExternalToolConstants.ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY.equals( >- configuration.getType().getCategory())) { >- // don't prompt for builders >- return true; >- } >- return super.saveBeforeLaunch(configuration, mode, monitor); >- } >- >- /** >- * Sets the default working directory to be the parent folder of the buildfile if >- * the user has not explicitly set the working directory. >- */ >- private void setDefaultWorkingDirectory(ILaunchConfigurationWorkingCopy copy) { >- try { >- String wd = copy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null); >- if (wd == null) { >- wd= ExternalToolsUtil.getLocation(copy).removeLastSegments(1).toOSString(); >- copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, wd); >- } >- } catch (CoreException e) { >- AntUIPlugin.log(e.getStatus()); >- } >- } >-} >+///******************************************************************************* >+// * Copyright (c) 2000, 2009 IBM Corporation and others. >+// * All rights reserved. This program and the accompanying materials >+// * are made available under the terms of the Eclipse Public License v1.0 >+// * which accompanies this distribution, and is available at >+// * http://www.eclipse.org/legal/epl-v10.html >+// * >+// * Contributors: >+// * IBM Corporation - initial API and implementation >+// * Juan A. Hernandez - bug 89926 >+// * dakshinamurthy.karra@gmail.com - bug 165371 >+// *******************************************************************************/ >+//package org.eclipse.ant.internal.ui.launchConfigurations; >+// >+//import java.io.File; >+//import java.io.IOException; >+//import java.net.URL; >+//import java.util.HashMap; >+//import java.util.Iterator; >+//import java.util.List; >+//import java.util.Map; >+// >+//import org.apache.tools.ant.ProjectHelper; >+//import org.eclipse.ant.core.AntCorePlugin; >+//import org.eclipse.ant.core.AntCorePreferences; >+//import org.eclipse.ant.core.AntRunner; >+//import org.eclipse.ant.core.Property; >+//import org.eclipse.ant.core.Task; >+//import org.eclipse.ant.core.Type; >+//import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger; >+//import org.eclipse.ant.internal.launching.AntLaunchingUtil; >+//import org.eclipse.ant.internal.ui.AntUIPlugin; >+//import org.eclipse.ant.internal.ui.AntUtil; >+//import org.eclipse.ant.internal.ui.IAntUIConstants; >+//import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants; >+//import org.eclipse.ant.internal.ui.debug.IAntDebugConstants; >+//import org.eclipse.ant.internal.ui.debug.model.RemoteAntDebugBuildListener; >+//import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants; >+//import org.eclipse.core.resources.IProject; >+//import org.eclipse.core.runtime.CoreException; >+//import org.eclipse.core.runtime.FileLocator; >+//import org.eclipse.core.runtime.IPath; >+//import org.eclipse.core.runtime.IProgressMonitor; >+//import org.eclipse.core.runtime.IStatus; >+//import org.eclipse.core.runtime.Path; >+//import org.eclipse.core.runtime.Platform; >+//import org.eclipse.core.runtime.Status; >+//import org.eclipse.core.runtime.SubProgressMonitor; >+//import org.eclipse.core.variables.VariablesPlugin; >+//import org.eclipse.debug.core.DebugEvent; >+//import org.eclipse.debug.core.DebugPlugin; >+//import org.eclipse.debug.core.IBreakpointManager; >+//import org.eclipse.debug.core.IDebugEventSetListener; >+//import org.eclipse.debug.core.ILaunch; >+//import org.eclipse.debug.core.ILaunchConfiguration; >+//import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+//import org.eclipse.debug.core.ILaunchManager; >+//import org.eclipse.debug.core.model.IBreakpoint; >+//import org.eclipse.debug.core.model.IProcess; >+//import org.eclipse.debug.core.model.LaunchConfigurationDelegate; >+//import org.eclipse.debug.ui.CommonTab; >+//import org.eclipse.debug.ui.IDebugUIConstants; >+//import org.eclipse.debug.ui.RefreshTab; >+//import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+//import org.eclipse.jdt.launching.IVMInstall; >+//import org.eclipse.jdt.launching.JavaRuntime; >+//import org.eclipse.jdt.launching.SocketUtil; >+//import org.eclipse.jface.dialogs.MessageDialogWithToggle; >+//import org.eclipse.jface.preference.IPreferenceStore; >+//import org.eclipse.osgi.service.resolver.BundleDescription; >+//import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab; >+//import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; >+//import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants; >+//import org.eclipse.ui.externaltools.internal.program.launchConfigurations.BackgroundResourceRefresher; >+//import org.osgi.framework.Bundle; >+// >+//import com.ibm.icu.text.MessageFormat; >+// >+///** >+// * Launch delegate for Ant builds >+// */ >+//public class AntLaunchDelegate extends LaunchConfigurationDelegate { >+// >+// private static final String ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessBuildLogger"; //$NON-NLS-1$ >+// private static final String ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessDebugBuildLogger"; //$NON-NLS-1$ >+// private static final String NULL_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.NullBuildLogger"; //$NON-NLS-1$ >+// private static final String REMOTE_ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.RemoteAntBuildLogger"; //$NON-NLS-1$ >+// private static final String REMOTE_ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.debug.RemoteAntDebugBuildLogger"; //$NON-NLS-1$ >+// private static final String BASE_DIR_PREFIX = "-Dbasedir="; //$NON-NLS-1$ >+// private static final String INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.AntInputHandler"; //$NON-NLS-1$ >+// private static final String REMOTE_INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.ProxyInputHandler"; //$NON-NLS-1$ >+// >+// private static final IProject[] NO_PROJECTS = new IProject[0]; >+// >+// /** >+// * String attribute identifying the build scope for a launch configuration. >+// * <code>null</code> indicates the default workspace build. >+// */ >+// private static final String ATTR_BUILD_SCOPE = AntUIPlugin.getUniqueIdentifier() + ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$ >+// >+// /** >+// * Attribute identifier specifying whether referenced projects should be >+// * considered when computing the projects to build. Default value is >+// * <code>true</code>. >+// */ >+// private static final String ATTR_INCLUDE_REFERENCED_PROJECTS = AntUIPlugin.getUniqueIdentifier() + ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$ >+// >+// >+// private static String fgSWTLibraryLocation; >+// >+// private String fMode; >+// private boolean fUserSpecifiedLogger= false; >+// >+// private String getProgramArguments(ILaunchConfiguration configuration) throws CoreException { >+// String arguments = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$ >+// return VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(arguments); >+// } >+// >+// /** >+// * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, >+// * java.lang.String, org.eclipse.debug.core.ILaunch, >+// * org.eclipse.core.runtime.IProgressMonitor) >+// */ >+// public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { >+// if (monitor.isCanceled()) { >+// return; >+// } >+// fUserSpecifiedLogger= false; >+// fMode= mode; >+// >+// // migrate the config to the new classpath format if required >+// AntLaunchingUtil.migrateToNewClasspathFormat(configuration); >+// >+// boolean isSeparateJRE= AntLaunchingUtil.isSeparateJREAntBuild(configuration); >+// >+// if (CommonTab.isLaunchInBackground(configuration)) { >+// monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1, new String[] {configuration.getName()}), 10); >+// } else { >+// monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Running__0__2, new String[] {configuration.getName()}), 100); >+// } >+// >+// // resolve location >+// IPath location = ExternalToolsUtil.getLocation(configuration); >+// monitor.worked(1); >+// >+// if (monitor.isCanceled()) { >+// return; >+// } >+// >+// if (!isSeparateJRE && AntRunner.isBuildRunning()) { >+// IStatus status= new Status(IStatus.ERROR, IAntUIConstants.PLUGIN_ID, 1, MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Build_In_Progress, new String[]{location.toOSString()}), null); >+// throw new CoreException(status); >+// } >+// >+// // resolve working directory >+// IPath workingDirectory = ExternalToolsUtil.getWorkingDirectory(configuration); >+// String basedir = null; >+// if (workingDirectory != null) { >+// basedir= workingDirectory.toOSString(); >+// } >+// monitor.worked(1); >+// >+// if (monitor.isCanceled()) { >+// return; >+// } >+// >+// // link the process to its build logger via a timestamp >+// long timeStamp = System.currentTimeMillis(); >+// String idStamp = Long.toString(timeStamp); >+// StringBuffer idProperty = new StringBuffer("-D"); //$NON-NLS-1$ >+// idProperty.append(AbstractEclipseBuildLogger.ANT_PROCESS_ID); >+// idProperty.append('='); >+// idProperty.append(idStamp); >+// >+// // resolve arguments >+// String[] arguments = null; >+// if (isSeparateJRE) { >+// arguments = new String[] {getProgramArguments(configuration)}; >+// } else { >+// arguments = ExternalToolsUtil.getArguments(configuration); >+// } >+// >+// Map userProperties= AntLaunchingUtil.getProperties(configuration); >+// if (userProperties != null) {//create a copy so as to not affect the configuration with transient properties >+// userProperties= new HashMap(userProperties); >+// } >+// String[] propertyFiles= AntUtil.getPropertyFiles(configuration); >+// String[] targets = AntLaunchingUtil.getTargetNames(configuration); >+// URL[] customClasspath= AntLaunchingUtil.getCustomClasspath(configuration); >+// String antHome= AntLaunchingUtil.getAntHome(configuration); >+// >+// boolean setInputHandler= true; >+// try { >+// //check if set specify inputhandler >+// setInputHandler = configuration.getAttribute(IAntUIConstants.SET_INPUTHANDLER, true); >+// } catch (CoreException ce) { >+// AntUIPlugin.log(ce); >+// } >+// >+// AntRunner runner= null; >+// if (!isSeparateJRE) { >+// runner = configureAntRunner(configuration, location, basedir, idProperty, arguments, userProperties, propertyFiles, targets, customClasspath, antHome, setInputHandler); >+// } >+// >+// monitor.worked(1); >+// >+// if (monitor.isCanceled()) { >+// return; >+// } >+// boolean captureOutput= ExternalToolsUtil.getCaptureOutput(configuration); >+// int port= -1; >+// int requestPort= -1; >+// if (isSeparateJRE && captureOutput) { >+// if (userProperties == null) { >+// userProperties= new HashMap(); >+// } >+// port= SocketUtil.findFreePort(); >+// userProperties.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp); >+// userProperties.put("eclipse.connect.port", Integer.toString(port)); //$NON-NLS-1$ >+// if (fMode.equals(ILaunchManager.DEBUG_MODE)) { >+// requestPort= SocketUtil.findFreePort(); >+// userProperties.put("eclipse.connect.request_port", Integer.toString(requestPort)); //$NON-NLS-1$ >+// } >+// } >+// >+// StringBuffer commandLine= generateCommandLine(location, arguments, userProperties, propertyFiles, targets, antHome, basedir, isSeparateJRE, captureOutput, setInputHandler); >+// >+// if (isSeparateJRE) { >+// monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1, new String[] {configuration.getName()}), 10); >+// runInSeparateVM(configuration, launch, monitor, idStamp, antHome, port, requestPort, commandLine, captureOutput, setInputHandler); >+// } else { >+// runInSameVM(configuration, launch, monitor, location, idStamp, runner, commandLine, captureOutput); >+// } >+// >+// monitor.done(); >+// } >+// >+// private void runInSameVM(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor, IPath location, String idStamp, AntRunner runner, StringBuffer commandLine, boolean captureOutput) throws CoreException { >+// Map attributes= new HashMap(2); >+// attributes.put(IProcess.ATTR_PROCESS_TYPE, IAntLaunchConfigurationConstants.ID_ANT_PROCESS_TYPE); >+// attributes.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp); >+// >+// final AntProcess process = new AntProcess(location.toOSString(), launch, attributes); >+// setProcessAttributes(process, idStamp, commandLine, captureOutput); >+// boolean debug= fMode.equals(ILaunchManager.DEBUG_MODE); >+// if (debug || CommonTab.isLaunchInBackground(configuration)) { >+// final AntRunner finalRunner= runner; >+// Runnable r = new Runnable() { >+// public void run() { >+// try { >+// finalRunner.run(process); >+// } catch (CoreException e) { >+// handleException(e, AntLaunchConfigurationMessages.AntLaunchDelegate_Failure); >+// } >+// process.terminated(); >+// } >+// }; >+// Thread background = new Thread(r); >+// background.setDaemon(true); >+// background.start(); >+// monitor.worked(1); >+// //refresh resources after process finishes >+// if (RefreshTab.getRefreshScope(configuration) != null) { >+// BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(configuration, process); >+// refresher.startBackgroundRefresh(); >+// } >+// } else { >+// // execute the build >+// try { >+// runner.run(monitor); >+// } catch (CoreException e) { >+// process.terminated(); >+// monitor.done(); >+// handleException(e, AntLaunchConfigurationMessages.AntLaunchDelegate_23); >+// return; >+// } >+// process.terminated(); >+// >+// // refresh resources >+// RefreshTab.refreshResources(configuration, monitor); >+// } >+// } >+// >+// 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 { >+// int argLength = 1; // at least one user property - timestamp >+// if (arguments != null) { >+// argLength += arguments.length; >+// } >+// if (baseDir != null && baseDir.length() > 0) { >+// argLength++; >+// } >+// String[] runnerArgs = new String[argLength]; >+// if (arguments != null) { >+// System.arraycopy(arguments, 0, runnerArgs, 0, arguments.length); >+// } >+// if (baseDir != null && baseDir.length() > 0) { >+// runnerArgs[runnerArgs.length - 2] = BASE_DIR_PREFIX + baseDir; >+// } >+// runnerArgs[runnerArgs.length -1] = idProperty.toString(); >+// >+// AntRunner runner= new AntRunner(); >+// runner.setBuildFileLocation(location.toOSString()); >+// boolean captureOutput= ExternalToolsUtil.getCaptureOutput(configuration); >+// if (captureOutput) { >+// if (fMode.equals(ILaunchManager.DEBUG_MODE)) { >+// runner.addBuildLogger(ANT_DEBUG_LOGGER_CLASS); >+// } else { >+// runner.addBuildLogger(ANT_LOGGER_CLASS); >+// } >+// } else { >+// runner.addBuildLogger(NULL_LOGGER_CLASS); >+// } >+// if (setInputHandler) { >+// runner.setInputHandler(INPUT_HANDLER_CLASS); >+// } else { >+// runner.setInputHandler(""); //$NON-NLS-1$ >+// } >+// runner.setArguments(runnerArgs); >+// if (userProperties != null) { >+// runner.addUserProperties(userProperties); >+// } >+// >+// if (propertyFiles != null) { >+// runner.setPropertyFiles(propertyFiles); >+// } >+// >+// if (targets != null) { >+// runner.setExecutionTargets(targets); >+// } >+// >+// if (customClasspath != null) { >+// runner.setCustomClasspath(customClasspath); >+// } >+// >+// if (antHome != null) { >+// runner.setAntHome(antHome); >+// } >+// return runner; >+// } >+// >+// private void handleException(final CoreException e, final String title) { >+// IPreferenceStore store= AntUIPlugin.getDefault().getPreferenceStore(); >+// if (store.getBoolean(IAntUIPreferenceConstants.ANT_ERROR_DIALOG)) { >+// AntUIPlugin.getStandardDisplay().asyncExec(new Runnable() { >+// public void run() { >+// MessageDialogWithToggle.openError(null, title, e.getMessage(), AntLaunchConfigurationMessages.AntLaunchDelegate_22, false, AntUIPlugin.getDefault().getPreferenceStore(), IAntUIPreferenceConstants.ANT_ERROR_DIALOG); >+// } >+// }); >+// } >+// } >+// >+// private void setProcessAttributes(IProcess process, String idStamp, StringBuffer commandLine, boolean captureOutput) { >+// // link the process to the Eclipse build logger via a timestamp >+// if (!fUserSpecifiedLogger) { >+// process.setAttribute(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp); >+// } >+// >+// // create "fake" command line for the process >+// if (commandLine != null) { >+// process.setAttribute(IProcess.ATTR_CMDLINE, commandLine.toString()); >+// } >+// } >+// >+// private StringBuffer generateCommandLine(IPath location, String[] arguments, Map userProperties, String[] propertyFiles, String[] targets, String antHome, String basedir, boolean separateVM, boolean captureOutput, boolean setInputHandler) { >+// StringBuffer commandLine= new StringBuffer(); >+// >+// if (!separateVM) { >+// commandLine.append("ant"); //$NON-NLS-1$ >+// } >+// >+// if (arguments != null) { >+// for (int i = 0; i < arguments.length; i++) { >+// commandLine.append(' '); >+// commandLine.append(arguments[i]); >+// } >+// } >+// >+// AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences(); >+// if (propertyFiles == null) { //global >+// String[] files= prefs.getCustomPropertyFiles(); >+// for (int i = 0; i < files.length; i++) { >+// String path = files[i]; >+// commandLine.append(" -propertyfile \""); //$NON-NLS-1$ >+// commandLine.append(path); >+// commandLine.append('\"'); >+// } >+// } else {//"local" configuration >+// for (int i = 0; i < propertyFiles.length; i++) { >+// String path = propertyFiles[i]; >+// commandLine.append(" -propertyfile \""); //$NON-NLS-1$ >+// commandLine.append(path); >+// commandLine.append('\"'); >+// } >+// } >+// //"local" configuration >+// if (userProperties != null) { >+// Iterator keys = userProperties.keySet().iterator(); >+// String key; >+// while (keys.hasNext()) { >+// key= (String)keys.next(); >+// appendProperty(commandLine, key, (String)userProperties.get(key)); >+// } >+// } >+// >+// //global >+// List properties= null; >+// if (!separateVM) { >+// properties= prefs.getProperties(); >+// } else { >+// properties= prefs.getRemoteAntProperties(); >+// } >+// >+// //if we have user properties this means that the user has chosen to override the global properties >+// //if in a separate VM and have only two (or three if debug) user properties these are really only Eclipse generated properties >+// //and the user is still using the global properties >+// int numberOfEclipseProperties= 2; >+// if (userProperties != null && userProperties.get("eclipse.connect.request_port") != null){ //$NON-NLS-1$ >+// numberOfEclipseProperties= 3; //debug mode >+// } >+// boolean useGlobalProperties = userProperties == null || (separateVM && userProperties.size() == numberOfEclipseProperties); >+// if (useGlobalProperties) { >+// for (Iterator iter = properties.iterator(); iter.hasNext();) { >+// Property property = (Property) iter.next(); >+// String key= property.getName(); >+// String value= property.getValue(false); >+// if (value != null) { >+// appendProperty(commandLine, key, value); >+// } >+// } >+// } >+// >+// if (basedir != null && basedir.length() > 0) { >+// appendProperty(commandLine, "basedir", basedir); //$NON-NLS-1$ >+// } >+// >+// if (antHome != null) { >+// commandLine.append(" \"-Dant.home="); //$NON-NLS-1$ >+// commandLine.append(antHome); >+// commandLine.append('\"'); >+// } >+// >+// if (separateVM) { >+// if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$ >+// if (captureOutput) { >+// commandLine.append(" -logger "); //$NON-NLS-1$ >+// if (fMode.equals(ILaunchManager.DEBUG_MODE)) { >+// commandLine.append(REMOTE_ANT_DEBUG_LOGGER_CLASS); >+// } else { >+// commandLine.append(REMOTE_ANT_LOGGER_CLASS); >+// } >+// } >+// } else { >+// fUserSpecifiedLogger= true; >+// } >+// if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$ >+// commandLine.append(" -inputhandler "); //$NON-NLS-1$ >+// commandLine.append(REMOTE_INPUT_HANDLER_CLASS); >+// } >+// } else { >+// if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$ >+// commandLine.append(" -inputhandler "); //$NON-NLS-1$ >+// commandLine.append(INPUT_HANDLER_CLASS); >+// } >+// if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$ >+// commandLine.append(" -logger "); //$NON-NLS-1$ >+// if (fMode.equals(ILaunchManager.DEBUG_MODE)) { >+// commandLine.append(ANT_DEBUG_LOGGER_CLASS); >+// } else if (captureOutput) { >+// commandLine.append(ANT_LOGGER_CLASS); >+// } else { >+// commandLine.append(NULL_LOGGER_CLASS); >+// } >+// } >+// } >+// >+// if (separateVM) { >+// appendTaskAndTypes(prefs, commandLine); >+// } >+// commandLine.append(" -buildfile \""); //$NON-NLS-1$ >+// commandLine.append(location.toOSString()); >+// commandLine.append('\"'); >+// >+// if (targets != null) { >+// for (int i = 0; i < targets.length; i++) { >+// commandLine.append(" \""); //$NON-NLS-1$ >+// commandLine.append(targets[i]); >+// commandLine.append('\"'); >+// } >+// } >+// return commandLine; >+// } >+// >+// private void appendTaskAndTypes(AntCorePreferences prefs, StringBuffer commandLine) { >+// List tasks= prefs.getRemoteTasks(); >+// Iterator itr= tasks.iterator(); >+// while (itr.hasNext()) { >+// Task task = (Task) itr.next(); >+// commandLine.append(" -eclipseTask "); //$NON-NLS-1$ >+// String name= ProjectHelper.genComponentName(task.getURI(), task.getTaskName()); >+// commandLine.append(name); >+// commandLine.append(','); >+// commandLine.append(task.getClassName()); >+// } >+// >+// List types= prefs.getRemoteTypes(); >+// itr= types.iterator(); >+// while (itr.hasNext()) { >+// Type type = (Type) itr.next(); >+// commandLine.append(" -eclipseType "); //$NON-NLS-1$ >+// String name= ProjectHelper.genComponentName(type.getURI(), type.getTypeName()); >+// commandLine.append(name); >+// commandLine.append(','); >+// commandLine.append(type.getClassName()); >+// } >+// } >+// >+// private void appendProperty(StringBuffer commandLine, String name, String value) { >+// commandLine.append(" \"-D"); //$NON-NLS-1$ >+// commandLine.append(name); >+// commandLine.append('='); >+// commandLine.append(value); >+// if (value.length() > 0 && value.charAt(value.length() - 1) == File.separatorChar) { >+// commandLine.append(File.separatorChar); >+// } >+// commandLine.append("\""); //$NON-NLS-1$ >+// } >+// >+// 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 { >+// boolean debug= fMode.equals(ILaunchManager.DEBUG_MODE); >+// if (captureOutput) { >+// if (debug) { >+// RemoteAntDebugBuildListener listener= new RemoteAntDebugBuildListener(launch); >+// if (requestPort != -1) { >+// listener.startListening(port, requestPort); >+// } >+// } else if (!fUserSpecifiedLogger) { >+// RemoteAntBuildListener client= new RemoteAntBuildListener(launch); >+// if (port != -1) { >+// client.startListening(port); >+// } >+// } >+// } >+// >+// ILaunchConfigurationWorkingCopy copy= configuration.getWorkingCopy(); >+// setDefaultWorkingDirectory(copy); >+// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, commandLine.toString()); >+// StringBuffer vmArgs= generateVMArguments(copy, setInputHandler, antHome); >+// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs.toString()); >+// copy.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true); >+// if (copy.getAttribute(IAntLaunchConfigurationConstants.ATTR_DEFAULT_VM_INSTALL, false)) { >+// setDefaultVM(configuration, copy); >+// } >+// if (debug) { //do not allow launch in foreground bug 83254 >+// copy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true); >+// } >+// >+// //set the ANT_HOME environment variable >+// if (antHome != null) { >+// Map vars = copy.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, new HashMap(1)); >+// vars.put("ANT_HOME", antHome); //$NON-NLS-1$ >+// copy.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, vars); >+// } >+// >+// //copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"); >+// IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 10); >+// AntJavaLaunchDelegate delegate= new AntJavaLaunchDelegate(); >+// delegate.preLaunchCheck(copy, ILaunchManager.RUN_MODE, subMonitor); >+// delegate.launch(copy, ILaunchManager.RUN_MODE, launch, subMonitor); >+// final IProcess[] processes= launch.getProcesses(); >+// for (int i = 0; i < processes.length; i++) { >+// setProcessAttributes(processes[i], idStamp, null, captureOutput); >+// } >+// >+// if (CommonTab.isLaunchInBackground(copy)) { >+// // refresh resources after process finishes >+// if (RefreshTab.getRefreshScope(configuration) != null) { >+// BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(configuration, processes[0]); >+// refresher.startBackgroundRefresh(); >+// } >+// } else { >+// final boolean[] terminated= new boolean[1]; >+// terminated[0]= launch.isTerminated(); >+// IDebugEventSetListener listener= new IDebugEventSetListener() { >+// public void handleDebugEvents(DebugEvent[] events) { >+// for (int i = 0; i < events.length; i++) { >+// DebugEvent event = events[i]; >+// for (int j= 0, numProcesses= processes.length; j < numProcesses; j++) { >+// if (event.getSource() == processes[j] && event.getKind() == DebugEvent.TERMINATE) { >+// terminated[0]= true; >+// break; >+// } >+// } >+// } >+// } >+// }; >+// DebugPlugin.getDefault().addDebugEventListener(listener); >+// monitor.subTask(AntLaunchConfigurationMessages.AntLaunchDelegate_28); >+// while (!monitor.isCanceled() && !terminated[0]) { >+// try { >+// Thread.sleep(50); >+// } catch (InterruptedException e) { >+// } >+// } >+// DebugPlugin.getDefault().removeDebugEventListener(listener); >+// if (!monitor.isCanceled()) { >+// // refresh resources >+// RefreshTab.refreshResources(configuration, monitor); >+// } >+// } >+// } >+// >+// private void setDefaultVM(ILaunchConfiguration configuration, ILaunchConfigurationWorkingCopy copy) { >+// try { >+// JavaRuntime.getJavaProject(configuration); >+// //remove the vm name, install type and jre container path for the Java launching concept of default VM >+// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, (String)null); >+// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, (String)null); >+// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, (String)null); >+// } catch (CoreException ce) { >+// //not in a Java project >+// IVMInstall defaultVMInstall= JavaRuntime.getDefaultVMInstall(); >+// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, defaultVMInstall.getName()); >+// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, defaultVMInstall.getVMInstallType().getId()); >+// } >+// } >+// >+// private StringBuffer generateVMArguments(ILaunchConfiguration config, boolean setInputHandler, String antHome) { >+// StringBuffer vmArgs= new StringBuffer(); >+// try { >+// String configArgs= config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String)null); >+// if (configArgs != null) { >+// vmArgs.append(configArgs); >+// vmArgs.append(' '); >+// } >+// } catch (CoreException e) { >+// } >+// >+// if (antHome != null) { >+// vmArgs.append("-Dant.home=\""); //$NON-NLS-1$ >+// vmArgs.append(antHome); >+// vmArgs.append("\" "); //$NON-NLS-1$ >+// >+// File antLibDir= new File(antHome, "lib"); //$NON-NLS-1$ >+// vmArgs.append("-Dant.library.dir=\""); //$NON-NLS-1$ >+// vmArgs.append(antLibDir.getAbsolutePath()); >+// vmArgs.append('\"'); >+// } >+// if (setInputHandler) { >+// String swtLocation= getSWTLibraryLocation(); >+// if (swtLocation != null) { >+// vmArgs.append(" -Djava.library.path=\""); //$NON-NLS-1$ >+// String javaLibPath= System.getProperty("java.library.path"); //$NON-NLS-1$ >+// javaLibPath= stripUnescapedQuotes(javaLibPath); >+// if (javaLibPath != null) { >+// vmArgs.append(javaLibPath); >+// if (vmArgs.charAt(vmArgs.length() - 1) != File.pathSeparatorChar) { >+// vmArgs.append(File.pathSeparatorChar); >+// } >+// } >+// vmArgs.append(swtLocation); >+// vmArgs.append('"'); >+// } >+// } >+// return vmArgs; >+// } >+// >+// private String stripUnescapedQuotes(String javaLibPath) { >+// StringBuffer buf = new StringBuffer(javaLibPath.length()); >+// for (int i = 0; i < javaLibPath.length(); i++) { >+// char c = javaLibPath.charAt(i); >+// switch (c) { >+// case '"': >+// if (i != 0 && javaLibPath.charAt(i-1) == '\\') { >+// buf.append(c); >+// } >+// break; >+// default: >+// buf.append(c); >+// break; >+// } >+// } >+// return buf.toString(); >+// } >+// >+// /* (non-Javadoc) >+// * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String) >+// */ >+// protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException { >+// IProject[] projects = ExternalToolsBuildTab.getBuildProjects(configuration, ATTR_BUILD_SCOPE); >+// if (projects == null) { >+// return NO_PROJECTS; >+// } >+// boolean isRef = ExternalToolsBuildTab.isIncludeReferencedProjects(configuration, ATTR_INCLUDE_REFERENCED_PROJECTS); >+// if (isRef) { >+// return computeReferencedBuildOrder(projects); >+// } >+// return computeBuildOrder(projects); >+// } >+// >+// private String getSWTLibraryLocation() { >+// if (fgSWTLibraryLocation == null) { >+// Bundle bundle= Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$ >+// BundleDescription description= Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId()); >+// BundleDescription[] fragments= description.getFragments(); >+// if (fragments == null || fragments.length == 0) { >+// return null; >+// } >+// Bundle fragBundle= Platform.getBundle(fragments[0].getSymbolicName()); >+// try { >+// URL url= FileLocator.toFileURL(fragBundle.getEntry("/")); //$NON-NLS-1$ >+// IPath path= new Path(url.getPath()); >+// path= path.removeTrailingSeparator(); >+// fgSWTLibraryLocation= path.toOSString(); >+// } catch (IOException e) { >+// } >+// } >+// return fgSWTLibraryLocation; >+// } >+// >+// /* (non-Javadoc) >+// * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBreakpoints(org.eclipse.debug.core.ILaunchConfiguration) >+// */ >+// protected IBreakpoint[] getBreakpoints(ILaunchConfiguration configuration) { >+// IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager(); >+// if (!breakpointManager.isEnabled()) { >+// // no need to check breakpoints individually. >+// return null; >+// } >+// return breakpointManager.getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL); >+// } >+// >+// /* (non-Javadoc) >+// * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#saveBeforeLaunch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.core.runtime.IProgressMonitor) >+// */ >+// protected boolean saveBeforeLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException { >+// if (IExternalToolConstants.ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY.equals( >+// configuration.getType().getCategory())) { >+// // don't prompt for builders >+// return true; >+// } >+// return super.saveBeforeLaunch(configuration, mode, monitor); >+// } >+// >+// /** >+// * Sets the default working directory to be the parent folder of the buildfile if >+// * the user has not explicitly set the working directory. >+// */ >+// private void setDefaultWorkingDirectory(ILaunchConfigurationWorkingCopy copy) { >+// try { >+// String wd = copy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null); >+// if (wd == null) { >+// wd= ExternalToolsUtil.getLocation(copy).removeLastSegments(1).toOSString(); >+// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, wd); >+// } >+// } catch (CoreException e) { >+// AntUIPlugin.log(e.getStatus()); >+// } >+// } >+//} >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntBuilderTargetsTab.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntBuilderTargetsTab.java,v >retrieving revision 1.8 >diff -u -r1.8 AntBuilderTargetsTab.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntBuilderTargetsTab.java 13 Aug 2008 15:32:18 -0000 1.8 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntBuilderTargetsTab.java 25 Sep 2009 16:23:36 -0000 >@@ -13,9 +13,9 @@ > import java.util.HashMap; > import java.util.Map; > >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.ant.internal.ui.AntUIImages; > import org.eclipse.ant.internal.ui.AntUIPlugin; >-import org.eclipse.ant.internal.ui.AntUtil; > import org.eclipse.ant.internal.ui.IAntUIConstants; > import org.eclipse.core.resources.IncrementalProjectBuilder; > import org.eclipse.core.runtime.CoreException; >@@ -182,7 +182,7 @@ > } > targetsSelected= configTargets; > } >- String[] targets= AntUtil.parseRunTargets(targetsSelected); >+ String[] targets= AntLaunchingUtil.parseRunTargets(targetsSelected); > StringBuffer result= new StringBuffer(targets[0]); > for (int i = 1; i < targets.length; i++) { > result.append(", "); //$NON-NLS-1$ >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/TaskLinkManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/TaskLinkManager.java,v >retrieving revision 1.7 >diff -u -r1.7 TaskLinkManager.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/TaskLinkManager.java 23 Feb 2005 17:20:11 -0000 1.7 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/TaskLinkManager.java 25 Sep 2009 16:23:40 -0000 >@@ -10,20 +10,26 @@ > *******************************************************************************/ > package org.eclipse.ant.internal.ui.launchConfigurations; > >- >+import java.io.File; > import java.util.ArrayList; > import java.util.HashMap; > import java.util.Iterator; > import java.util.List; > import java.util.Map; > >+import org.apache.tools.ant.util.FileUtils; >+import org.eclipse.ant.internal.launching.AntLaunch; >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; >+import org.eclipse.ant.internal.launching.LinkDescriptor; > import org.eclipse.ant.internal.ui.AntUtil; >+import org.eclipse.ant.internal.ui.ExternalHyperlink; > import org.eclipse.core.resources.IFile; > import org.eclipse.debug.core.model.IProcess; > import org.eclipse.debug.ui.console.FileLink; > import org.eclipse.debug.ui.console.IConsole; > import org.eclipse.jface.text.BadLocationException; > import org.eclipse.jface.text.IRegion; >+import org.eclipse.jface.text.Region; > import org.eclipse.ui.console.IHyperlink; > > /** >@@ -33,61 +39,60 @@ > * each build event associated with a task. When the associated line is later > * appended to the console, the corresponding text region in the console > * document is determined (as the length of a console document can not be >- * determined beforehand), and the hyperlink is added to the document. >- * The new line is added to the console, information from that line >- * may be stored to process future incoming tasks hyperlinks. >+ * determined beforehand), and the hyperlink is added to the document. The new >+ * line is added to the console, information from that line may be stored to >+ * process future incoming tasks hyperlinks. > */ > public class TaskLinkManager { >- >- /** >- * A map of processes to lists of queued task hyperlink entries >- */ >- private static Map fgProcessToLinks; >- >+ > /** > * A map of processes to lists of queued new line regions > */ > private static Map fgProcessToNewLines; >+ >+ private static Map fFileNameToIFile = new HashMap(); >+ >+ private static File fBuildFileParent = null; > >- private static List fgAntBuilds; >- >+ private Map links; >+ > private static class HyperlinkEntry { > private IHyperlink fLink; > private IRegion fRegion; > private String fMessage; >- >+ > public HyperlinkEntry(IHyperlink link, IRegion region, String message) { > fLink = link; >- fRegion = region; >+ fRegion = region; > fMessage = message; > } >- >+ > public IRegion getRegion() { > return fRegion; > } >- >+ > public IHyperlink getLink() { > return fLink; > } >- >+ > public String getMessage() { > return fMessage; > } > } >- >+ > private static class LineEntry { > private IConsole fConsole; > private IRegion fRegion; >- >+ > public LineEntry(IConsole console, IRegion region) { > fConsole = console; >- fRegion = region; >+ fRegion = region; > } >- >+ > public IRegion getRegion() { > return fRegion; > } >- >+ > public IConsole getConsole() { > return fConsole; > } >@@ -99,50 +104,63 @@ > private TaskLinkManager() { > super(); > } >- >- /** >- * Registers a hyperlink for the given process and task name. The given >- * region is relative to the beginning of the line (not the document). >- * >- * @param process the process associated with the link >- * @param link the link for the process >- * @param region The region within the line >- * @param message The message related to the link >- */ >- public static synchronized void addTaskHyperlink(IProcess process, IHyperlink link, IRegion region, String message) { >- if (fgProcessToNewLines != null) { >- List newLines = (List)fgProcessToNewLines.get(process); >- if (newLines != null) { >- for (int index= 0; index < newLines.size(); index++) { >- LineEntry newLine = (LineEntry) newLines.get(index); >- if (addLink(newLine.getConsole(), link, newLine.getRegion(), region, message)) { >- newLines.subList(0, index + 1).clear(); >- return; >+ >+ private static HyperlinkEntry createHyperlink( >+ LinkDescriptor linkDescriptor, IProcess process) { >+ String line = linkDescriptor.getLine(); >+ String fileName = linkDescriptor.getFileName(); >+ int lineNumber = linkDescriptor.getLineNumber(); >+ int offset = linkDescriptor.getOffset(); >+ int length = linkDescriptor.getLength(); >+ >+ IHyperlink taskLink = null; >+ if (lineNumber == -1) { >+ // fileName will actually be the String representation of Location >+ taskLink = AntUtil.getLocationLink(fileName, fBuildFileParent); >+ } else { >+ IFile file = (IFile) fFileNameToIFile.get(fileName); >+ if (file == null) { >+ file = AntLaunchingUtil.getFileForLocation(fileName, >+ fBuildFileParent); >+ if (file != null) { >+ fFileNameToIFile.put(fileName, file); >+ taskLink = new FileLink(file, null, -1, -1, lineNumber); >+ } else { >+ File javaIOFile = FileUtils.getFileUtils().resolveFile( >+ fBuildFileParent, fileName); >+ if (javaIOFile.exists()) { >+ taskLink = new ExternalHyperlink(javaIOFile, lineNumber); > } > } >+ } else { >+ taskLink = new FileLink(file, null, -1, -1, lineNumber); > } > } >- >- if (fgProcessToLinks == null) { >- fgProcessToLinks = new HashMap(); >- >+ if (taskLink != null) { >+ return new HyperlinkEntry(taskLink, new Region(offset, length), >+ line); > } >- List links = (List)fgProcessToLinks.get(process); >- if (links == null) { >- links = new ArrayList(10); >- fgProcessToLinks.put(process, links); >+ return null; >+ } >+ >+ public static Map createHyperlinksForLaunch(IProcess process) { >+ Map links = new HashMap(); >+ AntLaunch antLaunch = (AntLaunch) process.getLaunch(); >+ List linksDescriptors = antLaunch.getLinkDescriptors(); >+ for (int i = 0; i < linksDescriptors.size(); i ++) { >+ links.put(linksDescriptors.get(i), createHyperlink((LinkDescriptor) linksDescriptors.get(i), >+ process)); > } >- >- links.add(new HyperlinkEntry(link, region, message)); >+ return links; > } >- >- private static boolean addLink(IConsole console, IHyperlink link, IRegion lineRegion, IRegion region, String message) { >- >+ >+ private static boolean addLink(IConsole console, IHyperlink link, >+ IRegion lineRegion, IRegion region, String message) { > int length = region.getLength(); >- > String text; > try { >- text = console.getDocument().get(lineRegion.getOffset(), lineRegion.getLength()); >+ text = console.getDocument().get(lineRegion.getOffset(), >+ lineRegion.getLength()); > } catch (BadLocationException e) { > return false; > } >@@ -156,49 +174,49 @@ > > /** > * A new line has been added to the given console. Adds any task hyperlink >- * associated with the line, to the console. >- * The new line may be stored to process future incoming tasks hyperlinks. >+ * associated with the line, to the console. The new line may be stored to >+ * process future incoming tasks hyperlinks. > * > * @param console > * @param newLine > */ >- public static synchronized void processNewLine(IConsole console, IRegion newLine) { >+ public static synchronized void processNewLine(IConsole console, >+ IRegion newLine) { > IProcess process = console.getProcess(); >- if (fgAntBuilds != null && fgAntBuilds.contains(process)) { >- if (linkBuildFileMessage(console, newLine)) { >- fgAntBuilds.remove(process); >- return; >- } >- } >- if (fgProcessToLinks == null) { >- addNewLine(console, newLine, process); >+ >+ Map links = createHyperlinksForLaunch(process); >+ >+ if (linkBuildFileMessage(console, newLine)) { > return; > } >- >- List links = (List)fgProcessToLinks.get(process); >+ > if (links == null) { > addNewLine(console, newLine, process); > return; > } >- >- for (int index= 0; index < links.size(); index++) { >- HyperlinkEntry link = (HyperlinkEntry) links.get(index); >- if (addLink(console, link.getLink(), newLine, link.getRegion(), link.getMessage())) { >- links.subList(0, index + 1).clear(); >+ >+ for (Iterator i = links.keySet().iterator(); i.hasNext();) { >+ LinkDescriptor keyLinkDescriptor = (LinkDescriptor) i.next(); >+ HyperlinkEntry link = (HyperlinkEntry) links.get(keyLinkDescriptor); >+ if (addLink(console, link.getLink(), newLine, link.getRegion(), >+ link.getMessage())) { >+ ((AntLaunch) process.getLaunch()).removeLinkDescriptor(keyLinkDescriptor); >+ links.remove(keyLinkDescriptor); > return; > } > } > } >- >- private static void addNewLine(IConsole console, IRegion newLine, IProcess process) { >+ >+ private static void addNewLine(IConsole console, IRegion newLine, >+ IProcess process) { > if (fgProcessToNewLines == null) { > fgProcessToNewLines = new HashMap(); > } >- List newLines = (List)fgProcessToNewLines.get(process); >+ List newLines = (List) fgProcessToNewLines.get(process); > if (newLines == null) { >- newLines= new ArrayList(); >+ newLines = new ArrayList(); > } >- >+ > newLines.add(new LineEntry(console, newLine)); > fgProcessToNewLines.put(process, newLines); > } >@@ -209,56 +227,24 @@ > * @param process > */ > public static void dispose(IProcess process) { >- if (fgProcessToLinks != null) { >- fgProcessToLinks.remove(process); >- } > if (fgProcessToNewLines != null) { > fgProcessToNewLines.remove(process); > } >- if (fgAntBuilds != null) { >- fgAntBuilds.remove(process); >- } > } >- >- /** >- * Registers the specified process as an Ant build process. >- * Allows for the generation of the "Buildfile: somefile" link in the >- * Ant output. >- * >- * @param process >- */ >- public static synchronized void registerAntBuild(IProcess process) { >- if (fgProcessToNewLines != null) { >- List newLines = (List)fgProcessToNewLines.get(process); >- if (newLines != null) { >- for (Iterator iter = newLines.iterator(); iter.hasNext();) { >- LineEntry newLine = (LineEntry) iter.next(); >- if (linkBuildFileMessage(newLine.getConsole(), newLine.getRegion())){ >- iter.remove(); >- return; >- } >- } >- } >- } >- if (fgAntBuilds == null) { >- fgAntBuilds= new ArrayList(); >- } >- fgAntBuilds.add(process); >- } >- >+ > private static boolean linkBuildFileMessage(IConsole console, IRegion region) { >- >- String message= ""; //$NON-NLS-1$ >- int offset= region.getOffset(); >+ >+ String message = ""; //$NON-NLS-1$ >+ int offset = region.getOffset(); > try { > message = console.getDocument().get(offset, region.getLength()); > } catch (BadLocationException e) { > } > if (message.startsWith("Buildfile:")) { //$NON-NLS-1$ > String fileName = message.substring(10).trim(); >- IFile file = AntUtil.getFileForLocation(fileName, null); >+ IFile file = AntLaunchingUtil.getFileForLocation(fileName, null); > if (file != null) { >- FileLink link = new FileLink(file, null, -1, -1, -1); >+ FileLink link = new FileLink(file, null, -1, -1, -1); > console.addLink(link, offset + 11, fileName.length()); > return true; > } >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchConfigurationMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchConfigurationMessages.properties,v >retrieving revision 1.44 >diff -u -r1.44 AntLaunchConfigurationMessages.properties >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchConfigurationMessages.properties 12 Dec 2007 21:00:25 -0000 1.44 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchConfigurationMessages.properties 25 Sep 2009 16:23:37 -0000 >@@ -15,14 +15,6 @@ > AddVariableStringAction_3=&Variables... > AddVariableStringAction_4=Add Variable Classpath Entry > >-AntLaunchDelegate_Launching__0__1=Launching {0} >-AntLaunchDelegate_Running__0__2=Running {0} >-AntLaunchDelegate_Build_In_Progress=Ant build {0} already in progress. Concurrent Ant builds are possible if you specify to build in a separate JRE. >-AntLaunchDelegate_Failure=Failure of Background Ant Build >-AntLaunchDelegate_22=&Do not show error dialog when Ant build fails >-AntLaunchDelegate_23=Ant Build Failed >-AntLaunchDelegate_28=Waiting for virtual machine to exit... >- > AntLaunchShortcut_Unable=Unable to find an Ant file to run. > AntLaunchShortcut_2=An exception occurred while creating a default Ant launch configuration for {0} > AntLaunchShortcut_3=An exception occurred while retrieving Ant launch configurations. >@@ -41,8 +33,6 @@ > AntJRETab_2=Run in the same &JRE as the workspace > AntJRETab_3=Se¶te JRE: > >-AntHomeClasspathEntry_8=Ant Home (Default) >-AntHomeClasspathEntry_9=Ant Home ({0}) > AntBuilderTargetsTab_0=<Builder is not set to run for this build kind> > AntBuilderTargetsTab_1=After a "Clean": > AntBuilderTargetsTab_2=&Set Targets... >@@ -53,8 +43,6 @@ > AntBuilderTargetsTab_7=During a "Clean": > AntBuilderTargetsTab_8=Set Tar&gets... > AntBuilderTargetsTab_10=<default target selected> >-AntHomeClasspathEntry_10=Ant Home {0} does not exist >-AntHomeClasspathEntry_11=Ant Home {0} does not contain a "lib" directory > > AntMainTab__Select_a_build_file__1=&Select a buildfile: > AntMainTab_3=Base Direct&ory: >@@ -81,8 +69,6 @@ > AntTargetsTab_1=No targets could be determined for the buildfile > AntClasspathTab_0=Add F&olders... > >-ContributedClasspathEntriesEntry_1=Additional Tasks & Support >- > EditAntHomeEntryAction_1=Ant &Home... > > TargetOrderDialog_Order_Targets_1=Order Targets >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntClasspathProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntClasspathProvider.java,v >retrieving revision 1.13 >diff -u -r1.13 AntClasspathProvider.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntClasspathProvider.java 1 Dec 2005 22:56:18 -0000 1.13 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntClasspathProvider.java 25 Sep 2009 16:23:36 -0000 >@@ -1,50 +1,51 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.ant.internal.ui.launchConfigurations; >- >-import java.util.ArrayList; >-import java.util.List; >- >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.debug.core.ILaunchConfiguration; >-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >-import org.eclipse.jdt.launching.IRuntimeClasspathEntry; >-import org.eclipse.jdt.launching.JavaRuntime; >-import org.eclipse.jdt.launching.StandardClasspathProvider; >- >-public class AntClasspathProvider extends StandardClasspathProvider { >- >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.IRuntimeClasspathProvider#computeUnresolvedClasspath(org.eclipse.debug.core.ILaunchConfiguration) >- */ >- public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException { >- boolean useDefault = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true); >- if (useDefault) { >- List rtes = new ArrayList(10); >- IRuntimeClasspathEntry jreEntry = null; >- try { >- jreEntry = JavaRuntime.computeJREEntry(configuration); >- } catch (CoreException e) { >- // not a java project >- } >- if (jreEntry == null) { >- jreEntry = JavaRuntime.newRuntimeContainerClasspathEntry( >- JavaRuntime.newDefaultJREContainerPath(), IRuntimeClasspathEntry.STANDARD_CLASSES); >- } >- rtes.add(jreEntry); >- rtes.add(new AntHomeClasspathEntry()); >- rtes.add(new ContributedClasspathEntriesEntry()); >- return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]); >- } >- return super.computeUnresolvedClasspath(configuration); >- } >-} >+///******************************************************************************* >+// * Copyright (c) 2000, 2005 IBM Corporation and others. >+// * All rights reserved. This program and the accompanying materials >+// * are made available under the terms of the Eclipse Public License v1.0 >+// * which accompanies this distribution, and is available at >+// * http://www.eclipse.org/legal/epl-v10.html >+// * >+// * Contributors: >+// * IBM Corporation - initial API and implementation >+// *******************************************************************************/ >+// >+//package org.eclipse.ant.internal.ui.launchConfigurations; >+// >+//import java.util.ArrayList; >+//import java.util.List; >+// >+//import org.eclipse.ant.internal.launching.launchConfigurations.AntHomeClasspathEntry; >+//import org.eclipse.core.runtime.CoreException; >+//import org.eclipse.debug.core.ILaunchConfiguration; >+//import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+//import org.eclipse.jdt.launching.IRuntimeClasspathEntry; >+//import org.eclipse.jdt.launching.JavaRuntime; >+//import org.eclipse.jdt.launching.StandardClasspathProvider; >+// >+//public class AntClasspathProvider extends StandardClasspathProvider { >+// >+// /* (non-Javadoc) >+// * @see org.eclipse.jdt.launching.IRuntimeClasspathProvider#computeUnresolvedClasspath(org.eclipse.debug.core.ILaunchConfiguration) >+// */ >+// public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException { >+// boolean useDefault = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true); >+// if (useDefault) { >+// List rtes = new ArrayList(10); >+// IRuntimeClasspathEntry jreEntry = null; >+// try { >+// jreEntry = JavaRuntime.computeJREEntry(configuration); >+// } catch (CoreException e) { >+// // not a java project >+// } >+// if (jreEntry == null) { >+// jreEntry = JavaRuntime.newRuntimeContainerClasspathEntry( >+// JavaRuntime.newDefaultJREContainerPath(), IRuntimeClasspathEntry.STANDARD_CLASSES); >+// } >+// rtes.add(jreEntry); >+// rtes.add(new AntHomeClasspathEntry()); >+// rtes.add(new ContributedClasspathEntriesEntry()); >+// return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]); >+// } >+// return super.computeUnresolvedClasspath(configuration); >+// } >+//} >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/ContributedClasspathEntriesEntry.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/ContributedClasspathEntriesEntry.java,v >retrieving revision 1.20 >diff -u -r1.20 ContributedClasspathEntriesEntry.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/ContributedClasspathEntriesEntry.java 15 Feb 2006 17:41:23 -0000 1.20 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/ContributedClasspathEntriesEntry.java 25 Sep 2009 16:23:40 -0000 >@@ -1,246 +1,246 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.ant.internal.ui.launchConfigurations; >- >-import java.io.File; >-import java.io.FilenameFilter; >-import java.io.IOException; >-import java.net.MalformedURLException; >-import java.net.URL; >-import java.util.ArrayList; >-import java.util.List; >- >-import org.eclipse.ant.core.AntCorePlugin; >-import org.eclipse.ant.core.AntCorePreferences; >-import org.eclipse.ant.core.IAntClasspathEntry; >-import org.eclipse.ant.internal.ui.AntUIPlugin; >-import org.eclipse.ant.internal.ui.AntUtil; >-import org.eclipse.ant.internal.ui.IAntUIConstants; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.FileLocator; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.debug.core.ILaunchConfiguration; >-import org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry; >-import org.eclipse.jdt.launching.IRuntimeClasspathEntry; >-import org.eclipse.jdt.launching.IVMInstall; >-import org.eclipse.jdt.launching.JavaRuntime; >-import org.eclipse.osgi.service.resolver.BundleDescription; >-import org.osgi.framework.Bundle; >-import org.w3c.dom.Document; >-import org.w3c.dom.Element; >- >-/** >- * A classpath entry that contains a contributed classpath entries >- * via the <code>extraClasspathEntries</code> extension point. >- * >- * @since 3.0 >- */ >-public class ContributedClasspathEntriesEntry extends AbstractRuntimeClasspathEntry { >- >- public static final String TYPE_ID = "org.eclipse.ant.ui.classpathentry.extraClasspathEntries"; //$NON-NLS-1$ >- >- public static List fgSWTEntries= null; >- >- /** >- * Default contructor required to instantiate persisted extensions. >- */ >- public ContributedClasspathEntriesEntry() { >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element) >- */ >- protected void buildMemento(Document document, Element memento) throws CoreException { >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jdt.internal.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element) >- */ >- public void initializeFrom(Element memento) throws CoreException { >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId() >- */ >- public String getTypeId() { >- return TYPE_ID; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration) >- */ >- public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException { >- boolean separateVM= AntUtil.isSeparateJREAntBuild(configuration); >- boolean setInputHandler= configuration.getAttribute(IAntUIConstants.SET_INPUTHANDLER, true); >- AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences(); >- IAntClasspathEntry[] antClasspathEntries = prefs.getContributedClasspathEntries(); >- IAntClasspathEntry[] userEntries = prefs.getAdditionalClasspathEntries(); >- List rtes = new ArrayList(antClasspathEntries.length + userEntries.length); >- IAntClasspathEntry entry; >- for (int i = 0; i < antClasspathEntries.length; i++) { >- entry= antClasspathEntries[i]; >- if (!separateVM || (separateVM && !entry.isEclipseRuntimeRequired())) { >- rtes.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel())); >- } >- } >- boolean haveToolsEntry= false; >- String path; >- for (int i = 0; i < userEntries.length; i++) { >- entry = userEntries[i]; >- path= entry.getLabel(); >- IPath toolsPath= new Path(path); >- if (toolsPath.lastSegment().equals("tools.jar")) { //$NON-NLS-1$ >- haveToolsEntry= true; >- // replace with dynamically resolved tools.jar based on >- // the JRE being used >- addToolsJar(configuration, rtes, path); >- } else { >- rtes.add(JavaRuntime.newStringVariableClasspathEntry(path)); >- } >- } >- if (!haveToolsEntry) { >- addToolsJar(configuration, rtes, null); >- } >- >- if (setInputHandler && separateVM) { >- addSWTJars(rtes); >- } >- >- return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]); >- } >- >- private void addToolsJar(ILaunchConfiguration configuration, List rtes, String path) { >- IRuntimeClasspathEntry tools = getToolsJar(configuration); >- if (tools == null) { >- if (path != null) { >- //use the global entry >- rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(path))); >- } else { >- //use the default vm install to try to find a tools.jar >- IVMInstall install= JavaRuntime.getDefaultVMInstall(); >- if (install != null) { >- IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath())); >- if (entry != null) { >- rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath()))); >- } >- } >- } >- } else { >- rtes.add(tools); >- } >- } >- >- private void addSWTJars(List rtes) { >- if (fgSWTEntries == null) { >- fgSWTEntries= new ArrayList(); >- Bundle bundle= Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$ >- BundleDescription description= Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId()); >- BundleDescription[] fragments= description.getFragments(); >- for (int i = 0; i < fragments.length; i++) { >- Bundle fragmentBundle= Platform.getBundle(fragments[i].getName()); >- URL bundleURL; >- try { >- bundleURL = FileLocator.resolve(fragmentBundle.getEntry("/")); //$NON-NLS-1$ >- } catch (IOException e) { >- AntUIPlugin.log(e); >- continue; >- } >- String urlFileName= bundleURL.getFile(); >- if (urlFileName.startsWith("file:")) { //$NON-NLS-1$ >- try { >- urlFileName= new URL(urlFileName).getFile(); >- if (urlFileName.endsWith("!/")) { //$NON-NLS-1$ >- urlFileName= urlFileName.substring(0, urlFileName.length() - 2); >- } >- } catch (MalformedURLException e) { >- AntUIPlugin.log(e); >- continue; >- } >- } >- IPath fragmentPath= new Path(urlFileName); >- if (fragmentPath.getFileExtension() != null) { //JAR file >- fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath)); >- } else { // folder >- File bundleFolder= fragmentPath.toFile(); >- if (!bundleFolder.isDirectory()) { >- continue; >- } >- String[] names= bundleFolder.list(new FilenameFilter() { >- public boolean accept(File dir, String name) { >- return name.endsWith(".jar"); //$NON-NLS-1$ >- } >- }); >- for (int j = 0; j < names.length; j++) { >- String jarName = names[j]; >- fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath.append(jarName))); >- } >- } >- } >- } >- rtes.addAll(fgSWTEntries); >- } >- >- /** >- * Returns the tools.jar to use for this launch configuration, or <code>null</code> >- * if none. >- * >- * @param configuration configuration to resolve a tools.jar for >- * @return associated tools.jar archive, or <code>null</code> >- */ >- private IRuntimeClasspathEntry getToolsJar(ILaunchConfiguration configuration) { >- try { >- IVMInstall install = JavaRuntime.computeVMInstall(configuration); >- if (install != null) { >- IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath())); >- if (entry != null) { >- return JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath())); >- } >- } >- } catch (CoreException ce) { >- //likely dealing with a non-Java project >- } >- >- return null; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName() >- */ >- public String getName() { >- return AntLaunchConfigurationMessages.ContributedClasspathEntriesEntry_1; >- } >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType() >- */ >- public int getType() { >- return IRuntimeClasspathEntry.OTHER; >- } >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#isComposite() >- */ >- public boolean isComposite() { >- return true; >- } >- /* (non-Javadoc) >- * @see java.lang.Object#equals(java.lang.Object) >- */ >- public boolean equals(Object obj) { >- return obj instanceof ContributedClasspathEntriesEntry; >- } >- /* (non-Javadoc) >- * @see java.lang.Object#hashCode() >- */ >- public int hashCode() { >- return getClass().hashCode(); >- } >-} >+///******************************************************************************* >+// * Copyright (c) 2000, 2006 IBM Corporation and others. >+// * All rights reserved. This program and the accompanying materials >+// * are made available under the terms of the Eclipse Public License v1.0 >+// * which accompanies this distribution, and is available at >+// * http://www.eclipse.org/legal/epl-v10.html >+// * >+// * Contributors: >+// * IBM Corporation - initial API and implementation >+// *******************************************************************************/ >+//package org.eclipse.ant.internal.ui.launchConfigurations; >+// >+//import java.io.File; >+//import java.io.FilenameFilter; >+//import java.io.IOException; >+//import java.net.MalformedURLException; >+//import java.net.URL; >+//import java.util.ArrayList; >+//import java.util.List; >+// >+//import org.eclipse.ant.core.AntCorePlugin; >+//import org.eclipse.ant.core.AntCorePreferences; >+//import org.eclipse.ant.core.IAntClasspathEntry; >+//import org.eclipse.ant.internal.launching.AntLaunchingUtil; >+//import org.eclipse.ant.internal.ui.AntUIPlugin; >+//import org.eclipse.ant.internal.ui.IAntUIConstants; >+//import org.eclipse.core.runtime.CoreException; >+//import org.eclipse.core.runtime.FileLocator; >+//import org.eclipse.core.runtime.IPath; >+//import org.eclipse.core.runtime.Path; >+//import org.eclipse.core.runtime.Platform; >+//import org.eclipse.debug.core.ILaunchConfiguration; >+//import org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry; >+//import org.eclipse.jdt.launching.IRuntimeClasspathEntry; >+//import org.eclipse.jdt.launching.IVMInstall; >+//import org.eclipse.jdt.launching.JavaRuntime; >+//import org.eclipse.osgi.service.resolver.BundleDescription; >+//import org.osgi.framework.Bundle; >+//import org.w3c.dom.Document; >+//import org.w3c.dom.Element; >+// >+///** >+// * A classpath entry that contains a contributed classpath entries >+// * via the <code>extraClasspathEntries</code> extension point. >+// * >+// * @since 3.0 >+// */ >+//public class ContributedClasspathEntriesEntry extends AbstractRuntimeClasspathEntry { >+// >+// public static final String TYPE_ID = "org.eclipse.ant.ui.classpathentry.extraClasspathEntries"; //$NON-NLS-1$ >+// >+// public static List fgSWTEntries= null; >+// >+// /** >+// * Default contructor required to instantiate persisted extensions. >+// */ >+// public ContributedClasspathEntriesEntry() { >+// } >+// >+// /* (non-Javadoc) >+// * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element) >+// */ >+// protected void buildMemento(Document document, Element memento) throws CoreException { >+// } >+// >+// /* (non-Javadoc) >+// * @see org.eclipse.jdt.internal.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element) >+// */ >+// public void initializeFrom(Element memento) throws CoreException { >+// } >+// >+// /* (non-Javadoc) >+// * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId() >+// */ >+// public String getTypeId() { >+// return TYPE_ID; >+// } >+// >+// /* (non-Javadoc) >+// * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration) >+// */ >+// public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException { >+// boolean separateVM= AntLaunchingUtil.isSeparateJREAntBuild(configuration); >+// boolean setInputHandler= configuration.getAttribute(IAntUIConstants.SET_INPUTHANDLER, true); >+// AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences(); >+// IAntClasspathEntry[] antClasspathEntries = prefs.getContributedClasspathEntries(); >+// IAntClasspathEntry[] userEntries = prefs.getAdditionalClasspathEntries(); >+// List rtes = new ArrayList(antClasspathEntries.length + userEntries.length); >+// IAntClasspathEntry entry; >+// for (int i = 0; i < antClasspathEntries.length; i++) { >+// entry= antClasspathEntries[i]; >+// if (!separateVM || (separateVM && !entry.isEclipseRuntimeRequired())) { >+// rtes.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel())); >+// } >+// } >+// boolean haveToolsEntry= false; >+// String path; >+// for (int i = 0; i < userEntries.length; i++) { >+// entry = userEntries[i]; >+// path= entry.getLabel(); >+// IPath toolsPath= new Path(path); >+// if (toolsPath.lastSegment().equals("tools.jar")) { //$NON-NLS-1$ >+// haveToolsEntry= true; >+// // replace with dynamically resolved tools.jar based on >+// // the JRE being used >+// addToolsJar(configuration, rtes, path); >+// } else { >+// rtes.add(JavaRuntime.newStringVariableClasspathEntry(path)); >+// } >+// } >+// if (!haveToolsEntry) { >+// addToolsJar(configuration, rtes, null); >+// } >+// >+// if (setInputHandler && separateVM) { >+// addSWTJars(rtes); >+// } >+// >+// return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]); >+// } >+// >+// private void addToolsJar(ILaunchConfiguration configuration, List rtes, String path) { >+// IRuntimeClasspathEntry tools = getToolsJar(configuration); >+// if (tools == null) { >+// if (path != null) { >+// //use the global entry >+// rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(path))); >+// } else { >+// //use the default vm install to try to find a tools.jar >+// IVMInstall install= JavaRuntime.getDefaultVMInstall(); >+// if (install != null) { >+// IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath())); >+// if (entry != null) { >+// rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath()))); >+// } >+// } >+// } >+// } else { >+// rtes.add(tools); >+// } >+// } >+// >+// private void addSWTJars(List rtes) { >+// if (fgSWTEntries == null) { >+// fgSWTEntries= new ArrayList(); >+// Bundle bundle= Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$ >+// BundleDescription description= Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId()); >+// BundleDescription[] fragments= description.getFragments(); >+// for (int i = 0; i < fragments.length; i++) { >+// Bundle fragmentBundle= Platform.getBundle(fragments[i].getName()); >+// URL bundleURL; >+// try { >+// bundleURL = FileLocator.resolve(fragmentBundle.getEntry("/")); //$NON-NLS-1$ >+// } catch (IOException e) { >+// AntUIPlugin.log(e); >+// continue; >+// } >+// String urlFileName= bundleURL.getFile(); >+// if (urlFileName.startsWith("file:")) { //$NON-NLS-1$ >+// try { >+// urlFileName= new URL(urlFileName).getFile(); >+// if (urlFileName.endsWith("!/")) { //$NON-NLS-1$ >+// urlFileName= urlFileName.substring(0, urlFileName.length() - 2); >+// } >+// } catch (MalformedURLException e) { >+// AntUIPlugin.log(e); >+// continue; >+// } >+// } >+// IPath fragmentPath= new Path(urlFileName); >+// if (fragmentPath.getFileExtension() != null) { //JAR file >+// fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath)); >+// } else { // folder >+// File bundleFolder= fragmentPath.toFile(); >+// if (!bundleFolder.isDirectory()) { >+// continue; >+// } >+// String[] names= bundleFolder.list(new FilenameFilter() { >+// public boolean accept(File dir, String name) { >+// return name.endsWith(".jar"); //$NON-NLS-1$ >+// } >+// }); >+// for (int j = 0; j < names.length; j++) { >+// String jarName = names[j]; >+// fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath.append(jarName))); >+// } >+// } >+// } >+// } >+// rtes.addAll(fgSWTEntries); >+// } >+// >+// /** >+// * Returns the tools.jar to use for this launch configuration, or <code>null</code> >+// * if none. >+// * >+// * @param configuration configuration to resolve a tools.jar for >+// * @return associated tools.jar archive, or <code>null</code> >+// */ >+// private IRuntimeClasspathEntry getToolsJar(ILaunchConfiguration configuration) { >+// try { >+// IVMInstall install = JavaRuntime.computeVMInstall(configuration); >+// if (install != null) { >+// IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath())); >+// if (entry != null) { >+// return JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath())); >+// } >+// } >+// } catch (CoreException ce) { >+// //likely dealing with a non-Java project >+// } >+// >+// return null; >+// } >+// >+// /* (non-Javadoc) >+// * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName() >+// */ >+// public String getName() { >+// return AntLaunchConfigurationMessages.ContributedClasspathEntriesEntry_1; >+// } >+// /* (non-Javadoc) >+// * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType() >+// */ >+// public int getType() { >+// return IRuntimeClasspathEntry.OTHER; >+// } >+// /* (non-Javadoc) >+// * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#isComposite() >+// */ >+// public boolean isComposite() { >+// return true; >+// } >+// /* (non-Javadoc) >+// * @see java.lang.Object#equals(java.lang.Object) >+// */ >+// public boolean equals(Object obj) { >+// return obj instanceof ContributedClasspathEntriesEntry; >+// } >+// /* (non-Javadoc) >+// * @see java.lang.Object#hashCode() >+// */ >+// public int hashCode() { >+// return getClass().hashCode(); >+// } >+//} >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/EditAntHomeEntryAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/EditAntHomeEntryAction.java,v >retrieving revision 1.8 >diff -u -r1.8 EditAntHomeEntryAction.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/EditAntHomeEntryAction.java 11 Aug 2005 16:30:00 -0000 1.8 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/EditAntHomeEntryAction.java 25 Sep 2009 16:23:40 -0000 >@@ -12,6 +12,7 @@ > > import org.eclipse.ant.core.AntCorePlugin; > import org.eclipse.ant.core.AntCorePreferences; >+import org.eclipse.ant.internal.launching.launchConfigurations.AntHomeClasspathEntry; > import org.eclipse.ant.internal.ui.AntUIPlugin; > import org.eclipse.ant.internal.ui.IAntUIConstants; > import org.eclipse.ant.internal.ui.preferences.AntPreferencesMessages; >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntWorkingDirectoryBlock.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntWorkingDirectoryBlock.java,v >retrieving revision 1.19 >diff -u -r1.19 AntWorkingDirectoryBlock.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntWorkingDirectoryBlock.java 28 Jan 2008 15:54:05 -0000 1.19 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntWorkingDirectoryBlock.java 25 Sep 2009 16:23:40 -0000 >@@ -16,7 +16,7 @@ > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.jdt.internal.debug.ui.launcher.JavaWorkingDirectoryBlock; > import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >-import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; >+import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil; > > import com.ibm.icu.text.MessageFormat; > >@@ -51,7 +51,7 @@ > setLaunchConfiguration(configuration); > try { > try { >- fDefaultWorkingDirPath= ExternalToolsUtil.getLocation(configuration).removeLastSegments(1).toOSString(); >+ fDefaultWorkingDirPath= ExternalToolsCoreUtil.getLocation(configuration).removeLastSegments(1).toOSString(); > } > catch(CoreException ce){} > String wd = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null); >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntHomeClasspathEntry.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntHomeClasspathEntry.java,v >retrieving revision 1.11 >diff -u -r1.11 AntHomeClasspathEntry.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntHomeClasspathEntry.java 11 Apr 2006 14:45:04 -0000 1.11 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntHomeClasspathEntry.java 25 Sep 2009 16:23:37 -0000 >@@ -1,209 +1,209 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.ant.internal.ui.launchConfigurations; >- >-import java.io.File; >-import com.ibm.icu.text.MessageFormat; >-import java.util.ArrayList; >-import java.util.List; >- >-import org.eclipse.ant.core.AntCorePlugin; >-import org.eclipse.ant.core.AntCorePreferences; >-import org.eclipse.ant.core.IAntClasspathEntry; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.debug.core.ILaunchConfiguration; >-import org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry; >-import org.eclipse.jdt.launching.IRuntimeClasspathEntry; >-import org.eclipse.jdt.launching.JavaRuntime; >-import org.w3c.dom.Document; >-import org.w3c.dom.Element; >- >-/** >- * A classpath entry that contains a set of archives for a particular >- * ANT_HOME. >- * >- * @since 3.0 >- */ >-public class AntHomeClasspathEntry extends AbstractRuntimeClasspathEntry { >- >- public static final String TYPE_ID = "org.eclipse.ant.ui.classpathentry.antHome"; //$NON-NLS-1$ >- >- /** >- * Local path on disk where Ant Home is located or <code>null</code> >- * to indicate the use of the default Ant Home. >- */ >- private String antHomeLocation = null; >- >- /** >- * Creates an AntHome entry for the default AntHome installation. >- */ >- public AntHomeClasspathEntry() { >- antHomeLocation = null; >- } >- >- /** >- * Constructs an AntHome entry for the Ant installed at the specified >- * root directory. >- * >- * @param antHome path in the local file system to an Ant installation >- */ >- public AntHomeClasspathEntry(String antHome) { >- antHomeLocation = antHome; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element) >- */ >- protected void buildMemento(Document document, Element memento) throws CoreException { >- if (antHomeLocation == null) { >- memento.setAttribute("default", "true"); //$NON-NLS-1$//$NON-NLS-2$ >- } else { >- memento.setAttribute("antHome", new Path(antHomeLocation).toString()); //$NON-NLS-1$ >- } >- } >- /* (non-Javadoc) >- * @see org.eclipse.jdt.internal.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element) >- */ >- public void initializeFrom(Element memento) throws CoreException { >- String antHome = memento.getAttribute("antHome"); //$NON-NLS-1$ >- if (antHome != null && (antHome.length() > 0)) { >- IPath path = new Path(antHome); >- antHomeLocation = path.toOSString(); >- } else { >- antHomeLocation = null; >- } >- } >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId() >- */ >- public String getTypeId() { >- return TYPE_ID; >- } >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration) >- */ >- public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException { >- List libs = new ArrayList(40); >- AntCorePreferences preferences = AntCorePlugin.getPlugin().getPreferences(); >- if (antHomeLocation == null) { >- IAntClasspathEntry[] entries = preferences.getAntHomeClasspathEntries(); >- for (int i = 0; i < entries.length; i++) { >- IAntClasspathEntry entry = entries[i]; >- libs.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel())); >- } >- } else { >- File lib= resolveAntHome(); >- IPath libDir = new Path(antHomeLocation).append("lib"); //$NON-NLS-1$ >- String[] fileNames = lib.list(); >- for (int i = 0; i < fileNames.length; i++) { >- String name = fileNames[i]; >- IPath path = new Path(name); >- String fileExtension = path.getFileExtension(); >- if ("jar".equalsIgnoreCase(fileExtension)) { //$NON-NLS-1$ >- libs.add(JavaRuntime.newArchiveRuntimeClasspathEntry(libDir.append(path))); >- } >- } >- } >- return (IRuntimeClasspathEntry[]) libs.toArray(new IRuntimeClasspathEntry[libs.size()]); >- } >- >- public File resolveAntHome() throws CoreException { >- if (antHomeLocation == null) { //using the default ant home >- return null; >- } >- IPath libDir= new Path(antHomeLocation).append("lib"); //$NON-NLS-1$ >- File lib= libDir.toFile(); >- File parentDir= lib.getParentFile(); >- if (parentDir == null || !parentDir.exists()) { >- abort(MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_10, new String[] {antHomeLocation}), null); >- } >- if (!lib.exists() || !lib.isDirectory()) { >- abort(MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_11, new String[] {antHomeLocation}), null); >- } >- return lib; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName() >- */ >- public String getName() { >- if (antHomeLocation == null) { >- return AntLaunchConfigurationMessages.AntHomeClasspathEntry_8; >- } >- return MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_9, new String[]{antHomeLocation}); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType() >- */ >- public int getType() { >- return IRuntimeClasspathEntry.OTHER; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#isComposite() >- */ >- public boolean isComposite() { >- return true; >- } >- >- /* (non-Javadoc) >- * @see java.lang.Object#equals(java.lang.Object) >- */ >- public boolean equals(Object obj) { >- return obj instanceof AntHomeClasspathEntry && >- equalsOrNull(antHomeLocation, ((AntHomeClasspathEntry)obj).antHomeLocation); >- } >- >- /** >- * Return whether s1 is equivalent to s2. >- * >- * @param s1 >- * @param s2 >- * @return whether s1 is equivalent to s2 >- */ >- private boolean equalsOrNull(String s1, String s2) { >- if (s1 == null || s2 == null) { >- return s1 == s2; >- } >- return s1.equalsIgnoreCase(s2); >- } >- >- /* (non-Javadoc) >- * @see java.lang.Object#hashCode() >- */ >- public int hashCode() { >- return getClass().hashCode(); >- } >- >- /** >- * Sets the ant home to use. >- * >- * @param path path to toor of an ant home installation >- */ >- protected void setAntHome(String path) { >- antHomeLocation = path; >- } >- >- /** >- * Returns the ant home location >- * >- * @return path to root ant installation directory >- */ >- public String getAntHome() { >- if (antHomeLocation == null) { >- return AntCorePlugin.getPlugin().getPreferences().getAntHome(); >- } >- return antHomeLocation; >- } >-} >+///******************************************************************************* >+// * Copyright (c) 2000, 2006 IBM Corporation and others. >+// * All rights reserved. This program and the accompanying materials >+// * are made available under the terms of the Eclipse Public License v1.0 >+// * which accompanies this distribution, and is available at >+// * http://www.eclipse.org/legal/epl-v10.html >+// * >+// * Contributors: >+// * IBM Corporation - initial API and implementation >+// *******************************************************************************/ >+//package org.eclipse.ant.internal.ui.launchConfigurations; >+// >+//import java.io.File; >+//import com.ibm.icu.text.MessageFormat; >+//import java.util.ArrayList; >+//import java.util.List; >+// >+//import org.eclipse.ant.core.AntCorePlugin; >+//import org.eclipse.ant.core.AntCorePreferences; >+//import org.eclipse.ant.core.IAntClasspathEntry; >+//import org.eclipse.core.runtime.CoreException; >+//import org.eclipse.core.runtime.IPath; >+//import org.eclipse.core.runtime.Path; >+//import org.eclipse.debug.core.ILaunchConfiguration; >+//import org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry; >+//import org.eclipse.jdt.launching.IRuntimeClasspathEntry; >+//import org.eclipse.jdt.launching.JavaRuntime; >+//import org.w3c.dom.Document; >+//import org.w3c.dom.Element; >+// >+///** >+// * A classpath entry that contains a set of archives for a particular >+// * ANT_HOME. >+// * >+// * @since 3.0 >+// */ >+//public class AntHomeClasspathEntry extends AbstractRuntimeClasspathEntry { >+// >+// public static final String TYPE_ID = "org.eclipse.ant.ui.classpathentry.antHome"; //$NON-NLS-1$ >+// >+// /** >+// * Local path on disk where Ant Home is located or <code>null</code> >+// * to indicate the use of the default Ant Home. >+// */ >+// private String antHomeLocation = null; >+// >+// /** >+// * Creates an AntHome entry for the default AntHome installation. >+// */ >+// public AntHomeClasspathEntry() { >+// antHomeLocation = null; >+// } >+// >+// /** >+// * Constructs an AntHome entry for the Ant installed at the specified >+// * root directory. >+// * >+// * @param antHome path in the local file system to an Ant installation >+// */ >+// public AntHomeClasspathEntry(String antHome) { >+// antHomeLocation = antHome; >+// } >+// >+// /* (non-Javadoc) >+// * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element) >+// */ >+// protected void buildMemento(Document document, Element memento) throws CoreException { >+// if (antHomeLocation == null) { >+// memento.setAttribute("default", "true"); //$NON-NLS-1$//$NON-NLS-2$ >+// } else { >+// memento.setAttribute("antHome", new Path(antHomeLocation).toString()); //$NON-NLS-1$ >+// } >+// } >+// /* (non-Javadoc) >+// * @see org.eclipse.jdt.internal.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element) >+// */ >+// public void initializeFrom(Element memento) throws CoreException { >+// String antHome = memento.getAttribute("antHome"); //$NON-NLS-1$ >+// if (antHome != null && (antHome.length() > 0)) { >+// IPath path = new Path(antHome); >+// antHomeLocation = path.toOSString(); >+// } else { >+// antHomeLocation = null; >+// } >+// } >+// /* (non-Javadoc) >+// * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId() >+// */ >+// public String getTypeId() { >+// return TYPE_ID; >+// } >+// /* (non-Javadoc) >+// * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration) >+// */ >+// public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException { >+// List libs = new ArrayList(40); >+// AntCorePreferences preferences = AntCorePlugin.getPlugin().getPreferences(); >+// if (antHomeLocation == null) { >+// IAntClasspathEntry[] entries = preferences.getAntHomeClasspathEntries(); >+// for (int i = 0; i < entries.length; i++) { >+// IAntClasspathEntry entry = entries[i]; >+// libs.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel())); >+// } >+// } else { >+// File lib= resolveAntHome(); >+// IPath libDir = new Path(antHomeLocation).append("lib"); //$NON-NLS-1$ >+// String[] fileNames = lib.list(); >+// for (int i = 0; i < fileNames.length; i++) { >+// String name = fileNames[i]; >+// IPath path = new Path(name); >+// String fileExtension = path.getFileExtension(); >+// if ("jar".equalsIgnoreCase(fileExtension)) { //$NON-NLS-1$ >+// libs.add(JavaRuntime.newArchiveRuntimeClasspathEntry(libDir.append(path))); >+// } >+// } >+// } >+// return (IRuntimeClasspathEntry[]) libs.toArray(new IRuntimeClasspathEntry[libs.size()]); >+// } >+// >+// public File resolveAntHome() throws CoreException { >+// if (antHomeLocation == null) { //using the default ant home >+// return null; >+// } >+// IPath libDir= new Path(antHomeLocation).append("lib"); //$NON-NLS-1$ >+// File lib= libDir.toFile(); >+// File parentDir= lib.getParentFile(); >+// if (parentDir == null || !parentDir.exists()) { >+// abort(MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_10, new String[] {antHomeLocation}), null); >+// } >+// if (!lib.exists() || !lib.isDirectory()) { >+// abort(MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_11, new String[] {antHomeLocation}), null); >+// } >+// return lib; >+// } >+// >+// /* (non-Javadoc) >+// * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName() >+// */ >+// public String getName() { >+// if (antHomeLocation == null) { >+// return AntLaunchConfigurationMessages.AntHomeClasspathEntry_8; >+// } >+// return MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_9, new String[]{antHomeLocation}); >+// } >+// >+// /* (non-Javadoc) >+// * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType() >+// */ >+// public int getType() { >+// return IRuntimeClasspathEntry.OTHER; >+// } >+// >+// /* (non-Javadoc) >+// * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#isComposite() >+// */ >+// public boolean isComposite() { >+// return true; >+// } >+// >+// /* (non-Javadoc) >+// * @see java.lang.Object#equals(java.lang.Object) >+// */ >+// public boolean equals(Object obj) { >+// return obj instanceof AntHomeClasspathEntry && >+// equalsOrNull(antHomeLocation, ((AntHomeClasspathEntry)obj).antHomeLocation); >+// } >+// >+// /** >+// * Return whether s1 is equivalent to s2. >+// * >+// * @param s1 >+// * @param s2 >+// * @return whether s1 is equivalent to s2 >+// */ >+// private boolean equalsOrNull(String s1, String s2) { >+// if (s1 == null || s2 == null) { >+// return s1 == s2; >+// } >+// return s1.equalsIgnoreCase(s2); >+// } >+// >+// /* (non-Javadoc) >+// * @see java.lang.Object#hashCode() >+// */ >+// public int hashCode() { >+// return getClass().hashCode(); >+// } >+// >+// /** >+// * Sets the ant home to use. >+// * >+// * @param path path to toor of an ant home installation >+// */ >+// protected void setAntHome(String path) { >+// antHomeLocation = path; >+// } >+// >+// /** >+// * Returns the ant home location >+// * >+// * @return path to root ant installation directory >+// */ >+// public String getAntHome() { >+// if (antHomeLocation == null) { >+// return AntCorePlugin.getPlugin().getPreferences().getAntHome(); >+// } >+// return antHomeLocation; >+// } >+//} >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntEnvironmentTab.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntEnvironmentTab.java,v >retrieving revision 1.7 >diff -u -r1.7 AntEnvironmentTab.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntEnvironmentTab.java 11 Aug 2005 16:30:00 -0000 1.7 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntEnvironmentTab.java 25 Sep 2009 16:23:36 -0000 >@@ -10,7 +10,7 @@ > *******************************************************************************/ > package org.eclipse.ant.internal.ui.launchConfigurations; > >-import org.eclipse.ant.internal.ui.AntUtil; >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; > import org.eclipse.debug.ui.EnvironmentTab; > import org.eclipse.jface.dialogs.Dialog; >@@ -60,7 +60,7 @@ > if (wrappingComposite == null) { > return; > } >- boolean isSeparateJREBuild= AntUtil.isSeparateJREAntBuild(workingCopy); >+ boolean isSeparateJREBuild= AntLaunchingUtil.isSeparateJREAntBuild(workingCopy); > > Color tableColor= isSeparateJREBuild ? null : Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); > Color labelColor= isSeparateJREBuild ? null : Display.getDefault().getSystemColor(SWT.COLOR_RED); >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/RemoteAntBuildListener.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/RemoteAntBuildListener.java,v >retrieving revision 1.32 >diff -u -r1.32 RemoteAntBuildListener.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/RemoteAntBuildListener.java 4 May 2009 16:10:59 -0000 1.32 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/RemoteAntBuildListener.java 25 Sep 2009 16:23:40 -0000 >@@ -29,11 +29,12 @@ > import org.apache.tools.ant.Project; > import org.apache.tools.ant.util.FileUtils; > import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger; >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; >+import org.eclipse.ant.internal.launching.IAntLaunchingPreferenceConstants; > import org.eclipse.ant.internal.ui.AntUIPlugin; > import org.eclipse.ant.internal.ui.AntUtil; > import org.eclipse.ant.internal.ui.ExternalHyperlink; > import org.eclipse.ant.internal.ui.IAntUIConstants; >-import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.ISafeRunnable; > import org.eclipse.debug.core.DebugPlugin; >@@ -42,7 +43,6 @@ > import org.eclipse.debug.core.model.IProcess; > import org.eclipse.debug.ui.console.FileLink; > import org.eclipse.jface.preference.IPreferenceStore; >-import org.eclipse.jface.text.Region; > import org.eclipse.ui.console.IHyperlink; > > /** >@@ -90,7 +90,7 @@ > try { > fServerSocket= new ServerSocket(fServerPort); > IPreferenceStore prefs = AntUIPlugin.getDefault().getPreferenceStore(); >- int socketTimeout= prefs.getInt(IAntUIPreferenceConstants.ANT_COMMUNICATION_TIMEOUT); >+ int socketTimeout= prefs.getInt(IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT); > fServerSocket.setSoTimeout(socketTimeout); > fSocket= fServerSocket.accept(); > fBufferedReader= new BufferedReader(new InputStreamReader(fSocket.getInputStream(), "UTF-8")); //$NON-NLS-1$ >@@ -179,7 +179,7 @@ > if (message.startsWith("Total time:")) { //$NON-NLS-1$ > fBuildFailed= false; > } else { >- AntUtil.linkBuildFailedMessage(message, getProcess()); >+ AntLaunchingUtil.linkBuildFailedMessage(message, getProcess()); > } > } > } >@@ -262,7 +262,7 @@ > } else { > IFile file= (IFile) fFileNameToIFile.get(fileName); > if (file == null) { >- file= AntUtil.getFileForLocation(fileName, fBuildFileParent); >+ file= AntLaunchingUtil.getFileForLocation(fileName, fBuildFileParent); > if (file != null) { > fFileNameToIFile.put(fileName, file); > taskLink= new FileLink(file, null, -1, -1, lineNumber); >@@ -277,7 +277,7 @@ > } > } > if (taskLink != null) { >- TaskLinkManager.addTaskHyperlink(getProcess(), taskLink, new Region(offset, length), line); >+ //TaskLinkManager.addTaskHyperlink(getProcess(), taskLink, new Region(offset, length), line); > } > } > >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchShortcut.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchShortcut.java,v >retrieving revision 1.43 >diff -u -r1.43 AntLaunchShortcut.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchShortcut.java 20 Jan 2009 17:07:07 -0000 1.43 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchShortcut.java 25 Sep 2009 16:23:39 -0000 >@@ -14,8 +14,8 @@ > import java.util.ArrayList; > import java.util.List; > >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.ant.internal.ui.AntUIPlugin; >-import org.eclipse.ant.internal.ui.AntUtil; > import org.eclipse.ant.internal.ui.IAntUIConstants; > import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants; > import org.eclipse.ant.internal.ui.model.AntElementNode; >@@ -54,7 +54,7 @@ > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.dialogs.ElementListSelectionDialog; > import org.eclipse.ui.editors.text.ILocationProvider; >-import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; >+import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil; > import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants; > > import com.ibm.icu.text.MessageFormat; >@@ -175,7 +175,7 @@ > for(int i = 0; i < configs.length; i++) { > if(configs[i].exists()) { > try { >- location = ExternalToolsUtil.getLocation(configs[i]); >+ location = ExternalToolsCoreUtil.getLocation(configs[i]); > if(location != null && location.equals(filepath)) { > list.add(configs[i]); > } >@@ -343,7 +343,7 @@ > //the user has not specified any names to look for > return null; > } >- return AntUtil.parseString(buildFileNames, ","); //$NON-NLS-1$ >+ return AntLaunchingUtil.parseString(buildFileNames, ","); //$NON-NLS-1$ > } > > /** >@@ -393,7 +393,7 @@ > jreTab.setDefaults(workingCopy); > jreTab.dispose(); > >- IFile file= AntUtil.getFileForLocation(filePath.toString(), null); >+ IFile file= AntLaunchingUtil.getFileForLocation(filePath.toString(), null); > workingCopy.setMappedResources(new IResource[] {file}); > > return workingCopy.doSave(); >@@ -421,7 +421,7 @@ > ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type); > for (int i = 0; i < configs.length; i++) { > try { >- if (filePath.equals(ExternalToolsUtil.getLocation(configs[i]))) { >+ if (filePath.equals(ExternalToolsCoreUtil.getLocation(configs[i]))) { > validConfigs.add(configs[i]); > } > } >Index: Ant Tools Support/org/eclipse/ant/internal/ui/IAntUIPreferenceConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/IAntUIPreferenceConstants.java,v >retrieving revision 1.6 >diff -u -r1.6 IAntUIPreferenceConstants.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/IAntUIPreferenceConstants.java 28 Mar 2006 00:43:40 -0000 1.6 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/IAntUIPreferenceConstants.java 25 Sep 2009 16:23:35 -0000 >@@ -34,12 +34,6 @@ > public static final String CONSOLE_DEBUG_COLOR = "org.eclipse.ant.ui.debugColor"; //$NON-NLS-1$ > > public static final String ANT_TOOLS_JAR_WARNING= "toolsJAR"; //$NON-NLS-1$ >- >- /** >- * int preference identifier constant which specifies the length of time to wait >- * to connect with the socket that communicates with the separate JRE to capture the output >- */ >- public static final String ANT_COMMUNICATION_TIMEOUT= "timeout"; //$NON-NLS-1$ > > public static final String ANT_ERROR_DIALOG= "errorDialog"; //$NON-NLS-1$ > >Index: Ant Tools Support/org/eclipse/ant/internal/ui/AntUIPreferenceInitializer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUIPreferenceInitializer.java,v >retrieving revision 1.6 >diff -u -r1.6 AntUIPreferenceInitializer.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/AntUIPreferenceInitializer.java 19 Jan 2006 23:19:09 -0000 1.6 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/AntUIPreferenceInitializer.java 25 Sep 2009 16:23:35 -0000 >@@ -34,9 +34,7 @@ > prefs.setDefault(IAntUIPreferenceConstants.ANT_FIND_BUILD_FILE_NAMES, "build.xml"); //$NON-NLS-1$ > > prefs.setDefault(IAntUIPreferenceConstants.DOCUMENTATION_URL, "http://ant.apache.org/manual"); //$NON-NLS-1$ >- >- prefs.setDefault(IAntUIPreferenceConstants.ANT_COMMUNICATION_TIMEOUT, 20000); >- >+ > EditorsUI.useAnnotationsPreferencePage(prefs); > EditorsUI.useQuickDiffPreferencePage(prefs); > if (AntUIPlugin.isMacOS()) { >Index: Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java,v >retrieving revision 1.38 >diff -u -r1.38 AntUtil.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java 31 Aug 2009 17:56:26 -0000 1.38 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java 25 Sep 2009 16:23:35 -0000 >@@ -11,7 +11,6 @@ > package org.eclipse.ant.internal.ui; > > import java.io.File; >-import java.io.IOException; > import java.net.MalformedURLException; > import java.net.URL; > import java.util.ArrayList; >@@ -20,17 +19,13 @@ > import java.util.Iterator; > import java.util.List; > import java.util.Map; >-import java.util.StringTokenizer; > import java.util.regex.Pattern; > >-import org.apache.tools.ant.BuildException; > import org.apache.tools.ant.Target; >-import org.apache.tools.ant.util.FileUtils; > import org.eclipse.ant.core.AntCorePlugin; > import org.eclipse.ant.internal.core.AntCoreUtil; >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.ant.internal.ui.editor.AntEditor; >-import org.eclipse.ant.internal.ui.launchConfigurations.AntHomeClasspathEntry; >-import org.eclipse.ant.internal.ui.launchConfigurations.TaskLinkManager; > import org.eclipse.ant.internal.ui.model.AntElementNode; > import org.eclipse.ant.internal.ui.model.AntModel; > import org.eclipse.ant.internal.ui.model.AntProjectNode; >@@ -43,8 +38,6 @@ > import org.eclipse.core.filebuffers.ITextFileBufferManager; > import org.eclipse.core.filebuffers.LocationKind; > import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IWorkspaceRoot; >-import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.IStatus; >@@ -54,17 +47,10 @@ > import org.eclipse.core.variables.IStringVariableManager; > import org.eclipse.core.variables.VariablesPlugin; > import org.eclipse.debug.core.ILaunchConfiguration; >-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >-import org.eclipse.debug.core.model.IProcess; > import org.eclipse.debug.ui.console.FileLink; >-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >-import org.eclipse.jdt.launching.IRuntimeClasspathEntry; >-import org.eclipse.jdt.launching.IRuntimeClasspathEntry2; >-import org.eclipse.jdt.launching.JavaRuntime; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.text.BadLocationException; > import org.eclipse.jface.text.IDocument; >-import org.eclipse.jface.text.Region; > import org.eclipse.swt.SWT; > import org.eclipse.swt.program.Program; > import org.eclipse.swt.widgets.Shell; >@@ -78,8 +64,7 @@ > import org.eclipse.ui.browser.IWebBrowser; > import org.eclipse.ui.browser.IWorkbenchBrowserSupport; > import org.eclipse.ui.console.IHyperlink; >-import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; >-import org.eclipse.ui.externaltools.internal.model.ExternalToolBuilder; >+import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil; > import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants; > import org.eclipse.ui.ide.IDE; > import org.eclipse.ui.part.FileEditorInput; >@@ -93,300 +78,235 @@ > */ > public final class AntUtil { > public static final String ATTRIBUTE_SEPARATOR = ","; //$NON-NLS-1$; >- public static final char ANT_CLASSPATH_DELIMITER= '*'; >- public static final String ANT_HOME_CLASSPATH_PLACEHOLDER= "G"; //$NON-NLS-1$ >- public static final String ANT_GLOBAL_USER_CLASSPATH_PLACEHOLDER= "UG"; //$NON-NLS-1$ >- >+ public static final char ANT_CLASSPATH_DELIMITER = '*'; >+ public static final String ANT_HOME_CLASSPATH_PLACEHOLDER = "G"; //$NON-NLS-1$ >+ public static final String ANT_GLOBAL_USER_CLASSPATH_PLACEHOLDER = "UG"; //$NON-NLS-1$ >+ > private static String fgBrowserId; >- >+ > /** > * No instances allowed > */ > private AntUtil() { > super(); > } >- >- /** >- * Returns a single-string of the strings for storage. >- * >- * @param strings the array of strings >- * @return a single-string representation of the strings or >- * <code>null</code> if the array is empty. >- */ >- public static String combineStrings(String[] strings) { >- if (strings.length == 0) >- return null; >- >- if (strings.length == 1) >- return strings[0]; >- >- StringBuffer buf = new StringBuffer(); >- for (int i = 0; i < strings.length - 1; i++) { >- buf.append(strings[i]); >- buf.append(ATTRIBUTE_SEPARATOR); >- } >- buf.append(strings[strings.length - 1]); >- return buf.toString(); >- } >- >- /** >- * Returns an array of targets to be run, or <code>null</code> if none are >- * specified (indicating the default target or implicit target should be run). >- * >- * @param configuration launch configuration >- * @return array of target names, or <code>null</code> >- * @throws CoreException if unable to access the associated attribute >- */ >- public static String[] getTargetNames(ILaunchConfiguration configuration) throws CoreException { >- String attribute= null; >- if (IAntLaunchConfigurationConstants.ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE.equals(configuration.getType().getIdentifier())) { >- attribute= getTargetNamesForAntBuilder(configuration); >- } >- if (attribute == null) { >- attribute = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, (String) null); >- if (attribute == null) { >- return null; >- } >- } >- >- return AntUtil.parseRunTargets(attribute); >- } >- >- private static String getTargetNamesForAntBuilder(ILaunchConfiguration configuration) throws CoreException { >- String buildType= ExternalToolBuilder.getBuildType(); >- String targets= null; >- if (IExternalToolConstants.BUILD_TYPE_AUTO.equals(buildType)) { >- targets= configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_AUTO_TARGETS, (String)null); >- } else if (IExternalToolConstants.BUILD_TYPE_CLEAN.equals(buildType)) { >- targets = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_CLEAN_TARGETS, (String) null); >- } else if (IExternalToolConstants.BUILD_TYPE_FULL.equals(buildType)) { >- targets = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_AFTER_CLEAN_TARGETS, (String) null); >- } else if (IExternalToolConstants.BUILD_TYPE_INCREMENTAL.equals(buildType)) { >- targets = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_MANUAL_TARGETS, (String) null); >- } >- >- return targets; >- } >- >- /** >- * Returns a map of properties to be defined for the build, or >- * <code>null</code> if none are specified (indicating no additional >- * properties specified for the build). >- * >- * @param configuration launch configuration >- * @return map of properties (name --> value), or <code>null</code> >- * @throws CoreException if unable to access the associated attribute >- */ >- public static Map getProperties(ILaunchConfiguration configuration) throws CoreException { >- Map map = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTIES, (Map) null); >- return map; >- } >- >- /** >- * Returns a String specifying the Ant home to use for the build. >- * >- * @param configuration launch configuration >- * @return String specifying Ant home to use or <code>null</code> >- * @throws CoreException if unable to access the associated attribute >- */ >- public static String getAntHome(ILaunchConfiguration configuration) throws CoreException { >- IRuntimeClasspathEntry[] entries = JavaRuntime.computeUnresolvedRuntimeClasspath(configuration); >- for (int i = 0; i < entries.length; i++) { >- IRuntimeClasspathEntry entry = entries[i]; >- if (entry.getType() == IRuntimeClasspathEntry.OTHER) { >- IRuntimeClasspathEntry2 entry2 = (IRuntimeClasspathEntry2)entry; >- if (entry2.getTypeId().equals(AntHomeClasspathEntry.TYPE_ID)) { >- return ((AntHomeClasspathEntry)entry2).getAntHome(); >- } >- } >- } >- return null; >- } > > /** > * Returns an array of property files to be used for the build, or > * <code>null</code> if none are specified (indicating no additional > * property files specified for the build). >- * >- * @param configuration launch configuration >+ * >+ * @param configuration >+ * launch configuration > * @return array of property file names, or <code>null</code> >- * @throws CoreException if unable to access the associated attribute >+ * @throws CoreException >+ * if unable to access the associated attribute > */ >- public static String[] getPropertyFiles(ILaunchConfiguration configuration) throws CoreException { >- String attribute = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTY_FILES, (String) null); >+ public static String[] getPropertyFiles(ILaunchConfiguration configuration) >+ throws CoreException { >+ String attribute = configuration.getAttribute( >+ IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTY_FILES, >+ (String) null); > if (attribute == null) { > return null; > } >- String[] propertyFiles= AntUtil.parseString(attribute, ","); //$NON-NLS-1$ >+ String[] propertyFiles = AntLaunchingUtil.parseString(attribute, ","); //$NON-NLS-1$ > for (int i = 0; i < propertyFiles.length; i++) { > String propertyFile = propertyFiles[i]; >- propertyFile= expandVariableString(propertyFile, AntUIModelMessages.AntUtil_6); >- propertyFiles[i]= propertyFile; >+ propertyFile = expandVariableString(propertyFile, >+ AntUIModelMessages.AntUtil_6); >+ propertyFiles[i] = propertyFile; > } > return propertyFiles; > } >- >- public static AntTargetNode[] getTargets(String path, ILaunchConfiguration config) throws CoreException { >- File buildfile= getBuildFile(path); >+ >+ public static AntTargetNode[] getTargets(String path, >+ ILaunchConfiguration config) throws CoreException { >+ File buildfile = getBuildFile(path); > if (buildfile == null) { >- return null; >+ return null; > } >- URL[] urls= getCustomClasspath(config); >- //no lexical, no position, no task >- IAntModel model= getAntModel(buildfile, urls, false, false, false); >+ URL[] urls = AntLaunchingUtil.getCustomClasspath(config); >+ // no lexical, no position, no task >+ IAntModel model = getAntModel(buildfile, urls, false, false, false); > try { > model.setProperties(getAllProperties(config)); >- } catch (CoreException ex){ >+ } catch (CoreException ex) { > } > model.setPropertyFiles(getPropertyFiles(config)); >- AntProjectNode project= model.getProjectNode(); //forces a reconcile >+ AntProjectNode project = model.getProjectNode(); // forces a reconcile > model.dispose(); > return getTargets(project); > } >- >- private static Map getAllProperties(ILaunchConfiguration config) throws CoreException { >- String allArgs = config.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String) null); >- Map properties= new HashMap(); >+ >+ private static Map getAllProperties(ILaunchConfiguration config) >+ throws CoreException { >+ String allArgs = config.getAttribute( >+ IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String) null); >+ Map properties = new HashMap(); > if (allArgs != null) { >- String[] arguments = ExternalToolsUtil.parseStringIntoList(allArgs); >- // filter arguments to avoid resolving variables that will prompt the user >+ String[] arguments = ExternalToolsCoreUtil >+ .parseStringIntoList(allArgs); >+ // filter arguments to avoid resolving variables that will prompt >+ // the user > List filtered = new ArrayList(); > Pattern pattern = Pattern.compile("\\$\\{.*_prompt.*\\}"); //$NON-NLS-1$ >- IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); >+ IStringVariableManager manager = VariablesPlugin.getDefault() >+ .getStringVariableManager(); > for (int i = 0; i < arguments.length; i++) { > String arg = arguments[i]; > if (arg.startsWith("-D")) { //$NON-NLS-1$ > if (!pattern.matcher(arg).find()) { >- filtered.add(manager.performStringSubstitution(arg, false)); >+ filtered.add(manager.performStringSubstitution(arg, >+ false)); > } > } > } >- AntCoreUtil.processMinusDProperties(filtered, properties); >+ AntCoreUtil.processMinusDProperties(filtered, properties); > } >- Map configProperties= getProperties(config); >+ Map configProperties = AntLaunchingUtil.getProperties(config); > if (configProperties != null) { >- Iterator keys= configProperties.keySet().iterator(); >- while (keys.hasNext()) { >- String name = (String) keys.next(); >- if (properties.get(name) == null) { >- properties.put(name, configProperties.get(name)); >- } >- } >+ Iterator keys = configProperties.keySet().iterator(); >+ while (keys.hasNext()) { >+ String name = (String) keys.next(); >+ if (properties.get(name) == null) { >+ properties.put(name, configProperties.get(name)); >+ } >+ } > } > return properties; >- } >+ } > >- private static AntTargetNode[] getTargets(AntProjectNode project) { >- if (project == null || !project.hasChildren()) { >- return null; >+ private static AntTargetNode[] getTargets(AntProjectNode project) { >+ if (project == null || !project.hasChildren()) { >+ return null; > } >- List targets= new ArrayList(); >- Iterator possibleTargets= project.getChildNodes().iterator(); >+ List targets = new ArrayList(); >+ Iterator possibleTargets = project.getChildNodes().iterator(); > while (possibleTargets.hasNext()) { >- AntElementNode node= (AntElementNode)possibleTargets.next(); >+ AntElementNode node = (AntElementNode) possibleTargets.next(); > if (node instanceof AntTargetNode) { > targets.add(node); > } > } > if (targets.size() == 0) { >- return null; >+ return null; > } >- return (AntTargetNode[])targets.toArray(new AntTargetNode[targets.size()]); >- } >+ return (AntTargetNode[]) targets.toArray(new AntTargetNode[targets >+ .size()]); >+ } > >- public static AntTargetNode[] getTargets(String path) { >- File buildfile= getBuildFile(path); >+ public static AntTargetNode[] getTargets(String path) { >+ File buildfile = getBuildFile(path); > if (buildfile == null) { >- return null; >+ return null; > } >- //tasks and position info but no lexical info >- IAntModel model= getAntModel(buildfile, null, false, true, true); >- AntProjectNode project= model.getProjectNode(); >+ // tasks and position info but no lexical info >+ IAntModel model = getAntModel(buildfile, null, false, true, true); >+ AntProjectNode project = model.getProjectNode(); > if (project == null) { > model.dispose(); > return null; > } >- AntTargetNode[] targets= getTargets(project); >- if (targets == null) { >- Hashtable antTargets= project.getProject().getTargets(); >- Target implicitTarget= (Target) antTargets.get(""); //$NON-NLS-1$ >- if (implicitTarget != null) { >- AntTargetNode implicitTargetNode= new AntTargetNode(implicitTarget); >- project.addChildNode(implicitTargetNode); >- return new AntTargetNode[] {implicitTargetNode}; >- } >- } >- return targets; >- } >- >- public static IAntModel getAntModel(String buildFilePath, boolean needsLexicalResolution, boolean needsPositionResolution, boolean needsTaskResolution) { >- IAntModel model= getAntModel(getBuildFile(buildFilePath), null, needsLexicalResolution, needsPositionResolution, needsTaskResolution); >- return model; >+ AntTargetNode[] targets = getTargets(project); >+ if (targets == null) { >+ Hashtable antTargets = project.getProject().getTargets(); >+ Target implicitTarget = (Target) antTargets.get(""); //$NON-NLS-1$ >+ if (implicitTarget != null) { >+ AntTargetNode implicitTargetNode = new AntTargetNode( >+ implicitTarget); >+ project.addChildNode(implicitTargetNode); >+ return new AntTargetNode[] { implicitTargetNode }; >+ } >+ } >+ return targets; >+ } >+ >+ public static IAntModel getAntModel(String buildFilePath, >+ boolean needsLexicalResolution, boolean needsPositionResolution, >+ boolean needsTaskResolution) { >+ IAntModel model = getAntModel(getBuildFile(buildFilePath), null, >+ needsLexicalResolution, needsPositionResolution, >+ needsTaskResolution); >+ return model; > } >- >+ > /** >- * Return a buildfile from the specified location. >- * If there isn't one return null. >+ * Return a buildfile from the specified location. If there isn't one return >+ * null. > */ > private static File getBuildFile(String path) { > File buildFile = new File(path); >- if (!buildFile.isFile() || !buildFile.exists()) { >+ if (!buildFile.isFile() || !buildFile.exists()) { > return null; > } > > return buildFile; > } >- >- private static IAntModel getAntModel(final File buildFile, URL[] urls, boolean needsLexical, boolean needsPosition, boolean needsTask) { >- if (buildFile == null || !buildFile.exists()) { >- return null; >- } >- IDocument doc= getDocument(buildFile); >+ >+ private static IAntModel getAntModel(final File buildFile, URL[] urls, >+ boolean needsLexical, boolean needsPosition, boolean needsTask) { >+ if (buildFile == null || !buildFile.exists()) { >+ return null; >+ } >+ IDocument doc = getDocument(buildFile); > if (doc == null) { > return null; > } >- final IFile file= getFileForLocation(buildFile.getAbsolutePath(), null); >- LocationProvider provider= new LocationProvider(null) { >- /* (non-Javadoc) >- * @see org.eclipse.ant.internal.ui.model.LocationProvider#getFile() >- */ >- public IFile getFile() { >- return file; >- } >- /* (non-Javadoc) >- * @see org.eclipse.ant.internal.ui.model.LocationProvider#getLocation() >+ final IFile file = AntLaunchingUtil.getFileForLocation(buildFile >+ .getAbsolutePath(), null); >+ LocationProvider provider = new LocationProvider(null) { >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ant.internal.ui.model.LocationProvider#getFile() >+ */ >+ public IFile getFile() { >+ return file; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.ant.internal.ui.model.LocationProvider#getLocation() > */ > public IPath getLocation() { >- if (file == null) { >- return new Path(buildFile.getAbsolutePath()); >- } >- return file.getLocation(); >+ if (file == null) { >+ return new Path(buildFile.getAbsolutePath()); >+ } >+ return file.getLocation(); > } > }; >- IAntModel model= new AntModel(doc, null, provider, needsLexical, needsPosition, needsTask); >- >+ IAntModel model = new AntModel(doc, null, provider, needsLexical, >+ needsPosition, needsTask); >+ > if (urls != null) { >- model.setClassLoader(AntCorePlugin.getPlugin().getNewClassLoader(urls)); >+ model.setClassLoader(AntCorePlugin.getPlugin().getNewClassLoader( >+ urls)); > } > return model; > } >- >+ > private static IDocument getDocument(File buildFile) { >- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager(); >- IPath location= new Path(buildFile.getAbsolutePath()); >- boolean connected= false; >+ ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager(); >+ IPath location = new Path(buildFile.getAbsolutePath()); >+ boolean connected = false; > try { >- ITextFileBuffer buffer= manager.getTextFileBuffer(location, LocationKind.NORMALIZE); >+ ITextFileBuffer buffer = manager.getTextFileBuffer(location, >+ LocationKind.NORMALIZE); > if (buffer == null) { >- //no existing file buffer..create one >- manager.connect(location, LocationKind.NORMALIZE, new NullProgressMonitor()); >- connected= true; >- buffer= manager.getTextFileBuffer(location, LocationKind.NORMALIZE); >+ // no existing file buffer..create one >+ manager.connect(location, LocationKind.NORMALIZE, >+ new NullProgressMonitor()); >+ connected = true; >+ buffer = manager.getTextFileBuffer(location, >+ LocationKind.NORMALIZE); > if (buffer == null) { > return null; > } > } >- >+ > return buffer.getDocument(); > } catch (CoreException ce) { > AntUIPlugin.log(ce.getStatus()); >@@ -394,100 +314,28 @@ > } finally { > if (connected) { > try { >- manager.disconnect(location, LocationKind.NORMALIZE, new NullProgressMonitor()); >+ manager.disconnect(location, LocationKind.NORMALIZE, >+ new NullProgressMonitor()); > } catch (CoreException e) { > AntUIPlugin.log(e.getStatus()); > } > } > } > } >- >- /** >- * Returns the list of URLs that define the custom classpath for the Ant >- * build, or <code>null</code> if the global classpath is to be used. >- * >- * @param config launch configuration >- * @return a list of <code>URL</code> >- * >- * @throws CoreException if file does not exist, IO problems, or invalid format. >- */ >- public static URL[] getCustomClasspath(ILaunchConfiguration config) throws CoreException { >- boolean useDefault = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true); >- if (useDefault) { >- return null; >- } >- IRuntimeClasspathEntry[] unresolved = JavaRuntime.computeUnresolvedRuntimeClasspath(config); >- // don't consider bootpath entries >- List userEntries = new ArrayList(unresolved.length); >- for (int i = 0; i < unresolved.length; i++) { >- IRuntimeClasspathEntry entry = unresolved[i]; >- if (entry.getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES) { >- userEntries.add(entry); >- } >- } >- IRuntimeClasspathEntry[] entries = JavaRuntime.resolveRuntimeClasspath((IRuntimeClasspathEntry[])userEntries.toArray(new IRuntimeClasspathEntry[userEntries.size()]), config); >- URL[] urls = new URL[entries.length]; >- for (int i = 0; i < entries.length; i++) { >- IRuntimeClasspathEntry entry = entries[i]; >- try { >- urls[i] = new URL("file:"+entry.getLocation()); //$NON-NLS-1$ >- } catch (MalformedURLException e) { >- throw new CoreException(new Status(IStatus.ERROR, AntUIPlugin.getUniqueIdentifier(), AntUIPlugin.INTERNAL_ERROR, AntUIModelMessages.AntUtil_7, e)); >- } >- } >- return urls; >- } > >- private static String expandVariableString(String variableString, String invalidMessage) throws CoreException { >- String expandedString = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(variableString); >+ private static String expandVariableString(String variableString, >+ String invalidMessage) throws CoreException { >+ String expandedString = VariablesPlugin.getDefault() >+ .getStringVariableManager().performStringSubstitution( >+ variableString); > if (expandedString == null || expandedString.length() == 0) { >- String msg = MessageFormat.format(invalidMessage, new String[] {variableString}); >- throw new CoreException(new Status(IStatus.ERROR, IAntUIConstants.PLUGIN_ID, 0, msg, null)); >- } >- >- return expandedString; >- } >- >- /** >- * Returns the list of target names to run >- * >- * @param extraAttibuteValue the external tool's extra attribute value >- * for the run targets key. >- * @return a list of target names >- */ >- public static String[] parseRunTargets(String extraAttibuteValue) { >- return parseString(extraAttibuteValue, ATTRIBUTE_SEPARATOR); >- } >- >- /** >- * Returns the list of Strings that were delimiter separated. >- * >- * @param delimString the String to be tokenized based on the delimiter >- * @return a list of Strings >- */ >- public static String[] parseString(String delimString, String delim) { >- if (delimString == null) { >- return new String[0]; >- } >- >- // Need to handle case where separator character is >- // actually part of the target name! >- StringTokenizer tokenizer = new StringTokenizer(delimString, delim); >- String[] results = new String[tokenizer.countTokens()]; >- for (int i = 0; i < results.length; i++) { >- results[i] = tokenizer.nextToken(); >+ String msg = MessageFormat.format(invalidMessage, >+ new String[] { variableString }); >+ throw new CoreException(new Status(IStatus.ERROR, >+ IAntUIConstants.PLUGIN_ID, 0, msg, null)); > } >- >- return results; >- } >- >- /** >- * Returns an IFile with the given fully qualified path (relative to the workspace root). >- * The returned IFile may or may not exist. >- */ >- public static IFile getFile(String fullPath) { >- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); >- return root.getFile(new Path(fullPath)); >+ >+ return expandedString; > } > > public static IHyperlink getLocationLink(String path, File buildFileParent) { >@@ -497,12 +345,12 @@ > } > if (path.startsWith("file:")) { //$NON-NLS-1$ > // remove "file:" >- path= path.substring(5, path.length()); >+ path = path.substring(5, path.length()); > } > // format is file:F:L: where F is file path, and L is line number > int index = path.lastIndexOf(':'); > if (index == -1) { >- //incorrect format >+ // incorrect format > return null; > } > if (index == path.length() - 1) { >@@ -515,283 +363,155 @@ > try { > String lineNumber = path.substring(index + 1); > int line = Integer.parseInt(lineNumber); >- IFile file = getFileForLocation(fileName, buildFileParent); >+ IFile file = AntLaunchingUtil.getFileForLocation(fileName, >+ buildFileParent); > if (file != null) { > return new FileLink(file, null, -1, -1, line); > } > } catch (NumberFormatException e) { > } >- >+ > return null; > } > >- /** >- * Returns the workspace file associated with the given path in the >- * local file system, or <code>null</code> if none. >- * If the path happens to be a relative path, then the path is interpreted as >- * relative to the specified parent file. >- * >- * Attempts to handle linked files; the first found linked file with the correct >- * path is returned. >- * >- * @param path >- * @param buildFileParent >- * @return file or <code>null</code> >- * @see org.eclipse.core.resources.IWorkspaceRoot#findFilesForLocation(IPath) >- */ >- public static IFile getFileForLocation(String path, File buildFileParent) { >- if (path == null) { >- return null; >+ private static int getOffset(int line, int column, ITextEditor editor) { >+ IDocumentProvider provider = editor.getDocumentProvider(); >+ IEditorInput input = editor.getEditorInput(); >+ try { >+ provider.connect(input); >+ } catch (CoreException e) { >+ return -1; > } >- IPath filePath= new Path(path); >- IFile file = null; >- IFile[] files= ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(filePath); >- if (files.length > 0) { >- file= files[0]; >- } >- if (file == null) { >- //relative path >- File relativeFile= null; >- try { >- //this call is ok if buildFileParent is null >- relativeFile= FileUtils.getFileUtils().resolveFile(buildFileParent, path); >- filePath= new Path(relativeFile.getAbsolutePath()); >- files= ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(filePath); >- if (files.length > 0) { >- file= files[0]; >- } else { >- return null; >+ try { >+ IDocument document = provider.getDocument(input); >+ if (document != null) { >+ if (column > -1) { >+ // column marks the length..adjust to 0 index and to be >+ // within the element's source range >+ return document.getLineOffset(line - 1) + column - 1 - 2; > } >- } catch (BuildException be) { >- return null; >+ return document.getLineOffset(line - 1); > } >+ } catch (BadLocationException e) { >+ } finally { >+ provider.disconnect(input); > } >- >- if (file.exists()) { >- return file; >- } >- File ioFile= file.getLocation().toFile(); >- if (ioFile.exists()) {//needs to handle case insensitivity on WINOS >- try { >- files= ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(ioFile.getCanonicalPath())); >- if (files.length > 0) { >- return files[0]; >- } >- } catch (IOException e) { >- } >- } >- >- return null; >+ return -1; > } > > /** >- * Migrates the classpath in the given configuration from the old format >- * to the new format. The old format is not preserved. Instead, the default >- * classpath will be used. However, ANT_HOME settings are preserved. >+ * Opens the given editor on the buildfile of the provided node and selects >+ * that node in the editor. > * >- * @param configuration a configuration to migrate >- * @throws CoreException if unable to migrate >- * @since 3.0 >- */ >- public static void migrateToNewClasspathFormat(ILaunchConfiguration configuration) throws CoreException { >- String oldClasspath = configuration.getAttribute(org.eclipse.ant.internal.ui.launchConfigurations.IAntLaunchConfigurationConstants.ATTR_ANT_CUSTOM_CLASSPATH, (String)null); >- String oldAntHome = configuration.getAttribute(org.eclipse.ant.internal.ui.launchConfigurations.IAntLaunchConfigurationConstants.ATTR_ANT_HOME, (String)null); >- String provider = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, (String)null); >- if (oldClasspath != null || oldAntHome != null || provider == null) { >- ILaunchConfigurationWorkingCopy workingCopy = null; >- if (configuration.isWorkingCopy()) { >- workingCopy = (ILaunchConfigurationWorkingCopy) configuration; >+ * @param page >+ * the page to open the editor in >+ * @param editorDescriptor >+ * the editor descriptor, or <code>null</code> for the system >+ * editor >+ * @param node >+ * the node from the buildfile to open and then select in the >+ * editor >+ */ >+ public static void openInEditor(IWorkbenchPage page, >+ IEditorDescriptor editorDescriptor, AntElementNode node) { >+ IEditorPart editorPart = null; >+ IFile fileResource = node.getIFile(); >+ try { >+ if (editorDescriptor == null) { >+ editorPart = page.openEditor(new FileEditorInput(fileResource), >+ IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID); > } else { >- workingCopy = configuration.getWorkingCopy(); >+ editorPart = page.openEditor(new FileEditorInput(fileResource), >+ editorDescriptor.getId()); > } >- workingCopy.setAttribute(org.eclipse.ant.internal.ui.launchConfigurations.IAntLaunchConfigurationConstants.ATTR_ANT_CUSTOM_CLASSPATH, (String)null); >- workingCopy.setAttribute(org.eclipse.ant.internal.ui.launchConfigurations.IAntLaunchConfigurationConstants.ATTR_ANT_HOME, (String)null); >- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, "org.eclipse.ant.ui.AntClasspathProvider"); //$NON-NLS-1$ >- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true); >- if (oldAntHome != null) { >- IRuntimeClasspathEntry[] entries = JavaRuntime.computeUnresolvedRuntimeClasspath(workingCopy); >- List mementos = new ArrayList(entries.length); >- for (int i = 0; i < entries.length; i++) { >- IRuntimeClasspathEntry entry = entries[i]; >- if (entry.getType() == IRuntimeClasspathEntry.OTHER) { >- IRuntimeClasspathEntry2 entry2 = (IRuntimeClasspathEntry2) entry; >- if (entry2.getTypeId().equals(AntHomeClasspathEntry.TYPE_ID)) { >- AntHomeClasspathEntry homeEntry = new AntHomeClasspathEntry(oldAntHome); >- mementos.add(homeEntry.getMemento()); >- continue; >- } >- } >- mementos.add(entry.getMemento()); >+ } catch (PartInitException e) { >+ AntUIPlugin.log(MessageFormat.format(AntUIModelMessages.AntUtil_0, >+ new String[] { fileResource.getLocation().toOSString() }), >+ e); >+ } >+ >+ if (editorPart instanceof AntEditor) { >+ AntEditor editor = (AntEditor) editorPart; >+ if (node.getImportNode() != null) { >+ AntModel model = editor.getAntModel(); >+ AntProjectNode project = model.getProjectNode(); >+ if (project == null) { >+ return; > } >- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false); >- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, mementos); >+ int[] info = node.getExternalInfo(); >+ int offset = getOffset(info[0], info[1], editor); >+ node = project.getNode(offset); > } >- workingCopy.doSave(); >+ editor.setSelection(node, true); > } > } > >- private static int getOffset(int line, int column, ITextEditor editor) { >- IDocumentProvider provider= editor.getDocumentProvider(); >- IEditorInput input= editor.getEditorInput(); >- try { >- provider.connect(input); >- } catch (CoreException e) { >- return -1; >- } >- try { >- IDocument document= provider.getDocument(input); >- if (document != null) { >- if (column > -1) { >- //column marks the length..adjust to 0 index and to be within the element's source range >- return document.getLineOffset(line - 1) + column - 1 - 2; >- } >- return document.getLineOffset(line - 1); >- } >- } catch (BadLocationException e) { >- } finally { >- provider.disconnect(input); >- } >- return -1; >- } >- >- /** >- * Opens the given editor on the buildfile of the provided node and selects that node in the editor. >- * >- * @param page the page to open the editor in >- * @param editorDescriptor the editor descriptor, or <code>null</code> for the system editor >- * @param node the node from the buildfile to open and then select in the editor >- */ >- public static void openInEditor(IWorkbenchPage page, IEditorDescriptor editorDescriptor, AntElementNode node) { >- IEditorPart editorPart= null; >- IFile fileResource = node.getIFile(); >- try { >- if (editorDescriptor == null) { >- editorPart= page.openEditor(new FileEditorInput(fileResource), IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID); >- } else { >- editorPart= page.openEditor(new FileEditorInput(fileResource), editorDescriptor.getId()); >- } >- } catch (PartInitException e) { >- AntUIPlugin.log(MessageFormat.format(AntUIModelMessages.AntUtil_0, new String[]{fileResource.getLocation().toOSString()}), e); >- } >- >- if (editorPart instanceof AntEditor) { >- AntEditor editor= (AntEditor)editorPart; >- if (node.getImportNode() != null) { >- AntModel model= editor.getAntModel(); >- AntProjectNode project= model.getProjectNode(); >- if (project == null) { >- return; >- } >- int[] info= node.getExternalInfo(); >- int offset= getOffset(info[0], info[1], editor); >- node= project.getNode(offset); >- } >- editor.setSelection(node, true); >- } >- } >- >- /** >- * Opens an editor on the buildfile of the provided node and selects that node in the editor. >- * >- * @param page the page to open the editor in >- * @param node the node from the buildfile to open and then select in the editor >- */ >- public static void openInEditor(IWorkbenchPage page, AntElementNode node) { >- IFile file= node.getIFile(); >- IEditorDescriptor editorDesc; >- try { >- editorDesc = IDE.getEditorDescriptor(file); >- } catch (PartInitException e) { >- return; >- } >- openInEditor(page, editorDesc, node); >- } >- >- /** >- * Opens an external browser on the provided <code>urlString</code> >- * @param urlString The url to open >- * @param shell the shell >- * @param errorDialogTitle the title of any error dialog >- */ >- public static void openBrowser(final String urlString, final Shell shell, final String errorDialogTitle) { >- shell.getDisplay().syncExec(new Runnable() { >- public void run() { >- IWorkbenchBrowserSupport support= PlatformUI.getWorkbench().getBrowserSupport(); >- try { >- IWebBrowser browser= support.createBrowser(fgBrowserId); >- fgBrowserId= browser.getId(); >- browser.openURL(new URL(urlString)); >- return; >- } catch (PartInitException e) { >- AntUIPlugin.log(e.getStatus()); >- } catch (MalformedURLException e) { >- AntUIPlugin.log(e); >- } >- >- String platform= SWT.getPlatform(); >- boolean succeeded= true; >- if ("motif".equals(platform) || "gtk".equals(platform)) { //$NON-NLS-1$ //$NON-NLS-2$ >- Program program= Program.findProgram("html"); //$NON-NLS-1$ >- if (program == null) { >- program= Program.findProgram("htm"); //$NON-NLS-1$ >- } >- if (program != null) { >- succeeded= program.execute(urlString.toString()); >- } >- } else { >- succeeded= Program.launch(urlString.toString()); >- } >- if (!succeeded) { >- MessageDialog.openInformation(shell, errorDialogTitle, AntUIModelMessages.AntUtil_1); >- } >- } >- }); >- } >- >- public static boolean isSeparateJREAntBuild(ILaunchConfiguration configuration) { >- boolean separateJRE= true; >+ /** >+ * Opens an editor on the buildfile of the provided node and selects that >+ * node in the editor. >+ * >+ * @param page >+ * the page to open the editor in >+ * @param node >+ * the node from the buildfile to open and then select in the >+ * editor >+ */ >+ public static void openInEditor(IWorkbenchPage page, AntElementNode node) { >+ IFile file = node.getIFile(); >+ IEditorDescriptor editorDesc; > try { >- //always null for same JRE >- separateJRE = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String)null) != null; >- } catch (CoreException e) { >- AntUIPlugin.log(AntUIModelMessages.AntUtil_2, e); >+ editorDesc = IDE.getEditorDescriptor(file); >+ } catch (PartInitException e) { >+ return; > } >- >- return separateJRE; >- } >- >- public static void linkBuildFailedMessage(String message, IProcess process) { >- String fileName = null; >- String lineNumber = ""; //$NON-NLS-1$ >- int fileStart = 0; >- int index = message.indexOf("xml"); //$NON-NLS-1$ >- if (index > 0) { >- int numberStart= index + 4; >- int numberEnd= message.indexOf(':', numberStart); >- int fileEnd = index + 3; >- if (numberStart > 0 && fileEnd > 0) { >- fileName = message.substring(fileStart, fileEnd).trim(); >- if (numberEnd > 0) { >- lineNumber = message.substring(numberStart, numberEnd).trim(); >- } >- } >- } >- >- if (fileName != null) { >- int num = -1; >- try { >- num = Integer.parseInt(lineNumber); >- } catch (NumberFormatException e) { >- } >- IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(fileName)); >- IFile file= null; >- if (files.length > 0) { >- file= files[0]; >- } >- if (file != null && file.exists()) { >- FileLink link = new FileLink(file, null, -1, -1, num); >- TaskLinkManager.addTaskHyperlink(process, link, new Region(0, message.length()), message); >- } >- } >- } >+ openInEditor(page, editorDesc, node); >+ } >+ >+ /** >+ * Opens an external browser on the provided <code>urlString</code> >+ * >+ * @param urlString >+ * The url to open >+ * @param shell >+ * the shell >+ * @param errorDialogTitle >+ * the title of any error dialog >+ */ >+ public static void openBrowser(final String urlString, final Shell shell, >+ final String errorDialogTitle) { >+ shell.getDisplay().syncExec(new Runnable() { >+ public void run() { >+ IWorkbenchBrowserSupport support = PlatformUI.getWorkbench() >+ .getBrowserSupport(); >+ try { >+ IWebBrowser browser = support.createBrowser(fgBrowserId); >+ fgBrowserId = browser.getId(); >+ browser.openURL(new URL(urlString)); >+ return; >+ } catch (PartInitException e) { >+ AntUIPlugin.log(e.getStatus()); >+ } catch (MalformedURLException e) { >+ AntUIPlugin.log(e); >+ } >+ >+ String platform = SWT.getPlatform(); >+ boolean succeeded = true; >+ if ("motif".equals(platform) || "gtk".equals(platform)) { //$NON-NLS-1$ //$NON-NLS-2$ >+ Program program = Program.findProgram("html"); //$NON-NLS-1$ >+ if (program == null) { >+ program = Program.findProgram("htm"); //$NON-NLS-1$ >+ } >+ if (program != null) { >+ succeeded = program.execute(urlString.toString()); >+ } >+ } else { >+ succeeded = Program.launch(urlString.toString()); >+ } >+ if (!succeeded) { >+ MessageDialog.openInformation(shell, errorDialogTitle, >+ AntUIModelMessages.AntUtil_1); >+ } >+ } >+ }); >+ } > } >\ No newline at end of file >Index: Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/RemoteAntDebugBuildListener.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/RemoteAntDebugBuildListener.java,v >retrieving revision 1.22 >diff -u -r1.22 RemoteAntDebugBuildListener.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/RemoteAntDebugBuildListener.java 20 Mar 2006 22:51:29 -0000 1.22 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/RemoteAntDebugBuildListener.java 25 Sep 2009 16:23:36 -0000 >@@ -18,9 +18,9 @@ > import java.net.Socket; > import java.net.UnknownHostException; > >+import org.eclipse.ant.internal.launching.launchConfigurations.RemoteAntBuildListener; > import org.eclipse.ant.internal.ui.AntUIPlugin; > import org.eclipse.ant.internal.ui.debug.IAntDebugController; >-import org.eclipse.ant.internal.ui.launchConfigurations.RemoteAntBuildListener; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.debug.core.DebugEvent; > import org.eclipse.debug.core.DebugPlugin; >Index: Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/AntStackFrame.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/AntStackFrame.java,v >retrieving revision 1.15 >diff -u -r1.15 AntStackFrame.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/AntStackFrame.java 2 Jun 2005 16:34:26 -0000 1.15 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/AntStackFrame.java 25 Sep 2009 16:23:36 -0000 >@@ -10,7 +10,7 @@ > *******************************************************************************/ > package org.eclipse.ant.internal.ui.debug.model; > >-import org.eclipse.ant.internal.ui.AntUtil; >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.Path; > import org.eclipse.debug.core.DebugException; >@@ -84,7 +84,7 @@ > > protected void setFilePath(String fullPath) { > fFullPath= fullPath; >- IFile file= AntUtil.getFileForLocation(fullPath, null); >+ IFile file= AntLaunchingUtil.getFileForLocation(fullPath, null); > if (file != null) { > fFilePath= file.getProjectRelativePath().toString(); > } else { >Index: Ant Tools Support/org/eclipse/ant/internal/ui/refactoring/LaunchConfigurationBuildfileChange.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/refactoring/LaunchConfigurationBuildfileChange.java,v >retrieving revision 1.9 >diff -u -r1.9 LaunchConfigurationBuildfileChange.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/refactoring/LaunchConfigurationBuildfileChange.java 23 Sep 2008 14:45:18 -0000 1.9 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/refactoring/LaunchConfigurationBuildfileChange.java 25 Sep 2009 16:23:43 -0000 >@@ -14,7 +14,7 @@ > import java.util.List; > > import org.eclipse.ant.core.AntCorePlugin; >-import org.eclipse.ant.internal.ui.AntUtil; >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants; > import org.eclipse.core.resources.IContainer; > import org.eclipse.core.resources.IFile; >@@ -277,7 +277,7 @@ > try { > String expandedLocation= manager.performStringSubstitution(location); > if (expandedLocation != null) { >- file= AntUtil.getFileForLocation(expandedLocation, null); >+ file= AntLaunchingUtil.getFileForLocation(expandedLocation, null); > } > } catch (CoreException e) { > } >Index: Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPropertiesBlock.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPropertiesBlock.java,v >retrieving revision 1.26 >diff -u -r1.26 AntPropertiesBlock.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPropertiesBlock.java 24 Feb 2009 16:29:02 -0000 1.26 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPropertiesBlock.java 25 Sep 2009 16:23:42 -0000 >@@ -16,8 +16,8 @@ > import java.util.Map; > > import org.eclipse.ant.core.Property; >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.ant.internal.ui.AntUIPlugin; >-import org.eclipse.ant.internal.ui.AntUtil; > import org.eclipse.ant.internal.ui.ColumnSorter; > import org.eclipse.ant.internal.ui.IAntUIConstants; > import org.eclipse.core.resources.IFile; >@@ -174,7 +174,7 @@ > for (int j = 0; j < existingFiles.length; j++) { > String file = (String)existingFiles[j]; > try { >- propFiles.add(AntUtil.getFileForLocation(VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(file), null)); >+ propFiles.add(AntLaunchingUtil.getFileForLocation(VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(file), null)); > } catch (CoreException e) { > AntUIPlugin.log(e.getStatus()); > } >Index: Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreferencePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreferencePage.java,v >retrieving revision 1.24 >diff -u -r1.24 AntPreferencePage.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreferencePage.java 10 Apr 2006 15:39:25 -0000 1.24 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreferencePage.java 25 Sep 2009 16:23:41 -0000 >@@ -10,12 +10,14 @@ > *******************************************************************************/ > package org.eclipse.ant.internal.ui.preferences; > >- >-import com.ibm.icu.text.MessageFormat; >- >+import org.eclipse.ant.internal.launching.AntLaunching; >+import org.eclipse.ant.internal.launching.IAntLaunchingPreferenceConstants; > import org.eclipse.ant.internal.ui.AntUIPlugin; > import org.eclipse.ant.internal.ui.IAntUIHelpContextIds; > import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.preferences.IEclipsePreferences; >+import org.eclipse.core.runtime.preferences.InstanceScope; > import org.eclipse.jface.preference.BooleanFieldEditor; > import org.eclipse.jface.preference.FieldEditorPreferencePage; > import org.eclipse.jface.preference.IPreferenceStore; >@@ -40,161 +42,212 @@ > import org.eclipse.ui.IWorkbenchPreferencePage; > import org.eclipse.ui.PlatformUI; > >-public class AntPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { >- >+import com.ibm.icu.text.MessageFormat; >+ >+public class AntPreferencePage extends FieldEditorPreferencePage implements >+ IWorkbenchPreferencePage { >+ > private List fConsoleColorList; > private ColorEditor fConsoleColorEditor; >- >- private BooleanFieldEditor fToolsWarningEditor= null; >- >- // Array containing the message to display, the preference key, and the >- // default value (initialized in storeInitialValues()) for each color preference >- private final String[][] fAppearanceColorListModel= new String[][] { >- {AntPreferencesMessages.AntPreferencePage__Error__2, IAntUIPreferenceConstants.CONSOLE_ERROR_COLOR, null}, >- {AntPreferencesMessages.AntPreferencePage__Warning__3, IAntUIPreferenceConstants.CONSOLE_WARNING_COLOR, null}, >- {AntPreferencesMessages.AntPreferencePage_I_nformation__4, IAntUIPreferenceConstants.CONSOLE_INFO_COLOR, null}, >- {AntPreferencesMessages.AntPreferencePage_Ve_rbose__5, IAntUIPreferenceConstants.CONSOLE_VERBOSE_COLOR, null}, >- {AntPreferencesMessages.AntPreferencePage_Deb_ug__6, IAntUIPreferenceConstants.CONSOLE_DEBUG_COLOR, null}, >- }; >+ private IntegerFieldEditor timeout; >+ >+ private BooleanFieldEditor fToolsWarningEditor = null; >+ >+ // Array containing the message to display, the preference key, and the >+ // default value (initialized in storeInitialValues()) for each color >+ // preference >+ private final String[][] fAppearanceColorListModel = new String[][] { >+ { AntPreferencesMessages.AntPreferencePage__Error__2, >+ IAntUIPreferenceConstants.CONSOLE_ERROR_COLOR, null }, >+ { AntPreferencesMessages.AntPreferencePage__Warning__3, >+ IAntUIPreferenceConstants.CONSOLE_WARNING_COLOR, null }, >+ { AntPreferencesMessages.AntPreferencePage_I_nformation__4, >+ IAntUIPreferenceConstants.CONSOLE_INFO_COLOR, null }, >+ { AntPreferencesMessages.AntPreferencePage_Ve_rbose__5, >+ IAntUIPreferenceConstants.CONSOLE_VERBOSE_COLOR, null }, >+ { AntPreferencesMessages.AntPreferencePage_Deb_ug__6, >+ IAntUIPreferenceConstants.CONSOLE_DEBUG_COLOR, null }, }; > > /** >- * Create the Ant page. >- */ >+ * Create the Ant page. >+ */ > public AntPreferencePage() { > super(GRID); > setDescription(AntPreferencesMessages.AntPreferencePage_General); > setPreferenceStore(AntUIPlugin.getDefault().getPreferenceStore()); > } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors >+ * () > */ > protected void createFieldEditors() { > storeAppliedValues(); > >- Font font= getFieldEditorParent().getFont(); >- Label label= new Label(getFieldEditorParent(), SWT.WRAP); >+ Font font = getFieldEditorParent().getFont(); >+ Label label = new Label(getFieldEditorParent(), SWT.WRAP); > label.setText(AntPreferencesMessages.AntPreferencePage_Enter); >- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan= 3; >- gd.widthHint= convertWidthInCharsToPixels(60); >+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = 3; >+ gd.widthHint = convertWidthInCharsToPixels(60); > label.setLayoutData(gd); > label.setLayoutData(gd); > label.setFont(font); >- >- StringFieldEditor editor = new StringFieldEditor(IAntUIPreferenceConstants.ANT_FIND_BUILD_FILE_NAMES, AntPreferencesMessages.AntPreferencePage__Names__3, getFieldEditorParent()); >+ >+ StringFieldEditor editor = new StringFieldEditor( >+ IAntUIPreferenceConstants.ANT_FIND_BUILD_FILE_NAMES, >+ AntPreferencesMessages.AntPreferencePage__Names__3, >+ getFieldEditorParent()); > addField(editor); >- >- IntegerFieldEditor timeout = new IntegerFieldEditor(IAntUIPreferenceConstants.ANT_COMMUNICATION_TIMEOUT, AntPreferencesMessages.AntPreferencePage_13, getFieldEditorParent()); >- int minValue= AntUIPlugin.getDefault().getPreferenceStore().getDefaultInt(IAntUIPreferenceConstants.ANT_COMMUNICATION_TIMEOUT); >- int maxValue = 1200000; >- timeout.setValidRange(minValue, maxValue); >- timeout.setErrorMessage(MessageFormat.format(AntPreferencesMessages.AntPreferencePage_14, new Object[] {new Integer(minValue), new Integer(maxValue)})); >- addField(timeout); >- >- editor = new URLFieldEditor(IAntUIPreferenceConstants.DOCUMENTATION_URL, AntPreferencesMessages.AntPreferencePage_2, getFieldEditorParent()); >+ >+ timeout = new IntegerFieldEditor( >+ IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT, >+ AntPreferencesMessages.AntPreferencePage_13, >+ getFieldEditorParent()); >+ int minValue = Platform.getPreferencesService().getInt( >+ AntLaunching.getUniqueIdentifier(), >+ IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT, >+ 20000, null); >+ int maxValue = 1200000; >+ timeout.setValidRange(minValue, maxValue); >+ timeout.setErrorMessage(MessageFormat.format( >+ AntPreferencesMessages.AntPreferencePage_14, new Object[] { >+ new Integer(minValue), new Integer(maxValue) })); >+ addField(timeout); >+ >+ editor = new URLFieldEditor( >+ IAntUIPreferenceConstants.DOCUMENTATION_URL, >+ AntPreferencesMessages.AntPreferencePage_2, >+ getFieldEditorParent()); > addField(editor); >- >+ > createSpace(); >- >+ > if (!AntUIPlugin.isMacOS()) { >- //the mac does not have a tools.jar Bug 40778 >- label= new Label(getFieldEditorParent(), SWT.WRAP); >+ // the mac does not have a tools.jar Bug 40778 >+ label = new Label(getFieldEditorParent(), SWT.WRAP); > label.setText(AntPreferencesMessages.AntPreferencePage_0); >- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan= 3; >- gd.widthHint= convertWidthInCharsToPixels(60); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = 3; >+ gd.widthHint = convertWidthInCharsToPixels(60); > label.setLayoutData(gd); > label.setFont(font); >- fToolsWarningEditor= new BooleanFieldEditor(IAntUIPreferenceConstants.ANT_TOOLS_JAR_WARNING, AntPreferencesMessages.AntPreferencePage_1, getFieldEditorParent()); >+ fToolsWarningEditor = new BooleanFieldEditor( >+ IAntUIPreferenceConstants.ANT_TOOLS_JAR_WARNING, >+ AntPreferencesMessages.AntPreferencePage_1, >+ getFieldEditorParent()); > addField(fToolsWarningEditor); > createSpace(); > } >- >- addField(new BooleanFieldEditor(IAntUIPreferenceConstants.ANT_ERROR_DIALOG, AntPreferencesMessages.AntPreferencePage_12, getFieldEditorParent())); >+ >+ addField(new BooleanFieldEditor( >+ IAntUIPreferenceConstants.ANT_ERROR_DIALOG, >+ AntPreferencesMessages.AntPreferencePage_12, >+ getFieldEditorParent())); > createSpace(); >- >- >- addField(new BooleanFieldEditor(IAntUIPreferenceConstants.ANT_CREATE_MARKERS, AntPreferencesMessages.AntPreferencePage_15, getFieldEditorParent())); >- label= new Label(getFieldEditorParent(), SWT.WRAP); >+ >+ addField(new BooleanFieldEditor( >+ IAntUIPreferenceConstants.ANT_CREATE_MARKERS, >+ AntPreferencesMessages.AntPreferencePage_15, >+ getFieldEditorParent())); >+ label = new Label(getFieldEditorParent(), SWT.WRAP); > label.setText(AntPreferencesMessages.AntPreferencePage_16); >- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan= 3; >- gd.widthHint= convertWidthInCharsToPixels(60); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = 3; >+ gd.widthHint = convertWidthInCharsToPixels(60); > label.setLayoutData(gd); > label.setFont(font); >- >- createSpace(); >+ >+ createSpace(); > createColorComposite(); > getPreferenceStore().addPropertyChangeListener(this); > } >- >+ > private void createSpace() { >- Label label= new Label(getFieldEditorParent(), SWT.NONE); >- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan= 3; >+ Label label = new Label(getFieldEditorParent(), SWT.NONE); >+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = 3; > label.setLayoutData(gd); > } > > /** >- * Stores the initial values of the color preferences. The preference values are updated >- * on the fly as the user edits them (instead of only when they press "Apply"). We need >- * to store the old values so that we can reset them when the user chooses "Cancel". >+ * Stores the initial values of the color preferences. The preference values >+ * are updated on the fly as the user edits them (instead of only when they >+ * press "Apply"). We need to store the old values so that we can reset them >+ * when the user chooses "Cancel". > */ > private void storeAppliedValues() { >- IPreferenceStore store= getPreferenceStore(); >+ IPreferenceStore store = getPreferenceStore(); > for (int i = 0; i < fAppearanceColorListModel.length; i++) { > String preference = fAppearanceColorListModel[i][1]; >- fAppearanceColorListModel[i][2]= store.getString(preference); >+ fAppearanceColorListModel[i][2] = store.getString(preference); >+ } >+ >+ IEclipsePreferences node = new InstanceScope() >+ .getNode(AntLaunching.getUniqueIdentifier()); >+ String t = node.get( >+ IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT, >+ "2000"); >+ if (timeout != null) { >+ t = Integer.valueOf(timeout.getIntValue()).toString(); > } >+ node.put(IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT, t); //$NON-NLS-1$ > } >- >+ > private void createColorComposite() { >- Font font= getFieldEditorParent().getFont(); >- Label label= new Label(getFieldEditorParent(), SWT.LEFT); >- label.setText(AntPreferencesMessages.AntPreferencePage_Ant_Color_Options__6); >+ Font font = getFieldEditorParent().getFont(); >+ Label label = new Label(getFieldEditorParent(), SWT.LEFT); >+ label >+ .setText(AntPreferencesMessages.AntPreferencePage_Ant_Color_Options__6); > label.setFont(font); >- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan= 2; >+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = 2; > label.setLayoutData(gd); >- >- Composite editorComposite= new Composite(getFieldEditorParent(), SWT.NONE); >- GridLayout layout= new GridLayout(); >- layout.numColumns= 2; >- layout.marginHeight= 0; >- layout.marginWidth= 0; >+ >+ Composite editorComposite = new Composite(getFieldEditorParent(), >+ SWT.NONE); >+ GridLayout layout = new GridLayout(); >+ layout.numColumns = 2; >+ layout.marginHeight = 0; >+ layout.marginWidth = 0; > editorComposite.setLayout(layout); > editorComposite.setFont(font); >- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); >- gd.horizontalSpan= 2; >- editorComposite.setLayoutData(gd); >- >- fConsoleColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); >- gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); >- gd.heightHint= convertHeightInCharsToPixels(8); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL >+ | GridData.FILL_VERTICAL); >+ gd.horizontalSpan = 2; >+ editorComposite.setLayoutData(gd); >+ >+ fConsoleColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL >+ | SWT.H_SCROLL | SWT.BORDER); >+ gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING >+ | GridData.FILL_HORIZONTAL); >+ gd.heightHint = convertHeightInCharsToPixels(8); > fConsoleColorList.setLayoutData(gd); > fConsoleColorList.setFont(font); >- >- Composite stylesComposite= new Composite(editorComposite, SWT.NONE); >- layout= new GridLayout(); >- layout.marginHeight= 0; >- layout.marginWidth= 0; >- layout.numColumns= 2; >+ >+ Composite stylesComposite = new Composite(editorComposite, SWT.NONE); >+ layout = new GridLayout(); >+ layout.marginHeight = 0; >+ layout.marginWidth = 0; >+ layout.numColumns = 2; > stylesComposite.setLayout(layout); > stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); > stylesComposite.setFont(font); > >- label= new Label(stylesComposite, SWT.LEFT); >+ label = new Label(stylesComposite, SWT.LEFT); > label.setText(AntPreferencesMessages.AntPreferencePage_Color__7); > label.setFont(font); >- gd= new GridData(); >- gd.horizontalAlignment= GridData.BEGINNING; >+ gd = new GridData(); >+ gd.horizontalAlignment = GridData.BEGINNING; > label.setLayoutData(gd); > >- fConsoleColorEditor= new ColorEditor(stylesComposite); >- Button foregroundColorButton= fConsoleColorEditor.getButton(); >- gd= new GridData(GridData.FILL_HORIZONTAL); >- gd.horizontalAlignment= GridData.BEGINNING; >+ fConsoleColorEditor = new ColorEditor(stylesComposite); >+ Button foregroundColorButton = fConsoleColorEditor.getButton(); >+ gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalAlignment = GridData.BEGINNING; > foregroundColorButton.setLayoutData(gd); > foregroundColorButton.setFont(font); > >@@ -205,27 +258,29 @@ > }); > foregroundColorButton.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { >- int i= fConsoleColorList.getSelectionIndex(); >- if (i == -1) { //bug 85590 >+ int i = fConsoleColorList.getSelectionIndex(); >+ if (i == -1) { // bug 85590 > return; > } >- String key= fAppearanceColorListModel[i][1]; >- PreferenceConverter.setValue(getPreferenceStore(), key, fConsoleColorEditor.getColorValue()); >+ String key = fAppearanceColorListModel[i][1]; >+ PreferenceConverter.setValue(getPreferenceStore(), key, >+ fConsoleColorEditor.getColorValue()); > } > }); > } >- >+ > /** > * Restore all color preferences to their values when the page was opened. > */ > public boolean performCancel() { > for (int i = 0; i < fAppearanceColorListModel.length; i++) { > String preference = fAppearanceColorListModel[i][1]; >- PreferenceConverter.setValue(getPreferenceStore(), preference, StringConverter.asRGB(fAppearanceColorListModel[i][2])); >+ PreferenceConverter.setValue(getPreferenceStore(), preference, >+ StringConverter.asRGB(fAppearanceColorListModel[i][2])); > } > return super.performCancel(); > } >- >+ > /** > * When the user applies the preferences, update the set of stored > * preferences so that we will fall back to the applied values on Cancel. >@@ -234,22 +289,23 @@ > storeAppliedValues(); > return super.performOk(); > } >- >- private void handleAppearanceColorListSelection() { >- int i= fConsoleColorList.getSelectionIndex(); >- if (i == -1) { //bug 85590 >+ >+ private void handleAppearanceColorListSelection() { >+ int i = fConsoleColorList.getSelectionIndex(); >+ if (i == -1) { // bug 85590 > return; > } >- String key= fAppearanceColorListModel[i][1]; >- RGB rgb= PreferenceConverter.getColor(getPreferenceStore(), key); >- fConsoleColorEditor.setColorValue(rgb); >+ String key = fAppearanceColorListModel[i][1]; >+ RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), key); >+ fConsoleColorEditor.setColorValue(rgb); > } >- >+ > /** > * @see FieldEditorPreferencePage#createContents(org.eclipse.swt.widgets.Composite) > */ > protected Control createContents(Composite parent) { >- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IAntUIHelpContextIds.ANT_PREFERENCE_PAGE); >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, >+ IAntUIHelpContextIds.ANT_PREFERENCE_PAGE); > return super.createContents(parent); > } > >@@ -258,49 +314,60 @@ > */ > public void init(IWorkbench workbench) { > } >- >+ > /** > * @see org.eclipse.jface.preference.FieldEditorPreferencePage#initialize() > */ > protected void initialize() { > super.initialize(); >- for (int i= 0; i < fAppearanceColorListModel.length; i++) { >+ for (int i = 0; i < fAppearanceColorListModel.length; i++) { > fConsoleColorList.add(fAppearanceColorListModel[i][0]); > } > fConsoleColorList.getDisplay().asyncExec(new Runnable() { > public void run() { >- if (fConsoleColorList != null && !fConsoleColorList.isDisposed()) { >+ if (fConsoleColorList != null >+ && !fConsoleColorList.isDisposed()) { > fConsoleColorList.select(0); > handleAppearanceColorListSelection(); > } > } > }); > } >+ > /** > * @see org.eclipse.jface.preference.PreferencePage#performDefaults() > */ > protected void performDefaults() { > for (int i = 0; i < fAppearanceColorListModel.length; i++) { >- String key= fAppearanceColorListModel[i][1]; >- PreferenceConverter.setValue(getPreferenceStore(), key, PreferenceConverter.getDefaultColor(getPreferenceStore(), key)); >+ String key = fAppearanceColorListModel[i][1]; >+ PreferenceConverter.setValue(getPreferenceStore(), key, >+ PreferenceConverter.getDefaultColor(getPreferenceStore(), >+ key)); > } > handleAppearanceColorListSelection(); >- >+ > super.performDefaults(); > } >- >- /* (non-Javadoc) >+ >+ /* >+ * (non-Javadoc) >+ * > * @see org.eclipse.jface.dialogs.IDialogPage#dispose() > */ > public void dispose() { > getPreferenceStore().removePropertyChangeListener(this); > } > >- /* (non-Javadoc) >- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse >+ * .jface.util.PropertyChangeEvent) > */ > public void propertyChange(PropertyChangeEvent event) { >- if (event.getProperty().equals(IAntUIPreferenceConstants.ANT_TOOLS_JAR_WARNING)) { >+ if (event.getProperty().equals( >+ IAntUIPreferenceConstants.ANT_TOOLS_JAR_WARNING)) { > if (fToolsWarningEditor != null) { > fToolsWarningEditor.load(); > } >Index: Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditor.java,v >retrieving revision 1.115 >diff -u -r1.115 AntEditor.java >--- Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditor.java 24 Nov 2008 17:56:34 -0000 1.115 >+++ Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditor.java 25 Sep 2009 16:23:35 -0000 >@@ -23,8 +23,8 @@ > import java.util.Map; > import java.util.ResourceBundle; > >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.ant.internal.ui.AntUIPlugin; >-import org.eclipse.ant.internal.ui.AntUtil; > import org.eclipse.ant.internal.ui.ExternalHyperlink; > import org.eclipse.ant.internal.ui.IAntUIHelpContextIds; > import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants; >@@ -45,35 +45,21 @@ > import org.eclipse.ant.internal.ui.model.AntProjectNode; > import org.eclipse.ant.internal.ui.model.IAntModelListener; > import org.eclipse.ant.internal.ui.preferences.AntEditorPreferenceConstants; >- >-import org.eclipse.swt.custom.StyledText; >-import org.eclipse.swt.events.ShellAdapter; >-import org.eclipse.swt.events.ShellEvent; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Shell; >- >+import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.core.runtime.Status; > import org.eclipse.core.runtime.jobs.Job; >- >-import org.eclipse.core.resources.IFile; >- >+import org.eclipse.debug.ui.actions.IRunToLineTarget; >+import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; >+import org.eclipse.jdt.ui.JavaUI; >+import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds; > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.action.IMenuManager; > import org.eclipse.jface.action.Separator; > import org.eclipse.jface.preference.IPreferenceStore; >-import org.eclipse.jface.util.PropertyChangeEvent; >-import org.eclipse.jface.viewers.IPostSelectionProvider; >-import org.eclipse.jface.viewers.ISelection; >-import org.eclipse.jface.viewers.ISelectionChangedListener; >-import org.eclipse.jface.viewers.ISelectionProvider; >-import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.jface.viewers.SelectionChangedEvent; >- > import org.eclipse.jface.text.BadLocationException; > import org.eclipse.jface.text.DocumentEvent; > import org.eclipse.jface.text.IAutoEditStrategy; >@@ -99,7 +85,19 @@ > import org.eclipse.jface.text.source.projection.IProjectionListener; > import org.eclipse.jface.text.source.projection.ProjectionSupport; > import org.eclipse.jface.text.source.projection.ProjectionViewer; >- >+import org.eclipse.jface.util.PropertyChangeEvent; >+import org.eclipse.jface.viewers.IPostSelectionProvider; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.ISelectionChangedListener; >+import org.eclipse.jface.viewers.ISelectionProvider; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.SelectionChangedEvent; >+import org.eclipse.swt.custom.StyledText; >+import org.eclipse.swt.events.ShellAdapter; >+import org.eclipse.swt.events.ShellEvent; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Shell; > import org.eclipse.ui.IEditorInput; > import org.eclipse.ui.IPageLayout; > import org.eclipse.ui.IPartService; >@@ -107,24 +105,16 @@ > import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.IWorkbenchWindow; > import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.editors.text.TextEditor; > import org.eclipse.ui.ide.IDE; > import org.eclipse.ui.part.IShowInTargetList; >-import org.eclipse.ui.views.contentoutline.ContentOutline; >-import org.eclipse.ui.views.contentoutline.IContentOutlinePage; >- > import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; > import org.eclipse.ui.texteditor.IDocumentProvider; > import org.eclipse.ui.texteditor.IEditorStatusLine; > import org.eclipse.ui.texteditor.ITextEditorActionConstants; > import org.eclipse.ui.texteditor.TextOperationAction; >- >-import org.eclipse.ui.editors.text.TextEditor; >- >-import org.eclipse.debug.ui.actions.IRunToLineTarget; >-import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; >- >-import org.eclipse.jdt.ui.JavaUI; >-import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds; >+import org.eclipse.ui.views.contentoutline.ContentOutline; >+import org.eclipse.ui.views.contentoutline.IContentOutlinePage; > > /** > * The actual editor implementation for Eclipse's Ant integration. >@@ -906,7 +896,7 @@ > if (buildFile != null) { > buildFileParent= buildFile.getParentFile(); > } >- IFile file= AntUtil.getFileForLocation(path, buildFileParent); >+ IFile file= AntLaunchingUtil.getFileForLocation(path, buildFileParent); > if (file != null && file.exists()) { > try { > IWorkbenchPage p= getEditorSite().getPage(); >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.32 >diff -u -r1.32 MANIFEST.MF >--- META-INF/MANIFEST.MF 2 Sep 2009 16:14:59 -0000 1.32 >+++ META-INF/MANIFEST.MF 25 Sep 2009 16:23:43 -0000 >@@ -51,7 +51,8 @@ > org.eclipse.team.core;bundle-version="[3.2.0,4.0.0)", > org.eclipse.ltk.core.refactoring;bundle-version="[3.2.0,4.0.0)", > org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)", >- org.eclipse.jdt.junit;bundle-version="[3.5.0,4.0.0)" >+ org.eclipse.jdt.junit;bundle-version="[3.5.0,4.0.0)", >+ org.eclipse.ant.launching;bundle-version="1.0.0" > Bundle-ActivationPolicy: lazy > Import-Package: com.ibm.icu.text > Bundle-RequiredExecutionEnvironment: J2SE-1.4 >Index: Ant Runner Support/org/eclipse/ant/internal/ui/antsupport/logger/AntProcessBuildLogger.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Runner Support/org/eclipse/ant/internal/ui/antsupport/logger/AntProcessBuildLogger.java,v >retrieving revision 1.31 >diff -u -r1.31 AntProcessBuildLogger.java >--- Ant Runner Support/org/eclipse/ant/internal/ui/antsupport/logger/AntProcessBuildLogger.java 24 Apr 2007 03:42:29 -0000 1.31 >+++ Ant Runner Support/org/eclipse/ant/internal/ui/antsupport/logger/AntProcessBuildLogger.java 25 Sep 2009 16:23:35 -0000 >@@ -25,6 +25,7 @@ > import org.apache.tools.ant.Target; > import org.apache.tools.ant.util.FileUtils; > import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger; >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.ant.internal.ui.AntUtil; > import org.eclipse.ant.internal.ui.ExternalHyperlink; > import org.eclipse.ant.internal.ui.IAntUIConstants; >@@ -33,7 +34,6 @@ > import org.eclipse.ant.internal.ui.launchConfigurations.AntProcess; > import org.eclipse.ant.internal.ui.launchConfigurations.AntStreamMonitor; > import org.eclipse.ant.internal.ui.launchConfigurations.AntStreamsProxy; >-import org.eclipse.ant.internal.ui.launchConfigurations.TaskLinkManager; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.OperationCanceledException; > import org.eclipse.debug.core.DebugPlugin; >@@ -142,7 +142,7 @@ > IRegion region= new Region(offset, label.length() - 3); // only want the name length "[name] " > IHyperlink link= getLocationLink(location); > if (link != null) { >- TaskLinkManager.addTaskHyperlink(getAntProcess(fProcessId), link, region, newLine); >+ //TaskLinkManager.addTaskHyperlink(getAntProcess(fProcessId), link, region, newLine); > } > } > } >@@ -194,7 +194,7 @@ > if (file != null) { > return new FileLink(file, null, -1, -1, lineNumber); > } >- file= AntUtil.getFileForLocation(fileName, fBuildFileParent); >+ file= AntLaunchingUtil.getFileForLocation(fileName, fBuildFileParent); > if (file != null) { > fFileNameToIFile.put(fileName, file); > return new FileLink(file, null, -1, -1, lineNumber); >@@ -254,7 +254,7 @@ > while (line != null) { > logMessage(line, event, Project.MSG_ERR); > if (!message.startsWith("Total time:")) { //$NON-NLS-1$ >- AntUtil.linkBuildFailedMessage(line, antProcess); >+ AntLaunchingUtil.linkBuildFailedMessage(line, antProcess); > } > line = r.readLine(); > } >@@ -337,7 +337,7 @@ > IRegion region= new Region(0, targetName.length()); > IHyperlink link= getLocationLink(location); > if (link != null) { >- TaskLinkManager.addTaskHyperlink(getAntProcess(fProcessId), link, region, message.trim()); >+ //TaskLinkManager.addTaskHyperlink(getAntProcess(fProcessId), link, region, message.trim()); > } > } > logMessage(message, event, Project.MSG_INFO); >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/plugin.xml,v >retrieving revision 1.153 >diff -u -r1.153 plugin.xml >--- plugin.xml 4 May 2009 16:10:59 -0000 1.153 >+++ plugin.xml 25 Sep 2009 16:23:33 -0000 >@@ -24,48 +24,6 @@ > </editor> > </extension> > <extension >- point="org.eclipse.debug.core.launchConfigurationTypes"> >- <launchConfigurationType >- category="org.eclipse.ui.externaltools" >- delegate="org.eclipse.ant.internal.ui.launchConfigurations.AntLaunchDelegate" >- delegateDescription="%AntLaunchDelegate.description" >- delegateName="%AntLaunchDelegate.name" >- id="org.eclipse.ant.AntLaunchConfigurationType" >- migrationDelegate="org.eclipse.ant.internal.ui.launchConfigurations.AntMigrationDelegate" >- modes="run, debug" >- name="%AntBuild" >- sourceLocatorId="org.eclipse.ant.ui.debug.sourceLookupDirector" >- sourcePathComputerId="org.eclipse.ant.ui.debug.sourcePathComputer"> >- </launchConfigurationType> >- <launchConfigurationType >- category="org.eclipse.ui.externaltools.builder" >- delegate="org.eclipse.ant.internal.ui.launchConfigurations.AntLaunchDelegate" >- delegateDescription="%AntBuilderLaunchDelegate.description" >- delegateName="%AntBuilderLaunchDelegate.name" >- id="org.eclipse.ant.AntBuilderLaunchConfigurationType" >- modes="run" >- name="%AntBuilder.name"> >- </launchConfigurationType> >- </extension> >- <extension >- point="org.eclipse.jdt.launching.classpathProviders"> >- <classpathProvider >- class="org.eclipse.ant.internal.ui.launchConfigurations.AntClasspathProvider" >- id="org.eclipse.ant.ui.AntClasspathProvider"> >- </classpathProvider> >- </extension> >- <extension >- point="org.eclipse.jdt.launching.runtimeClasspathEntries"> >- <runtimeClasspathEntry >- class="org.eclipse.ant.internal.ui.launchConfigurations.AntHomeClasspathEntry" >- id="org.eclipse.ant.ui.classpathentry.antHome"> >- </runtimeClasspathEntry> >- <runtimeClasspathEntry >- class="org.eclipse.ant.internal.ui.launchConfigurations.ContributedClasspathEntriesEntry" >- id="org.eclipse.ant.ui.classpathentry.extraClasspathEntries"> >- </runtimeClasspathEntry> >- </extension> >- <extension > point="org.eclipse.ui.views"> > <category > name="%CategoryView.antViews" >@@ -553,13 +511,13 @@ > id="org.eclipse.ant.ui.statusHandler.runAntInit"> > </statusHandler> > </extension> >- <extension >+ <!--extension > point="org.eclipse.debug.core.processFactories"> > <processFactory > class="org.eclipse.ant.internal.ui.launchConfigurations.RemoteAntProcessFactory" > id="org.eclipse.ant.ui.remoteAntProcessFactory"> > </processFactory> >- </extension> >+ </extension--> > > <extension > point="org.eclipse.ui.editors.templates"> >Index: Ant Tools Support/org/eclipse/ant/internal/ui/views/AntViewDropAdapter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/AntViewDropAdapter.java,v >retrieving revision 1.7 >diff -u -r1.7 AntViewDropAdapter.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/views/AntViewDropAdapter.java 23 Feb 2005 17:31:21 -0000 1.7 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/views/AntViewDropAdapter.java 25 Sep 2009 16:23:43 -0000 >@@ -10,7 +10,7 @@ > *******************************************************************************/ > package org.eclipse.ant.internal.ui.views; > >-import org.eclipse.ant.internal.ui.AntUtil; >+import org.eclipse.ant.internal.launching.AntLaunchingUtil; > import org.eclipse.ant.internal.ui.model.AntProjectNode; > import org.eclipse.ant.internal.ui.model.AntProjectNodeProxy; > import org.eclipse.core.resources.IFile; >@@ -60,7 +60,7 @@ > * @param buildFileName the string to process > */ > private void processString(String buildFileName) { >- IFile buildFile = AntUtil.getFileForLocation(buildFileName, null); >+ IFile buildFile = AntLaunchingUtil.getFileForLocation(buildFileName, null); > if (buildFile == null || !buildFileName.toLowerCase().endsWith(".xml")) { //$NON-NLS-1$ > return; > } >#P org.eclipse.ui.externaltools >Index: Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramLaunchDelegate.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramLaunchDelegate.java,v >retrieving revision 1.38 >diff -u -r1.38 ProgramLaunchDelegate.java >--- Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramLaunchDelegate.java 30 Jul 2007 02:21:16 -0000 1.38 >+++ Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramLaunchDelegate.java 25 Sep 2009 16:23:50 -0000 >@@ -38,7 +38,7 @@ > import org.eclipse.ui.IWorkbenchWindow; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab; >-import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; >+import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil; > import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants; > > /** >@@ -103,21 +103,21 @@ > } > > // resolve location >- IPath location = ExternalToolsUtil.getLocation(configuration); >+ IPath location = ExternalToolsCoreUtil.getLocation(configuration); > > if (monitor.isCanceled()) { > return; > } > > // resolve working directory >- IPath workingDirectory = ExternalToolsUtil.getWorkingDirectory(configuration); >+ IPath workingDirectory = ExternalToolsCoreUtil.getWorkingDirectory(configuration); > > if (monitor.isCanceled()) { > return; > } > > // resolve arguments >- String[] arguments = ExternalToolsUtil.getArguments(configuration); >+ String[] arguments = ExternalToolsCoreUtil.getArguments(configuration); > > if (monitor.isCanceled()) { > return; >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.externaltools/META-INF/MANIFEST.MF,v >retrieving revision 1.15 >diff -u -r1.15 MANIFEST.MF >--- META-INF/MANIFEST.MF 14 May 2008 16:04:30 -0000 1.15 >+++ META-INF/MANIFEST.MF 25 Sep 2009 16:23:50 -0000 >@@ -19,6 +19,7 @@ > org.eclipse.ui;bundle-version="[3.2.0,4.0.0)", > org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)", > org.eclipse.debug.ui;bundle-version="[3.2.0,4.0.0)", >- org.eclipse.core.runtime;bundle-version="[3.1.0,4.0.0)" >+ org.eclipse.core.runtime;bundle-version="[3.1.0,4.0.0)", >+ org.eclipse.core.externaltools;bundle-version="1.0.0" > Bundle-ActivationPolicy: lazy > Bundle-RequiredExecutionEnvironment: J2SE-1.4 >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.externaltools/plugin.xml,v >retrieving revision 1.131 >diff -u -r1.131 plugin.xml >--- plugin.xml 4 May 2009 16:11:04 -0000 1.131 >+++ plugin.xml 25 Sep 2009 16:23:49 -0000 >@@ -112,23 +112,6 @@ > </extension> > <!-- Launch Configuration Extensions --> > <extension >- point="org.eclipse.debug.core.launchConfigurationTypes"> >- <launchConfigurationType >- name="%Program.externalTools" >- delegate="org.eclipse.ui.externaltools.internal.program.launchConfigurations.ProgramLaunchDelegate" >- category="org.eclipse.ui.externaltools" >- modes="run" >- id="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"> >- </launchConfigurationType> >- <launchConfigurationType >- name="%Program.externalTools" >- delegate="org.eclipse.ui.externaltools.internal.program.launchConfigurations.ProgramLaunchDelegate" >- category="org.eclipse.ui.externaltools.builder" >- modes="run" >- id="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType"> >- </launchConfigurationType> >- </extension> >- <extension > point="org.eclipse.ui.externaltools.configurationDuplicationMaps"> > <configurationMap > sourceType="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType" >Index: External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolBuilder.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolBuilder.java,v >retrieving revision 1.57 >diff -u -r1.57 ExternalToolBuilder.java >--- External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolBuilder.java 16 Apr 2007 23:46:04 -0000 1.57 >+++ External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolBuilder.java 25 Sep 2009 16:23:50 -0000 >@@ -29,7 +29,7 @@ > import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; > import org.eclipse.debug.core.ILaunchManager; > import org.eclipse.osgi.util.NLS; >-import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; >+import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil; > import org.eclipse.ui.externaltools.internal.registry.ExternalToolMigration; > import org.osgi.framework.Bundle; > >@@ -74,7 +74,7 @@ > throw ExternalToolsPlugin.newError(ExternalToolsModelMessages.ExternalToolBuilder_0, null); > } > IProject[] projectsWithinScope= null; >- IResource[] resources = ExternalToolsUtil.getResourcesForBuildScope(config); >+ IResource[] resources = ExternalToolsCoreUtil.getResourcesForBuildScope(config); > if (resources != null) { > projectsWithinScope= new IProject[resources.length]; > for (int i = 0; i < resources.length; i++) { >@@ -148,7 +148,7 @@ > */ > private boolean configEnabled(ILaunchConfiguration config) { > try { >- return ExternalToolsUtil.isBuilderEnabled(config); >+ return ExternalToolsCoreUtil.isBuilderEnabled(config); > } catch (CoreException e) { > ExternalToolsPlugin.getDefault().log(e); > } >Index: External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java,v >retrieving revision 1.43 >diff -u -r1.43 ExternalToolsPlugin.java >--- External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java 23 Feb 2005 16:02:16 -0000 1.43 >+++ External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java 25 Sep 2009 16:23:50 -0000 >@@ -10,19 +10,29 @@ > *******************************************************************************/ > package org.eclipse.ui.externaltools.internal.model; > >- > import java.net.MalformedURLException; > import java.net.URL; > > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationType; >+import org.eclipse.debug.core.ILaunchListener; >+import org.eclipse.debug.core.ILaunchManager; >+import org.eclipse.debug.internal.ui.views.console.ProcessConsoleManager; >+import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.resource.ImageRegistry; > import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.IWindowListener; > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.externaltools.internal.program.launchConfigurations.ExternalToolsProgramMessages; > import org.eclipse.ui.plugin.AbstractUIPlugin; > import org.osgi.framework.Bundle; > import org.osgi.framework.BundleContext; >@@ -30,15 +40,81 @@ > /** > * External tools plug-in class > */ >-public final class ExternalToolsPlugin extends AbstractUIPlugin { >+public final class ExternalToolsPlugin extends AbstractUIPlugin implements >+ ILaunchListener { > /** > * Status representing no problems encountered during operation. > */ >- public static final IStatus OK_STATUS = new Status(IStatus.OK, IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$ >+ public static final IStatus OK_STATUS = new Status(IStatus.OK, >+ IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$ > > private static ExternalToolsPlugin plugin; >- >- private static final String EMPTY_STRING= ""; //$NON-NLS-1$ >+ >+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$ >+ >+ private static IWindowListener fWindowListener; >+ >+ private static ILaunchManager launchManager; >+ >+ /** >+ * Singleton console document manager >+ */ >+ private ProcessConsoleManager fProcessConsoleManager = null; >+ >+ /** >+ * A window listener that warns the user about any running programs when the >+ * workbench closes. Programs are killed when the VM exits. >+ */ >+ private class ProgramLaunchWindowListener implements IWindowListener { >+ public void windowActivated(IWorkbenchWindow window) { >+ } >+ >+ public void windowDeactivated(IWorkbenchWindow window) { >+ } >+ >+ public void windowClosed(IWorkbenchWindow window) { >+ IWorkbenchWindow windows[] = PlatformUI.getWorkbench() >+ .getWorkbenchWindows(); >+ if (windows.length > 1) { >+ // There are more windows still open. >+ return; >+ } >+ ILaunchManager manager = DebugPlugin.getDefault() >+ .getLaunchManager(); >+ ILaunchConfigurationType programType = manager >+ .getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE); >+ if (programType == null) { >+ return; >+ } >+ ILaunch launches[] = manager.getLaunches(); >+ ILaunchConfigurationType configType; >+ ILaunchConfiguration config; >+ for (int i = 0; i < launches.length; i++) { >+ try { >+ config = launches[i].getLaunchConfiguration(); >+ if (config == null) { >+ continue; >+ } >+ configType = config.getType(); >+ } catch (CoreException e) { >+ continue; >+ } >+ if (configType.equals(programType)) { >+ if (!launches[i].isTerminated()) { >+ MessageDialog >+ .openWarning( >+ window.getShell(), >+ ExternalToolsProgramMessages.ProgramLaunchDelegate_Workbench_Closing_1, >+ ExternalToolsProgramMessages.ProgramLaunchDelegate_The_workbench_is_exiting); >+ break; >+ } >+ } >+ } >+ } >+ >+ public void windowOpened(IWorkbenchWindow window) { >+ } >+ } > > /** > * Create an instance of the External Tools plug-in. >@@ -49,8 +125,8 @@ > } > > /** >- * Returns the default instance of the receiver. >- * This represents the runtime plugin. >+ * Returns the default instance of the receiver. This represents the runtime >+ * plugin. > */ > public static ExternalToolsPlugin getDefault() { > return plugin; >@@ -61,32 +137,39 @@ > */ > public static IStatus newErrorStatus(String message, Throwable exception) { > if (message == null) { >- message= EMPTY_STRING; >- } >- return new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, message, exception); >+ message = EMPTY_STRING; >+ } >+ return new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, >+ message, exception); > } > > /** > * Returns a new <code>CoreException</code> for this plug-in > */ > public static CoreException newError(String message, Throwable exception) { >- return new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, message, exception)); >+ return new CoreException(new Status(IStatus.ERROR, >+ IExternalToolConstants.PLUGIN_ID, 0, message, exception)); > } > > /** > * Writes the message to the plug-in's log > * >- * @param message the text to write to the log >+ * @param message >+ * the text to write to the log > */ > public void log(String message, Throwable exception) { > IStatus status = newErrorStatus(message, exception); > getLog().log(status); > } >- >+ > public void log(Throwable exception) { >- //this message is intentionally not internationalized, as an exception may >+ // this message is intentionally not internationalized, as an exception >+ // may > // be due to the resource bundle itself >- getLog().log(newErrorStatus("Internal error logged from External Tools UI: ", exception)); //$NON-NLS-1$ >+ getLog() >+ .log( >+ newErrorStatus( >+ "Internal error logged from External Tools UI: ", exception)); //$NON-NLS-1$ > } > > /** >@@ -96,7 +179,7 @@ > */ > public ImageDescriptor getImageDescriptor(String path) { > try { >- Bundle bundle= getDefault().getBundle(); >+ Bundle bundle = getDefault().getBundle(); > URL installURL = bundle.getEntry("/"); //$NON-NLS-1$ > URL url = new URL(installURL, path); > return ImageDescriptor.createFromURL(url); >@@ -111,18 +194,18 @@ > public static IWorkbenchWindow getActiveWorkbenchWindow() { > return getDefault().getWorkbench().getActiveWorkbenchWindow(); > } >- >+ > /** > * Returns the active workbench page or <code>null</code> if none. > */ > public static IWorkbenchPage getActivePage() { >- IWorkbenchWindow window= getActiveWorkbenchWindow(); >+ IWorkbenchWindow window = getActiveWorkbenchWindow(); > if (window != null) { > return window.getActivePage(); > } > return null; > } >- >+ > /** > * Returns the active workbench shell or <code>null</code> if none. > */ >@@ -135,9 +218,9 @@ > } > > /** >- * Returns the standard display to be used. The method first checks, if >- * the thread calling this method has an associated display. If so, this >- * display is returned. Otherwise the method returns the default display. >+ * Returns the standard display to be used. The method first checks, if the >+ * thread calling this method has an associated display. If so, this display >+ * is returned. Otherwise the method returns the default display. > */ > public static Display getStandardDisplay() { > Display display = Display.getCurrent(); >@@ -147,15 +230,20 @@ > return display; > } > >- /* (non-Javadoc) >+ /* >+ * (non-Javadoc) >+ * > * @see org.eclipse.ui.plugin.AbstractUIPlugin#createImageRegistry() > */ > protected ImageRegistry createImageRegistry() { > return ExternalToolsImages.initializeImageRegistry(); > } > >- /* (non-Javadoc) >- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) > */ > public void stop(BundleContext context) throws Exception { > try { >@@ -164,4 +252,49 @@ > super.stop(context); > } > } >+ >+ public void start(BundleContext context) throws Exception { >+ super.start(context); >+ // Listen to launches to lazily create "launch processors" >+ launchManager = DebugPlugin.getDefault().getLaunchManager(); >+ ILaunch[] launches = launchManager.getLaunches(); >+ if (launches.length > 0) { >+ if (fWindowListener == null) { >+ fWindowListener = new ProgramLaunchWindowListener(); >+ PlatformUI.getWorkbench().addWindowListener(fWindowListener); >+ } >+ } else { >+ // if no launches, wait for first launch to initialize processors >+ launchManager.addLaunchListener(this); >+ } >+ } >+ >+ public void launchAdded(ILaunch launch) { >+ ILaunchConfiguration launchConfiguration = launch >+ .getLaunchConfiguration(); >+ try { >+ ILaunchConfigurationType launchConfigurationType = launchConfiguration >+ .getType(); >+ if (launchConfigurationType >+ .getIdentifier() >+ .equals( >+ IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE)) { >+ if (fWindowListener == null) { >+ fWindowListener = new ProgramLaunchWindowListener(); >+ PlatformUI.getWorkbench() >+ .addWindowListener(fWindowListener); >+ } >+ } >+ } catch (CoreException e) { >+ log(e); >+ } >+ } >+ >+ public void launchChanged(ILaunch launch) { >+ >+ } >+ >+ public void launchRemoved(ILaunch launch) { >+ launchManager.removeLaunch(launch); >+ } > } >Index: External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsUtil.java >=================================================================== >RCS file: External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsUtil.java >diff -N External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsUtil.java >--- External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsUtil.java 30 Jul 2007 02:21:16 -0000 1.47 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,203 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- * Keith Seitz (keiths@redhat.com) - Bug 27243 (environment variables contribution) >- * dakshinamurthy.karra@gmail.com - bug 165371 >- *******************************************************************************/ >-package org.eclipse.ui.externaltools.internal.launchConfigurations; >- >- >-import java.io.File; >- >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.core.runtime.Status; >-import org.eclipse.core.variables.IStringVariableManager; >-import org.eclipse.core.variables.VariablesPlugin; >-import org.eclipse.debug.core.DebugPlugin; >-import org.eclipse.debug.core.ILaunchConfiguration; >-import org.eclipse.debug.ui.RefreshTab; >-import org.eclipse.osgi.util.NLS; >-import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants; >- >-/** >- * Utilities for external tool launch configurations. >- * <p> >- * This class it not intended to be instantiated. >- * </p> >- */ >-public class ExternalToolsUtil { >- >- /** >- * Throws a core exception with an error status object built from >- * the given message, lower level exception, and error code. >- * >- * @param message the status message >- * @param exception lower level exception associated with the >- * error, or <code>null</code> if none >- * @param code error code >- */ >- protected static void abort(String message, Throwable exception, int code) throws CoreException { >- throw new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, code, message, exception)); >- } >- >- /** >- * Expands and returns the location attribute of the given launch >- * configuration. The location is >- * verified to point to an existing file, in the local file system. >- * >- * @param configuration launch configuration >- * @return an absolute path to a file in the local file system >- * @throws CoreException if unable to retrieve the associated launch >- * configuration attribute, if unable to resolve any variables, or if the >- * resolved location does not point to an existing file in the local file >- * system >- */ >- public static IPath getLocation(ILaunchConfiguration configuration) throws CoreException { >- String location = configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String) null); >- if (location == null) { >- abort(NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_Location_not_specified_by__0__1, new String[] { configuration.getName()}), null, 0); >- } else { >- String expandedLocation = getStringVariableManager().performStringSubstitution(location); >- if (expandedLocation == null || expandedLocation.length() == 0) { >- String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()}); >- abort(msg, null, 0); >- } else { >- File file = new File(expandedLocation); >- if (file.isFile()) { >- return new Path(expandedLocation); >- } >- >- String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()}); >- abort(msg, null, 0); >- } >- } >- // execution will not reach here >- return null; >- } >- >- /** >- * Returns a boolean specifying whether or not output should be captured for >- * the given configuration >- * >- * @param configuration the configuration from which the value will be >- * extracted >- * @return boolean specifying whether or not output should be captured >- * @throws CoreException if unable to access the associated attribute >- */ >- public static boolean getCaptureOutput(ILaunchConfiguration configuration) throws CoreException { >- return configuration.getAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true); >- } >- >- /** >- * Expands and returns the working directory attribute of the given launch >- * configuration. Returns <code>null</code> if a working directory is not >- * specified. If specified, the working is verified to point to an existing >- * directory in the local file system. >- * >- * @param configuration launch configuration >- * @return an absolute path to a directory in the local file system, or >- * <code>null</code> if unspecified >- * @throws CoreException if unable to retrieve the associated launch >- * configuration attribute, if unable to resolve any variables, or if the >- * resolved location does not point to an existing directory in the local >- * file system >- */ >- public static IPath getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException { >- String location = configuration.getAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) null); >- if (location != null) { >- String expandedLocation = getStringVariableManager().performStringSubstitution(location); >- if (expandedLocation.length() > 0) { >- File path = new File(expandedLocation); >- if (path.isDirectory()) { >- return new Path(expandedLocation); >- } >- String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidDirectory__0_, new Object[] { expandedLocation, configuration.getName()}); >- abort(msg, null, 0); >- } >- } >- return null; >- } >- >- /** >- * Expands and returns the arguments attribute of the given launch >- * configuration. Returns <code>null</code> if arguments are not specified. >- * >- * @param configuration launch configuration >- * @return an array of resolved arguments, or <code>null</code> if >- * unspecified >- * @throws CoreException if unable to retrieve the associated launch >- * configuration attribute, or if unable to resolve any variables >- */ >- public static String[] getArguments(ILaunchConfiguration configuration) throws CoreException { >- String args = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String) null); >- if (args != null) { >- String expanded = getStringVariableManager().performStringSubstitution(args); >- return parseStringIntoList(expanded); >- } >- return null; >- } >- >- private static IStringVariableManager getStringVariableManager() { >- return VariablesPlugin.getDefault().getStringVariableManager(); >- } >- >- /** >- * Returns whether the given launch configuration is enabled. This property >- * is intended only to apply to external tool builder configurations and >- * determines whether the project builder will launch the configuration >- * when it builds. >- * >- * @param configuration the configuration for which the enabled state should >- * be determined. >- * @return whether the given configuration is enabled to be run when a build occurs. >- * @throws CoreException if unable to access the associated attribute >- */ >- public static boolean isBuilderEnabled(ILaunchConfiguration configuration) throws CoreException { >- return configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_ENABLED, true); >- } >- >- /** >- * Returns the collection of resources for the build scope as specified by the given launch configuration. >- * >- * @param configuration launch configuration >- * @throws CoreException if an exception occurs while retrieving the resources >- */ >- public static IResource[] getResourcesForBuildScope(ILaunchConfiguration configuration) throws CoreException { >- String scope = configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_SCOPE, (String) null); >- if (scope == null) { >- return null; >- } >- >- return RefreshTab.getRefreshResources(scope); >- } >- >- /** >- * Parses the argument text into an array of individual >- * strings using the space character as the delimiter. >- * An individual argument containing spaces must have a >- * double quote (") at the start and end. Two double >- * quotes together is taken to mean an embedded double >- * quote in the argument text. >- * >- * @param arguments the arguments as one string >- * @return the array of arguments >- */ >- public static String[] parseStringIntoList(String arguments) { >- if (arguments == null || arguments.length() == 0) { >- return new String[0]; >- } >- String[] res= DebugPlugin.parseArguments(arguments); >- return res; >- } >- >-} >Index: External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuildTab.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuildTab.java,v >retrieving revision 1.1 >diff -u -r1.1 ExternalToolsBuildTab.java >--- External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuildTab.java 30 Jul 2007 02:21:16 -0000 1.1 >+++ External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuildTab.java 25 Sep 2009 16:23:49 -0000 >@@ -11,21 +11,18 @@ > *******************************************************************************/ > package org.eclipse.ui.externaltools.internal.launchConfigurations; > >- > import java.util.ArrayList; > import java.util.Iterator; > import java.util.List; > >+import org.eclipse.core.internal.externaltools.launchConfigurations.ExternalToolsCoreUtil; > import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.IWorkspace; >-import org.eclipse.core.resources.IWorkspaceRoot; > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; > import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; >-import org.eclipse.debug.ui.DebugUITools; > import org.eclipse.jface.viewers.IStructuredContentProvider; > import org.eclipse.jface.viewers.Viewer; > import org.eclipse.jface.window.Window; >@@ -45,79 +42,93 @@ > import org.eclipse.ui.model.WorkbenchLabelProvider; > > /** >- * A launch configuration tab which allows the user to specify >- * which resources should be built before a build (a build scope) >+ * A launch configuration tab which allows the user to specify which resources >+ * should be built before a build (a build scope) > * <p> >- * This class may be instantiated; this class is not intended >- * to be subclassed. >+ * This class may be instantiated; this class is not intended to be subclassed. > * </p> >- * A generalized version of AntBuildTab which was removed after the work of bug 165371 >+ * A generalized version of AntBuildTab which was removed after the work of bug >+ * 165371 >+ * > * @since 3.4 > */ > public class ExternalToolsBuildTab extends AbstractLaunchConfigurationTab { > // Check Buttons > private Button fBuildButton; >- >+ > // Group box > private Group fGroup; >- >+ > // Radio Buttons > private Button fProjectButton; > private Button fSpecificProjectsButton; > private Button fWorkspaceButton; >- >+ > // Push Button > private Button fSelectButton; >- >+ > // whether to include referenced projects > private Button fReferencedProjects; >- >+ > // projects to build (empty if none) > private List fProjects = new ArrayList(); >- >+ > class ProjectsContentProvider implements IStructuredContentProvider { > >- /* (non-Javadoc) >- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.jface.viewers.IStructuredContentProvider#getElements( >+ * java.lang.Object) > */ > public Object[] getElements(Object inputElement) { >- return ((IWorkspace)inputElement).getRoot().getProjects(); >+ return ((IWorkspace) inputElement).getRoot().getProjects(); > } > >- /* (non-Javadoc) >+ /* >+ * (non-Javadoc) >+ * > * @see org.eclipse.jface.viewers.IContentProvider#dispose() > */ > public void dispose() { > } > >- /* (non-Javadoc) >- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse >+ * .jface.viewers.Viewer, java.lang.Object, java.lang.Object) > */ > public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { > } >- >+ > } >+ > /** > * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) > */ > public void createControl(Composite parent) { > Composite mainComposite = new Composite(parent, SWT.NONE); > setControl(mainComposite); >- >+ > GridLayout layout = new GridLayout(); > GridData gd = new GridData(GridData.FILL_HORIZONTAL); > mainComposite.setLayout(layout); > mainComposite.setLayoutData(gd); > mainComposite.setFont(parent.getFont()); >- >- fBuildButton = createCheckButton(mainComposite, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_1); >+ >+ fBuildButton = createCheckButton( >+ mainComposite, >+ ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_1); > fBuildButton.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { > updateEnabledState(); > updateLaunchConfigurationDialog(); > } > }); >- >+ > fGroup = new Group(mainComposite, SWT.NONE); > fGroup.setFont(mainComposite.getFont()); > layout = new GridLayout(); >@@ -130,49 +141,65 @@ > > SelectionAdapter adapter = new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { >- if (((Button)e.getSource()).getSelection()) { >+ if (((Button) e.getSource()).getSelection()) { > updateEnabledState(); > updateLaunchConfigurationDialog(); > } > } > }; >- >- fWorkspaceButton = createRadioButton(fGroup, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_2); >+ >+ fWorkspaceButton = createRadioButton( >+ fGroup, >+ ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_2); > gd = new GridData(GridData.FILL_HORIZONTAL); > gd.horizontalSpan = 2; > fWorkspaceButton.setLayoutData(gd); > fWorkspaceButton.addSelectionListener(adapter); >- >- fProjectButton = createRadioButton(fGroup, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_3); >+ >+ fProjectButton = createRadioButton( >+ fGroup, >+ ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_3); > gd = new GridData(GridData.FILL_HORIZONTAL); > gd.horizontalSpan = 2; >- fProjectButton.setLayoutData(gd); >+ fProjectButton.setLayoutData(gd); > fProjectButton.addSelectionListener(adapter); >- >- fSpecificProjectsButton = createRadioButton(fGroup, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_4); >+ >+ fSpecificProjectsButton = createRadioButton( >+ fGroup, >+ ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_4); > gd = new GridData(GridData.FILL_HORIZONTAL); > gd.horizontalSpan = 1; > fSpecificProjectsButton.setLayoutData(gd); >- fSpecificProjectsButton.addSelectionListener(adapter); >- >- fSelectButton = createPushButton(fGroup, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_5, null); >- gd = (GridData)fSelectButton.getLayoutData(); >+ fSpecificProjectsButton.addSelectionListener(adapter); >+ >+ fSelectButton = createPushButton( >+ fGroup, >+ ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_5, >+ null); >+ gd = (GridData) fSelectButton.getLayoutData(); > gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END; > fSelectButton.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { > selectResources(); > } > }); >- >+ > createVerticalSpacer(mainComposite, 1); >- fReferencedProjects = createCheckButton(mainComposite, ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_6); >+ fReferencedProjects = createCheckButton( >+ mainComposite, >+ ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_6); > } > > /** > * Prompts the user to select the projects to build. > */ > private void selectResources() { >- ListSelectionDialog dialog = new ListSelectionDialog(getShell(), ResourcesPlugin.getWorkspace(), new ProjectsContentProvider(), new WorkbenchLabelProvider(), ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_7); >+ ListSelectionDialog dialog = new ListSelectionDialog( >+ getShell(), >+ ResourcesPlugin.getWorkspace(), >+ new ProjectsContentProvider(), >+ new WorkbenchLabelProvider(), >+ ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_7); > dialog.setInitialElementSelections(fProjects); > if (dialog.open() == Window.CANCEL) { > return; >@@ -184,7 +211,7 @@ > } > updateLaunchConfigurationDialog(); > } >- >+ > /** > * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) > */ >@@ -197,15 +224,18 @@ > public void initializeFrom(ILaunchConfiguration configuration) { > updateScope(configuration); > updateReferencedProjects(configuration); >- updateEnabledState(); >+ updateEnabledState(); > } >- >+ > private void updateReferencedProjects(ILaunchConfiguration configuration) { > boolean ref = false; > try { >- ref = configuration.getAttribute(IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS, true); >+ ref = configuration.getAttribute( >+ IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS, >+ true); > } catch (CoreException e) { >- ExternalToolsPlugin.getDefault().log("Exception reading launch configuration", e); //$NON-NLS-1$ >+ ExternalToolsPlugin.getDefault().log( >+ "Exception reading launch configuration", e); //$NON-NLS-1$ > } > fReferencedProjects.setSelection(ref); > } >@@ -216,9 +246,11 @@ > private void updateScope(ILaunchConfiguration configuration) { > String scope = null; > try { >- scope= configuration.getAttribute(IExternalToolConstants.ATTR_BUILD_SCOPE, (String)null); >+ scope = configuration.getAttribute( >+ IExternalToolConstants.ATTR_BUILD_SCOPE, (String) null); > } catch (CoreException ce) { >- ExternalToolsPlugin.getDefault().log("Exception reading launch configuration", ce); //$NON-NLS-1$ >+ ExternalToolsPlugin.getDefault().log( >+ "Exception reading launch configuration", ce); //$NON-NLS-1$ > } > fBuildButton.setSelection(scope != null); > fWorkspaceButton.setSelection(false); >@@ -236,7 +268,8 @@ > fProjectButton.setSelection(true); > } else if (scope.startsWith("${projects:")) { //$NON-NLS-1$ > fSpecificProjectsButton.setSelection(true); >- IProject[] projects = getBuildProjects(configuration, IExternalToolConstants.ATTR_BUILD_SCOPE); >+ IProject[] projects = getBuildProjects(configuration, >+ IExternalToolConstants.ATTR_BUILD_SCOPE); > fProjects = new ArrayList(projects.length); > for (int i = 0; i < projects.length; i++) { > fProjects.add(projects[i]); >@@ -244,17 +277,23 @@ > } > } > } >+ > /** > * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) > */ > public void performApply(ILaunchConfigurationWorkingCopy configuration) { > String scope = generateScopeMemento(); >- configuration.setAttribute(IExternalToolConstants.ATTR_BUILD_SCOPE, scope); >+ configuration.setAttribute(IExternalToolConstants.ATTR_BUILD_SCOPE, >+ scope); > if (fReferencedProjects.getSelection()) { > // default is true >- configuration.setAttribute(IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS, (String)null); >+ configuration.setAttribute( >+ IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS, >+ (String) null); > } else { >- configuration.setAttribute(IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS, false); >+ configuration.setAttribute( >+ IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS, >+ false); > } > } > >@@ -273,7 +312,7 @@ > return getBuildScopeAttribute(fProjects); > } > return null; >- >+ > } > return "${none}"; //$NON-NLS-1$ > } >@@ -284,106 +323,87 @@ > public String getName() { > return ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_8; > } >- >+ > /** > * Updates the enablement state of the fields. > */ > private void updateEnabledState() { >- boolean enabled= fBuildButton.getSelection(); >+ boolean enabled = fBuildButton.getSelection(); > fGroup.setEnabled(enabled); > fWorkspaceButton.setEnabled(enabled); > fProjectButton.setEnabled(enabled); > fSpecificProjectsButton.setEnabled(enabled); >- fSelectButton.setEnabled(enabled && fSpecificProjectsButton.getSelection()); >+ fSelectButton.setEnabled(enabled >+ && fSpecificProjectsButton.getSelection()); > if (!enabled) { > super.setErrorMessage(null); > } > if (enabled) { >- if (!fWorkspaceButton.getSelection() && !fProjectButton.getSelection() && >- !fSpecificProjectsButton.getSelection()) { >+ if (!fWorkspaceButton.getSelection() >+ && !fProjectButton.getSelection() >+ && !fSpecificProjectsButton.getSelection()) { > fWorkspaceButton.setSelection(true); > } > } >- fReferencedProjects.setEnabled(fBuildButton.getSelection() && (fProjectButton.getSelection() || fSpecificProjectsButton.getSelection())); >+ fReferencedProjects.setEnabled(fBuildButton.getSelection() >+ && (fProjectButton.getSelection() || fSpecificProjectsButton >+ .getSelection())); > } >- >+ > /** > * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage() > */ > public Image getImage() { >- return ExternalToolsImages.getImage(IExternalToolConstants.IMG_TAB_BUILD); >+ return ExternalToolsImages >+ .getImage(IExternalToolConstants.IMG_TAB_BUILD); > } > > public boolean isValid(ILaunchConfiguration launchConfig) { > setErrorMessage(null); > setMessage(null); >- if (fBuildButton.getSelection() && fSpecificProjectsButton.getSelection() && fProjects.isEmpty()) { >+ if (fBuildButton.getSelection() >+ && fSpecificProjectsButton.getSelection() >+ && fProjects.isEmpty()) { > setErrorMessage(ExternalToolsLaunchConfigurationMessages.ExternalToolsBuildTab_9); > return false; > } > return true; > } >- >+ > /** > * Returns a collection of projects referenced by a build scope attribute. > * > * @return collection of projects referred to by configuration > */ >- public static IProject[] getBuildProjects(ILaunchConfiguration configuration, String buildScopeId) { >- String scope = null; >- String id = buildScopeId ; >- if (id == null) { >- id = IExternalToolConstants.ATTR_BUILD_SCOPE ; >- } >- try { >- scope = configuration.getAttribute(id, (String)null); >- } catch (CoreException e) { >- return null; >- } >- if (scope == null) { >- return null; >- } >- if (scope.startsWith("${projects:")) { //$NON-NLS-1$ >- String pathString = scope.substring(11, scope.length() - 1); >- if (pathString.length() > 1) { >- String[] names = pathString.split(","); //$NON-NLS-1$ >- IProject[] projects = new IProject[names.length]; >- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >- for (int i = 0; i < names.length; i++) { >- projects[i] = root.getProject(names[i]); >- } >- return projects; >- } >- } else if (scope.equals("${project}")) { //$NON-NLS-1$ >- IResource resource = DebugUITools.getSelectedResource(); >- if (resource != null) { >- return new IProject[]{resource.getProject()}; >- } >- } >- return new IProject[0]; >+ public static IProject[] getBuildProjects( >+ ILaunchConfiguration configuration, String buildScopeId) { >+ return ExternalToolsCoreUtil.getBuildProjects(configuration, >+ buildScopeId); >+ > } >- >+ > /** >- * Whether referenced projects should be considered when building. Only valid >- * when a set of projects is to be built. >+ * Whether referenced projects should be considered when building. Only >+ * valid when a set of projects is to be built. > * > * @param configuration > * @return whether referenced projects should be considerd when building >- * @throws CoreException if unable to access the associated attribute >+ * @throws CoreException >+ * if unable to access the associated attribute > */ >- public static boolean isIncludeReferencedProjects(ILaunchConfiguration configuration, String includeReferencedProjectsId) throws CoreException { >- String id = includeReferencedProjectsId; >- if (id == null) { >- id = IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS ; >- } >- return configuration.getAttribute(id, true); >+ public static boolean isIncludeReferencedProjects( >+ ILaunchConfiguration configuration, >+ String includeReferencedProjectsId) throws CoreException { >+ return ExternalToolsCoreUtil.isIncludeReferencedProjects(configuration, >+ includeReferencedProjectsId); > } >- >+ > /** > * Creates and returns a memento for the given project set, to be used as a > * build scope attribute. > * >- * @param projects list of projects >+ * @param projects >+ * list of projects > * @return an equivalent refresh attribute > */ > public static String getBuildScopeAttribute(List projects) { >@@ -400,16 +420,24 @@ > buf.append("}"); //$NON-NLS-1$ > return buf.toString(); > } >- >- /* (non-Javadoc) >- * @see org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug >+ * .core.ILaunchConfigurationWorkingCopy) > */ > public void activated(ILaunchConfigurationWorkingCopy workingCopy) { > // do nothing on activation > } > >- /* (non-Javadoc) >- * @see org.eclipse.debug.ui.ILaunchConfigurationTab#deactivated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.debug.ui.ILaunchConfigurationTab#deactivated(org.eclipse. >+ * debug.core.ILaunchConfigurationWorkingCopy) > */ > public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) { > // do nothing on deactivation >Index: External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java,v >retrieving revision 1.102 >diff -u -r1.102 BuilderPropertyPage.java >--- External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java 3 Feb 2009 14:36:22 -0000 1.102 >+++ External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java 25 Sep 2009 16:23:50 -0000 >@@ -75,7 +75,7 @@ > import org.eclipse.ui.dialogs.ElementListSelectionDialog; > import org.eclipse.ui.dialogs.PropertyPage; > import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsMainTab; >-import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; >+import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil; > import org.eclipse.ui.externaltools.internal.launchConfigurations.IgnoreWhiteSpaceComparator; > import org.eclipse.ui.externaltools.internal.model.BuilderUtils; > import org.eclipse.ui.externaltools.internal.model.ExternalToolBuilder; >@@ -858,7 +858,7 @@ > } > } else if (element instanceof ILaunchConfiguration) { > try { >- return ExternalToolsUtil.isBuilderEnabled((ILaunchConfiguration) element); >+ return ExternalToolsCoreUtil.isBuilderEnabled((ILaunchConfiguration) element); > } catch (CoreException e) { > } > } else if (element instanceof ErrorConfig) { >@@ -985,7 +985,7 @@ > String disabledBuilderName; > try { > disabledBuilderName = config.getAttribute(IExternalToolConstants.ATTR_DISABLED_BUILDER, (String)null); >- if (disabledBuilderName != null && ExternalToolsUtil.isBuilderEnabled(config)) { >+ if (disabledBuilderName != null && ExternalToolsCoreUtil.isBuilderEnabled(config)) { > possibleCommands.add(translateBackToCommand(config, project)); > continue; > } >Index: External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsCoreUtil.java >=================================================================== >RCS file: External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsCoreUtil.java >diff -N External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsCoreUtil.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsCoreUtil.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,203 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Keith Seitz (keiths@redhat.com) - Bug 27243 (environment variables contribution) >+ * dakshinamurthy.karra@gmail.com - bug 165371 >+ *******************************************************************************/ >+package org.eclipse.ui.externaltools.internal.launchConfigurations; >+ >+ >+import java.io.File; >+ >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.variables.IStringVariableManager; >+import org.eclipse.core.variables.VariablesPlugin; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.ui.RefreshTab; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants; >+ >+/** >+ * Utilities for external tool launch configurations. >+ * <p> >+ * This class it not intended to be instantiated. >+ * </p> >+ */ >+public class ExternalToolsCoreUtil { >+ >+ /** >+ * Throws a core exception with an error status object built from >+ * the given message, lower level exception, and error code. >+ * >+ * @param message the status message >+ * @param exception lower level exception associated with the >+ * error, or <code>null</code> if none >+ * @param code error code >+ */ >+ protected static void abort(String message, Throwable exception, int code) throws CoreException { >+ throw new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, code, message, exception)); >+ } >+ >+ /** >+ * Expands and returns the location attribute of the given launch >+ * configuration. The location is >+ * verified to point to an existing file, in the local file system. >+ * >+ * @param configuration launch configuration >+ * @return an absolute path to a file in the local file system >+ * @throws CoreException if unable to retrieve the associated launch >+ * configuration attribute, if unable to resolve any variables, or if the >+ * resolved location does not point to an existing file in the local file >+ * system >+ */ >+ public static IPath getLocation(ILaunchConfiguration configuration) throws CoreException { >+ String location = configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String) null); >+ if (location == null) { >+ abort(NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_Location_not_specified_by__0__1, new String[] { configuration.getName()}), null, 0); >+ } else { >+ String expandedLocation = getStringVariableManager().performStringSubstitution(location); >+ if (expandedLocation == null || expandedLocation.length() == 0) { >+ String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()}); >+ abort(msg, null, 0); >+ } else { >+ File file = new File(expandedLocation); >+ if (file.isFile()) { >+ return new Path(expandedLocation); >+ } >+ >+ String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()}); >+ abort(msg, null, 0); >+ } >+ } >+ // execution will not reach here >+ return null; >+ } >+ >+ /** >+ * Returns a boolean specifying whether or not output should be captured for >+ * the given configuration >+ * >+ * @param configuration the configuration from which the value will be >+ * extracted >+ * @return boolean specifying whether or not output should be captured >+ * @throws CoreException if unable to access the associated attribute >+ */ >+ public static boolean getCaptureOutput(ILaunchConfiguration configuration) throws CoreException { >+ return configuration.getAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true); >+ } >+ >+ /** >+ * Expands and returns the working directory attribute of the given launch >+ * configuration. Returns <code>null</code> if a working directory is not >+ * specified. If specified, the working is verified to point to an existing >+ * directory in the local file system. >+ * >+ * @param configuration launch configuration >+ * @return an absolute path to a directory in the local file system, or >+ * <code>null</code> if unspecified >+ * @throws CoreException if unable to retrieve the associated launch >+ * configuration attribute, if unable to resolve any variables, or if the >+ * resolved location does not point to an existing directory in the local >+ * file system >+ */ >+ public static IPath getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException { >+ String location = configuration.getAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) null); >+ if (location != null) { >+ String expandedLocation = getStringVariableManager().performStringSubstitution(location); >+ if (expandedLocation.length() > 0) { >+ File path = new File(expandedLocation); >+ if (path.isDirectory()) { >+ return new Path(expandedLocation); >+ } >+ String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidDirectory__0_, new Object[] { expandedLocation, configuration.getName()}); >+ abort(msg, null, 0); >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * Expands and returns the arguments attribute of the given launch >+ * configuration. Returns <code>null</code> if arguments are not specified. >+ * >+ * @param configuration launch configuration >+ * @return an array of resolved arguments, or <code>null</code> if >+ * unspecified >+ * @throws CoreException if unable to retrieve the associated launch >+ * configuration attribute, or if unable to resolve any variables >+ */ >+ public static String[] getArguments(ILaunchConfiguration configuration) throws CoreException { >+ String args = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String) null); >+ if (args != null) { >+ String expanded = getStringVariableManager().performStringSubstitution(args); >+ return parseStringIntoList(expanded); >+ } >+ return null; >+ } >+ >+ private static IStringVariableManager getStringVariableManager() { >+ return VariablesPlugin.getDefault().getStringVariableManager(); >+ } >+ >+ /** >+ * Returns whether the given launch configuration is enabled. This property >+ * is intended only to apply to external tool builder configurations and >+ * determines whether the project builder will launch the configuration >+ * when it builds. >+ * >+ * @param configuration the configuration for which the enabled state should >+ * be determined. >+ * @return whether the given configuration is enabled to be run when a build occurs. >+ * @throws CoreException if unable to access the associated attribute >+ */ >+ public static boolean isBuilderEnabled(ILaunchConfiguration configuration) throws CoreException { >+ return configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_ENABLED, true); >+ } >+ >+ /** >+ * Returns the collection of resources for the build scope as specified by the given launch configuration. >+ * >+ * @param configuration launch configuration >+ * @throws CoreException if an exception occurs while retrieving the resources >+ */ >+ public static IResource[] getResourcesForBuildScope(ILaunchConfiguration configuration) throws CoreException { >+ String scope = configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_SCOPE, (String) null); >+ if (scope == null) { >+ return null; >+ } >+ >+ return RefreshTab.getRefreshResources(scope); >+ } >+ >+ /** >+ * Parses the argument text into an array of individual >+ * strings using the space character as the delimiter. >+ * An individual argument containing spaces must have a >+ * double quote (") at the start and end. Two double >+ * quotes together is taken to mean an embedded double >+ * quote in the argument text. >+ * >+ * @param arguments the arguments as one string >+ * @return the array of arguments >+ */ >+ public static String[] parseStringIntoList(String arguments) { >+ if (arguments == null || arguments.length() == 0) { >+ return new String[0]; >+ } >+ String[] res= DebugPlugin.parseArguments(arguments); >+ return res; >+ } >+ >+} >#P org.eclipse.ant.core >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.core/META-INF/MANIFEST.MF,v >retrieving revision 1.19 >diff -u -r1.19 MANIFEST.MF >--- META-INF/MANIFEST.MF 26 Jun 2008 19:01:12 -0000 1.19 >+++ META-INF/MANIFEST.MF 25 Sep 2009 16:24:00 -0000 >@@ -7,7 +7,7 @@ > Bundle-Vendor: %providerName > Bundle-Localization: plugin > Export-Package: org.eclipse.ant.core, >- org.eclipse.ant.internal.core;x-friends:="org.eclipse.ant.ui", >+ org.eclipse.ant.internal.core;x-friends:="org.eclipse.ant.ui,org.eclipse.ant.launching", > org.eclipse.ant.internal.core.contentDescriber;x-internal:=true > Require-Bundle: org.eclipse.core.variables;bundle-version="[3.1.0,4.0.0)", > org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)"
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 264338
:
148142
|
148349
|
148353
|
148443
|
148455
|
148459
|
148730
|
148864
|
148946
|
149050