diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-08-23 11:23:10 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-08-23 11:23:10 +0300 |
commit | af8afede9f0d196a28792dea9e587a1eac829902 (patch) | |
tree | b95ec915d266e8a95f781b27b5b204503d4eb0fd /server | |
parent | 8606feb8596ed8f6cd3ed41160706b692f6f4679 (diff) | |
download | vaadin-framework-af8afede9f0d196a28792dea9e587a1eac829902.tar.gz vaadin-framework-af8afede9f0d196a28792dea9e587a1eac829902.zip |
Handle requestRepaint automatically (#9325)
Diffstat (limited to 'server')
19 files changed, 20 insertions, 140 deletions
diff --git a/server/src/com/vaadin/terminal/AbstractClientConnector.java b/server/src/com/vaadin/terminal/AbstractClientConnector.java index 53b3bb1c9d..2b96c5fb35 100644 --- a/server/src/com/vaadin/terminal/AbstractClientConnector.java +++ b/server/src/com/vaadin/terminal/AbstractClientConnector.java @@ -146,6 +146,12 @@ public abstract class AbstractClientConnector implements ClientConnector { if (null == sharedState) { sharedState = createState(); } + + Root root = getRoot(); + if (root != null && !root.getConnectorTracker().isDirty(this)) { + requestRepaint(); + } + return sharedState; } @@ -280,8 +286,6 @@ public abstract class AbstractClientConnector implements ClientConnector { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { addMethodInvocationToQueue(rpcInterfaceName, method, args); - // TODO no need to do full repaint if only RPC calls - requestRepaint(); return null; } @@ -304,6 +308,8 @@ public abstract class AbstractClientConnector implements ClientConnector { // add to queue pendingInvocations.add(new ClientMethodInvocation(this, interfaceName, method, parameters)); + // TODO no need to do full repaint if only RPC calls + requestRepaint(); } /** diff --git a/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java b/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java index 6153cf2619..f0063a8708 100644 --- a/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java +++ b/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java @@ -60,9 +60,7 @@ public class JavaScriptCallbackHelper implements Serializable { JavaScriptFunction javaScriptCallback) { callbacks.put(functionName, javaScriptCallback); JavaScriptConnectorState state = getConnectorState(); - if (state.getCallbackNames().add(functionName)) { - connector.requestRepaint(); - } + state.getCallbackNames().add(functionName); ensureRpc(); } @@ -100,7 +98,6 @@ public class JavaScriptCallbackHelper implements Serializable { connector.addMethodInvocationToQueue( JavaScriptCallbackRpc.class.getName(), CALL_METHOD, new Object[] { name, args }); - connector.requestRepaint(); } public void registerRpc(Class<?> rpcInterfaceType) { @@ -119,7 +116,6 @@ public class JavaScriptCallbackHelper implements Serializable { } rpcInterfaces.put(interfaceName, methodNames); - connector.requestRepaint(); } } diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index 585e3e2513..a799c5d679 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -148,7 +148,6 @@ public abstract class AbstractComponent extends AbstractClientConnector public void setStyleName(String style) { if (style == null || "".equals(style)) { getState().setStyles(null); - requestRepaint(); return; } if (getState().getStyles() == null) { @@ -162,7 +161,6 @@ public abstract class AbstractComponent extends AbstractClientConnector styles.add(part); } } - requestRepaint(); } @Override @@ -184,7 +182,6 @@ public abstract class AbstractComponent extends AbstractClientConnector List<String> styles = getState().getStyles(); if (!styles.contains(style)) { styles.add(style); - requestRepaint(); } } @@ -197,7 +194,6 @@ public abstract class AbstractComponent extends AbstractClientConnector getState().getStyles().remove(part); } } - requestRepaint(); } } @@ -221,7 +217,6 @@ public abstract class AbstractComponent extends AbstractClientConnector @Override public void setCaption(String caption) { getState().setCaption(caption); - requestRepaint(); } /* @@ -289,7 +284,6 @@ public abstract class AbstractComponent extends AbstractClientConnector @Override public void setIcon(Resource icon) { getState().setIcon(ResourceReference.create(icon)); - requestRepaint(); } /* @@ -309,10 +303,7 @@ public abstract class AbstractComponent extends AbstractClientConnector */ @Override public void setEnabled(boolean enabled) { - if (getState().isEnabled() != enabled) { - getState().setEnabled(enabled); - requestRepaint(); - } + getState().setEnabled(enabled); } /* @@ -355,7 +346,6 @@ public abstract class AbstractComponent extends AbstractClientConnector */ public void setImmediate(boolean immediate) { getState().setImmediate(immediate); - requestRepaint(); } /* @@ -380,7 +370,6 @@ public abstract class AbstractComponent extends AbstractClientConnector } getState().setVisible(visible); - requestRepaint(); if (getParent() != null) { // Must always repaint the parent (at least the hierarchy) when // visibility of a child component changes. @@ -463,7 +452,6 @@ public abstract class AbstractComponent extends AbstractClientConnector */ public void setDescription(String description) { getState().setDescription(description); - requestRepaint(); } /* @@ -566,7 +554,6 @@ public abstract class AbstractComponent extends AbstractClientConnector @Override public void setReadOnly(boolean readOnly) { getState().setReadOnly(readOnly); - requestRepaint(); } /* @@ -718,17 +705,6 @@ public abstract class AbstractComponent extends AbstractClientConnector } } - /* Documentation copied from interface */ - @Override - public void requestRepaint() { - // Invisible components (by flag in this particular component) do not - // need repaints - if (!getState().isVisible()) { - return; - } - super.requestRepaint(); - } - /* General event framework */ private static final Method COMPONENT_EVENT_METHOD = ReflectTools diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index f13c6a3138..23481eca9e 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -360,7 +360,6 @@ public abstract class AbstractField<T> extends AbstractComponent implements private void setModified(boolean modified) { getState().setModified(modified); - requestRepaint(); } /** @@ -1101,7 +1100,6 @@ public abstract class AbstractField<T> extends AbstractComponent implements @Override public void readOnlyStatusChange(Property.ReadOnlyStatusChangeEvent event) { getState().setPropertyReadOnly(event.getProperty().isReadOnly()); - requestRepaint(); } /** @@ -1233,7 +1231,6 @@ public abstract class AbstractField<T> extends AbstractComponent implements @Override public void setTabIndex(int tabIndex) { getState().setTabIndex(tabIndex); - requestRepaint(); } /** @@ -1336,7 +1333,6 @@ public abstract class AbstractField<T> extends AbstractComponent implements @Override public void setRequired(boolean required) { getState().setRequired(required); - requestRepaint(); } /** diff --git a/server/src/com/vaadin/ui/AbstractMedia.java b/server/src/com/vaadin/ui/AbstractMedia.java index 7a29c8f4ce..77c12ac045 100644 --- a/server/src/com/vaadin/ui/AbstractMedia.java +++ b/server/src/com/vaadin/ui/AbstractMedia.java @@ -66,7 +66,6 @@ public abstract class AbstractMedia extends AbstractComponent { if (source != null) { getState().getSources().add(new ResourceReference(source)); getState().getSourceTypes().add(source.getMIMEType()); - requestRepaint(); } } @@ -103,7 +102,6 @@ public abstract class AbstractMedia extends AbstractComponent { */ public void setShowControls(boolean showControls) { getState().setShowControls(showControls); - requestRepaint(); } /** @@ -126,7 +124,6 @@ public abstract class AbstractMedia extends AbstractComponent { */ public void setAltText(String altText) { getState().setAltText(altText); - requestRepaint(); } /** @@ -145,7 +142,6 @@ public abstract class AbstractMedia extends AbstractComponent { */ public void setHtmlContentAllowed(boolean htmlContentAllowed) { getState().setHtmlContentAllowed(htmlContentAllowed); - requestRepaint(); } /** @@ -164,7 +160,6 @@ public abstract class AbstractMedia extends AbstractComponent { */ public void setAutoplay(boolean autoplay) { getState().setAutoplay(autoplay); - requestRepaint(); } /** @@ -181,7 +176,6 @@ public abstract class AbstractMedia extends AbstractComponent { */ public void setMuted(boolean muted) { getState().setMuted(muted); - requestRepaint(); } /** diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java index ce6a3eafbd..0a57cb98c4 100644 --- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -144,13 +144,10 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements private void componentRemoved(Component c) { getState().getChildData().remove(c); - requestRepaint(); } private void componentAdded(Component c) { getState().getChildData().put(c, new ChildComponentData()); - requestRepaint(); - } /** @@ -240,7 +237,6 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements if (childData != null) { // Alignments are bit masks childData.setAlignmentBitmask(alignment.getBitMask()); - requestRepaint(); } else { throw new IllegalArgumentException( "Component must be added to layout before using setComponentAlignment()"); @@ -274,7 +270,6 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements @Override public void setSpacing(boolean spacing) { getState().setSpacing(spacing); - requestRepaint(); } /* @@ -324,8 +319,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements } childData.setExpandRatio(ratio); - requestRepaint(); - }; + } /** * Returns the expand ratio of given component. @@ -404,6 +398,5 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements @Override public void setMargin(MarginInfo marginInfo) { getState().setMarginsBitmask(marginInfo.getBitMask()); - requestRepaint(); } } diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java index 54d15eff26..51d5449fdd 100644 --- a/server/src/com/vaadin/ui/AbstractTextField.java +++ b/server/src/com/vaadin/ui/AbstractTextField.java @@ -324,7 +324,6 @@ public abstract class AbstractTextField extends AbstractField<String> implements */ public void setMaxLength(int maxLength) { getState().setMaxLength(maxLength); - requestRepaint(); } /** @@ -351,7 +350,6 @@ public abstract class AbstractTextField extends AbstractField<String> implements columns = 0; } getState().setColumns(columns); - requestRepaint(); } /** @@ -372,7 +370,6 @@ public abstract class AbstractTextField extends AbstractField<String> implements */ public void setInputPrompt(String inputPrompt) { getState().setInputPrompt(inputPrompt); - requestRepaint(); } /* ** Text Change Events ** */ diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java index c55a955679..8546d8f830 100644 --- a/server/src/com/vaadin/ui/Button.java +++ b/server/src/com/vaadin/ui/Button.java @@ -478,7 +478,6 @@ public class Button extends AbstractComponent implements */ public void setDisableOnClick(boolean disableOnClick) { getState().setDisableOnClick(disableOnClick); - requestRepaint(); } /* @@ -499,7 +498,6 @@ public class Button extends AbstractComponent implements @Override public void setTabIndex(int tabIndex) { getState().setTabIndex(tabIndex); - requestRepaint(); } @Override @@ -526,10 +524,7 @@ public class Button extends AbstractComponent implements * <code>false</code> otherwise */ public void setHtmlContentAllowed(boolean htmlContentAllowed) { - if (getState().isHtmlContentAllowed() != htmlContentAllowed) { - getState().setHtmlContentAllowed(htmlContentAllowed); - requestRepaint(); - } + getState().setHtmlContentAllowed(htmlContentAllowed); } /** diff --git a/server/src/com/vaadin/ui/ConnectorTracker.java b/server/src/com/vaadin/ui/ConnectorTracker.java index 2afe7f9025..72879e0a25 100644 --- a/server/src/com/vaadin/ui/ConnectorTracker.java +++ b/server/src/com/vaadin/ui/ConnectorTracker.java @@ -385,4 +385,8 @@ public class ConnectorTracker implements Serializable { diffStates.put(connector, diffState); } + public boolean isDirty(ClientConnector connector) { + return dirtyConnectors.contains(connector); + } + } diff --git a/server/src/com/vaadin/ui/CustomLayout.java b/server/src/com/vaadin/ui/CustomLayout.java index 0948a92e5b..54308b99c3 100644 --- a/server/src/com/vaadin/ui/CustomLayout.java +++ b/server/src/com/vaadin/ui/CustomLayout.java @@ -145,7 +145,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { getState().getChildLocations().put(c, location); c.setParent(this); fireComponentAttachEvent(c); - requestRepaint(); } /** @@ -176,7 +175,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { slots.values().remove(c); getState().getChildLocations().remove(c); super.removeComponent(c); - requestRepaint(); } /** @@ -251,7 +249,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { slots.put(oldLocation, newComponent); getState().getChildLocations().put(newComponent, oldLocation); getState().getChildLocations().put(oldComponent, newLocation); - requestRepaint(); } } @@ -277,7 +274,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { public void setTemplateName(String templateName) { getState().setTemplateName(templateName); getState().setTemplateContents(null); - requestRepaint(); } /** @@ -288,7 +284,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { public void setTemplateContents(String templateContents) { getState().setTemplateContents(templateContents); getState().setTemplateName(null); - requestRepaint(); } @Override diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java index 689a088c41..8f63ad511a 100644 --- a/server/src/com/vaadin/ui/Form.java +++ b/server/src/com/vaadin/ui/Form.java @@ -820,10 +820,6 @@ public class Form extends AbstractField<Object> implements Item.Editor, // Replace the previous layout layout.setParent(this); getState().setLayout(layout); - - // Hierarchy has changed so we need to repaint (this could be a - // hierarchy repaint only) - requestRepaint(); } /** @@ -1239,11 +1235,6 @@ public class Form extends AbstractField<Object> implements Item.Editor, getState().setFooter(footer); footer.setParent(this); - - // Hierarchy has changed so we need to repaint (this could be a - // hierarchy repaint only) - requestRepaint(); - } @Override diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java index 5abfb1a22e..5de6cc79c7 100644 --- a/server/src/com/vaadin/ui/GridLayout.java +++ b/server/src/com/vaadin/ui/GridLayout.java @@ -962,8 +962,6 @@ public class GridLayout extends AbstractLayout implements } getState().setColumns(columns); - - requestRepaint(); } /** @@ -1006,8 +1004,6 @@ public class GridLayout extends AbstractLayout implements } getState().setRows(rows); - - requestRepaint(); } /** @@ -1132,7 +1128,6 @@ public class GridLayout extends AbstractLayout implements @Override public void setSpacing(boolean spacing) { getState().setSpacing(spacing); - requestRepaint(); } /* @@ -1391,7 +1386,6 @@ public class GridLayout extends AbstractLayout implements @Override public void setMargin(MarginInfo marginInfo) { getState().setMarginsBitmask(marginInfo.getBitMask()); - requestRepaint(); } /* diff --git a/server/src/com/vaadin/ui/JavaScript.java b/server/src/com/vaadin/ui/JavaScript.java index 5984c63e7a..e34ccae82a 100644 --- a/server/src/com/vaadin/ui/JavaScript.java +++ b/server/src/com/vaadin/ui/JavaScript.java @@ -93,9 +93,7 @@ public class JavaScript extends AbstractExtension { */ public void addFunction(String name, JavaScriptFunction function) { functions.put(name, function); - if (getState().getNames().add(name)) { - requestRepaint(); - } + getState().getNames().add(name); } /** @@ -111,9 +109,7 @@ public class JavaScript extends AbstractExtension { */ public void removeFunction(String name) { functions.remove(name); - if (getState().getNames().remove(name)) { - requestRepaint(); - } + getState().getNames().remove(name); } /** diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java index d0a6059865..5055c7e573 100644 --- a/server/src/com/vaadin/ui/Label.java +++ b/server/src/com/vaadin/ui/Label.java @@ -190,7 +190,6 @@ public class Label extends AbstractComponent implements Property<String>, } if (getPropertyDataSource() == null) { getState().text = (String) newStringValue; - requestRepaint(); } else { throw new IllegalStateException( "Label is only a Property.Viewer and cannot update its data source"); @@ -294,7 +293,6 @@ public class Label extends AbstractComponent implements Property<String>, } getState().contentMode = contentMode; - requestRepaint(); } /* Value change events */ @@ -385,7 +383,6 @@ public class Label extends AbstractComponent implements Property<String>, public void valueChange(Property.ValueChangeEvent event) { // Update the internal value from the data source getState().text = getValue(); - requestRepaint(); fireValueChange(); } diff --git a/server/src/com/vaadin/ui/Panel.java b/server/src/com/vaadin/ui/Panel.java index 985eed8a28..1f3b8580f8 100644 --- a/server/src/com/vaadin/ui/Panel.java +++ b/server/src/com/vaadin/ui/Panel.java @@ -318,7 +318,6 @@ public class Panel extends AbstractComponentContainer implements Scrollable, "Scroll offset must be at least 0"); } getState().setScrollLeft(scrollLeft); - requestRepaint(); } /* @@ -333,7 +332,6 @@ public class Panel extends AbstractComponentContainer implements Scrollable, "Scroll offset must be at least 0"); } getState().setScrollTop(scrollTop); - requestRepaint(); } /* Documented in superclass */ @@ -465,7 +463,6 @@ public class Panel extends AbstractComponentContainer implements Scrollable, @Override public void setTabIndex(int tabIndex) { getState().setTabIndex(tabIndex); - requestRepaint(); } /** diff --git a/server/src/com/vaadin/ui/Root.java b/server/src/com/vaadin/ui/Root.java index 4b90d613bb..f96fa1dc5a 100644 --- a/server/src/com/vaadin/ui/Root.java +++ b/server/src/com/vaadin/ui/Root.java @@ -860,8 +860,6 @@ public abstract class Root extends AbstractComponentContainer implements if (content != null) { super.addComponent(content); } - - requestRepaint(); } /** diff --git a/server/src/com/vaadin/ui/TextArea.java b/server/src/com/vaadin/ui/TextArea.java index f885781d46..0dc9722eb3 100644 --- a/server/src/com/vaadin/ui/TextArea.java +++ b/server/src/com/vaadin/ui/TextArea.java @@ -96,7 +96,6 @@ public class TextArea extends AbstractTextField { rows = 0; } getState().setRows(rows); - requestRepaint(); } /** @@ -117,7 +116,6 @@ public class TextArea extends AbstractTextField { */ public void setWordwrap(boolean wordwrap) { getState().setWordwrap(wordwrap); - requestRepaint(); } /** diff --git a/server/src/com/vaadin/ui/Video.java b/server/src/com/vaadin/ui/Video.java index 04ecc9af06..b54d404da6 100644 --- a/server/src/com/vaadin/ui/Video.java +++ b/server/src/com/vaadin/ui/Video.java @@ -80,7 +80,6 @@ public class Video extends AbstractMedia { */ public void setPoster(Resource poster) { getState().setPoster(ResourceReference.create(poster)); - requestRepaint(); } /** diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java index 705e093bce..902d33bc64 100644 --- a/server/src/com/vaadin/ui/Window.java +++ b/server/src/com/vaadin/ui/Window.java @@ -174,14 +174,14 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, final int x = positionx.intValue(); // This is information from the client so it is already using the // position. No need to repaint. - setPositionX(x < 0 ? -1 : x, false); + setPositionX(x < 0 ? -1 : x); } final Integer positiony = (Integer) variables.get("positiony"); if (positiony != null) { final int y = positiony.intValue(); // This is information from the client so it is already using the // position. No need to repaint. - setPositionY(y < 0 ? -1 : y, false); + setPositionY(y < 0 ? -1 : y); } if (isClosable()) { @@ -255,26 +255,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @since 4.0.0 */ public void setPositionX(int positionX) { - setPositionX(positionX, true); - } - - /** - * Sets the distance of Window left border in pixels from left border of the - * containing (main window). - * - * @param positionX - * the Distance of Window left border in pixels from left border - * of the containing (main window). or -1 if unspecified. - * @param repaintRequired - * true if the window needs to be repainted, false otherwise - * @since 6.3.4 - */ - private void setPositionX(int positionX, boolean repaintRequired) { getState().setPositionX(positionX); getState().setCentered(false); - if (repaintRequired) { - requestRepaint(); - } } /** @@ -301,27 +283,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @since 4.0.0 */ public void setPositionY(int positionY) { - setPositionY(positionY, true); - } - - /** - * Sets the distance of Window top border in pixels from top border of the - * containing (main window). - * - * @param positionY - * the Distance of Window top border in pixels from top border of - * the containing (main window). or -1 if unspecified - * @param repaintRequired - * true if the window needs to be repainted, false otherwise - * - * @since 6.3.4 - */ - private void setPositionY(int positionY, boolean repaintRequired) { getState().setPositionY(positionY); getState().setCentered(false); - if (repaintRequired) { - requestRepaint(); - } } private static final Method WINDOW_CLOSE_METHOD; @@ -543,7 +506,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, public void setModal(boolean modal) { getState().setModal(modal); center(); - requestRepaint(); } /** @@ -561,7 +523,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, */ public void setResizable(boolean resizable) { getState().setResizable(resizable); - requestRepaint(); } /** @@ -595,7 +556,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, */ public void setResizeLazy(boolean resizeLazy) { getState().setResizeLazy(resizeLazy); - requestRepaint(); } /** @@ -609,7 +569,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, */ public void center() { getState().setCentered(true); - requestRepaint(); } /** @@ -674,7 +633,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, */ public void setDraggable(boolean draggable) { getState().setDraggable(draggable); - requestRepaint(); } /* |