]> source.dussan.org Git - vaadin-framework.git/commitdiff
TreeTable should support font icons for items (#14077)
authorGuillermo Alvarez <guillermo@vaadin.com>
Thu, 2 Oct 2014 14:43:52 +0000 (17:43 +0300)
committerVaadin Code Review <review@vaadin.com>
Tue, 7 Oct 2014 12:49:11 +0000 (12:49 +0000)
Change-Id: I758e0f80446290f17280447b1ff5c1f44cb8604b

client/src/com/vaadin/client/ui/VTreeTable.java
uitest/src/com/vaadin/tests/components/treetable/TreeTableRowIcons.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/treetable/TreeTableRowIconsTest.java [new file with mode: 0644]

index 49d398246f3ccc34716d3e62f3ccd84a8d8525f1..9b7e9702b234d7f961e72fc1075ede8013a383b6 100644 (file)
@@ -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 (file)
index 0000000..0668a6a
--- /dev/null
@@ -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 (file)
index 0000000..2e299d6
--- /dev/null
@@ -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);
+    }
+
+}