diff options
Diffstat (limited to 'src/com/itmill/toolkit/ui/Table.java')
-rw-r--r-- | src/com/itmill/toolkit/ui/Table.java | 171 |
1 files changed, 50 insertions, 121 deletions
diff --git a/src/com/itmill/toolkit/ui/Table.java b/src/com/itmill/toolkit/ui/Table.java index 4be9b840e8..5dbadf6d9c 100644 --- a/src/com/itmill/toolkit/ui/Table.java +++ b/src/com/itmill/toolkit/ui/Table.java @@ -21,11 +21,12 @@ import com.itmill.toolkit.data.Property; import com.itmill.toolkit.data.util.ContainerOrderedWrapper; import com.itmill.toolkit.data.util.IndexedContainer; import com.itmill.toolkit.event.Action; +import com.itmill.toolkit.terminal.HasSize; import com.itmill.toolkit.terminal.KeyMapper; import com.itmill.toolkit.terminal.PaintException; import com.itmill.toolkit.terminal.PaintTarget; import com.itmill.toolkit.terminal.Resource; -import com.itmill.toolkit.terminal.Sizeable; +import com.itmill.toolkit.terminal.Size; /** * <code>TableComponent</code> is used for representing data or components in @@ -37,7 +38,7 @@ import com.itmill.toolkit.terminal.Sizeable; * @since 3.0 */ public class Table extends AbstractSelect implements Action.Container, - Container.Ordered, Container.Sortable, Sizeable { + Container.Ordered, Container.Sortable, HasSize { private static final int CELL_KEY = 0; @@ -49,25 +50,7 @@ public class Table extends AbstractSelect implements Action.Container, private static final int CELL_FIRSTCOL = 4; - /** - * Width of the table or -1 if unspecified. - */ - private int width = -1; - - /** - * Height of the table or -1 if unspecified. - */ - private int height = -1; - - /** - * Width unit. - */ - private int widthUnit = Sizeable.UNITS_PIXELS; - - /** - * Height unit. - */ - private int heightUnit = Sizeable.UNITS_PIXELS; + private Size size; /** * Left column alignment. <b>This is the default behaviour. </b> @@ -308,6 +291,7 @@ public class Table extends AbstractSelect implements Action.Container, */ public Table() { setRowHeaderMode(ROW_HEADER_MODE_HIDDEN); + size = new Size(this); } /** @@ -1422,14 +1406,7 @@ public class Table extends AbstractSelect implements Action.Container, } // Size - if (getHeight() >= 0) { - target.addAttribute("height", "" + getHeight() - + Sizeable.UNIT_SYMBOLS[getHeightUnits()]); - } - if (getWidth() >= 0) { - target.addAttribute("width", "" + getWidth() - + Sizeable.UNIT_SYMBOLS[getWidthUnits()]); - } + size.paint(target); // Initialize temps final Object[] colids = getVisibleColumns(); @@ -2439,126 +2416,78 @@ public class Table extends AbstractSelect implements Action.Container, } /** - * Gets height property unit. + * Table does not support lazy options loading mode. Setting this true will + * throw UnsupportedOperationException. * - * @see com.itmill.toolkit.terminal.Sizeable#getHeightUnits() + * @see com.itmill.toolkit.ui.Select#setLazyLoading(boolean) */ - public int getHeightUnits() { - return heightUnit; + public void setLazyLoading(boolean useLazyLoading) { + if (useLazyLoading) { + throw new UnsupportedOperationException( + "Lazy options loading is not supported by Table."); + } } + public Size getSize() { + return size; + } + + /* Compatibility methods */ + /** - * Gets width property unit. - * - * @see com.itmill.toolkit.terminal.Sizeable#getWidthUnits() + * @deprecated use Size object instead (getSize().setWidth()). */ - public int getWidthUnits() { - return widthUnit; + public void setWidth(int width) { + size.setWidth(width); } - + /** - * Sets height units. - * - * @see com.itmill.toolkit.terminal.Sizeable#setHeightUnits(int) + * @deprecated use Size object instead (getSize().setWidthUnits()). */ - public void setHeightUnits(int units) { - heightUnit = units; + public void setWidthUnits(int unit) { + size.setWidthUnits(unit); } - + /** - * Sets width units. Table supports only Sizeable.UNITS_PIXELS and - * Sizeable.UNITS_PERCENTAGE. Setting to any other throws - * IllegalArgumentException. - * - * @see com.itmill.toolkit.terminal.Sizeable#setWidthUnits(int) + * @deprecated use Size object instead (getSize().setHeight()). */ - public void setWidthUnits(int units) { - if (units != Sizeable.UNITS_PIXELS - && units != Sizeable.UNITS_PERCENTAGE) { - throw new IllegalArgumentException(); - } - widthUnit = units; + public void setHeight(int height) { + size.setHeight(height); } - + /** - * Gets height. - * - * @return height value as a positive integer or negative value if not - * assigned. - * @see com.itmill.toolkit.terminal.Sizeable#getHeight() + * @deprecated use Size object instead (getSize().setHeightUnits()). */ - public int getHeight() { - return height; + public void setHeightUnits(int unit) { + size.setHeightUnits(unit); } - + /** - * Gets width. - * - * @return width value as positive integer or negative value if not - * assigned. - * @see com.itmill.toolkit.terminal.Sizeable#getWidth() + * @deprecated use Size object instead (getSize().getWidth()). */ public int getWidth() { - return width; + return size.getWidth(); } - + /** - * Sets height. Use negative value to let the client decide the height. - * - * @param height - * the height to set. + * @deprecated use Size object instead (getSize().getWidthUnits()). */ - public void setHeight(int height) { - this.height = height; - requestRepaint(); + public int getWidthUnits() { + return size.getWidthUnits(); } - + /** - * Sets width. Use negative value to allow the client decide the width. - * - * @param width - * the width to set. + * @deprecated use Size object instead (getSize().getHeight()). */ - public void setWidth(int width) { - this.width = width; - requestRepaint(); + public int getHeight() { + return size.getHeight(); } - + /** - * Table does not support lazy options loading mode. Setting this true will - * throw UnsupportedOperationException. - * - * @see com.itmill.toolkit.ui.Select#setLazyLoading(boolean) + * @deprecated use Size object instead (getSize().getHeightUnits()). */ - public void setLazyLoading(boolean useLazyLoading) { - if (useLazyLoading) { - throw new UnsupportedOperationException( - "Lazy options loading is not supported by Table."); - } - } - - /* - * (non-Javadoc) - * - * @see com.itmill.toolkit.terminal.Sizeable#setSizeFull() - */ - public void setSizeFull() { - setWidth(100); - setHeight(100); - setWidthUnits(UNITS_PERCENTAGE); - setHeightUnits(UNITS_PERCENTAGE); - } - - /* - * (non-Javadoc) - * - * @see com.itmill.toolkit.terminal.Sizeable#setSizeUndefined() - */ - public void setSizeUndefined() { - setWidth(-1); - setHeight(-1); - setWidthUnits(UNITS_PIXELS); - setHeightUnits(UNITS_PIXELS); + public int getHeightUnits() { + return size.getHeightUnits(); } }
\ No newline at end of file |