-moz-box-sizing: border-box;
box-sizing: border-box;
overflow:hidden;
+
+ /*
+ * Because Vaadin changes the font size after the initial render, we
+ * need to mention the font size here explicitly, otherwise automatic
+ * row height detection gets broken.
+ */
+ font-size: $font-size;
}
.#{$primaryStyleName}-cell.frozen {
z-index: 0;
}
-}
\ No newline at end of file
+}
.popup-style .v-datefield-calendarpanel-body {
background: yellow;
}
+
+#escalator .v-escalator-body .v-escalator-cell {
+ height: 50px;
+}
\ No newline at end of file
import com.google.gwt.animation.client.AnimationScheduler.AnimationHandle;
import com.google.gwt.core.client.Duration;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
private abstract class AbstractRowContainer implements RowContainer {
- private static final int INITIAL_DEFAULT_ROW_HEIGHT = 20;
-
private EscalatorUpdater updater = EscalatorUpdater.NULL;
private int rows;
@Deprecated
private final Map<Element, Integer> rowTopPositionMap = new HashMap<Element, Integer>();
+ private boolean defaultRowHeightShouldBeAutodetected = true;
+
private int defaultRowHeight = INITIAL_DEFAULT_ROW_HEIGHT;
public AbstractRowContainer(final Element rowContainerElement) {
+ px + " was given.");
}
+ defaultRowHeightShouldBeAutodetected = false;
defaultRowHeight = px;
reapplyDefaultRowHeights();
}
protected void removeRowPosition(Element tr) {
rowTopPositionMap.remove(tr);
}
+
+ public void autodetectRowHeight() {
+ Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
+
+ @Override
+ public void execute() {
+ if (defaultRowHeightShouldBeAutodetected && isAttached()) {
+ final Element detectionTr = DOM.createTR();
+ detectionTr
+ .setClassName(getStylePrimaryName() + "-row");
+
+ final Element cellElem = DOM
+ .createElement(getCellElementTagName());
+ cellElem.setClassName(getStylePrimaryName() + "-cell");
+ cellElem.setInnerHTML("foo");
+
+ detectionTr.appendChild(cellElem);
+ root.appendChild(detectionTr);
+ defaultRowHeight = Math.max(1,
+ cellElem.getOffsetHeight());
+ root.removeChild(detectionTr);
+
+ if (root.hasChildNodes()) {
+ reapplyDefaultRowHeights();
+ }
+
+ defaultRowHeightShouldBeAutodetected = false;
+ }
+ }
+ });
+ }
}
private abstract class AbstractStaticRowContainer extends
protected void onLoad() {
super.onLoad();
+ header.autodetectRowHeight();
+ body.autodetectRowHeight();
+ footer.autodetectRowHeight();
+
header.paintInsertRows(0, header.getRowCount());
footer.paintInsertRows(0, footer.getRowCount());
recalculateElementSizes();
* @see Escalator#getFooter()
*/
public interface RowContainer {
+
+ /**
+ * An arbitrary pixel height of a row, before any autodetection for the row
+ * height has been made.
+ * */
+ public static final int INITIAL_DEFAULT_ROW_HEIGHT = 20;
+
/**
* Returns the current {@link EscalatorUpdater} used to render cells.
*
* the default height in pixels of the rows in this RowContainer
* @throws IllegalArgumentException
* if <code>px < 1</code>
+ * @see #getDefaultRowHeight()
*/
public void setDefaultRowHeight(int px) throws IllegalArgumentException;
/**
* Returns the default height of the rows in this RowContainer.
+ * <p>
+ * This value will be equal to {@link #INITIAL_DEFAULT_ROW_HEIGHT} if the
+ * {@link Escalator} has not yet had a chance to autodetect the row height,
+ * or no explicit value has yet given via {@link #setDefaultRowHeight(int)}
*
* @return the default height of the rows in this RowContainer, in pixels
+ * @see #setDefaultRowHeight(int)
*/
public int getDefaultRowHeight();
}
--- /dev/null
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.grid;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class BasicEscalatorTest extends MultiBrowserTest {
+
+ @Test
+ public void testNormalHeight() throws Exception {
+ openTestURL();
+ compareScreen("normalHeight");
+ }
+
+ @Test
+ public void testModifiedHeight() throws Exception {
+ openTestURLWithTheme("reindeer-tests");
+ compareScreen("modifiedHeight");
+ }
+
+ private WebElement getFirstBodyRowCell() {
+ return getDriver().findElement(
+ By.xpath("//tbody/tr[@class='v-escalator-row'][1]/td[1]"));
+ }
+
+ private void openTestURLWithTheme(String themeName) {
+ String testUrl = getTestUrl();
+ testUrl += (testUrl.contains("?")) ? "&" : "?";
+ testUrl += "theme=" + themeName;
+ getDriver().get(testUrl);
+ }
+}