Mercurial > projects > dwt-addons
annotate dwtx/jface/text/AbstractHoverInformationControlManager.d @ 200:eb3414669eb0 default tip
fix for dmd 1.041 and tango 0.99.8
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 28 Mar 2009 03:09:57 +0100 |
parents | c3583c6ec027 |
children |
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; | |
192
c3583c6ec027
Added missing default cases for switch statements
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
493 default: |
129 | 494 } |
495 } | |
496 | |
497 /** | |
498 * Handle mouse movement events. | |
148 | 499 * |
129 | 500 * @param event the event |
501 * @since 3.4 | |
502 */ | |
503 private void handleMouseMove(Event event) { | |
148 | 504 // if (DEBUG) |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
505 // System.out_.println("AbstractHoverInformationControl.Closer.handleMouseMove():" + event); //$NON-NLS-1$ |
148 | 506 |
149 | 507 if (!( cast(Control)event.widget )) |
129 | 508 return; |
134 | 509 Control eventControl= cast(Control) event.widget; |
148 | 510 |
129 | 511 //transform coordinates to subject control: |
512 Point mouseLoc= event.display.map(eventControl, fSubjectControl, event.x, event.y); | |
148 | 513 |
129 | 514 if (fSubjectArea.contains(mouseLoc)) |
515 return; | |
148 | 516 |
129 | 517 IInformationControl iControl= getCurrentInformationControl(); |
518 if (!hasInformationControlReplacer() || !canMoveIntoInformationControl(iControl)) { | |
149 | 519 if ( cast(AnnotationBarHoverManager)this.outer ) { |
129 | 520 if (getInternalAccessor().getAllowMouseExit()) |
521 return; | |
522 } | |
523 hideInformationControl(); | |
524 return; | |
525 } | |
148 | 526 |
134 | 527 IInformationControlExtension3 iControl3= cast(IInformationControlExtension3) iControl; |
129 | 528 Rectangle controlBounds= iControl3.getBounds(); |
529 if (controlBounds !is null) { | |
530 Rectangle tooltipBounds= event.display.map(null, eventControl, controlBounds); | |
531 if (tooltipBounds.contains(event.x, event.y)) { | |
532 if (!isReplaceInProgress() && event.type !is DWT.MouseExit) | |
533 startReplaceInformationControl(event.display); | |
534 return; | |
535 } | |
536 cancelReplacingDelay(); | |
537 } | |
538 | |
539 if (!fSubjectControl.getBounds().contains(mouseLoc)) { | |
540 /* | |
541 * Use inKeepUpZone() to make sure it also works when the hover is | |
542 * completely outside of the subject control. | |
543 */ | |
544 if (!inKeepUpZone(mouseLoc.x, mouseLoc.y, fSubjectControl, fSubjectArea, true)) { | |
545 hideInformationControl(); | |
546 return; | |
547 } | |
548 } | |
549 } | |
550 } | |
551 | |
552 /** | |
553 * To be installed on the manager's subject control. Serves two different purposes: | |
554 * <ul> | |
555 * <li> start function: initiates the computation of the information to be presented. This happens on | |
556 * receipt of a mouse hover event and disables the information control manager, | |
557 * <li> restart function: tracks mouse move and shell activation event to determine when the information | |
558 * control manager needs to be reactivated. | |
559 * </ul> | |
560 */ | |
561 class MouseTracker : ShellAdapter , MouseTrackListener, MouseMoveListener { | |
562 | |
563 /** Margin around the original hover event location for computing the hover area. */ | |
146 | 564 private const static int EPSILON= 3; |
129 | 565 |
566 /** The area in which the original hover event occurred. */ | |
567 private Rectangle fHoverArea; | |
568 /** The area for which is computed information is valid. */ | |
569 private Rectangle fSubjectArea; | |
570 /** The tracker's subject control. */ | |
571 private Control fSubjectControl; | |
572 | |
573 /** Indicates whether the tracker is in restart mode ignoring hover events. */ | |
574 private bool fIsInRestartMode= false; | |
575 /** Indicates whether the tracker is computing the information to be presented. */ | |
576 private bool fIsComputing= false; | |
577 /** Indicates whether the mouse has been lost. */ | |
578 private bool fMouseLostWhileComputing= false; | |
579 /** Indicates whether the subject control's shell has been deactivated. */ | |
580 private bool fShellDeactivatedWhileComputing= false; | |
581 | |
582 /** | |
583 * Creates a new mouse tracker. | |
584 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
585 public this() { |
129 | 586 } |
587 | |
588 /** | |
589 * Sets this mouse tracker's subject area, the area to be tracked in order | |
590 * to re-enable the information control manager. | |
591 * | |
592 * @param subjectArea the subject area | |
593 */ | |
594 public void setSubjectArea(Rectangle subjectArea) { | |
595 Assert.isNotNull(subjectArea); | |
596 fSubjectArea= subjectArea; | |
597 } | |
598 | |
599 /** | |
600 * Starts this mouse tracker. The given control becomes this tracker's subject control. | |
601 * Installs itself as mouse track listener on the subject control. | |
602 * | |
603 * @param subjectControl the subject control | |
604 */ | |
605 public void start(Control subjectControl) { | |
606 fSubjectControl= subjectControl; | |
607 if (fSubjectControl !is null && !fSubjectControl.isDisposed()) | |
608 fSubjectControl.addMouseTrackListener(this); | |
609 | |
610 fIsInRestartMode= false; | |
611 fIsComputing= false; | |
612 fMouseLostWhileComputing= false; | |
613 fShellDeactivatedWhileComputing= false; | |
614 } | |
615 | |
616 /** | |
617 * Stops this mouse tracker. Removes itself as mouse track, mouse move, and | |
618 * shell listener from the subject control. | |
619 */ | |
620 public void stop() { | |
621 if (fSubjectControl !is null && !fSubjectControl.isDisposed()) { | |
622 fSubjectControl.removeMouseTrackListener(this); | |
623 fSubjectControl.removeMouseMoveListener(this); | |
624 fSubjectControl.getShell().removeShellListener(this); | |
625 } | |
626 } | |
627 | |
628 /** | |
629 * Initiates the computation of the information to be presented. Sets the initial hover area | |
630 * to a small rectangle around the hover event location. Adds mouse move and shell activation listeners | |
631 * to track whether the computed information is, after completion, useful for presentation and to | |
632 * implement the restart function. | |
633 * | |
634 * @param event the mouse hover event | |
635 */ | |
636 public void mouseHover(MouseEvent event) { | |
637 if (fIsComputing || fIsInRestartMode || | |
638 (fSubjectControl !is null && !fSubjectControl.isDisposed() && fSubjectControl.getShell() !is fSubjectControl.getShell().getDisplay().getActiveShell())) { | |
148 | 639 if (DEBUG) |
162 | 640 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 | 641 return; |
642 } | |
148 | 643 |
129 | 644 fIsInRestartMode= true; |
645 fIsComputing= true; | |
646 fMouseLostWhileComputing= false; | |
647 fShellDeactivatedWhileComputing= false; | |
648 | |
649 fHoverEventStateMask= event.stateMask; | |
650 fHoverEvent= event; | |
651 fHoverArea= new Rectangle(event.x - EPSILON, event.y - EPSILON, 2 * EPSILON, 2 * EPSILON ); | |
652 if (fHoverArea.x < 0) | |
653 fHoverArea.x= 0; | |
654 if (fHoverArea.y < 0) | |
655 fHoverArea.y= 0; | |
656 setSubjectArea(fHoverArea); | |
657 | |
658 if (fSubjectControl !is null && !fSubjectControl.isDisposed()) { | |
659 fSubjectControl.addMouseMoveListener(this); | |
660 fSubjectControl.getShell().addShellListener(this); | |
661 } | |
662 doShowInformation(); | |
663 } | |
664 | |
665 /** | |
666 * Deactivates this tracker's restart function and enables the information control | |
667 * manager. Does not have any effect if the tracker is still executing the start function (i.e. | |
668 * computing the information to be presented. | |
669 */ | |
670 protected void deactivate() { | |
671 if (fIsComputing) | |
672 return; | |
148 | 673 |
129 | 674 fIsInRestartMode= false; |
675 if (fSubjectControl !is null && !fSubjectControl.isDisposed()) { | |
676 fSubjectControl.removeMouseMoveListener(this); | |
677 fSubjectControl.getShell().removeShellListener(this); | |
678 } | |
679 } | |
680 | |
681 /* | |
682 * @see MouseTrackListener#mouseEnter(MouseEvent) | |
683 */ | |
684 public void mouseEnter(MouseEvent e) { | |
685 } | |
686 | |
687 /* | |
688 * @see MouseTrackListener#mouseExit(MouseEvent) | |
689 */ | |
690 public void mouseExit(MouseEvent e) { | |
691 if (!hasInformationControlReplacer() || !canMoveIntoInformationControl(getCurrentInformationControl()) || !inKeepUpZone(e.x, e.y, fSubjectControl, fSubjectArea, false)) { | |
692 fMouseLostWhileComputing= true; | |
693 deactivate(); | |
694 } | |
695 } | |
696 | |
697 /* | |
698 * @see MouseMoveListener#mouseMove(MouseEvent) | |
699 */ | |
700 public void mouseMove(MouseEvent event) { | |
701 if (!hasInformationControlReplacer() || !canMoveIntoInformationControl(getCurrentInformationControl())) { | |
702 if (!fSubjectArea.contains(event.x, event.y)) | |
703 deactivate(); | |
704 } else { | |
705 if (!inKeepUpZone(event.x, event.y, fSubjectControl, fSubjectArea, false)) | |
706 deactivate(); | |
707 } | |
708 } | |
709 | |
710 /* | |
711 * @see ShellListener#shellDeactivated(ShellEvent) | |
712 */ | |
713 public void shellDeactivated(ShellEvent e) { | |
714 fShellDeactivatedWhileComputing= true; | |
715 deactivate(); | |
716 } | |
717 | |
718 /* | |
719 * @see ShellListener#shellIconified(ShellEvent) | |
720 */ | |
721 public void shellIconified(ShellEvent e) { | |
722 fShellDeactivatedWhileComputing= true; | |
723 deactivate(); | |
724 } | |
725 | |
726 /** | |
727 * Tells this tracker that the start function processing has been completed. | |
728 */ | |
729 public void computationCompleted() { | |
730 fIsComputing= false; | |
731 fMouseLostWhileComputing= false; | |
732 fShellDeactivatedWhileComputing= false; | |
733 } | |
734 | |
735 /** | |
736 * Determines whether the computed information is still useful for presentation. | |
737 * This is not the case, if the shell of the subject control has been deactivated, the mouse | |
738 * left the subject control, or the mouse moved on, so that it is no longer in the subject | |
739 * area. | |
740 * | |
741 * @return <code>true</code> if information is still useful for presentation, <code>false</code> otherwise | |
742 */ | |
743 public bool isMouseLost() { | |
744 | |
745 if (fMouseLostWhileComputing || fShellDeactivatedWhileComputing) | |
746 return true; | |
747 | |
748 if (fSubjectControl !is null && !fSubjectControl.isDisposed()) { | |
749 Display display= fSubjectControl.getDisplay(); | |
750 Point p= display.getCursorLocation(); | |
751 p= fSubjectControl.toControl(p); | |
752 if (!fSubjectArea.contains(p) && !fHoverArea.contains(p)) | |
753 return true; | |
754 } | |
755 | |
756 return false; | |
757 } | |
758 } | |
759 | |
760 /** | |
761 * The delay in {@link ITextViewerExtension8.EnrichMode#AFTER_DELAY} mode after which | |
762 * the hover is enriched when the mouse has stopped moving inside the hover. | |
763 * @since 3.4 | |
764 */ | |
147 | 765 private static const long HOVER_AUTO_REPLACING_DELAY= 200; |
129 | 766 |
767 /** The mouse tracker on the subject control */ | |
159 | 768 private MouseTracker fMouseTracker; |
129 | 769 /** |
770 * The remembered hover event. | |
771 * @since 3.0 | |
772 */ | |
773 private MouseEvent fHoverEvent= null; | |
774 /** The remembered hover event state mask of the keyboard modifiers */ | |
775 private int fHoverEventStateMask= 0; | |
776 /** | |
777 * The thread that delays replacing of the hover information control. | |
778 * To be accessed in the UI thread only! | |
148 | 779 * |
129 | 780 * @since 3.4 |
781 */ | |
782 private Job fReplacingDelayJob; | |
148 | 783 |
129 | 784 /** |
785 * The {@link ITextViewerExtension8.EnrichMode}, may be <code>null</code>. | |
786 * @since 3.4 | |
787 */ | |
159 | 788 private ITextViewerExtension8_EnrichMode fEnrichMode; |
148 | 789 |
129 | 790 /** |
791 * Indicates whether we have received a MouseDown event and are waiting for a MouseUp | |
792 * (and don't replace the information control until that happened). | |
793 * @since 3.4 | |
794 */ | |
795 private bool fWaitForMouseUp= false; | |
148 | 796 |
129 | 797 /** |
798 * Creates a new hover information control manager using the given information control creator. | |
799 * By default a <code>Closer</code> instance is set as this manager's closer. | |
800 * | |
801 * @param creator the information control creator | |
802 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
803 protected this(IInformationControlCreator creator) { |
159 | 804 fMouseTracker= new MouseTracker(); |
129 | 805 super(creator); |
806 setCloser(new Closer()); | |
159 | 807 setHoverEnrichMode(ITextViewerExtension8_EnrichMode.AFTER_DELAY); |
129 | 808 } |
809 | |
810 /** | |
811 * Tests whether a given mouse location is within the keep-up zone. | |
812 * The hover should not be hidden as long as the mouse stays inside this zone. | |
148 | 813 * |
129 | 814 * @param x the x coordinate, relative to the <em>subject control</em> |
815 * @param y the y coordinate, relative to the <em>subject control</em> | |
816 * @param subjectControl the subject control | |
817 * @param subjectArea the area for which the presented information is valid | |
818 * @param blowUp If <code>true</code>, then calculate for the closer, i.e. blow up the keepUp area. | |
819 * If <code>false</code>, then use tight bounds for hover detection. | |
148 | 820 * |
129 | 821 * @return <code>true</code> iff the mouse event occurred in the keep-up zone |
822 * @since 3.4 | |
823 */ | |
824 private bool inKeepUpZone(int x, int y, Control subjectControl, Rectangle subjectArea, bool blowUp) { | |
825 if (subjectArea.contains(x, y)) | |
826 return true; | |
148 | 827 |
129 | 828 IInformationControl iControl= getCurrentInformationControl(); |
142 | 829 if (( cast(IInformationControlExtension5)iControl && !(cast(IInformationControlExtension5) iControl).isVisible())) { |
129 | 830 iControl= null; |
831 if (getInformationControlReplacer() !is null) { | |
832 iControl= getInformationControlReplacer().getCurrentInformationControl2(); | |
142 | 833 if (( cast(IInformationControlExtension5)iControl && !(cast(IInformationControlExtension5) iControl).isVisible())) { |
129 | 834 return false; |
835 } | |
836 } | |
837 } | |
138 | 838 if ( cast(IInformationControlExtension3)iControl ) { |
134 | 839 IInformationControlExtension3 iControl3= cast(IInformationControlExtension3) iControl; |
148 | 840 |
129 | 841 Rectangle iControlBounds= subjectControl.getDisplay().map(null, subjectControl, iControl3.getBounds()); |
842 Rectangle totalBounds= Geometry.copy(iControlBounds); | |
843 if (blowUp && isReplaceInProgress()) { | |
844 //Problem: blown up iControl overlaps rest of subjectArea's line | |
845 // solution for now: only blow up for keep up (closer), but not for further hover detection | |
846 int margin= getInformationControlReplacer().getKeepUpMargin(); | |
847 Geometry.expand(totalBounds, margin, margin, margin, margin); | |
848 } | |
148 | 849 |
129 | 850 if (!blowUp) { |
851 if (iControlBounds.contains(x, y)) | |
852 return true; | |
148 | 853 |
129 | 854 if (subjectArea.y + subjectArea.height < iControlBounds.y) { |
855 // special case for hover events: subjectArea totally above iControl: | |
856 // +-----------+ | |
857 // |subjectArea| | |
858 // +-----------+ | |
859 // |also keepUp| | |
860 // ++-----------+-------+ | |
861 // | InformationControl | | |
862 // +--------------------+ | |
863 if (subjectArea.y + subjectArea.height <= y && y <= totalBounds.y) { | |
864 // is vertically between subject area and iControl | |
865 if (subjectArea.x <= x && x <= subjectArea.x + subjectArea.width) { | |
866 // is below subject area (in a vertical projection) | |
867 return true; | |
868 } | |
869 // FIXME: cases when subjectArea extends to left or right of iControl? | |
870 } | |
871 return false; | |
148 | 872 |
129 | 873 } else if (iControlBounds.x + iControlBounds.width < subjectArea.x) { |
874 // special case for hover events (e.g. in overview ruler): iControl totally left of subjectArea | |
875 // +--------------------+-----------+ | |
876 // | | +-----------+ | |
877 // | InformationControl |also keepUp|subjectArea| | |
878 // | | +-----------+ | |
879 // +--------------------+-----------+ | |
880 if (iControlBounds.x + iControlBounds.width <= x && x <= subjectArea.x) { | |
881 // is horizontally between iControl and subject area | |
882 if (iControlBounds.y <= y && y <= iControlBounds.y + iControlBounds.height) { | |
883 // is to the right of iControl (in a horizontal projection) | |
884 return true; | |
885 } | |
886 } | |
887 return false; | |
148 | 888 |
129 | 889 } else if (subjectArea.x + subjectArea.width < iControlBounds.x) { |
890 // special case for hover events (e.g. in annotation ruler): subjectArea totally left of iControl | |
891 // +-----------+--------------------+ | |
892 // +-----------+ | | | |
893 // |subjectArea|also keepUp| InformationControl | | |
894 // +-----------+ | | | |
895 // +-----------+--------------------+ | |
896 if (subjectArea.x + subjectArea.width <= x && x <= iControlBounds.x) { | |
897 // is horizontally between subject area and iControl | |
898 if (iControlBounds.y <= y && y <= iControlBounds.y + iControlBounds.height) { | |
899 // is to the left of iControl (in a horizontal projection) | |
900 return true; | |
901 } | |
902 } | |
903 return false; | |
904 } | |
905 } | |
148 | 906 |
129 | 907 // FIXME: should maybe use convex hull, not bounding box |
908 totalBounds.add(subjectArea); | |
909 if (totalBounds.contains(x, y)) | |
910 return true; | |
911 } | |
912 return false; | |
913 } | |
148 | 914 |
129 | 915 /** |
916 * Tests whether the given information control allows the mouse to be moved | |
917 * into it. | |
148 | 918 * |
129 | 919 * @param iControl information control or <code>null</code> if none |
920 * @return <code>true</code> if information control allows mouse move into | |
921 * control, <code>false</code> otherwise | |
922 */ | |
923 bool canMoveIntoInformationControl(IInformationControl iControl) { | |
924 return fEnrichMode !is null && canReplace(iControl); | |
925 } | |
148 | 926 |
129 | 927 /* |
928 * @see dwtx.jface.text.AbstractInformationControlManager#hideInformationControl() | |
929 */ | |
930 protected void hideInformationControl() { | |
931 cancelReplacingDelay(); | |
932 super.hideInformationControl(); | |
933 } | |
934 | |
935 /** | |
936 * Sets the hover enrich mode. Only applicable when an information | |
937 * control replacer has been set with | |
938 * {@link #setInformationControlReplacer(InformationControlReplacer)} . | |
148 | 939 * |
129 | 940 * @param mode the enrich mode |
941 * @since 3.4 | |
942 * @see ITextViewerExtension8#setHoverEnrichMode(dwtx.jface.text.ITextViewerExtension8.EnrichMode) | |
943 */ | |
159 | 944 void setHoverEnrichMode(ITextViewerExtension8_EnrichMode mode) { |
129 | 945 fEnrichMode= mode; |
946 } | |
148 | 947 |
129 | 948 /* |
949 * @see dwtx.jface.text.AbstractInformationControlManager#replaceInformationControl(bool) | |
950 */ | |
951 void replaceInformationControl(bool takeFocus) { | |
952 fWaitForMouseUp= false; | |
953 super.replaceInformationControl(takeFocus); | |
954 } | |
148 | 955 |
129 | 956 /** |
957 * Cancels the replacing delay job. | |
958 * @return <code>true</code> iff canceling was successful, <code>false</code> if replacing has already started | |
959 */ | |
960 bool cancelReplacingDelay() { | |
961 fWaitForMouseUp= false; | |
962 if (fReplacingDelayJob !is null && fReplacingDelayJob.getState() !is Job.RUNNING) { | |
963 bool cancelled= fReplacingDelayJob.cancel(); | |
964 fReplacingDelayJob= null; | |
148 | 965 // if (DEBUG) |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
966 // System.out_.println("AbstractHoverInformationControlManager.cancelReplacingDelay(): cancelled=" + cancelled); //$NON-NLS-1$ |
129 | 967 return cancelled; |
968 } | |
148 | 969 // if (DEBUG) |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
970 // System.out_.println("AbstractHoverInformationControlManager.cancelReplacingDelay(): not delayed"); //$NON-NLS-1$ |
129 | 971 return true; |
972 } | |
148 | 973 |
129 | 974 /** |
975 * Starts replacing the information control, considering the current | |
976 * {@link ITextViewerExtension8.EnrichMode}. | |
977 * If set to {@link ITextViewerExtension8.EnrichMode#AFTER_DELAY}, this | |
978 * method cancels previous requests and restarts the delay timer. | |
148 | 979 * |
129 | 980 * @param display the display to be used for the call to |
981 * {@link #replaceInformationControl(bool)} in the UI thread | |
982 */ | |
156 | 983 private void startReplaceInformationControl(Display display) { |
159 | 984 if (fEnrichMode is ITextViewerExtension8_EnrichMode.ON_CLICK) |
129 | 985 return; |
148 | 986 |
129 | 987 if (fReplacingDelayJob !is null) { |
988 if (fReplacingDelayJob.getState() !is Job.RUNNING) { | |
989 if (fReplacingDelayJob.cancel()) { | |
159 | 990 if (fEnrichMode is ITextViewerExtension8_EnrichMode.IMMEDIATELY) { |
129 | 991 fReplacingDelayJob= null; |
992 if (! fWaitForMouseUp) | |
993 replaceInformationControl(false); | |
994 } else { | |
148 | 995 // if (DEBUG) |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
996 // System.out_.println("AbstractHoverInformationControlManager.startReplaceInformationControl(): rescheduled"); //$NON-NLS-1$ |
129 | 997 fReplacingDelayJob.schedule(HOVER_AUTO_REPLACING_DELAY); |
998 } | |
999 } | |
1000 } | |
1001 return; | |
1002 } | |
148 | 1003 |
156 | 1004 fReplacingDelayJob= new class("AbstractHoverInformationControlManager Replace Delayer", display) Job { //$NON-NLS-1$ |
1005 Display display_; | |
1006 this( String str, Display b){ | |
150 | 1007 super(str); |
156 | 1008 display_=b; |
150 | 1009 } |
1010 public IStatus run(IProgressMonitor monitor) { | |
156 | 1011 if (monitor.isCanceled() || display_.isDisposed()) { |
129 | 1012 return Status.CANCEL_STATUS; |
1013 } | |
156 | 1014 display_.syncExec(dgRunnable( (IProgressMonitor monitor_) { |
150 | 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 } | |
162 | 1092 package Point getHoverEventLocation_package() { |
1093 return getHoverEventLocation(); | |
1094 } | |
129 | 1095 |
1096 /** | |
1097 * Returns the most recent mouse hover event. | |
1098 * | |
1099 * @return the most recent mouse hover event or <code>null</code> | |
1100 * @since 3.0 | |
1101 */ | |
1102 protected MouseEvent getHoverEvent() { | |
1103 return fHoverEvent; | |
1104 } | |
1105 | |
1106 /** | |
1107 * Returns the DWT event state of the most recent mouse hover event. | |
1108 * | |
1109 * @return the DWT event state of the most recent mouse hover event | |
1110 */ | |
1111 protected int getHoverEventStateMask() { | |
1112 return fHoverEventStateMask; | |
1113 } | |
148 | 1114 |
129 | 1115 /** |
1116 * Returns an adapter that gives access to internal methods. | |
1117 * <p> | |
1118 * <strong>Note:</strong> This method is not intended to be referenced or overridden by clients.</p> | |
148 | 1119 * |
129 | 1120 * @return the replaceable information control accessor |
1121 * @since 3.4 | |
1122 * @noreference This method is not intended to be referenced by clients. | |
1123 * @nooverride This method is not intended to be re-implemented or extended by clients. | |
1124 */ | |
1125 public InternalAccessor getInternalAccessor() { | |
162 | 1126 return new MyInternalAccessor2(this); |
1127 } | |
1128 static class MyInternalAccessor2 : MyInternalAccessor { | |
1129 AbstractHoverInformationControlManager outer_; | |
1130 this( AbstractHoverInformationControlManager a ){ | |
1131 outer_=a; | |
1132 super(a); | |
1133 } | |
159 | 1134 public void setHoverEnrichMode(ITextViewerExtension8_EnrichMode mode) { |
162 | 1135 outer_.setHoverEnrichMode(mode); |
129 | 1136 } |
162 | 1137 } |
129 | 1138 |
1139 } |