Changeset 5570
- Timestamp:
- 10/01/08 06:40:48 (7 weeks ago)
- Location:
- trunk
- Files:
-
- 1 added
- 30 modified
-
WebContent/ITMILL/themes/default/orderedlayout/orderedlayout.css (modified) (1 diff)
-
WebContent/ITMILL/themes/default/styles.css (modified) (3 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java (modified) (15 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/Container.java (modified) (2 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ContainerResizedListener.java (modified) (1 diff)
-
src/com/itmill/toolkit/terminal/gwt/client/ICaption.java (modified) (4 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/RenderInformation.java (added)
-
src/com/itmill/toolkit/terminal/gwt/client/Util.java (modified) (5 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/IAccordion.java (modified) (4 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java (modified) (3 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/ICoordinateLayout.java (modified) (16 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomComponent.java (modified) (3 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java (modified) (4 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java (modified) (14 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java (modified) (6 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java (modified) (3 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java (modified) (6 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java (modified) (34 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java (modified) (11 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java (modified) (3 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java (modified) (1 diff)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/ISlider.java (modified) (1 diff)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java (modified) (12 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java (modified) (6 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetBase.java (modified) (2 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/ITextField.java (modified) (4 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java (modified) (1 diff)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java (modified) (8 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java (modified) (1 diff)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/absolutegrid/IAbsoluteGrid.java (modified) (5 diffs)
-
src/com/itmill/toolkit/terminal/gwt/client/ui/absolutegrid/ISizeableGridLayout.java (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebContent/ITMILL/themes/default/orderedlayout/orderedlayout.css
r5245 r5570 20 20 21 21 /* Placing error indicator right after the widget with empty caption */ 22 .i-orderedlayout-c * { float:left; display: block;}22 .i-orderedlayout-c * { float:left;} 23 23 .i-orderedlayout-w-e { float:left;} 24 24 * html .i-orderedlayout-c, * html .i-orderedlayout-w { height: 1%; } 25 .i-orderedlayout-w { display: block; }26 25 .i-orderedlayout-c { float:left; display: block;} 27 26 .i-orderedlayout-w:after, .i-orderedlayout-c:after { -
trunk/WebContent/ITMILL/themes/default/styles.css
r5562 r5570 163 163 */ 164 164 @media print { 165 165 166 .i-generated-body { 166 167 height: auto; … … 168 169 overflow: visible; 169 170 } 171 170 172 .i-app { 171 173 height:auto; … … 882 884 883 885 /* Placing error indicator right after the widget with empty caption */ 884 .i-orderedlayout-c * { float:left; display: block;}886 .i-orderedlayout-c * { float:left;} 885 887 .i-orderedlayout-w-e { float:left;} 886 888 * html .i-orderedlayout-c, * html .i-orderedlayout-w { height: 1%; } 887 .i-orderedlayout-w { display: block; }888 889 .i-orderedlayout-c { float:left; display: block;} 889 890 .i-orderedlayout-w:after, .i-orderedlayout-c:after { -
trunk/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
r5559 r5570 36 36 import com.google.gwt.user.client.ui.HasWidgets; 37 37 import com.google.gwt.user.client.ui.Widget; 38 import com.itmill.toolkit.terminal.gwt.client.RenderInformation.FloatSize; 39 import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size; 38 40 import com.itmill.toolkit.terminal.gwt.client.ui.Field; 39 41 import com.itmill.toolkit.terminal.gwt.client.ui.IContextMenu; … … 66 68 private final Vector pendingVariables = new Vector(); 67 69 68 private final HashMap idToPaintable = new HashMap();69 70 private final HashMap paintableToId = new HashMap();70 private final HashMap<String, Paintable> idToPaintable = new HashMap<String, Paintable>(); 71 72 private final HashMap<Paintable, String> paintableToId = new HashMap<Paintable, String>(); 71 73 72 74 /** Contains ExtendedTitleInfo by paintable id */ 73 private final HashMap paintableToTitle = new HashMap(); 75 private final HashMap<Paintable, TooltipInfo> paintableToTitle = new HashMap<Paintable, TooltipInfo>(); 76 77 private final HashMap<Widget, FloatSize> componentRelativeSizes = new HashMap<Widget, FloatSize>(); 78 private final HashMap<Widget, Size> componentOffsetSizes = new HashMap<Widget, Size>(); 74 79 75 80 private final WidgetSet widgetSet; … … 526 531 .get("changes"); 527 532 528 Set<Widget> sizeUpdatedWidgets = new HashSet<Widget>();533 Vector<Widget> updatedWidgets = new Vector<Widget>(); 529 534 530 535 for (int i = 0; i < changes.size(); i++) { … … 543 548 if (paintable != null) { 544 549 Widget widget = (Widget) paintable; 545 int w = widget.getOffsetWidth();546 int h = widget.getOffsetHeight();547 550 548 551 paintable.updateFromUIDL(uidl, this); 549 552 550 if (w != widget.getOffsetWidth() 551 || h != widget.getOffsetHeight()) { 552 sizeUpdatedWidgets.add((Widget) paintable); 553 } 553 updatedWidgets.add(widget); 554 554 } else { 555 555 if (!uidl.getTag().equals("window")) { … … 568 568 } 569 569 570 // Check which widgets' size has been updated 571 Set<Widget> sizeUpdatedWidgets = new HashSet<Widget>(); 572 573 for (Widget widget : updatedWidgets) { 574 Size oldSize = componentOffsetSizes.get(widget); 575 Size newSize = new Size(widget.getOffsetWidth(), widget 576 .getOffsetHeight()); 577 578 if (oldSize == null || !oldSize.equals(newSize)) { 579 sizeUpdatedWidgets.add(widget); 580 componentOffsetSizes.put(widget, newSize); 581 } 582 583 } 584 570 585 Util.componentSizeUpdated(sizeUpdatedWidgets); 571 586 … … 589 604 590 605 if (html.length() != 0) { 591 INotification n = new INotification(1000 * 60 * 45); // 45min606 INotification n = new INotification(1000 * 60 * 45); // 45min 592 607 n.addEventListener(new NotificationRedirect(url)); 593 608 n.show(html, INotification.CENTERED_TOP, … … 638 653 639 654 public void unregisterPaintable(Paintable p) { 640 Objectid = paintableToId.get(p);655 String id = paintableToId.get(p); 641 656 idToPaintable.remove(id); 642 657 paintableToTitle.remove(id); … … 667 682 */ 668 683 public Paintable getPaintable(String id) { 669 return (Paintable)idToPaintable.get(id);684 return idToPaintable.get(id); 670 685 } 671 686 … … 858 873 // Switch to correct implementation if needed 859 874 if (!widgetSet.isCorrectImplementation(component, uidl)) { 860 final Container parent = Util.get ParentLayout(component);875 final Container parent = Util.getLayout(component); 861 876 if (parent != null) { 862 877 final Widget w = (Widget) widgetSet.createWidget(uidl); … … 867 882 } 868 883 } 869 870 updateComponentSize(component, uidl);871 884 872 885 boolean enabled = !uidl.getBooleanAttribute("disabled"); … … 941 954 // Set captions 942 955 if (manageCaption) { 943 final Container parent = Util.get ParentLayout(component);956 final Container parent = Util.getLayout(component); 944 957 if (parent != null) { 945 958 parent.updateCaption((Paintable) component, uidl); … … 950 963 DOM.setElementProperty(component.getElement(), "id", uidl.getId()); 951 964 } 965 966 /* 967 * updateComponentSize need to be after caption update so caption can be 968 * taken into account 969 */ 970 971 updateComponentSize(component, uidl); 952 972 953 973 return false; … … 957 977 String w = uidl.hasAttribute("width") ? uidl 958 978 .getStringAttribute("width") : ""; 959 component.setWidth(w); 979 960 980 String h = uidl.hasAttribute("height") ? uidl 961 981 .getStringAttribute("height") : ""; 962 component.setHeight(h); 982 983 float relativeWidth = Util.parseRelativeSize(w); 984 float relativeHeight = Util.parseRelativeSize(h); 985 986 if (relativeHeight >= 0.0 || relativeWidth >= 0.0) { 987 // One or both is relative 988 FloatSize relativeSize = new FloatSize(relativeWidth, 989 relativeHeight); 990 componentRelativeSizes.put(component, relativeSize); 991 handleComponentRelativeSize(component); 992 } else if (relativeHeight < 0.0 && relativeWidth < 0.0) { 993 // No relative sizes 994 componentRelativeSizes.remove(component); 995 } 996 997 if (relativeHeight < 0.0) { 998 component.setHeight(h); 999 } 1000 if (relativeWidth < 0.0) { 1001 component.setWidth(w); 1002 } 1003 } 1004 1005 /** 1006 * Traverses recursively ancestors until ContainerResizedListener child 1007 * widget is found. They will delegate it further if needed. 1008 * 1009 * @param container 1010 */ 1011 public void runDescendentsLayout(HasWidgets container) { 1012 // getConsole().log( 1013 // "runDescendentsLayout(" 1014 // + container.getClass().getName().replaceAll( 1015 // "[^\\.]*\\.", "") + "/" + container.hashCode() 1016 // + ")"); 1017 final Iterator childWidgets = container.iterator(); 1018 while (childWidgets.hasNext()) { 1019 final Widget child = (Widget) childWidgets.next(); 1020 1021 if (child instanceof Paintable) { 1022 handleComponentRelativeSize(child); 1023 } 1024 1025 if (child instanceof ContainerResizedListener) { 1026 ((ContainerResizedListener) child).iLayout(); 1027 } else if (child instanceof HasWidgets) { 1028 final HasWidgets childContainer = (HasWidgets) child; 1029 runDescendentsLayout(childContainer); 1030 } 1031 1032 } 1033 } 1034 1035 public void handleComponentRelativeSize(Widget child) { 1036 Widget widget = child; 1037 FloatSize relativeSize = componentRelativeSizes.get(widget); 1038 if (relativeSize == null) { 1039 return; 1040 } 1041 1042 Size availPixels = Util.getLayout(widget).getAllocatedSpace(widget); 1043 if (relativeSize.getWidth() >= 0) { 1044 1045 if (availPixels != null) { 1046 1047 int width = availPixels.getWidth(); 1048 width *= relativeSize.getWidth() / 100.0; 1049 1050 if (width >= 0) { 1051 // getConsole().log( 1052 // "Widget " + widget.getClass().getName() + "/" 1053 // + widget.hashCode() + " relative width " 1054 // + relativeSize.getWidth() + "%: " + width 1055 // + "px"); 1056 widget.setWidth(width + "px"); 1057 } 1058 } else { 1059 widget.setWidth(relativeSize.getWidth() + "%"); 1060 ApplicationConnection.getConsole().error( 1061 Util.getLayout(widget).getClass().getName() 1062 + " did not produce allocatedSpace for " 1063 + widget.getClass().getName()); 1064 } 1065 } 1066 if (relativeSize.getHeight() >= 0) { 1067 if (availPixels != null) { 1068 1069 int height = availPixels.getHeight(); 1070 height *= relativeSize.getHeight() / 100.0; 1071 1072 if (height >= 0) { 1073 // getConsole().log( 1074 // "Widget " + widget.getClass().getName() + "/" 1075 // + widget.hashCode() + " relative height " 1076 // + relativeSize.getHeight() + "%: " + height 1077 // + "px"); 1078 widget.setHeight(height + "px"); 1079 } 1080 } else { 1081 widget.setHeight(relativeSize.getHeight() + "%"); 1082 ApplicationConnection.getConsole().error( 1083 Util.getLayout(widget).getClass().getName() 1084 + " did not produce allocatedSpace for " 1085 + widget.getClass().getName()); 1086 } 1087 } 1088 963 1089 } 964 1090 … … 1063 1189 */ 1064 1190 public TooltipInfo getTitleInfo(Paintable titleOwner) { 1065 TooltipInfo info = (TooltipInfo)paintableToTitle.get(titleOwner);1191 TooltipInfo info = paintableToTitle.get(titleOwner); 1066 1192 if (info == null) { 1067 1193 info = new TooltipInfo(); … … 1120 1246 getConsole().log( 1121 1247 "Running re-layout of " + view.getClass().getName()); 1122 Util.runDescendentsLayout(view);1248 runDescendentsLayout(view); 1123 1249 isPending = false; 1124 1250 } -
trunk/src/com/itmill/toolkit/terminal/gwt/client/Container.java
r5453 r5570 5 5 package com.itmill.toolkit.terminal.gwt.client; 6 6 7 import java.util.Set; 8 7 9 import com.google.gwt.user.client.ui.Widget; 10 import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size; 8 11 9 12 public interface Container extends Paintable { … … 54 57 * phase. 55 58 * 59 * @param child 60 * Set of child widgets whose size have changed 56 61 * @return true if the size of the Container remains the same, false if the 57 62 * event need to be propagated to the Containers parent 58 63 */ 59 boolean childComponentSizesUpdated(); 64 boolean requestLayout(Set<Paintable> child); 65 66 /** 67 * Returns the size currently allocated for the child component. 68 * 69 * @param child 70 * @return 71 */ 72 Size getAllocatedSpace(Widget child); 73 60 74 } -
trunk/src/com/itmill/toolkit/terminal/gwt/client/ContainerResizedListener.java
r5453 r5570 17 17 * from Util class may be a good helper for this. 18 18 * 19 * The width and height parameters specifies the space available for the20 * component (in pixels) if the parent container can or want to produce21 * these numbers. If the parent container does not know (has not calculated)22 * or cannot produce (undefined dimensions) one of these numbers -1 is23 * passed.24 *25 * Note that these numbers should not be considered the maximum size for the26 * widget if the layout has undefined dimension. In that case the currently27 * allocated space is passed (eg. OrderedLayout with undefined width might28 * pass availableWidth 100 if the widest component in the layout is 100 but29 * it will still stretch if another 200 pixel wide component is rendered)30 19 */ 31 public void iLayout( int availableWidth, int availableHeight);20 public void iLayout(); 32 21 } -
trunk/src/com/itmill/toolkit/terminal/gwt/client/ICaption.java
r5405 r5570 9 9 import com.google.gwt.user.client.Event; 10 10 import com.google.gwt.user.client.ui.HTML; 11 import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size; 11 12 import com.itmill.toolkit.terminal.gwt.client.ui.Icon; 12 13 … … 28 29 29 30 private boolean placedAfterComponent = false; 31 32 private Size requiredSpace = new Size(0, 0); 30 33 31 34 /** … … 139 142 } 140 143 144 requiredSpace.setWidth(getOffsetWidth()); 145 requiredSpace.setHeight(getOffsetHeight()); 141 146 } 142 147 … … 178 183 return placedAfterComponent; 179 184 } 185 186 public Size getRequiredSpace() { 187 return requiredSpace; 188 } 189 190 public int getWidth() { 191 int width = 0; 192 if (icon != null) { 193 width += icon.getOffsetWidth(); 194 } 195 if (captionText != null) { 196 width += captionText.getOffsetWidth(); 197 } 198 if (requiredFieldIndicator != null) { 199 width += requiredFieldIndicator.getOffsetWidth(); 200 } 201 if (errorIndicatorElement != null) { 202 width += errorIndicatorElement.getOffsetWidth(); 203 } 204 205 if (BrowserInfo.get().isIE6() && shouldBePlacedAfterComponent()) { 206 // FIXME: Should find out what the real issue is 207 // Workaround for IE6 weirdness 208 width += 3; 209 } 210 211 return width; 212 213 } 214 215 public int getHeight() { 216 return getOffsetHeight(); 217 } 218 219 public void setAlignment(String alignment) { 220 DOM.setStyleAttribute(getElement(), "textAlign", alignment); 221 222 } 180 223 } -
trunk/src/com/itmill/toolkit/terminal/gwt/client/Util.java
r5468 r5570 5 5 package com.itmill.toolkit.terminal.gwt.client; 6 6 7 import java.util.HashMap; 7 8 import java.util.HashSet; 8 import java.util. Iterator;9 import java.util.Map; 9 10 import java.util.Set; 10 11 11 12 import com.google.gwt.user.client.DOM; 12 13 import com.google.gwt.user.client.Element; 13 import com.google.gwt.user.client.ui.HasWidgets;14 14 import com.google.gwt.user.client.ui.Widget; 15 15 … … 51 51 } 52 52 53 Set<Container> parents = new HashSet<Container>();53 Map<Container, Set<Paintable>> childWidgets = new HashMap<Container, Set<Paintable>>(); 54 54 55 55 for (Widget widget : widgets) { … … 59 59 } 60 60 if (parent != null) { 61 parents.add((Container) parent); 61 Set<Paintable> set = childWidgets.get(parent); 62 if (set == null) { 63 set = new HashSet<Paintable>(); 64 childWidgets.put((Container) parent, set); 65 } 66 set.add((Paintable) widget); 62 67 } 63 68 } 64 69 65 70 Set<Widget> parentChanges = new HashSet<Widget>(); 66 for (Container parent : parents) {67 if (!parent. childComponentSizesUpdated()) {71 for (Container parent : childWidgets.keySet()) { 72 if (!parent.requestLayout(childWidgets.get(parent))) { 68 73 parentChanges.add((Widget) parent); 69 74 } … … 73 78 } 74 79 75 /** 76 * Traverses recursively ancestors until ContainerResizedListener child 77 * widget is found. They will delegate it futher if needed. 78 * 79 * @param container 80 */ 81 public static void runDescendentsLayout(HasWidgets container) { 82 final Iterator childWidgets = container.iterator(); 83 while (childWidgets.hasNext()) { 84 final Widget child = (Widget) childWidgets.next(); 85 if (child instanceof ContainerResizedListener) { 86 int w = -1, h = -1; 87 88 if (container instanceof WidgetSpaceAllocator) { 89 w = ((WidgetSpaceAllocator) container) 90 .getAllocatedWidth(child); 91 h = ((WidgetSpaceAllocator) container) 92 .getAllocatedHeight(child); 93 } 94 95 ((ContainerResizedListener) child).iLayout(w, h); 96 } else if (child instanceof HasWidgets) { 97 final HasWidgets childContainer = (HasWidgets) child; 98 runDescendentsLayout(childContainer); 99 } 100 } 101 } 102 103 public interface WidgetSpaceAllocator { 104 int getAllocatedWidth(Widget child); 105 106 int getAllocatedHeight(Widget child); 80 public static float parseRelativeSize(String size) { 81 if (size == null || !size.endsWith("%")) { 82 return -1; 83 } 84 85 try { 86 return Float.parseFloat(size.substring(0, size.length() - 1)); 87 } catch (Exception e) { 88 ClientExceptionHandler.displayError( 89 "Unable to parse relative size", e); 90 } 91 92 return -1; 107 93 } 108 94 … … 114 100 * @return closest parent Container 115 101 */ 116 public static Container get ParentLayout(Widget component) {102 public static Container getLayout(Widget component) { 117 103 Widget parent = component.getParent(); 118 104 while (parent != null && !(parent instanceof Container)) { 119 105 parent = parent.getParent(); 120 106 } 121 if (parent != null && ((Container) parent).hasChildComponent(component)) { 107 if (parent != null) { 108 assert ((Container) parent).hasChildComponent(component); 109 122 110 return (Container) parent; 123 111 } -
trunk/src/com/itmill/toolkit/terminal/gwt/client/ui/IAccordion.java
r5498 r5570 20 20 import com.itmill.toolkit.terminal.gwt.client.Paintable; 21 21 import com.itmill.toolkit.terminal.gwt.client.UIDL; 22 import com.itmill.toolkit.terminal.gwt.client. Util;22 import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size; 23 23 24 24 public class IAccordion extends ITabsheetBase implements … … 129 129 } 130 130 131 private void iLayout() { 132 iLayout(-1, -1); 133 }
