]> source.dussan.org Git - vaadin-framework.git/commitdiff
select: stretch option popup to be width of textfield (minimum)
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 1 Nov 2007 13:21:49 +0000 (13:21 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 1 Nov 2007 13:21:49 +0000 (13:21 +0000)
svn changeset:2656/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java

index de78951986fbc48d0995bfe56c34e5d30ae40cc7..bb41130a1b18d31bf43517f0b6f95493fdab3eda 100644 (file)
@@ -27,8 +27,7 @@ import com.itmill.toolkit.terminal.gwt.client.Util;
 
 /**
  * 
- * TODO needs major refactoring to be easily expandable TODO add new items TODO
- * null selections
+ * TODO needs major refactoring (to be extensible etc)
  */
 public class IFilterSelect extends Composite implements Paintable,
                KeyboardListener, ClickListener {
@@ -215,10 +214,18 @@ public class IFilterSelect extends Composite implements Paintable,
                        menu.setHeight("");
                        menu.setWidth("");
                        offsetHeight = getOffsetHeight();
+                       
+                       offsetWidth = getOffsetWidth();
+                       int desiredWidth = IFilterSelect.this.getOffsetWidth() - popupOpener.getOffsetWidth();
+                       if(offsetWidth < desiredWidth) {
+                               menu.setWidth(desiredWidth + "px");
+                       }
+                       
                        if (!isPagingEnabled && offsetHeight > Window.getClientHeight()) {
                                offsetHeight = Window.getClientHeight();
                                menu.setHeight((offsetHeight - EXTRASPACE) + "px");
                                DOM.setStyleAttribute(menu.getElement(), "overflow", "auto");
+
                                // add scrollbar width
                                menu
                                                .setWidth((menu.getOffsetWidth() * 2 - DOM
@@ -265,6 +272,15 @@ public class IFilterSelect extends Composite implements Paintable,
                        }
                        suggestionPopup.hide();
                }
+               
+               public void setWidth(String width) {
+                       super.setWidth(width);
+                       if(!width.equals("") || width != null) {
+                               DOM.setStyleAttribute(DOM.getFirstChild(getElement()), "width", "100%");
+                       } else {
+                               DOM.setStyleAttribute(DOM.getFirstChild(getElement()), "width", "");
+                       }
+               }
        }
 
        public static final int FILTERINGMODE_OFF = 0;