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

(-)core/org/eclipse/debug/internal/core/LaunchManager.java (-14 / +24 lines)
Lines 19-25 Link Here
19
import java.io.File;
19
import java.io.File;
20
import java.io.FileInputStream;
20
import java.io.FileInputStream;
21
import java.io.FileNotFoundException;
21
import java.io.FileNotFoundException;
22
import java.io.FilenameFilter;
23
import java.io.IOException;
22
import java.io.IOException;
24
import java.io.InputStream;
23
import java.io.InputStream;
25
import java.io.InputStreamReader;
24
import java.io.InputStreamReader;
Lines 65-70 Link Here
65
import org.eclipse.core.runtime.ISafeRunnable;
64
import org.eclipse.core.runtime.ISafeRunnable;
66
import org.eclipse.core.runtime.IStatus;
65
import org.eclipse.core.runtime.IStatus;
67
import org.eclipse.core.runtime.ListenerList;
66
import org.eclipse.core.runtime.ListenerList;
67
import org.eclipse.core.runtime.Path;
68
import org.eclipse.core.runtime.Platform;
68
import org.eclipse.core.runtime.Platform;
69
import org.eclipse.core.runtime.PlatformObject;
69
import org.eclipse.core.runtime.PlatformObject;
70
import org.eclipse.core.runtime.Preferences;
70
import org.eclipse.core.runtime.Preferences;
Lines 931-951 Link Here
931
		List configs = new ArrayList(10);
931
		List configs = new ArrayList(10);
932
		final File directory = containerPath.toFile();
932
		final File directory = containerPath.toFile();
933
		if (directory.isDirectory()) {
933
		if (directory.isDirectory()) {
934
			FilenameFilter filter = new FilenameFilter() {
934
			traverse(directory, configs);
935
				public boolean accept(File dir, String name) {
936
					return dir.equals(directory) &&
937
							name.endsWith(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION);
938
				}
939
			};
940
			String[] files = directory.list(filter);
941
			LaunchConfiguration config = null;
942
			for (int i = 0; i < files.length; i++) {
943
				config = new LaunchConfiguration(containerPath.append(files[i]));
944
				configs.add(config);
945
			}
946
		}
935
		}
947
		return configs;
936
		return configs;
948
	}
937
	}
938
	
939
	private void traverse(File directory, List configs) {
940
		File[] files = directory.listFiles();
941
		for (int i = 0; i < files.length; i++) {
942
			File file = files[i];
943
			if (file.isDirectory()) {
944
				traverse(file, configs);
945
			} else {
946
				if (file.getName().endsWith(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION)) {
947
					configs.add(new LaunchConfiguration(new Path(file.toString())));
948
				}
949
			}
950
		}
951
	}
949
		
952
		
950
	/**
953
	/**
951
	 * Fires notification to (single) listeners that a launch has been
954
	 * Fires notification to (single) listeners that a launch has been
Lines 2312-2316 Link Here
2312
            }
2315
            }
2313
        }
2316
        }
2314
        return title;
2317
        return title;
2315
    }	
2318
    }
2319
2320
	/* (non-Javadoc)
2321
	 * @see org.eclipse.debug.core.ILaunchManager#getLaunchConfiguration(org.eclipse.core.runtime.IPath)
2322
	 */
2323
	public ILaunchConfiguration getLaunchConfiguration(IPath location) {
2324
		return new LaunchConfiguration(location);
2325
	}	
2316
}
2326
}
(-)core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java (-22 / +17 lines)
Lines 486-502 Link Here
486
	 * @see ILaunchConfiguration#getLocation()
486
	 * @see ILaunchConfiguration#getLocation()
487
	 */
487
	 */
488
	public IPath getLocation() {
488
	public IPath getLocation() {
489
		if (isMoved()) {
489
		IPath path = null;
490
			IPath path = null;
490
		if (isLocal()) {
491
			if (isLocal()) {
491
			path = LaunchManager.LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH;
492
				path = LaunchManager.LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH;
492
			try {
493
			} else {
493
				IResource[] resources = getMappedResources();
494
				path = getContainer().getLocation();
494
				if (resources != null && resources.length > 0) {
495
					IResource resource = resources[0];
496
					path = path.append(resource.getFullPath());
497
				}
498
			} catch (CoreException e) {
499
				DebugPlugin.log(e.getStatus());
495
			}
500
			}
496
			path = path.append(getName() + "." + LAUNCH_CONFIGURATION_FILE_EXTENSION); //$NON-NLS-1$
501
		} else {
497
			return path;
502
			path = getContainer().getLocation();
498
		} 
503
		}
499
		return getOriginal().getLocation();
504
		path = path.append(getName() + "." + LAUNCH_CONFIGURATION_FILE_EXTENSION); //$NON-NLS-1$
505
		return path;
500
	}
506
	}
501
	
507
	
502
	/**
508
	/**
Lines 518-535 Link Here
518
	 * location has changed from that of its original
524
	 * location has changed from that of its original
519
	 */
525
	 */
520
	protected boolean isMoved() {
526
	protected boolean isMoved() {
521
		if (isNew() || fRenamed) {
527
		return isNew() || !getLocation().equals(getOriginal().getLocation());
522
			return true;
523
		}
524
		IContainer newContainer = getContainer();
525
		IContainer originalContainer = ((LaunchConfiguration)getOriginal()).getContainer();
526
		if (newContainer == originalContainer) {
527
			return false;
528
		}
529
		if (newContainer == null) {
530
			return !originalContainer.equals(newContainer);
531
		} 
532
		return !newContainer.equals(originalContainer);
533
	}		
528
	}		
534
	
529
	
535
	/**
530
	/**
(-)core/org/eclipse/debug/core/ILaunchManager.java (+11 lines)
Lines 15-20 Link Here
15
15
16
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.IPath;
18
import org.eclipse.debug.core.model.IDebugTarget;
19
import org.eclipse.debug.core.model.IDebugTarget;
19
import org.eclipse.debug.core.model.IPersistableSourceLocator;
20
import org.eclipse.debug.core.model.IPersistableSourceLocator;
20
import org.eclipse.debug.core.model.IProcess;
21
import org.eclipse.debug.core.model.IProcess;
Lines 459-464 Link Here
459
	 */
460
	 */
460
	public void removeLaunchListener(ILaunchListener listener);
461
	public void removeLaunchListener(ILaunchListener listener);
461
	
462
	
463
	/**
464
	 * Returns the launch configuration at the specified location. The configuration
465
	 * may or may not exist. The location is full path in the workspace or a path
466
	 * in the location file system.
467
	 * 
468
	 * @param location full workspace path or local file system path
469
	 * @return launch configuration that may or may not exist
470
	 * @since 3.3
471
	 */
472
	public ILaunchConfiguration getLaunchConfiguration(IPath location);
462
}
473
}
463
474
464
475
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java (-7 / +10 lines)
Lines 1236-1248 Link Here
1236
			}
1236
			}
1237
	
1237
	
1238
			// Otherwise, if there's already a config with the same name, complain
1238
			// Otherwise, if there's already a config with the same name, complain
1239
			if (!getOriginal().getName().equals(currentName)) {
1239
			if (!getOriginal().getLocation().equals(getWorkingCopy().getLocation())) {
1240
				if (DebugPlugin.getDefault().getLaunchManager().isExistingLaunchConfigurationName(currentName)) {
1240
				if (DebugPlugin.getDefault().getLaunchManager().getLaunchConfiguration(
1241
					throw new CoreException(new Status(IStatus.ERROR,
1241
						getWorkingCopy().getLocation()).exists()) {
1242
														 DebugUIPlugin.getUniqueIdentifier(),
1242
					if (DebugPlugin.getDefault().getLaunchManager().isExistingLaunchConfigurationName(currentName)) {
1243
														 0,
1243
						throw new CoreException(new Status(IStatus.ERROR,
1244
														 LaunchConfigurationsMessages.LaunchConfigurationDialog_Launch_configuration_already_exists_with_this_name_12, 
1244
															 DebugUIPlugin.getUniqueIdentifier(),
1245
														 null));
1245
															 0,
1246
															 LaunchConfigurationsMessages.LaunchConfigurationDialog_Launch_configuration_already_exists_with_this_name_12, 
1247
															 null));
1248
					}
1246
				}
1249
				}
1247
			}
1250
			}
1248
		}
1251
		}

Return to bug 59289