|
Lines 13-18
Link Here
|
| 13 |
|
13 |
|
| 14 |
import java.util.ArrayList; |
14 |
import java.util.ArrayList; |
| 15 |
import java.util.Collections; |
15 |
import java.util.Collections; |
|
|
16 |
import java.util.HashMap; |
| 16 |
import java.util.HashSet; |
17 |
import java.util.HashSet; |
| 17 |
import java.util.Hashtable; |
18 |
import java.util.Hashtable; |
| 18 |
import java.util.Iterator; |
19 |
import java.util.Iterator; |
|
Lines 31-37
Link Here
|
| 31 |
import org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate; |
32 |
import org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate; |
| 32 |
import org.eclipse.debug.core.ILaunchConfigurationType; |
33 |
import org.eclipse.debug.core.ILaunchConfigurationType; |
| 33 |
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
34 |
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
| 34 |
import org.eclipse.debug.core.ILaunchDelegateProxy; |
35 |
import org.eclipse.debug.core.ILaunchDelegate; |
| 35 |
import org.eclipse.debug.core.ILaunchManager; |
36 |
import org.eclipse.debug.core.ILaunchManager; |
| 36 |
import org.eclipse.debug.core.ILaunchMode; |
37 |
import org.eclipse.debug.core.ILaunchMode; |
| 37 |
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; |
38 |
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; |
|
Lines 55-61
Link Here
|
| 55 |
* a listing of modes contributed to this launch configuration type |
56 |
* a listing of modes contributed to this launch configuration type |
| 56 |
* @since 3.3 |
57 |
* @since 3.3 |
| 57 |
* |
58 |
* |
| 58 |
* <p> |
59 |
* <p> |
| 59 |
* <strong>EXPERIMENTAL</strong>. This field has been added as |
60 |
* <strong>EXPERIMENTAL</strong>. This field has been added as |
| 60 |
* part of a work in progress. There is no guarantee that this API will |
61 |
* part of a work in progress. There is no guarantee that this API will |
| 61 |
* remain unchanged during the 3.3 release cycle. Please do not use this API |
62 |
* remain unchanged during the 3.3 release cycle. Please do not use this API |
|
Lines 65-70
Link Here
|
| 65 |
private Set fModes = null; |
66 |
private Set fModes = null; |
| 66 |
|
67 |
|
| 67 |
/** |
68 |
/** |
|
|
69 |
* A set of sets containing all of the supported mode combinations of this type |
| 70 |
* |
| 71 |
* @since 3.3 |
| 72 |
* |
| 73 |
* EXPERIMENTAL |
| 74 |
*/ |
| 75 |
private Set fModeCombinations = null; |
| 76 |
|
| 77 |
/** |
| 68 |
* the default source path computer for this config type |
78 |
* the default source path computer for this config type |
| 69 |
* @since 3.3 |
79 |
* @since 3.3 |
| 70 |
* |
80 |
* |
|
Lines 88-96
Link Here
|
| 88 |
* be different delegates for different modes (since 3.0). |
98 |
* be different delegates for different modes (since 3.0). |
| 89 |
* Map of modes (Set of modes) to list of delegates |
99 |
* Map of modes (Set of modes) to list of delegates |
| 90 |
*/ |
100 |
*/ |
| 91 |
private Map fDelegates; |
101 |
private Map fDelegates = null; |
| 92 |
|
102 |
|
| 93 |
private LaunchDelegate fSourceProvider; |
103 |
/** |
|
|
104 |
* The source provider cache entry |
| 105 |
*/ |
| 106 |
private LaunchDelegate fSourceProvider = null; |
| 107 |
|
| 108 |
/** |
| 109 |
* A map of preferred launch delegates for mode combinations |
| 110 |
* |
| 111 |
* @since 3.3 |
| 112 |
* |
| 113 |
* EXPERIMENTAL |
| 114 |
*/ |
| 115 |
private Map fPreferredDelegates = null; |
| 94 |
|
116 |
|
| 95 |
/** |
117 |
/** |
| 96 |
* Constructs a new launch configuration type on the |
118 |
* Constructs a new launch configuration type on the |
|
Lines 129-135
Link Here
|
| 129 |
public ILaunchConfigurationDelegate getDelegate(String mode) throws CoreException { |
151 |
public ILaunchConfigurationDelegate getDelegate(String mode) throws CoreException { |
| 130 |
Set modes = new HashSet(); |
152 |
Set modes = new HashSet(); |
| 131 |
modes.add(mode); |
153 |
modes.add(mode); |
| 132 |
ILaunchDelegateProxy[] delegates = getDelegates(modes); |
154 |
ILaunchDelegate[] delegates = getDelegates(modes); |
| 133 |
if (delegates.length > 0) { |
155 |
if (delegates.length > 0) { |
| 134 |
return delegates[0].getDelegate(); |
156 |
return delegates[0].getDelegate(); |
| 135 |
} |
157 |
} |
|
Lines 147-186
Link Here
|
| 147 |
throw new CoreException(status); |
169 |
throw new CoreException(status); |
| 148 |
} |
170 |
} |
| 149 |
|
171 |
|
| 150 |
public ILaunchDelegateProxy[] getDelegates(Set modes) throws CoreException { |
172 |
/* (non-Javadoc) |
|
|
173 |
* @see org.eclipse.debug.core.ILaunchConfigurationType#getDelegates(java.util.Set) |
| 174 |
*/ |
| 175 |
public ILaunchDelegate[] getDelegates(Set modes) throws CoreException { |
| 151 |
initializeDelegates(); |
176 |
initializeDelegates(); |
| 152 |
Object[] theModes = modes.toArray(); |
177 |
initializePreferredDelegates(); |
| 153 |
for (int i = 0; i < theModes.length; i++) { |
|
|
| 154 |
String mode = (String) theModes[i]; |
| 155 |
if (!supportsMode(mode)) { |
| 156 |
throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, |
| 157 |
MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_9, new String[] {mode, getIdentifier()}), null)); |
| 158 |
} |
| 159 |
} |
| 160 |
List delegates = (List) fDelegates.get(modes); |
178 |
List delegates = (List) fDelegates.get(modes); |
| 161 |
if (delegates == null) { |
179 |
if (delegates == null) { |
| 162 |
delegates = Collections.EMPTY_LIST; |
180 |
delegates = Collections.EMPTY_LIST; |
| 163 |
} |
181 |
} |
| 164 |
return (ILaunchDelegateProxy[]) delegates.toArray(new ILaunchDelegateProxy[delegates.size()]); |
182 |
return (ILaunchDelegate[]) delegates.toArray(new ILaunchDelegate[delegates.size()]); |
|
|
183 |
} |
| 184 |
|
| 185 |
/** |
| 186 |
* @see org.eclipse.debug.core.ILaunchConfigurationType#setPreferredDelegate(java.util.Set, org.eclipse.debug.core.ILaunchDelegateProxy) |
| 187 |
*/ |
| 188 |
public void setPreferredDelegate(Set modes, ILaunchDelegate delegate) { |
| 189 |
if(fPreferredDelegates == null) { |
| 190 |
fPreferredDelegates = new HashMap(); |
| 191 |
} |
| 192 |
fPreferredDelegates.put(modes, delegate); |
| 193 |
} |
| 194 |
|
| 195 |
/** |
| 196 |
* @see org.eclipse.debug.core.ILaunchConfigurationType#getPreferredDelegate(java.util.Set) |
| 197 |
*/ |
| 198 |
public ILaunchDelegate getPreferredDelegate(Set modes) { |
| 199 |
initializePreferredDelegates(); |
| 200 |
return (ILaunchDelegate) fPreferredDelegates.get(modes); |
| 165 |
} |
201 |
} |
| 166 |
|
202 |
|
|
|
203 |
/** |
| 204 |
* Internal use method to allow access to the listing of preferred delegates |
| 205 |
* @return the map opf preferred delegates |
| 206 |
* |
| 207 |
* @since 3.3 |
| 208 |
* |
| 209 |
* EXPERIMENTAL |
| 210 |
*/ |
| 211 |
public Map getPreferredDelegates() { |
| 212 |
initializePreferredDelegates(); |
| 213 |
return fPreferredDelegates; |
| 214 |
} |
| 215 |
|
| 216 |
/** |
| 217 |
* This method is used to initialize the listing of preferred launch delegates for this type |
| 218 |
* |
| 219 |
* <p> |
| 220 |
* Undecide if this code should live in the launch manager and have it load a listing of all perferred launch |
| 221 |
* delegates that each config type could then query as needed when looking for their preferrred delegate. |
| 222 |
* Seems like it would be alot less work... |
| 223 |
* </p> |
| 224 |
* @since 3.3 |
| 225 |
* |
| 226 |
* EXPERIMENTAL |
| 227 |
*/ |
| 228 |
private synchronized void initializePreferredDelegates() { |
| 229 |
if(fPreferredDelegates == null) { |
| 230 |
fPreferredDelegates = new HashMap(); |
| 231 |
initializeDelegates(); |
| 232 |
LaunchManager lm = (LaunchManager) DebugPlugin.getDefault().getLaunchManager(); |
| 233 |
ILaunchDelegate delegate = null; |
| 234 |
Set modes = null; |
| 235 |
for(Iterator iter = fDelegates.keySet().iterator(); iter.hasNext();) { |
| 236 |
modes = (Set) iter.next(); |
| 237 |
delegate = lm.getPreferredDelegate(getIdentifier(), modes); |
| 238 |
if(delegate != null) { |
| 239 |
fPreferredDelegates.put(modes, delegate); |
| 240 |
} |
| 241 |
} |
| 242 |
} |
| 243 |
} |
| 244 |
|
| 245 |
/** |
| 246 |
* Initializes the listing of launch delegates for this type |
| 247 |
*/ |
| 167 |
private synchronized void initializeDelegates() { |
248 |
private synchronized void initializeDelegates() { |
| 168 |
if (fDelegates == null) { |
249 |
if (fDelegates == null) { |
| 169 |
// initialize delegate |
250 |
// initialize delegate |
| 170 |
fDelegates = new Hashtable(); |
251 |
fDelegates = new Hashtable(); |
| 171 |
LaunchDelegate[] launchDelegates = getLaunchDelegateExtensions(); |
252 |
LaunchDelegate[] launchDelegates = getLaunchDelegateExtensions(); |
|
|
253 |
LaunchDelegate delegate = null; |
| 254 |
List modelist = null; |
| 172 |
for (int i = 0; i < launchDelegates.length; i++) { |
255 |
for (int i = 0; i < launchDelegates.length; i++) { |
| 173 |
LaunchDelegate delegate = launchDelegates[i]; |
256 |
delegate = launchDelegates[i]; |
| 174 |
List combintaions = delegate.getModeCombinations(); |
257 |
modelist = delegate.getModes(); |
| 175 |
Iterator iterator = combintaions.iterator(); |
258 |
for(int j = 0; j < modelist.size(); j++) { |
| 176 |
while (iterator.hasNext()) { |
259 |
//cache the delegate based on its set of modes and delegate |
| 177 |
Set combination = (Set) iterator.next(); |
260 |
registerDelegate(delegate, (Set) modelist.get(j)); |
| 178 |
registerDelegate(delegate, combination); |
|
|
| 179 |
} |
261 |
} |
| 180 |
} |
262 |
} |
| 181 |
} |
263 |
} |
| 182 |
} |
264 |
} |
| 183 |
|
265 |
|
| 184 |
/** |
266 |
/** |
| 185 |
* Returns all launch delegate extensions registered for this configuration type. |
267 |
* Returns all launch delegate extensions registered for this configuration type. |
| 186 |
* |
268 |
* |
|
Lines 190-195
Link Here
|
| 190 |
return ((LaunchManager) DebugPlugin.getDefault().getLaunchManager()).getLaunchDelegates(getIdentifier()); |
272 |
return ((LaunchManager) DebugPlugin.getDefault().getLaunchManager()).getLaunchDelegates(getIdentifier()); |
| 191 |
} |
273 |
} |
| 192 |
|
274 |
|
|
|
275 |
/** |
| 276 |
* Caches a delegate keyed using the set of modes that it supports |
| 277 |
* @param delegate the delegate to cache |
| 278 |
* @param modes the set of modes that the specified delegate supports |
| 279 |
*/ |
| 193 |
private void registerDelegate(LaunchDelegate delegate, Set modes) { |
280 |
private void registerDelegate(LaunchDelegate delegate, Set modes) { |
| 194 |
List delegatesForModes = (List) fDelegates.get(modes); |
281 |
List delegatesForModes = (List) fDelegates.get(modes); |
| 195 |
if (delegatesForModes == null) { |
282 |
if (delegatesForModes == null) { |
|
Lines 289-301
Link Here
|
| 289 |
if(fModes == null) { |
376 |
if(fModes == null) { |
| 290 |
fModes = new HashSet(); |
377 |
fModes = new HashSet(); |
| 291 |
LaunchDelegate[] delegates = getLaunchDelegateExtensions(); |
378 |
LaunchDelegate[] delegates = getLaunchDelegateExtensions(); |
|
|
379 |
List modesets = null; |
| 292 |
for(int i= 0; i < delegates.length; i++) { |
380 |
for(int i= 0; i < delegates.length; i++) { |
| 293 |
fModes.addAll(delegates[i].getModes()); |
381 |
modesets = delegates[i].getModes(); |
|
|
382 |
for(Iterator iter = modesets.iterator(); iter.hasNext();) { |
| 383 |
fModes.addAll((Set) iter.next()); |
| 384 |
} |
| 294 |
} |
385 |
} |
| 295 |
} |
386 |
} |
| 296 |
return fModes; |
387 |
return fModes; |
| 297 |
} |
388 |
} |
| 298 |
|
389 |
|
|
|
390 |
/** |
| 391 |
* @see org.eclipse.debug.core.ILaunchConfigurationType#getSupportedModeCombinations() |
| 392 |
*/ |
| 393 |
public Set getSupportedModeCombinations() { |
| 394 |
if(fModeCombinations == null) { |
| 395 |
initializeDelegates(); |
| 396 |
fModeCombinations = new HashSet(); |
| 397 |
fModeCombinations = fDelegates.keySet(); |
| 398 |
} |
| 399 |
//return a clone or bad things happen |
| 400 |
HashSet set = new HashSet(); |
| 401 |
for(Iterator iter = fModeCombinations.iterator(); iter.hasNext();) { |
| 402 |
set.add(new HashSet((Set) iter.next())); |
| 403 |
} |
| 404 |
return set; |
| 405 |
} |
| 406 |
|
| 299 |
/** |
407 |
/** |
| 300 |
* determines if the specified candidate is suitable for migration by loading it delegate. |
408 |
* determines if the specified candidate is suitable for migration by loading it delegate. |
| 301 |
* @param candidate the candidate to inspect for migration suitability |
409 |
* @param candidate the candidate to inspect for migration suitability |
|
Lines 368-374
Link Here
|
| 368 |
* @see org.eclipse.debug.core.ILaunchConfigurationType#supportsMode(java.lang.String) |
476 |
* @see org.eclipse.debug.core.ILaunchConfigurationType#supportsMode(java.lang.String) |
| 369 |
*/ |
477 |
*/ |
| 370 |
public boolean supportsMode(String mode) { |
478 |
public boolean supportsMode(String mode) { |
| 371 |
return getSupportedModes().contains(mode); |
479 |
if(fModeCombinations == null) { |
|
|
480 |
getSupportedModeCombinations(); |
| 481 |
} |
| 482 |
Set modes = null; |
| 483 |
for(Iterator iter = fModeCombinations.iterator(); iter.hasNext();) { |
| 484 |
modes = (Set) iter.next(); |
| 485 |
if(modes.size() == 1 && modes.contains(mode)) { |
| 486 |
return true; |
| 487 |
} |
| 488 |
} |
| 489 |
return false; |
| 372 |
} |
490 |
} |
| 373 |
|
491 |
|
| 374 |
/* (non-Javadoc) |
492 |
/* (non-Javadoc) |
|
Lines 386-410
Link Here
|
| 386 |
} |
504 |
} |
| 387 |
|
505 |
|
| 388 |
/* (non-Javadoc) |
506 |
/* (non-Javadoc) |
| 389 |
* @see org.eclipse.debug.core.ILaunchConfigurationType#getSupportedModeCombinations() |
|
|
| 390 |
*/ |
| 391 |
public Set[] getSupportedModeCombinations() { |
| 392 |
initializeDelegates(); |
| 393 |
Set combinations = fDelegates.keySet(); |
| 394 |
Set[] sets = (Set[])combinations.toArray(new Set[combinations.size()]); |
| 395 |
Set[] copy = new Set[sets.length]; |
| 396 |
for (int i = 0; i < copy.length; i++) { |
| 397 |
copy[i] = new HashSet(sets[i]); |
| 398 |
} |
| 399 |
return copy; |
| 400 |
} |
| 401 |
|
| 402 |
/* (non-Javadoc) |
| 403 |
* @see org.eclipse.debug.core.ILaunchConfigurationType#supportsModeCombination(java.util.Set) |
507 |
* @see org.eclipse.debug.core.ILaunchConfigurationType#supportsModeCombination(java.util.Set) |
| 404 |
*/ |
508 |
*/ |
| 405 |
public boolean supportsModeCombination(Set modes) { |
509 |
public boolean supportsModes(Set modes) { |
| 406 |
initializeDelegates(); |
510 |
if(fModeCombinations == null) { |
| 407 |
return fDelegates.containsKey(modes); |
511 |
getSupportedModeCombinations(); |
|
|
512 |
} |
| 513 |
return fModeCombinations.contains(modes); |
| 408 |
} |
514 |
} |
| 409 |
|
515 |
|
| 410 |
} |
516 |
} |