|
Lines 57-62
Link Here
|
| 57 |
import org.eclipse.core.resources.IResourceDeltaVisitor; |
57 |
import org.eclipse.core.resources.IResourceDeltaVisitor; |
| 58 |
import org.eclipse.core.resources.IResourceProxy; |
58 |
import org.eclipse.core.resources.IResourceProxy; |
| 59 |
import org.eclipse.core.resources.IResourceProxyVisitor; |
59 |
import org.eclipse.core.resources.IResourceProxyVisitor; |
|
|
60 |
import org.eclipse.core.resources.ProjectScope; |
| 60 |
import org.eclipse.core.resources.ResourcesPlugin; |
61 |
import org.eclipse.core.resources.ResourcesPlugin; |
| 61 |
import org.eclipse.core.runtime.CoreException; |
62 |
import org.eclipse.core.runtime.CoreException; |
| 62 |
import org.eclipse.core.runtime.IConfigurationElement; |
63 |
import org.eclipse.core.runtime.IConfigurationElement; |
|
Lines 65-75
Link Here
|
| 65 |
import org.eclipse.core.runtime.ISafeRunnable; |
66 |
import org.eclipse.core.runtime.ISafeRunnable; |
| 66 |
import org.eclipse.core.runtime.IStatus; |
67 |
import org.eclipse.core.runtime.IStatus; |
| 67 |
import org.eclipse.core.runtime.ListenerList; |
68 |
import org.eclipse.core.runtime.ListenerList; |
|
|
69 |
import org.eclipse.core.runtime.Path; |
| 68 |
import org.eclipse.core.runtime.Platform; |
70 |
import org.eclipse.core.runtime.Platform; |
| 69 |
import org.eclipse.core.runtime.PlatformObject; |
71 |
import org.eclipse.core.runtime.PlatformObject; |
| 70 |
import org.eclipse.core.runtime.Preferences; |
72 |
import org.eclipse.core.runtime.Preferences; |
| 71 |
import org.eclipse.core.runtime.SafeRunner; |
73 |
import org.eclipse.core.runtime.SafeRunner; |
| 72 |
import org.eclipse.core.runtime.Status; |
74 |
import org.eclipse.core.runtime.Status; |
|
|
75 |
import org.eclipse.core.runtime.preferences.InstanceScope; |
| 73 |
import org.eclipse.core.variables.VariablesPlugin; |
76 |
import org.eclipse.core.variables.VariablesPlugin; |
| 74 |
import org.eclipse.debug.core.DebugException; |
77 |
import org.eclipse.debug.core.DebugException; |
| 75 |
import org.eclipse.debug.core.DebugPlugin; |
78 |
import org.eclipse.debug.core.DebugPlugin; |
|
Lines 77-82
Link Here
|
| 77 |
import org.eclipse.debug.core.ILaunchConfiguration; |
80 |
import org.eclipse.debug.core.ILaunchConfiguration; |
| 78 |
import org.eclipse.debug.core.ILaunchConfigurationListener; |
81 |
import org.eclipse.debug.core.ILaunchConfigurationListener; |
| 79 |
import org.eclipse.debug.core.ILaunchConfigurationType; |
82 |
import org.eclipse.debug.core.ILaunchConfigurationType; |
|
|
83 |
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
| 80 |
import org.eclipse.debug.core.ILaunchDelegate; |
84 |
import org.eclipse.debug.core.ILaunchDelegate; |
| 81 |
import org.eclipse.debug.core.ILaunchListener; |
85 |
import org.eclipse.debug.core.ILaunchListener; |
| 82 |
import org.eclipse.debug.core.ILaunchManager; |
86 |
import org.eclipse.debug.core.ILaunchManager; |
|
Lines 94-99
Link Here
|
| 94 |
import org.eclipse.debug.internal.core.sourcelookup.SourceContainerType; |
98 |
import org.eclipse.debug.internal.core.sourcelookup.SourceContainerType; |
| 95 |
import org.eclipse.debug.internal.core.sourcelookup.SourcePathComputer; |
99 |
import org.eclipse.debug.internal.core.sourcelookup.SourcePathComputer; |
| 96 |
import org.eclipse.osgi.service.environment.Constants; |
100 |
import org.eclipse.osgi.service.environment.Constants; |
|
|
101 |
import org.osgi.service.prefs.BackingStoreException; |
| 97 |
import org.w3c.dom.Document; |
102 |
import org.w3c.dom.Document; |
| 98 |
import org.w3c.dom.Element; |
103 |
import org.w3c.dom.Element; |
| 99 |
import org.w3c.dom.Node; |
104 |
import org.w3c.dom.Node; |
|
Lines 116-121
Link Here
|
| 116 |
|
121 |
|
| 117 |
|
122 |
|
| 118 |
/** |
123 |
/** |
|
|
124 |
* |
| 125 |
*/ |
| 126 |
private static final String DEFAULT_CONFIGURATION = "defaultConfiguration"; |
| 127 |
/** |
| 119 |
* Constants for xml node names |
128 |
* Constants for xml node names |
| 120 |
* |
129 |
* |
| 121 |
* @since 3.3 |
130 |
* @since 3.3 |
|
Lines 2312-2316
Link Here
|
| 2312 |
} |
2321 |
} |
| 2313 |
} |
2322 |
} |
| 2314 |
return title; |
2323 |
return title; |
| 2315 |
} |
2324 |
} |
|
|
2325 |
|
| 2326 |
/* (non-Javadoc) |
| 2327 |
* @see org.eclipse.debug.core.ILaunchManager#getDefaultConfiguration(org.eclipse.core.resources.IResource) |
| 2328 |
*/ |
| 2329 |
public ILaunchConfiguration getDefaultConfiguration(IResource resource) throws CoreException { |
| 2330 |
IProject project = resource.getProject(); |
| 2331 |
if (project != null) { |
| 2332 |
org.osgi.service.prefs.Preferences projectNode = getProjectNode(resource); |
| 2333 |
String configValue = projectNode.get(DEFAULT_CONFIGURATION, null); |
| 2334 |
if (configValue != null) { |
| 2335 |
// shared config |
| 2336 |
IFile file = project.getFile(Path.fromPortableString(configValue)); |
| 2337 |
return getLaunchConfiguration(file); |
| 2338 |
} else { |
| 2339 |
org.osgi.service.prefs.Preferences instanceNode = getInstanceNode(resource); |
| 2340 |
configValue = instanceNode.get(DEFAULT_CONFIGURATION, null); |
| 2341 |
if (configValue != null) { |
| 2342 |
// local config |
| 2343 |
return getLaunchConfiguration(configValue); |
| 2344 |
} |
| 2345 |
} |
| 2346 |
} |
| 2347 |
return null; |
| 2348 |
} |
| 2349 |
|
| 2350 |
/* (non-Javadoc) |
| 2351 |
* @see org.eclipse.debug.core.ILaunchManager#setDefaultConfiguration(org.eclipse.core.resources.IResource, org.eclipse.debug.core.ILaunchConfiguration) |
| 2352 |
*/ |
| 2353 |
public void setDefaultConfiguration(IResource resource, ILaunchConfiguration configuration) throws CoreException { |
| 2354 |
IProject project = resource.getProject(); |
| 2355 |
if (project == null) { |
| 2356 |
throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), |
| 2357 |
DebugPlugin.INTERNAL_ERROR, "Illegal argument: can only set default launch configuration on and within projects.", null)); |
| 2358 |
} |
| 2359 |
if (configuration != null && !configuration.isLocal()) { |
| 2360 |
if (!configuration.getFile().getProject().equals(project)) { |
| 2361 |
throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), |
| 2362 |
DebugPlugin.INTERNAL_ERROR, "A shared launch configuration must be shared in same project that it is a default configuration for.", null)); |
| 2363 |
} |
| 2364 |
} |
| 2365 |
|
| 2366 |
// remove previous settings, if any |
| 2367 |
org.osgi.service.prefs.Preferences projectNode = getProjectNode(resource); |
| 2368 |
projectNode.remove(DEFAULT_CONFIGURATION); |
| 2369 |
flush(projectNode); |
| 2370 |
org.osgi.service.prefs.Preferences instanceNode = getInstanceNode(resource); |
| 2371 |
instanceNode.remove(DEFAULT_CONFIGURATION); |
| 2372 |
flush(instanceNode); |
| 2373 |
|
| 2374 |
if (configuration != null) { |
| 2375 |
org.osgi.service.prefs.Preferences node = null; |
| 2376 |
String configurationValue = null; |
| 2377 |
if (configuration.isLocal()) { |
| 2378 |
// for local configurations, use workspace (instance) scope preferences |
| 2379 |
node = instanceNode; |
| 2380 |
if (configuration.isWorkingCopy()) { |
| 2381 |
configurationValue = ((ILaunchConfigurationWorkingCopy)configuration).getOriginal().getMemento(); |
| 2382 |
} else { |
| 2383 |
configurationValue = configuration.getMemento(); |
| 2384 |
} |
| 2385 |
} else { |
| 2386 |
// for shared configurations, use project scope preferences |
| 2387 |
node = projectNode; |
| 2388 |
configurationValue = configuration.getFile().getProjectRelativePath().toPortableString(); |
| 2389 |
} |
| 2390 |
node.put(DEFAULT_CONFIGURATION, configurationValue); |
| 2391 |
flush(node); |
| 2392 |
} |
| 2393 |
|
| 2394 |
} |
| 2395 |
|
| 2396 |
private void flush(org.osgi.service.prefs.Preferences node) { |
| 2397 |
try { |
| 2398 |
node.flush(); |
| 2399 |
} catch (BackingStoreException e) { |
| 2400 |
// TODO Auto-generated catch block |
| 2401 |
e.printStackTrace(); |
| 2402 |
} |
| 2403 |
} |
| 2404 |
|
| 2405 |
private org.osgi.service.prefs.Preferences getProjectNode(IResource resource) { |
| 2406 |
org.osgi.service.prefs.Preferences node = Platform.getPreferencesService().getRootNode(); |
| 2407 |
ProjectScope scope = new ProjectScope(resource.getProject()); |
| 2408 |
node = scope.getNode(DebugPlugin.getUniqueIdentifier()); |
| 2409 |
IProject project = resource.getProject(); |
| 2410 |
if (!resource.equals(project)) { |
| 2411 |
node = node.node(resource.getProjectRelativePath().toString()); |
| 2412 |
} |
| 2413 |
return node; |
| 2414 |
} |
| 2415 |
|
| 2416 |
private org.osgi.service.prefs.Preferences getInstanceNode(IResource resource) { |
| 2417 |
org.osgi.service.prefs.Preferences node = Platform.getPreferencesService().getRootNode(); |
| 2418 |
node = node.node(InstanceScope.SCOPE).node(DebugPlugin.getUniqueIdentifier()); |
| 2419 |
return node.node(resource.getFullPath().makeRelative().toString()); |
| 2420 |
} |
| 2316 |
} |
2421 |
} |