|
Lines 14-19
Link Here
|
| 14 |
|
14 |
|
| 15 |
import java.util.ArrayList; |
15 |
import java.util.ArrayList; |
| 16 |
import java.util.HashMap; |
16 |
import java.util.HashMap; |
|
|
17 |
import java.util.Iterator; |
| 17 |
import java.util.List; |
18 |
import java.util.List; |
| 18 |
import java.util.Map; |
19 |
import java.util.Map; |
| 19 |
|
20 |
|
|
Lines 77-82
Link Here
|
| 77 |
private static final String EP_EXTENDEDCONFIGURATION = "editorConfiguration"; //$NON-NLS-1$ |
78 |
private static final String EP_EXTENDEDCONFIGURATION = "editorConfiguration"; //$NON-NLS-1$ |
| 78 |
private static ExtendedConfigurationBuilder instance = null; |
79 |
private static ExtendedConfigurationBuilder instance = null; |
| 79 |
public static final String VALUE = "value"; //$NON-NLS-1$ |
80 |
public static final String VALUE = "value"; //$NON-NLS-1$ |
|
|
81 |
public static final String PRIORITY = "priority"; //$NON-NLS-1$ |
| 80 |
|
82 |
|
| 81 |
/** |
83 |
/** |
| 82 |
* Creates an extension. If the extension plugin has not been loaded a |
84 |
* Creates an extension. If the extension plugin has not been loaded a |
|
Lines 185-191
Link Here
|
| 185 |
List configurations = getConfigurations(extensionType, targetID); |
187 |
List configurations = getConfigurations(extensionType, targetID); |
| 186 |
if (configurations.isEmpty()) |
188 |
if (configurations.isEmpty()) |
| 187 |
return null; |
189 |
return null; |
| 188 |
return configurations.get(0); |
190 |
|
|
|
191 |
// select configuration with the highest 'priority' value |
| 192 |
Iterator i = configurations.iterator(); |
| 193 |
Object start = i.next(); |
| 194 |
|
| 195 |
if (start instanceof IConfigurationElement) { |
| 196 |
IConfigurationElement rt = (IConfigurationElement) start; |
| 197 |
float maxPriority = readPriority(rt); |
| 198 |
|
| 199 |
for (;i.hasNext();) { |
| 200 |
Object next = i.next(); |
| 201 |
if (next instanceof IConfigurationElement) { |
| 202 |
IConfigurationElement configuration = (IConfigurationElement) i.next(); |
| 203 |
float priority = readPriority(configuration); |
| 204 |
if (priority > maxPriority) { |
| 205 |
maxPriority = priority; |
| 206 |
rt = configuration; |
| 207 |
} |
| 208 |
} |
| 209 |
} |
| 210 |
return rt; |
| 211 |
} else { |
| 212 |
return start; |
| 213 |
} |
| 214 |
} |
| 215 |
|
| 216 |
/** |
| 217 |
* Reads the <code>priority</code> decimal value for configuration. |
| 218 |
* If undefined or invalid, the default value is returned. |
| 219 |
* Default value is <code>.0f</code>. |
| 220 |
* @param configuration configuration element possibly containing the |
| 221 |
* <code>priority</code> attribute |
| 222 |
* @return value defined by <code>priority</code> attribute or |
| 223 |
* <code>.0f</code>. |
| 224 |
*/ |
| 225 |
private float readPriority(IConfigurationElement configuration) { |
| 226 |
String priorityVal = configuration.getAttribute(PRIORITY); |
| 227 |
if (priorityVal != null) { |
| 228 |
try { |
| 229 |
return Float.parseFloat(priorityVal); |
| 230 |
} catch (NumberFormatException e) { |
| 231 |
return .0f; |
| 232 |
} |
| 233 |
} |
| 234 |
return .0f; |
| 189 |
} |
235 |
} |
| 190 |
|
236 |
|
| 191 |
/** |
237 |
/** |