diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-05-10 16:53:33 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2013-05-10 16:53:33 +0300 |
commit | 42d94768bfacb3d831e125ae33eeb4b9fa1d8a53 (patch) | |
tree | a09cd9d99d1be99dd6600a90db07fb08d15af28a /client | |
parent | 762c924a8bf05f57b8af7108d7bb6a9c59dcc6c6 (diff) | |
parent | 19e27a15ca765de477fbe929a1cb6a7412c523f7 (diff) | |
download | vaadin-framework-42d94768bfacb3d831e125ae33eeb4b9fa1d8a53.tar.gz vaadin-framework-42d94768bfacb3d831e125ae33eeb4b9fa1d8a53.zip |
Merge changes from origin/7.0
7d9f544 Test for #11396 (merged from 6.8 branch). Depends on a blur event so cannot be autotested with TB.
1b18807 Remove pre-loader element after pre-loading, fixes #10863
ce9c818 Instead of applying workaround to the root panel, apply it to the sub window content element instead to prevent scrolling of the document when a sub window is removed. #11713 (#10776)
3f5d022 Liferay 6.2 compatibility (#11751)
ffd1c1b Don't ignore child component margins in AbstractOrderedLayout (#11553)
62ae5e1 More verbose output from running Jetty
21d9b67 Add a large number of debug calls to VFilterSelect (disabled by default)
bdb7931 Merge test for #11623 to 7.0.
19e27a1 Move suggestion popup width calculation from connector to VFilterSelect
Change-Id: I2d980126599e55fa5e4f6ec523dca16ba54107b5
Diffstat (limited to 'client')
5 files changed, 135 insertions, 45 deletions
diff --git a/client/src/com/vaadin/client/ResourceLoader.java b/client/src/com/vaadin/client/ResourceLoader.java index b3b9ac7256..7fc8b4f9f3 100644 --- a/client/src/com/vaadin/client/ResourceLoader.java +++ b/client/src/com/vaadin/client/ResourceLoader.java @@ -50,8 +50,8 @@ public class ResourceLoader { * Event fired when a resource has been loaded. */ public static class ResourceLoadEvent { - private ResourceLoader loader; - private String resourceUrl; + private final ResourceLoader loader; + private final String resourceUrl; private final boolean preload; /** @@ -286,25 +286,35 @@ public class ResourceLoader { // Inject loader element if this is the first time this is preloaded // AND the resources isn't already being loaded in the normal way - Element element = getPreloadElement(url); + final Element element = getPreloadElement(url); addOnloadHandler(element, new ResourceLoadListener() { @Override public void onLoad(ResourceLoadEvent event) { fireLoad(event); + Document.get().getBody().removeChild(element); } @Override public void onError(ResourceLoadEvent event) { fireError(event); + Document.get().getBody().removeChild(element); } }, event); - // TODO Remove object when loaded (without causing spinner in FF) Document.get().getBody().appendChild(element); } } private static Element getPreloadElement(String url) { + /*- + * TODO + * In Chrome, FF: + * <object> does not fire event if resource is 404 -> eternal spinner. + * <img> always fires onerror -> no way to know if it loaded -> eternal spinner + * <script type="text/javascript> fires, but also executes -> not preloading + * <script type="text/cache"> does not fire events + * XHR not tested - should work, probably causes other issues + -*/ if (BrowserInfo.get().isIE()) { ScriptElement element = Document.get().createScriptElement(); element.setSrc(url); diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java index 5ec7039462..05535686d5 100644 --- a/client/src/com/vaadin/client/ui/VFilterSelect.java +++ b/client/src/com/vaadin/client/ui/VFilterSelect.java @@ -205,6 +205,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, */ SuggestionPopup() { super(true, false, true); + debug("VFS.SP: constructor()"); setOwner(VFilterSelect.this); menu = new SuggestionMenu(); setWidget(menu); @@ -243,6 +244,11 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, 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 @@ -310,6 +316,9 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * @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() @@ -327,6 +336,10 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * @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() @@ -343,6 +356,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * 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) { @@ -362,6 +376,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * 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) { @@ -396,6 +411,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, @Override public void run() { + debug("VFS.SP.LPS: run()"); if (pagesToScroll != 0) { if (!waitingForFilteringResponse) { /* @@ -416,6 +432,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, } public void scrollUp() { + debug("VFS.SP.LPS: scrollUp()"); if (currentPage + pagesToScroll > 0) { pagesToScroll--; cancel(); @@ -424,6 +441,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, } public void scrollDown() { + debug("VFS.SP.LPS: scrollDown()"); if (totalMatches > (currentPage + pagesToScroll + 1) * pageLength) { pagesToScroll++; @@ -443,6 +461,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, @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)) { @@ -476,6 +495,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * Should the paging be turned on? */ public void setPagingEnabled(boolean paging) { + debug("VFS.SP: setPagingEnabled(" + paging + ")"); if (isPagingEnabled == paging) { return; } @@ -501,6 +521,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, @Override public void setPosition(int offsetWidth, int offsetHeight) { + debug("VFS.SP: setPosition()"); int top = -1; int left = -1; @@ -579,6 +600,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * @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); } @@ -593,6 +615,9 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, @Override public void onClose(CloseEvent<PopupPanel> event) { + if (enableDebug) { + debug("VFS.SP: onClose(" + event.isAutoClosed() + ")"); + } if (event.isAutoClosed()) { lastAutoClosed = (new Date()).getTime(); } @@ -608,6 +633,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, */ public void updateStyleNames(UIDL uidl, AbstractComponentState componentState) { + debug("VFS.SP: updateStyleNames()"); setStyleName(VFilterSelect.this.getStylePrimaryName() + "-suggestpopup"); menu.setStyleName(VFilterSelect.this.getStylePrimaryName() @@ -643,6 +669,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, @Override public void execute() { + debug("VFS.SM: delayedImageLoadExecutioner()"); if (suggestionPopup.isVisible() && suggestionPopup.isAttached()) { setWidth(""); @@ -660,6 +687,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, */ SuggestionMenu() { super(true); + debug("VFS.SM: constructor()"); addDomHandler(this, LoadEvent.getType()); } @@ -683,6 +711,9 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, */ 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); @@ -708,6 +739,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * 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) @@ -737,6 +769,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * Triggered after a selection has been made */ public void doPostFilterSelectedItemAction() { + debug("VFS.SM: doPostFilterSelectedItemAction()"); final MenuItem item = getSelectedItem(); final String enteredItemValue = tb.getText(); @@ -833,6 +866,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, @Override public void onLoad(LoadEvent event) { + debug("VFS.SM: onLoad()"); // Handle icon onload events to ensure shadow is resized // correctly delayedImageLoadExecutioner.trigger(); @@ -840,6 +874,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, } public void selectFirstItem() { + debug("VFS.SM: selectFirstItem()"); MenuItem firstItem = getItems().get(0); selectItem(firstItem); } @@ -853,6 +888,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, } public void selectLastItem() { + debug("VFS.SM: selectLastItem()"); List<MenuItem> items = getItems(); MenuItem lastItem = items.get(items.size() - 1); selectItem(lastItem); @@ -1145,6 +1181,10 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * 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, @@ -1171,10 +1211,12 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, /** 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); @@ -1200,6 +1242,9 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * the text to set in the text box */ public void setTextboxText(final String text) { + if (enableDebug) { + debug("VFS: setTextboxText(" + text + ")"); + } tb.setText(text); } @@ -1208,6 +1253,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * in the text box if nothing has been entered. */ public void setPromptingOn() { + debug("VFS: setPromptingOn()"); if (!prompting) { prompting = true; addStyleDependentName(CLASSNAME_PROMPT); @@ -1225,6 +1271,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * The text the text box should contain. */ public void setPromptingOff(String text) { + debug("VFS: setPromptingOff()"); setTextboxText(text); if (prompting) { prompting = false; @@ -1239,6 +1286,10 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * The suggestion that just got selected. */ public void onSuggestionSelected(FilterSelectSuggestion suggestion) { + if (enableDebug) { + debug("VFS: onSuggestionSelected(" + suggestion.caption + ": " + + suggestion.key + ")"); + } updateSelectionWhenReponseIsReceived = false; currentSuggestion = suggestion; @@ -1334,7 +1385,9 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, if (enabled && !readonly) { int keyCode = event.getNativeKeyCode(); - debug("key down: " + keyCode); + if (enableDebug) { + debug("VFS: key down: " + keyCode); + } if (waitingForFilteringResponse && navigationKeyCodes.contains(keyCode)) { /* @@ -1342,18 +1395,25 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * 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); } } @@ -1372,6 +1432,9 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * 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: @@ -1414,6 +1477,9 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * 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()) { @@ -1494,6 +1560,9 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, @Override public void onKeyUp(KeyUpEvent event) { + if (enableDebug) { + debug("VFS: onKeyUp(" + event.getNativeKeyCode() + ")"); + } if (enabled && !readonly) { switch (event.getNativeKeyCode()) { case KeyCodes.KEY_ENTER: @@ -1521,6 +1590,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * Resets the Select to its initial state */ private void reset() { + debug("VFS: reset()"); if (currentSuggestion != null) { String text = currentSuggestion.getReplacementString(); setPromptingOff(text); @@ -1543,6 +1613,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, @Override public void onClick(ClickEvent event) { + debug("VFS: onClick()"); if (textInputEnabled && event.getNativeEvent().getEventTarget().cast() == tb .getElement()) { @@ -1569,6 +1640,29 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, } /** + * Update minimum width for FilterSelect textarea based on input prompt and + * suggestions. + * <p> + * For internal use only. May be removed or replaced in the future. + */ + public void updateSuggestionPopupMinWidth() { + // used only to calculate minimum width + String captions = Util.escapeHTML(inputPrompt); + + for (FilterSelectSuggestion suggestion : currentSuggestions) { + // Collect captions so we can calculate minimum width for + // textarea + if (captions.length() > 0) { + captions += "|"; + } + captions += Util.escapeHTML(suggestion.getReplacementString()); + } + + // Calculate minimum textarea width + suggestionPopupMinWidth = minWidth(captions); + } + + /** * Calculate minimum width for FilterSelect textarea. * <p> * For internal use only. May be removed or replaced in the future. @@ -1610,6 +1704,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, @Override public void onFocus(FocusEvent event) { + debug("VFS: onFocus()"); /* * When we disable a blur event in ie we need to refocus the textfield. @@ -1648,6 +1743,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, @Override public void onBlur(BlurEvent event) { + debug("VFS: onBlur()"); if (BrowserInfo.get().isIE() && preventNextBlurEventInIE) { /* @@ -1708,6 +1804,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, @Override public void focus() { + debug("VFS: focus()"); focused = true; if (prompting && !readonly) { setPromptingOff(""); @@ -1807,6 +1904,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, */ if (BrowserInfo.get().isIE() && focused) { preventNextBlurEventInIE = true; + debug("VFS: Going to prevent next blur event on IE"); } } } diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index 0ed5bd57bd..38dfdba1b8 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -415,14 +415,6 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, @Override public void hide() { - if (vaadinModality) { - hideModalityCurtain(); - } - super.hide(); - - // Remove window from windowOrder to avoid references being left - // hanging. - windowOrder.remove(this); /* * If the window has a RichTextArea and the RTA is focused at the time @@ -439,20 +431,28 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, if (BrowserInfo.get().isIE8()) { fixIE8FocusCaptureIssue(); } + + if (vaadinModality) { + hideModalityCurtain(); + } + super.hide(); + + // Remove window from windowOrder to avoid references being left + // hanging. + windowOrder.remove(this); } private void fixIE8FocusCaptureIssue() { Element e = DOM.createInputText(); Style elemStyle = e.getStyle(); elemStyle.setPosition(Position.ABSOLUTE); - elemStyle.setLeft(-10, Unit.PX); + elemStyle.setTop(-10, Unit.PX); elemStyle.setWidth(0, Unit.PX); elemStyle.setHeight(0, Unit.PX); - Element rootPanel = RootPanel.getBodyElement(); - rootPanel.appendChild(e); + contentPanel.getElement().appendChild(e); e.focus(); - rootPanel.removeChild(e); + contentPanel.getElement().removeChild(e); } /** For internal use only. May be removed or replaced in the future. */ diff --git a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java index 98d2651849..e96d27032b 100644 --- a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java +++ b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java @@ -20,7 +20,6 @@ import java.util.Iterator; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.Paintable; import com.vaadin.client.UIDL; -import com.vaadin.client.Util; import com.vaadin.client.ui.AbstractFieldConnector; import com.vaadin.client.ui.SimpleManagedLayout; import com.vaadin.client.ui.VFilterSelect; @@ -124,9 +123,6 @@ public class ComboBoxConnector extends AbstractFieldConnector implements getWidget().totalMatches = 0; } - // used only to calculate minimum popup width - String captions = Util.escapeHTML(getWidget().inputPrompt); - for (final Iterator<?> i = options.getChildIterator(); i.hasNext();) { final UIDL optionUidl = (UIDL) i.next(); final FilterSelectSuggestion suggestion = getWidget().new FilterSelectSuggestion( @@ -152,12 +148,6 @@ public class ComboBoxConnector extends AbstractFieldConnector implements getWidget().currentSuggestion = suggestion; getWidget().setSelectedItemIcon(suggestion.getIconUri()); } - - // Collect captions so we can calculate minimum width for textarea - if (captions.length() > 0) { - captions += "|"; - } - captions += Util.escapeHTML(suggestion.getReplacementString()); } if ((!getWidget().waitingForFilteringResponse || getWidget().popupOpenerClicked) @@ -222,8 +212,8 @@ public class ComboBoxConnector extends AbstractFieldConnector implements } } - // Calculate minumum textarea width - getWidget().suggestionPopupMinWidth = getWidget().minWidth(captions); + // Calculate minimum textarea width + getWidget().updateSuggestionPopupMinWidth(); getWidget().popupOpenerClicked = false; diff --git a/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java b/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java index d8b0888936..b5a6262693 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java @@ -503,14 +503,10 @@ public class VAbstractOrderedLayout extends FlowPanel { // TODO check caption position if (vertical) { int size = layoutManager.getOuterHeight(slot - .getWidget().getElement()) - - layoutManager.getMarginHeight(slot - .getWidget().getElement()); + .getWidget().getElement()); if (slot.hasCaption()) { size += layoutManager.getOuterHeight(slot - .getCaptionElement()) - - layoutManager.getMarginHeight(slot - .getCaptionElement()); + .getCaptionElement()); } if (size > 0) { totalSize += size; @@ -518,14 +514,10 @@ public class VAbstractOrderedLayout extends FlowPanel { } else { int max = -1; max = layoutManager.getOuterWidth(slot.getWidget() - .getElement()) - - layoutManager.getMarginWidth(slot - .getWidget().getElement()); + .getElement()); if (slot.hasCaption()) { int max2 = layoutManager.getOuterWidth(slot - .getCaptionElement()) - - layoutManager.getMarginWidth(slot - .getCaptionElement()); + .getCaptionElement()); max = Math.max(max, max2); } if (max > 0) { |