|
Lines 11-19
Link Here
|
| 11 |
package org.eclipse.debug.internal.core; |
11 |
package org.eclipse.debug.internal.core; |
| 12 |
|
12 |
|
| 13 |
import java.util.ArrayList; |
13 |
import java.util.ArrayList; |
| 14 |
import java.util.Collection; |
|
|
| 15 |
import java.util.HashSet; |
14 |
import java.util.HashSet; |
| 16 |
import java.util.Iterator; |
|
|
| 17 |
import java.util.List; |
15 |
import java.util.List; |
| 18 |
import java.util.Set; |
16 |
import java.util.Set; |
| 19 |
|
17 |
|
|
Lines 59-67
Link Here
|
| 59 |
*/ |
57 |
*/ |
| 60 |
private ILaunchConfigurationDelegate fDelegate = null; |
58 |
private ILaunchConfigurationDelegate fDelegate = null; |
| 61 |
|
59 |
|
| 62 |
//lists of cached entries |
60 |
//a listing of sets of |
|
|
61 |
private List fLaunchModes = null; |
| 63 |
private HashSet fModes = null; |
62 |
private HashSet fModes = null; |
| 64 |
private HashSet fOptions = null; |
|
|
| 65 |
private String fType = null; |
63 |
private String fType = null; |
| 66 |
|
64 |
|
| 67 |
/** |
65 |
/** |
|
Lines 72-77
Link Here
|
| 72 |
fElement = element; |
70 |
fElement = element; |
| 73 |
} |
71 |
} |
| 74 |
|
72 |
|
|
|
73 |
/* (non-Javadoc) |
| 74 |
* @see org.eclipse.debug.core.ILaunchDelegateProxy#getDelegate() |
| 75 |
*/ |
| 75 |
public ILaunchConfigurationDelegate getDelegate() throws CoreException { |
76 |
public ILaunchConfigurationDelegate getDelegate() throws CoreException { |
| 76 |
if(fDelegate == null) { |
77 |
if(fDelegate == null) { |
| 77 |
Object obj = fElement.createExecutableExtension(IConfigurationElementConstants.DELEGATE); |
78 |
Object obj = fElement.createExecutableExtension(IConfigurationElementConstants.DELEGATE); |
|
Lines 84-89
Link Here
|
| 84 |
return fDelegate; |
85 |
return fDelegate; |
| 85 |
} |
86 |
} |
| 86 |
|
87 |
|
|
|
88 |
/* (non-Javadoc) |
| 89 |
* @see org.eclipse.debug.core.ILaunchDelegateProxy#getId() |
| 90 |
*/ |
| 87 |
public String getId() { |
91 |
public String getId() { |
| 88 |
return fElement.getAttribute(IConfigurationElementConstants.ID); |
92 |
return fElement.getAttribute(IConfigurationElementConstants.ID); |
| 89 |
} |
93 |
} |
|
Lines 103-127
Link Here
|
| 103 |
} |
107 |
} |
| 104 |
return fType; |
108 |
return fType; |
| 105 |
} |
109 |
} |
| 106 |
|
|
|
| 107 |
public Set getOptions() { |
| 108 |
if(fOptions == null) { |
| 109 |
fOptions = new HashSet(); |
| 110 |
String option = fElement.getAttribute(IConfigurationElementConstants.OPTIONS); |
| 111 |
if(option != null) { |
| 112 |
String[] options = option.split(","); //$NON-NLS-1$ |
| 113 |
for(int i = 0; i < options.length; i++) { |
| 114 |
fOptions.add(options[i].trim()); |
| 115 |
} |
| 116 |
} |
| 117 |
} |
| 118 |
return fOptions; |
| 119 |
} |
| 120 |
|
110 |
|
| 121 |
public Set getModes() { |
111 |
/** |
|
|
112 |
* Parese a list of modes and creates a new set of them |
| 113 |
* @param element the configuraiton element to read from |
| 114 |
* @return a set of launch modes created form a comma seperated list |
| 115 |
*/ |
| 116 |
private Set getModes(IConfigurationElement element) { |
| 122 |
if (fModes == null) { |
117 |
if (fModes == null) { |
| 123 |
fModes = new HashSet(); |
118 |
fModes = new HashSet(); |
| 124 |
String modes = fElement.getAttribute(IConfigurationElementConstants.MODES); |
119 |
String modes = element.getAttribute(IConfigurationElementConstants.MODES); |
| 125 |
if (modes != null) { |
120 |
if (modes != null) { |
| 126 |
String[] strings = modes.split(","); //$NON-NLS-1$ |
121 |
String[] strings = modes.split(","); //$NON-NLS-1$ |
| 127 |
for (int i = 0; i < strings.length; i++) { |
122 |
for (int i = 0; i < strings.length; i++) { |
|
Lines 132-137
Link Here
|
| 132 |
return fModes; |
127 |
return fModes; |
| 133 |
} |
128 |
} |
| 134 |
|
129 |
|
|
|
130 |
/* (non-Javadoc) |
| 131 |
* @see org.eclipse.debug.core.ILaunchDelegateProxy#getModes() |
| 132 |
*/ |
| 133 |
public List getModes() { |
| 134 |
if(fLaunchModes == null) { |
| 135 |
fLaunchModes = new ArrayList(); |
| 136 |
IConfigurationElement[] children = fElement.getChildren(IConfigurationElementConstants.MODES_COMBINATION); |
| 137 |
for (int i = 0; i < children.length; i++) { |
| 138 |
fLaunchModes.add(getModes(children[i])); |
| 139 |
} |
| 140 |
if(fLaunchModes.size() == 0) { |
| 141 |
//try to get the modes from the old definition and make each one |
| 142 |
//a seperate set of one element |
| 143 |
String modes = fElement.getAttribute(IConfigurationElementConstants.MODES); |
| 144 |
if (modes != null) { |
| 145 |
String[] strings = modes.split(","); //$NON-NLS-1$ |
| 146 |
HashSet modeset = null; |
| 147 |
for (int i = 0; i < strings.length; i++) { |
| 148 |
modeset = new HashSet(); |
| 149 |
modeset.add(strings[i].trim()); |
| 150 |
fLaunchModes.add(modeset); |
| 151 |
} |
| 152 |
} |
| 153 |
} |
| 154 |
} |
| 155 |
return fLaunchModes; |
| 156 |
} |
| 157 |
|
| 135 |
/** |
158 |
/** |
| 136 |
* Returns the human readable name for this launch delegate |
159 |
* Returns the human readable name for this launch delegate |
| 137 |
* @return the human readable name for this launch delegate, or <code>null</code> if none |
160 |
* @return the human readable name for this launch delegate, or <code>null</code> if none |
|
Lines 164-218
Link Here
|
| 164 |
public String getSourcePathComputerId() { |
187 |
public String getSourcePathComputerId() { |
| 165 |
return fElement.getAttribute(IConfigurationElementConstants.SOURCE_PATH_COMPUTER); |
188 |
return fElement.getAttribute(IConfigurationElementConstants.SOURCE_PATH_COMPUTER); |
| 166 |
} |
189 |
} |
| 167 |
|
|
|
| 168 |
/** |
| 169 |
* Returns all combinations of supported options. |
| 170 |
* |
| 171 |
* @return combinations of supported options |
| 172 |
*/ |
| 173 |
private Collection getOptionSets() { |
| 174 |
Set optionSets = new HashSet(); |
| 175 |
optionSets.add(new HashSet()); // seed with the empty option set |
| 176 |
Object[] options = getOptions().toArray(); |
| 177 |
boolean grew = false; |
| 178 |
do { |
| 179 |
grew = false; |
| 180 |
Set[] sets = (Set[]) optionSets.toArray(new Set[optionSets.size()]); |
| 181 |
for (int i = 0; i < sets.length; i++) { |
| 182 |
Set optionSet = sets[i]; |
| 183 |
for (int j = 0; j < options.length; j++) { |
| 184 |
Object option = options[j]; |
| 185 |
Set newOptionSet = new HashSet(optionSet); |
| 186 |
if (newOptionSet.add(option)) { |
| 187 |
if (optionSets.add(newOptionSet)) { |
| 188 |
grew = true; |
| 189 |
} |
| 190 |
} |
| 191 |
} |
| 192 |
} |
| 193 |
} while (grew); |
| 194 |
return optionSets; |
| 195 |
} |
| 196 |
|
| 197 |
/** |
| 198 |
* Returns all supported launch mode combinations as sets of modes. |
| 199 |
* |
| 200 |
* @return all supported launch mode combinations |
| 201 |
*/ |
| 202 |
List getModeCombinations() { |
| 203 |
Collection optionSets = getOptionSets(); |
| 204 |
Object[] modes = getModes().toArray(); |
| 205 |
List combinations = new ArrayList(optionSets.size() * modes.length); |
| 206 |
Iterator iterator = optionSets.iterator(); |
| 207 |
while (iterator.hasNext()) { |
| 208 |
Set optionSet = (Set) iterator.next(); |
| 209 |
for (int i = 0; i < modes.length; i++) { |
| 210 |
Object mode = modes[i]; |
| 211 |
Set set = new HashSet(optionSet); |
| 212 |
set.add(mode); |
| 213 |
combinations.add(set); |
| 214 |
} |
| 215 |
} |
| 216 |
return combinations; |
| 217 |
} |
| 218 |
} |
190 |
} |