Lines 69-74
Link Here
|
69 |
import org.eclipse.core.runtime.ListenerList; |
69 |
import org.eclipse.core.runtime.ListenerList; |
70 |
import org.eclipse.core.runtime.Platform; |
70 |
import org.eclipse.core.runtime.Platform; |
71 |
import org.eclipse.core.runtime.PlatformObject; |
71 |
import org.eclipse.core.runtime.PlatformObject; |
|
|
72 |
import org.eclipse.core.runtime.Preferences; |
72 |
import org.eclipse.core.runtime.SafeRunner; |
73 |
import org.eclipse.core.runtime.SafeRunner; |
73 |
import org.eclipse.core.runtime.Status; |
74 |
import org.eclipse.core.runtime.Status; |
74 |
import org.eclipse.core.variables.VariablesPlugin; |
75 |
import org.eclipse.core.variables.VariablesPlugin; |
Lines 86-91
Link Here
|
86 |
import org.eclipse.debug.core.IStatusHandler; |
87 |
import org.eclipse.debug.core.IStatusHandler; |
87 |
import org.eclipse.debug.core.model.IDebugTarget; |
88 |
import org.eclipse.debug.core.model.IDebugTarget; |
88 |
import org.eclipse.debug.core.model.IDisconnect; |
89 |
import org.eclipse.debug.core.model.IDisconnect; |
|
|
90 |
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; |
89 |
import org.eclipse.debug.core.model.IPersistableSourceLocator; |
91 |
import org.eclipse.debug.core.model.IPersistableSourceLocator; |
90 |
import org.eclipse.debug.core.model.IProcess; |
92 |
import org.eclipse.debug.core.model.IProcess; |
91 |
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector; |
93 |
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector; |
Lines 136-141
Link Here
|
136 |
private static final String EMPTY_STRING = ""; //$NON-NLS-1$ |
138 |
private static final String EMPTY_STRING = ""; //$NON-NLS-1$ |
137 |
|
139 |
|
138 |
/** |
140 |
/** |
|
|
141 |
* Constant for the root preference node for saving preferred launch delegates |
142 |
* @since 3.3 |
143 |
*/ |
144 |
private static final String PREFERRED_DELEGATE = "preferredDelegates"; //$NON-NLS-1$ |
145 |
|
146 |
/** |
147 |
* Constant for the delegate provider attribute when saving preferred delegates |
148 |
* @since 3.3 |
149 |
*/ |
150 |
private static final String DELEGATE_PROVIDER = "provider"; //$NON-NLS-1$ |
151 |
|
152 |
/** |
153 |
* Constant for the mode attribute when saving preferred delegates |
154 |
* @since 3.3 |
155 |
*/ |
156 |
private static final String DELEGATE_MODE = "mode"; //$NON-NLS-1$ |
157 |
|
158 |
/** |
139 |
* Status code for which a UI prompter is registered. |
159 |
* Status code for which a UI prompter is registered. |
140 |
* |
160 |
* |
141 |
* @since 3.2 |
161 |
* @since 3.2 |
Lines 150-156
Link Here
|
150 |
*/ |
170 |
*/ |
151 |
protected static final IStatus deleteAssociatedLaunchConfigs = new Status(IStatus.INFO, DEBUG_CORE, 225, EMPTY_STRING, null); |
171 |
protected static final IStatus deleteAssociatedLaunchConfigs = new Status(IStatus.INFO, DEBUG_CORE, 225, EMPTY_STRING, null); |
152 |
|
172 |
|
|
|
173 |
/** |
174 |
* Simple class to collect information for a single preferred delegate |
175 |
* @since 3.3 |
176 |
*/ |
177 |
class PreferredDelegate { |
178 |
private String fMode; |
179 |
private ILaunchConfigurationDelegate fDelegate; |
180 |
private ILaunchConfigurationType fType; |
181 |
private String fProvider; |
182 |
|
183 |
public PreferredDelegate(ILaunchConfigurationType type, ILaunchConfigurationDelegate delegate, String mode, String provider) { |
184 |
fMode = mode; |
185 |
fDelegate = delegate; |
186 |
fType = type; |
187 |
fProvider = provider; |
188 |
} |
189 |
|
190 |
public void setProvider(String provider) { |
191 |
fProvider = provider; |
192 |
} |
193 |
|
194 |
public String getMode() { |
195 |
return fMode; |
196 |
} |
197 |
|
198 |
public String getProvider() { |
199 |
return fProvider; |
200 |
} |
201 |
|
202 |
public ILaunchConfigurationDelegate getDelegeate() { |
203 |
return fDelegate; |
204 |
} |
205 |
|
206 |
public void setDelegate(ILaunchConfigurationDelegate delegate) { |
207 |
fDelegate = delegate; |
208 |
} |
209 |
|
210 |
public ILaunchConfigurationType getType() { |
211 |
return fType; |
212 |
} |
213 |
} |
153 |
|
214 |
|
|
|
215 |
/** |
216 |
* Simple class to describe a list of conflicting delegates for a specific type and mode |
217 |
* @since 3.3 |
218 |
*/ |
219 |
class ConflictingDelegate { |
220 |
private String fMode; |
221 |
private ILaunchConfigurationType fType; |
222 |
private String fProvider; |
223 |
/** map: <provider _id, delegate> **/ |
224 |
private HashMap fConflicts; |
225 |
|
226 |
public ConflictingDelegate(ILaunchConfigurationType type, String mode, HashMap conflicts) { |
227 |
fType = type; |
228 |
fMode = mode; |
229 |
fConflicts = conflicts; |
230 |
} |
231 |
|
232 |
public void setProvider(String provider) { |
233 |
fProvider = provider; |
234 |
} |
235 |
|
236 |
public ILaunchConfigurationType getType() { |
237 |
return fType; |
238 |
} |
239 |
|
240 |
public String getMode() { |
241 |
return fMode; |
242 |
} |
243 |
|
244 |
public HashMap getConflicts() { |
245 |
return fConflicts; |
246 |
} |
247 |
|
248 |
public String getProvider() { |
249 |
return fProvider; |
250 |
} |
251 |
} |
154 |
|
252 |
|
155 |
/** |
253 |
/** |
156 |
* Notifies a launch config listener in a safe runnable to handle |
254 |
* Notifies a launch config listener in a safe runnable to handle |
Lines 529-534
Link Here
|
529 |
private List fLaunchConfigurationTypes = null; |
627 |
private List fLaunchConfigurationTypes = null; |
530 |
|
628 |
|
531 |
/** |
629 |
/** |
|
|
630 |
* List of <code>PreferredDelegate</code> objects |
631 |
* @since 3.3 |
632 |
*/ |
633 |
private List fPreferredDelegates = null; |
634 |
|
635 |
/** |
636 |
* List of <code>ConflictingDelegate</code> objects |
637 |
* @since 3.3 |
638 |
*/ |
639 |
private List fConflictingDelegates = null; |
640 |
|
641 |
/** |
642 |
* The last chosen provider id, which allows us to maintain similar default choices for providers. |
643 |
*/ |
644 |
private String fLastChosenDefaultProvider = null; |
645 |
|
646 |
/** |
532 |
* Launch configuration cache. Keys are <code>LaunchConfiguration</code>, |
647 |
* Launch configuration cache. Keys are <code>LaunchConfiguration</code>, |
533 |
* values are <code>LaunchConfigurationInfo</code>. |
648 |
* values are <code>LaunchConfigurationInfo</code>. |
534 |
*/ |
649 |
*/ |
Lines 1024-1030
Link Here
|
1024 |
} |
1139 |
} |
1025 |
|
1140 |
|
1026 |
/** |
1141 |
/** |
1027 |
* @see ILaunchManager#getDebugTargets() |
1142 |
* @see org.eclipse.debug.core.ILaunchManager#getContributedDelegates(java.lang.String) |
|
|
1143 |
*/ |
1144 |
public synchronized List getContributedDelegates(String mode) { |
1145 |
ArrayList list = new ArrayList(0); |
1146 |
List delegates = getContributedDelegates(); |
1147 |
ContributedDelegate cd = null; |
1148 |
for(int i = 0; i < delegates.size(); i++) { |
1149 |
cd = (ContributedDelegate) delegates.get(i); |
1150 |
if(cd.getModes().contains(mode)) { |
1151 |
list.add(cd); |
1152 |
} |
1153 |
} |
1154 |
return list; |
1155 |
} |
1156 |
|
1157 |
/* (non-Javadoc) |
1158 |
* @see org.eclipse.debug.core.ILaunchManager#getContributedDelegates(org.eclipse.debug.core.ILaunchConfigurationType, java.lang.String) |
1159 |
*/ |
1160 |
public synchronized List getContributedDelegates(ILaunchConfigurationType type, String mode) throws CoreException { |
1161 |
if(!type.supportsMode(mode)) { |
1162 |
throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_9, new String[] {mode, type.getIdentifier()}), null)); |
1163 |
} |
1164 |
ArrayList list = new ArrayList(0); |
1165 |
List delegates = getContributedDelegates(); |
1166 |
ContributedDelegate cd = null; |
1167 |
for(int i = 0; i < delegates.size(); i++) { |
1168 |
cd = (ContributedDelegate) delegates.get(i); |
1169 |
if(cd.getModes().contains(mode) & cd.getLaunchConfigurationType().equals(type.getIdentifier())) { |
1170 |
list.add(cd); |
1171 |
} |
1172 |
} |
1173 |
return list; |
1174 |
} |
1175 |
|
1176 |
/* (non-Javadoc) |
1177 |
* @see org.eclipse.debug.core.ILaunchManager#getContributedDelegates(org.eclipse.debug.core.ILaunchConfigurationType) |
1178 |
*/ |
1179 |
public synchronized List getContributedDelegates(ILaunchConfigurationType type) throws CoreException { |
1180 |
ArrayList list = new ArrayList(0); |
1181 |
List delegates = getContributedDelegates(); |
1182 |
ContributedDelegate cd = null; |
1183 |
for(int i = 0; i < delegates.size(); i++) { |
1184 |
cd = (ContributedDelegate) delegates.get(i); |
1185 |
if(cd.getLaunchConfigurationType().equals(type.getIdentifier())) { |
1186 |
list.add(cd); |
1187 |
} |
1188 |
} |
1189 |
return list; |
1190 |
} |
1191 |
|
1192 |
/* (non-Javadoc) |
1193 |
* @see org.eclipse.debug.core.ILaunchManager#getDebugTargets() |
1028 |
*/ |
1194 |
*/ |
1029 |
public IDebugTarget[] getDebugTargets() { |
1195 |
public IDebugTarget[] getDebugTargets() { |
1030 |
synchronized (fLaunches) { |
1196 |
synchronized (fLaunches) { |
Lines 1540-1546
Link Here
|
1540 |
} |
1706 |
} |
1541 |
|
1707 |
|
1542 |
/** |
1708 |
/** |
1543 |
* Load comparator extensions. |
1709 |
* Load launch mode extensions. |
1544 |
* |
1710 |
* |
1545 |
* @exception CoreException if an exception occurs reading |
1711 |
* @exception CoreException if an exception occurs reading |
1546 |
* the extensions |
1712 |
* the extensions |
Lines 1942-1947
Link Here
|
1942 |
/** |
2108 |
/** |
1943 |
* Terminates/Disconnects any active debug targets/processes. |
2109 |
* Terminates/Disconnects any active debug targets/processes. |
1944 |
* Clears launch configuration types. |
2110 |
* Clears launch configuration types. |
|
|
2111 |
* Saves and clears preferred launch delegates |
1945 |
*/ |
2112 |
*/ |
1946 |
public void shutdown() { |
2113 |
public void shutdown() { |
1947 |
fListeners = new ListenerList(); |
2114 |
fListeners = new ListenerList(); |
Lines 1966-1972
Link Here
|
1966 |
} |
2133 |
} |
1967 |
|
2134 |
|
1968 |
clearAllLaunchConfigurations(); |
2135 |
clearAllLaunchConfigurations(); |
1969 |
|
2136 |
clearPreferredLaunchDelegates(); |
1970 |
getWorkspace().removeResourceChangeListener(this); |
2137 |
getWorkspace().removeResourceChangeListener(this); |
1971 |
} |
2138 |
} |
1972 |
|
2139 |
|
Lines 2017-2021
Link Here
|
2017 |
} |
2184 |
} |
2018 |
} |
2185 |
} |
2019 |
|
2186 |
|
|
|
2187 |
/** |
2188 |
* @see org.eclipse.debug.core.IPreferredLaunchDelegateManager#getPreferredDelegate(org.eclipse.debug.core.ILaunchConfigurationType, java.lang.String) |
2189 |
* @since 3.3 |
2190 |
*/ |
2191 |
public ILaunchConfigurationDelegate getPreferredDelegate(ILaunchConfigurationType type, String mode) throws CoreException { |
2192 |
if(!type.supportsMode(mode)) { |
2193 |
throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_9, new String[] {mode, type.getIdentifier()}), null)); |
2194 |
} |
2195 |
PreferredDelegate pd = findPreferredDelegate(type, mode); |
2196 |
if(pd != null) { |
2197 |
return pd.getDelegeate(); |
2198 |
} |
2199 |
return null; |
2200 |
} |
2201 |
|
2202 |
/** |
2203 |
* @see org.eclipse.debug.core.IPreferredLaunchDelegateManager#hasConflictingDelegates(org.eclipse.debug.core.ILaunchConfigurationType, java.lang.String) |
2204 |
* @since 3.3 |
2205 |
*/ |
2206 |
public boolean hasConflictingDelegates(ILaunchConfigurationType type, String mode) throws CoreException { |
2207 |
if(!type.supportsMode(mode)) { |
2208 |
throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_9, new String[] {mode, type.getIdentifier()}), null)); |
2209 |
} |
2210 |
return findConflictingDelegate(type, mode) != null; |
2211 |
} |
2212 |
|
2213 |
/** |
2214 |
* @see org.eclipse.debug.core.IPreferredLaunchDelegateManager#setPreferredDelegate(org.eclipse.debug.core.ILaunchConfigurationType, java.lang.String, org.eclipse.debug.core.model.ILaunchConfigurationDelegate) |
2215 |
* @since 3.3 |
2216 |
*/ |
2217 |
public void setPreferredDelegate(ILaunchConfigurationType type, String mode, ILaunchConfigurationDelegate delegate, String provider) throws CoreException { |
2218 |
if(!type.supportsMode(mode)) { |
2219 |
throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_9, new String[] {mode, type.getIdentifier()}), null)); |
2220 |
} |
2221 |
initializePreferredDelegates(); |
2222 |
PreferredDelegate pd = findPreferredDelegate(type, mode); |
2223 |
if(pd == null) { |
2224 |
fPreferredDelegates.add(new PreferredDelegate(type, delegate, mode, provider)); |
2225 |
} |
2226 |
else { |
2227 |
pd.setDelegate(delegate); |
2228 |
pd.setProvider(provider); |
2229 |
} |
2230 |
} |
2231 |
|
2232 |
/* (non-Javadoc) |
2233 |
* @see org.eclipse.debug.core.ILaunchManager#getConflictingDelegates(org.eclipse.debug.core.ILaunchConfigurationType, java.lang.String) |
2234 |
*/ |
2235 |
public HashMap getConflictingDelegates(ILaunchConfigurationType type, String mode) throws CoreException { |
2236 |
if(!type.supportsMode(mode)) { |
2237 |
throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_9, new String[] {mode, type.getIdentifier()}), null)); |
2238 |
} |
2239 |
ConflictingDelegate cd = findConflictingDelegate(type, mode); |
2240 |
if(cd != null) { |
2241 |
return cd.getConflicts(); |
2242 |
} |
2243 |
return new HashMap(0); |
2244 |
} |
2245 |
|
2246 |
/** |
2247 |
* @see org.eclipse.debug.core.IPreferredLaunchDelegateManager#removePreferredDelegate(org.eclipse.debug.core.ILaunchConfigurationType, java.lang.String) |
2248 |
* @since 3.3 |
2249 |
*/ |
2250 |
public void removePreferredDelegate(ILaunchConfigurationType type, String mode) throws CoreException { |
2251 |
if(!type.supportsMode(mode)) { |
2252 |
throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_9, new String[] {mode, type.getIdentifier()}), null)); |
2253 |
} |
2254 |
fPreferredDelegates.remove(findPreferredDelegate(type, mode)); |
2255 |
} |
2256 |
|
2257 |
/** |
2258 |
* Internal method for finding a <code>PreferredDelegate</code> item from a specified type and mode |
2259 |
* @param type the type to find |
2260 |
* @param mode the mode associated with the type |
2261 |
* @return the <code>PreferredDelegate</code> object or <code>null</code> if not found |
2262 |
* @since 3.3 |
2263 |
*/ |
2264 |
private PreferredDelegate findPreferredDelegate(ILaunchConfigurationType type, String mode) throws CoreException { |
2265 |
PreferredDelegate prefer = null; |
2266 |
initializePreferredDelegates(); |
2267 |
for(int i = 0; i < fPreferredDelegates.size(); i++) { |
2268 |
prefer = (PreferredDelegate) fPreferredDelegates.get(i); |
2269 |
if(prefer.getType().getIdentifier().equals(type.getIdentifier()) & prefer.getMode().equals(mode)) { |
2270 |
return prefer; |
2271 |
} |
2272 |
} |
2273 |
// if at this stage we have none for conflicting types, pick some defaults. |
2274 |
//if a there is a shared provider accross multi conflicts try to choose that one to maintain consistency |
2275 |
if(hasConflictingDelegates(type, mode)) { |
2276 |
HashMap map = getConflictingDelegates(type, mode); |
2277 |
if(!map.containsKey(fLastChosenDefaultProvider)) { |
2278 |
for(Iterator iter = map.keySet().iterator(); iter.hasNext();) { |
2279 |
fLastChosenDefaultProvider = (String) iter.next(); |
2280 |
break; |
2281 |
} |
2282 |
} |
2283 |
prefer = new PreferredDelegate(type, (ILaunchConfigurationDelegate) map.get(fLastChosenDefaultProvider), mode, fLastChosenDefaultProvider); |
2284 |
fPreferredDelegates.add(prefer); |
2285 |
return prefer; |
2286 |
} |
2287 |
return null; |
2288 |
} |
2289 |
|
2290 |
/* (non-Javadoc) |
2291 |
* @see org.eclipse.debug.core.ILaunchManager#getPreferredDelegateProvider(org.eclipse.debug.core.ILaunchConfigurationType, java.lang.String) |
2292 |
*/ |
2293 |
public String getPreferredDelegateProvider(ILaunchConfigurationType type, String mode) throws CoreException { |
2294 |
if(!type.supportsMode(mode)) { |
2295 |
throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_9, new String[] {mode, type.getIdentifier()}), null)); |
2296 |
} |
2297 |
PreferredDelegate pd = findPreferredDelegate(type, mode); |
2298 |
if(pd != null) { |
2299 |
return pd.getProvider(); |
2300 |
} |
2301 |
return null; |
2302 |
} |
2303 |
|
2304 |
/** |
2305 |
* Returns the <code>ConflictingDelegate</code> object associated with the specified type and given mode |
2306 |
* @param type the type to check for |
2307 |
* @param mode the mode for the type |
2308 |
* @return the <code>ConflictingDelegate</code> object or <code>null</code> if none |
2309 |
* @since 3.3 |
2310 |
*/ |
2311 |
private ConflictingDelegate findConflictingDelegate(ILaunchConfigurationType type, String mode) { |
2312 |
ConflictingDelegate conflict = null; |
2313 |
initializeConflictingDelegates(); |
2314 |
for(int i = 0; i < fConflictingDelegates.size(); i++) { |
2315 |
conflict = (ConflictingDelegate) fConflictingDelegates.get(i); |
2316 |
if(type.getIdentifier().equals(conflict.getType().getIdentifier()) & mode.equals(conflict.getMode())) { |
2317 |
return conflict; |
2318 |
} |
2319 |
} |
2320 |
return null; |
2321 |
} |
2322 |
|
2323 |
/** |
2324 |
* initializes the cache of preferred launch delegates from the <code>DebugPlugin</code> preferences |
2325 |
* @since 3.3 |
2326 |
*/ |
2327 |
private synchronized void initializePreferredDelegates() { |
2328 |
if(fPreferredDelegates == null) { |
2329 |
fPreferredDelegates = new ArrayList(0); |
2330 |
Preferences prefs = DebugPlugin.getDefault().getPluginPreferences(); |
2331 |
String docname = prefs.getString(DebugPlugin.PREF_PREFERRED_LAUNCH_DELEGATES); |
2332 |
if(!docname.equals(EMPTY_STRING)) { |
2333 |
try { |
2334 |
Element root = DebugPlugin.parseDocument(docname); |
2335 |
NodeList delegates = root.getChildNodes(); |
2336 |
Node child = null; |
2337 |
Element delegate = null; |
2338 |
ILaunchConfigurationType type = null; |
2339 |
String mode = null; |
2340 |
String provider = null; |
2341 |
List contributed = null; |
2342 |
ContributedDelegate cdelegate = null; |
2343 |
for(int i = 0; i < delegates.getLength(); i++) { |
2344 |
child = delegates.item(i); |
2345 |
if(child instanceof Element) { |
2346 |
delegate = (Element) child; |
2347 |
type = getLaunchConfigurationType(delegate.getNodeName()); |
2348 |
if(type != null) { |
2349 |
mode = delegate.getAttribute(DELEGATE_MODE); |
2350 |
provider = delegate.getAttribute(DELEGATE_PROVIDER); |
2351 |
if(provider != null && provider.equals(type.getIdentifier())) { |
2352 |
//use the default one (non-contributed) |
2353 |
fPreferredDelegates.add(new PreferredDelegate(type, type.getDelegate(mode), mode, provider)); |
2354 |
} |
2355 |
else { |
2356 |
//if we are not using the 'default' delegate search the contributed ones |
2357 |
contributed = getContributedDelegates(type, mode); |
2358 |
for(int j = 0; j < contributed.size(); j++) { |
2359 |
cdelegate = (ContributedDelegate) contributed.get(j); |
2360 |
if(cdelegate.getLaunchConfigurationType().equals(type.getIdentifier()) & cdelegate.getIdentifier().equals(provider)) { |
2361 |
fPreferredDelegates.add(new PreferredDelegate(type, cdelegate.getDelegate(), mode, cdelegate.getIdentifier())); |
2362 |
} |
2363 |
} |
2364 |
} |
2365 |
} |
2366 |
} |
2367 |
} |
2368 |
} |
2369 |
catch (CoreException e) {DebugPlugin.log(e);} |
2370 |
} |
2371 |
} |
2372 |
} |
2373 |
|
2374 |
/** |
2375 |
* initializes the cache of conflicting launch delegates |
2376 |
* @since 3.3 |
2377 |
*/ |
2378 |
private synchronized void initializeConflictingDelegates() { |
2379 |
if(fConflictingDelegates == null) { |
2380 |
try { |
2381 |
fConflictingDelegates = new ArrayList(); |
2382 |
List types = getLaunchConfigurationTypeList(); |
2383 |
ILaunchConfigurationType type = null; |
2384 |
HashMap map = new HashMap(); |
2385 |
HashMap dels = null; |
2386 |
String mode = null; |
2387 |
Set modes = null; |
2388 |
Object obj = null; |
2389 |
List tmp = null; |
2390 |
ContributedDelegate contrib = null; |
2391 |
for(int i = 0; i < types.size(); i++) { |
2392 |
type = (ILaunchConfigurationType) types.get(i); |
2393 |
modes = type.getSupportedModes(); |
2394 |
//load up the default modes |
2395 |
for(Iterator imodes = modes.iterator(); imodes.hasNext();) { |
2396 |
mode = (String) imodes.next(); |
2397 |
obj = map.get(mode); |
2398 |
if(obj == null) { |
2399 |
dels = new HashMap(0); |
2400 |
} |
2401 |
else { |
2402 |
dels = (HashMap)obj; |
2403 |
} |
2404 |
dels.put(type.getIdentifier(), type.getDelegate(mode)); |
2405 |
map.put(mode, dels); |
2406 |
} |
2407 |
//now get all of the contributed ones for this type |
2408 |
tmp = getContributedDelegates(type); |
2409 |
for(int j = 0; j < tmp.size(); j++) { |
2410 |
contrib = (ContributedDelegate)tmp.get(j); |
2411 |
modes = contrib.getModes(); |
2412 |
for(Iterator imodes = modes.iterator(); imodes.hasNext();) { |
2413 |
mode = (String) imodes.next(); |
2414 |
obj = map.get(mode); |
2415 |
if(obj == null) { |
2416 |
dels = new HashMap(0); |
2417 |
} |
2418 |
else { |
2419 |
dels = (HashMap)obj; |
2420 |
} |
2421 |
if(dels.containsValue(contrib.getDelegate())) { |
2422 |
dels.remove(type.getIdentifier()); |
2423 |
} |
2424 |
dels.put(contrib.getIdentifier(), contrib.getDelegate()); |
2425 |
map.put(mode, dels); |
2426 |
} |
2427 |
} |
2428 |
//now for each mode in the map see if there are conflicts, if so add them to the list |
2429 |
for(Iterator iter = map.keySet().iterator(); iter.hasNext();) { |
2430 |
mode = (String)iter.next(); |
2431 |
dels = (HashMap)map.get(mode); |
2432 |
if(dels != null && dels.size() > 1) { |
2433 |
//we have a conflict |
2434 |
fConflictingDelegates.add(new ConflictingDelegate(type, mode, dels)); |
2435 |
} |
2436 |
} |
2437 |
map.clear(); |
2438 |
} |
2439 |
} |
2440 |
catch(CoreException e) {DebugPlugin.log(e);} |
2441 |
} |
2442 |
} |
2020 |
|
2443 |
|
|
|
2444 |
/** |
2445 |
* Cleans up the caches used for the preferred delegates on shutdown |
2446 |
* Document elements are created as: |
2447 |
* <pre><config_type_id mode="" provider=""/></pre> |
2448 |
* Where provider can be either config_type_id or the id of the contributed delegate. |
2449 |
* @since 3.3 |
2450 |
*/ |
2451 |
private void clearPreferredLaunchDelegates() { |
2452 |
if(fPreferredDelegates != null) { |
2453 |
try { |
2454 |
Preferences prefs = DebugPlugin.getDefault().getPluginPreferences(); |
2455 |
Document doc = DebugPlugin.newDocument(); |
2456 |
Element root = doc.createElement(PREFERRED_DELEGATE); |
2457 |
doc.appendChild(root); |
2458 |
Element child = null; |
2459 |
PreferredDelegate delegate = null; |
2460 |
for(int i = 0; i < fPreferredDelegates.size(); i++) { |
2461 |
delegate = (PreferredDelegate) fPreferredDelegates.get(i); |
2462 |
child = doc.createElement(delegate.getType().getIdentifier()); |
2463 |
child.setAttribute(DELEGATE_MODE, delegate.getMode()); |
2464 |
child.setAttribute(DELEGATE_PROVIDER, delegate.getProvider()); |
2465 |
root.appendChild(child); |
2466 |
} |
2467 |
try { |
2468 |
prefs.setValue(DebugPlugin.PREF_PREFERRED_LAUNCH_DELEGATES, serializeDocument(doc)); |
2469 |
DebugPlugin.getDefault().savePluginPreferences(); |
2470 |
} |
2471 |
catch (IOException ioe) {DebugPlugin.log(ioe);} |
2472 |
catch (TransformerException te) {DebugPlugin.log(te);} |
2473 |
} |
2474 |
catch (CoreException e) {DebugPlugin.log(e);} |
2475 |
fPreferredDelegates.clear(); |
2476 |
fPreferredDelegates = null; |
2477 |
} |
2478 |
if(fConflictingDelegates != null) { |
2479 |
fConflictingDelegates.clear(); |
2480 |
fConflictingDelegates = null; |
2481 |
} |
2482 |
} |
2021 |
} |
2483 |
} |