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