From 496a0c003995f3f29c2bd1f3bbcc3fb77a9d859f Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 11 Apr 2012 11:08:12 +0300 Subject: [PATCH] Component no longer implements Paintable --- src/com/vaadin/event/ActionManager.java | 9 +- src/com/vaadin/terminal/LegacyPaint.java | 80 ++++++++++ src/com/vaadin/terminal/PaintTarget.java | 30 ++-- src/com/vaadin/terminal/Paintable.java | 147 ------------------ src/com/vaadin/terminal/Vaadin6Component.java | 30 ++++ .../server/AbstractCommunicationManager.java | 27 ++-- .../terminal/gwt/server/JsonPaintTarget.java | 74 ++++----- .../gwt/widgetsetutils/ClassPathExplorer.java | 39 ++--- src/com/vaadin/ui/AbstractComponent.java | 123 +-------------- src/com/vaadin/ui/AbstractField.java | 6 - src/com/vaadin/ui/AbstractMedia.java | 11 +- src/com/vaadin/ui/AbstractOrderedLayout.java | 11 +- src/com/vaadin/ui/AbstractSelect.java | 14 +- src/com/vaadin/ui/AbstractTextField.java | 7 +- src/com/vaadin/ui/Button.java | 13 +- src/com/vaadin/ui/CheckBox.java | 9 +- src/com/vaadin/ui/Component.java | 125 +++++++++++---- src/com/vaadin/ui/CustomField.java | 13 -- src/com/vaadin/ui/DateField.java | 7 +- src/com/vaadin/ui/DirtyConnectorTracker.java | 6 +- src/com/vaadin/ui/DragAndDropWrapper.java | 9 +- src/com/vaadin/ui/Embedded.java | 8 +- src/com/vaadin/ui/Form.java | 10 +- src/com/vaadin/ui/GridLayout.java | 15 +- src/com/vaadin/ui/Label.java | 9 +- src/com/vaadin/ui/Link.java | 10 +- src/com/vaadin/ui/MenuBar.java | 12 +- src/com/vaadin/ui/Panel.java | 16 +- src/com/vaadin/ui/PopupView.java | 12 +- src/com/vaadin/ui/ProgressIndicator.java | 11 +- src/com/vaadin/ui/RichTextArea.java | 10 +- src/com/vaadin/ui/Root.java | 4 - src/com/vaadin/ui/Slider.java | 7 +- src/com/vaadin/ui/TabSheet.java | 13 +- src/com/vaadin/ui/Table.java | 5 +- src/com/vaadin/ui/Upload.java | 6 +- src/com/vaadin/ui/Window.java | 4 +- .../TextFieldWithPropertyFormatter.java | 6 +- .../components/TestComboBoxValueChange.java | 2 +- .../components/TestTextFieldValueChange.java | 2 +- 40 files changed, 410 insertions(+), 542 deletions(-) create mode 100644 src/com/vaadin/terminal/LegacyPaint.java delete mode 100644 src/com/vaadin/terminal/Paintable.java create mode 100644 src/com/vaadin/terminal/Vaadin6Component.java diff --git a/src/com/vaadin/event/ActionManager.java b/src/com/vaadin/event/ActionManager.java index f362eb6c0a..08e9c85043 100644 --- a/src/com/vaadin/event/ActionManager.java +++ b/src/com/vaadin/event/ActionManager.java @@ -11,6 +11,7 @@ import com.vaadin.event.Action.Handler; import com.vaadin.terminal.KeyMapper; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; +import com.vaadin.terminal.VariableOwner; import com.vaadin.ui.Component; /** @@ -47,7 +48,8 @@ public class ActionManager implements Action.Container, Action.Handler, } - public ActionManager(T viewer) { + public ActionManager( + T viewer) { this.viewer = viewer; } @@ -57,7 +59,8 @@ public class ActionManager implements Action.Container, Action.Handler, } } - public void setViewer(T viewer) { + public void setViewer( + T viewer) { if (viewer == this.viewer) { return; } @@ -153,7 +156,7 @@ public class ActionManager implements Action.Container, Action.Handler, if (!actions.isEmpty() || clientHasActions) { actionMapper = new KeyMapper(); - paintTarget.addVariable(viewer, "action", ""); + paintTarget.addVariable((VariableOwner) viewer, "action", ""); paintTarget.startTag("actions"); for (final Action a : actions) { diff --git a/src/com/vaadin/terminal/LegacyPaint.java b/src/com/vaadin/terminal/LegacyPaint.java new file mode 100644 index 0000000000..692c05c5f6 --- /dev/null +++ b/src/com/vaadin/terminal/LegacyPaint.java @@ -0,0 +1,80 @@ +package com.vaadin.terminal; + +import com.vaadin.terminal.PaintTarget.PaintStatus; +import com.vaadin.ui.Component; +import com.vaadin.ui.HasComponents; + +public class LegacyPaint { + /** + * + *

+ * Paints the Paintable into a UIDL stream. This method creates the UIDL + * sequence describing it and outputs it to the given UIDL stream. + *

+ * + *

+ * It is called when the contents of the component should be painted in + * response to the component first being shown or having been altered so + * that its visual representation is changed. + *

+ * + *

+ * Do not override this to paint your component. Override + * {@link #paintContent(PaintTarget)} instead. + *

+ * + * + * @param target + * the target UIDL stream where the component should paint itself + * to. + * @throws PaintException + * if the paint operation failed. + */ + public static void paint(Component component, PaintTarget target) + throws PaintException { + // Only paint content of visible components. + if (!isVisibleInContext(component)) { + return; + } + + final String tag = target.getTag(component); + final PaintStatus status = target.startPaintable(component, tag); + if (PaintStatus.CACHED == status) { + // nothing to do but flag as cached and close the paintable tag + target.addAttribute("cached", true); + } else { + // Paint the contents of the component + if (component instanceof Vaadin6Component) { + ((Vaadin6Component) component).paintContent(target); + } + + } + target.endPaintable(component); + + } + + /** + * Checks if the component is visible and its parent is visible, + * recursively. + *

+ * This is only a helper until paint is moved away from this class. + * + * @return + */ + protected static boolean isVisibleInContext(Component c) { + HasComponents p = c.getParent(); + while (p != null) { + if (!p.isVisible()) { + return false; + } + p = p.getParent(); + } + if (c.getParent() != null && !c.getParent().isComponentVisible(c)) { + return false; + } + + // All parents visible, return this state + return c.isVisible(); + } + +} diff --git a/src/com/vaadin/terminal/PaintTarget.java b/src/com/vaadin/terminal/PaintTarget.java index 57dd711ba5..9cfa324133 100644 --- a/src/com/vaadin/terminal/PaintTarget.java +++ b/src/com/vaadin/terminal/PaintTarget.java @@ -9,6 +9,7 @@ import java.util.Map; import com.vaadin.terminal.StreamVariable.StreamingStartEvent; import com.vaadin.terminal.gwt.client.ApplicationConnection; +import com.vaadin.terminal.gwt.server.ClientConnector; /** * This interface defines the methods for painting XML to the UIDL stream. @@ -38,7 +39,7 @@ public interface PaintTarget extends Serializable { /** * Result of starting to paint a Paintable ( - * {@link PaintTarget#startPaintable(Paintable, String)}). + * {@link PaintTarget#startPaintable(ClientConnector, String)}). * * @since 7.0 */ @@ -72,8 +73,8 @@ public interface PaintTarget extends Serializable { *

*

* Each paintable being painted should be closed by a matching - * {@link #endPaintable(Paintable)} regardless of the {@link PaintStatus} - * returned. + * {@link #endPaintable(ClientConnector)} regardless of the + * {@link PaintStatus} returned. *

* * @param paintable @@ -88,15 +89,15 @@ public interface PaintTarget extends Serializable { * @see #startTag(String) * @since 7.0 (previously using startTag(Paintable, String)) */ - public PaintStatus startPaintable(Paintable paintable, String tag) + public PaintStatus startPaintable(ClientConnector paintable, String tag) throws PaintException; /** * Prints paintable element end tag. * - * Calls to {@link #startPaintable(Paintable, String)} should be matched by - * {@link #endPaintable(Paintable)}. If the parent tag is closed before - * every child tag is closed a PaintException is raised. + * Calls to {@link #startPaintable(ClientConnector, String)}should be + * matched by {@link #endPaintable(ClientConnector)}. If the parent tag is + * closed before every child tag is closed a PaintException is raised. * * @param paintable * the paintable to close. @@ -104,7 +105,7 @@ public interface PaintTarget extends Serializable { * if the paint operation failed. * @since 7.0 (previously using engTag(String)) */ - public void endPaintable(Paintable paintable) throws PaintException; + public void endPaintable(ClientConnector paintable) throws PaintException; /** * Prints element start tag. @@ -288,7 +289,7 @@ public interface PaintTarget extends Serializable { * the Paintable to be referenced on client side * @throws PaintException */ - public void addAttribute(String name, Paintable value) + public void addAttribute(String name, ClientConnector value) throws PaintException; /** @@ -420,8 +421,8 @@ public interface PaintTarget extends Serializable { * @throws PaintException * if the paint oparation fails */ - public void addVariable(VariableOwner owner, String name, Paintable value) - throws PaintException; + public void addVariable(VariableOwner owner, String name, + ClientConnector value) throws PaintException; /** * Adds a upload stream type variable. @@ -492,14 +493,15 @@ public interface PaintTarget extends Serializable { /** * @return the "tag" string used in communication to present given - * {@link Paintable} type. Terminal may define how to present - * paintable. + * {@link ClientConnector} type. Terminal may define how to present + * the connector. */ - public String getTag(Paintable paintable); + public String getTag(ClientConnector paintable); /** * @return true if a full repaint has been requested. E.g. refresh in a * browser window or such. */ public boolean isFullRepaint(); + } diff --git a/src/com/vaadin/terminal/Paintable.java b/src/com/vaadin/terminal/Paintable.java deleted file mode 100644 index d043cb2606..0000000000 --- a/src/com/vaadin/terminal/Paintable.java +++ /dev/null @@ -1,147 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ - -package com.vaadin.terminal; - -import java.io.Serializable; -import java.util.EventObject; - -/** - * Interface implemented by all classes that can be painted. Classes - * implementing this interface know how to output themselves to a UIDL stream - * and that way describing to the terminal how it should be displayed in the UI. - * - * @author Vaadin Ltd. - * @version - * @VERSION@ - * @since 3.0 - */ -public interface Paintable extends java.util.EventListener, Serializable { - - /** - *

- * Paints the Paintable into a UIDL stream. This method creates the UIDL - * sequence describing it and outputs it to the given UIDL stream. - *

- * - *

- * It is called when the contents of the component should be painted in - * response to the component first being shown or having been altered so - * that its visual representation is changed. - *

- * - * @param target - * the target UIDL stream where the component should paint itself - * to. - * @throws PaintException - * if the paint operation failed. - */ - public void paint(PaintTarget target) throws PaintException; - - /** - * Requests that the paintable should be repainted as soon as possible. - */ - public void requestRepaint(); - - /** - * Adds an unique id for component that get's transferred to terminal for - * testing purposes. Keeping identifiers unique throughout the Application - * instance is on programmers responsibility. - *

- * Note, that with the current terminal implementation the identifier cannot - * be changed while the component is visible. This means that the identifier - * should be set before the component is painted for the first time and kept - * the same while visible in the client. - * - * @param id - * A short (< 20 chars) alphanumeric id - */ - public void setDebugId(String id); - - /** - * Get's currently set debug identifier - * - * @return current debug id, null if not set - */ - public String getDebugId(); - - /** - * Repaint request event is thrown when the paintable needs to be repainted. - * This is typically done when the paint method would return - * dissimilar UIDL from the previous call of the method. - */ - @SuppressWarnings("serial") - public class RepaintRequestEvent extends EventObject { - - /** - * Constructs a new event. - * - * @param source - * the paintable needing repaint. - */ - public RepaintRequestEvent(Paintable source) { - super(source); - } - - /** - * Gets the paintable needing repainting. - * - * @return Paintable for which the paint method will return - * dissimilar UIDL from the previous call of the method. - */ - public Paintable getPaintable() { - return (Paintable) getSource(); - } - } - - /** - * Listens repaint requests. The repaintRequested method is - * called when the paintable needs to be repainted. This is typically done - * when the paint method would return dissimilar UIDL from the - * previous call of the method. - */ - public interface RepaintRequestListener extends Serializable { - - /** - * Receives repaint request events. - * - * @param event - * the repaint request event specifying the paintable source. - */ - public void repaintRequested(RepaintRequestEvent event); - } - - /** - * Adds repaint request listener. In order to assure that no repaint - * requests are missed, the new repaint listener should paint the paintable - * right after adding itself as listener. - * - * @param listener - * the listener to be added. - */ - public void addListener(RepaintRequestListener listener); - - /** - * Removes repaint request listener. - * - * @param listener - * the listener to be removed. - */ - public void removeListener(RepaintRequestListener listener); - - /** - * Request sending of repaint events on any further visible changes. - * Normally the paintable only send up to one repaint request for listeners - * after paint as the paintable as the paintable assumes that the listeners - * already know about the repaint need. This method resets the assumtion. - * Paint implicitly does the assumtion reset functionality implemented by - * this method. - *

- * This method is normally used only by the terminals to note paintables - * about implicit repaints (painting the component without actually invoking - * paint method). - *

- */ - public void requestRepaintRequests(); -} diff --git a/src/com/vaadin/terminal/Vaadin6Component.java b/src/com/vaadin/terminal/Vaadin6Component.java new file mode 100644 index 0000000000..5b81336254 --- /dev/null +++ b/src/com/vaadin/terminal/Vaadin6Component.java @@ -0,0 +1,30 @@ +package com.vaadin.terminal; + +import java.util.EventListener; + +import com.vaadin.ui.Component; + +public interface Vaadin6Component extends VariableOwner, Component, + EventListener { + + /** + *

+ * Paints the Paintable into a UIDL stream. This method creates the UIDL + * sequence describing it and outputs it to the given UIDL stream. + *

+ * + *

+ * It is called when the contents of the component should be painted in + * response to the component first being shown or having been altered so + * that its visual representation is changed. + *

+ * + * @param target + * the target UIDL stream where the component should paint itself + * to. + * @throws PaintException + * if the paint operation failed. + */ + public void paintContent(PaintTarget target) throws PaintException; + +} diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 17e504a3bb..25f3154fd2 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -48,15 +48,16 @@ import com.vaadin.external.json.JSONArray; import com.vaadin.external.json.JSONException; import com.vaadin.external.json.JSONObject; import com.vaadin.terminal.CombinedRequest; +import com.vaadin.terminal.LegacyPaint; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Paintable; import com.vaadin.terminal.RequestHandler; import com.vaadin.terminal.StreamVariable; import com.vaadin.terminal.StreamVariable.StreamingEndEvent; import com.vaadin.terminal.StreamVariable.StreamingErrorEvent; import com.vaadin.terminal.Terminal.ErrorEvent; import com.vaadin.terminal.Terminal.ErrorListener; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.VariableOwner; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedResponse; @@ -81,14 +82,6 @@ import com.vaadin.ui.Window; * JavaScript) and the server side components. Its client side counterpart is * {@link ApplicationConnection}. * - * A server side component sends its state to the client in a paint request (see - * {@link Paintable} and {@link PaintTarget} on the server side). The client - * widget receives these paint requests as calls to - * {@link com.vaadin.terminal.gwt.client.ComponentConnector#updateFromUIDL()}. - * The client component communicates back to the server by sending a list of - * variable changes (see {@link ApplicationConnection#updateVariable()} and - * {@link VariableOwner#changeVariables(Object, Map)}). - * * TODO Document better! */ @SuppressWarnings("serial") @@ -836,8 +829,8 @@ public abstract class AbstractCommunicationManager implements Serializable { // widget mapping JSONObject connectorTypes = new JSONObject(); - for (Connector connector : dirtyVisibleConnectors) { - String connectorType = paintTarget.getTag((Paintable) connector); + for (ClientConnector connector : dirtyVisibleConnectors) { + String connectorType = paintTarget.getTag(connector); try { connectorTypes.put(connector.getConnectorId(), connectorType); } catch (JSONException e) { @@ -1105,22 +1098,22 @@ public abstract class AbstractCommunicationManager implements Serializable { private void legacyPaint(PaintTarget paintTarget, ArrayList dirtyVisibleConnectors) throws PaintException { - List legacyComponents = new ArrayList(); + List legacyComponents = new ArrayList(); for (Connector connector : dirtyVisibleConnectors) { - if (connector instanceof Paintable) { + if (connector instanceof Vaadin6Component) { // All legacy Components must be Paintables as Component extends // Paintable in Vaadin 6 - legacyComponents.add((Component) connector); + legacyComponents.add((Vaadin6Component) connector); } } - sortByHierarchy(legacyComponents); - for (Component c : legacyComponents) { + sortByHierarchy((List) legacyComponents); + for (Vaadin6Component c : legacyComponents) { logger.info("Painting legacy Component " + c.getClass().getName() + "@" + Integer.toHexString(c.hashCode())); paintTarget.startTag("change"); final String pid = c.getConnectorId(); paintTarget.addAttribute("pid", pid); - c.paint(paintTarget); + LegacyPaint.paint(c, paintTarget); paintTarget.endTag("change"); } diff --git a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java index 78fc4d5fba..0140c0f799 100644 --- a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java +++ b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java @@ -20,7 +20,6 @@ import com.vaadin.terminal.ApplicationResource; import com.vaadin.terminal.ExternalResource; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Paintable; import com.vaadin.terminal.Resource; import com.vaadin.terminal.StreamVariable; import com.vaadin.terminal.ThemeResource; @@ -55,7 +54,7 @@ public class JsonPaintTarget implements PaintTarget { private final Stack openJsonTags; // these match each other element-wise - private final Stack openPaintables; + private final Stack openPaintables; private final Stack openPaintableTags; private final PrintWriter uidlBuffer; @@ -74,8 +73,6 @@ public class JsonPaintTarget implements PaintTarget { private boolean cacheEnabled = false; - private final Collection paintedComponents = new HashSet(); - private final Set> usedClientConnectors = new HashSet>(); /** @@ -103,7 +100,7 @@ public class JsonPaintTarget implements PaintTarget { mOpenTags = new Stack(); openJsonTags = new Stack(); - openPaintables = new Stack(); + openPaintables = new Stack(); openPaintableTags = new Stack(); cacheEnabled = cachingRequired; @@ -402,9 +399,9 @@ public class JsonPaintTarget implements PaintTarget { } - public void addAttribute(String name, Paintable value) + public void addAttribute(String name, ClientConnector value) throws PaintException { - final String id = getPaintIdentifier(value); + final String id = value.getConnectorId(); addAttribute(name, id); } @@ -420,9 +417,8 @@ public class JsonPaintTarget implements PaintTarget { Object key = it.next(); Object mapValue = value.get(key); sb.append("\""); - if (key instanceof Paintable) { - Paintable paintable = (Paintable) key; - sb.append(getPaintIdentifier(paintable)); + if (key instanceof ClientConnector) { + sb.append(((ClientConnector) key).getConnectorId()); } else { sb.append(escapeJSON(key.toString())); } @@ -471,10 +467,9 @@ public class JsonPaintTarget implements PaintTarget { tag.addVariable(new StringVariable(owner, name, escapeJSON(value))); } - public void addVariable(VariableOwner owner, String name, Paintable value) - throws PaintException { - tag.addVariable(new StringVariable(owner, name, - getPaintIdentifier(value))); + public void addVariable(VariableOwner owner, String name, + ClientConnector value) throws PaintException { + tag.addVariable(new StringVariable(owner, name, value.getConnectorId())); } public void addVariable(VariableOwner owner, String name, int value) @@ -650,19 +645,18 @@ public class JsonPaintTarget implements PaintTarget { * @see com.vaadin.terminal.PaintTarget#startPaintable(com.vaadin.terminal * .Paintable, java.lang.String) */ - public PaintStatus startPaintable(Paintable paintable, String tagName) + public PaintStatus startPaintable(ClientConnector connector, String tagName) throws PaintException { boolean topLevelPaintable = openPaintables.isEmpty(); - logger.fine("startPaintable for " + paintable.getClass().getName() - + "@" + Integer.toHexString(paintable.hashCode())); + logger.fine("startPaintable for " + connector.getClass().getName() + + "@" + Integer.toHexString(connector.hashCode())); startTag(tagName, true); - openPaintables.push(paintable); + openPaintables.push(connector); openPaintableTags.push(tagName); - final String id = getPaintIdentifier(paintable); - addAttribute("id", id); + addAttribute("id", connector.getConnectorId()); // Only paint top level paintables. All sub paintables are marked as // queued and painted separately later. @@ -670,24 +664,21 @@ public class JsonPaintTarget implements PaintTarget { return PaintStatus.CACHED; } - // not a nested paintable, paint the it now - paintedComponents.add(paintable); - - if (paintable instanceof CustomLayout) { + if (connector instanceof CustomLayout) { customLayoutArgumentsOpen = true; } return PaintStatus.PAINTING; } - public void endPaintable(Paintable paintable) throws PaintException { + public void endPaintable(ClientConnector paintable) throws PaintException { logger.fine("endPaintable for " + paintable.getClass().getName() + "@" + Integer.toHexString(paintable.hashCode())); - Paintable openPaintable = openPaintables.peek(); + ClientConnector openPaintable = openPaintables.peek(); if (paintable != openPaintable) { throw new PaintException("Invalid UIDL: closing wrong paintable: '" - + getPaintIdentifier(paintable) + "' expected: '" - + getPaintIdentifier(openPaintable) + "'."); + + paintable.getConnectorId() + "' expected: '" + + openPaintable.getConnectorId() + "'."); } // remove paintable from the stack openPaintables.pop(); @@ -695,15 +686,6 @@ public class JsonPaintTarget implements PaintTarget { endTag(openTag); } - public String getPaintIdentifier(Paintable paintable) throws PaintException { - // TODO This should be unnecessary as Paintable must be a Connector - if (paintable instanceof Connector) { - return ((Connector) paintable).getConnectorId(); - } - throw new RuntimeException("Paintable " + paintable - + " must implement Connector"); - } - /* * (non-Javadoc) * @@ -979,25 +961,21 @@ public class JsonPaintTarget implements PaintTarget { } @SuppressWarnings("unchecked") - public String getTag(Paintable paintable) { - if (!(paintable instanceof ClientConnector)) { - throw new IllegalArgumentException( - "Tags are only available for ClientConnectors"); - } - Class paintableClass = paintable.getClass(); - while (paintableClass.isAnonymousClass()) { - paintableClass = (Class) paintableClass + public String getTag(ClientConnector clientConnector) { + Class clientConnectorClass = clientConnector + .getClass(); + while (clientConnectorClass.isAnonymousClass()) { + clientConnectorClass = (Class) clientConnectorClass .getSuperclass(); } - Class clazz = paintableClass; + Class clazz = clientConnectorClass; while (!usedClientConnectors.contains(clazz) && clazz.getSuperclass() != null && ClientConnector.class.isAssignableFrom(clazz)) { usedClientConnectors.add((Class) clazz); clazz = clazz.getSuperclass(); } - return manager - .getTagForType((Class) paintableClass); + return manager.getTagForType(clientConnectorClass); } Collection> getUsedClientConnectors() { diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java b/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java index d1b554c358..6a0aa0f4c2 100644 --- a/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java +++ b/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java @@ -31,7 +31,7 @@ import java.util.logging.Logger; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; import com.vaadin.event.dd.acceptcriteria.ClientCriterion; -import com.vaadin.terminal.Paintable; +import com.vaadin.terminal.gwt.server.ClientConnector; /** * Utility class to collect widgetset related information from classpath. @@ -99,22 +99,20 @@ public class ClassPathExplorer { * As a side effect, also accept criteria are searched under the same class * path entries and added into the acceptCriterion collection. * - * @return a collection of {@link Paintable} classes + * @return a collection of {@link ClientConnector} classes */ - public static Collection> getPaintablesHavingWidgetAnnotation() { - logger.info("Searching for paintables.."); + public static void findAcceptCriteria() { + logger.info("Searching for accept criteria.."); long start = System.currentTimeMillis(); - Collection> paintables = new HashSet>(); Set keySet = classpathLocations.keySet(); for (String url : keySet) { - logger.fine("Searching for paintables in " + logger.fine("Searching for accept criteria in " + classpathLocations.get(url)); - searchForPaintables(classpathLocations.get(url), url, paintables); + searchForPaintables(classpathLocations.get(url), url); } long end = System.currentTimeMillis(); logger.info("Search took " + (end - start) + "ms"); - return paintables; } @@ -128,7 +126,7 @@ public class ClassPathExplorer { if (acceptCriterion.isEmpty()) { // accept criterion are searched as a side effect, normally after // paintable detection - getPaintablesHavingWidgetAnnotation(); + findAcceptCriteria(); } return acceptCriterion; } @@ -456,11 +454,9 @@ public class ClassPathExplorer { * * @param location * @param locationString - * @param paintables */ private final static void searchForPaintables(URL location, - String locationString, - Collection> paintables) { + String locationString) { // Get a File object for the package File directory = new File(location.getFile()); @@ -477,7 +473,7 @@ public class ClassPathExplorer { String packageName = locationString .substring(locationString.lastIndexOf("/") + 1); classname = packageName + "." + classname; - tryToAdd(classname, paintables); + tryToAdd(classname); } } } else { @@ -509,7 +505,7 @@ public class ClassPathExplorer { classname = classname.substring(1); } classname = classname.replace('/', '.'); - tryToAdd(classname, paintables); + tryToAdd(classname); } } } @@ -542,16 +538,12 @@ public class ClassPathExplorer { /** * Checks a class for the {@link ClientCriterion} annotations, and adds it - * to the appropriate collection if it has either. + * to the appropriate collection. * * @param fullclassName - * @param paintables - * the collection to which to add server side classes with - * {@link ClientCriterion} annotation */ @SuppressWarnings("unchecked") - private static void tryToAdd(final String fullclassName, - Collection> paintables) { + private static void tryToAdd(final String fullclassName) { PrintStream out = System.out; PrintStream err = System.err; Throwable errorToShow = null; @@ -663,10 +655,9 @@ public class ClassPathExplorer { * Test method for helper tool */ public static void main(String[] args) { - Collection> paintables = ClassPathExplorer - .getPaintablesHavingWidgetAnnotation(); - logger.info("Found annotated paintables:"); - for (Class cls : paintables) { + ClassPathExplorer.findAcceptCriteria(); + logger.info("Found client criteria:"); + for (Class cls : acceptCriterion) { logger.info(cls.getCanonicalName()); } diff --git a/src/com/vaadin/ui/AbstractComponent.java b/src/com/vaadin/ui/AbstractComponent.java index 8c26911a9a..b54f5ee948 100644 --- a/src/com/vaadin/ui/AbstractComponent.java +++ b/src/com/vaadin/ui/AbstractComponent.java @@ -29,9 +29,6 @@ import com.vaadin.event.EventRouter; import com.vaadin.event.MethodEventSource; import com.vaadin.event.ShortcutListener; import com.vaadin.terminal.ErrorMessage; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.PaintTarget.PaintStatus; import com.vaadin.terminal.Resource; import com.vaadin.terminal.Terminal; import com.vaadin.terminal.gwt.client.ComponentState; @@ -172,8 +169,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource /** * Sets and replaces all previous style names of the component. This method - * will trigger a {@link com.vaadin.terminal.Paintable.RepaintRequestEvent - * RepaintRequestEvent}. + * will trigger a {@link RepaintRequestEvent}. * * @param style * the new style of the component. @@ -273,8 +269,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource /** * Sets the component's caption String. Caption is the visible * name of the component. This method will trigger a - * {@link com.vaadin.terminal.Paintable.RepaintRequestEvent - * RepaintRequestEvent}. + * {@link RepaintRequestEvent}. * * @param caption * the new caption String for the component. @@ -343,8 +338,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource /** * Sets the component's icon. This method will trigger a - * {@link com.vaadin.terminal.Paintable.RepaintRequestEvent - * RepaintRequestEvent}. + * {@link RepaintRequestEvent}. * * @param icon * the icon to be shown with the component's caption. @@ -413,8 +407,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource /** * Sets the component's immediate mode to the specified status. This method - * will trigger a {@link com.vaadin.terminal.Paintable.RepaintRequestEvent - * RepaintRequestEvent}. + * will trigger a {@link RepaintRequestEvent}. * * @param immediate * the boolean value specifying if the component should be in the @@ -518,8 +511,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource /** * Sets the component's description. See {@link #getDescription()} for more * information on what the description is. This method will trigger a - * {@link com.vaadin.terminal.Paintable.RepaintRequestEvent - * RepaintRequestEvent}. + * {@link RepaintRequestEvent}. * * The description is displayed as HTML/XHTML in tooltips or directly in * certain components so care should be taken to avoid creating the @@ -708,84 +700,6 @@ public abstract class AbstractComponent implements Component, MethodEventSource } } - /* Component painting */ - - @Deprecated - public void requestRepaintRequests() { - // This is no longer needed. Remove when Component no longer extends - // Paintable - } - - /** - * - *

- * Paints the Paintable into a UIDL stream. This method creates the UIDL - * sequence describing it and outputs it to the given UIDL stream. - *

- * - *

- * It is called when the contents of the component should be painted in - * response to the component first being shown or having been altered so - * that its visual representation is changed. - *

- * - *

- * Do not override this to paint your component. Override - * {@link #paintContent(PaintTarget)} instead. - *

- * - * - * @param target - * the target UIDL stream where the component should paint itself - * to. - * @throws PaintException - * if the paint operation failed. - */ - public void paint(PaintTarget target) throws PaintException { - // Only paint content of visible components. - if (!isVisibleInContext()) { - return; - } - - final String tag = target.getTag(this); - final PaintStatus status = target.startPaintable(this, tag); - if (PaintStatus.CACHED == status) { - // nothing to do but flag as cached and close the paintable tag - target.addAttribute("cached", true); - } else { - // Paint the contents of the component - paintContent(target); - - } - target.endPaintable(this); - - } - - /** - * Checks if the component is visible and its parent is visible, - * recursively. - *

- * This is only a helper until paint is moved away from this class. - * - * @return - */ - @Deprecated - protected boolean isVisibleInContext() { - HasComponents p = getParent(); - while (p != null) { - if (!p.isVisible()) { - return false; - } - p = p.getParent(); - } - if (getParent() != null && !getParent().isComponentVisible(this)) { - return false; - } - - // All parents visible, return this state - return isVisible(); - } - /** * Build CSS compatible string representation of height. * @@ -812,22 +726,6 @@ public abstract class AbstractComponent implements Component, MethodEventSource } } - /** - * Paints any needed component-specific things to the given UIDL stream. The - * more general {@link #paint(PaintTarget)} method handles all general - * attributes common to all components, and it calls this method to paint - * any component-specific attributes to the UIDL stream. - * - * @param target - * the target UIDL stream where the component should paint itself - * to - * @throws PaintException - * if the paint operation failed. - */ - public void paintContent(PaintTarget target) throws PaintException { - - } - /** * Returns the shared state bean with information to be sent from the server * to the client. @@ -961,17 +859,6 @@ public abstract class AbstractComponent implements Component, MethodEventSource } } - /* Component variable changes */ - - /* - * Invoked when the value of a variable has changed. Don't add a JavaDoc - * comment here, we use the default documentation from implemented - * interface. - */ - public void changeVariables(Object source, Map variables) { - - } - /* General event framework */ private static final Method COMPONENT_EVENT_METHOD = ReflectTools diff --git a/src/com/vaadin/ui/AbstractField.java b/src/com/vaadin/ui/AbstractField.java index 9f5516a6ce..7ad2f20296 100644 --- a/src/com/vaadin/ui/AbstractField.java +++ b/src/com/vaadin/ui/AbstractField.java @@ -12,7 +12,6 @@ import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; -import java.util.Map; import java.util.logging.Logger; import com.vaadin.Application; @@ -1301,11 +1300,6 @@ public abstract class AbstractField extends AbstractComponent implements setInternalValue(convertFromDataSource(event.getProperty().getValue())); } - @Override - public void changeVariables(Object source, Map variables) { - super.changeVariables(source, variables); - } - /** * {@inheritDoc} */ diff --git a/src/com/vaadin/ui/AbstractMedia.java b/src/com/vaadin/ui/AbstractMedia.java index e164b087f3..09cfd5ff12 100644 --- a/src/com/vaadin/ui/AbstractMedia.java +++ b/src/com/vaadin/ui/AbstractMedia.java @@ -8,10 +8,12 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Resource; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.gwt.client.ui.MediaBaseConnector; import com.vaadin.terminal.gwt.client.ui.MediaBaseConnector.MediaControl; @@ -20,7 +22,8 @@ import com.vaadin.terminal.gwt.client.ui.MediaBaseConnector.MediaControl; * * @author Vaadin Ltd */ -public class AbstractMedia extends AbstractComponent { +public class AbstractMedia extends AbstractComponent implements + Vaadin6Component { private List sources = new ArrayList(); @@ -189,9 +192,7 @@ public class AbstractMedia extends AbstractComponent { getRpcProxy(MediaControl.class).play(); } - @Override public void paintContent(PaintTarget target) throws PaintException { - super.paintContent(target); target.addAttribute(MediaBaseConnector.ATTR_CONTROLS, isShowControls()); if (getAltText() != null) { target.addAttribute(MediaBaseConnector.ATTR_ALT_TEXT, getAltText()); @@ -208,4 +209,8 @@ public class AbstractMedia extends AbstractComponent { } target.addAttribute(MediaBaseConnector.ATTR_MUTED, isMuted()); } + + public void changeVariables(Object source, Map variables) { + // TODO Remove once Vaadin6Component is no longer implemented + } } diff --git a/src/com/vaadin/ui/AbstractOrderedLayout.java b/src/com/vaadin/ui/AbstractOrderedLayout.java index 97929dcf25..f7c4917650 100644 --- a/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -15,6 +15,7 @@ import com.vaadin.event.LayoutEvents.LayoutClickNotifier; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Sizeable; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.gwt.client.Connector; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.AbstractOrderedLayoutConnector.AbstractOrderedLayoutServerRPC; @@ -23,7 +24,8 @@ import com.vaadin.terminal.gwt.client.ui.LayoutClickEventHandler; @SuppressWarnings("serial") public abstract class AbstractOrderedLayout extends AbstractLayout implements - Layout.AlignmentHandler, Layout.SpacingHandler, LayoutClickNotifier { + Layout.AlignmentHandler, Layout.SpacingHandler, LayoutClickNotifier, + Vaadin6Component { private AbstractOrderedLayoutServerRPC rpc = new AbstractOrderedLayoutServerRPC() { @@ -175,15 +177,16 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements * @throws PaintException * if the paint operation failed. */ - @Override public void paintContent(PaintTarget target) throws PaintException { - super.paintContent(target); - // Add child component alignment info to layout tag target.addAttribute("alignments", componentToAlignment); target.addAttribute("expandRatios", componentToExpandRatio); } + public void changeVariables(Object source, Map variables) { + // TODO Remove once Vaadin6Component is no longer implemented + } + /* Documented in superclass */ public void replaceComponent(Component oldComponent, Component newComponent) { diff --git a/src/com/vaadin/ui/AbstractSelect.java b/src/com/vaadin/ui/AbstractSelect.java index defe6e9a86..e586810b2d 100644 --- a/src/com/vaadin/ui/AbstractSelect.java +++ b/src/com/vaadin/ui/AbstractSelect.java @@ -32,6 +32,7 @@ import com.vaadin.terminal.KeyMapper; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Resource; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.gwt.client.ui.dd.VIsOverId; import com.vaadin.terminal.gwt.client.ui.dd.VItemIdIs; import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; @@ -60,7 +61,7 @@ import com.vaadin.ui.AbstractSelect.ItemCaptionMode; public abstract class AbstractSelect extends AbstractField implements Container, Container.Viewer, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.ItemSetChangeNotifier, - Container.ItemSetChangeListener { + Container.ItemSetChangeListener, Vaadin6Component { public enum ItemCaptionMode { /** @@ -322,12 +323,8 @@ public abstract class AbstractSelect extends AbstractField implements * @throws PaintException * if the paint operation failed. */ - @Override public void paintContent(PaintTarget target) throws PaintException { - // Paints field properties - super.paintContent(target); - // Paints select attributes if (isMultiSelect()) { target.addAttribute("selectmode", "multi"); @@ -428,9 +425,7 @@ public abstract class AbstractSelect extends AbstractField implements * @see com.vaadin.ui.AbstractComponent#changeVariables(java.lang.Object, * java.util.Map) */ - @Override public void changeVariables(Object source, Map variables) { - super.changeVariables(source, variables); // New option entered (and it is allowed) if (isNewItemsAllowed()) { @@ -582,10 +577,7 @@ public abstract class AbstractSelect extends AbstractField implements * to the terminal or null if no items is visible. */ public Collection getVisibleItemIds() { - if (isVisibleInContext()) { - return getItemIds(); - } - return null; + return getItemIds(); } /* Property methods */ diff --git a/src/com/vaadin/ui/AbstractTextField.java b/src/com/vaadin/ui/AbstractTextField.java index 96d8a11410..fec13db248 100644 --- a/src/com/vaadin/ui/AbstractTextField.java +++ b/src/com/vaadin/ui/AbstractTextField.java @@ -18,10 +18,11 @@ import com.vaadin.event.FieldEvents.TextChangeListener; import com.vaadin.event.FieldEvents.TextChangeNotifier; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.gwt.client.ui.VTextField; public abstract class AbstractTextField extends AbstractField implements - BlurNotifier, FocusNotifier, TextChangeNotifier { + BlurNotifier, FocusNotifier, TextChangeNotifier, Vaadin6Component { /** * Value formatter used to format the string contents. @@ -99,9 +100,7 @@ public abstract class AbstractTextField extends AbstractField implements super(); } - @Override public void paintContent(PaintTarget target) throws PaintException { - super.paintContent(target); if (getMaxLength() >= 0) { target.addAttribute("maxLength", getMaxLength()); @@ -185,12 +184,10 @@ public abstract class AbstractTextField extends AbstractField implements } } - @Override public void changeVariables(Object source, Map variables) { changingVariables = true; try { - super.changeVariables(source, variables); if (variables.containsKey(VTextField.VAR_CURSOR)) { Integer object = (Integer) variables.get(VTextField.VAR_CURSOR); diff --git a/src/com/vaadin/ui/Button.java b/src/com/vaadin/ui/Button.java index 5c66d57939..68e75b2c69 100644 --- a/src/com/vaadin/ui/Button.java +++ b/src/com/vaadin/ui/Button.java @@ -18,6 +18,9 @@ import com.vaadin.event.ShortcutAction; import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutAction.ModifierKey; import com.vaadin.event.ShortcutListener; +import com.vaadin.terminal.PaintException; +import com.vaadin.terminal.PaintTarget; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.ButtonConnector.ButtonServerRpc; import com.vaadin.terminal.gwt.client.ui.ButtonState; @@ -35,7 +38,7 @@ import com.vaadin.ui.Component.Focusable; @SuppressWarnings("serial") public class Button extends AbstractComponent implements FieldEvents.BlurNotifier, FieldEvents.FocusNotifier, Focusable, - Action.ShortcutNotifier { + Action.ShortcutNotifier, Vaadin6Component { private ButtonServerRpc rpc = new ButtonServerRpc() { public void click(MouseEventDetails mouseEventDetails) { @@ -87,10 +90,7 @@ public class Button extends AbstractComponent implements * @param source * @param variables */ - @Override public void changeVariables(Object source, Map variables) { - super.changeVariables(source, variables); - if (variables.containsKey(FocusEvent.EVENT_ID)) { fireEvent(new FocusEvent(this)); } @@ -99,6 +99,10 @@ public class Button extends AbstractComponent implements } } + public void paintContent(PaintTarget target) throws PaintException { + // TODO Remove once Vaadin6Component is no longer implemented + } + /** * Click event. This event is thrown, when the button is clicked. * @@ -499,4 +503,5 @@ public class Button extends AbstractComponent implements public ButtonState getState() { return (ButtonState) super.getState(); } + } diff --git a/src/com/vaadin/ui/CheckBox.java b/src/com/vaadin/ui/CheckBox.java index f51110755e..e53bb5a3b7 100644 --- a/src/com/vaadin/ui/CheckBox.java +++ b/src/com/vaadin/ui/CheckBox.java @@ -13,9 +13,11 @@ import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.gwt.client.ui.VCheckBox; -public class CheckBox extends AbstractField { +public class CheckBox extends AbstractField implements + Vaadin6Component { /** * Creates a new checkbox. */ @@ -64,18 +66,13 @@ public class CheckBox extends AbstractField { return Boolean.class; } - @Override public void paintContent(PaintTarget target) throws PaintException { - super.paintContent(target); - Boolean value = getValue(); boolean booleanValue = (value != null) ? value : false; target.addVariable(this, VCheckBox.VARIABLE_STATE, booleanValue); } - @Override public void changeVariables(Object source, Map variables) { - super.changeVariables(source, variables); if (!isReadOnly() && variables.containsKey(VCheckBox.VARIABLE_STATE)) { // Gets the new and old states diff --git a/src/com/vaadin/ui/Component.java b/src/com/vaadin/ui/Component.java index 3589b43391..eacf17b6a7 100644 --- a/src/com/vaadin/ui/Component.java +++ b/src/com/vaadin/ui/Component.java @@ -12,7 +12,6 @@ import java.util.Locale; import com.vaadin.Application; import com.vaadin.event.FieldEvents; import com.vaadin.terminal.ErrorMessage; -import com.vaadin.terminal.Paintable; import com.vaadin.terminal.Resource; import com.vaadin.terminal.Sizeable; import com.vaadin.terminal.VariableOwner; @@ -53,8 +52,8 @@ import com.vaadin.terminal.gwt.server.RpcTarget; * @VERSION@ * @since 3.0 */ -public interface Component extends ClientConnector, Paintable, VariableOwner, - Sizeable, Serializable, RpcTarget { +public interface Component extends ClientConnector, Sizeable, Serializable, + RpcTarget { /** * Gets all user-defined CSS style names of a component. If the component @@ -117,9 +116,7 @@ public interface Component extends ClientConnector, Paintable, VariableOwner, *

* *

- * This method will trigger a - * {@link com.vaadin.terminal.Paintable.RepaintRequestEvent - * RepaintRequestEvent}. + * This method will trigger a {@link RepaintRequestEvent}. *

* * @param style @@ -161,9 +158,7 @@ public interface Component extends ClientConnector, Paintable, VariableOwner, * * *

- * This method will trigger a - * {@link com.vaadin.terminal.Paintable.RepaintRequestEvent - * RepaintRequestEvent}. + * This method will trigger a {@link RepaintRequestEvent}. *

* * @param style @@ -185,9 +180,7 @@ public interface Component extends ClientConnector, Paintable, VariableOwner, * style names defined in Vaadin or GWT can not be removed. *

* - * * This method will trigger a - * {@link com.vaadin.terminal.Paintable.RepaintRequestEvent - * RepaintRequestEvent}. + * * This method will trigger a {@link RepaintRequestEvent}. * * @param style * the style name or style names to be removed @@ -236,10 +229,9 @@ public interface Component extends ClientConnector, Paintable, VariableOwner, * * *

- * This method will trigger a - * {@link com.vaadin.terminal.Paintable.RepaintRequestEvent - * RepaintRequestEvent} for the component and, if it is a - * {@link ComponentContainer}, for all its children recursively. + * This method will trigger a {@link RepaintRequestEvent} for the component + * and, if it is a {@link ComponentContainer}, for all its children + * recursively. *

* * @param enabled @@ -389,9 +381,7 @@ public interface Component extends ClientConnector, Paintable, VariableOwner, *

* *

- * This method will trigger a - * {@link com.vaadin.terminal.Paintable.RepaintRequestEvent - * RepaintRequestEvent}. + * This method will trigger a {@link RepaintRequestEvent}. *

* * @param readOnly @@ -458,10 +448,8 @@ public interface Component extends ClientConnector, Paintable, VariableOwner, *

* *

- * This method will trigger a - * {@link com.vaadin.terminal.Paintable.RepaintRequestEvent - * RepaintRequestEvent}. A reimplementation should call the superclass - * implementation. + * This method will trigger a {@link RepaintRequestEvent}. A + * reimplementation should call the superclass implementation. *

* * @param caption @@ -531,9 +519,7 @@ public interface Component extends ClientConnector, Paintable, VariableOwner, * {@code v-caption} . *

* - * This method will trigger a - * {@link com.vaadin.terminal.Paintable.RepaintRequestEvent - * RepaintRequestEvent}. + * This method will trigger a {@link RepaintRequestEvent}. * * @param icon * the icon of the component. If null, no icon is shown and it @@ -718,6 +704,92 @@ public interface Component extends ClientConnector, Paintable, VariableOwner, */ public void updateState(); + /** + * Adds an unique id for component that get's transferred to terminal for + * testing purposes. Keeping identifiers unique is the responsibility of the + * programmer. + * + * @param id + * An alphanumeric id + */ + public void setDebugId(String id); + + /** + * Get's currently set debug identifier + * + * @return current debug id, null if not set + */ + public String getDebugId(); + + /** + * Requests that the component should be repainted as soon as possible. + */ + public void requestRepaint(); + + /** + * Repaint request event is thrown when the connector needs to be repainted. + * This is typically done when the paint method would return + * dissimilar UIDL from the previous call of the method. + */ + @SuppressWarnings("serial") + public static class RepaintRequestEvent extends EventObject { + + /** + * Constructs a new event. + * + * @param source + * the paintable needing repaint. + */ + public RepaintRequestEvent(ClientConnector source) { + super(source); + } + + /** + * Gets the connector needing repainting. + * + * @return Paintable for which the paint method will return + * dissimilar UIDL from the previous call of the method. + */ + public ClientConnector getConnector() { + return (ClientConnector) getSource(); + } + } + + /** + * Listens repaint requests. The repaintRequested method is + * called when the paintable needs to be repainted. This is typically done + * when the paint method would return dissimilar UIDL from the + * previous call of the method. + */ + public interface RepaintRequestListener extends Serializable { + + /** + * Receives repaint request events. + * + * @param event + * the repaint request event specifying the paintable source. + */ + public void repaintRequested(RepaintRequestEvent event); + } + + /** + * Adds repaint request listener. In order to assure that no repaint + * requests are missed, the new repaint listener should paint the paintable + * right after adding itself as listener. + * + * @param listener + * the listener to be added. + */ + public void addListener(RepaintRequestListener listener); + + /** + * Removes repaint request listener. + * + * @param listener + * the listener to be removed. + */ + public void removeListener(RepaintRequestListener listener); + /* Component event framework */ /** @@ -1106,4 +1178,5 @@ public interface Component extends ClientConnector, Paintable, VariableOwner, public void setTabIndex(int tabIndex); } + } diff --git a/src/com/vaadin/ui/CustomField.java b/src/com/vaadin/ui/CustomField.java index c333309fbf..806ee91335 100644 --- a/src/com/vaadin/ui/CustomField.java +++ b/src/com/vaadin/ui/CustomField.java @@ -9,8 +9,6 @@ import java.lang.reflect.Method; import java.util.Iterator; import com.vaadin.data.Property; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; /** * A {@link Field} whose UI content can be constructed by the user, enabling the @@ -84,17 +82,6 @@ public abstract class CustomField extends AbstractField implements getContent().detach(); } - @Override - public void paintContent(PaintTarget target) throws PaintException { - if (getContent() == null) { - throw new IllegalStateException( - "Content component or layout of the field must be set before the " - + getClass().getName() + " can be painted"); - } - - getContent().paint(target); - } - /** * Returns the content (UI) of the custom component. * diff --git a/src/com/vaadin/ui/DateField.java b/src/com/vaadin/ui/DateField.java index 311019c2e4..0d0bb04fc9 100644 --- a/src/com/vaadin/ui/DateField.java +++ b/src/com/vaadin/ui/DateField.java @@ -26,6 +26,7 @@ import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.gwt.client.ui.VDateField; /** @@ -50,7 +51,7 @@ import com.vaadin.terminal.gwt.client.ui.VDateField; */ @SuppressWarnings("serial") public class DateField extends AbstractField implements - FieldEvents.BlurNotifier, FieldEvents.FocusNotifier { + FieldEvents.BlurNotifier, FieldEvents.FocusNotifier, Vaadin6Component { /** * Resolutions for DateFields @@ -285,9 +286,7 @@ public class DateField extends AbstractField implements * Paints this component. Don't add a JavaDoc comment here, we use the * default documentation from implemented interface. */ - @Override public void paintContent(PaintTarget target) throws PaintException { - super.paintContent(target); // Adds the locale as attribute final Locale l = getLocale(); @@ -340,9 +339,7 @@ public class DateField extends AbstractField implements * comment here, we use the default documentation from implemented * interface. */ - @Override public void changeVariables(Object source, Map variables) { - super.changeVariables(source, variables); if (!isReadOnly() && (variables.containsKey("year") diff --git a/src/com/vaadin/ui/DirtyConnectorTracker.java b/src/com/vaadin/ui/DirtyConnectorTracker.java index fa5604eb5f..84df7e7c7c 100644 --- a/src/com/vaadin/ui/DirtyConnectorTracker.java +++ b/src/com/vaadin/ui/DirtyConnectorTracker.java @@ -9,10 +9,10 @@ import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; -import com.vaadin.terminal.Paintable.RepaintRequestEvent; -import com.vaadin.terminal.Paintable.RepaintRequestListener; import com.vaadin.terminal.gwt.server.AbstractCommunicationManager; import com.vaadin.terminal.gwt.server.ClientConnector; +import com.vaadin.ui.Component.RepaintRequestEvent; +import com.vaadin.ui.Component.RepaintRequestListener; /** * A class that tracks dirty {@link ClientConnector}s. A {@link ClientConnector} @@ -44,7 +44,7 @@ public class DirtyConnectorTracker implements RepaintRequestListener { } public void repaintRequested(RepaintRequestEvent event) { - markDirty((Component) event.getPaintable()); + markDirty((Component) event.getConnector()); } public void componentAttached(Component component) { diff --git a/src/com/vaadin/ui/DragAndDropWrapper.java b/src/com/vaadin/ui/DragAndDropWrapper.java index 937942f3d3..babe36be72 100644 --- a/src/com/vaadin/ui/DragAndDropWrapper.java +++ b/src/com/vaadin/ui/DragAndDropWrapper.java @@ -20,6 +20,7 @@ import com.vaadin.event.dd.TargetDetailsImpl; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.StreamVariable; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.VDragAndDropWrapper; import com.vaadin.terminal.gwt.client.ui.dd.HorizontalDropLocation; @@ -27,7 +28,7 @@ import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; @SuppressWarnings("serial") public class DragAndDropWrapper extends CustomComponent implements DropTarget, - DragSource { + DragSource, Vaadin6Component { public class WrapperTransferable extends TransferableImpl { @@ -213,9 +214,11 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, requestRepaint(); } - @Override + public void changeVariables(Object source, Map variables) { + // TODO Remove once Vaadin6Component is no longer implemented + } + public void paintContent(PaintTarget target) throws PaintException { - super.paintContent(target); target.addAttribute(VDragAndDropWrapper.DRAG_START_MODE, dragStartMode.ordinal()); if (getDropHandler() != null) { diff --git a/src/com/vaadin/ui/Embedded.java b/src/com/vaadin/ui/Embedded.java index 8d31e0060d..797b486337 100644 --- a/src/com/vaadin/ui/Embedded.java +++ b/src/com/vaadin/ui/Embedded.java @@ -13,6 +13,7 @@ import com.vaadin.event.MouseEvents.ClickListener; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Resource; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.ClickEventHandler; import com.vaadin.terminal.gwt.client.ui.EmbeddedConnector; @@ -27,7 +28,7 @@ import com.vaadin.terminal.gwt.client.ui.EmbeddedConnector.EmbeddedServerRPC; * @since 3.0 */ @SuppressWarnings("serial") -public class Embedded extends AbstractComponent { +public class Embedded extends AbstractComponent implements Vaadin6Component { /** * General object type. @@ -119,7 +120,6 @@ public class Embedded extends AbstractComponent { /** * Invoked when the component state should be painted. */ - @Override public void paintContent(PaintTarget target) throws PaintException { switch (type) { @@ -521,4 +521,8 @@ public class Embedded extends AbstractComponent { ClickEvent.class, listener); } + public void changeVariables(Object source, Map variables) { + // TODO Remove once Vaadin6Component is no longer implemented + } + } diff --git a/src/com/vaadin/ui/Form.java b/src/com/vaadin/ui/Form.java index fa0e1d1e31..3ff164cc53 100644 --- a/src/com/vaadin/ui/Form.java +++ b/src/com/vaadin/ui/Form.java @@ -30,6 +30,7 @@ import com.vaadin.terminal.ErrorMessage; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.UserError; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.gwt.client.ui.FormConnector.FormState; /** @@ -67,7 +68,8 @@ import com.vaadin.terminal.gwt.client.ui.FormConnector.FormState; */ @Deprecated public class Form extends AbstractField implements Item.Editor, - Buffered, Item, Validatable, Action.Notifier, HasComponents { + Buffered, Item, Validatable, Action.Notifier, HasComponents, + Vaadin6Component { private Object propertyValue; @@ -192,19 +194,13 @@ public class Form extends AbstractField implements Item.Editor, } /* Documented in interface */ - @Override public void paintContent(PaintTarget target) throws PaintException { - super.paintContent(target); - if (ownActionManager != null) { ownActionManager.paintActions(null, target); } } - @Override public void changeVariables(Object source, Map variables) { - super.changeVariables(source, variables); - // Actions if (ownActionManager != null) { ownActionManager.handleActions(variables, this); diff --git a/src/com/vaadin/ui/GridLayout.java b/src/com/vaadin/ui/GridLayout.java index c076c8a273..bdc08607e4 100644 --- a/src/com/vaadin/ui/GridLayout.java +++ b/src/com/vaadin/ui/GridLayout.java @@ -15,8 +15,10 @@ import java.util.Map.Entry; import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.event.LayoutEvents.LayoutClickNotifier; +import com.vaadin.terminal.LegacyPaint; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.gwt.client.Connector; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.GridLayoutConnector.GridLayoutServerRPC; @@ -51,7 +53,8 @@ import com.vaadin.terminal.gwt.client.ui.LayoutClickEventHandler; */ @SuppressWarnings("serial") public class GridLayout extends AbstractLayout implements - Layout.AlignmentHandler, Layout.SpacingHandler, LayoutClickNotifier { + Layout.AlignmentHandler, Layout.SpacingHandler, LayoutClickNotifier, + Vaadin6Component { private GridLayoutServerRPC rpc = new GridLayoutServerRPC() { @@ -428,6 +431,10 @@ public class GridLayout extends AbstractLayout implements return components.size(); } + public void changeVariables(Object source, Map variables) { + // TODO Remove once Vaadin6Component is no longer implemented + } + /** * Paints the contents of this component. * @@ -436,11 +443,7 @@ public class GridLayout extends AbstractLayout implements * @throws PaintException * if the paint operation failed. */ - @Override public void paintContent(PaintTarget target) throws PaintException { - - super.paintContent(target); - // TODO refactor attribute names in future release. target.addAttribute("structuralChange", structuralChange); structuralChange = false; @@ -541,7 +544,7 @@ public class GridLayout extends AbstractLayout implements if (rows > 1) { target.addAttribute("h", rows); } - area.getComponent().paint(target); + LegacyPaint.paint(area.getComponent(), target); alignmentsArray[index++] = String .valueOf(getComponentAlignment(area.getComponent()) diff --git a/src/com/vaadin/ui/Label.java b/src/com/vaadin/ui/Label.java index c69a68002b..e52090aa5f 100644 --- a/src/com/vaadin/ui/Label.java +++ b/src/com/vaadin/ui/Label.java @@ -5,11 +5,13 @@ package com.vaadin.ui; import java.lang.reflect.Method; +import java.util.Map; import com.vaadin.data.Property; import com.vaadin.data.util.ObjectProperty; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; +import com.vaadin.terminal.Vaadin6Component; /** * Label component for showing non-editable short texts. @@ -39,7 +41,7 @@ import com.vaadin.terminal.PaintTarget; // TODO generics for interface Property public class Label extends AbstractComponent implements Property, Property.Viewer, Property.ValueChangeListener, - Property.ValueChangeNotifier, Comparable { + Property.ValueChangeNotifier, Comparable, Vaadin6Component { /** * Content modes defining how the client should interpret a Label's value. @@ -255,7 +257,6 @@ public class Label extends AbstractComponent implements Property, * @throws PaintException * if the Paint Operation fails. */ - @Override public void paintContent(PaintTarget target) throws PaintException { String uidlName = contentMode.getUidlName(); if (uidlName != null) { @@ -565,4 +566,8 @@ public class Label extends AbstractComponent implements Property, return res.toString(); } + public void changeVariables(Object source, Map variables) { + // TODO Remove once Vaadin6Component is no longer implemented + } + } diff --git a/src/com/vaadin/ui/Link.java b/src/com/vaadin/ui/Link.java index 4f57acc6e5..ed5ffbba3a 100644 --- a/src/com/vaadin/ui/Link.java +++ b/src/com/vaadin/ui/Link.java @@ -4,9 +4,12 @@ package com.vaadin.ui; +import java.util.Map; + import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Resource; +import com.vaadin.terminal.Vaadin6Component; /** * Link is used to create external or internal URL links. @@ -17,7 +20,7 @@ import com.vaadin.terminal.Resource; * @since 3.0 */ @SuppressWarnings("serial") -public class Link extends AbstractComponent { +public class Link extends AbstractComponent implements Vaadin6Component { /* Target window border type constant: No window border */ public static final int TARGET_BORDER_NONE = Root.BORDER_NONE; @@ -92,7 +95,6 @@ public class Link extends AbstractComponent { * @throws PaintException * if the paint operation failed. */ - @Override public void paintContent(PaintTarget target) throws PaintException { if (resource != null) { @@ -230,4 +232,8 @@ public class Link extends AbstractComponent { this.resource = resource; requestRepaint(); } + + public void changeVariables(Object source, Map variables) { + // TODO Remove once Vaadin6Component is no longer implemented + } } diff --git a/src/com/vaadin/ui/MenuBar.java b/src/com/vaadin/ui/MenuBar.java index a58a742e8c..519f9e7372 100644 --- a/src/com/vaadin/ui/MenuBar.java +++ b/src/com/vaadin/ui/MenuBar.java @@ -13,6 +13,7 @@ import java.util.Stack; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Resource; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.gwt.client.ui.VMenuBar; /** @@ -23,7 +24,7 @@ import com.vaadin.terminal.gwt.client.ui.VMenuBar; *

*/ @SuppressWarnings("serial") -public class MenuBar extends AbstractComponent { +public class MenuBar extends AbstractComponent implements Vaadin6Component { // Items of the top-level menu private final List menuItems; @@ -38,12 +39,7 @@ public class MenuBar extends AbstractComponent { private boolean htmlContentAllowed; /** Paint (serialise) the component for the client. */ - @Override public void paintContent(PaintTarget target) throws PaintException { - - // Superclass writes any common attributes in the paint target. - super.paintContent(target); - target.addAttribute(VMenuBar.OPEN_ROOT_MENU_ON_HOWER, openRootOnHover); if (isHtmlContentAllowed()) { @@ -129,7 +125,6 @@ public class MenuBar extends AbstractComponent { } /** Deserialize changes received from client. */ - @Override public void changeVariables(Object source, Map variables) { Stack items = new Stack(); boolean found = false; @@ -731,8 +726,7 @@ public class MenuBar extends AbstractComponent { /** * Sets the items's description. See {@link #getDescription()} for more * information on what the description is. This method will trigger a - * {@link com.vaadin.terminal.Paintable.RepaintRequestEvent - * RepaintRequestEvent}. + * {@link RepaintRequestEvent}. * * @param description * the new description string for the component. diff --git a/src/com/vaadin/ui/Panel.java b/src/com/vaadin/ui/Panel.java index ad0ff4222f..7045313ce5 100644 --- a/src/com/vaadin/ui/Panel.java +++ b/src/com/vaadin/ui/Panel.java @@ -15,9 +15,9 @@ import com.vaadin.event.MouseEvents.ClickListener; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Scrollable; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.ClickEventHandler; -import com.vaadin.terminal.gwt.client.ui.PanelConnector; import com.vaadin.terminal.gwt.client.ui.PanelConnector.PanelServerRPC; import com.vaadin.terminal.gwt.client.ui.PanelConnector.PanelState; import com.vaadin.ui.Component.Focusable; @@ -33,7 +33,8 @@ import com.vaadin.ui.Component.Focusable; @SuppressWarnings("serial") public class Panel extends AbstractComponentContainer implements Scrollable, ComponentContainer.ComponentAttachListener, - ComponentContainer.ComponentDetachListener, Action.Notifier, Focusable { + ComponentContainer.ComponentDetachListener, Action.Notifier, Focusable, + Vaadin6Component { /** * Content of the panel. @@ -221,14 +222,10 @@ public class Panel extends AbstractComponentContainer implements Scrollable, * (non-Javadoc) * * @see - * com.vaadin.ui.AbstractComponent#paintContent(com.vaadin.terminal.PaintTarget - * ) + * com.vaadin.terminal.Vaadin6Component#paintContent(com.vaadin.terminal + * .PaintTarget) */ - @Override public void paintContent(PaintTarget target) throws PaintException { - // This is needed for now for paint to be ever run for the child - content.paint(target); - if (actionManager != null) { actionManager.paintActions(null, target); } @@ -289,10 +286,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, * @see com.vaadin.terminal.VariableOwner#changeVariables(Object, Map) */ @SuppressWarnings("unchecked") - @Override public void changeVariables(Object source, Map variables) { - super.changeVariables(source, variables); - // Get new size final Integer newWidth = (Integer) variables.get("width"); final Integer newHeight = (Integer) variables.get("height"); diff --git a/src/com/vaadin/ui/PopupView.java b/src/com/vaadin/ui/PopupView.java index 6babb5854f..911d926053 100644 --- a/src/com/vaadin/ui/PopupView.java +++ b/src/com/vaadin/ui/PopupView.java @@ -8,8 +8,10 @@ import java.lang.reflect.Method; import java.util.Iterator; import java.util.Map; +import com.vaadin.terminal.LegacyPaint; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; +import com.vaadin.terminal.Vaadin6Component; /** * @@ -21,7 +23,8 @@ import com.vaadin.terminal.PaintTarget; * @author Vaadin Ltd. */ @SuppressWarnings("serial") -public class PopupView extends AbstractComponentContainer { +public class PopupView extends AbstractComponentContainer implements + Vaadin6Component { private Content content; private boolean hideOnMouseOut; @@ -304,11 +307,7 @@ public class PopupView extends AbstractComponentContainer { * * @see com.vaadin.ui.AbstractComponent#paintContent(com.vaadin.terminal.PaintTarget) */ - @Override public void paintContent(PaintTarget target) throws PaintException { - // Superclass writes any common attributes in the paint target. - super.paintContent(target); - String html = content.getMinimizedValueAsHTML(); if (html == null) { html = ""; @@ -319,7 +318,7 @@ public class PopupView extends AbstractComponentContainer { // Only paint component to client if we know that the popup is showing if (isPopupVisible()) { target.startTag("popupComponent"); - visibleComponent.paint(target); + LegacyPaint.paint(visibleComponent, target); target.endTag("popupComponent"); } @@ -332,7 +331,6 @@ public class PopupView extends AbstractComponentContainer { * @see com.vaadin.ui.AbstractComponent#changeVariables(java.lang.Object, * java.util.Map) */ - @Override public void changeVariables(Object source, Map variables) { if (variables.containsKey("popupVisibility")) { setPopupVisible(((Boolean) variables.get("popupVisibility")) diff --git a/src/com/vaadin/ui/ProgressIndicator.java b/src/com/vaadin/ui/ProgressIndicator.java index f080199c72..4d585cfdd7 100644 --- a/src/com/vaadin/ui/ProgressIndicator.java +++ b/src/com/vaadin/ui/ProgressIndicator.java @@ -4,10 +4,13 @@ package com.vaadin.ui; +import java.util.Map; + import com.vaadin.data.Property; import com.vaadin.data.util.ObjectProperty; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; +import com.vaadin.terminal.Vaadin6Component; /** * ProgressIndicator is component that shows user state of a @@ -25,7 +28,7 @@ import com.vaadin.terminal.PaintTarget; */ @SuppressWarnings("serial") public class ProgressIndicator extends AbstractField implements - Property.Viewer, Property.ValueChangeListener { + Property.Viewer, Property.ValueChangeListener, Vaadin6Component { /** * Content mode, where the label contains only plain text. The getValue() @@ -108,7 +111,6 @@ public class ProgressIndicator extends AbstractField implements * @throws PaintException * if the Paint Operation fails. */ - @Override public void paintContent(PaintTarget target) throws PaintException { target.addAttribute("indeterminate", indeterminate); target.addAttribute("pollinginterval", pollingInterval); @@ -245,4 +247,9 @@ public class ProgressIndicator extends AbstractField implements return pollingInterval; } + public void changeVariables(Object source, Map variables) { + // TODO Remove once Vaadin6Component is no longer implemented + + } + } diff --git a/src/com/vaadin/ui/RichTextArea.java b/src/com/vaadin/ui/RichTextArea.java index 5c052e78f4..16d4761b40 100644 --- a/src/com/vaadin/ui/RichTextArea.java +++ b/src/com/vaadin/ui/RichTextArea.java @@ -10,6 +10,7 @@ import java.util.Map; import com.vaadin.data.Property; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; +import com.vaadin.terminal.Vaadin6Component; /** * A simple RichTextArea to edit HTML format text. @@ -18,7 +19,8 @@ import com.vaadin.terminal.PaintTarget; * {@link RichTextArea} may produce unexpected results as formatting is counted * into length of field. */ -public class RichTextArea extends AbstractField { +public class RichTextArea extends AbstractField implements + Vaadin6Component { /** * Value formatter used to format the string contents. @@ -101,7 +103,6 @@ public class RichTextArea extends AbstractField { setCaption(caption); } - @Override public void paintContent(PaintTarget target) throws PaintException { if (selectAll) { target.addAttribute("selectAll", true); @@ -119,7 +120,6 @@ public class RichTextArea extends AbstractField { } target.addVariable(this, "text", value); - super.paintContent(target); } @Override @@ -185,11 +185,7 @@ public class RichTextArea extends AbstractField { } } - @Override public void changeVariables(Object source, Map variables) { - - super.changeVariables(source, variables); - // Sets the text if (variables.containsKey("text") && !isReadOnly()) { diff --git a/src/com/vaadin/ui/Root.java b/src/com/vaadin/ui/Root.java index 3fcf70b922..6850c88a81 100644 --- a/src/com/vaadin/ui/Root.java +++ b/src/com/vaadin/ui/Root.java @@ -494,7 +494,6 @@ public abstract class Root extends AbstractComponentContainer implements return application; } - @Override public void paintContent(PaintTarget target) throws PaintException { // Open requested resource synchronized (openList) { @@ -600,10 +599,7 @@ public abstract class Root extends AbstractComponentContainer implements } @SuppressWarnings("unchecked") - @Override public void changeVariables(Object source, Map variables) { - super.changeVariables(source, variables); - if (variables.containsKey(CLICK_EVENT_ID)) { fireClick((Map) variables.get(CLICK_EVENT_ID)); } diff --git a/src/com/vaadin/ui/Slider.java b/src/com/vaadin/ui/Slider.java index 4509f7af1e..dc5dc0be98 100644 --- a/src/com/vaadin/ui/Slider.java +++ b/src/com/vaadin/ui/Slider.java @@ -8,6 +8,7 @@ import java.util.Map; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; +import com.vaadin.terminal.Vaadin6Component; /** * A component for selecting a numerical value within a range. @@ -45,7 +46,7 @@ import com.vaadin.terminal.PaintTarget; * * @author Vaadin Ltd. */ -public class Slider extends AbstractField { +public class Slider extends AbstractField implements Vaadin6Component { public static final int ORIENTATION_HORIZONTAL = 0; @@ -277,9 +278,7 @@ public class Slider extends AbstractField { super.setValue(newFieldValue); } - @Override public void paintContent(PaintTarget target) throws PaintException { - super.paintContent(target); target.addAttribute("min", min); if (max > min) { @@ -308,9 +307,7 @@ public class Slider extends AbstractField { * @param source * @param variables */ - @Override public void changeVariables(Object source, Map variables) { - super.changeVariables(source, variables); if (variables.containsKey("value")) { final Object value = variables.get("value"); final Double newValue = new Double(value.toString()); diff --git a/src/com/vaadin/ui/TabSheet.java b/src/com/vaadin/ui/TabSheet.java index 0c7dea1e52..109429473c 100644 --- a/src/com/vaadin/ui/TabSheet.java +++ b/src/com/vaadin/ui/TabSheet.java @@ -20,9 +20,11 @@ import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.event.FieldEvents.FocusNotifier; import com.vaadin.terminal.ErrorMessage; import com.vaadin.terminal.KeyMapper; +import com.vaadin.terminal.LegacyPaint; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Resource; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.gwt.client.ui.TabsheetBaseConnector; import com.vaadin.terminal.gwt.client.ui.VTabsheet; import com.vaadin.ui.Component.Focusable; @@ -59,7 +61,7 @@ import com.vaadin.ui.themes.Runo; * @since 3.0 */ public class TabSheet extends AbstractComponentContainer implements Focusable, - FocusNotifier, BlurNotifier { + FocusNotifier, BlurNotifier, Vaadin6Component { /** * List of component tabs (tab contents). In addition to being on this list, @@ -357,7 +359,6 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, * @throws PaintException * if the paint operation failed. */ - @Override public void paintContent(PaintTarget target) throws PaintException { if (areTabsHidden()) { @@ -422,7 +423,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, target.addAttribute("key", keyMapper.key(component)); if (component.equals(selected)) { target.addAttribute("selected", true); - component.paint(target); + LegacyPaint.paint(component, target); } target.endTag("tab"); } @@ -678,7 +679,6 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, } // inherits javadoc - @Override public void changeVariables(Object source, Map variables) { if (variables.containsKey("selected")) { setSelectedTab(keyMapper.get((String) variables.get("selected"))); @@ -1057,9 +1057,8 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, * * *

- * This method will trigger a - * {@link com.vaadin.terminal.Paintable.RepaintRequestEvent - * RepaintRequestEvent} on the TabSheet to which the Tab belongs. + * This method will trigger a {@link RepaintRequestEvent} on the + * TabSheet to which the Tab belongs. *

* * @param styleName diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index 1c62679e86..03d7c73536 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -43,6 +43,7 @@ import com.vaadin.event.dd.DropTarget; import com.vaadin.event.dd.acceptcriteria.ClientCriterion; import com.vaadin.event.dd.acceptcriteria.ServerSideCriterion; import com.vaadin.terminal.KeyMapper; +import com.vaadin.terminal.LegacyPaint; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Resource; @@ -3361,7 +3362,7 @@ public class Table extends AbstractSelect implements Action.Container, target.addText(""); paintCellTooltips(target, itemId, columnId); } else { - c.paint(target); + LegacyPaint.paint(c, target); } } else { target.addText((String) cells[CELL_FIRSTCOL + currentColumn][indexInRowbuffer]); @@ -5272,7 +5273,7 @@ public class Table extends AbstractSelect implements Action.Container, @Override public void setVisible(boolean visible) { - if (!isVisibleInContext() && visible) { + if (visible) { // We need to ensure that the rows are sent to the client when the // Table is made visible if it has been rendered as invisible. setRowCacheInvalidated(true); diff --git a/src/com/vaadin/ui/Upload.java b/src/com/vaadin/ui/Upload.java index 6aee91e935..4dff71e45b 100644 --- a/src/com/vaadin/ui/Upload.java +++ b/src/com/vaadin/ui/Upload.java @@ -15,6 +15,7 @@ import java.util.Map; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.StreamVariable.StreamingProgressEvent; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.gwt.server.NoInputStreamException; import com.vaadin.terminal.gwt.server.NoOutputStreamException; @@ -59,7 +60,8 @@ import com.vaadin.terminal.gwt.server.NoOutputStreamException; * @since 3.0 */ @SuppressWarnings("serial") -public class Upload extends AbstractComponent implements Component.Focusable { +public class Upload extends AbstractComponent implements Component.Focusable, + Vaadin6Component { /** * Should the field be focused on next repaint? @@ -120,7 +122,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @see com.vaadin.ui.AbstractComponent#changeVariables(java.lang.Object, * java.util.Map) */ - @Override public void changeVariables(Object source, Map variables) { if (variables.containsKey("pollForStart")) { int id = (Integer) variables.get("pollForStart"); @@ -140,7 +141,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @throws PaintException * if the paint operation failed. */ - @Override public void paintContent(PaintTarget target) throws PaintException { if (notStarted) { target.addAttribute("notStarted", true); diff --git a/src/com/vaadin/ui/Window.java b/src/com/vaadin/ui/Window.java index b025e923df..6bbb1eec8c 100644 --- a/src/com/vaadin/ui/Window.java +++ b/src/com/vaadin/ui/Window.java @@ -22,6 +22,7 @@ import com.vaadin.event.ShortcutAction.ModifierKey; import com.vaadin.event.ShortcutListener; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; +import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.WindowConnector.WindowServerRPC; import com.vaadin.terminal.gwt.client.ui.WindowConnector.WindowState; @@ -72,7 +73,8 @@ import com.vaadin.terminal.gwt.client.ui.WindowConnector.WindowState; * @since 3.0 */ @SuppressWarnings("serial") -public class Window extends Panel implements FocusNotifier, BlurNotifier { +public class Window extends Panel implements FocusNotifier, BlurNotifier, + Vaadin6Component { private WindowServerRPC rpc = new WindowServerRPC() { diff --git a/tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java b/tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java index d7b38cecfc..75905ca42e 100644 --- a/tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java +++ b/tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java @@ -9,8 +9,8 @@ import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.data.util.ObjectProperty; import com.vaadin.data.util.PropertyFormatter; -import com.vaadin.terminal.Paintable; -import com.vaadin.terminal.Paintable.RepaintRequestEvent; +import com.vaadin.ui.Component.RepaintRequestEvent; +import com.vaadin.ui.Component.RepaintRequestListener; import com.vaadin.ui.TextField; public class TextFieldWithPropertyFormatter extends TestCase { @@ -61,7 +61,7 @@ public class TextFieldWithPropertyFormatter extends TestCase { }; field.addListener(listener); - field.addListener(new Paintable.RepaintRequestListener() { + field.addListener(new RepaintRequestListener() { public void repaintRequested(RepaintRequestEvent event) { repainted++; } diff --git a/tests/server-side/com/vaadin/tests/server/components/TestComboBoxValueChange.java b/tests/server-side/com/vaadin/tests/server/components/TestComboBoxValueChange.java index 1ca06a86aa..308889fa33 100644 --- a/tests/server-side/com/vaadin/tests/server/components/TestComboBoxValueChange.java +++ b/tests/server-side/com/vaadin/tests/server/components/TestComboBoxValueChange.java @@ -25,7 +25,7 @@ public class TestComboBoxValueChange extends protected void setValue(AbstractField field) { Map variables = new HashMap(); variables.put("selected", new String[] { "myvalue" }); - field.changeVariables(field, variables); + ((ComboBox) field).changeVariables(field, variables); } } diff --git a/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java b/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java index 758c09d66e..f5db67be97 100644 --- a/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java +++ b/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java @@ -40,7 +40,7 @@ public class TestTextFieldValueChange extends protected void setValue(AbstractField field) { Map variables = new HashMap(); variables.put("text", "newValue"); - field.changeVariables(field, variables); + ((TextField) field).changeVariables(field, variables); } /** -- 2.39.5