]> source.dussan.org Git - vaadin-framework.git/commitdiff
initial commit for #217 . also removed one illegal character in JS
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 31 May 2007 11:55:15 +0000 (11:55 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 31 May 2007 11:55:15 +0000 (11:55 +0000)
svn changeset:1540/svn branch:trunk

src/com/itmill/toolkit/ui/Table.java

index e0cc144addc26b9cf98fd3ef63a9790b6a5faed3..071fe84169c903695a4156135d2859a39518e5be 100644 (file)
@@ -218,6 +218,11 @@ public class Table extends Select implements Action.Container,
         */
        private HashMap columnAlignments = new HashMap();
 
+       /**
+        * Holds column widths in pixels for visible columns (by propertyId).
+        */
+       private HashMap columnWidths = new HashMap();
+
        /**
         * Holds value of property pageLength. 0 disables paging.
         */
@@ -614,6 +619,31 @@ public class Table extends Select implements Action.Container,
                // Assures the visual refresh
                refreshCurrentPage();
        }
+       
+       /**
+        * Sets columns width (in pixels). Theme may not necessary respect very 
+        * small or very big values. Setting width to -1 (default) means that theme
+        * will make decision of width.
+        * 
+        * @param columnId colunmns property id
+        * @param width width to be reserved for colunmns content
+        * @since 4.0.3
+        */
+       public void setColumnWidth(Object columnId, int width) {
+               columnWidths.put(columnId, new Integer(width));
+       }
+       
+       /**
+        * Gets the width of column
+        * @param propertyId
+        * @return width of colun or -1 when value not set
+        */
+       public int getColumnWidth(Object propertyId) {
+               Integer value = (Integer) columnWidths.get(propertyId);
+               if(value == null)
+                       return -1;
+               return value.intValue();
+       }
 
        /**
         * Gets the page length.
@@ -1433,6 +1463,8 @@ public class Table extends Select implements Action.Container,
                                if (!ALIGN_LEFT.equals(this.getColumnAlignment(columnId)))
                                        target.addAttribute("align", this
                                                        .getColumnAlignment(columnId));
+                               if(getColumnWidth(columnId) > -1)
+                                       target.addAttribute("width", String.valueOf(getColumnWidth(columnId)));
                                target.endTag("ch");
                        }
                }