|
Lines 30-35
Link Here
|
| 30 |
import org.eclipse.core.runtime.Status; |
30 |
import org.eclipse.core.runtime.Status; |
| 31 |
import org.eclipse.core.runtime.content.IContentType; |
31 |
import org.eclipse.core.runtime.content.IContentType; |
| 32 |
import org.eclipse.jface.preference.IPreferenceStore; |
32 |
import org.eclipse.jface.preference.IPreferenceStore; |
|
|
33 |
import org.eclipse.wst.sse.ui.contentassist.AutoActivationDelegate; |
| 33 |
import org.eclipse.wst.sse.ui.internal.Logger; |
34 |
import org.eclipse.wst.sse.ui.internal.Logger; |
| 34 |
import org.eclipse.wst.sse.ui.internal.SSEUIPlugin; |
35 |
import org.eclipse.wst.sse.ui.internal.SSEUIPlugin; |
| 35 |
|
36 |
|
|
Lines 55-60
Link Here
|
| 55 |
|
56 |
|
| 56 |
/** The extension schema name for element ID attributes */ |
57 |
/** The extension schema name for element ID attributes */ |
| 57 |
private static final String ATTR_ID= "id"; //$NON-NLS-1$ |
58 |
private static final String ATTR_ID= "id"; //$NON-NLS-1$ |
|
|
59 |
|
| 60 |
/** The extension schema name for the partition's auto-activation class */ |
| 61 |
private static final String ATTR_AUTO_ACTIVATION_CLASS = "autoActivationDelegate"; //$NON-NLS-1$ |
| 58 |
|
62 |
|
| 59 |
/** preference key to keep track of the last known number of content assist computers */ |
63 |
/** preference key to keep track of the last known number of content assist computers */ |
| 60 |
private static final String NUM_COMPUTERS_PREF_KEY = "content_assist_number_of_computers"; //$NON-NLS-1$ |
64 |
private static final String NUM_COMPUTERS_PREF_KEY = "content_assist_number_of_computers"; //$NON-NLS-1$ |
|
Lines 109-114
Link Here
|
| 109 |
*/ |
113 |
*/ |
| 110 |
private final Map fDescriptors = new HashMap(); |
114 |
private final Map fDescriptors = new HashMap(); |
| 111 |
|
115 |
|
|
|
116 |
/** A map maintaining the relationship between content types, partition types and their associated {@link AutoActivationDelegate}s*/ |
| 117 |
private Map fAutoActivators = new HashMap(); |
| 118 |
|
| 112 |
/** The {@link CompletionProposalCategory}s tracked by this registry */ |
119 |
/** The {@link CompletionProposalCategory}s tracked by this registry */ |
| 113 |
private final List fCategories = new ArrayList(); |
120 |
private final List fCategories = new ArrayList(); |
| 114 |
|
121 |
|
|
Lines 235-240
Link Here
|
| 235 |
context.putDescriptor(partitionTypeID, descriptor); |
242 |
context.putDescriptor(partitionTypeID, descriptor); |
| 236 |
} |
243 |
} |
| 237 |
|
244 |
|
|
|
245 |
void putAutoActivator(String contentTypeID, String partitionTypeID, IConfigurationElement element) { |
| 246 |
String autoActivationClass = element.getAttribute(ATTR_AUTO_ACTIVATION_CLASS); |
| 247 |
if (autoActivationClass == null) |
| 248 |
return; |
| 249 |
|
| 250 |
Map partitionMap = (Map) fAutoActivators.get(contentTypeID); |
| 251 |
if (partitionMap == null) { |
| 252 |
partitionMap = new HashMap(); |
| 253 |
fAutoActivators.put(contentTypeID, partitionMap); |
| 254 |
} |
| 255 |
partitionMap.put(partitionTypeID, new Activator(element)); |
| 256 |
} |
| 257 |
|
| 258 |
public AutoActivationDelegate getActivator(String contentTypeID, String partitionTypeID) { |
| 259 |
Map partitionMap = (Map) fAutoActivators.get(contentTypeID); |
| 260 |
if (partitionMap != null) { |
| 261 |
Activator activator = (Activator) partitionMap.get(partitionTypeID); |
| 262 |
if (activator != null) { |
| 263 |
return activator.createAutoActivation(); |
| 264 |
} |
| 265 |
} |
| 266 |
return null; |
| 267 |
} |
| 268 |
|
| 238 |
/** |
269 |
/** |
| 239 |
* @param contentTypeID get only descriptors associated with this content type |
270 |
* @param contentTypeID get only descriptors associated with this content type |
| 240 |
* @param partitionTypeID get only descriptors associated with this partition type as well |
271 |
* @param partitionTypeID get only descriptors associated with this partition type as well |
|
Lines 505-508
Link Here
|
| 505 |
|
536 |
|
| 506 |
return contexts; |
537 |
return contexts; |
| 507 |
} |
538 |
} |
|
|
539 |
|
| 540 |
private static class Activator { |
| 541 |
IConfigurationElement fElement; |
| 542 |
|
| 543 |
public Activator(IConfigurationElement element) { |
| 544 |
fElement = element; |
| 545 |
} |
| 546 |
|
| 547 |
AutoActivationDelegate createAutoActivation() { |
| 548 |
AutoActivationDelegate activation = null; |
| 549 |
if (fElement != null) { |
| 550 |
try { |
| 551 |
activation = (AutoActivationDelegate) fElement.createExecutableExtension(ATTR_AUTO_ACTIVATION_CLASS); |
| 552 |
} catch (CoreException e) { |
| 553 |
} |
| 554 |
} |
| 555 |
return activation; |
| 556 |
} |
| 557 |
|
| 558 |
} |
| 508 |
} |
559 |
} |