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

...
author Frank Benoit <benoit@tionex.de>
date Tue, 26 Aug 2008 02:46:34 +0200
parents f70d9508c95c
children 3678e4f1a766
line wrap: on
line diff
--- a/dwtx/jface/text/contentassist/ContextInformationPopup.d	Mon Aug 25 19:06:44 2008 +0200
+++ b/dwtx/jface/text/contentassist/ContextInformationPopup.d	Tue Aug 26 02:46:34 2008 +0200
@@ -72,25 +72,6 @@
 import dwtx.jface.text.ITextViewer;
 import dwtx.jface.text.TextPresentation;
 
-
-/**
- * This class is used to present context information to the user.
- * If multiple contexts are valid at the current cursor location,
- * a list is presented from which the user may choose one context.
- * Once the user makes their choice, or if there was only a single
- * possible context, the context information is shown in a tool tip like popup. <p>
- * If the tool tip is visible and the user wants to see context information of
- * a context embedded into the one for which context information is displayed,
- * context information for the embedded context is shown. As soon as the
- * cursor leaves the embedded context area, the context information for
- * the embedding context is shown again.
- *
- * @see IContextInformation
- * @see IContextInformationValidator
- */
-class ContextInformationPopup : IContentAssistListener {
-
-
     /**
      * Represents the state necessary for embedding contexts.
      *
@@ -138,6 +119,26 @@
         }
     }
 
+    alias ContextFrame ContextInformationPopup_ContextFrame;
+/**
+ * This class is used to present context information to the user.
+ * If multiple contexts are valid at the current cursor location,
+ * a list is presented from which the user may choose one context.
+ * Once the user makes their choice, or if there was only a single
+ * possible context, the context information is shown in a tool tip like popup. <p>
+ * If the tool tip is visible and the user wants to see context information of
+ * a context embedded into the one for which context information is displayed,
+ * context information for the embedded context is shown. As soon as the
+ * cursor leaves the embedded context area, the context information for
+ * the embedding context is shown again.
+ *
+ * @see IContextInformation
+ * @see IContextInformationValidator
+ */
+class ContextInformationPopup : IContentAssistListener {
+
+
+
     private ITextViewer fViewer;
     private ContentAssistant fContentAssistant;
 
@@ -212,66 +213,63 @@
      * @param autoActivated <code>true</code>  if auto activated
      * @return  a potential error message or <code>null</code> in case of no error
      */
-    public String showContextProposals(final bool autoActivated) {
+    public String showContextProposals(bool autoActivated) {
         final Control control= fContentAssistSubjectControlAdapter.getControl();
-        BusyIndicator.showWhile(control.getDisplay(), new class()  Runnable {
-            public void run() {
+        BusyIndicator.showWhile(control.getDisplay(), dgRunnable( {
+            int offset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
 
-                int offset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
+            IContextInformation[] contexts= computeContextInformation(offset);
+            int count = (contexts is null ? 0 : contexts.length);
+            if (count is 1) {
 
-                IContextInformation[] contexts= computeContextInformation(offset);
-                int count = (contexts is null ? 0 : contexts.length);
-                if (count is 1) {
+                ContextFrame frame= createContextFrame(contexts[0], offset);
+                if (isDuplicate(frame))
+                    validateContextInformation();
+                else
+                    // Show context information directly
+                    internalShowContextInfo(frame);
+
+            } else if (count > 0) {
 
-                    ContextFrame frame= createContextFrame(contexts[0], offset);
-                    if (isDuplicate(frame))
+                // if any of the proposed context matches any of the contexts on the stack,
+                // assume that one (so, if context info is invoked repeatedly, the current
+                // info is kept)
+                for (int i= 0; i < contexts.length; i++) {
+                    IContextInformation info= contexts[i];
+                    ContextFrame frame= createContextFrame(info, offset);
+
+                    // check top of stack and stored context
+                    if (isDuplicate(frame)) {
                         validateContextInformation();
-                    else
-                        // Show context information directly
-                        internalShowContextInfo(frame);
-
-                } else if (count > 0) {
+                        return;
+                    }
 
-                    // if any of the proposed context matches any of the contexts on the stack,
-                    // assume that one (so, if context info is invoked repeatedly, the current
-                    // info is kept)
-                    for (int i= 0; i < contexts.length; i++) {
-                        IContextInformation info= contexts[i];
-                        ContextFrame frame= createContextFrame(info, offset);
+                    if (isLastFrame(frame)) {
+                        internalShowContextInfo(frame);
+                        return;
+                    }
 
-                        // check top of stack and stored context
-                        if (isDuplicate(frame)) {
+                    // also check all other contexts
+                    for (Iterator it= fContextFrameStack.iterator(); it.hasNext(); ) {
+                        ContextFrame stackFrame= cast(ContextFrame) it.next();
+                        if (stackFrame.equals(frame)) {
                             validateContextInformation();
                             return;
                         }
+                    }
+                }
 
-                        if (isLastFrame(frame)) {
-                            internalShowContextInfo(frame);
-                            return;
-                        }
+                // otherwise:
+                // Precise context must be selected
 
-                        // also check all other contexts
-                        for (Iterator it= fContextFrameStack.iterator(); it.hasNext(); ) {
-                            ContextFrame stackFrame= cast(ContextFrame) it.next();
-                            if (stackFrame.equals(frame)) {
-                                validateContextInformation();
-                                return;
-                            }
-                        }
-                    }
+                if (fLineDelimiter is null)
+                    fLineDelimiter= fContentAssistSubjectControlAdapter.getLineDelimiter();
 
-                    // otherwise:
-                    // Precise context must be selected
-
-                    if (fLineDelimiter is null)
-                        fLineDelimiter= fContentAssistSubjectControlAdapter.getLineDelimiter();
-
-                    createContextSelector();
-                    setContexts(contexts);
-                    displayContextSelector();
-                }
+                createContextSelector();
+                setContexts(contexts);
+                displayContextSelector();
             }
-        });
+        }));
 
         return getErrorMessage();
     }
@@ -283,22 +281,20 @@
      * @param offset the offset
      * @since 2.0
      */
-    public void showContextInformation(final IContextInformation info, final int offset) {
+    public void showContextInformation(IContextInformation info, int offset) {
         Control control= fContentAssistSubjectControlAdapter.getControl();
-        BusyIndicator.showWhile(control.getDisplay(), new class()  Runnable {
-            public void run() {
-                if (info is null)
+        BusyIndicator.showWhile(control.getDisplay(), dgRunnable( {
+            if (info_ is null)
+                validateContextInformation();
+            else {
+                ContextFrame frame= createContextFrame(info_, offset_);
+                if (isDuplicate(frame))
                     validateContextInformation();
-                else {
-                    ContextFrame frame= createContextFrame(info, offset);
-                    if (isDuplicate(frame))
-                        validateContextInformation();
-                    else
-                        internalShowContextInfo(frame);
-                    hideContextSelector();
-                }
+                else
+                    internalShowContextInfo(frame);
+                hideContextSelector();
             }
-        });
+        }, info, offset ));
     }
 
     /**
@@ -476,7 +472,7 @@
         if (bounds.width < size.x)
             // we don't fit on the screen - try again and wrap
             size= fContextInfoText.computeSize(bounds.width - PAD, DWT.DEFAULT, true);
-        
+
         size.x += TEXT_PAD;
         fContextInfoText.setSize(size);
         fContextInfoText.setLocation(1,1);
@@ -579,7 +575,7 @@
     /**
      * Returns the minimal required height for the popup, may return 0 if the popup has not been
      * created yet.
-     * 
+     *
      * @return the minimal height
      * @since 3.3
      */