Browse Source

Fix for #2974

svn changeset:13959/svn branch:6.4
tags/6.7.0.beta1
John Alhroos 14 years ago
parent
commit
2056d9d955
1 changed files with 43 additions and 4 deletions
  1. 43
    4
      src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java

+ 43
- 4
src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java View File

private int textboxPadding = -1; private int textboxPadding = -1;
private int componentPadding = -1; private int componentPadding = -1;
private int suggestionPopupMinWidth = 0; private int suggestionPopupMinWidth = 0;
private int popupWidth = -1;
/* /*
* Stores the last new item string to avoid double submissions. Cleared on * Stores the last new item string to avoid double submissions. Cleared on
* uidl updates * uidl updates


popupOpenerClicked = false; popupOpenerClicked = false;


updateRootWidth();
if (!initDone) {
updateRootWidth();
}


initDone = true; initDone = true;
} }


/*
* (non-Javadoc)
*
* @see com.google.gwt.user.client.ui.Composite#onAttach()
*/
@Override
protected void onAttach() {
super.onAttach();

/*
* We need to recalculate the root width when the select is attached, so
* #2974 won't happen.
*/
updateRootWidth();
}

/** /**
* Turns prompting on. When prompting is turned on a command prompt is shown * Turns prompting on. When prompting is turned on a command prompt is shown
* in the text box if nothing has been entered. * in the text box if nothing has been entered.
* the size of the combobox won't change over time. * the size of the combobox won't change over time.
*/ */
int tbWidth = Util.getRequiredWidth(tb); int tbWidth = Util.getRequiredWidth(tb);
int openerWidth = Util.getRequiredWidth(popupOpener);

if (popupWidth < 0) {
/*
* Only use the first page popup width so the textbox will not
* get resized whenever the popup is resized.
*/
popupWidth = Util.getRequiredWidth(popupOpener);
}

/*
* Note: iconWidth is here calculated as a negative pixel value so
* you should consider this in further calculations.
*/
int iconWidth = selectedItemIcon.isAttached() ? Util int iconWidth = selectedItemIcon.isAttached() ? Util
.measureMarginLeft(tb.getElement()) .measureMarginLeft(tb.getElement())
- Util.measureMarginLeft(selectedItemIcon.getElement()) : 0; - Util.measureMarginLeft(selectedItemIcon.getElement()) : 0;


int w = tbWidth + openerWidth + iconWidth;
if ((!initDone || currentPage + 1 <= 0)
int w = tbWidth + popupWidth + iconWidth;

/*
* When the select has a undefined with we need to check that we are
* only setting the text box width relative to the first page width
* of the items. If this is not done the text box width will change
* when the popup is used to view longer items than the text box is
* wide.
*/
if ((!initDone || currentPage + 1 < 0)
&& suggestionPopupMinWidth > w) { && suggestionPopupMinWidth > w) {
setTextboxWidth(suggestionPopupMinWidth); setTextboxWidth(suggestionPopupMinWidth);
w = suggestionPopupMinWidth; w = suggestionPopupMinWidth;

Loading…
Cancel
Save