diff dwtx/jface/text/contentassist/ContentAssistant.d @ 158:25f1f92fa3df

...
author Frank Benoit <benoit@tionex.de>
date Tue, 26 Aug 2008 02:46:34 +0200
parents f70d9508c95c
children 1a5b8f8129df
line wrap: on
line diff
--- a/dwtx/jface/text/contentassist/ContentAssistant.d	Mon Aug 25 19:06:44 2008 +0200
+++ b/dwtx/jface/text/contentassist/ContentAssistant.d	Tue Aug 26 02:46:34 2008 +0200
@@ -46,13 +46,9 @@
 import dwtx.jface.text.contentassist.IContentAssistantExtension; // packageimport
 import dwtx.jface.text.contentassist.JFaceTextMessages; // packageimport
 
-
 import dwt.dwthelper.utils;
-
 import dwtx.dwtxhelper.Collection;
-
-
-
+import tango.core.Thread;
 
 import dwt.DWT;
 import dwt.DWTError;
@@ -109,22 +105,22 @@
  * instantiate this class and configure it before using it.
  */
 public class ContentAssistant : IContentAssistant, IContentAssistantExtension, IContentAssistantExtension2, IContentAssistantExtension3, IContentAssistantExtension4, IWidgetTokenKeeper, IWidgetTokenKeeperExtension {
-    
-    
-    
+
+
+
     /**
      * Content assist command identifier for 'select next proposal'.
-     * 
+     *
      * @since 3.4
      */
     public static const String SELECT_NEXT_PROPOSAL_COMMAND_ID= "dwtx.ui.edit.text.contentAssist.selectNextProposal"; //$NON-NLS-1$
     /**
      * Content assist command identifier for 'select previous proposal'.
-     * 
+     *
      * @since 3.4
      */
     public static const String SELECT_PREVIOUS_PROPOSAL_COMMAND_ID= "dwtx.ui.edit.text.contentAssist.selectPreviousProposal"; //$NON-NLS-1$
-    
+
 
     /**
      * A generic closer class used to monitor various interface events in order to determine whether
@@ -275,7 +271,7 @@
      * implementation utilizes a thread to watch for input characters matching the activation
      * characters specified by the content assist processor, and if detected, will wait the
      * indicated delay interval before activating the content assistant.
-     * 
+     *
      * @since 3.4 protected, was added in 2.1 as private class
      */
     protected class AutoAssistListener : KeyAdapter , KeyListener, Runnable, VerifyKeyListener {
@@ -293,7 +289,8 @@
 
         protected void start(int showStyle) {
             fShowStyle= showStyle;
-            fThread= new Thread(this, JFaceTextMessages.getString("ContentAssistant.assist_delay_timer_name")); //$NON-NLS-1$
+            fThread= new Thread(&run);
+            fThread.name = JFaceTextMessages.getString("ContentAssistant.assist_delay_timer_name"); //$NON-NLS-1$
             fThread.start();
         }
 
@@ -344,10 +341,10 @@
             // Only act on typed characters and ignore modifier-only events
             if (e.character is 0 && (e.keyCode & DWT.KEYCODE_BIT) is 0)
                 return;
-            
+
             if (e.character !is 0 && (e.stateMask is DWT.ALT))
                 return;
-            
+
             // Only act on characters that are trigger candidates. This
             // avoids computing the model selection on every keystroke
             if (computeAllAutoActivationTriggers().indexOf(e.character) < 0) {
@@ -386,24 +383,24 @@
             keyPressed(event);
         }
 
-        protected void showAssist(final int showStyle) {
+        protected void showAssist(int showStyle) {
             final Control control= fContentAssistSubjectControlAdapter.getControl();
             if (control is null)
                 return;
-            
+
             final Display d= control.getDisplay();
             if (d is null)
                 return;
-            
+
             try {
                 d.syncExec(new class()  Runnable {
                     public void run() {
                         if (isProposalPopupActive())
                             return;
-                        
+
                         if (control.isDisposed() || !control.isFocusControl())
                             return;
-                        
+
                         if (showStyle is SHOW_PROPOSALS) {
                             if (!prepareToShowCompletions(true))
                                 return;
@@ -510,7 +507,7 @@
 
         /**
          * Layouts the popup defined by <code>type</code> at the given widget offset.
-         * 
+         *
          * @param type the kind of popup to layout
          * @param offset the widget offset
          */
@@ -623,7 +620,7 @@
         /**
          * Moves <code>point</code> such that <code>rectangle</code> does not bleed outside of
          * <code>bounds</code>. All coordinates must have the same reference.
-         * 
+         *
          * @param point the point to move if needed
          * @param shellSize the size of the shell that may be moved
          * @param bounds the bounds
@@ -635,10 +632,10 @@
 
             if (point.x < bounds.x)
                 point.x= bounds.x;
-            
+
             if (point.y + shellSize.y > bounds.y + bounds.height)
                 point.y= bounds.y + bounds.height - shellSize.y;
-            
+
             if (point.y < bounds.y)
                 point.y= bounds.y;
         }
@@ -647,20 +644,20 @@
             // clip width
             if (rect.width > bounds.width)
                 rect.width= bounds.width;
-            
+
             if (rect.x + rect.width > bounds.x + bounds.width)
                 rect.x= bounds.x + bounds.width - rect.width;
             if (rect.x < bounds.x)
                 rect.x= bounds.x;
-            
+
             return rect;
         }
-        
+
         /**
          * Returns the display bounds for <code>shell</code> such that it appears right above
          * <code>offset</code>, or below it if above is not suitable. The returned bounds lie
          * within the monitor at the caret location and never overlap with the caret line.
-         * 
+         *
          * @param shell the shell to compute the placement for
          * @param preferred the preferred size for <code>shell</code>
          * @param offset the caret offset in the subject control
@@ -674,7 +671,7 @@
             Monitor monitor= getClosestMonitor(display, caret);
             Rectangle bounds= monitor.getClientArea();
             Geometry.moveInside(caret, bounds);
-            
+
             int spaceAbove= caret.y - bounds.y;
             int caretLowerY= caret.y + caret.height;
             int spaceBelow= bounds.y + bounds.height - caretLowerY;
@@ -688,7 +685,7 @@
                 rect= new Rectangle(caret.x, bounds.y, preferred.x, spaceAbove);
             else
                 rect= new Rectangle(caret.x, caretLowerY, preferred.x, spaceBelow);
-            
+
             return constrainHorizontally(rect, bounds);
         }
 
@@ -696,7 +693,7 @@
          * Returns the display bounds for <code>shell</code> such that it appears right below
          * <code>offset</code>, or above it if below is not suitable. The returned bounds lie
          * within the monitor at the caret location and never overlap with the caret line.
-         * 
+         *
          * @param shell the shell to compute the placement for
          * @param preferred the preferred size for <code>shell</code>
          * @param offset the caret offset in the subject control
@@ -732,10 +729,10 @@
                 rect= new Rectangle(caret.x, bounds.y, preferred.x, spaceAbove);
                 switched= true;
             }
-            
+
             if (popup !is null)
                 popup.switchedPositionToAbove(switched);
-            
+
             return constrainHorizontally(rect, bounds);
         }
 
@@ -748,7 +745,7 @@
             Rectangle subjectRectangle= new Rectangle(location.x, location.y, 1, fContentAssistSubjectControlAdapter.getLineHeight());
             return subjectRectangle;
         }
-        
+
         protected Point getStackedLocation(Shell shell, Shell parent) {
             Point p= parent.getLocation();
             Point size= parent.getSize();
@@ -782,14 +779,14 @@
                     break;
             }
         }
-        
+
         /**
          * Copied from dwtx.jface.window.Window.
          * Returns the monitor whose client area contains the given point. If no
          * monitor contains the point, returns the monitor that is closest to the
          * point. If this is ever made public, it should be moved into a separate
          * utility class.
-         * 
+         *
          * @param toSearch
          *            point to find (display coordinates)
          * @param rectangle
@@ -837,7 +834,7 @@
          * @see VerifyKeyListener#verifyKey(dwt.events.VerifyEvent)
          */
         public void verifyKey(VerifyEvent e) {
-            IContentAssistListener[] listeners= (IContentAssistListener[]) fListeners.clone();
+            IContentAssistListener[] listeners= arraycast!(IContentAssistListener)( fListeners.clone() );
             for (int i= 0; i < listeners.length; i++) {
                 if (listeners[i] !is null) {
                     if (!listeners[i].verifyKey(e) || !e.doit)
@@ -855,7 +852,7 @@
 
             installKeyListener();
 
-            IContentAssistListener[] listeners= (IContentAssistListener[]) fListeners.clone();
+            IContentAssistListener[] listeners= arraycast!(IContentAssistListener)( fListeners.clone() );
             for (int i= 0; i < listeners.length; i++) {
                 if (listeners[i] !is null) {
                     listeners[i].processEvent(event);
@@ -996,7 +993,7 @@
     private bool fIsStatusLineVisible;
     /**
      * The last system time when auto activation performed.
-     * 
+     *
      * @since 3.2
      */
     private long fLastAutoActivation= Long.MIN_VALUE;
@@ -1006,17 +1003,17 @@
      * @since 3.2
      */
     private KeySequence fRepeatedInvocationKeySequence;
-    
+
     /**
      * Maps handler to command identifiers.
-     * 
+     *
      * @since 3.4
      */
     private Map fHandlers;
-    
+
     /**
      * Tells whether colored labels support is enabled.
-     * 
+     *
      * @since 3.4
      */
     private bool fIsColoredLabelsSupportEnabled= false;
@@ -1171,7 +1168,7 @@
 
     /**
      * This method allows subclasses to provide their own {@link AutoAssistListener}.
-     * 
+     *
      * @return a new auto assist listener
      * @since 3.4
      */
@@ -1192,7 +1189,7 @@
     /**
      * Gets the delay after which the content assistant is automatically invoked if the cursor is
      * behind an auto activation character.
-     * 
+     *
      * @return the auto activation delay
      * @since 3.4
      */
@@ -1272,7 +1269,7 @@
 
     /**
      * Returns the foreground of the context information popup.
-     * 
+     *
      *
      * @return the foreground of the context information popup
      * @since 2.0
@@ -1439,7 +1436,7 @@
     public void uninstall() {
         hide();
         manageAutoActivation(false);
-        
+
         if (fHandlers !is null) {
             fHandlers.clear();
             fHandlers= null;
@@ -1488,10 +1485,10 @@
     void layout(int type, int visibleOffset) {
         fLayoutManager.layout(type, visibleOffset);
     }
-    
+
     /**
      * Returns the layout manager.
-     * 
+     *
      * @return the layout manager
      * @since 3.3
      */
@@ -1710,7 +1707,7 @@
     /**
      * Prepares to show content assist proposals. It returns false if auto activation has kicked in
      * recently.
-     * 
+     *
      * @param isAutoActivated  whether completion was triggered by auto activation
      * @return <code>true</code> if the caller should continue and show the proposals,
      *         <code>false</code> otherwise.
@@ -1721,7 +1718,7 @@
         int gracePeriod= Math.max(fAutoActivationDelay, 200);
         if (current < fLastAutoActivation + gracePeriod)
             return false;
-        
+
         promoteKeyListener();
         fireSessionBeginEvent(isAutoActivated);
         return true;
@@ -2197,10 +2194,10 @@
     public void enablePrefixCompletion(bool enabled) {
         fIsPrefixCompletionEnabled= enabled;
     }
-    
+
     /**
      * Returns the prefix completion state.
-     * 
+     *
      * @return <code>true</code> if prefix completion is enabled, <code>false</code> otherwise
      * @since 3.2
      */
@@ -2237,7 +2234,7 @@
 
     /**
      * Fires a session begin event to all registered {@link ICompletionListener}s.
-     * 
+     *
      * @param isAutoActivated  <code>true</code> if this session was triggered by auto activation
      * @since 3.2
      */
@@ -2252,7 +2249,7 @@
             }
         }
     }
-    
+
     /**
      * Fires a session restart event to all registered {@link ICompletionListener}s.
      *
@@ -2406,17 +2403,17 @@
 
     /**
      * Returns the repeated invocation key sequence.
-     * 
+     *
      * @return the repeated invocation key sequence or <code>null</code>, if none
      * @since 3.2
      */
     KeySequence getRepeatedInvocationKeySequence() {
         return fRepeatedInvocationKeySequence;
     }
-    
+
     /**
      * Returns whether proposal popup is active.
-     * 
+     *
      * @return <code>true</code> if the proposal popup is active, <code>false</code> otherwise
      * @since 3.4
      */
@@ -2426,7 +2423,7 @@
 
     /**
      * Returns whether the context information popup is active.
-     * 
+     *
      * @return <code>true</code> if the context information popup is active, <code>false</code> otherwise
      * @since 3.4
      */
@@ -2436,7 +2433,7 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * @since 3.4
      */
     public final IHandler getHandler(String commandId) {
@@ -2446,14 +2443,14 @@
         IHandler handler= cast(IHandler)fHandlers.get(commandId);
         if (handler !is null)
             return handler;
-        
+
         Assert.isLegal(false);
         return null;
     }
 
     /**
      * Registers the given handler under the given command identifier.
-     * 
+     *
      * @param commandId the command identifier
      * @param handler the handler
      * @since 3.4
@@ -2466,7 +2463,7 @@
 
     /**
      * Tells whether the support for colored labels is enabled.
-     * 
+     *
      * @return <code>true</code> if the support for colored labels is enabled, <code>false</code> otherwise
      * @since 3.4
      */
@@ -2478,7 +2475,7 @@
      * Enables the support for colored labels in the proposal popup.
      * <p>Completion proposals can implement {@link ICompletionProposalExtension6}
      * to provide colored proposal labels.</p>
-     * 
+     *
      * @param isEnabled if <code>true</code> the support for colored labels is enabled in the proposal popup
      * @since 3.4
      */