/**
* Client side implementation of the Select component.
- *
+ *
* TODO needs major refactoring (to be extensible etc)
*/
@SuppressWarnings("deprecation")
/**
* Constructor
- *
+ *
* @param uidl
* The UIDL recieved from the server
*/
/**
* Get the option key which represents the item on the server side.
- *
+ *
* @return The key of the item
*/
public String getOptionKey() {
/**
* Get the URI of the icon. Used when constructing the displayed option.
- *
+ *
* @return
*/
public String getIconUri() {
/**
* Shows the popup where the user can see the filtered options
- *
+ *
* @param currentSuggestions
* The filtered suggestions
* @param currentPage
/**
* Should the next page button be visible to the user?
- *
+ *
* @param active
*/
private void setNextButtonActive(boolean active) {
/**
* Should the previous page button be visible to the user
- *
+ *
* @param active
*/
private void setPrevButtonActive(boolean active) {
* because otherwise the waiting flag will be reset in
* the first response and the second response will be
* ignored, causing an empty popup...
- *
+ *
* As long as the scrolling delay is suitable
* double/triple clicks will work by scrolling two or
* three pages at a time and this should not be a
/*
* (non-Javadoc)
- *
+ *
* @see
* com.google.gwt.user.client.ui.Widget#onBrowserEvent(com.google.gwt
* .user.client.Event)
* amount of items are visible at a time and a scrollbar or buttons are
* visible to change page. If paging is turned of then all options are
* rendered into the popup menu.
- *
+ *
* @param paging
* Should the paging be turned on?
*/
/*
* (non-Javadoc)
- *
+ *
* @see
* com.google.gwt.user.client.ui.PopupPanel$PositionCallback#setPosition
* (int, int)
/**
* Was the popup just closed?
- *
+ *
* @return true if popup was just closed
*/
public boolean isJustClosed() {
/*
* (non-Javadoc)
- *
+ *
* @see
* com.google.gwt.event.logical.shared.CloseHandler#onClose(com.google
* .gwt.event.logical.shared.CloseEvent)
/**
* Updates style names in suggestion popup to help theme building.
- *
+ *
* @param uidl
* UIDL for the whole combo box
* @param componentState
/**
* Sets the suggestions rendered in the menu
- *
+ *
* @param suggestions
* The suggestions to be rendered in the menu
*/
/**
* TextBox variant used as input element for filter selects, which prevents
* selecting text when disabled.
- *
+ *
* @since 7.1.5
*/
public class FilterSelectTextBox extends TextBox {
/*
* (non-Javadoc)
- *
+ *
* @see
* com.google.gwt.user.client.ui.Widget#onBrowserEvent(com.google.gwt
* .user.client.Event)
/*
* (non-Javadoc)
- *
+ *
* @see
* com.google.gwt.user.client.ui.Composite#onBrowserEvent(com.google.gwt
* .user.client.Event)
* It is invoked during the Constructor and should only be overridden if a
* custom TextBox shall be used. The overriding method cannot use any
* instance variables.
- *
+ *
* @since 7.1.5
* @return TextBox instance used by this VFilterSelect
*/
* instance. It is invoked during the Constructor and should only be
* overridden if a custom SuggestionPopup shall be used. The overriding
* method cannot use any instance variables.
- *
+ *
* @since 7.1.5
* @return SuggestionPopup instance used by this VFilterSelect
*/
/**
* Does the Select have more pages?
- *
+ *
* @return true if a next page exists, else false if the current page is the
* last page
*/
/**
* Filters the options at a certain page. Uses the text box input as a
* filter
- *
+ *
* @param page
* The page which items are to be filtered
*/
/**
* Filters the options at certain page using the given filter
- *
+ *
* @param page
* The page to filter
* @param filter
/**
* Filters the options at certain page using the given filter
- *
+ *
* @param page
* The page to filter
* @param filter
/**
* Sets the text in the text box.
- *
+ *
* @param text
* the text to set in the text box
*/
* shown in the text box if nothing has been entered.
* <p>
* For internal use only. May be removed or replaced in the future.
- *
+ *
* @param text
* The text the text box should contain.
*/
/**
* Triggered when a suggestion is selected
- *
+ *
* @param suggestion
* The suggestion that just got selected.
*/
/**
* Sets the icon URI of the selected item. The icon is shown on the left
* side of the item caption text. Set the URI to null to remove the icon.
- *
+ *
* @param iconUri
* The URI of the icon
*/
/*
* (non-Javadoc)
- *
+ *
* @see
* com.google.gwt.event.dom.client.KeyDownHandler#onKeyDown(com.google.gwt
* .event.dom.client.KeyDownEvent)
/**
* Triggered when a key is pressed in the text box
- *
+ *
* @param event
* The KeyDownEvent
*/
/**
* Triggered when a key was pressed in the suggestion popup.
- *
+ *
* @param event
* The KeyDownEvent of the key
*/
/**
* Triggered when a key was depressed
- *
+ *
* @param event
* The KeyUpEvent of the key depressed
*/
/*
* (non-Javadoc)
- *
+ *
* @see
* com.google.gwt.event.dom.client.FocusHandler#onFocus(com.google.gwt.event
* .dom.client.FocusEvent)
/*
* (non-Javadoc)
- *
+ *
* @see
* com.google.gwt.event.dom.client.BlurHandler#onBlur(com.google.gwt.event
* .dom.client.BlurEvent)
/*
* (non-Javadoc)
- *
+ *
* @see com.vaadin.client.Focusable#focus()
*/
* For internal use only. May be removed or replaced in the future.
*/
public void updateRootWidth() {
- updateRootWidth(false);
- }
-
- /**
- * Calculates the width of the select if the select has undefined width.
- * Should be called when the width changes or when the icon changes.
- * <p>
- * For internal use only. May be removed or replaced in the future.
- *
- * @param forceUpdate
- * a flag that forces a recalculation even if one would not
- * normally be done
- */
- public void updateRootWidth(boolean forceUpdate) {
ComponentConnector paintable = ConnectorMap.get(client).getConnector(
this);
+
if (paintable.isUndefinedWidth()) {
/*
*/
int w = Util.getRequiredWidth(this);
- if (forceUpdate || (!initDone || currentPage + 1 < 0)
+ if ((!initDone || currentPage + 1 < 0)
&& suggestionPopupMinWidth > w) {
/*
* We want to compensate for the paddings just to preserve the
String originalBorder = style.getBorderWidth();
style.setPaddingLeft(0, Unit.PX);
style.setBorderWidth(0, Unit.PX);
- int offset = w - Util.getRequiredWidth(this);
style.setProperty("padding", originalPadding);
style.setProperty("borderWidth", originalBorder);
- setWidth(suggestionPopupMinWidth + offset + "px");
+ // Use util.getRequiredWidth instead of getOffsetWidth here
+
+ int iconWidth = selectedItemIcon == null ? 0 : Util
+ .getRequiredWidth(selectedItemIcon);
+ int buttonWidth = popupOpener == null ? 0 : Util
+ .getRequiredWidth(popupOpener);
+
+ /*
+ * Instead of setting the width of the wrapper, set the width of
+ * the combobox. Subtract the width of the icon and the
+ * popupopener
+ */
+
+ tb.setWidth((suggestionPopupMinWidth - iconWidth - buttonWidth)
+ + "px");
+
}
/*
/**
* Get the width of the select in pixels where the text area and icon has
* been included.
- *
+ *
* @return The width in pixels
*/
private int getMainWidth() {
/**
* Handles special behavior of the mouse down event
- *
+ *
* @param event
*/
private void handleMouseDownEvent(Event event) {
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.Paintable;
import com.vaadin.client.UIDL;
-import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractFieldConnector;
import com.vaadin.client.ui.SimpleManagedLayout;
import com.vaadin.client.ui.VFilterSelect;
// update textbox text by a changed item caption.
private boolean oldSuggestionTextMatchTheOldSelection;
- // Need to recompute the width of the combobox when styles change, see
- // #13444
- private boolean stylesChanged;
-
/*
* (non-Javadoc)
*
getWidget().popupOpenerClicked = false;
/*
- * if styles have changed or this is our first time we need to
- * recalculate the root width.
+ * if this is our first time we need to recalculate the root width.
*/
if (!getWidget().initDone) {
- // no need to force update since we have no existing width
- getWidget().updateRootWidth(false);
- } else if (stylesChanged) {
- // we have previously calculated a width, we must force an update
- // due to changed styles
- getWidget().updateRootWidth(true);
+
+ getWidget().updateRootWidth();
}
// Focus dependent style names are lost during the update, so we add
getWidget().addStyleDependentName("focus");
}
- // width has been recalculated above, clear style change flag
- stylesChanged = false;
-
getWidget().initDone = true;
}
getWidget().tb.setEnabled(widgetEnabled);
}
- @Override
- public void onStateChanged(StateChangeEvent event) {
- super.onStateChanged(event);
- if (event.hasPropertyChanged("styles")) {
- stylesChanged = true;
- }
- }
-
}