Mercurial > projects > dwt-addons
annotate dwtx/jface/text/quickassist/QuickAssistAssistant.d @ 162:1a5b8f8129df
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 08 Sep 2008 00:51:37 +0200 |
parents | b6bad70d540a |
children |
rev | line source |
---|---|
129 | 1 /******************************************************************************* |
2 * Copyright (c) 2006, 2008 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 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwtx.jface.text.quickassist.QuickAssistAssistant; | |
14 | |
131 | 15 import dwtx.jface.text.quickassist.IQuickAssistAssistant; // packageimport |
16 import dwtx.jface.text.quickassist.IQuickAssistAssistantExtension; // packageimport | |
17 import dwtx.jface.text.quickassist.IQuickAssistInvocationContext; // packageimport | |
18 import dwtx.jface.text.quickassist.IQuickFixableAnnotation; // packageimport | |
19 import dwtx.jface.text.quickassist.IQuickAssistProcessor; // packageimport | |
20 | |
21 | |
129 | 22 import dwt.dwthelper.utils; |
23 | |
24 | |
25 | |
26 | |
27 import dwt.graphics.Color; | |
28 import dwtx.core.commands.IHandler; | |
29 import dwtx.jface.text.IDocument; | |
30 import dwtx.jface.text.IInformationControlCreator; | |
31 import dwtx.jface.text.ITextViewer; | |
32 import dwtx.jface.text.contentassist.ContentAssistant; | |
33 import dwtx.jface.text.contentassist.ICompletionListener; | |
34 import dwtx.jface.text.contentassist.ICompletionProposal; | |
35 import dwtx.jface.text.contentassist.IContentAssistProcessor; | |
36 import dwtx.jface.text.contentassist.IContextInformation; | |
37 import dwtx.jface.text.contentassist.IContextInformationValidator; | |
38 import dwtx.jface.text.source.Annotation; | |
39 import dwtx.jface.text.source.ISourceViewer; | |
40 import dwtx.jface.text.source.TextInvocationContext; | |
41 | |
42 | |
43 /** | |
44 * Default implementation of <code>IQuickAssistAssistant</code>. | |
162 | 45 * |
129 | 46 * @since 3.2 |
47 */ | |
48 public class QuickAssistAssistant : IQuickAssistAssistant, IQuickAssistAssistantExtension { | |
162 | 49 |
50 | |
129 | 51 private static final class QuickAssistAssistantImpl : ContentAssistant { |
52 /* | |
53 * @see dwtx.jface.text.contentassist.ContentAssistant#possibleCompletionsClosed() | |
54 */ | |
55 public void possibleCompletionsClosed() { | |
56 super.possibleCompletionsClosed(); | |
57 } | |
162 | 58 |
129 | 59 /* |
60 * @see dwtx.jface.text.contentassist.ContentAssistant#hide() | |
61 * @since 3.4 | |
62 */ | |
63 protected void hide() { | |
64 super.hide(); | |
65 } | |
66 } | |
67 | |
162 | 68 |
129 | 69 private static final class ContentAssistProcessor : IContentAssistProcessor { |
70 | |
71 private IQuickAssistProcessor fQuickAssistProcessor; | |
72 | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
73 this(IQuickAssistProcessor processor) { |
129 | 74 fQuickAssistProcessor= processor; |
75 } | |
162 | 76 |
129 | 77 /* |
78 * @see dwtx.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(dwtx.jface.text.ITextViewer, int) | |
79 */ | |
80 public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { | |
81 // panic code - should not happen | |
138 | 82 if (!( cast(ISourceViewer)viewer )) |
129 | 83 return null; |
162 | 84 |
134 | 85 return fQuickAssistProcessor.computeQuickAssistProposals(new TextInvocationContext(cast(ISourceViewer)viewer, offset, -1)); |
129 | 86 } |
87 | |
88 /* | |
89 * @see dwtx.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(dwtx.jface.text.ITextViewer, int) | |
90 */ | |
91 public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { | |
92 return null; | |
93 } | |
94 | |
95 /* | |
96 * @see dwtx.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() | |
97 */ | |
98 public char[] getCompletionProposalAutoActivationCharacters() { | |
99 return null; | |
100 } | |
101 | |
102 /* | |
103 * @see dwtx.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters() | |
104 */ | |
105 public char[] getContextInformationAutoActivationCharacters() { | |
106 return null; | |
107 } | |
108 | |
109 /* | |
110 * @see dwtx.jface.text.contentassist.IContentAssistProcessor#getErrorMessage() | |
111 */ | |
112 public String getErrorMessage() { | |
113 return null; | |
114 } | |
115 | |
116 /* | |
117 * @see dwtx.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator() | |
118 */ | |
119 public IContextInformationValidator getContextInformationValidator() { | |
120 return null; | |
121 } | |
162 | 122 |
129 | 123 } |
162 | 124 |
129 | 125 private QuickAssistAssistantImpl fQuickAssistAssistantImpl; |
126 private IQuickAssistProcessor fQuickAssistProcessor; | |
162 | 127 |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
128 public this() { |
129 | 129 fQuickAssistAssistantImpl= new QuickAssistAssistantImpl(); |
130 fQuickAssistAssistantImpl.enableAutoActivation(false); | |
131 fQuickAssistAssistantImpl.enableAutoInsert(false); | |
132 } | |
133 | |
134 /* | |
135 * @see dwtx.jface.text.quickassist.IQuickAssistAssistant#showPossibleQuickAssists() | |
136 */ | |
137 public String showPossibleQuickAssists() { | |
138 return fQuickAssistAssistantImpl.showPossibleCompletions(); | |
139 } | |
140 | |
141 /* | |
142 * @see dwtx.jface.text.quickassist.IQuickAssistAssistant#getQuickAssistProcessor(java.lang.String) | |
143 */ | |
144 public IQuickAssistProcessor getQuickAssistProcessor() { | |
145 return fQuickAssistProcessor; | |
146 } | |
147 | |
148 /* | |
149 * @see dwtx.jface.text.quickassist.IQuickAssistAssistant#setQuickAssistProcessor(dwtx.jface.text.quickassist.IQuickAssistProcessor) | |
150 */ | |
151 public void setQuickAssistProcessor(IQuickAssistProcessor processor) { | |
152 fQuickAssistProcessor= processor; | |
162 | 153 fQuickAssistAssistantImpl.setDocumentPartitioning("__" ~ this.classinfo.name ~ "_partitioning"); //$NON-NLS-1$ //$NON-NLS-2$ |
129 | 154 fQuickAssistAssistantImpl.setContentAssistProcessor(new ContentAssistProcessor(processor), IDocument.DEFAULT_CONTENT_TYPE); |
155 } | |
156 | |
157 /* | |
158 * @see dwtx.jface.text.quickassist.IQuickAssistAssistant#canFix(dwtx.jface.text.source.Annotation) | |
159 */ | |
160 public bool canFix(Annotation annotation) { | |
161 return fQuickAssistProcessor !is null && fQuickAssistProcessor.canFix(annotation); | |
162 } | |
163 | |
164 /* | |
165 * @see dwtx.jface.text.quickassist.IQuickAssistAssistant#canAssist(dwtx.jface.text.quickassist.IQuickAssistInvocationContext) | |
166 */ | |
167 public bool canAssist(IQuickAssistInvocationContext invocationContext) { | |
168 return fQuickAssistProcessor !is null && fQuickAssistProcessor.canAssist(invocationContext); | |
169 } | |
170 | |
171 /* | |
172 * @see dwtx.jface.text.quickassist.IQuickAssistAssistant#install(dwtx.jface.text.ITextViewer) | |
173 */ | |
174 public void install(ISourceViewer sourceViewer) { | |
175 fQuickAssistAssistantImpl.install(sourceViewer); | |
176 } | |
177 | |
178 /* | |
179 * @see dwtx.jface.text.quickassist.IQuickAssistAssistant#setInformationControlCreator(dwtx.jface.text.IInformationControlCreator) | |
180 */ | |
181 public void setInformationControlCreator(IInformationControlCreator creator) { | |
182 fQuickAssistAssistantImpl.setInformationControlCreator(creator); | |
183 } | |
162 | 184 |
129 | 185 /* |
186 * @see dwtx.jface.text.quickassist.IQuickAssistAssistant#uninstall() | |
187 */ | |
188 public void uninstall() { | |
189 fQuickAssistAssistantImpl.uninstall(); | |
190 } | |
162 | 191 |
129 | 192 /* |
193 * @see dwtx.jface.text.quickassist.IQuickAssistAssistant#setProposalSelectorBackground(dwt.graphics.Color) | |
194 */ | |
195 public void setProposalSelectorBackground(Color background) { | |
196 fQuickAssistAssistantImpl.setProposalSelectorBackground(background); | |
197 } | |
162 | 198 |
129 | 199 /* |
200 * @see dwtx.jface.text.quickassist.IQuickAssistAssistant#setProposalSelectorForeground(dwt.graphics.Color) | |
201 */ | |
202 public void setProposalSelectorForeground(Color foreground) { | |
203 fQuickAssistAssistantImpl.setProposalSelectorForeground(foreground); | |
204 } | |
205 | |
206 /** | |
207 * Callback to signal this quick assist assistant that the presentation of the | |
208 * possible completions has been stopped. | |
209 */ | |
210 protected void possibleCompletionsClosed() { | |
211 fQuickAssistAssistantImpl.possibleCompletionsClosed(); | |
212 } | |
213 | |
214 /* | |
215 * @see dwtx.jface.text.quickassist.IQuickAssistAssistant#addCompletionListener(dwtx.jface.text.contentassist.ICompletionListener) | |
216 */ | |
217 public void addCompletionListener(ICompletionListener listener) { | |
218 fQuickAssistAssistantImpl.addCompletionListener(listener); | |
219 } | |
220 | |
221 /* | |
222 * @see dwtx.jface.text.quickassist.IQuickAssistAssistant#removeCompletionListener(dwtx.jface.text.contentassist.ICompletionListener) | |
223 */ | |
224 public void removeCompletionListener(ICompletionListener listener) { | |
225 fQuickAssistAssistantImpl.removeCompletionListener(listener); | |
226 } | |
227 | |
228 /* | |
229 * @see dwtx.jface.text.quickassist.IQuickAssistAssistant#setStatusLineVisible(bool) | |
230 */ | |
231 public void setStatusLineVisible(bool show) { | |
232 fQuickAssistAssistantImpl.setStatusLineVisible(show); | |
162 | 233 |
129 | 234 } |
235 | |
236 /* | |
237 * @see dwtx.jface.text.quickassist.IQuickAssistAssistant#setStatusMessage(java.lang.String) | |
238 */ | |
239 public void setStatusMessage(String message) { | |
240 fQuickAssistAssistantImpl.setStatusMessage(message); | |
241 } | |
162 | 242 |
129 | 243 /** |
244 * {@inheritDoc} | |
162 | 245 * |
129 | 246 * @since 3.4 |
247 */ | |
248 public final IHandler getHandler(String commandId) { | |
249 return fQuickAssistAssistantImpl.getHandler(commandId); | |
250 } | |
251 | |
252 /** | |
253 * Hides any open pop-ups. | |
254 * | |
255 * @since 3.4 | |
256 */ | |
257 protected void hide() { | |
258 fQuickAssistAssistantImpl.hide(); | |
259 } | |
260 | |
261 /** | |
262 * {@inheritDoc} | |
162 | 263 * |
129 | 264 * @since 3.4 |
265 */ | |
266 public void enableColoredLabels(bool isEnabled) { | |
267 fQuickAssistAssistantImpl.enableColoredLabels(isEnabled); | |
268 } | |
269 | |
270 } |