From: Guillermo Alvarez Date: Thu, 2 Oct 2014 14:43:52 +0000 (+0300) Subject: TreeTable should support font icons for items (#14077) X-Git-Tag: 7.4.0.beta1~173 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e20a1594dd347f562145fea6a8645123c86fa3ec;p=vaadin-framework.git TreeTable should support font icons for items (#14077) Change-Id: I758e0f80446290f17280447b1ff5c1f44cb8604b --- diff --git a/client/src/com/vaadin/client/ui/VTreeTable.java b/client/src/com/vaadin/client/ui/VTreeTable.java index 49d398246f..9b7e9702b2 100644 --- a/client/src/com/vaadin/client/ui/VTreeTable.java +++ b/client/src/com/vaadin/client/ui/VTreeTable.java @@ -26,7 +26,6 @@ import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.ImageElement; import com.google.gwt.dom.client.SpanElement; import com.google.gwt.dom.client.Style.Display; import com.google.gwt.dom.client.Style.Unit; @@ -174,13 +173,10 @@ public class VTreeTable extends VScrollTable { .getFirstChild(); if (rowUidl.hasAttribute("icon")) { - // icons are in first content cell in TreeTable - ImageElement icon = Document.get().createImageElement(); - icon.setClassName("v-icon"); - icon.setAlt("icon"); - icon.setSrc(client.translateVaadinUri(rowUidl - .getStringAttribute("icon"))); - container.insertFirst(icon); + Icon icon = client.getIcon(rowUidl + .getStringAttribute("icon")); + icon.setAlternateText("icon"); + container.insertFirst(icon.getElement()); } String classname = "v-treetable-treespacer"; diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowIcons.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowIcons.java new file mode 100644 index 0000000000..0668a6aeeb --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowIcons.java @@ -0,0 +1,57 @@ +package com.vaadin.tests.components.treetable; + +import static com.vaadin.server.Sizeable.Unit.PIXELS; + +import com.vaadin.server.FontAwesome; +import com.vaadin.server.Resource; +import com.vaadin.server.ThemeResource; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.TreeTable; + +public class TreeTableRowIcons extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + HorizontalLayout layout = new HorizontalLayout(); + layout.setSpacing(true); + addComponent(layout); + + layout.addComponent(createTreeTableAndPopulate(new ThemeResource( + "../runo/icons/16/ok.png"))); + layout.addComponent(createTreeTableAndPopulate(FontAwesome.ANDROID)); + } + + private TreeTable createTreeTableAndPopulate(Resource icon) { + TreeTable tt = new TreeTable(); + tt.addContainerProperty("Foo", String.class, ""); + tt.setColumnWidth("Foo", 100); + tt.addContainerProperty("Bar", String.class, ""); + tt.setColumnWidth("Bar", 100); + tt.setIcon(icon); + tt.setHeight(400, PIXELS); + + Object item1 = tt.addItem(new Object[] { "Foo", "Bar" }, null); + Object item2 = tt.addItem(new Object[] { "Foo2", "Bar2" }, null); + tt.setItemIcon(item1, icon); + tt.setItemIcon(item2, icon); + + tt.setParent(item2, item1); + + tt.setCollapsed(item1, false); + + return tt; + } + + @Override + protected String getTestDescription() { + return "TreeTable should support font icons for items"; + } + + @Override + protected Integer getTicketNumber() { + return 14077; + } + +} \ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowIconsTest.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowIconsTest.java new file mode 100644 index 0000000000..2e299d62ea --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTableRowIconsTest.java @@ -0,0 +1,34 @@ +/* + * 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.treetable; + +import java.io.IOException; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TreeTableRowIconsTest extends MultiBrowserTest { + + public final String SCREENSHOT_NAME = "TreeTableRowIcons"; + + @Test + public void checkScreenshot() throws IOException { + openTestURL(); + compareScreen(SCREENSHOT_NAME); + } + +}