Change-Id: I3407555739ff443055e2e61aa14327d44a65cd8etags/7.2.0
@@ -0,0 +1,5 @@ | |||
@import url(../reindeer/legacy-styles.css); | |||
.v-table-footer-container, .v-table-cell-wrapper { | |||
text-align: center; | |||
} |
@@ -3843,7 +3843,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, | |||
"right"); | |||
break; | |||
default: | |||
DOM.setStyleAttribute(captionContainer, "textAlign", ""); | |||
DOM.setStyleAttribute(captionContainer, "textAlign", "left"); | |||
break; | |||
} | |||
} | |||
@@ -5407,17 +5407,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, | |||
} else { | |||
container.setInnerText(text); | |||
} | |||
if (align != ALIGN_LEFT) { | |||
switch (align) { | |||
case ALIGN_CENTER: | |||
container.getStyle().setProperty("textAlign", "center"); | |||
break; | |||
case ALIGN_RIGHT: | |||
default: | |||
container.getStyle().setProperty("textAlign", "right"); | |||
break; | |||
} | |||
} | |||
setAlign(align, container); | |||
setTooltip(td, description); | |||
td.appendChild(container); | |||
@@ -5455,6 +5445,21 @@ public class VScrollTable extends FlowPanel implements HasWidgets, | |||
} | |||
private void setAlign(char align, final Element container) { | |||
switch (align) { | |||
case ALIGN_CENTER: | |||
container.getStyle().setProperty("textAlign", "center"); | |||
break; | |||
case ALIGN_LEFT: | |||
container.getStyle().setProperty("textAlign", "left"); | |||
break; | |||
case ALIGN_RIGHT: | |||
default: | |||
container.getStyle().setProperty("textAlign", "right"); | |||
break; | |||
} | |||
} | |||
protected void initCellWithWidget(Widget w, char align, | |||
String style, boolean sorted, final TableCellElement td) { | |||
final Element container = DOM.createDiv(); | |||
@@ -5471,21 +5476,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, | |||
td.setClassName(className); | |||
container.setClassName(VScrollTable.this.getStylePrimaryName() | |||
+ "-cell-wrapper"); | |||
// TODO most components work with this, but not all (e.g. | |||
// Select) | |||
// Old comment: make widget cells respect align. | |||
// text-align:center for IE, margin: auto for others | |||
if (align != ALIGN_LEFT) { | |||
switch (align) { | |||
case ALIGN_CENTER: | |||
container.getStyle().setProperty("textAlign", "center"); | |||
break; | |||
case ALIGN_RIGHT: | |||
default: | |||
container.getStyle().setProperty("textAlign", "right"); | |||
break; | |||
} | |||
} | |||
setAlign(align, container); | |||
td.appendChild(container); | |||
getElement().appendChild(td); | |||
// ensure widget not attached to another element (possible tBody |
@@ -0,0 +1,90 @@ | |||
/* | |||
* Copyright 2000-2014 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.table; | |||
import com.vaadin.annotations.Theme; | |||
import com.vaadin.data.util.BeanItemContainer; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.Table; | |||
import com.vaadin.ui.Table.Align; | |||
/** | |||
* Test UI for issue #13399 : Left alignment should not be set explicitly | |||
* instead of relying on default behavior | |||
* | |||
* @author Vaadin Ltd | |||
*/ | |||
@Theme("tests-table") | |||
public class LeftColumnAlignment extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
final Table table = new Table(); | |||
BeanItemContainer<Bean> container = new BeanItemContainer<Bean>( | |||
Bean.class); | |||
Bean bean = new Bean(); | |||
bean.setName("property"); | |||
container.addBean(bean); | |||
table.setContainerDataSource(container); | |||
table.setFooterVisible(true); | |||
table.setWidth(100, Unit.PIXELS); | |||
table.setColumnAlignment("name", Align.RIGHT); | |||
addComponent(table); | |||
Button button = new Button("Align to Left"); | |||
button.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
table.setColumnAlignment("name", Align.LEFT); | |||
} | |||
}); | |||
addComponent(button); | |||
} | |||
@Override | |||
protected String getTestDescription() { | |||
return "Left alignment should not be set explicitly instead of relying on default behavior"; | |||
} | |||
@Override | |||
protected Integer getTicketNumber() { | |||
return 13399; | |||
} | |||
public static class Bean { | |||
private String name; | |||
public String getName() { | |||
return name; | |||
} | |||
public void setName(String name) { | |||
this.name = name; | |||
} | |||
} | |||
} |
@@ -0,0 +1,58 @@ | |||
/* | |||
* Copyright 2000-2014 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.table; | |||
import org.junit.Assert; | |||
import org.junit.Test; | |||
import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
/** | |||
* Test class for issue #13399 : Left alignment should not be set explicitly | |||
* instead of relying on default behavior | |||
* | |||
* @author Vaadin Ltd | |||
*/ | |||
public class LeftColumnAlignmentTest extends MultiBrowserTest { | |||
@Test | |||
public void testLeftColumnAlignment() throws Exception { | |||
openTestURL(); | |||
// Do align columns to the left | |||
WebElement webElement = driver.findElement(By.className("v-button")); | |||
webElement.click(); | |||
Assert.assertTrue("Table caption is not aligned to the left", | |||
isElementPresent(By | |||
.className("v-table-caption-container-align-left"))); | |||
WebElement footer = driver.findElement(By | |||
.className("v-table-footer-container")); | |||
Assert.assertEquals("Table footer is not aligned to the left", "left", | |||
footer.getCssValue("text-align")); | |||
WebElement cell = driver.findElement(By | |||
.className("v-table-cell-wrapper")); | |||
Assert.assertEquals("Table cell is not aligned to the left", "left", | |||
cell.getCssValue("text-align")); | |||
} | |||
} |