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.contentassist.AdditionalInfoController;
|
|
14
|
131
|
15 import dwtx.jface.text.contentassist.ContentAssistEvent; // packageimport
|
|
16 import dwtx.jface.text.contentassist.Helper; // packageimport
|
|
17 import dwtx.jface.text.contentassist.PopupCloser; // packageimport
|
|
18 import dwtx.jface.text.contentassist.IContentAssistant; // packageimport
|
|
19 import dwtx.jface.text.contentassist.CompletionProposal; // packageimport
|
|
20 import dwtx.jface.text.contentassist.ICompletionProposalExtension5; // packageimport
|
|
21 import dwtx.jface.text.contentassist.IContextInformationValidator; // packageimport
|
|
22 import dwtx.jface.text.contentassist.IContentAssistListener; // packageimport
|
|
23 import dwtx.jface.text.contentassist.ICompletionProposalExtension6; // packageimport
|
|
24 import dwtx.jface.text.contentassist.ICompletionListener; // packageimport
|
|
25 import dwtx.jface.text.contentassist.ICompletionProposalExtension2; // packageimport
|
|
26 import dwtx.jface.text.contentassist.IContentAssistantExtension4; // packageimport
|
|
27 import dwtx.jface.text.contentassist.ContextInformation; // packageimport
|
|
28 import dwtx.jface.text.contentassist.ICompletionProposalExtension3; // packageimport
|
|
29 import dwtx.jface.text.contentassist.ContextInformationValidator; // packageimport
|
|
30 import dwtx.jface.text.contentassist.ICompletionProposal; // packageimport
|
|
31 import dwtx.jface.text.contentassist.IContentAssistProcessor; // packageimport
|
|
32 import dwtx.jface.text.contentassist.IContextInformationPresenter; // packageimport
|
|
33 import dwtx.jface.text.contentassist.ICompletionProposalExtension4; // packageimport
|
|
34 import dwtx.jface.text.contentassist.ICompletionListenerExtension; // packageimport
|
|
35 import dwtx.jface.text.contentassist.ContextInformationPopup; // packageimport
|
|
36 import dwtx.jface.text.contentassist.IContextInformationExtension; // packageimport
|
|
37 import dwtx.jface.text.contentassist.IContentAssistantExtension2; // packageimport
|
|
38 import dwtx.jface.text.contentassist.ContentAssistSubjectControlAdapter; // packageimport
|
|
39 import dwtx.jface.text.contentassist.CompletionProposalPopup; // packageimport
|
|
40 import dwtx.jface.text.contentassist.ICompletionProposalExtension; // packageimport
|
|
41 import dwtx.jface.text.contentassist.IContextInformation; // packageimport
|
|
42 import dwtx.jface.text.contentassist.IContentAssistantExtension3; // packageimport
|
|
43 import dwtx.jface.text.contentassist.ContentAssistant; // packageimport
|
|
44 import dwtx.jface.text.contentassist.IContentAssistantExtension; // packageimport
|
|
45 import dwtx.jface.text.contentassist.JFaceTextMessages; // packageimport
|
|
46
|
|
47
|
129
|
48 import dwt.dwthelper.utils;
|
|
49
|
|
50
|
|
51
|
|
52
|
|
53 import dwt.events.SelectionEvent;
|
|
54 import dwt.events.SelectionListener;
|
|
55 import dwt.graphics.Point;
|
|
56 import dwt.graphics.Rectangle;
|
|
57 import dwt.widgets.Control;
|
|
58 import dwt.widgets.Display;
|
|
59 import dwt.widgets.Shell;
|
|
60 import dwt.widgets.Table;
|
|
61 import dwt.widgets.TableItem;
|
|
62 import dwtx.core.runtime.Assert;
|
|
63 import dwtx.core.runtime.IProgressMonitor;
|
|
64 import dwtx.core.runtime.IStatus;
|
|
65 import dwtx.core.runtime.Status;
|
|
66 import dwtx.core.runtime.jobs.Job;
|
|
67 import dwtx.jface.internal.text.InformationControlReplacer;
|
|
68 import dwtx.jface.text.AbstractInformationControlManager;
|
|
69 import dwtx.jface.text.AbstractReusableInformationControlCreator;
|
|
70 import dwtx.jface.text.DefaultInformationControl;
|
|
71 import dwtx.jface.text.IInformationControl;
|
|
72 import dwtx.jface.text.IInformationControlCreator;
|
|
73 import dwtx.jface.text.IInformationControlExtension3;
|
|
74
|
|
75
|
|
76 /**
|
|
77 * Displays the additional information available for a completion proposal.
|
|
78 *
|
|
79 * @since 2.0
|
|
80 */
|
|
81 class AdditionalInfoController : AbstractInformationControlManager {
|
|
82
|
|
83 /**
|
|
84 * A timer thread.
|
|
85 *
|
|
86 * @since 3.2
|
|
87 */
|
|
88 private static abstract class Timer {
|
|
89 private static final int DELAY_UNTIL_JOB_IS_SCHEDULED= 50;
|
|
90
|
|
91 /**
|
|
92 * A <code>Task</code> is {@link Task#run() run} when {@link #delay()} milliseconds have
|
|
93 * elapsed after it was scheduled without a {@link #reset(ICompletionProposal) reset}
|
|
94 * to occur.
|
|
95 */
|
|
96 private abstract class Task : Runnable {
|
|
97 /**
|
|
98 * @return the delay in milliseconds before this task should be run
|
|
99 */
|
|
100 public abstract long delay();
|
|
101 /**
|
|
102 * Runs this task.
|
|
103 */
|
|
104 public abstract void run();
|
|
105 /**
|
|
106 * @return the task to be scheduled after this task has been run
|
|
107 */
|
|
108 public abstract Task nextTask();
|
|
109 }
|
|
110
|
|
111 /**
|
|
112 * IDLE: the initial task, and active whenever the info has been shown. It cannot be run,
|
|
113 * but specifies an infinite delay.
|
|
114 */
|
|
115 private final Task IDLE= new Task() {
|
|
116 public void run() {
|
|
117 Assert.isTrue(false);
|
|
118 }
|
|
119
|
|
120 public Task nextTask() {
|
|
121 Assert.isTrue(false);
|
|
122 return null;
|
|
123 }
|
|
124
|
|
125 public long delay() {
|
|
126 return Long.MAX_VALUE;
|
|
127 }
|
|
128
|
|
129 public String toString() {
|
|
130 return "IDLE"; //$NON-NLS-1$
|
|
131 }
|
|
132 };
|
|
133 /**
|
|
134 * FIRST_WAIT: Schedules a platform {@link Job} to fetch additional info from an {@link ICompletionProposalExtension5}.
|
|
135 */
|
|
136 private final Task FIRST_WAIT= new Task() {
|
|
137 public void run() {
|
|
138 final ICompletionProposalExtension5 proposal= getCurrentProposalEx();
|
|
139 Job job= new Job(JFaceTextMessages.getString("AdditionalInfoController.job_name")) { //$NON-NLS-1$
|
|
140 protected IStatus run(IProgressMonitor monitor) {
|
|
141 Object info;
|
|
142 try {
|
|
143 info= proposal.getAdditionalProposalInfo(monitor);
|
|
144 } catch (RuntimeException x) {
|
|
145 /*
|
|
146 * XXX: This is the safest fix at this point so close to end of 3.2.
|
|
147 * Will be revisited when fixing https://bugs.eclipse.org/bugs/show_bug.cgi?id=101033
|
|
148 */
|
|
149 return new Status(IStatus.WARNING, "dwtx.jface.text", IStatus.OK, "", x); //$NON-NLS-1$ //$NON-NLS-2$
|
|
150 }
|
|
151 setInfo((ICompletionProposal) proposal, info);
|
|
152 return new Status(IStatus.OK, "dwtx.jface.text", IStatus.OK, "", null); //$NON-NLS-1$ //$NON-NLS-2$
|
|
153 }
|
|
154 };
|
|
155 job.schedule();
|
|
156 }
|
|
157
|
|
158 public Task nextTask() {
|
|
159 return SECOND_WAIT;
|
|
160 }
|
|
161
|
|
162 public long delay() {
|
|
163 return DELAY_UNTIL_JOB_IS_SCHEDULED;
|
|
164 }
|
|
165
|
|
166 public String toString() {
|
|
167 return "FIRST_WAIT"; //$NON-NLS-1$
|
|
168 }
|
|
169 };
|
|
170 /**
|
|
171 * SECOND_WAIT: Allows display of additional info obtained from an
|
|
172 * {@link ICompletionProposalExtension5}.
|
|
173 */
|
|
174 private final Task SECOND_WAIT= new Task() {
|
|
175 public void run() {
|
|
176 // show the info
|
|
177 allowShowing();
|
|
178 }
|
|
179
|
|
180 public Task nextTask() {
|
|
181 return IDLE;
|
|
182 }
|
|
183
|
|
184 public long delay() {
|
|
185 return fDelay - DELAY_UNTIL_JOB_IS_SCHEDULED;
|
|
186 }
|
|
187
|
|
188 public String toString() {
|
|
189 return "SECOND_WAIT"; //$NON-NLS-1$
|
|
190 }
|
|
191 };
|
|
192 /**
|
|
193 * LEGACY_WAIT: Posts a runnable into the display thread to fetch additional info from non-{@link ICompletionProposalExtension5}s.
|
|
194 */
|
|
195 private final Task LEGACY_WAIT= new Task() {
|
|
196 public void run() {
|
|
197 final ICompletionProposal proposal= getCurrentProposal();
|
|
198 if (!fDisplay.isDisposed()) {
|
|
199 fDisplay.asyncExec(new Runnable() {
|
|
200 public void run() {
|
|
201 synchronized (Timer.this) {
|
|
202 if (proposal is getCurrentProposal()) {
|
|
203 Object info= proposal.getAdditionalProposalInfo();
|
|
204 showInformation(proposal, info);
|
|
205 }
|
|
206 }
|
|
207 }
|
|
208 });
|
|
209 }
|
|
210 }
|
|
211
|
|
212 public Task nextTask() {
|
|
213 return IDLE;
|
|
214 }
|
|
215
|
|
216 public long delay() {
|
|
217 return fDelay;
|
|
218 }
|
|
219
|
|
220 public String toString() {
|
|
221 return "LEGACY_WAIT"; //$NON-NLS-1$
|
|
222 }
|
|
223 };
|
|
224 /**
|
|
225 * EXIT: The task that triggers termination of the timer thread.
|
|
226 */
|
|
227 private final Task EXIT= new Task() {
|
|
228 public long delay() {
|
|
229 return 1;
|
|
230 }
|
|
231
|
|
232 public Task nextTask() {
|
|
233 Assert.isTrue(false);
|
|
234 return EXIT;
|
|
235 }
|
|
236
|
|
237 public void run() {
|
|
238 Assert.isTrue(false);
|
|
239 }
|
|
240
|
|
241 public String toString() {
|
|
242 return "EXIT"; //$NON-NLS-1$
|
|
243 }
|
|
244 };
|
|
245
|
|
246 /** The timer thread. */
|
|
247 private final Thread fThread;
|
|
248
|
|
249 /** The currently waiting / active task. */
|
|
250 private Task fTask;
|
|
251 /** The next wake up time. */
|
|
252 private long fNextWakeup;
|
|
253
|
|
254 private ICompletionProposal fCurrentProposal= null;
|
|
255 private Object fCurrentInfo= null;
|
|
256 private bool fAllowShowing= false;
|
|
257
|
|
258 private final Display fDisplay;
|
|
259 private final int fDelay;
|
|
260
|
|
261 /**
|
|
262 * Creates a new timer.
|
|
263 *
|
|
264 * @param display the display to use for display thread posting.
|
|
265 * @param delay the delay until to show additional info
|
|
266 */
|
|
267 public Timer(Display display, int delay) {
|
|
268 fDisplay= display;
|
|
269 fDelay= delay;
|
|
270 long current= System.currentTimeMillis();
|
|
271 schedule(IDLE, current);
|
|
272
|
|
273 fThread= new Thread(new Runnable() {
|
|
274 public void run() {
|
|
275 try {
|
|
276 loop();
|
|
277 } catch (InterruptedException x) {
|
|
278 }
|
|
279 }
|
|
280 }, JFaceTextMessages.getString("InfoPopup.info_delay_timer_name")); //$NON-NLS-1$
|
|
281 fThread.start();
|
|
282 }
|
|
283
|
|
284 /**
|
|
285 * Terminates the timer thread.
|
|
286 */
|
|
287 public synchronized final void terminate() {
|
|
288 schedule(EXIT, System.currentTimeMillis());
|
|
289 notifyAll();
|
|
290 }
|
|
291
|
|
292 /**
|
|
293 * Resets the timer thread as the selection has changed to a new proposal.
|
|
294 *
|
|
295 * @param p the new proposal
|
|
296 */
|
|
297 public final synchronized void reset(ICompletionProposal p) {
|
|
298 if (fCurrentProposal !is p) {
|
|
299 fCurrentProposal= p;
|
|
300 fCurrentInfo= null;
|
|
301 fAllowShowing= false;
|
|
302
|
|
303 long oldWakeup= fNextWakeup;
|
|
304 Task task= taskOnReset(p);
|
|
305 schedule(task, System.currentTimeMillis());
|
|
306 if (fNextWakeup < oldWakeup)
|
|
307 notifyAll();
|
|
308 }
|
|
309 }
|
|
310
|
|
311 private Task taskOnReset(ICompletionProposal p) {
|
|
312 if (p is null)
|
|
313 return IDLE;
|
|
314 if (isExt5(p))
|
|
315 return FIRST_WAIT;
|
|
316 return LEGACY_WAIT;
|
|
317 }
|
|
318
|
|
319 private synchronized void loop() throws InterruptedException {
|
|
320 long current= System.currentTimeMillis();
|
|
321 Task task= currentTask();
|
|
322
|
|
323 while (task !is EXIT) {
|
|
324 long delay= fNextWakeup - current;
|
|
325 if (delay <= 0) {
|
|
326 task.run();
|
|
327 task= task.nextTask();
|
|
328 schedule(task, current);
|
|
329 } else {
|
|
330 wait(delay);
|
|
331 current= System.currentTimeMillis();
|
|
332 task= currentTask();
|
|
333 }
|
|
334 }
|
|
335 }
|
|
336
|
|
337 private Task currentTask() {
|
|
338 return fTask;
|
|
339 }
|
|
340
|
|
341 private void schedule(Task task, long current) {
|
|
342 fTask= task;
|
|
343 long nextWakeup= current + task.delay();
|
|
344 if (nextWakeup <= current)
|
|
345 fNextWakeup= Long.MAX_VALUE;
|
|
346 else
|
|
347 fNextWakeup= nextWakeup;
|
|
348 }
|
|
349
|
|
350 private bool isExt5(ICompletionProposal p) {
|
|
351 return p instanceof ICompletionProposalExtension5;
|
|
352 }
|
|
353
|
|
354 ICompletionProposal getCurrentProposal() {
|
|
355 return fCurrentProposal;
|
|
356 }
|
|
357
|
|
358 ICompletionProposalExtension5 getCurrentProposalEx() {
|
|
359 Assert.isTrue(fCurrentProposal instanceof ICompletionProposalExtension5);
|
|
360 return (ICompletionProposalExtension5) fCurrentProposal;
|
|
361 }
|
|
362
|
|
363 synchronized void setInfo(ICompletionProposal proposal, Object info) {
|
|
364 if (proposal is fCurrentProposal) {
|
|
365 fCurrentInfo= info;
|
|
366 if (fAllowShowing) {
|
|
367 triggerShowing();
|
|
368 }
|
|
369 }
|
|
370 }
|
|
371
|
|
372 private void triggerShowing() {
|
|
373 final Object info= fCurrentInfo;
|
|
374 if (!fDisplay.isDisposed()) {
|
|
375 fDisplay.asyncExec(new Runnable() {
|
|
376 public void run() {
|
|
377 synchronized (Timer.this) {
|
|
378 if (info is fCurrentInfo) {
|
|
379 showInformation(fCurrentProposal, info);
|
|
380 }
|
|
381 }
|
|
382 }
|
|
383 });
|
|
384 }
|
|
385 }
|
|
386
|
|
387 /**
|
|
388 * Called in the display thread to show additional info.
|
|
389 *
|
|
390 * @param proposal the proposal to show information about
|
|
391 * @param info the information about <code>proposal</code>
|
|
392 */
|
|
393 protected abstract void showInformation(ICompletionProposal proposal, Object info);
|
|
394
|
|
395 void allowShowing() {
|
|
396 fAllowShowing= true;
|
|
397 triggerShowing();
|
|
398 }
|
|
399 }
|
|
400 /**
|
|
401 * Internal table selection listener.
|
|
402 */
|
|
403 private class TableSelectionListener : SelectionListener {
|
|
404
|
|
405 /*
|
|
406 * @see SelectionListener#widgetSelected(SelectionEvent)
|
|
407 */
|
|
408 public void widgetSelected(SelectionEvent e) {
|
|
409 handleTableSelectionChanged();
|
|
410 }
|
|
411
|
|
412 /*
|
|
413 * @see SelectionListener#widgetDefaultSelected(SelectionEvent)
|
|
414 */
|
|
415 public void widgetDefaultSelected(SelectionEvent e) {
|
|
416 }
|
|
417 }
|
|
418
|
|
419 /**
|
|
420 * Default control creator for the information control replacer.
|
|
421 * @since 3.4
|
|
422 */
|
|
423 private static class DefaultPresenterControlCreator : AbstractReusableInformationControlCreator {
|
|
424 public IInformationControl doCreateInformationControl(Shell shell) {
|
|
425 return new DefaultInformationControl(shell, true);
|
|
426 }
|
|
427 }
|
|
428
|
|
429 /** The proposal table. */
|
|
430 private Table fProposalTable;
|
|
431 /** The table selection listener */
|
|
432 private SelectionListener fSelectionListener= new TableSelectionListener();
|
|
433 /** The delay after which additional information is displayed */
|
|
434 private final int fDelay;
|
|
435 /**
|
|
436 * The timer thread.
|
|
437 * @since 3.2
|
|
438 */
|
|
439 private Timer fTimer;
|
|
440 /**
|
|
441 * The proposal most recently set by {@link #showInformation(ICompletionProposal, Object)},
|
|
442 * possibly <code>null</code>.
|
|
443 * @since 3.2
|
|
444 */
|
|
445 private ICompletionProposal fProposal;
|
|
446 /**
|
|
447 * The information most recently set by {@link #showInformation(ICompletionProposal, Object)},
|
|
448 * possibly <code>null</code>.
|
|
449 * @since 3.2
|
|
450 */
|
|
451 private Object fInformation;
|
|
452
|
|
453 /**
|
|
454 * Creates a new additional information controller.
|
|
455 *
|
|
456 * @param creator the information control creator to be used by this controller
|
|
457 * @param delay time in milliseconds after which additional info should be displayed
|
|
458 */
|
|
459 AdditionalInfoController(IInformationControlCreator creator, int delay) {
|
|
460 super(creator);
|
|
461 fDelay= delay;
|
|
462 setAnchor(ANCHOR_RIGHT);
|
|
463 setFallbackAnchors(new Anchor[] { ANCHOR_RIGHT, ANCHOR_LEFT, ANCHOR_BOTTOM });
|
|
464
|
|
465 /*
|
|
466 * Adjust the location by one pixel towards the proposal popup, so that the single pixel
|
|
467 * border of the additional info popup overlays with the border of the popup. This avoids
|
|
468 * having a double black line.
|
|
469 */
|
|
470 int spacing= -1;
|
|
471 setMargins(spacing, spacing); // see also adjustment in #computeLocation
|
|
472
|
|
473 InformationControlReplacer replacer= new InformationControlReplacer(new DefaultPresenterControlCreator());
|
|
474 getInternalAccessor().setInformationControlReplacer(replacer);
|
|
475 }
|
|
476
|
|
477 /*
|
|
478 * @see AbstractInformationControlManager#install(Control)
|
|
479 */
|
|
480 public void install(Control control) {
|
|
481
|
|
482 if (fProposalTable is control) {
|
|
483 // already installed
|
|
484 return;
|
|
485 }
|
|
486
|
|
487 super.install(control.getShell());
|
|
488
|
|
489 Assert.isTrue(control instanceof Table);
|
|
490 fProposalTable= (Table) control;
|
|
491 fProposalTable.addSelectionListener(fSelectionListener);
|
|
492 getInternalAccessor().getInformationControlReplacer().install(fProposalTable);
|
|
493
|
|
494 fTimer= new Timer(fProposalTable.getDisplay(), fDelay) {
|
|
495 protected void showInformation(ICompletionProposal proposal, Object info) {
|
|
496 InformationControlReplacer replacer= getInternalAccessor().getInformationControlReplacer();
|
|
497 if (replacer !is null)
|
|
498 replacer.hideInformationControl();
|
|
499 AdditionalInfoController.this.showInformation(proposal, info);
|
|
500 }
|
|
501 };
|
|
502 }
|
|
503
|
|
504 /*
|
|
505 * @see AbstractInformationControlManager#disposeInformationControl()
|
|
506 */
|
|
507 public void disposeInformationControl() {
|
|
508
|
|
509 if (fTimer !is null) {
|
|
510 fTimer.terminate();
|
|
511 fTimer= null;
|
|
512 }
|
|
513
|
|
514 fProposal= null;
|
|
515 fInformation= null;
|
|
516
|
|
517 if (fProposalTable !is null && !fProposalTable.isDisposed()) {
|
|
518 fProposalTable.removeSelectionListener(fSelectionListener);
|
|
519 fProposalTable= null;
|
|
520 }
|
|
521
|
|
522 super.disposeInformationControl();
|
|
523 }
|
|
524
|
|
525 /**
|
|
526 *Handles a change of the line selected in the associated selector.
|
|
527 */
|
|
528 public void handleTableSelectionChanged() {
|
|
529
|
|
530 if (fProposalTable !is null && !fProposalTable.isDisposed() && fProposalTable.isVisible()) {
|
|
531 TableItem[] selection= fProposalTable.getSelection();
|
|
532 if (selection !is null && selection.length > 0) {
|
|
533
|
|
534 TableItem item= selection[0];
|
|
535
|
|
536 Object d= item.getData();
|
|
537 if (d instanceof ICompletionProposal) {
|
|
538 ICompletionProposal p= (ICompletionProposal) d;
|
|
539 fTimer.reset(p);
|
|
540 }
|
|
541 }
|
|
542 }
|
|
543 }
|
|
544
|
|
545 void showInformation(ICompletionProposal proposal, Object info) {
|
|
546 if (fProposalTable is null || fProposalTable.isDisposed())
|
|
547 return;
|
|
548
|
|
549 if (fProposal is proposal && ((info is null && fInformation is null) || (info !is null && info.equals(fInformation))))
|
|
550 return;
|
|
551
|
|
552 fInformation= info;
|
|
553 fProposal= proposal;
|
|
554 showInformation();
|
|
555 }
|
|
556
|
|
557 /*
|
|
558 * @see AbstractInformationControlManager#computeInformation()
|
|
559 */
|
|
560 protected void computeInformation() {
|
|
561 if (fProposal instanceof ICompletionProposalExtension3)
|
|
562 setCustomInformationControlCreator(((ICompletionProposalExtension3) fProposal).getInformationControlCreator());
|
|
563 else
|
|
564 setCustomInformationControlCreator(null);
|
|
565
|
|
566 // compute subject area
|
|
567 Point size= fProposalTable.getShell().getSize();
|
|
568
|
|
569 // set information & subject area
|
|
570 setInformation(fInformation, new Rectangle(0, 0, size.x, size.y));
|
|
571 }
|
|
572
|
|
573 /*
|
|
574 * @see dwtx.jface.text.AbstractInformationControlManager#computeLocation(dwt.graphics.Rectangle, dwt.graphics.Point, dwtx.jface.text.AbstractInformationControlManager.Anchor)
|
|
575 */
|
|
576 protected Point computeLocation(Rectangle subjectArea, Point controlSize, Anchor anchor) {
|
|
577 Point location= super.computeLocation(subjectArea, controlSize, anchor);
|
|
578
|
|
579 /*
|
|
580 * The location is computed using subjectControl.toDisplay(), which does not include the
|
|
581 * trim of the subject control. As we want the additional info popup aligned with the outer
|
|
582 * coordinates of the proposal popup, adjust this here
|
|
583 */
|
|
584 Rectangle trim= fProposalTable.getShell().computeTrim(0, 0, 0, 0);
|
|
585 location.x += trim.x;
|
|
586 location.y += trim.y;
|
|
587
|
|
588 return location;
|
|
589 }
|
|
590
|
|
591 /*
|
|
592 * @see dwtx.jface.text.AbstractInformationControlManager#computeSizeConstraints(Control, IInformationControl)
|
|
593 */
|
|
594 protected Point computeSizeConstraints(Control subjectControl, IInformationControl informationControl) {
|
|
595 // at least as big as the proposal table
|
|
596 Point sizeConstraint= super.computeSizeConstraints(subjectControl, informationControl);
|
|
597 Point size= subjectControl.getShell().getSize();
|
|
598
|
|
599 // AbstractInformationControlManager#internalShowInformationControl(Rectangle, Object) adds trims
|
|
600 // to the computed constraints. Need to remove them here, to make the outer bounds of the additional
|
|
601 // info shell fit the bounds of the proposal shell:
|
|
602 if (fInformationControl instanceof IInformationControlExtension3) {
|
|
603 Rectangle shellTrim= ((IInformationControlExtension3) fInformationControl).computeTrim();
|
|
604 size.x -= shellTrim.width;
|
|
605 size.y -= shellTrim.height;
|
|
606 }
|
|
607
|
|
608 if (sizeConstraint.x < size.x)
|
|
609 sizeConstraint.x= size.x;
|
|
610 if (sizeConstraint.y < size.y)
|
|
611 sizeConstraint.y= size.y;
|
|
612 return sizeConstraint;
|
|
613 }
|
|
614
|
|
615 /*
|
|
616 * @see dwtx.jface.text.AbstractInformationControlManager#hideInformationControl()
|
|
617 */
|
|
618 protected void hideInformationControl() {
|
|
619 super.hideInformationControl();
|
|
620 }
|
|
621
|
|
622 /**
|
|
623 * @return the current information control, or <code>null</code> if none available
|
|
624 */
|
|
625 public IInformationControl getCurrentInformationControl2() {
|
|
626 return getInternalAccessor().getCurrentInformationControl();
|
|
627 }
|
|
628 }
|
|
629
|
|
630
|