1 package net.sourceforge.phpeclipse.xml.ui.internal.preferences;
3 import net.sourceforge.phpeclipse.ui.PreferenceConstants;
4 import net.sourceforge.phpeclipse.ui.templates.template.BasicCompletionProcessor;
5 import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLPartitionScanner;
7 import org.eclipse.jface.preference.IPreferenceStore;
8 import org.eclipse.jface.text.contentassist.ContentAssistant;
9 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
12 public class ContentAssistPreference {
13 /** Preference key for html content assist auto activation triggers */
14 private final static String AUTOACTIVATION_TRIGGERS_HTML = PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_HTML;
16 /** Preference key for alphabetic ordering of proposals */
17 private final static String ORDER_PROPOSALS = PreferenceConstants.CODEASSIST_ORDER_PROPOSALS;
19 private static BasicCompletionProcessor getHTMLProcessor(ContentAssistant assistant) {
20 IContentAssistProcessor p = assistant.getContentAssistProcessor(XMLPartitionScanner.XML_TAG);
21 if (p instanceof BasicCompletionProcessor)
22 return (BasicCompletionProcessor) p;
26 private static void configureHTMLProcessor(ContentAssistant assistant, IPreferenceStore store) {
27 BasicCompletionProcessor hcp = getHTMLProcessor(assistant);
31 String triggers = store.getString(AUTOACTIVATION_TRIGGERS_HTML);
33 hcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
36 // boolean enabled = store.getBoolean(CASE_SENSITIVITY);
37 // jdcp.restrictProposalsToMatchingCases(enabled);
39 enabled = store.getBoolean(ORDER_PROPOSALS);
40 // hcp.orderProposalsAlphabetically(enabled);
42 private static void changeHTMLProcessor(ContentAssistant assistant, IPreferenceStore store, String key) {
43 BasicCompletionProcessor jdcp = getHTMLProcessor(assistant);
47 if (AUTOACTIVATION_TRIGGERS_HTML.equals(key)) {
48 String triggers = store.getString(AUTOACTIVATION_TRIGGERS_HTML);
50 jdcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
51 // } else if (CASE_SENSITIVITY.equals(key)) {
52 // boolean enabled = store.getBoolean(CASE_SENSITIVITY);
53 // jdcp.restrictProposalsToMatchingCases(enabled);
54 } else if (ORDER_PROPOSALS.equals(key)) {
55 boolean enable = store.getBoolean(ORDER_PROPOSALS);
56 // jdcp.orderProposalsAlphabetically(enable);