diff dwtx/jface/internal/text/link/contentassist/ContentAssistant2.d @ 168:cef27f663573

jface.text ...
author Frank Benoit <benoit@tionex.de>
date Tue, 09 Sep 2008 17:44:11 +0200
parents 862b05e0334a
children c3583c6ec027
line wrap: on
line diff
--- a/dwtx/jface/internal/text/link/contentassist/ContentAssistant2.d	Tue Sep 09 15:59:16 2008 +0200
+++ b/dwtx/jface/internal/text/link/contentassist/ContentAssistant2.d	Tue Sep 09 17:44:11 2008 +0200
@@ -25,6 +25,8 @@
 import dwt.dwthelper.utils;
 import dwtx.dwtxhelper.Collection;
 import dwtx.dwtxhelper.JThread;
+import tango.core.sync.Mutex;
+import tango.core.sync.Condition;
 
 import dwt.DWT;
 import dwt.DWTError;
@@ -232,28 +234,31 @@
 
         private JThread fThread;
         private bool fIsReset= false;
-        private Object fMutex= new Object();
+        private Mutex     fMutex;
+        private Condition fMutex_cond;
         private int fShowStyle;
 
         private const static int SHOW_PROPOSALS= 1;
         private const static int SHOW_CONTEXT_INFO= 2;
 
         protected this() {
+            fMutex = new Mutex();
+            fMutex_cond = new Condition(fMutex);
         }
 
         protected void start(int showStyle) {
             fShowStyle= showStyle;
-            fThread= new Thread(&run);
-            fThread.name = ContentAssistMessages.getString("ContentAssistant.assist_delay_timer_name"); //$NON-NLS-1$
+            fThread= new JThread(this);
+            fThread.setName( ContentAssistMessages.getString("ContentAssistant.assist_delay_timer_name")); //$NON-NLS-1$
             fThread.start();
         }
 
-        public void run() {
+        public override void run() {
             try {
                 while (true) {
                     synchronized (fMutex) {
                         if (fAutoActivationDelay !is 0)
-                            fMutex.wait(fAutoActivationDelay);
+                            fMutex_cond.wait(fAutoActivationDelay);
                         if (fIsReset) {
                             fIsReset= false;
                             continue;
@@ -271,12 +276,12 @@
             synchronized (fMutex) {
                 fShowStyle= showStyle;
                 fIsReset= true;
-                fMutex.notifyAll();
+                fMutex_cond.notifyAll();
             }
         }
 
         protected void stop() {
-            Thread threadToStop= fThread;
+            JThread threadToStop= fThread;
             if (threadToStop !is null)
                 threadToStop.interrupt();
         }
@@ -357,8 +362,13 @@
         public const static int LAYOUT_CONTEXT_INFO_POPUP= 2;
 
         int fContextType= LAYOUT_CONTEXT_SELECTOR;
-        Shell[] fShells= new Shell[3];
-        Object[] fPopups= new Object[3];
+        Shell[] fShells;
+        Object[] fPopups;
+
+        this(){
+            fShells= new Shell[3];
+            fPopups= new Object[3];
+        }
 
         protected void add(Object popup, Shell shell, int type, int offset) {
             Assert.isNotNull(popup);
@@ -632,7 +642,7 @@
          * @see VerifyKeyListener#verifyKey(dwt.events.VerifyEvent)
          */
         public void verifyKey(VerifyEvent e) {
-            IContentAssistListener2[] listeners= arraycast!(IContentAssistListener2)( fListeners.clone());
+            IContentAssistListener2[] listeners= arraycast!(IContentAssistListener2)( fListeners.dup );
             for (int i= 0; i < listeners.length; i++) {
                 if (listeners[i] !is null) {
                     if (!listeners[i].verifyKey(e) || !e.doit)
@@ -648,7 +658,7 @@
 
             installKeyListener();
 
-            IContentAssistListener2[] listeners= arraycast!(IContentAssistListener2)(fListeners.clone());
+            IContentAssistListener2[] listeners= arraycast!(IContentAssistListener2)( fListeners.dup );
             for (int i= 0; i < listeners.length; i++) {
                 if (listeners[i] !is null) {
                     listeners[i].processEvent(event);
@@ -661,9 +671,9 @@
 
 
     // Content-Assist Listener types
-    final static int CONTEXT_SELECTOR= 0;
-    final static int PROPOSAL_SELECTOR= 1;
-    final static int CONTEXT_INFO_POPUP= 2;
+    const static int CONTEXT_SELECTOR= 0;
+    const static int PROPOSAL_SELECTOR= 1;
+    const static int CONTEXT_INFO_POPUP= 2;
 
     /**
      * The popup priority: &gt; info pop-ups, &lt; standard content assist.
@@ -701,11 +711,11 @@
     private ContextInformationPopup2 fContextInfoPopup;
 
     private bool fKeyListenerHooked= false;
-    private IContentAssistListener2[] fListeners= new IContentAssistListener2[4];
+    private IContentAssistListener2[] fListeners;
     private int fCompletionPosition;
     private String[] fProposalStrings;
     private ICompletionProposal[] fProposals;
-    private const List fProposalListeners= new ArrayList();
+    private const List fProposalListeners;
 
     /**
      * Tells whether colored label support is enabled.
@@ -722,6 +732,9 @@
      * is activated after a 500 ms delay. It uses the default partitioning.
      */
     public this() {
+        fListeners= new IContentAssistListener2[4];
+        fProposalListeners= new ArrayList();
+
         setContextInformationPopupOrientation(CONTEXT_INFO_ABOVE);
         setInformationControlCreator(getInformationControlCreator());
 
@@ -786,7 +799,7 @@
         if (processor is null)
             fProcessors.remove(contentType);
         else
-            fProcessors.put(contentType, processor);
+            fProcessors.put(contentType, cast(Object)processor);
     }
 
     /*
@@ -1014,7 +1027,7 @@
      * @see IContentAssist#install
      */
     public void install(ITextViewer textViewer) {
-        Assert.isNotNull(textViewer);
+        Assert.isNotNull(cast(Object)textViewer);
 
         fViewer= textViewer;
 
@@ -1026,7 +1039,7 @@
             int delay= fAutoActivationDelay;
             if (delay is 0)
                 delay= DEFAULT_AUTO_ACTIVATION_DELAY;
-            delay= Math.round(delay * 1.5f);
+            delay= cast(int)Math.round(delay * 1.5f);
             controller= new AdditionalInfoController2(fInformationControlCreator, delay);
         }
         fContextInfoPopup= new ContextInformationPopup2(this, fViewer);
@@ -1568,14 +1581,14 @@
      * @param listener
      */
     public void removeProposalListener(IProposalListener listener) {
-        fProposalListeners.remove(listener);
+        fProposalListeners.remove(cast(Object)listener);
     }
 
     /**
      * @param listener
      */
     public void addProposalListener(IProposalListener listener) {
-        fProposalListeners.add(listener);
+        fProposalListeners.add(cast(Object)listener);
     }
 
     /**