comparison dwtx/jface/internal/text/link/contentassist/ContentAssistant2.d @ 158:25f1f92fa3df

...
author Frank Benoit <benoit@tionex.de>
date Tue, 26 Aug 2008 02:46:34 +0200
parents f70d9508c95c
children 1a5b8f8129df
comparison
equal deleted inserted replaced
157:7f75eaa8103a 158:25f1f92fa3df
20 import dwtx.jface.internal.text.link.contentassist.Helper2; // packageimport 20 import dwtx.jface.internal.text.link.contentassist.Helper2; // packageimport
21 import dwtx.jface.internal.text.link.contentassist.PopupCloser2; // packageimport 21 import dwtx.jface.internal.text.link.contentassist.PopupCloser2; // packageimport
22 import dwtx.jface.internal.text.link.contentassist.IContentAssistListener2; // packageimport 22 import dwtx.jface.internal.text.link.contentassist.IContentAssistListener2; // packageimport
23 import dwtx.jface.internal.text.link.contentassist.AdditionalInfoController2; // packageimport 23 import dwtx.jface.internal.text.link.contentassist.AdditionalInfoController2; // packageimport
24 24
25
26 import dwt.dwthelper.utils; 25 import dwt.dwthelper.utils;
27
28 import dwtx.dwtxhelper.Collection; 26 import dwtx.dwtxhelper.Collection;
29 27 import tango.core.Thread;
30
31
32
33 28
34 import dwt.DWT; 29 import dwt.DWT;
35 import dwt.DWTError; 30 import dwt.DWTError;
36 import dwt.custom.StyledText; 31 import dwt.custom.StyledText;
37 import dwt.custom.VerifyKeyListener; 32 import dwt.custom.VerifyKeyListener;
246 protected this() { 241 protected this() {
247 } 242 }
248 243
249 protected void start(int showStyle) { 244 protected void start(int showStyle) {
250 fShowStyle= showStyle; 245 fShowStyle= showStyle;
251 fThread= new Thread(this, ContentAssistMessages.getString("ContentAssistant.assist_delay_timer_name")); //$NON-NLS-1$ 246 fThread= new Thread(&run);
247 fThread.name = ContentAssistMessages.getString("ContentAssistant.assist_delay_timer_name"); //$NON-NLS-1$
252 fThread.start(); 248 fThread.start();
253 } 249 }
254 250
255 public void run() { 251 public void run() {
256 try { 252 try {
324 reset(showStyle); 320 reset(showStyle);
325 else 321 else
326 start(showStyle); 322 start(showStyle);
327 } 323 }
328 324
329 protected void showAssist(final int showStyle) { 325 protected void showAssist(int showStyle) {
330 Control control= fViewer.getTextWidget(); 326 Control control= fViewer.getTextWidget();
331 Display d= control.getDisplay(); 327 Display d= control.getDisplay();
332 if (d !is null) { 328 if (d !is null) {
333 try { 329 try {
334 d.syncExec(new class() Runnable { 330 d.syncExec(new class() Runnable {
634 * 630 *
635 * @param e the verify event 631 * @param e the verify event
636 * @see VerifyKeyListener#verifyKey(dwt.events.VerifyEvent) 632 * @see VerifyKeyListener#verifyKey(dwt.events.VerifyEvent)
637 */ 633 */
638 public void verifyKey(VerifyEvent e) { 634 public void verifyKey(VerifyEvent e) {
639 IContentAssistListener2[] listeners= (IContentAssistListener2[]) fListeners.clone(); 635 IContentAssistListener2[] listeners= arraycast!(IContentAssistListener2)( fListeners.clone());
640 for (int i= 0; i < listeners.length; i++) { 636 for (int i= 0; i < listeners.length; i++) {
641 if (listeners[i] !is null) { 637 if (listeners[i] !is null) {
642 if (!listeners[i].verifyKey(e) || !e.doit) 638 if (!listeners[i].verifyKey(e) || !e.doit)
643 return; 639 return;
644 } 640 }
650 */ 646 */
651 public void processEvent(VerifyEvent event) { 647 public void processEvent(VerifyEvent event) {
652 648
653 installKeyListener(); 649 installKeyListener();
654 650
655 IContentAssistListener2[] listeners= (IContentAssistListener2[])fListeners.clone(); 651 IContentAssistListener2[] listeners= arraycast!(IContentAssistListener2)(fListeners.clone());
656 for (int i= 0; i < listeners.length; i++) { 652 for (int i= 0; i < listeners.length; i++) {
657 if (listeners[i] !is null) { 653 if (listeners[i] !is null) {
658 listeners[i].processEvent(event); 654 listeners[i].processEvent(event);
659 if (!event.doit) 655 if (!event.doit)
660 return; 656 return;
708 private IContentAssistListener2[] fListeners= new IContentAssistListener2[4]; 704 private IContentAssistListener2[] fListeners= new IContentAssistListener2[4];
709 private int fCompletionPosition; 705 private int fCompletionPosition;
710 private String[] fProposalStrings; 706 private String[] fProposalStrings;
711 private ICompletionProposal[] fProposals; 707 private ICompletionProposal[] fProposals;
712 private const List fProposalListeners= new ArrayList(); 708 private const List fProposalListeners= new ArrayList();
713 709
714 /** 710 /**
715 * Tells whether colored label support is enabled. 711 * Tells whether colored label support is enabled.
716 * @since 3.4 712 * @since 3.4
717 */ 713 */
718 private bool fIsColoredLabelsSupportEnabled= false; 714 private bool fIsColoredLabelsSupportEnabled= false;
719 715
720 716
721 /** 717 /**
722 * Creates a new content assistant. The content assistant is not automatically activated, 718 * Creates a new content assistant. The content assistant is not automatically activated,
723 * overlays the completion proposals with context information list if necessary, and 719 * overlays the completion proposals with context information list if necessary, and
724 * shows the context information above the location at which it was activated. If auto 720 * shows the context information above the location at which it was activated. If auto
1571 * @param listener 1567 * @param listener
1572 */ 1568 */
1573 public void addProposalListener(IProposalListener listener) { 1569 public void addProposalListener(IProposalListener listener) {
1574 fProposalListeners.add(listener); 1570 fProposalListeners.add(listener);
1575 } 1571 }
1576 1572
1577 /** 1573 /**
1578 * Tells whether the support for colored labels is enabled. 1574 * Tells whether the support for colored labels is enabled.
1579 * 1575 *
1580 * @return <code>true</code> if the support for colored labels is enabled, <code>false</code> otherwise 1576 * @return <code>true</code> if the support for colored labels is enabled, <code>false</code> otherwise
1581 * @since 3.4 1577 * @since 3.4
1582 */ 1578 */
1583 bool isColoredLabelsSupportEnabled() { 1579 bool isColoredLabelsSupportEnabled() {
1584 return fIsColoredLabelsSupportEnabled; 1580 return fIsColoredLabelsSupportEnabled;
1586 1582
1587 /** 1583 /**
1588 * Enables the support for colored labels in the proposal popup. 1584 * Enables the support for colored labels in the proposal popup.
1589 * <p>Completion proposals can implement {@link ICompletionProposalExtension6} 1585 * <p>Completion proposals can implement {@link ICompletionProposalExtension6}
1590 * to provide colored proposal labels.</p> 1586 * to provide colored proposal labels.</p>
1591 * 1587 *
1592 * @param isEnabled if <code>true</code> the support for colored labels is enabled in the proposal popup 1588 * @param isEnabled if <code>true</code> the support for colored labels is enabled in the proposal popup
1593 * @since 3.4 1589 * @since 3.4
1594 */ 1590 */
1595 public void enableColoredLabels(bool isEnabled) { 1591 public void enableColoredLabels(bool isEnabled) {
1596 fIsColoredLabelsSupportEnabled= isEnabled; 1592 fIsColoredLabelsSupportEnabled= isEnabled;