diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-04-22 12:44:40 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-04-22 12:44:40 +0300 |
commit | d0d0875430a6d1d57bd2ebb7d4c827c04e1c7731 (patch) | |
tree | 9a9611bbbe5216f2bdb8933d607be12de834a8b8 /client | |
parent | a69660c9d8cb35fc73af09b42df82c7a4a153caa (diff) | |
parent | c0aa2f569663b25681a61319c65d30521b5b8a85 (diff) | |
download | vaadin-framework-d0d0875430a6d1d57bd2ebb7d4c827c04e1c7731.tar.gz vaadin-framework-d0d0875430a6d1d57bd2ebb7d4c827c04e1c7731.zip |
Merge remote-tracking branch 'origin/master' into grid-7.5
Change-Id: I01c7d52b1e80483ec46f87ac8c5d7a48d4c01c84
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/VWindow.java | 16 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/ui/UIConnector.java | 22 | ||||
-rw-r--r-- | client/src/com/vaadin/client/widgets/Escalator.java | 109 | ||||
-rw-r--r-- | client/src/com/vaadin/client/widgets/Grid.java | 6 |
4 files changed, 79 insertions, 74 deletions
diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index 501dedbaa8..d28686e777 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -558,6 +558,21 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, w.bringToFrontSequence = -1; } } + focusTopmostModalWindow(); + } + + private static void focusTopmostModalWindow() { + // If we call focus() directly without scheduling, it does not work in + // IE and FF. + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + @Override + public void execute() { + VWindow topmost = getTopmostWindow(); + if ((topmost != null) && (topmost.vaadinModality)) { + topmost.focus(); + } + } + }); } @Override @@ -690,6 +705,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, while (curIndex < windowOrder.size()) { windowOrder.get(curIndex).setWindowOrder(curIndex++); } + focusTopmostModalWindow(); } private void fixIE8FocusCaptureIssue() { diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index 804ad45f92..e7c252f26a 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -887,6 +887,26 @@ public class UIConnector extends AbstractSingleComponentContainerConnector } + private void updateVaadinFavicon(String newTheme) { + NodeList<Element> iconElements = querySelectorAll("link[rel~=\"icon\"]"); + for (int i = 0; i < iconElements.getLength(); i++) { + Element iconElement = iconElements.getItem(i); + + String href = iconElement.getAttribute("href"); + if (href != null && href.contains("VAADIN/themes") + && href.endsWith("/favicon.ico")) { + href = href.replaceFirst("VAADIN/themes/.+?/favicon.ico", + "VAADIN/themes/" + newTheme + "/favicon.ico"); + iconElement.setAttribute("href", href); + } + } + } + + private static native NodeList<Element> querySelectorAll(String selector) + /*-{ + return $doc.querySelectorAll(selector); + }-*/; + /** * Finds a link tag for a style sheet with the given URL * @@ -979,6 +999,8 @@ public class UIConnector extends AbstractSingleComponentContainerConnector getWidget().getParent().addStyleName(newTheme); VOverlay.getOverlayContainer(getConnection()).addClassName( activeTheme); + + updateVaadinFavicon(newTheme); } forceStateChangeRecursively(UIConnector.this); diff --git a/client/src/com/vaadin/client/widgets/Escalator.java b/client/src/com/vaadin/client/widgets/Escalator.java index cfbbb7dace..17236c5e30 100644 --- a/client/src/com/vaadin/client/widgets/Escalator.java +++ b/client/src/com/vaadin/client/widgets/Escalator.java @@ -2032,8 +2032,9 @@ public class Escalator extends Widget implements RequiresResize, return new Cell(domRowIndex, domColumnIndex, cellElement); } - void createAutoSizeElements(int colIndex, - Collection<TableCellElement> elements) { + double getMaxCellWidth(int colIndex) throws IllegalArgumentException { + double maxCellWidth = -1; + assert isAttached() : "Can't measure max width of cell, since Escalator is not attached to the DOM."; NodeList<TableRowElement> rows = root.getRows(); @@ -2062,9 +2063,24 @@ public class Escalator extends Widget implements RequiresResize, cellClone.getStyle().clearWidth(); rowElement.insertBefore(cellClone, cellOriginal); + double requiredWidth = WidgetUtil + .getRequiredWidthBoundingClientRectDouble(cellClone); + + if (BrowserInfo.get().isIE()) { + /* + * IE browsers have some issues with subpixels. Occasionally + * content is overflown even if not necessary. Increase the + * counted required size by 0.01 just to be on the safe + * side. + */ + requiredWidth += 0.01; + } - elements.add(cellClone); + maxCellWidth = Math.max(requiredWidth, maxCellWidth); + cellClone.removeFromParent(); } + + return maxCellWidth; } private boolean cellIsPartOfSpan(TableCellElement cell) { @@ -3926,8 +3942,7 @@ public class Escalator extends Widget implements RequiresResize, if (px < 0) { if (isAttached()) { - autosizeColumns(Collections.singletonList(columns - .indexOf(this))); + calculateWidth(); } else { /* * the column's width is calculated at Escalator.onLoad @@ -3981,6 +3996,10 @@ public class Escalator extends Widget implements RequiresResize, } return false; } + + private void calculateWidth() { + calculatedWidth = getMaxCellWidth(columns.indexOf(this)); + } } private final List<Column> columns = new ArrayList<Column>(); @@ -4285,7 +4304,6 @@ public class Escalator extends Widget implements RequiresResize, return; } - List<Integer> autosizeColumns = new ArrayList<Integer>(); for (Entry<Integer, Double> entry : indexWidthMap.entrySet()) { int index = entry.getKey().intValue(); double width = entry.getValue().doubleValue(); @@ -4295,14 +4313,9 @@ public class Escalator extends Widget implements RequiresResize, } checkValidColumnIndex(index); - if (width >= 0) { - columns.get(index).setWidth(width); - } else { - autosizeColumns.add(index); - } - } + columns.get(index).setWidth(width); - autosizeColumns(autosizeColumns); + } widthsArray = null; header.reapplyColumnWidths(); @@ -4314,64 +4327,6 @@ public class Escalator extends Widget implements RequiresResize, recalculateElementSizes(); } - private void autosizeColumns(List<Integer> columns) { - if (columns.isEmpty()) { - return; - } - - // Must process columns in index order - Collections.sort(columns); - - Map<Integer, List<TableCellElement>> autoSizeElements = new HashMap<Integer, List<TableCellElement>>(); - try { - // Set up the entire DOM at once - for (int i = columns.size() - 1; i >= 0; i--) { - // Iterate backwards to not mess with the indexing - Integer colIndex = columns.get(i); - - ArrayList<TableCellElement> elements = new ArrayList<TableCellElement>(); - autoSizeElements.put(colIndex, elements); - - header.createAutoSizeElements(colIndex, elements); - body.createAutoSizeElements(colIndex, elements); - footer.createAutoSizeElements(colIndex, elements); - } - - // Extract all measurements & update values - for (Integer colIndex : columns) { - double maxWidth = Double.NEGATIVE_INFINITY; - List<TableCellElement> elements = autoSizeElements - .get(colIndex); - for (TableCellElement element : elements) { - - double cellWidth = WidgetUtil - .getRequiredWidthBoundingClientRectDouble(element); - - maxWidth = Math.max(maxWidth, cellWidth); - } - assert maxWidth >= 0 : "Got a negative max width for a column, which should be impossible."; - - if (BrowserInfo.get().isIE()) { - /* - * IE browsers have some issues with subpixels. - * Occasionally content is overflown even if not - * necessary. Increase the counted required size by 0.01 - * just to be on the safe side. - */ - maxWidth += 0.01; - } - - this.columns.get(colIndex).calculatedWidth = maxWidth; - } - } finally { - for (List<TableCellElement> list : autoSizeElements.values()) { - for (TableCellElement element : list) { - element.removeFromParent(); - } - } - } - } - private void checkValidColumnIndex(int index) throws IllegalArgumentException { if (!Range.withLength(0, getColumnCount()).contains(index)) { @@ -4391,6 +4346,18 @@ public class Escalator extends Widget implements RequiresResize, return columns.get(index).getCalculatedWidth(); } + private double getMaxCellWidth(int colIndex) + throws IllegalArgumentException { + double headerWidth = header.getMaxCellWidth(colIndex); + double bodyWidth = body.getMaxCellWidth(colIndex); + double footerWidth = footer.getMaxCellWidth(colIndex); + + double maxWidth = Math.max(headerWidth, + Math.max(bodyWidth, footerWidth)); + assert maxWidth >= 0 : "Got a negative max width for a column, which should be impossible."; + return maxWidth; + } + /** * Calculates the width of the columns in a given range. * diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index 6717f0c17d..0934d61eeb 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -219,13 +219,13 @@ public class Grid<T> extends ResizeComposite implements * @param <ROWTYPE> * the type of the rows in the section */ - protected abstract static class StaticSection<ROWTYPE extends StaticSection.StaticRow<?>> { + public abstract static class StaticSection<ROWTYPE extends StaticSection.StaticRow<?>> { /** * A header or footer cell. Has a simple textual caption. * */ - static class StaticCell { + public static class StaticCell { private Object content = null; @@ -398,7 +398,7 @@ public class Grid<T> extends ResizeComposite implements * @param <CELLTYPE> * the type of the cells in the row */ - abstract static class StaticRow<CELLTYPE extends StaticCell> { + public abstract static class StaticRow<CELLTYPE extends StaticCell> { private Map<Column<?, ?>, CELLTYPE> cells = new HashMap<Column<?, ?>, CELLTYPE>(); |