|
|
@@ -81,7 +81,7 @@ import com.vaadin.shared.ui.combobox.FilteringMode; |
|
|
|
|
|
|
|
/** |
|
|
|
* Client side implementation of the Select component. |
|
|
|
* |
|
|
|
* |
|
|
|
* TODO needs major refactoring (to be extensible etc) |
|
|
|
*/ |
|
|
|
@SuppressWarnings("deprecation") |
|
|
@@ -101,7 +101,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Constructor |
|
|
|
* |
|
|
|
* |
|
|
|
* @param uidl |
|
|
|
* The UIDL recieved from the server |
|
|
|
*/ |
|
|
@@ -150,7 +150,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Get the option key which represents the item on the server side. |
|
|
|
* |
|
|
|
* |
|
|
|
* @return The key of the item |
|
|
|
*/ |
|
|
|
public String getOptionKey() { |
|
|
@@ -159,7 +159,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Get the URI of the icon. Used when constructing the displayed option. |
|
|
|
* |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public String getIconUri() { |
|
|
@@ -253,7 +253,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Shows the popup where the user can see the filtered options |
|
|
|
* |
|
|
|
* |
|
|
|
* @param currentSuggestions |
|
|
|
* The filtered suggestions |
|
|
|
* @param currentPage |
|
|
@@ -336,7 +336,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Should the next page button be visible to the user? |
|
|
|
* |
|
|
|
* |
|
|
|
* @param active |
|
|
|
*/ |
|
|
|
private void setNextButtonActive(boolean active) { |
|
|
@@ -356,7 +356,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Should the previous page button be visible to the user |
|
|
|
* |
|
|
|
* |
|
|
|
* @param active |
|
|
|
*/ |
|
|
|
private void setPrevButtonActive(boolean active) { |
|
|
@@ -411,7 +411,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Select the first item of the suggestions list popup. |
|
|
|
* |
|
|
|
* |
|
|
|
* @since |
|
|
|
*/ |
|
|
|
public void selectFirstItem() { |
|
|
@@ -421,7 +421,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Select the last item of the suggestions list popup. |
|
|
|
* |
|
|
|
* |
|
|
|
* @since |
|
|
|
*/ |
|
|
|
public void selectLastItem() { |
|
|
@@ -547,7 +547,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
* 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? |
|
|
|
*/ |
|
|
@@ -672,7 +672,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Was the popup just closed? |
|
|
|
* |
|
|
|
* |
|
|
|
* @return true if popup was just closed |
|
|
|
*/ |
|
|
|
public boolean isJustClosed() { |
|
|
@@ -701,7 +701,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Updates style names in suggestion popup to help theme building. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param uidl |
|
|
|
* UIDL for the whole combo box |
|
|
|
* @param componentState |
|
|
@@ -792,7 +792,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Sets the suggestions rendered in the menu |
|
|
|
* |
|
|
|
* |
|
|
|
* @param suggestions |
|
|
|
* The suggestions to be rendered in the menu |
|
|
|
*/ |
|
|
@@ -1039,7 +1039,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
/** |
|
|
|
* TextBox variant used as input element for filter selects, which prevents |
|
|
|
* selecting text when disabled. |
|
|
|
* |
|
|
|
* |
|
|
|
* @since 7.1.5 |
|
|
|
*/ |
|
|
|
public class FilterSelectTextBox extends TextBox { |
|
|
@@ -1291,7 +1291,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
* 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 |
|
|
|
*/ |
|
|
@@ -1304,7 +1304,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
* 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 |
|
|
|
*/ |
|
|
@@ -1332,7 +1332,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Does the Select have more pages? |
|
|
|
* |
|
|
|
* |
|
|
|
* @return true if a next page exists, else false if the current page is the |
|
|
|
* last page |
|
|
|
*/ |
|
|
@@ -1347,7 +1347,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
/** |
|
|
|
* 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 |
|
|
|
*/ |
|
|
@@ -1357,7 +1357,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Filters the options at certain page using the given filter |
|
|
|
* |
|
|
|
* |
|
|
|
* @param page |
|
|
|
* The page to filter |
|
|
|
* @param filter |
|
|
@@ -1369,7 +1369,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Filters the options at certain page using the given filter |
|
|
|
* |
|
|
|
* |
|
|
|
* @param page |
|
|
|
* The page to filter |
|
|
|
* @param filter |
|
|
@@ -1436,7 +1436,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Sets the text in the text box. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param text |
|
|
|
* the text to set in the text box |
|
|
|
*/ |
|
|
@@ -1465,7 +1465,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
* 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. |
|
|
|
*/ |
|
|
@@ -1480,7 +1480,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Triggered when a suggestion is selected |
|
|
|
* |
|
|
|
* |
|
|
|
* @param suggestion |
|
|
|
* The suggestion that just got selected. |
|
|
|
*/ |
|
|
@@ -1523,7 +1523,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
/** |
|
|
|
* 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 |
|
|
|
*/ |
|
|
@@ -1649,7 +1649,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Triggered when a key is pressed in the text box |
|
|
|
* |
|
|
|
* |
|
|
|
* @param event |
|
|
|
* The KeyDownEvent |
|
|
|
*/ |
|
|
@@ -1694,7 +1694,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Triggered when a key was pressed in the suggestion popup. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param event |
|
|
|
* The KeyDownEvent of the key |
|
|
|
*/ |
|
|
@@ -1790,7 +1790,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Triggered when a key was depressed |
|
|
|
* |
|
|
|
* |
|
|
|
* @param event |
|
|
|
* The KeyUpEvent of the key depressed |
|
|
|
*/ |
|
|
@@ -2073,6 +2073,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
public void updateRootWidth() { |
|
|
|
ComponentConnector paintable = ConnectorMap.get(client).getConnector( |
|
|
|
this); |
|
|
|
|
|
|
|
if (paintable.isUndefinedWidth()) { |
|
|
|
|
|
|
|
/* |
|
|
@@ -2097,11 +2098,25 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
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"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
@@ -2119,7 +2134,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
/** |
|
|
|
* 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() { |
|
|
@@ -2136,7 +2151,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, |
|
|
|
|
|
|
|
/** |
|
|
|
* Handles special behavior of the mouse down event |
|
|
|
* |
|
|
|
* |
|
|
|
* @param event |
|
|
|
*/ |
|
|
|
private void handleMouseDownEvent(Event event) { |