Change-Id: I0511bcf6814fa33d558712da2bc112b545468153tags/7.2.0.beta1
-moz-box-sizing: border-box; | -moz-box-sizing: border-box; | ||||
box-sizing: border-box; | box-sizing: border-box; | ||||
overflow:hidden; | 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 { | .#{$primaryStyleName}-cell.frozen { | ||||
z-index: 0; | z-index: 0; | ||||
} | } | ||||
} | |||||
} |
.popup-style .v-datefield-calendarpanel-body { | .popup-style .v-datefield-calendarpanel-body { | ||||
background: yellow; | background: yellow; | ||||
} | } | ||||
#escalator .v-escalator-body .v-escalator-cell { | |||||
height: 50px; | |||||
} |
import com.google.gwt.animation.client.AnimationScheduler.AnimationHandle; | import com.google.gwt.animation.client.AnimationScheduler.AnimationHandle; | ||||
import com.google.gwt.core.client.Duration; | import com.google.gwt.core.client.Duration; | ||||
import com.google.gwt.core.client.JavaScriptObject; | 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.Document; | ||||
import com.google.gwt.dom.client.Element; | import com.google.gwt.dom.client.Element; | ||||
import com.google.gwt.dom.client.NativeEvent; | import com.google.gwt.dom.client.NativeEvent; | ||||
private abstract class AbstractRowContainer implements RowContainer { | private abstract class AbstractRowContainer implements RowContainer { | ||||
private static final int INITIAL_DEFAULT_ROW_HEIGHT = 20; | |||||
private EscalatorUpdater updater = EscalatorUpdater.NULL; | private EscalatorUpdater updater = EscalatorUpdater.NULL; | ||||
private int rows; | private int rows; | ||||
@Deprecated | @Deprecated | ||||
private final Map<Element, Integer> rowTopPositionMap = new HashMap<Element, Integer>(); | private final Map<Element, Integer> rowTopPositionMap = new HashMap<Element, Integer>(); | ||||
private boolean defaultRowHeightShouldBeAutodetected = true; | |||||
private int defaultRowHeight = INITIAL_DEFAULT_ROW_HEIGHT; | private int defaultRowHeight = INITIAL_DEFAULT_ROW_HEIGHT; | ||||
public AbstractRowContainer(final Element rowContainerElement) { | public AbstractRowContainer(final Element rowContainerElement) { | ||||
+ px + " was given."); | + px + " was given."); | ||||
} | } | ||||
defaultRowHeightShouldBeAutodetected = false; | |||||
defaultRowHeight = px; | defaultRowHeight = px; | ||||
reapplyDefaultRowHeights(); | reapplyDefaultRowHeights(); | ||||
} | } | ||||
protected void removeRowPosition(Element tr) { | protected void removeRowPosition(Element tr) { | ||||
rowTopPositionMap.remove(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 | private abstract class AbstractStaticRowContainer extends | ||||
protected void onLoad() { | protected void onLoad() { | ||||
super.onLoad(); | super.onLoad(); | ||||
header.autodetectRowHeight(); | |||||
body.autodetectRowHeight(); | |||||
footer.autodetectRowHeight(); | |||||
header.paintInsertRows(0, header.getRowCount()); | header.paintInsertRows(0, header.getRowCount()); | ||||
footer.paintInsertRows(0, footer.getRowCount()); | footer.paintInsertRows(0, footer.getRowCount()); | ||||
recalculateElementSizes(); | recalculateElementSizes(); |
* @see Escalator#getFooter() | * @see Escalator#getFooter() | ||||
*/ | */ | ||||
public interface RowContainer { | 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. | * Returns the current {@link EscalatorUpdater} used to render cells. | ||||
* | * | ||||
* the default height in pixels of the rows in this RowContainer | * the default height in pixels of the rows in this RowContainer | ||||
* @throws IllegalArgumentException | * @throws IllegalArgumentException | ||||
* if <code>px < 1</code> | * if <code>px < 1</code> | ||||
* @see #getDefaultRowHeight() | |||||
*/ | */ | ||||
public void setDefaultRowHeight(int px) throws IllegalArgumentException; | public void setDefaultRowHeight(int px) throws IllegalArgumentException; | ||||
/** | /** | ||||
* Returns the default height of the rows in this RowContainer. | * 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 | * @return the default height of the rows in this RowContainer, in pixels | ||||
* @see #setDefaultRowHeight(int) | |||||
*/ | */ | ||||
public int getDefaultRowHeight(); | public int getDefaultRowHeight(); | ||||
} | } |
/* | |||||
* 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); | |||||
} | |||||
} |