Lines 39-44
Link Here
|
39 |
import org.eclipse.jface.text.contentassist.ContentAssistEvent; |
39 |
import org.eclipse.jface.text.contentassist.ContentAssistEvent; |
40 |
import org.eclipse.jface.text.contentassist.ContentAssistant; |
40 |
import org.eclipse.jface.text.contentassist.ContentAssistant; |
41 |
import org.eclipse.jface.text.contentassist.ICompletionListener; |
41 |
import org.eclipse.jface.text.contentassist.ICompletionListener; |
|
|
42 |
import org.eclipse.jface.text.contentassist.ICompletionListenerExtension; |
42 |
import org.eclipse.jface.text.contentassist.ICompletionProposal; |
43 |
import org.eclipse.jface.text.contentassist.ICompletionProposal; |
43 |
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; |
44 |
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; |
44 |
import org.eclipse.jface.text.contentassist.IContentAssistant; |
45 |
import org.eclipse.jface.text.contentassist.IContentAssistant; |
Lines 121-225
Link Here
|
121 |
|
122 |
|
122 |
private String fErrorMessage; |
123 |
private String fErrorMessage; |
123 |
|
124 |
|
124 |
public ContentAssistProcessor(ContentAssistant assistant, String partition) { |
125 |
class CompletionListener implements ICompletionListener, |
125 |
Assert.isNotNull(partition); |
126 |
ICompletionListenerExtension { |
126 |
Assert.isNotNull(assistant); |
|
|
127 |
|
127 |
|
128 |
fPartition = partition; |
|
|
129 |
fCategories = CompletionProposalComputerRegistry.getDefault() |
130 |
.getProposalCategories(); |
131 |
fAssistant = assistant; |
132 |
fAssistant.addCompletionListener(new ICompletionListener() { |
133 |
|
128 |
|
134 |
public void assistSessionStarted(ContentAssistEvent event) { |
129 |
public void assistSessionStarted(ContentAssistEvent event) { |
135 |
|
130 |
|
136 |
if (event.processor != ContentAssistProcessor.this) { |
131 |
if (event.processor != ContentAssistProcessor.this) { |
137 |
final IContentAssistant assistant = event.assistant; |
132 |
final IContentAssistant assistant = event.assistant; |
138 |
if (assistant instanceof IScriptContentAssistExtension) { |
133 |
if (assistant instanceof IScriptContentAssistExtension) { |
139 |
final IScriptContentAssistExtension extension = (IScriptContentAssistExtension) assistant; |
134 |
final IScriptContentAssistExtension extension = (IScriptContentAssistExtension) assistant; |
140 |
if (!extension.provide(event.processor)) |
135 |
if (!extension.provide(event.processor)) |
141 |
return; |
|
|
142 |
} else { |
143 |
return; |
136 |
return; |
144 |
} |
137 |
} else { |
|
|
138 |
return; |
145 |
} |
139 |
} |
|
|
140 |
} |
146 |
|
141 |
|
147 |
fIterationGesture = getIterationGesture(); |
142 |
fIterationGesture = getIterationGesture(); |
148 |
KeySequence binding = getIterationBinding(); |
143 |
KeySequence binding = getIterationBinding(); |
149 |
|
|
|
150 |
// this may show the warning dialog if all categories are |
151 |
// disabled |
152 |
fCategoryIteration = getCategoryIteration(); |
153 |
for (CompletionProposalCategory cat : fCategories) { |
154 |
cat.sessionStarted(); |
155 |
} |
156 |
|
144 |
|
157 |
fRepetition = 0; |
145 |
// this may show the warning dialog if all categories are |
158 |
if (event.assistant instanceof IContentAssistantExtension2) { |
146 |
// disabled |
159 |
IContentAssistantExtension2 extension = (IContentAssistantExtension2) event.assistant; |
147 |
fCategoryIteration = getCategoryIteration(); |
160 |
|
148 |
for (CompletionProposalCategory cat : fCategories) { |
161 |
if (fCategoryIteration.size() == 1) { |
149 |
cat.sessionStarted(); |
162 |
extension.setRepeatedInvocationMode(false); |
|
|
163 |
extension.setShowEmptyList(false); |
164 |
} else { |
165 |
extension.setRepeatedInvocationMode(true); |
166 |
extension.setStatusLineVisible(true); |
167 |
extension.setStatusMessage(createIterationMessage()); |
168 |
extension.setShowEmptyList(true); |
169 |
if (extension instanceof IContentAssistantExtension3) { |
170 |
IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension; |
171 |
((ContentAssistant) ext3) |
172 |
.setRepeatedInvocationTrigger(binding); |
173 |
} |
174 |
} |
175 |
|
176 |
} |
177 |
} |
150 |
} |
178 |
|
151 |
|
179 |
/* |
152 |
fRepetition = 0; |
180 |
* @seeorg.eclipse.jface.text.contentassist.ICompletionListener# |
153 |
if (event.assistant instanceof IContentAssistantExtension2) { |
181 |
* assistSessionEnded |
154 |
IContentAssistantExtension2 extension = (IContentAssistantExtension2) event.assistant; |
182 |
* (org.eclipse.jface.text.contentassist.ContentAssistEvent) |
|
|
183 |
*/ |
184 |
public void assistSessionEnded(ContentAssistEvent event) { |
185 |
|
186 |
if (event.processor != ContentAssistProcessor.this) { |
187 |
final IContentAssistant assistant = event.assistant; |
188 |
if (assistant instanceof IScriptContentAssistExtension) { |
189 |
final IScriptContentAssistExtension extension = (IScriptContentAssistExtension) assistant; |
190 |
if (!extension.provide(event.processor)) |
191 |
return; |
192 |
} else { |
193 |
return; |
194 |
} |
195 |
} |
196 |
|
155 |
|
197 |
for (CompletionProposalCategory cat : fCategories) { |
156 |
if (fCategoryIteration.size() == 1) { |
198 |
cat.sessionEnded(); |
|
|
199 |
} |
200 |
|
201 |
fCategoryIteration = null; |
202 |
fRepetition = -1; |
203 |
fIterationGesture = null; |
204 |
if (event.assistant instanceof IContentAssistantExtension2) { |
205 |
IContentAssistantExtension2 extension = (IContentAssistantExtension2) event.assistant; |
206 |
extension.setShowEmptyList(false); |
207 |
extension.setRepeatedInvocationMode(false); |
157 |
extension.setRepeatedInvocationMode(false); |
208 |
extension.setStatusLineVisible(false); |
158 |
extension.setShowEmptyList(false); |
|
|
159 |
} else { |
160 |
extension.setRepeatedInvocationMode(true); |
161 |
extension.setStatusLineVisible(true); |
162 |
extension.setStatusMessage(createIterationMessage()); |
163 |
extension.setShowEmptyList(true); |
209 |
if (extension instanceof IContentAssistantExtension3) { |
164 |
if (extension instanceof IContentAssistantExtension3) { |
210 |
IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension; |
165 |
IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension; |
211 |
((ContentAssistant) ext3) |
166 |
((ContentAssistant) ext3) |
212 |
.setRepeatedInvocationTrigger(KeySequence |
167 |
.setRepeatedInvocationTrigger(binding); |
213 |
.getInstance()); |
|
|
214 |
} |
168 |
} |
215 |
} |
169 |
} |
|
|
170 |
|
171 |
} |
172 |
} |
173 |
|
174 |
/* |
175 |
* @seeorg.eclipse.jface.text.contentassist.ICompletionListener# |
176 |
* assistSessionEnded |
177 |
* (org.eclipse.jface.text.contentassist.ContentAssistEvent) |
178 |
*/ |
179 |
public void assistSessionEnded(ContentAssistEvent event) { |
180 |
|
181 |
if (event.processor != ContentAssistProcessor.this) { |
182 |
final IContentAssistant assistant = event.assistant; |
183 |
if (assistant instanceof IScriptContentAssistExtension) { |
184 |
final IScriptContentAssistExtension extension = (IScriptContentAssistExtension) assistant; |
185 |
if (!extension.provide(event.processor)) |
186 |
return; |
187 |
} else { |
188 |
return; |
189 |
} |
190 |
} |
191 |
|
192 |
for (CompletionProposalCategory cat : fCategories) { |
193 |
cat.sessionEnded(); |
216 |
} |
194 |
} |
217 |
|
195 |
|
218 |
public void selectionChanged(ICompletionProposal proposal, |
196 |
fCategoryIteration = null; |
219 |
boolean smartToggle) { |
197 |
fRepetition = -1; |
|
|
198 |
fIterationGesture = null; |
199 |
if (event.assistant instanceof IContentAssistantExtension2) { |
200 |
IContentAssistantExtension2 extension = (IContentAssistantExtension2) event.assistant; |
201 |
extension.setShowEmptyList(false); |
202 |
extension.setRepeatedInvocationMode(false); |
203 |
extension.setStatusLineVisible(false); |
204 |
if (extension instanceof IContentAssistantExtension3) { |
205 |
IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension; |
206 |
((ContentAssistant) ext3) |
207 |
.setRepeatedInvocationTrigger(KeySequence |
208 |
.getInstance()); |
209 |
} |
220 |
} |
210 |
} |
|
|
211 |
} |
221 |
|
212 |
|
222 |
}); |
213 |
public void selectionChanged(ICompletionProposal proposal, |
|
|
214 |
boolean smartToggle) { |
215 |
} |
216 |
|
217 |
public void assistSessionRestarted(ContentAssistEvent event) { |
218 |
fRepetition = 0; |
219 |
} |
220 |
|
221 |
} |
222 |
|
223 |
public ContentAssistProcessor(ContentAssistant assistant, String partition) { |
224 |
Assert.isNotNull(partition); |
225 |
Assert.isNotNull(assistant); |
226 |
|
227 |
fPartition = partition; |
228 |
fCategories = CompletionProposalComputerRegistry.getDefault() |
229 |
.getProposalCategories(); |
230 |
fAssistant = assistant; |
231 |
fAssistant.addCompletionListener(new CompletionListener()); |
223 |
} |
232 |
} |
224 |
|
233 |
|
225 |
public final ICompletionProposal[] computeCompletionProposals( |
234 |
public final ICompletionProposal[] computeCompletionProposals( |