*/
SuggestionPopup() {
super(true, false, true);
+ debug("VFS.SP: constructor()");
setOwner(VFilterSelect.this);
menu = new SuggestionMenu();
setWidget(menu);
final Collection<FilterSelectSuggestion> currentSuggestions,
final int currentPage, final int totalSuggestions) {
+ if (enableDebug) {
+ debug("VFS.SP: showSuggestions(" + currentSuggestions + ", "
+ + currentPage + ", " + totalSuggestions + ")");
+ }
+
/*
* We need to defer the opening of the popup so that the parent DOM
* has stabilized so we can calculate an absolute top and left
* @param active
*/
private void setNextButtonActive(boolean active) {
+ if (enableDebug) {
+ debug("VFS.SP: setNextButtonActive(" + active + ")");
+ }
if (active) {
DOM.sinkEvents(down, Event.ONCLICK);
down.setClassName(VFilterSelect.this.getStylePrimaryName()
* @param active
*/
private void setPrevButtonActive(boolean active) {
+ if (enableDebug) {
+ debug("VFS.SP: setPrevButtonActive(" + active + ")");
+ }
+
if (active) {
DOM.sinkEvents(up, Event.ONCLICK);
up.setClassName(VFilterSelect.this.getStylePrimaryName()
* Selects the next item in the filtered selections
*/
public void selectNextItem() {
+ debug("VFS.SP: selectNextItem()");
final MenuItem cur = menu.getSelectedItem();
final int index = 1 + menu.getItems().indexOf(cur);
if (menu.getItems().size() > index) {
* Selects the previous item in the filtered selections
*/
public void selectPrevItem() {
+ debug("VFS.SP: selectPrevItem()");
final MenuItem cur = menu.getSelectedItem();
final int index = -1 + menu.getItems().indexOf(cur);
if (index > -1) {
@Override
public void run() {
+ debug("VFS.SP.LPS: run()");
if (pagesToScroll != 0) {
if (!waitingForFilteringResponse) {
/*
}
public void scrollUp() {
+ debug("VFS.SP.LPS: scrollUp()");
if (currentPage + pagesToScroll > 0) {
pagesToScroll--;
cancel();
}
public void scrollDown() {
+ debug("VFS.SP.LPS: scrollDown()");
if (totalMatches > (currentPage + pagesToScroll + 1)
* pageLength) {
pagesToScroll++;
@Override
public void onBrowserEvent(Event event) {
+ debug("VFS.SP: onBrowserEvent()");
if (event.getTypeInt() == Event.ONCLICK) {
final Element target = DOM.eventGetTarget(event);
if (target == up || target == DOM.getChild(up, 0)) {
* Should the paging be turned on?
*/
public void setPagingEnabled(boolean paging) {
+ debug("VFS.SP: setPagingEnabled(" + paging + ")");
if (isPagingEnabled == paging) {
return;
}
@Override
public void setPosition(int offsetWidth, int offsetHeight) {
+ debug("VFS.SP: setPosition()");
int top = -1;
int left = -1;
* @return true if popup was just closed
*/
public boolean isJustClosed() {
+ debug("VFS.SP: justClosed()");
final long now = (new Date()).getTime();
return (lastAutoClosed > 0 && (now - lastAutoClosed) < 200);
}
@Override
public void onClose(CloseEvent<PopupPanel> event) {
+ if (enableDebug) {
+ debug("VFS.SP: onClose(" + event.isAutoClosed() + ")");
+ }
if (event.isAutoClosed()) {
lastAutoClosed = (new Date()).getTime();
}
*/
public void updateStyleNames(UIDL uidl,
AbstractComponentState componentState) {
+ debug("VFS.SP: updateStyleNames()");
setStyleName(VFilterSelect.this.getStylePrimaryName()
+ "-suggestpopup");
menu.setStyleName(VFilterSelect.this.getStylePrimaryName()
@Override
public void execute() {
+ debug("VFS.SM: delayedImageLoadExecutioner()");
if (suggestionPopup.isVisible()
&& suggestionPopup.isAttached()) {
setWidth("");
*/
SuggestionMenu() {
super(true);
+ debug("VFS.SM: constructor()");
addDomHandler(this, LoadEvent.getType());
}
*/
public void setSuggestions(
Collection<FilterSelectSuggestion> suggestions) {
+ if (enableDebug) {
+ debug("VFS.SM: setSuggestions(" + suggestions + ")");
+ }
// Reset keyboard selection when contents is updated to avoid
// reusing old, invalid data
setKeyboardSelectedItem(null);
* is made or on a blur event.
*/
public void doSelectedItemAction() {
+ debug("VFS.SM: doSelectedItemAction()");
// do not send a value change event if null was and stays selected
final String enteredItemValue = tb.getText();
if (nullSelectionAllowed && "".equals(enteredItemValue)
* Triggered after a selection has been made
*/
public void doPostFilterSelectedItemAction() {
+ debug("VFS.SM: doPostFilterSelectedItemAction()");
final MenuItem item = getSelectedItem();
final String enteredItemValue = tb.getText();
@Override
public void onLoad(LoadEvent event) {
+ debug("VFS.SM: onLoad()");
// Handle icon onload events to ensure shadow is resized
// correctly
delayedImageLoadExecutioner.trigger();
}
public void selectFirstItem() {
+ debug("VFS.SM: selectFirstItem()");
MenuItem firstItem = getItems().get(0);
selectItem(firstItem);
}
}
public void selectLastItem() {
+ debug("VFS.SM: selectLastItem()");
List<MenuItem> items = getItems();
MenuItem lastItem = items.get(items.size() - 1);
selectItem(lastItem);
* Whether to send the options request immediately
*/
private void filterOptions(int page, String filter, boolean immediate) {
+ if (enableDebug) {
+ debug("VFS: filterOptions(" + page + ", " + filter + ", "
+ + immediate + ")");
+ }
if (filter.equals(lastFilter) && currentPage == page) {
if (!suggestionPopup.isAttached()) {
suggestionPopup.showSuggestions(currentSuggestions,
/** For internal use only. May be removed or replaced in the future. */
public void updateReadOnly() {
+ debug("VFS: updateReadOnly()");
tb.setReadOnly(readonly || !textInputEnabled);
}
public void setTextInputEnabled(boolean textInputEnabled) {
+ debug("VFS: setTextInputEnabled()");
// Always update styles as they might have been overwritten
if (textInputEnabled) {
removeStyleDependentName(STYLE_NO_INPUT);
* the text to set in the text box
*/
public void setTextboxText(final String text) {
+ if (enableDebug) {
+ debug("VFS: setTextboxText(" + text + ")");
+ }
tb.setText(text);
}
* in the text box if nothing has been entered.
*/
public void setPromptingOn() {
+ debug("VFS: setPromptingOn()");
if (!prompting) {
prompting = true;
addStyleDependentName(CLASSNAME_PROMPT);
* The text the text box should contain.
*/
public void setPromptingOff(String text) {
+ debug("VFS: setPromptingOff()");
setTextboxText(text);
if (prompting) {
prompting = false;
* The suggestion that just got selected.
*/
public void onSuggestionSelected(FilterSelectSuggestion suggestion) {
+ if (enableDebug) {
+ debug("VFS: onSuggestionSelected(" + suggestion.caption + ": "
+ + suggestion.key + ")");
+ }
updateSelectionWhenReponseIsReceived = false;
currentSuggestion = suggestion;
if (enabled && !readonly) {
int keyCode = event.getNativeKeyCode();
- debug("key down: " + keyCode);
+ if (enableDebug) {
+ debug("VFS: key down: " + keyCode);
+ }
if (waitingForFilteringResponse
&& navigationKeyCodes.contains(keyCode)) {
/*
* waiting for a response. This avoids flickering, disappearing
* items, wrongly interpreted responses and more.
*/
- debug("Ignoring " + keyCode
- + " because we are waiting for a filtering response");
+ if (enableDebug) {
+ debug("Ignoring "
+ + keyCode
+ + " because we are waiting for a filtering response");
+ }
DOM.eventPreventDefault(DOM.eventGetCurrentEvent());
event.stopPropagation();
return;
}
if (suggestionPopup.isAttached()) {
- debug("Keycode " + keyCode + " target is popup");
+ if (enableDebug) {
+ debug("Keycode " + keyCode + " target is popup");
+ }
popupKeyDown(event);
} else {
- debug("Keycode " + keyCode + " target is text field");
+ if (enableDebug) {
+ debug("Keycode " + keyCode + " target is text field");
+ }
inputFieldKeyDown(event);
}
}
* The KeyDownEvent
*/
private void inputFieldKeyDown(KeyDownEvent event) {
+ if (enableDebug) {
+ debug("VFS: inputFieldKeyDown(" + event.getNativeKeyCode() + ")");
+ }
switch (event.getNativeKeyCode()) {
case KeyCodes.KEY_DOWN:
case KeyCodes.KEY_UP:
* The KeyDownEvent of the key
*/
private void popupKeyDown(KeyDownEvent event) {
+ if (enableDebug) {
+ debug("VFS: popupKeyDown(" + event.getNativeKeyCode() + ")");
+ }
// Propagation of handled events is stopped so other handlers such as
// shortcut key handlers do not also handle the same events.
switch (event.getNativeKeyCode()) {
@Override
public void onKeyUp(KeyUpEvent event) {
+ if (enableDebug) {
+ debug("VFS: onKeyUp(" + event.getNativeKeyCode() + ")");
+ }
if (enabled && !readonly) {
switch (event.getNativeKeyCode()) {
case KeyCodes.KEY_ENTER:
* Resets the Select to its initial state
*/
private void reset() {
+ debug("VFS: reset()");
if (currentSuggestion != null) {
String text = currentSuggestion.getReplacementString();
setPromptingOff(text);
@Override
public void onClick(ClickEvent event) {
+ debug("VFS: onClick()");
if (textInputEnabled
&& event.getNativeEvent().getEventTarget().cast() == tb
.getElement()) {
@Override
public void onFocus(FocusEvent event) {
+ debug("VFS: onFocus()");
/*
* When we disable a blur event in ie we need to refocus the textfield.
@Override
public void onBlur(BlurEvent event) {
+ debug("VFS: onBlur()");
if (BrowserInfo.get().isIE() && preventNextBlurEventInIE) {
/*
@Override
public void focus() {
+ debug("VFS: focus()");
focused = true;
if (prompting && !readonly) {
setPromptingOff("");
*/
if (BrowserInfo.get().isIE() && focused) {
preventNextBlurEventInIE = true;
+ debug("VFS: Going to prevent next blur event on IE");
}
}
}