Changeset 3588a2fad in vaadin
- Timestamp:
- 02/10/12 09:35:43 (15 months ago)
- Branches:
- master, 7.0, 7.1
- Children:
- eba294b5
- Parents:
- 81540696
- git-author:
- Henri Sara <hesara@…> (02/10/12 09:35:43)
- git-committer:
- Henri Sara <hesara@…> (02/10/12 09:35:43)
- Location:
- src/com/vaadin
- Files:
-
- 7 edited
-
terminal/PaintTarget.java (modified) (4 diffs)
-
terminal/gwt/client/ApplicationConnection.java (modified) (1 diff)
-
terminal/gwt/client/ui/VAbstractPaintableWidget.java (modified) (1 diff)
-
terminal/gwt/client/ui/layout/CellBasedLayoutPaintable.java (modified) (3 diffs)
-
terminal/gwt/server/AbstractCommunicationManager.java (modified) (1 diff)
-
terminal/gwt/server/JsonPaintTarget.java (modified) (4 diffs)
-
ui/AbstractComponent.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/com/vaadin/terminal/PaintTarget.java
r81540696 r3588a2fad 36 36 public void addSection(String sectionTagName, String sectionData) 37 37 throws PaintException; 38 39 /** 40 * Result of starting to paint a Paintable ( 41 * {@link PaintTarget#startPaintable(Paintable, String)}). 42 * 43 * @since 7.0 44 */ 45 public enum PaintStatus { 46 /** 47 * Painting started, addVariable() and addAttribute() etc. methods may 48 * be called. 49 */ 50 PAINTING, 51 /** 52 * Paintable is cached on the client side and unmodified - only an 53 * indication of that should be painted. 54 */ 55 CACHED, 56 /** 57 * A previously unpainted or painted {@link Paintable} has been queued 58 * be created/update later in a separate change in the same set of 59 * changes. 60 */ 61 DEFER 62 }; 38 63 39 64 /** … … 53 78 * <p> 54 79 * Each paintable being painted should be closed by a matching 55 * {@link #endPaintable(Paintable)}. 80 * {@link #endPaintable(Paintable)} regardless of the {@link PaintStatus} 81 * returned. 56 82 * </p> 57 83 * … … 60 86 * @param tag 61 87 * the name of the start tag. 62 * @return <code>true</code> if paintable found in cache, <code>false</code>63 * otherwise.88 * @return {@link PaintStatus} - ready to paint, already cached on the 89 * client or defer painting to another change 64 90 * @throws PaintException 65 91 * if the paint operation failed. … … 67 93 * @since 7.0 (previously using startTag(Paintable, String)) 68 94 */ 69 public booleanstartPaintable(Paintable paintable, String tag)95 public PaintStatus startPaintable(Paintable paintable, String tag) 70 96 throws PaintException; 71 97 -
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
r947e59a1 r3588a2fad 1866 1866 public VPaintableWidget getPaintable(UIDL uidl) { 1867 1867 final String pid = uidl.getId(); 1868 // the actual content UIDL may be deferred, but it always contains 1869 // enough information to create a paintable instance 1868 1870 if (!paintableMap.hasPaintable(pid)) { 1869 1871 // Create and register a new paintable if no old was found -
src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java
r2bb7aae1 r3588a2fad 107 107 108 108 protected static boolean isRealUpdate(UIDL uidl) { 109 return !isCachedUpdate(uidl) && !uidl.getBooleanAttribute("invisible"); 109 return !isCachedUpdate(uidl) && !uidl.getBooleanAttribute("invisible") 110 && !uidl.hasAttribute("deferred"); 110 111 } 111 112 -
src/com/vaadin/terminal/gwt/client/ui/layout/CellBasedLayoutPaintable.java
r6e7f9728 r3588a2fad 16 16 getWidgetForPaintable().client = client; 17 17 18 // Only non-cached UIDL:s can introduce changes 19 if (isCachedUpdate(uidl)) { 20 return; 18 if (isRealUpdate(uidl)) { 19 /** 20 * Margin and spacing detection depends on classNames and must be 21 * set before setting size. Here just update the details from UIDL 22 * and from overridden setStyleName run actual margin detections. 23 */ 24 updateMarginAndSpacingInfo(uidl); 21 25 } 22 23 /**24 * Margin and spacind detection depends on classNames and must be set25 * before setting size. Here just update the details from UIDL and from26 * overridden setStyleName run actual margin detections.27 */28 updateMarginAndSpacingInfo(uidl);29 26 30 27 /* … … 34 31 super.updateFromUIDL(uidl, client); 35 32 36 handleDynamicDimensions(uidl); 33 if (isRealUpdate(uidl)) { 34 handleDynamicDimensions(uidl); 35 } 37 36 } 38 37 … … 59 58 60 59 void updateMarginAndSpacingInfo(UIDL uidl) { 61 if (!uidl.hasAttribute("invisible")) { 62 int bitMask = uidl.getIntAttribute("margins"); 63 if (getWidgetForPaintable().activeMarginsInfo.getBitMask() != bitMask) { 64 getWidgetForPaintable().activeMarginsInfo = new VMarginInfo( 65 bitMask); 66 getWidgetForPaintable().marginsNeedsRecalculation = true; 67 } 68 boolean spacing = uidl.getBooleanAttribute("spacing"); 69 if (spacing != getWidgetForPaintable().spacingEnabled) { 70 getWidgetForPaintable().marginsNeedsRecalculation = true; 71 getWidgetForPaintable().spacingEnabled = spacing; 72 } 60 int bitMask = uidl.getIntAttribute("margins"); 61 if (getWidgetForPaintable().activeMarginsInfo.getBitMask() != bitMask) { 62 getWidgetForPaintable().activeMarginsInfo = new VMarginInfo(bitMask); 63 getWidgetForPaintable().marginsNeedsRecalculation = true; 64 } 65 boolean spacing = uidl.getBooleanAttribute("spacing"); 66 if (spacing != getWidgetForPaintable().spacingEnabled) { 67 getWidgetForPaintable().marginsNeedsRecalculation = true; 68 getWidgetForPaintable().spacingEnabled = spacing; 73 69 } 74 70 } -
src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
r81540696 r3588a2fad 857 857 if (paintTarget.needsToBePainted(p)) { 858 858 paintTarget.startTag("change"); 859 paintTarget.addAttribute("format", "uidl");860 859 final String pid = getPaintableId(p); 861 860 paintTarget.addAttribute("pid", pid); 862 861 863 // TODO this should paint subcomponents as references and 864 // defer painting their contents to another top-level change 862 // paints subcomponents as references (via 863 // JsonPaintTarget.startPaintable()) and defers painting 864 // their contents to another top-level change (via 865 // queuePaintable()) 865 866 p.paint(paintTarget); 866 867 -
src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java
r81540696 r3588a2fad 12 12 import java.io.Serializable; 13 13 import java.io.StringWriter; 14 import java.util.ArrayList; 14 15 import java.util.Collection; 15 16 import java.util.HashMap; … … 91 92 private Collection<Paintable> identifiersCreatedDueRefPaint; 92 93 94 private Collection<Paintable> deferredPaintables; 95 93 96 private final Collection<Class<? extends Paintable>> usedPaintableTypes = new LinkedList<Class<? extends Paintable>>(); 94 97 … … 120 123 openPaintables = new Stack<Paintable>(); 121 124 openPaintableTags = new Stack<String>(); 125 126 deferredPaintables = new ArrayList<Paintable>(); 122 127 123 128 cacheEnabled = cachingRequired; … … 678 683 * (non-Javadoc) 679 684 * 680 * @see com.vaadin.terminal.PaintTarget#start Tag(com.vaadin.terminal685 * @see com.vaadin.terminal.PaintTarget#startPaintable(com.vaadin.terminal 681 686 * .Paintable, java.lang.String) 682 687 */ 683 public booleanstartPaintable(Paintable paintable, String tagName)688 public PaintStatus startPaintable(Paintable paintable, String tagName) 684 689 throws PaintException { 685 690 startTag(tagName, true); 686 691 final boolean isPreviouslyPainted = manager.hasPaintableId(paintable) 687 692 && (identifiersCreatedDueRefPaint == null || !identifiersCreatedDueRefPaint 688 .contains(paintable)); 693 .contains(paintable)) 694 && !deferredPaintables.contains(paintable); 689 695 final String id = manager.getPaintableId(paintable); 690 696 paintable.addListener(manager); 691 697 addAttribute("id", id); 692 698 693 // TODO if to queue if already painting a paintable 694 // if (openPaintables.isEmpty()) { 699 // queue for painting later if already painting a paintable 700 boolean topLevelPaintableTag = openPaintables.isEmpty(); 701 695 702 openPaintables.push(paintable); 696 703 openPaintableTags.push(tagName); 697 704 698 paintedComponents.add(paintable); 699 // } else { 700 // // notify manager: add to paint queue instead of painting now 701 // manager.queuePaintable(paintable); 702 // // TODO return suitable value to defer painting and close tag if a 703 // // paintable tag is already open 704 // } 705 706 if (paintable instanceof CustomLayout) { 707 customLayoutArgumentsOpen = true; 708 } 709 710 return cacheEnabled && isPreviouslyPainted; 705 if (cacheEnabled && isPreviouslyPainted) { 706 // cached (unmodified) paintable, paint the it now 707 paintedComponents.add(paintable); 708 deferredPaintables.remove(paintable); 709 return PaintStatus.CACHED; 710 } else if (!topLevelPaintableTag) { 711 // notify manager: add to paint queue instead of painting now 712 manager.queuePaintable(paintable); 713 deferredPaintables.add(paintable); 714 return PaintStatus.DEFER; 715 } else { 716 // not a nested paintable, paint the it now 717 paintedComponents.add(paintable); 718 deferredPaintables.remove(paintable); 719 720 if (paintable instanceof CustomLayout) { 721 customLayoutArgumentsOpen = true; 722 } 723 return PaintStatus.PAINTING; 724 } 711 725 } 712 726 -
src/com/vaadin/ui/AbstractComponent.java
r81540696 r3588a2fad 28 28 import com.vaadin.terminal.PaintException; 29 29 import com.vaadin.terminal.PaintTarget; 30 import com.vaadin.terminal.PaintTarget.PaintStatus; 30 31 import com.vaadin.terminal.Resource; 31 32 import com.vaadin.terminal.Terminal; … … 754 755 public void paint(PaintTarget target) throws PaintException { 755 756 final String tag = target.getTag(this); 756 if (!target.startPaintable(this, tag) 757 || repaintRequestListenersNotified) { 758 757 final PaintStatus status = target.startPaintable(this, tag); 758 if (PaintStatus.DEFER == status) { 759 // nothing to do but flag as deferred and close the paintable tag 760 // paint() will be called again later to paint the contents 761 target.addAttribute("deferred", true); 762 } else if (PaintStatus.CACHED == status 763 && !repaintRequestListenersNotified) { 764 // Contents have not changed, only cached presentation can be used 765 target.addAttribute("cached", true); 766 } else { 759 767 // Paint the contents of the component 760 768 … … 810 818 target.addAttribute("invisible", true); 811 819 } 812 } else {813 814 // Contents have not changed, only cached presentation can be used815 target.addAttribute("cached", true);816 820 } 817 821 target.endPaintable(this);
Note: See TracChangeset
for help on using the changeset viewer.
