fix completion popup crop to dialog size for single line editors (see copy class...
authorAlexey Pegov <alexey.pegov@jetbrains.com>
Thu, 19 Aug 2010 13:41:45 +0000 (17:41 +0400)
committerAlexey Pegov <alexey.pegov@jetbrains.com>
Thu, 19 Aug 2010 13:41:45 +0000 (17:41 +0400)
platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java
platform/platform-impl/src/com/intellij/ui/LightweightHint.java
platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java

index d53b026b7417772127314681421609343721f988..82fcb38bf007f75acca53fa00f46096e665d0949 100644 (file)
@@ -90,6 +90,12 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
     myFreezeSemaphore = freezeSemaphore;
 
     myLookup = (LookupImpl)LookupManager.getInstance(editor.getProject()).createLookup(editor, LookupElement.EMPTY_ARRAY, "", new CompletionLookupArranger(parameters));
+    if (editor.isOneLineMode()) {
+      myLookup.setForceShowAsPopup(true);
+      myLookup.setCancelOnClickOutside(true);
+      myLookup.setCancelOnOtherWindowOpen(true);
+      myLookup.setResizable(false);
+    }
 
     myLookup.addLookupListener(new LookupAdapter() {
       public void itemSelected(LookupEvent event) {
index 48251f87e99c02d69da5559e49b6e930978726d6..d068c8c3fd2a13027d02c7b2edd59dd888be47cd 100644 (file)
@@ -48,6 +48,9 @@ public class LightweightHint extends UserDataHolderBase implements Hint {
 
   private boolean myForceShowAsPopup = false;
   private String myTitle = null;
+  private boolean myCancelOnClickOutside;
+  private boolean myCancelOnOtherWindowOpen;
+  private boolean myResizable;
 
   public LightweightHint(@NotNull final JComponent component) {
     myComponent = component;
@@ -74,6 +77,18 @@ public class LightweightHint extends UserDataHolderBase implements Hint {
     mySelectingHint = selectingHint;
   }
 
+  public void setCancelOnClickOutside(final boolean b) {
+    myCancelOnClickOutside = b;
+  }
+
+  public void setCancelOnOtherWindowOpen(final boolean b) {
+    myCancelOnOtherWindowOpen = b;
+  }
+
+  public void setResizable(final boolean b) {
+    myResizable = b;
+  }
+
   /**
    * Shows the hint in the layered pane. Coordinates <code>x</code> and <code>y</code>
    * are in <code>parentComponent</code> coordinate system. Note that the component
@@ -105,13 +120,13 @@ public class LightweightHint extends UserDataHolderBase implements Hint {
       myIsRealPopup = true;
       myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(myComponent, null)
         .setRequestFocus(false)
-        .setResizable(myForceShowAsPopup)
-        .setMovable(myForceShowAsPopup)
+        .setResizable(myResizable)
+        .setMovable(myTitle != null)
         .setTitle(myTitle)
         .setShowShadow(false)
         .setCancelKeyEnabled(false)
-        .setCancelOnClickOutside(false)
-        .setCancelOnOtherWindowOpen(false)
+        .setCancelOnClickOutside(myCancelOnClickOutside)
+        .setCancelOnOtherWindowOpen(myCancelOnOtherWindowOpen)
         .createPopup();
 
       beforeShow();
index db179130e98b17ff91d3767ecc8b0d77dc97025f..7fd4950bad6a613a3961c74ac6a9d9db05f8b517 100644 (file)
@@ -197,7 +197,7 @@ public class AbstractPopup implements JBPopup {
     myPopupBorder = PopupBorder.Factory.create(true);
     myShadowed = showShadow;
     myPaintShadow = showShadow && !SystemInfo.isMac && !movable && !resizable && Registry.is("ide.popup.dropShadow");
-    myContent = createContentPanel(resizable, myPopupBorder, isToDrawMacCorner());
+    myContent = createContentPanel(resizable, myPopupBorder, isToDrawMacCorner() && resizable);
     myMayBeParent = mayBeParent;
 
     myContent.add(component, BorderLayout.CENTER);