Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 328366 | Differences between
and this patch

Collapse All | Expand All

(-)schema/completionProposal.exsd (+10 lines)
Lines 195-200 Link Here
195
               </documentation>
195
               </documentation>
196
            </annotation>
196
            </annotation>
197
         </attribute>
197
         </attribute>
198
         <attribute name="autoActivationDelegate" type="string">
199
            <annotation>
200
               <documentation>
201
                  Identifies a class that is responsible for identifying auto-activation characters for the associated content and partition type.
202
               </documentation>
203
               <appInfo>
204
                  <meta.attribute kind="java" basedOn="org.eclipse.wst.sse.ui.contentassist.AutoActivationDelegate:"/>
205
               </appInfo>
206
            </annotation>
207
         </attribute>
198
      </complexType>
208
      </complexType>
199
   </element>
209
   </element>
200
210
(-)src/org/eclipse/wst/sse/ui/contentassist/AutoActivationDelegate.java (+24 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.sse.ui.contentassist;
12
13
public abstract class AutoActivationDelegate {
14
15
	public char[] getCompletionProposalAutoActivationCharacters() {
16
		return null;
17
	}
18
19
	public char[] getContextInformationAutoActivationCharacters() {
20
		return null;
21
	}
22
23
	public abstract void dispose();
24
}
(-)src/org/eclipse/wst/sse/ui/contentassist/StructuredContentAssistProcessor.java (-2 / +12 lines)
Lines 176-181 Link Here
176
	/** the context information validator for this processor */
176
	/** the context information validator for this processor */
177
	private IContextInformationValidator fContextInformationValidator;
177
	private IContextInformationValidator fContextInformationValidator;
178
	
178
	
179
	private AutoActivationDelegate fAutoActivation;
180
179
	/**
181
	/**
180
	 * <p>Create a new content assist processor for a specific partition type. 
182
	 * <p>Create a new content assist processor for a specific partition type. 
181
	 * The content type will be determined when a document is set on the viewer</p>
183
	 * The content type will be determined when a document is set on the viewer</p>
Lines 291-297 Link Here
291
	 * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
293
	 * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
292
	 */
294
	 */
293
	public char[] getCompletionProposalAutoActivationCharacters() {
295
	public char[] getCompletionProposalAutoActivationCharacters() {
294
		return null;
296
		return (fAutoActivation != null) ? fAutoActivation.getCompletionProposalAutoActivationCharacters() : null;
295
	}
297
	}
296
298
297
	/**
299
	/**
Lines 301-307 Link Here
301
	 * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
303
	 * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
302
	 */
304
	 */
303
	public char[] getContextInformationAutoActivationCharacters() {
305
	public char[] getContextInformationAutoActivationCharacters() {
304
		return null;
306
		return (fAutoActivation != null) ? fAutoActivation.getContextInformationAutoActivationCharacters() : null;
305
	}
307
	}
306
308
307
	/**
309
	/**
Lines 333-338 Link Here
333
	 * @see org.eclipse.wst.sse.ui.internal.IReleasable#release()
335
	 * @see org.eclipse.wst.sse.ui.internal.IReleasable#release()
334
	 */
336
	 */
335
	public void release() {
337
	public void release() {
338
		if (fAutoActivation != null) {
339
			fAutoActivation.dispose();
340
			fAutoActivation = null;
341
		}
336
		if(this.fPreferenceStore != null) {
342
		if(this.fPreferenceStore != null) {
337
			this.fPreferenceStore.removePropertyChangeListener(this);
343
			this.fPreferenceStore.removePropertyChangeListener(this);
338
			this.fPreferenceStore = null;
344
			this.fPreferenceStore = null;
Lines 891-896 Link Here
891
						model = StructuredModelManager.getModelManager().getModelForRead((IStructuredDocument)newInput);
897
						model = StructuredModelManager.getModelManager().getModelForRead((IStructuredDocument)newInput);
892
						if(model != null) {
898
						if(model != null) {
893
							fContentTypeID = model.getContentTypeIdentifier();
899
							fContentTypeID = model.getContentTypeIdentifier();
900
							if (fAutoActivation != null) {
901
								fAutoActivation.dispose();
902
							}
903
							fAutoActivation = CompletionProposalComputerRegistry.getDefault().getActivator(fContentTypeID, fPartitionTypeID);
894
						}
904
						}
895
					} finally {
905
					} finally {
896
						if(model != null) {
906
						if(model != null) {
(-)src/org/eclipse/wst/sse/ui/internal/contentassist/CompletionProposalComputerDescriptor.java (+1 lines)
Lines 470-475 Link Here
470
						ContentAssistUtils.checkExtensionAttributeNotNull(partitionTypeID, ATTR_ID, partitionTypes[partitionTypeIndex]);
470
						ContentAssistUtils.checkExtensionAttributeNotNull(partitionTypeID, ATTR_ID, partitionTypes[partitionTypeIndex]);
471
						
471
						
472
						CompletionProposalComputerRegistry.getDefault().putDescription(contentTypeID, partitionTypeID, desc);
472
						CompletionProposalComputerRegistry.getDefault().putDescription(contentTypeID, partitionTypeID, desc);
473
						CompletionProposalComputerRegistry.getDefault().putAutoActivator(contentTypeID, partitionTypeID, partitionTypes[partitionTypeIndex]);
473
					}
474
					}
474
				} else {
475
				} else {
475
					CompletionProposalComputerRegistry.getDefault().putDescription(contentTypeID, null, desc);
476
					CompletionProposalComputerRegistry.getDefault().putDescription(contentTypeID, null, desc);
(-)src/org/eclipse/wst/sse/ui/internal/contentassist/CompletionProposalComputerRegistry.java (+50 lines)
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 = "autoActivationClass"; //$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 235-240 Link Here
235
		context.putDescriptor(partitionTypeID, descriptor);
239
		context.putDescriptor(partitionTypeID, descriptor);
236
	}
240
	}
237
241
242
	private Map fAutoActivators = new HashMap();
243
244
	static class Activator {
245
		IConfigurationElement fElement;
246
247
		public Activator(IConfigurationElement element) {
248
			fElement = element;
249
		}
250
251
		AutoActivationDelegate createAutoActivation() {
252
			AutoActivationDelegate activation = null;
253
			if (fElement != null) {
254
				try {
255
					activation = (AutoActivationDelegate) fElement.createExecutableExtension(ATTR_AUTO_ACTIVATION_CLASS);
256
				} catch (CoreException e) {
257
				}
258
			}
259
			return activation;
260
		}
261
262
	}
263
264
	void putAutoActivator(String contentTypeID, String partitionTypeID, IConfigurationElement element) {
265
		String autoActivationClass = element.getAttribute(ATTR_AUTO_ACTIVATION_CLASS);
266
		if (autoActivationClass == null)
267
			return;
268
269
		Map partitionMap = (Map) fAutoActivators.get(contentTypeID);
270
		if (partitionMap == null) {
271
			partitionMap = new HashMap();
272
			fAutoActivators.put(contentTypeID, partitionMap);
273
		}
274
		partitionMap.put(partitionTypeID, new Activator(element));
275
	}
276
277
	public AutoActivationDelegate getActivator(String contentTypeID, String partitionTypeID) {
278
		Map partitionMap = (Map) fAutoActivators.get(contentTypeID);
279
		if (partitionMap != null) {
280
			Activator activator = (Activator) partitionMap.get(partitionTypeID);
281
			if (activator != null) {
282
				return activator.createAutoActivation();
283
			}
284
		}
285
		return null;
286
	}
287
238
	/**
288
	/**
239
	 * @param contentTypeID get only descriptors associated with this content type
289
	 * @param contentTypeID get only descriptors associated with this content type
240
	 * @param partitionTypeID get only descriptors associated with this partition type as well
290
	 * @param partitionTypeID get only descriptors associated with this partition type as well

Return to bug 328366