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 326602
Collapse All | Expand All

(-)src/org/eclipse/wst/jsdt/web/support/jsp/JSDTStructuredTextViewerConfigurationJSP.java (+31 lines)
Lines 14-24 Link Here
14
package org.eclipse.wst.jsdt.web.support.jsp;
14
package org.eclipse.wst.jsdt.web.support.jsp;
15
15
16
import org.eclipse.jface.text.IAutoEditStrategy;
16
import org.eclipse.jface.text.IAutoEditStrategy;
17
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
17
import org.eclipse.jface.text.source.ISourceViewer;
18
import org.eclipse.jface.text.source.ISourceViewer;
18
import org.eclipse.jst.jsp.core.text.IJSPPartitions;
19
import org.eclipse.jst.jsp.core.text.IJSPPartitions;
19
import org.eclipse.jst.jsp.ui.StructuredTextViewerConfigurationJSP;
20
import org.eclipse.jst.jsp.ui.StructuredTextViewerConfigurationJSP;
20
import org.eclipse.wst.html.core.text.IHTMLPartitions;
21
import org.eclipse.wst.html.core.text.IHTMLPartitions;
22
import org.eclipse.wst.jsdt.web.core.text.IJsPartitions;
21
import org.eclipse.wst.jsdt.web.ui.StructuredTextViewerConfigurationJSDT;
23
import org.eclipse.wst.jsdt.web.ui.StructuredTextViewerConfigurationJSDT;
24
import org.eclipse.wst.jsdt.web.ui.contentassist.JSDTStructuredContentAssistProcessor;
22
import org.eclipse.wst.jsdt.web.ui.internal.autoedit.AutoEditStrategyForJs;
25
import org.eclipse.wst.jsdt.web.ui.internal.autoedit.AutoEditStrategyForJs;
23
import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration;
26
import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration;
24
import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
27
import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
Lines 73-76 Link Here
73
			return super.getAutoEditStrategies(sourceViewer, contentType);
76
			return super.getAutoEditStrategies(sourceViewer, contentType);
74
		}
77
		}
75
	}
78
	}
79
	
80
	/**
81
	 * @see org.eclipse.jst.jsp.ui.StructuredTextViewerConfigurationJSP#getContentAssistProcessors(org.eclipse.jface.text.source.ISourceViewer, java.lang.String)
82
	 */
83
	protected IContentAssistProcessor[] getContentAssistProcessors(
84
			ISourceViewer sourceViewer, String partitionType) {
85
		
86
		IContentAssistProcessor[] processors;
87
		
88
		if(isJavascriptPartitionType(partitionType)) {
89
			IContentAssistProcessor processor = new JSDTStructuredContentAssistProcessor(
90
					this.getContentAssistant(), partitionType, sourceViewer);
91
			processors = new IContentAssistProcessor[]{processor};
92
		} else {
93
			processors = super.getContentAssistProcessors(sourceViewer, partitionType);
94
		} 
95
		
96
		return processors;
97
	}
98
	
99
	/**
100
	 * @param partitionTypeID check to see if this partition type ID is for a Javascript partition type
101
	 * @return <code>true</code> if the given partiton type is a Javascript partition type,
102
	 * <code>false</code> otherwise
103
	 */
104
	private static boolean isJavascriptPartitionType(String partitionTypeID) {
105
		return IJsPartitions.HtmlJsPartition.equals(partitionTypeID);
106
	}
76
}
107
}
(-)META-INF/MANIFEST.MF (+1 lines)
Lines 7-12 Link Here
7
Bundle-Vendor: %Bundle-Vendor.0
7
Bundle-Vendor: %Bundle-Vendor.0
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
9
Export-Package: org.eclipse.wst.jsdt.web.ui;x-internal:=true,
9
Export-Package: org.eclipse.wst.jsdt.web.ui;x-internal:=true,
10
 org.eclipse.wst.jsdt.web.ui.contentassist,
10
 org.eclipse.wst.jsdt.web.ui.internal;x-internal:=true,
11
 org.eclipse.wst.jsdt.web.ui.internal;x-internal:=true,
11
 org.eclipse.wst.jsdt.web.ui.internal.autoedit;x-internal:=true,
12
 org.eclipse.wst.jsdt.web.ui.internal.autoedit;x-internal:=true,
12
 org.eclipse.wst.jsdt.web.ui.internal.contentassist;x-internal:=true,
13
 org.eclipse.wst.jsdt.web.ui.internal.contentassist;x-internal:=true,
(-)src/org/eclipse/wst/jsdt/web/ui/StructuredTextViewerConfigurationJSDT.java (+31 lines)
Lines 11-19 Link Here
11
package org.eclipse.wst.jsdt.web.ui;
11
package org.eclipse.wst.jsdt.web.ui;
12
12
13
import org.eclipse.jface.text.IAutoEditStrategy;
13
import org.eclipse.jface.text.IAutoEditStrategy;
14
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
14
import org.eclipse.jface.text.source.ISourceViewer;
15
import org.eclipse.jface.text.source.ISourceViewer;
15
import org.eclipse.wst.html.core.text.IHTMLPartitions;
16
import org.eclipse.wst.html.core.text.IHTMLPartitions;
16
import org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML;
17
import org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML;
18
import org.eclipse.wst.jsdt.web.core.text.IJsPartitions;
19
import org.eclipse.wst.jsdt.web.ui.contentassist.JSDTStructuredContentAssistProcessor;
17
import org.eclipse.wst.jsdt.web.ui.internal.autoedit.AutoEditStrategyForJs;
20
import org.eclipse.wst.jsdt.web.ui.internal.autoedit.AutoEditStrategyForJs;
18
21
19
/**
22
/**
Lines 54-57 Link Here
54
			return super.getAutoEditStrategies(sourceViewer, contentType);
57
			return super.getAutoEditStrategies(sourceViewer, contentType);
55
		}
58
		}
56
	}
59
	}
60
	
61
	/**
62
	 * @see org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML#getContentAssistProcessors(org.eclipse.jface.text.source.ISourceViewer, java.lang.String)
63
	 */
64
	protected IContentAssistProcessor[] getContentAssistProcessors(
65
			ISourceViewer sourceViewer, String partitionType) {
66
		
67
		IContentAssistProcessor[] processors;
68
		
69
		if(isJavascriptPartitionType(partitionType)) {
70
			IContentAssistProcessor processor = new JSDTStructuredContentAssistProcessor(
71
					this.getContentAssistant(), partitionType, sourceViewer);
72
			processors = new IContentAssistProcessor[]{processor};
73
		} else {
74
			processors = super.getContentAssistProcessors(sourceViewer, partitionType);
75
		} 
76
		
77
		return processors;
78
	}
79
	
80
	/**
81
	 * @param partitionTypeID check to see if this partition type ID is for a Javascript partition type
82
	 * @return <code>true</code> if the given partiton type is a Javascript partition type,
83
	 * <code>false</code> otherwise
84
	 */
85
	private static boolean isJavascriptPartitionType(String partitionTypeID) {
86
		return IJsPartitions.HtmlJsPartition.equals(partitionTypeID);
87
	}
57
}
88
}
(-)src/org/eclipse/wst/jsdt/web/ui/contentassist/JSDTStructuredContentAssistProcessor.java (+78 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.jsdt.web.ui.contentassist;
12
13
import org.eclipse.jface.preference.IPreferenceStore;
14
import org.eclipse.jface.text.ITextViewer;
15
import org.eclipse.jface.text.contentassist.ContentAssistant;
16
import org.eclipse.jface.util.PropertyChangeEvent;
17
import org.eclipse.wst.jsdt.ui.PreferenceConstants;
18
import org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor;
19
20
/**
21
 * <p>Content assist processor for Javascript regions so that autoactivation will work in those regions.</p>
22
 * 
23
 * <p><b>NOTE:</b> This class does not check that the given partition type is a javascript region, it just
24
 * assumes it is, so the instantiator of this class must be sure they want the given partition type to be
25
 * treated as if it was Javascript.</p>
26
 */
27
public class JSDTStructuredContentAssistProcessor extends StructuredContentAssistProcessor {
28
	/** auto activation characters */
29
	private char[] fCompletionPropoaslAutoActivationCharacters;
30
31
	/**
32
	 * @param assistant {@link ContentAssistant} to use
33
	 * @param partitionTypeID the Javascript partition type this processor is for
34
	 * @param viewer {@link ITextViewer} this processor is acting in
35
	 */
36
	public JSDTStructuredContentAssistProcessor(ContentAssistant assistant,
37
			String partitionTypeID, ITextViewer viewer) {
38
		super(assistant, partitionTypeID, viewer, PreferenceConstants.getPreferenceStore());
39
		
40
		//get the current user preference
41
		getAutoActivationCharacterPreferences();
42
	}
43
	
44
	/**
45
	 * @see org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
46
	 */
47
	public char[] getCompletionProposalAutoActivationCharacters() {
48
		return this.fCompletionPropoaslAutoActivationCharacters;
49
	}
50
	
51
	/**
52
	 * @see org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor#propertyChange(
53
	 * 	org.eclipse.jface.util.PropertyChangeEvent)
54
	 */
55
	public void propertyChange(PropertyChangeEvent event) {
56
		String property = event.getProperty();
57
		if(property.equals(PreferenceConstants.CODEASSIST_AUTOACTIVATION) ||
58
				property.equals(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA)) {
59
			
60
			getAutoActivationCharacterPreferences();
61
		}
62
	}
63
	
64
	/**
65
	 * <p>Gets the auto activation character user preferences for Javascript and stores them for later use</p>
66
	 */
67
	private void getAutoActivationCharacterPreferences() {
68
		IPreferenceStore store = getPreferenceStore();
69
		
70
		boolean doAuto = store.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
71
		if (doAuto) {
72
			fCompletionPropoaslAutoActivationCharacters =
73
				store.getString(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA).toCharArray();
74
		} else {
75
			fCompletionPropoaslAutoActivationCharacters = null;
76
		}
77
	}
78
}

Return to bug 326602