Mercurial > projects > dwt-addons
annotate dwtx/jface/text/AbstractHoverInformationControlManager.d @ 162:1a5b8f8129df
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 08 Sep 2008 00:51:37 +0200 |
parents | 7926b636c282 |
children | c3583c6ec027 |
rev | line source |
---|---|
129 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 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.AbstractHoverInformationControlManager; | |
14 | |
131 | 15 import dwtx.jface.text.IDocumentPartitioningListener; // packageimport |
16 import dwtx.jface.text.DefaultTextHover; // packageimport | |
17 import dwtx.jface.text.AbstractInformationControl; // packageimport | |
18 import dwtx.jface.text.TextUtilities; // packageimport | |
19 import dwtx.jface.text.IInformationControlCreatorExtension; // packageimport | |
20 import dwtx.jface.text.AbstractInformationControlManager; // packageimport | |
21 import dwtx.jface.text.ITextViewerExtension2; // packageimport | |
22 import dwtx.jface.text.IDocumentPartitioner; // packageimport | |
23 import dwtx.jface.text.DefaultIndentLineAutoEditStrategy; // packageimport | |
24 import dwtx.jface.text.ITextSelection; // packageimport | |
25 import dwtx.jface.text.Document; // packageimport | |
26 import dwtx.jface.text.FindReplaceDocumentAdapterContentProposalProvider; // packageimport | |
27 import dwtx.jface.text.ITextListener; // packageimport | |
28 import dwtx.jface.text.BadPartitioningException; // packageimport | |
29 import dwtx.jface.text.ITextViewerExtension5; // packageimport | |
30 import dwtx.jface.text.IDocumentPartitionerExtension3; // packageimport | |
31 import dwtx.jface.text.IUndoManager; // packageimport | |
32 import dwtx.jface.text.ITextHoverExtension2; // packageimport | |
33 import dwtx.jface.text.IRepairableDocument; // packageimport | |
34 import dwtx.jface.text.IRewriteTarget; // packageimport | |
35 import dwtx.jface.text.DefaultPositionUpdater; // packageimport | |
36 import dwtx.jface.text.RewriteSessionEditProcessor; // packageimport | |
37 import dwtx.jface.text.TextViewerHoverManager; // packageimport | |
38 import dwtx.jface.text.DocumentRewriteSession; // packageimport | |
39 import dwtx.jface.text.TextViewer; // packageimport | |
40 import dwtx.jface.text.ITextViewerExtension8; // packageimport | |
41 import dwtx.jface.text.RegExMessages; // packageimport | |
42 import dwtx.jface.text.IDelayedInputChangeProvider; // packageimport | |
43 import dwtx.jface.text.ITextOperationTargetExtension; // packageimport | |
44 import dwtx.jface.text.IWidgetTokenOwner; // packageimport | |
45 import dwtx.jface.text.IViewportListener; // packageimport | |
46 import dwtx.jface.text.GapTextStore; // packageimport | |
47 import dwtx.jface.text.MarkSelection; // packageimport | |
48 import dwtx.jface.text.IDocumentPartitioningListenerExtension; // packageimport | |
49 import dwtx.jface.text.IDocumentAdapterExtension; // packageimport | |
50 import dwtx.jface.text.IInformationControlExtension; // packageimport | |
51 import dwtx.jface.text.IDocumentPartitioningListenerExtension2; // packageimport | |
52 import dwtx.jface.text.DefaultDocumentAdapter; // packageimport | |
53 import dwtx.jface.text.ITextViewerExtension3; // packageimport | |
54 import dwtx.jface.text.IInformationControlCreator; // packageimport | |
55 import dwtx.jface.text.TypedRegion; // packageimport | |
56 import dwtx.jface.text.ISynchronizable; // packageimport | |
57 import dwtx.jface.text.IMarkRegionTarget; // packageimport | |
58 import dwtx.jface.text.TextViewerUndoManager; // packageimport | |
59 import dwtx.jface.text.IRegion; // packageimport | |
60 import dwtx.jface.text.IInformationControlExtension2; // packageimport | |
61 import dwtx.jface.text.IDocumentExtension4; // packageimport | |
62 import dwtx.jface.text.IDocumentExtension2; // packageimport | |
63 import dwtx.jface.text.IDocumentPartitionerExtension2; // packageimport | |
64 import dwtx.jface.text.DefaultInformationControl; // packageimport | |
65 import dwtx.jface.text.IWidgetTokenOwnerExtension; // packageimport | |
66 import dwtx.jface.text.DocumentClone; // packageimport | |
67 import dwtx.jface.text.DefaultUndoManager; // packageimport | |
68 import dwtx.jface.text.IFindReplaceTarget; // packageimport | |
69 import dwtx.jface.text.IAutoEditStrategy; // packageimport | |
70 import dwtx.jface.text.ILineTrackerExtension; // packageimport | |
71 import dwtx.jface.text.IUndoManagerExtension; // packageimport | |
72 import dwtx.jface.text.TextSelection; // packageimport | |
73 import dwtx.jface.text.DefaultAutoIndentStrategy; // packageimport | |
74 import dwtx.jface.text.IAutoIndentStrategy; // packageimport | |
75 import dwtx.jface.text.IPainter; // packageimport | |
76 import dwtx.jface.text.IInformationControl; // packageimport | |
77 import dwtx.jface.text.IInformationControlExtension3; // packageimport | |
78 import dwtx.jface.text.ITextViewerExtension6; // packageimport | |
79 import dwtx.jface.text.IInformationControlExtension4; // packageimport | |
80 import dwtx.jface.text.DefaultLineTracker; // packageimport | |
81 import dwtx.jface.text.IDocumentInformationMappingExtension; // packageimport | |
82 import dwtx.jface.text.IRepairableDocumentExtension; // packageimport | |
83 import dwtx.jface.text.ITextHover; // packageimport | |
84 import dwtx.jface.text.FindReplaceDocumentAdapter; // packageimport | |
85 import dwtx.jface.text.ILineTracker; // packageimport | |
86 import dwtx.jface.text.Line; // packageimport | |
87 import dwtx.jface.text.ITextViewerExtension; // packageimport | |
88 import dwtx.jface.text.IDocumentAdapter; // packageimport | |
89 import dwtx.jface.text.TextEvent; // packageimport | |
90 import dwtx.jface.text.BadLocationException; // packageimport | |
91 import dwtx.jface.text.AbstractDocument; // packageimport | |
92 import dwtx.jface.text.AbstractLineTracker; // packageimport | |
93 import dwtx.jface.text.TreeLineTracker; // packageimport | |
94 import dwtx.jface.text.ITextPresentationListener; // packageimport | |
95 import dwtx.jface.text.Region; // packageimport | |
96 import dwtx.jface.text.ITextViewer; // packageimport | |
97 import dwtx.jface.text.IDocumentInformationMapping; // packageimport | |
98 import dwtx.jface.text.MarginPainter; // packageimport | |
99 import dwtx.jface.text.IPaintPositionManager; // packageimport | |
100 import dwtx.jface.text.TextPresentation; // packageimport | |
101 import dwtx.jface.text.IFindReplaceTargetExtension; // packageimport | |
102 import dwtx.jface.text.ISlaveDocumentManagerExtension; // packageimport | |
103 import dwtx.jface.text.ISelectionValidator; // packageimport | |
104 import dwtx.jface.text.IDocumentExtension; // packageimport | |
105 import dwtx.jface.text.PropagatingFontFieldEditor; // packageimport | |
106 import dwtx.jface.text.ConfigurableLineTracker; // packageimport | |
107 import dwtx.jface.text.SlaveDocumentEvent; // packageimport | |
108 import dwtx.jface.text.IDocumentListener; // packageimport | |
109 import dwtx.jface.text.PaintManager; // packageimport | |
110 import dwtx.jface.text.IFindReplaceTargetExtension3; // packageimport | |
111 import dwtx.jface.text.ITextDoubleClickStrategy; // packageimport | |
112 import dwtx.jface.text.IDocumentExtension3; // packageimport | |
113 import dwtx.jface.text.Position; // packageimport | |
114 import dwtx.jface.text.TextMessages; // packageimport | |
115 import dwtx.jface.text.CopyOnWriteTextStore; // packageimport | |
116 import dwtx.jface.text.WhitespaceCharacterPainter; // packageimport | |
117 import dwtx.jface.text.IPositionUpdater; // packageimport | |
118 import dwtx.jface.text.DefaultTextDoubleClickStrategy; // packageimport | |
119 import dwtx.jface.text.ListLineTracker; // packageimport | |
120 import dwtx.jface.text.ITextInputListener; // packageimport | |
121 import dwtx.jface.text.BadPositionCategoryException; // packageimport | |
122 import dwtx.jface.text.IWidgetTokenKeeperExtension; // packageimport | |
123 import dwtx.jface.text.IInputChangedListener; // packageimport | |
124 import dwtx.jface.text.ITextOperationTarget; // packageimport | |
125 import dwtx.jface.text.IDocumentInformationMappingExtension2; // packageimport | |
126 import dwtx.jface.text.ITextViewerExtension7; // packageimport | |
127 import dwtx.jface.text.IInformationControlExtension5; // packageimport | |
128 import dwtx.jface.text.IDocumentRewriteSessionListener; // packageimport | |
129 import dwtx.jface.text.JFaceTextUtil; // packageimport | |
130 import dwtx.jface.text.AbstractReusableInformationControlCreator; // packageimport | |
131 import dwtx.jface.text.TabsToSpacesConverter; // packageimport | |
132 import dwtx.jface.text.CursorLinePainter; // packageimport | |
133 import dwtx.jface.text.ITextHoverExtension; // packageimport | |
134 import dwtx.jface.text.IEventConsumer; // packageimport | |
135 import dwtx.jface.text.IDocument; // packageimport | |
136 import dwtx.jface.text.IWidgetTokenKeeper; // packageimport | |
137 import dwtx.jface.text.DocumentCommand; // packageimport | |
138 import dwtx.jface.text.TypedPosition; // packageimport | |
139 import dwtx.jface.text.IEditingSupportRegistry; // packageimport | |
140 import dwtx.jface.text.IDocumentPartitionerExtension; // packageimport | |
141 import dwtx.jface.text.IEditingSupport; // packageimport | |
142 import dwtx.jface.text.IMarkSelection; // packageimport | |
143 import dwtx.jface.text.ISlaveDocumentManager; // packageimport | |
144 import dwtx.jface.text.DocumentEvent; // packageimport | |
145 import dwtx.jface.text.DocumentPartitioningChangedEvent; // packageimport | |
146 import dwtx.jface.text.ITextStore; // packageimport | |
147 import dwtx.jface.text.JFaceTextMessages; // packageimport | |
148 import dwtx.jface.text.DocumentRewriteSessionEvent; // packageimport | |
149 import dwtx.jface.text.SequentialRewriteTextStore; // packageimport | |
150 import dwtx.jface.text.DocumentRewriteSessionType; // packageimport | |
151 import dwtx.jface.text.TextAttribute; // packageimport | |
152 import dwtx.jface.text.ITextViewerExtension4; // packageimport | |
153 import dwtx.jface.text.ITypedRegion; // packageimport | |
154 | |
129 | 155 import dwt.dwthelper.utils; |
162 | 156 import tango.text.convert.Format; |
129 | 157 |
158 import dwt.DWT; | |
159 import dwt.events.ControlEvent; | |
160 import dwt.events.ControlListener; | |
161 import dwt.events.KeyEvent; | |
162 import dwt.events.KeyListener; | |
163 import dwt.events.MouseEvent; | |
164 import dwt.events.MouseListener; | |
165 import dwt.events.MouseMoveListener; | |
166 import dwt.events.MouseTrackListener; | |
167 import dwt.events.SelectionEvent; | |
168 import dwt.events.SelectionListener; | |
169 import dwt.events.ShellAdapter; | |
170 import dwt.events.ShellEvent; | |
171 import dwt.graphics.Point; | |
172 import dwt.graphics.Rectangle; | |
173 import dwt.widgets.Control; | |
174 import dwt.widgets.Display; | |
175 import dwt.widgets.Event; | |
176 import dwt.widgets.Listener; | |
177 import dwt.widgets.ScrollBar; | |
178 import dwt.widgets.Scrollable; | |
179 import dwtx.core.runtime.Assert; | |
180 import dwtx.core.runtime.IProgressMonitor; | |
181 import dwtx.core.runtime.IStatus; | |
182 import dwtx.core.runtime.Status; | |
183 import dwtx.core.runtime.jobs.Job; | |
184 import dwtx.jface.internal.text.DelayedInputChangeListener; | |
185 import dwtx.jface.internal.text.InformationControlReplacer; | |
186 import dwtx.jface.internal.text.InternalAccessor; | |
156 | 187 import dwtx.jface.text.ITextViewerExtension8; |
129 | 188 import dwtx.jface.text.source.AnnotationBarHoverManager; |
189 import dwtx.jface.util.Geometry; | |
190 | |
191 | |
192 /** | |
193 * An information control manager that shows information in response to mouse | |
194 * hover events. The mouse hover events are caught by registering a | |
195 * {@link dwt.events.MouseTrackListener} on the manager's subject | |
196 * control. The manager has by default an information control closer that closes | |
197 * the information control as soon as the mouse pointer leaves the subject area, | |
198 * the user presses a key, or the subject control is resized, moved, or | |
199 * deactivated. | |
200 * <p> | |
201 * When being activated by a mouse hover event, the manager disables itself, | |
202 * until the mouse leaves the subject area. Thus, the manager is usually still | |
203 * disabled, when the information control has already been closed by the closer. | |
204 * | |
205 * @see dwt.events.MouseTrackListener | |
206 * @since 2.0 | |
207 */ | |
208 abstract public class AbstractHoverInformationControlManager : AbstractInformationControlManager { | |
148 | 209 |
129 | 210 /** |
211 * The information control closer for the hover information. Closes the information control as | |
212 * soon as the mouse pointer leaves the subject area (unless "move into hover" is enabled), | |
213 * a mouse button is pressed, the user presses a key, or the subject control is resized, moved, or loses focus. | |
214 */ | |
215 class Closer : IInformationControlCloser, MouseListener, MouseMoveListener, ControlListener, KeyListener, SelectionListener, Listener { | |
148 | 216 |
129 | 217 /** The closer's subject control */ |
218 private Control fSubjectControl; | |
219 /** The subject area */ | |
220 private Rectangle fSubjectArea; | |
221 /** Indicates whether this closer is active */ | |
222 private bool fIsActive= false; | |
223 /** | |
224 * The cached display. | |
225 * @since 3.1 | |
226 */ | |
227 private Display fDisplay; | |
228 | |
229 | |
230 /** | |
231 * Creates a new information control closer. | |
232 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
233 public this() { |
129 | 234 } |
235 | |
236 /* | |
237 * @see IInformationControlCloser#setSubjectControl(Control) | |
238 */ | |
239 public void setSubjectControl(Control control) { | |
240 fSubjectControl= control; | |
241 } | |
242 | |
243 /* | |
244 * @see IInformationControlCloser#setHoverControl(IHoverControl) | |
245 */ | |
246 public void setInformationControl(IInformationControl control) { | |
247 // NOTE: we use getCurrentInformationControl() from the outer class | |
248 } | |
249 | |
250 /* | |
251 * @see IInformationControlCloser#start(Rectangle) | |
252 */ | |
253 public void start(Rectangle subjectArea) { | |
254 | |
255 if (fIsActive) | |
256 return; | |
257 fIsActive= true; | |
258 fWaitForMouseUp= false; | |
259 | |
260 fSubjectArea= subjectArea; | |
261 | |
262 if (fSubjectControl !is null && !fSubjectControl.isDisposed()) { | |
263 fSubjectControl.addMouseListener(this); | |
264 fSubjectControl.addMouseMoveListener(this); | |
265 fSubjectControl.addControlListener(this); | |
266 fSubjectControl.addKeyListener(this); | |
138 | 267 if ( cast(Scrollable)fSubjectControl ) { |
134 | 268 Scrollable scrollable= cast(Scrollable) fSubjectControl; |
129 | 269 ScrollBar vBar= scrollable.getVerticalBar(); |
270 if (vBar !is null) | |
271 vBar.addSelectionListener(this); | |
272 ScrollBar hBar= scrollable.getHorizontalBar(); | |
273 if (hBar !is null) | |
274 hBar.addSelectionListener(this); | |
275 } | |
148 | 276 |
129 | 277 fDisplay= fSubjectControl.getDisplay(); |
278 if (!fDisplay.isDisposed()) { | |
279 fDisplay.addFilter(DWT.Activate, this); | |
280 fDisplay.addFilter(DWT.MouseWheel, this); | |
148 | 281 |
129 | 282 fDisplay.addFilter(DWT.FocusOut, this); |
148 | 283 |
129 | 284 fDisplay.addFilter(DWT.MouseDown, this); |
285 fDisplay.addFilter(DWT.MouseUp, this); | |
148 | 286 |
129 | 287 fDisplay.addFilter(DWT.MouseMove, this); |
288 fDisplay.addFilter(DWT.MouseEnter, this); | |
289 fDisplay.addFilter(DWT.MouseExit, this); | |
290 } | |
291 } | |
292 } | |
293 | |
294 /* | |
295 * @see IInformationControlCloser#stop() | |
296 */ | |
297 public void stop() { | |
298 if (!fIsActive) | |
299 return; | |
300 | |
301 fIsActive= false; | |
302 | |
148 | 303 if (DEBUG) |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
304 System.out_.println("AbstractHoverInformationControlManager.Closer stopped"); //$NON-NLS-1$ |
129 | 305 |
306 if (fSubjectControl !is null && !fSubjectControl.isDisposed()) { | |
307 fSubjectControl.removeMouseListener(this); | |
308 fSubjectControl.removeMouseMoveListener(this); | |
309 fSubjectControl.removeControlListener(this); | |
310 fSubjectControl.removeKeyListener(this); | |
138 | 311 if ( cast(Scrollable)fSubjectControl ) { |
134 | 312 Scrollable scrollable= cast(Scrollable) fSubjectControl; |
129 | 313 ScrollBar vBar= scrollable.getVerticalBar(); |
314 if (vBar !is null) | |
315 vBar.removeSelectionListener(this); | |
316 ScrollBar hBar= scrollable.getHorizontalBar(); | |
317 if (hBar !is null) | |
318 hBar.removeSelectionListener(this); | |
319 } | |
320 } | |
321 | |
322 if (fDisplay !is null && !fDisplay.isDisposed()) { | |
323 fDisplay.removeFilter(DWT.Activate, this); | |
324 fDisplay.removeFilter(DWT.MouseWheel, this); | |
148 | 325 |
129 | 326 fDisplay.removeFilter(DWT.FocusOut, this); |
148 | 327 |
129 | 328 fDisplay.removeFilter(DWT.MouseDown, this); |
329 fDisplay.removeFilter(DWT.MouseUp, this); | |
148 | 330 |
129 | 331 fDisplay.removeFilter(DWT.MouseMove, this); |
332 fDisplay.removeFilter(DWT.MouseEnter, this); | |
333 fDisplay.removeFilter(DWT.MouseExit, this); | |
334 } | |
335 fDisplay= null; | |
336 } | |
337 | |
338 /* | |
339 * @see dwt.events.MouseMoveListener#mouseMove(dwt.events.MouseEvent) | |
340 */ | |
341 public void mouseMove(MouseEvent event) { | |
342 if (!hasInformationControlReplacer() || !canMoveIntoInformationControl(getCurrentInformationControl())) { | |
343 if (!fSubjectArea.contains(event.x, event.y)) { | |
344 hideInformationControl(); | |
345 } | |
346 | |
347 } else if (getCurrentInformationControl() !is null && !getCurrentInformationControl().isFocusControl()) { | |
348 if (!inKeepUpZone(event.x, event.y, fSubjectControl, fSubjectArea, true)) { | |
349 hideInformationControl(); | |
350 } | |
351 } | |
352 } | |
353 | |
354 /* | |
355 * @see dwt.events.MouseListener#mouseUp(dwt.events.MouseEvent) | |
356 */ | |
357 public void mouseUp(MouseEvent event) { | |
358 } | |
359 | |
360 /* | |
361 * @see MouseListener#mouseDown(MouseEvent) | |
362 */ | |
363 public void mouseDown(MouseEvent event) { | |
364 hideInformationControl(); | |
365 } | |
366 | |
367 /* | |
368 * @see MouseListener#mouseDoubleClick(MouseEvent) | |
369 */ | |
370 public void mouseDoubleClick(MouseEvent event) { | |
371 hideInformationControl(); | |
372 } | |
373 | |
374 /* | |
375 * @see ControlListener#controlResized(ControlEvent) | |
376 */ | |
377 public void controlResized(ControlEvent event) { | |
378 hideInformationControl(); | |
379 } | |
380 | |
381 /* | |
382 * @see ControlListener#controlMoved(ControlEvent) | |
383 */ | |
384 public void controlMoved(ControlEvent event) { | |
385 hideInformationControl(); | |
386 } | |
387 | |
388 /* | |
389 * @see KeyListener#keyReleased(KeyEvent) | |
390 */ | |
391 public void keyReleased(KeyEvent event) { | |
392 } | |
393 | |
394 /* | |
395 * @see KeyListener#keyPressed(KeyEvent) | |
396 */ | |
397 public void keyPressed(KeyEvent event) { | |
398 hideInformationControl(); | |
399 } | |
400 | |
401 /* | |
402 * @see dwt.events.SelectionListener#widgetSelected(dwt.events.SelectionEvent) | |
403 */ | |
404 public void widgetSelected(SelectionEvent e) { | |
405 hideInformationControl(); | |
406 } | |
148 | 407 |
129 | 408 /* |
409 * @see dwt.events.SelectionListener#widgetDefaultSelected(dwt.events.SelectionEvent) | |
410 */ | |
411 public void widgetDefaultSelected(SelectionEvent e) { | |
412 } | |
148 | 413 |
129 | 414 /* |
415 * @see dwt.widgets.Listener#handleEvent(dwt.widgets.Event) | |
416 * @since 3.1 | |
417 */ | |
418 public void handleEvent(Event event) { | |
419 switch (event.type) { | |
420 case DWT.Activate: | |
421 case DWT.MouseWheel: | |
422 if (!hasInformationControlReplacer()) | |
423 hideInformationControl(); | |
424 else if (!isReplaceInProgress()) { | |
425 IInformationControl infoControl= getCurrentInformationControl(); | |
426 // During isReplaceInProgress(), events can come from the replacing information control | |
149 | 427 if ( cast(Control)event.widget && cast(IInformationControlExtension5)infoControl ) { |
134 | 428 Control control= cast(Control) event.widget; |
429 IInformationControlExtension5 iControl5= cast(IInformationControlExtension5) infoControl; | |
129 | 430 if (!(iControl5.containsControl(control))) |
431 hideInformationControl(); | |
432 else if (event.type is DWT.MouseWheel && cancelReplacingDelay()) | |
433 replaceInformationControl(false); | |
434 } else if (infoControl !is null && infoControl.isFocusControl() && cancelReplacingDelay()) { | |
435 replaceInformationControl(true); | |
436 } | |
437 } | |
438 break; | |
148 | 439 |
129 | 440 case DWT.MouseUp: |
441 case DWT.MouseDown: | |
442 if (!hasInformationControlReplacer()) | |
443 hideInformationControl(); | |
444 else if (!isReplaceInProgress()) { | |
445 IInformationControl infoControl= getCurrentInformationControl(); | |
149 | 446 if ( cast(Control)event.widget && cast(IInformationControlExtension5)infoControl ) { |
134 | 447 Control control= cast(Control) event.widget; |
448 final IInformationControlExtension5 iControl5= cast(IInformationControlExtension5) infoControl; | |
129 | 449 if (!(iControl5.containsControl(control))) { |
450 hideInformationControl(); | |
451 } else if (cancelReplacingDelay()) { | |
452 if (event.type is DWT.MouseUp) { | |
453 stop(); // avoid that someone else replaces the info control before the async is exec'd | |
138 | 454 if ( cast(IDelayedInputChangeProvider)infoControl ) { |
134 | 455 final IDelayedInputChangeProvider delayedICP= cast(IDelayedInputChangeProvider) infoControl; |
129 | 456 final IInputChangedListener inputChangeListener= new DelayedInputChangeListener(delayedICP, getInformationControlReplacer()); |
457 delayedICP.setDelayedInputChangeListener(inputChangeListener); | |
458 // cancel automatic input updating after a small timeout: | |
135 | 459 control.getShell().getDisplay().timerExec(1000, new class() Runnable { |
129 | 460 public void run() { |
461 delayedICP.setDelayedInputChangeListener(null); | |
462 } | |
463 }); | |
464 } | |
148 | 465 |
129 | 466 // XXX: workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=212392 : |
135 | 467 control.getShell().getDisplay().asyncExec(new class() Runnable { |
129 | 468 public void run() { |
469 replaceInformationControl(true); | |
470 } | |
471 }); | |
472 } else { | |
473 fWaitForMouseUp= true; | |
474 } | |
475 } | |
476 } else { | |
477 handleMouseMove(event); | |
478 } | |
479 } | |
480 break; | |
481 | |
482 case DWT.FocusOut: | |
483 IInformationControl iControl= getCurrentInformationControl(); | |
484 if (iControl !is null && ! iControl.isFocusControl()) | |
485 hideInformationControl(); | |
486 break; | |
148 | 487 |
129 | 488 case DWT.MouseMove: |
489 case DWT.MouseEnter: | |
490 case DWT.MouseExit: | |
491 handleMouseMove(event); | |
492 break; | |
493 } | |
494 } | |
495 | |
496 /** | |
497 * Handle mouse movement events. | |
148 | 498 * |
129 | 499 * @param event the event |
500 * @since 3.4 | |
501 */ | |
502 private void handleMouseMove(Event event) { | |
148 | 503 // if (DEBUG) |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
504 // System.out_.println("AbstractHoverInformationControl.Closer.handleMouseMove():" + event); //$NON-NLS-1$ |
148 | 505 |
149 | 506 if (!( cast(Control)event.widget )) |
129 | 507 return; |
134 | 508 Control eventControl= cast(Control) event.widget; |
148 | 509 |
129 | 510 //transform coordinates to subject control: |
511 Point mouseLoc= event.display.map(eventControl, fSubjectControl, event.x, event.y); | |
148 | 512 |
129 | 513 if (fSubjectArea.contains(mouseLoc)) |
514 return; | |
148 | 515 |
129 | 516 IInformationControl iControl= getCurrentInformationControl(); |
517 if (!hasInformationControlReplacer() || !canMoveIntoInformationControl(iControl)) { | |
149 | 518 if ( cast(AnnotationBarHoverManager)this.outer ) { |
129 | 519 if (getInternalAccessor().getAllowMouseExit()) |
520 return; | |
521 } | |
522 hideInformationControl(); | |
523 return; | |
524 } | |
148 | 525 |
134 | 526 IInformationControlExtension3 iControl3= cast(IInformationControlExtension3) iControl; |
129 | 527 Rectangle controlBounds= iControl3.getBounds(); |
528 if (controlBounds !is null) { | |
529 Rectangle tooltipBounds= event.display.map(null, eventControl, controlBounds); | |
530 if (tooltipBounds.contains(event.x, event.y)) { | |
531 if (!isReplaceInProgress() && event.type !is DWT.MouseExit) | |
532 startReplaceInformationControl(event.display); | |
533 return; | |
534 } | |
535 cancelReplacingDelay(); | |
536 } | |
537 | |
538 if (!fSubjectControl.getBounds().contains(mouseLoc)) { | |
539 /* | |
540 * Use inKeepUpZone() to make sure it also works when the hover is | |
541 * completely outside of the subject control. | |
542 */ | |
543 if (!inKeepUpZone(mouseLoc.x, mouseLoc.y, fSubjectControl, fSubjectArea, true)) { | |
544 hideInformationControl(); | |
545 return; | |
546 } | |
547 } | |
548 } | |
549 } | |
550 | |
551 /** | |
552 * To be installed on the manager's subject control. Serves two different purposes: | |
553 * <ul> | |
554 * <li> start function: initiates the computation of the information to be presented. This happens on | |
555 * receipt of a mouse hover event and disables the information control manager, | |
556 * <li> restart function: tracks mouse move and shell activation event to determine when the information | |
557 * control manager needs to be reactivated. | |
558 * </ul> | |
559 */ | |
560 class MouseTracker : ShellAdapter , MouseTrackListener, MouseMoveListener { | |
561 | |
562 /** Margin around the original hover event location for computing the hover area. */ | |
146 | 563 private const static int EPSILON= 3; |
129 | 564 |
565 /** The area in which the original hover event occurred. */ | |
566 private Rectangle fHoverArea; | |
567 /** The area for which is computed information is valid. */ | |
568 private Rectangle fSubjectArea; | |
569 /** The tracker's subject control. */ | |
570 private Control fSubjectControl; | |
571 | |
572 /** Indicates whether the tracker is in restart mode ignoring hover events. */ | |
573 private bool fIsInRestartMode= false; | |
574 /** Indicates whether the tracker is computing the information to be presented. */ | |
575 private bool fIsComputing= false; | |
576 /** Indicates whether the mouse has been lost. */ | |
577 private bool fMouseLostWhileComputing= false; | |
578 /** Indicates whether the subject control's shell has been deactivated. */ | |
579 private bool fShellDeactivatedWhileComputing= false; | |
580 | |
581 /** | |
582 * Creates a new mouse tracker. | |
583 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
584 public this() { |
129 | 585 } |
586 | |
587 /** | |
588 * Sets this mouse tracker's subject area, the area to be tracked in order | |
589 * to re-enable the information control manager. | |
590 * | |
591 * @param subjectArea the subject area | |
592 */ | |
593 public void setSubjectArea(Rectangle subjectArea) { | |
594 Assert.isNotNull(subjectArea); | |
595 fSubjectArea= subjectArea; | |
596 } | |
597 | |
598 /** | |
599 * Starts this mouse tracker. The given control becomes this tracker's subject control. | |
600 * Installs itself as mouse track listener on the subject control. | |
601 * | |
602 * @param subjectControl the subject control | |
603 */ | |
604 public void start(Control subjectControl) { | |
605 fSubjectControl= subjectControl; | |
606 if (fSubjectControl !is null && !fSubjectControl.isDisposed()) | |
607 fSubjectControl.addMouseTrackListener(this); | |
608 | |
609 fIsInRestartMode= false; | |
610 fIsComputing= false; | |
611 fMouseLostWhileComputing= false; | |
612 fShellDeactivatedWhileComputing= false; | |
613 } | |
614 | |
615 /** | |
616 * Stops this mouse tracker. Removes itself as mouse track, mouse move, and | |
617 * shell listener from the subject control. | |
618 */ | |
619 public void stop() { | |
620 if (fSubjectControl !is null && !fSubjectControl.isDisposed()) { | |
621 fSubjectControl.removeMouseTrackListener(this); | |
622 fSubjectControl.removeMouseMoveListener(this); | |
623 fSubjectControl.getShell().removeShellListener(this); | |
624 } | |
625 } | |
626 | |
627 /** | |
628 * Initiates the computation of the information to be presented. Sets the initial hover area | |
629 * to a small rectangle around the hover event location. Adds mouse move and shell activation listeners | |
630 * to track whether the computed information is, after completion, useful for presentation and to | |
631 * implement the restart function. | |
632 * | |
633 * @param event the mouse hover event | |
634 */ | |
635 public void mouseHover(MouseEvent event) { | |
636 if (fIsComputing || fIsInRestartMode || | |
637 (fSubjectControl !is null && !fSubjectControl.isDisposed() && fSubjectControl.getShell() !is fSubjectControl.getShell().getDisplay().getActiveShell())) { | |
148 | 638 if (DEBUG) |
162 | 639 System.out_.println(Format("AbstractHoverInformationControlManager...mouseHover: @ {}/{} : hover cancelled: fIsComputing= {}, fIsInRestartMode= {}", event.x, event.y, fIsComputing, fIsInRestartMode)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
129 | 640 return; |
641 } | |
148 | 642 |
129 | 643 fIsInRestartMode= true; |
644 fIsComputing= true; | |
645 fMouseLostWhileComputing= false; | |
646 fShellDeactivatedWhileComputing= false; | |
647 | |
648 fHoverEventStateMask= event.stateMask; | |
649 fHoverEvent= event; | |
650 fHoverArea= new Rectangle(event.x - EPSILON, event.y - EPSILON, 2 * EPSILON, 2 * EPSILON ); | |
651 if (fHoverArea.x < 0) | |
652 fHoverArea.x= 0; | |
653 if (fHoverArea.y < 0) | |
654 fHoverArea.y= 0; | |
655 setSubjectArea(fHoverArea); | |
656 | |
657 if (fSubjectControl !is null && !fSubjectControl.isDisposed()) { | |
658 fSubjectControl.addMouseMoveListener(this); | |
659 fSubjectControl.getShell().addShellListener(this); | |
660 } | |
661 doShowInformation(); | |
662 } | |
663 | |
664 /** | |
665 * Deactivates this tracker's restart function and enables the information control | |
666 * manager. Does not have any effect if the tracker is still executing the start function (i.e. | |
667 * computing the information to be presented. | |
668 */ | |
669 protected void deactivate() { | |
670 if (fIsComputing) | |
671 return; | |
148 | 672 |
129 | 673 fIsInRestartMode= false; |
674 if (fSubjectControl !is null && !fSubjectControl.isDisposed()) { | |
675 fSubjectControl.removeMouseMoveListener(this); | |
676 fSubjectControl.getShell().removeShellListener(this); | |
677 } | |
678 } | |
679 | |
680 /* | |
681 * @see MouseTrackListener#mouseEnter(MouseEvent) | |
682 */ | |
683 public void mouseEnter(MouseEvent e) { | |
684 } | |
685 | |
686 /* | |
687 * @see MouseTrackListener#mouseExit(MouseEvent) | |
688 */ | |
689 public void mouseExit(MouseEvent e) { | |
690 if (!hasInformationControlReplacer() || !canMoveIntoInformationControl(getCurrentInformationControl()) || !inKeepUpZone(e.x, e.y, fSubjectControl, fSubjectArea, false)) { | |
691 fMouseLostWhileComputing= true; | |
692 deactivate(); | |
693 } | |
694 } | |
695 | |
696 /* | |
697 * @see MouseMoveListener#mouseMove(MouseEvent) | |
698 */ | |
699 public void mouseMove(MouseEvent event) { | |
700 if (!hasInformationControlReplacer() || !canMoveIntoInformationControl(getCurrentInformationControl())) { | |
701 if (!fSubjectArea.contains(event.x, event.y)) | |
702 deactivate(); | |
703 } else { | |
704 if (!inKeepUpZone(event.x, event.y, fSubjectControl, fSubjectArea, false)) | |
705 deactivate(); | |
706 } | |
707 } | |
708 | |
709 /* | |
710 * @see ShellListener#shellDeactivated(ShellEvent) | |
711 */ | |
712 public void shellDeactivated(ShellEvent e) { | |
713 fShellDeactivatedWhileComputing= true; | |
714 deactivate(); | |
715 } | |
716 | |
717 /* | |
718 * @see ShellListener#shellIconified(ShellEvent) | |
719 */ | |
720 public void shellIconified(ShellEvent e) { | |
721 fShellDeactivatedWhileComputing= true; | |
722 deactivate(); | |
723 } | |
724 | |
725 /** | |
726 * Tells this tracker that the start function processing has been completed. | |
727 */ | |
728 public void computationCompleted() { | |
729 fIsComputing= false; | |
730 fMouseLostWhileComputing= false; | |
731 fShellDeactivatedWhileComputing= false; | |
732 } | |
733 | |
734 /** | |
735 * Determines whether the computed information is still useful for presentation. | |
736 * This is not the case, if the shell of the subject control has been deactivated, the mouse | |
737 * left the subject control, or the mouse moved on, so that it is no longer in the subject | |
738 * area. | |
739 * | |
740 * @return <code>true</code> if information is still useful for presentation, <code>false</code> otherwise | |
741 */ | |
742 public bool isMouseLost() { | |
743 | |
744 if (fMouseLostWhileComputing || fShellDeactivatedWhileComputing) | |
745 return true; | |
746 | |
747 if (fSubjectControl !is null && !fSubjectControl.isDisposed()) { | |
748 Display display= fSubjectControl.getDisplay(); | |
749 Point p= display.getCursorLocation(); | |
750 p= fSubjectControl.toControl(p); | |
751 if (!fSubjectArea.contains(p) && !fHoverArea.contains(p)) | |
752 return true; | |
753 } | |
754 | |
755 return false; | |
756 } | |
757 } | |
758 | |
759 /** | |
760 * The delay in {@link ITextViewerExtension8.EnrichMode#AFTER_DELAY} mode after which | |
761 * the hover is enriched when the mouse has stopped moving inside the hover. | |
762 * @since 3.4 | |
763 */ | |
147 | 764 private static const long HOVER_AUTO_REPLACING_DELAY= 200; |
129 | 765 |
766 /** The mouse tracker on the subject control */ | |
159 | 767 private MouseTracker fMouseTracker; |
129 | 768 /** |
769 * The remembered hover event. | |
770 * @since 3.0 | |
771 */ | |
772 private MouseEvent fHoverEvent= null; | |
773 /** The remembered hover event state mask of the keyboard modifiers */ | |
774 private int fHoverEventStateMask= 0; | |
775 /** | |
776 * The thread that delays replacing of the hover information control. | |
777 * To be accessed in the UI thread only! | |
148 | 778 * |
129 | 779 * @since 3.4 |
780 */ | |
781 private Job fReplacingDelayJob; | |
148 | 782 |
129 | 783 /** |
784 * The {@link ITextViewerExtension8.EnrichMode}, may be <code>null</code>. | |
785 * @since 3.4 | |
786 */ | |
159 | 787 private ITextViewerExtension8_EnrichMode fEnrichMode; |
148 | 788 |
129 | 789 /** |
790 * Indicates whether we have received a MouseDown event and are waiting for a MouseUp | |
791 * (and don't replace the information control until that happened). | |
792 * @since 3.4 | |
793 */ | |
794 private bool fWaitForMouseUp= false; | |
148 | 795 |
129 | 796 /** |
797 * Creates a new hover information control manager using the given information control creator. | |
798 * By default a <code>Closer</code> instance is set as this manager's closer. | |
799 * | |
800 * @param creator the information control creator | |
801 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
802 protected this(IInformationControlCreator creator) { |
159 | 803 fMouseTracker= new MouseTracker(); |
129 | 804 super(creator); |
805 setCloser(new Closer()); | |
159 | 806 setHoverEnrichMode(ITextViewerExtension8_EnrichMode.AFTER_DELAY); |
129 | 807 } |
808 | |
809 /** | |
810 * Tests whether a given mouse location is within the keep-up zone. | |
811 * The hover should not be hidden as long as the mouse stays inside this zone. | |
148 | 812 * |
129 | 813 * @param x the x coordinate, relative to the <em>subject control</em> |
814 * @param y the y coordinate, relative to the <em>subject control</em> | |
815 * @param subjectControl the subject control | |
816 * @param subjectArea the area for which the presented information is valid | |
817 * @param blowUp If <code>true</code>, then calculate for the closer, i.e. blow up the keepUp area. | |
818 * If <code>false</code>, then use tight bounds for hover detection. | |
148 | 819 * |
129 | 820 * @return <code>true</code> iff the mouse event occurred in the keep-up zone |
821 * @since 3.4 | |
822 */ | |
823 private bool inKeepUpZone(int x, int y, Control subjectControl, Rectangle subjectArea, bool blowUp) { | |
824 if (subjectArea.contains(x, y)) | |
825 return true; | |
148 | 826 |
129 | 827 IInformationControl iControl= getCurrentInformationControl(); |
142 | 828 if (( cast(IInformationControlExtension5)iControl && !(cast(IInformationControlExtension5) iControl).isVisible())) { |
129 | 829 iControl= null; |
830 if (getInformationControlReplacer() !is null) { | |
831 iControl= getInformationControlReplacer().getCurrentInformationControl2(); | |
142 | 832 if (( cast(IInformationControlExtension5)iControl && !(cast(IInformationControlExtension5) iControl).isVisible())) { |
129 | 833 return false; |
834 } | |
835 } | |
836 } | |
138 | 837 if ( cast(IInformationControlExtension3)iControl ) { |
134 | 838 IInformationControlExtension3 iControl3= cast(IInformationControlExtension3) iControl; |
148 | 839 |
129 | 840 Rectangle iControlBounds= subjectControl.getDisplay().map(null, subjectControl, iControl3.getBounds()); |
841 Rectangle totalBounds= Geometry.copy(iControlBounds); | |
842 if (blowUp && isReplaceInProgress()) { | |
843 //Problem: blown up iControl overlaps rest of subjectArea's line | |
844 // solution for now: only blow up for keep up (closer), but not for further hover detection | |
845 int margin= getInformationControlReplacer().getKeepUpMargin(); | |
846 Geometry.expand(totalBounds, margin, margin, margin, margin); | |
847 } | |
148 | 848 |
129 | 849 if (!blowUp) { |
850 if (iControlBounds.contains(x, y)) | |
851 return true; | |
148 | 852 |
129 | 853 if (subjectArea.y + subjectArea.height < iControlBounds.y) { |
854 // special case for hover events: subjectArea totally above iControl: | |
855 // +-----------+ | |
856 // |subjectArea| | |
857 // +-----------+ | |
858 // |also keepUp| | |
859 // ++-----------+-------+ | |
860 // | InformationControl | | |
861 // +--------------------+ | |
862 if (subjectArea.y + subjectArea.height <= y && y <= totalBounds.y) { | |
863 // is vertically between subject area and iControl | |
864 if (subjectArea.x <= x && x <= subjectArea.x + subjectArea.width) { | |
865 // is below subject area (in a vertical projection) | |
866 return true; | |
867 } | |
868 // FIXME: cases when subjectArea extends to left or right of iControl? | |
869 } | |
870 return false; | |
148 | 871 |
129 | 872 } else if (iControlBounds.x + iControlBounds.width < subjectArea.x) { |
873 // special case for hover events (e.g. in overview ruler): iControl totally left of subjectArea | |
874 // +--------------------+-----------+ | |
875 // | | +-----------+ | |
876 // | InformationControl |also keepUp|subjectArea| | |
877 // | | +-----------+ | |
878 // +--------------------+-----------+ | |
879 if (iControlBounds.x + iControlBounds.width <= x && x <= subjectArea.x) { | |
880 // is horizontally between iControl and subject area | |
881 if (iControlBounds.y <= y && y <= iControlBounds.y + iControlBounds.height) { | |
882 // is to the right of iControl (in a horizontal projection) | |
883 return true; | |
884 } | |
885 } | |
886 return false; | |
148 | 887 |
129 | 888 } else if (subjectArea.x + subjectArea.width < iControlBounds.x) { |
889 // special case for hover events (e.g. in annotation ruler): subjectArea totally left of iControl | |
890 // +-----------+--------------------+ | |
891 // +-----------+ | | | |
892 // |subjectArea|also keepUp| InformationControl | | |
893 // +-----------+ | | | |
894 // +-----------+--------------------+ | |
895 if (subjectArea.x + subjectArea.width <= x && x <= iControlBounds.x) { | |
896 // is horizontally between subject area and iControl | |
897 if (iControlBounds.y <= y && y <= iControlBounds.y + iControlBounds.height) { | |
898 // is to the left of iControl (in a horizontal projection) | |
899 return true; | |
900 } | |
901 } | |
902 return false; | |
903 } | |
904 } | |
148 | 905 |
129 | 906 // FIXME: should maybe use convex hull, not bounding box |
907 totalBounds.add(subjectArea); | |
908 if (totalBounds.contains(x, y)) | |
909 return true; | |
910 } | |
911 return false; | |
912 } | |
148 | 913 |
129 | 914 /** |
915 * Tests whether the given information control allows the mouse to be moved | |
916 * into it. | |
148 | 917 * |
129 | 918 * @param iControl information control or <code>null</code> if none |
919 * @return <code>true</code> if information control allows mouse move into | |
920 * control, <code>false</code> otherwise | |
921 */ | |
922 bool canMoveIntoInformationControl(IInformationControl iControl) { | |
923 return fEnrichMode !is null && canReplace(iControl); | |
924 } | |
148 | 925 |
129 | 926 /* |
927 * @see dwtx.jface.text.AbstractInformationControlManager#hideInformationControl() | |
928 */ | |
929 protected void hideInformationControl() { | |
930 cancelReplacingDelay(); | |
931 super.hideInformationControl(); | |
932 } | |
933 | |
934 /** | |
935 * Sets the hover enrich mode. Only applicable when an information | |
936 * control replacer has been set with | |
937 * {@link #setInformationControlReplacer(InformationControlReplacer)} . | |
148 | 938 * |
129 | 939 * @param mode the enrich mode |
940 * @since 3.4 | |
941 * @see ITextViewerExtension8#setHoverEnrichMode(dwtx.jface.text.ITextViewerExtension8.EnrichMode) | |
942 */ | |
159 | 943 void setHoverEnrichMode(ITextViewerExtension8_EnrichMode mode) { |
129 | 944 fEnrichMode= mode; |
945 } | |
148 | 946 |
129 | 947 /* |
948 * @see dwtx.jface.text.AbstractInformationControlManager#replaceInformationControl(bool) | |
949 */ | |
950 void replaceInformationControl(bool takeFocus) { | |
951 fWaitForMouseUp= false; | |
952 super.replaceInformationControl(takeFocus); | |
953 } | |
148 | 954 |
129 | 955 /** |
956 * Cancels the replacing delay job. | |
957 * @return <code>true</code> iff canceling was successful, <code>false</code> if replacing has already started | |
958 */ | |
959 bool cancelReplacingDelay() { | |
960 fWaitForMouseUp= false; | |
961 if (fReplacingDelayJob !is null && fReplacingDelayJob.getState() !is Job.RUNNING) { | |
962 bool cancelled= fReplacingDelayJob.cancel(); | |
963 fReplacingDelayJob= null; | |
148 | 964 // if (DEBUG) |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
965 // System.out_.println("AbstractHoverInformationControlManager.cancelReplacingDelay(): cancelled=" + cancelled); //$NON-NLS-1$ |
129 | 966 return cancelled; |
967 } | |
148 | 968 // if (DEBUG) |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
969 // System.out_.println("AbstractHoverInformationControlManager.cancelReplacingDelay(): not delayed"); //$NON-NLS-1$ |
129 | 970 return true; |
971 } | |
148 | 972 |
129 | 973 /** |
974 * Starts replacing the information control, considering the current | |
975 * {@link ITextViewerExtension8.EnrichMode}. | |
976 * If set to {@link ITextViewerExtension8.EnrichMode#AFTER_DELAY}, this | |
977 * method cancels previous requests and restarts the delay timer. | |
148 | 978 * |
129 | 979 * @param display the display to be used for the call to |
980 * {@link #replaceInformationControl(bool)} in the UI thread | |
981 */ | |
156 | 982 private void startReplaceInformationControl(Display display) { |
159 | 983 if (fEnrichMode is ITextViewerExtension8_EnrichMode.ON_CLICK) |
129 | 984 return; |
148 | 985 |
129 | 986 if (fReplacingDelayJob !is null) { |
987 if (fReplacingDelayJob.getState() !is Job.RUNNING) { | |
988 if (fReplacingDelayJob.cancel()) { | |
159 | 989 if (fEnrichMode is ITextViewerExtension8_EnrichMode.IMMEDIATELY) { |
129 | 990 fReplacingDelayJob= null; |
991 if (! fWaitForMouseUp) | |
992 replaceInformationControl(false); | |
993 } else { | |
148 | 994 // if (DEBUG) |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
995 // System.out_.println("AbstractHoverInformationControlManager.startReplaceInformationControl(): rescheduled"); //$NON-NLS-1$ |
129 | 996 fReplacingDelayJob.schedule(HOVER_AUTO_REPLACING_DELAY); |
997 } | |
998 } | |
999 } | |
1000 return; | |
1001 } | |
148 | 1002 |
156 | 1003 fReplacingDelayJob= new class("AbstractHoverInformationControlManager Replace Delayer", display) Job { //$NON-NLS-1$ |
1004 Display display_; | |
1005 this( String str, Display b){ | |
150 | 1006 super(str); |
156 | 1007 display_=b; |
150 | 1008 } |
1009 public IStatus run(IProgressMonitor monitor) { | |
156 | 1010 if (monitor.isCanceled() || display_.isDisposed()) { |
129 | 1011 return Status.CANCEL_STATUS; |
1012 } | |
156 | 1013 display_.syncExec(dgRunnable( (IProgressMonitor monitor_) { |
150 | 1014 fReplacingDelayJob= null; |
1015 if (monitor_.isCanceled()) | |
1016 return; | |
1017 if (! fWaitForMouseUp) | |
1018 replaceInformationControl(false); | |
1019 }, monitor )); | |
129 | 1020 return Status.OK_STATUS; |
1021 } | |
1022 }; | |
1023 fReplacingDelayJob.setSystem(true); | |
1024 fReplacingDelayJob.setPriority(Job.INTERACTIVE); | |
148 | 1025 // if (DEBUG) |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
1026 // System.out_.println("AbstractHoverInformationControlManager.startReplaceInformationControl(): scheduled"); //$NON-NLS-1$ |
129 | 1027 fReplacingDelayJob.schedule(HOVER_AUTO_REPLACING_DELAY); |
1028 } | |
1029 | |
1030 /* | |
1031 * @see dwtx.jface.text.AbstractInformationControlManager#presentInformation() | |
1032 */ | |
1033 protected void presentInformation() { | |
1034 if (fMouseTracker is null) { | |
1035 super.presentInformation(); | |
1036 return; | |
1037 } | |
1038 | |
1039 Rectangle area= getSubjectArea(); | |
1040 if (area !is null) | |
1041 fMouseTracker.setSubjectArea(area); | |
1042 | |
1043 if (fMouseTracker.isMouseLost()) { | |
1044 fMouseTracker.computationCompleted(); | |
1045 fMouseTracker.deactivate(); | |
1046 } else { | |
1047 fMouseTracker.computationCompleted(); | |
1048 super.presentInformation(); | |
1049 } | |
1050 } | |
1051 | |
1052 /** | |
1053 * {@inheritDoc} | |
1054 * @deprecated visibility will be changed to protected | |
1055 */ | |
1056 public void setEnabled(bool enabled) { | |
1057 | |
1058 bool was= isEnabled(); | |
1059 super.setEnabled(enabled); | |
150 | 1060 bool is_= isEnabled(); |
129 | 1061 |
150 | 1062 if (was !is is_ && fMouseTracker !is null) { |
1063 if (is_) | |
129 | 1064 fMouseTracker.start(getSubjectControl()); |
1065 else | |
1066 fMouseTracker.stop(); | |
1067 } | |
1068 } | |
1069 | |
1070 /** | |
1071 * Disposes this manager's information control. | |
1072 */ | |
1073 public void dispose() { | |
1074 if (fMouseTracker !is null) { | |
1075 fMouseTracker.stop(); | |
1076 fMouseTracker.fSubjectControl= null; | |
1077 fMouseTracker= null; | |
1078 } | |
1079 super.dispose(); | |
1080 } | |
1081 | |
1082 /** | |
1083 * Returns the location at which the most recent mouse hover event | |
1084 * has been issued. | |
1085 * | |
1086 * @return the location of the most recent mouse hover event | |
1087 */ | |
1088 protected Point getHoverEventLocation() { | |
1089 return fHoverEvent !is null ? new Point(fHoverEvent.x, fHoverEvent.y) : new Point(-1, -1); | |
1090 } | |
162 | 1091 package Point getHoverEventLocation_package() { |
1092 return getHoverEventLocation(); | |
1093 } | |
129 | 1094 |
1095 /** | |
1096 * Returns the most recent mouse hover event. | |
1097 * | |
1098 * @return the most recent mouse hover event or <code>null</code> | |
1099 * @since 3.0 | |
1100 */ | |
1101 protected MouseEvent getHoverEvent() { | |
1102 return fHoverEvent; | |
1103 } | |
1104 | |
1105 /** | |
1106 * Returns the DWT event state of the most recent mouse hover event. | |
1107 * | |
1108 * @return the DWT event state of the most recent mouse hover event | |
1109 */ | |
1110 protected int getHoverEventStateMask() { | |
1111 return fHoverEventStateMask; | |
1112 } | |
148 | 1113 |
129 | 1114 /** |
1115 * Returns an adapter that gives access to internal methods. | |
1116 * <p> | |
1117 * <strong>Note:</strong> This method is not intended to be referenced or overridden by clients.</p> | |
148 | 1118 * |
129 | 1119 * @return the replaceable information control accessor |
1120 * @since 3.4 | |
1121 * @noreference This method is not intended to be referenced by clients. | |
1122 * @nooverride This method is not intended to be re-implemented or extended by clients. | |
1123 */ | |
1124 public InternalAccessor getInternalAccessor() { | |
162 | 1125 return new MyInternalAccessor2(this); |
1126 } | |
1127 static class MyInternalAccessor2 : MyInternalAccessor { | |
1128 AbstractHoverInformationControlManager outer_; | |
1129 this( AbstractHoverInformationControlManager a ){ | |
1130 outer_=a; | |
1131 super(a); | |
1132 } | |
159 | 1133 public void setHoverEnrichMode(ITextViewerExtension8_EnrichMode mode) { |
162 | 1134 outer_.setHoverEnrichMode(mode); |
129 | 1135 } |
162 | 1136 } |
129 | 1137 |
1138 } |