|
Lines 290-295
Link Here
|
| 290 |
} |
290 |
} |
| 291 |
|
291 |
|
| 292 |
/** |
292 |
/** |
|
|
293 |
* Visitor for handling a resource begin deleted, and the need to check mapped configurations |
| 294 |
* for auto-deletion |
| 295 |
* @since 3.4 |
| 296 |
*/ |
| 297 |
class MappedResourceVisitor implements IResourceDeltaVisitor { |
| 298 |
|
| 299 |
/* (non-Javadoc) |
| 300 |
* @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta) |
| 301 |
*/ |
| 302 |
public boolean visit(IResourceDelta delta) throws CoreException { |
| 303 |
if(delta.getKind() == IResourceDelta.REMOVED && delta.getFlags() != IResourceDelta.MOVED_TO) { |
| 304 |
if (isDeleteConfigurations()) { |
| 305 |
ArrayList configs = collectAssociatedLaunches(delta.getResource()); |
| 306 |
if(configs.size() > 0) { |
| 307 |
for(Iterator iter = configs.iterator(); iter.hasNext();) { |
| 308 |
try { |
| 309 |
((ILaunchConfiguration)iter.next()).delete(); |
| 310 |
} catch (CoreException e) { |
| 311 |
DebugPlugin.log(e.getStatus()); |
| 312 |
} |
| 313 |
} |
| 314 |
} |
| 315 |
} |
| 316 |
return false; |
| 317 |
} |
| 318 |
return true; |
| 319 |
} |
| 320 |
} |
| 321 |
|
| 322 |
/** |
| 293 |
* Visitor for handling resource deltas. |
323 |
* Visitor for handling resource deltas. |
| 294 |
*/ |
324 |
*/ |
| 295 |
class LaunchManagerVisitor implements IResourceDeltaVisitor { |
325 |
class LaunchManagerVisitor implements IResourceDeltaVisitor { |
|
Lines 335-341
Link Here
|
| 335 |
if (0 != (delta.getFlags() & IResourceDelta.OPEN)) { |
365 |
if (0 != (delta.getFlags() & IResourceDelta.OPEN)) { |
| 336 |
if (delta.getResource() instanceof IProject) { |
366 |
if (delta.getResource() instanceof IProject) { |
| 337 |
IProject project = (IProject)delta.getResource(); |
367 |
IProject project = (IProject)delta.getResource(); |
| 338 |
|
|
|
| 339 |
if (project.isOpen()) { |
368 |
if (project.isOpen()) { |
| 340 |
LaunchManager.this.projectOpened(project); |
369 |
LaunchManager.this.projectOpened(project); |
| 341 |
} else { |
370 |
} else { |
|
Lines 371-392
Link Here
|
| 371 |
} |
400 |
} |
| 372 |
} |
401 |
} |
| 373 |
return false; |
402 |
return false; |
| 374 |
} else if (resource instanceof IProject) { |
|
|
| 375 |
if (isDeleteConfigurations()) { |
| 376 |
if(delta.getKind() == IResourceDelta.REMOVED && delta.getFlags() != IResourceDelta.MOVED_TO) { |
| 377 |
IProject project = (IProject) resource; |
| 378 |
ArrayList configs = collectAssociatedLaunches(project); |
| 379 |
if(configs.size() > 0) { |
| 380 |
for(Iterator iter = configs.iterator(); iter.hasNext();) { |
| 381 |
try { |
| 382 |
((ILaunchConfiguration)iter.next()).delete(); |
| 383 |
} catch (CoreException e) { |
| 384 |
DebugPlugin.log(e.getStatus()); |
| 385 |
} |
| 386 |
} |
| 387 |
} |
| 388 |
} |
| 389 |
} |
| 390 |
} |
403 |
} |
| 391 |
return true; |
404 |
return true; |
| 392 |
} |
405 |
} |
|
Lines 631-636
Link Here
|
| 631 |
private LaunchManagerVisitor fgVisitor; |
644 |
private LaunchManagerVisitor fgVisitor; |
| 632 |
|
645 |
|
| 633 |
/** |
646 |
/** |
|
|
647 |
* Visitor used to process a deleted resource, |
| 648 |
* to remove mapped launch configurations in the event |
| 649 |
* auto-removal of launch configurations is enabled |
| 650 |
* |
| 651 |
* @since 3.4 |
| 652 |
*/ |
| 653 |
private MappedResourceVisitor fgMRVisitor; |
| 654 |
|
| 655 |
/** |
| 634 |
* Whether this manager is listening for resource change events |
656 |
* Whether this manager is listening for resource change events |
| 635 |
*/ |
657 |
*/ |
| 636 |
private boolean fListening = false; |
658 |
private boolean fListening = false; |
|
Lines 1179-1184
Link Here
|
| 1179 |
return fgVisitor; |
1201 |
return fgVisitor; |
| 1180 |
} |
1202 |
} |
| 1181 |
|
1203 |
|
|
|
1204 |
/** |
| 1205 |
* Returns the resource delta visitor for auto-removal of mapped launch configurations |
| 1206 |
* @return the resource delta visitor for auto-removal of mapped launch configurations |
| 1207 |
* |
| 1208 |
* @since 3.4 |
| 1209 |
*/ |
| 1210 |
private MappedResourceVisitor getMappedResourceVisitor() { |
| 1211 |
if(fgMRVisitor == null) { |
| 1212 |
fgMRVisitor = new MappedResourceVisitor(); |
| 1213 |
} |
| 1214 |
return fgMRVisitor; |
| 1215 |
} |
| 1182 |
|
1216 |
|
| 1183 |
/* (non-Javadoc) |
1217 |
/* (non-Javadoc) |
| 1184 |
* @see org.eclipse.debug.core.ILaunchManager#getEnvironment(org.eclipse.debug.core.ILaunchConfiguration) |
1218 |
* @see org.eclipse.debug.core.ILaunchManager#getEnvironment(org.eclipse.debug.core.ILaunchConfiguration) |
|
Lines 2165-2172
Link Here
|
| 2165 |
} |
2199 |
} |
| 2166 |
} else { |
2200 |
} else { |
| 2167 |
LaunchManagerVisitor visitor = getDeltaVisitor(); |
2201 |
LaunchManagerVisitor visitor = getDeltaVisitor(); |
|
|
2202 |
MappedResourceVisitor v = getMappedResourceVisitor(); |
| 2168 |
try { |
2203 |
try { |
| 2169 |
delta.accept(visitor); |
2204 |
delta.accept(visitor); |
|
|
2205 |
delta.accept(v); |
| 2170 |
} catch (CoreException e) { |
2206 |
} catch (CoreException e) { |
| 2171 |
DebugPlugin.log(e.getStatus()); |
2207 |
DebugPlugin.log(e.getStatus()); |
| 2172 |
} |
2208 |
} |
|
Lines 2175-2188
Link Here
|
| 2175 |
} |
2211 |
} |
| 2176 |
|
2212 |
|
| 2177 |
/** |
2213 |
/** |
| 2178 |
* Gets the launch configuration associated with the specified project. |
2214 |
* Gets the launch configuration associated with the specified <code>IResource</code>. |
| 2179 |
* This method relies on the resource mapping existing, if no such mapping |
2215 |
* This method relies on the resource mapping existing, if no such mapping |
| 2180 |
* exists the launch configuration is ignored. |
2216 |
* exists the launch configuration is ignored. |
| 2181 |
* |
2217 |
* |
| 2182 |
* @param project the project to collect launch configurations for |
2218 |
* @param resource the resource to collect launch configurations for |
| 2183 |
* @return the list of associated launch configurations |
2219 |
* @return the list of associated launch configurations |
| 2184 |
*/ |
2220 |
*/ |
| 2185 |
private ArrayList collectAssociatedLaunches(IProject project) { |
2221 |
private ArrayList collectAssociatedLaunches(IResource resource) { |
| 2186 |
ArrayList list = new ArrayList(); |
2222 |
ArrayList list = new ArrayList(); |
| 2187 |
try { |
2223 |
try { |
| 2188 |
ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(); |
2224 |
ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(); |
|
Lines 2192-2198
Link Here
|
| 2192 |
resources = configs[i].getMappedResources(); |
2228 |
resources = configs[i].getMappedResources(); |
| 2193 |
if(resources != null) { |
2229 |
if(resources != null) { |
| 2194 |
for(int j = 0; j < resources.length; j++){ |
2230 |
for(int j = 0; j < resources.length; j++){ |
| 2195 |
if(project.equals(resources[j].getProject())) { |
2231 |
if(resource.equals(resources[j]) || |
|
|
2232 |
resource.getFullPath().isPrefixOf(resources[j].getFullPath())) { |
| 2196 |
list.add(configs[i]); |
2233 |
list.add(configs[i]); |
| 2197 |
} |
2234 |
} |
| 2198 |
} |
2235 |
} |