]> source.dussan.org Git - vaadin-framework.git/commitdiff
#8324 Corrected paintable hierarchy as VScrollTableRow is no longer a
authorArtur Signell <artur@vaadin.com>
Fri, 3 Feb 2012 18:27:38 +0000 (20:27 +0200)
committerArtur Signell <artur@vaadin.com>
Fri, 3 Feb 2012 18:27:38 +0000 (20:27 +0200)
paintable

src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
src/com/vaadin/terminal/gwt/client/ui/VScrollTablePaintable.java
src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java

index aeab9f8ffbe054486269ccec45331fa7f481e193..c9be032063b2c0dc2119bed341e56c3ca63f3d72 100644 (file)
@@ -106,7 +106,7 @@ import com.vaadin.terminal.gwt.client.ui.label.VLabel;
  */
 public class VScrollTable extends FlowPanel implements HasWidgets,
         ScrollHandler, VHasDropHandler, FocusHandler, BlurHandler, Focusable,
-        ActionOwner {
+        ActionOwner, Container {
 
     public enum SelectMode {
         NONE(0), SINGLE(1), MULTI(2);
@@ -4321,8 +4321,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
             }
         }
 
-        public class VScrollTableRow extends Panel implements ActionOwner,
-                Container {
+        public class VScrollTableRow extends Panel implements ActionOwner {
 
             private static final int TOUCHSCROLL_TIMEOUT = 70;
             private static final int DRAGMODE_MULTIROW = 2;
@@ -5279,29 +5278,6 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
                 return paintableId;
             }
 
-            public RenderSpace getAllocatedSpace(Widget child) {
-                int w = 0;
-                int i = getColIndexOf(child);
-                HeaderCell headerCell = tHead.getHeaderCell(i);
-                if (headerCell != null) {
-                    if (initializedAndAttached) {
-                        w = headerCell.getWidth();
-                    } else {
-                        // header offset width is not absolutely correct value,
-                        // but a best guess (expecting similar content in all
-                        // columns ->
-                        // if one component is relative width so are others)
-                        w = headerCell.getOffsetWidth() - getCellExtraWidth();
-                    }
-                }
-                return new RenderSpace(w, 0) {
-                    @Override
-                    public int getHeight() {
-                        return (int) getRowHeight();
-                    }
-                };
-            }
-
             private int getColIndexOf(Widget child) {
                 com.google.gwt.dom.client.Element widgetCell = child
                         .getElement().getParentElement().getParentElement();
@@ -5331,16 +5307,6 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
 
             }
 
-            public boolean requestLayout(Set<Widget> children) {
-                // row size should never change and system wouldn't event
-                // survive as this is a kind of fake paitable
-                return true;
-            }
-
-            public void updateCaption(VPaintableWidget component, UIDL uidl) {
-                // NOP, not rendered
-            }
-
             public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                 // Should never be called,
                 // Component container interface faked here to get layouts
@@ -6706,4 +6672,45 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
         return this;
     }
 
+    public void replaceChildComponent(Widget oldComponent, Widget newComponent) {
+        VScrollTableRow row = (VScrollTableRow) oldComponent.getParent();
+        row.replaceChildComponent(oldComponent, newComponent);
+
+    }
+
+    public boolean hasChildComponent(Widget child) {
+        VScrollTableRow row = (VScrollTableRow) child.getParent();
+        return row.hasChildComponent(child);
+    }
+
+    public boolean requestLayout(Set<Widget> children) {
+        // row size should never change
+        return true;
+    }
+
+    public RenderSpace getAllocatedSpace(Widget child) {
+        // Called by widgets attached to a row
+        VScrollTableRow row = (VScrollTableRow) child.getParent();
+        int w = 0;
+        int i = row.getColIndexOf(child);
+        HeaderCell headerCell = tHead.getHeaderCell(i);
+        if (headerCell != null) {
+            if (initializedAndAttached) {
+                w = headerCell.getWidth();
+            } else {
+                // header offset width is not absolutely correct value,
+                // but a best guess (expecting similar content in all
+                // columns ->
+                // if one component is relative width so are others)
+                w = headerCell.getOffsetWidth()
+                        - scrollBody.getCellExtraWidth();
+            }
+        }
+        return new RenderSpace(w, 0) {
+            @Override
+            public int getHeight() {
+                return (int) scrollBody.getRowHeight();
+            }
+        };
+    }
 }
index 0c41ed1aa39ec041e494bdd87842614a6d6758cc..058b8f15b31760b964dcbedf7c766e7e5671f0dc 100644 (file)
@@ -12,8 +12,9 @@ import com.vaadin.terminal.gwt.client.ApplicationConnection;
 import com.vaadin.terminal.gwt.client.BrowserInfo;
 import com.vaadin.terminal.gwt.client.UIDL;
 import com.vaadin.terminal.gwt.client.Util;
+import com.vaadin.terminal.gwt.client.VPaintableWidget;
 
-public class VScrollTablePaintable extends VAbstractPaintableWidget {
+public class VScrollTablePaintable extends VAbstractPaintableWidgetContainer {
 
     /*
      * (non-Javadoc)
@@ -251,4 +252,9 @@ public class VScrollTablePaintable extends VAbstractPaintableWidget {
     public VScrollTable getWidgetForPaintable() {
         return (VScrollTable) super.getWidgetForPaintable();
     }
+
+    public void updateCaption(VPaintableWidget component, UIDL uidl) {
+        // NOP, not rendered
+    }
+
 }
index 0eddca0ed33818822b73ec71e0f9b6e14073c304..f0c284c2d05b2231603432366520a91a7f23ec81 100644 (file)
@@ -223,29 +223,6 @@ public class VTreeTable extends VScrollTable {
                 }
             }
 
-            @Override
-            public RenderSpace getAllocatedSpace(Widget child) {
-                if (widgetInHierarchyColumn == child) {
-                    final int hierarchyAndIconWidth = getHierarchyAndIconWidth();
-                    final RenderSpace allocatedSpace = super
-                            .getAllocatedSpace(child);
-                    return new RenderSpace() {
-                        @Override
-                        public int getWidth() {
-                            return allocatedSpace.getWidth()
-                                    - hierarchyAndIconWidth;
-                        }
-
-                        @Override
-                        public int getHeight() {
-                            return allocatedSpace.getHeight();
-                        }
-
-                    };
-                }
-                return super.getAllocatedSpace(child);
-            }
-
             private int getHierarchyAndIconWidth() {
                 int consumedSpace = treeSpacer.getOffsetWidth();
                 if (treeSpacer.getParentElement().getChildCount() > 2) {
@@ -824,4 +801,27 @@ public class VTreeTable extends VScrollTable {
         int newTotalRows = uidl.getIntAttribute("totalrows");
         setTotalRows(newTotalRows);
     }
+
+    @Override
+    public RenderSpace getAllocatedSpace(Widget child) {
+        VTreeTableRow row = (VTreeTableRow) child.getParent();
+        if (row.widgetInHierarchyColumn == child) {
+            final int hierarchyAndIconWidth = row.getHierarchyAndIconWidth();
+            final RenderSpace allocatedSpace = super.getAllocatedSpace(child);
+            return new RenderSpace() {
+                @Override
+                public int getWidth() {
+                    return allocatedSpace.getWidth() - hierarchyAndIconWidth;
+                }
+
+                @Override
+                public int getHeight() {
+                    return allocatedSpace.getHeight();
+                }
+
+            };
+        }
+        return super.getAllocatedSpace(child);
+    }
+
 }