diff options
11 files changed, 33 insertions, 21 deletions
diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java index 5eb18ee61f..65189fed0c 100644 --- a/server/src/com/vaadin/ui/Table.java +++ b/server/src/com/vaadin/ui/Table.java @@ -3479,8 +3479,8 @@ public class Table extends AbstractSelect implements Action.Container, * target. */ if (cellStyleGenerator != null) { - String cellStyle = cellStyleGenerator - .getStyle(itemId, columnId); + String cellStyle = cellStyleGenerator.getStyle(this, itemId, + columnId); if (cellStyle != null && !cellStyle.equals("")) { target.addAttribute("style-" + columnIdMap.key(columnId), cellStyle); @@ -3567,7 +3567,7 @@ public class Table extends AbstractSelect implements Action.Container, * to the target. */ if (cellStyleGenerator != null) { - String rowStyle = cellStyleGenerator.getStyle(itemId, null); + String rowStyle = cellStyleGenerator.getStyle(this, itemId, null); if (rowStyle != null && !rowStyle.equals("")) { target.addAttribute("rowstyle", rowStyle); } @@ -4602,6 +4602,8 @@ public class Table extends AbstractSelect implements Action.Container, /** * Called by Table when a cell (and row) is painted. * + * @param source + * the source Table * @param itemId * The itemId of the painted cell * @param propertyId @@ -4610,7 +4612,8 @@ public class Table extends AbstractSelect implements Action.Container, * name will be v-table-cell-content-[style name], or * v-table-row-[style name] for rows) */ - public abstract String getStyle(Object itemId, Object propertyId); + public abstract String getStyle(Table source, Object itemId, + Object propertyId); } @Override diff --git a/server/src/com/vaadin/ui/Tree.java b/server/src/com/vaadin/ui/Tree.java index ad3674fe1e..306d1f18ba 100644 --- a/server/src/com/vaadin/ui/Tree.java +++ b/server/src/com/vaadin/ui/Tree.java @@ -611,7 +611,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, } if (itemStyleGenerator != null) { - String stylename = itemStyleGenerator.getStyle(itemId); + String stylename = itemStyleGenerator + .getStyle(this, itemId); if (stylename != null) { target.addAttribute(TreeConstants.ATTRIBUTE_NODE_STYLE, stylename); @@ -1255,12 +1256,14 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, /** * Called by Tree when an item is painted. * + * @param source + * the source Tree * @param itemId * The itemId of the item to be painted * @return The style name to add to this item. (the CSS class name will * be v-tree-node-[style name] */ - public abstract String getStyle(Object itemId); + public abstract String getStyle(Tree source, Object itemId); } // Overriden so javadoc comes from Container.Hierarchical diff --git a/uitest/src/com/vaadin/tests/Components.java b/uitest/src/com/vaadin/tests/Components.java index 5882c5cdb1..7ac1b55d35 100644 --- a/uitest/src/com/vaadin/tests/Components.java +++ b/uitest/src/com/vaadin/tests/Components.java @@ -25,9 +25,9 @@ import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.Embedded; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; -import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Tree; import com.vaadin.ui.Tree.ItemStyleGenerator; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Components extends Application.LegacyApplication { @@ -138,7 +138,7 @@ public class Components extends Application.LegacyApplication { naviTree.setItemStyleGenerator(new ItemStyleGenerator() { @Override - public String getStyle(Object itemId) { + public String getStyle(Tree source, Object itemId) { Class<?> cls = (Class<?>) itemId; if (!isAbstract(cls)) { return "blue"; diff --git a/uitest/src/com/vaadin/tests/components/table/CellStyleGeneratorTest.java b/uitest/src/com/vaadin/tests/components/table/CellStyleGeneratorTest.java index 35f35c1407..fb4bc5a045 100644 --- a/uitest/src/com/vaadin/tests/components/table/CellStyleGeneratorTest.java +++ b/uitest/src/com/vaadin/tests/components/table/CellStyleGeneratorTest.java @@ -17,7 +17,8 @@ public class CellStyleGeneratorTest extends TestBase { CellStyleGenerator g = new CellStyleGenerator() { @Override - public String getStyle(Object itemId, Object propertyId) { + public String getStyle(Table source, Object itemId, + Object propertyId) { if (propertyId != null && propertyId.equals("red")) { return "red"; } else if (itemId.equals("blue") && propertyId == null) { diff --git a/uitest/src/com/vaadin/tests/components/table/Tables.java b/uitest/src/com/vaadin/tests/components/table/Tables.java index 1431155b1a..a08533fdbd 100644 --- a/uitest/src/com/vaadin/tests/components/table/Tables.java +++ b/uitest/src/com/vaadin/tests/components/table/Tables.java @@ -335,7 +335,8 @@ public class Tables<T extends Table> extends AbstractSelectTestCase<T> c.setCellStyleGenerator(new CellStyleGenerator() { @Override - public String getStyle(Object itemId, Object propertyId) { + public String getStyle(Table source, Object itemId, + Object propertyId) { if (cellStyleInfo.appliesTo(itemId, propertyId)) { return cellStyleInfo.styleName; } diff --git a/uitest/src/com/vaadin/tests/components/tree/ItemStyleGenerator.java b/uitest/src/com/vaadin/tests/components/tree/ItemStyleGenerator.java index 33bd4cef65..c561781d2b 100644 --- a/uitest/src/com/vaadin/tests/components/tree/ItemStyleGenerator.java +++ b/uitest/src/com/vaadin/tests/components/tree/ItemStyleGenerator.java @@ -33,7 +33,7 @@ public class ItemStyleGenerator extends TestBase { tree.setItemStyleGenerator(new Tree.ItemStyleGenerator() { @Override - public String getStyle(Object itemId) { + public String getStyle(Tree source, Object itemId) { // simple return itemId as css style name return itemId.toString(); } diff --git a/uitest/src/com/vaadin/tests/components/tree/Trees.java b/uitest/src/com/vaadin/tests/components/tree/Trees.java index 3ee1d7b0de..8796fb854c 100644 --- a/uitest/src/com/vaadin/tests/components/tree/Trees.java +++ b/uitest/src/com/vaadin/tests/components/tree/Trees.java @@ -27,7 +27,7 @@ public class Trees extends AbstractSelectTestCase<Tree> implements private ItemStyleGenerator rootGreenSecondLevelRed = new com.vaadin.ui.Tree.ItemStyleGenerator() { @Override - public String getStyle(Object itemId) { + public String getStyle(Tree source, Object itemId) { Hierarchical c = (Container.Hierarchical) getComponent() .getContainerDataSource(); if (c.isRoot(itemId)) { @@ -52,7 +52,7 @@ public class Trees extends AbstractSelectTestCase<Tree> implements private ItemStyleGenerator evenItemsBold = new com.vaadin.ui.Tree.ItemStyleGenerator() { @Override - public String getStyle(Object itemId) { + public String getStyle(Tree source, Object itemId) { Hierarchical c = (Container.Hierarchical) getComponent() .getContainerDataSource(); int idx = 0; diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTableTest.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTableTest.java index f27a47f12b..8fafdb2d26 100644 --- a/uitest/src/com/vaadin/tests/components/treetable/TreeTableTest.java +++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTableTest.java @@ -9,6 +9,7 @@ import com.vaadin.data.Container; import com.vaadin.data.Container.Hierarchical; import com.vaadin.data.util.HierarchicalContainer; import com.vaadin.tests.components.table.Tables; +import com.vaadin.ui.Table; import com.vaadin.ui.Table.CellStyleGenerator; import com.vaadin.ui.Tree.CollapseEvent; import com.vaadin.ui.Tree.CollapseListener; @@ -28,7 +29,7 @@ public class TreeTableTest extends Tables<TreeTable> implements private CellStyleGenerator rootGreenSecondLevelRed = new com.vaadin.ui.Table.CellStyleGenerator() { @Override - public String getStyle(Object itemId, Object propertyId) { + public String getStyle(Table source, Object itemId, Object propertyId) { if (propertyId != null) { return null; } @@ -56,7 +57,7 @@ public class TreeTableTest extends Tables<TreeTable> implements private CellStyleGenerator evenItemsBold = new CellStyleGenerator() { @Override - public String getStyle(Object itemId, Object propertyId) { + public String getStyle(Table source, Object itemId, Object propertyId) { if (propertyId != null) { return null; } diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket1857.java b/uitest/src/com/vaadin/tests/tickets/Ticket1857.java index 039f867fff..be0158e0fb 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket1857.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket1857.java @@ -7,8 +7,8 @@ import com.vaadin.event.Action; import com.vaadin.event.Action.Handler; import com.vaadin.ui.CheckBox; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket1857 extends Application.LegacyApplication implements @@ -60,7 +60,8 @@ public class Ticket1857 extends Application.LegacyApplication implements if (cellStylesEnabler.getValue().booleanValue()) { t.setCellStyleGenerator(new Table.CellStyleGenerator() { @Override - public String getStyle(Object itemId, Object propertyId) { + public String getStyle(Table source, Object itemId, + Object propertyId) { Object cell = t.getContainerProperty(itemId, propertyId).getValue(); if (!(cell instanceof Integer)) { diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket2125.java b/uitest/src/com/vaadin/tests/tickets/Ticket2125.java index bc1f886418..defd7f4a22 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket2125.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket2125.java @@ -5,10 +5,10 @@ import com.vaadin.data.util.MethodProperty; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.Label; -import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.Table.CellStyleGenerator; import com.vaadin.ui.Table.ColumnGenerator; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2125 extends Application.LegacyApplication { @@ -42,7 +42,8 @@ public class Ticket2125 extends Application.LegacyApplication { }); table.setCellStyleGenerator(new CellStyleGenerator() { @Override - public String getStyle(Object itemId, Object propertyId) { + public String getStyle(Table source, Object itemId, + Object propertyId) { if (new Integer(4).equals(itemId)) { if (propertyId == null) { return "MYROW"; diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket2208.java b/uitest/src/com/vaadin/tests/tickets/Ticket2208.java index f622f093ee..98cd6724d4 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket2208.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket2208.java @@ -4,10 +4,10 @@ import com.vaadin.Application; import com.vaadin.data.Item; import com.vaadin.ui.Component; import com.vaadin.ui.Label; -import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.Table.CellStyleGenerator; import com.vaadin.ui.Table.ColumnGenerator; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2208 extends Application.LegacyApplication { @@ -40,7 +40,8 @@ public class Ticket2208 extends Application.LegacyApplication { t.setCellStyleGenerator(new CellStyleGenerator() { @Override - public String getStyle(Object itemId, Object propertyId) { + public String getStyle(Table source, Object itemId, + Object propertyId) { if ("col 1 (red)".equals(propertyId)) { return "red"; } |