]> source.dussan.org Git - vaadin-framework.git/commitdiff
Embed DesignSynchronizable methods to Component interface (#7749)
authorMatti Hosio <mhosio@vaadin.com>
Fri, 12 Dec 2014 11:04:31 +0000 (13:04 +0200)
committerMatti Hosio <mhosio@vaadin.com>
Fri, 12 Dec 2014 14:18:20 +0000 (16:18 +0200)
Change-Id: I06de4d2065dee107da40c2a4941e7d9e22f0832b

17 files changed:
server/src/com/vaadin/ui/AbsoluteLayout.java
server/src/com/vaadin/ui/AbstractComponent.java
server/src/com/vaadin/ui/AbstractOrderedLayout.java
server/src/com/vaadin/ui/AbstractSingleComponentContainer.java
server/src/com/vaadin/ui/Button.java
server/src/com/vaadin/ui/Component.java
server/src/com/vaadin/ui/CssLayout.java
server/src/com/vaadin/ui/DesignSynchronizable.java [deleted file]
server/src/com/vaadin/ui/Label.java
server/src/com/vaadin/ui/TabSheet.java
server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java
server/src/com/vaadin/ui/declarative/DesignContext.java
server/src/com/vaadin/ui/declarative/LayoutHandler.java
server/tests/src/com/vaadin/tests/layoutparser/ParseLayoutTest.java
server/tests/src/com/vaadin/tests/server/component/absolutelayout/TestSynchronizeFromDesign.java
server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestSynchronizeFromDesign.java
server/tests/src/com/vaadin/tests/server/component/csslayout/TestSynchronizeFromDesign.java

index c4c0de764f94bd949cce7ada927f4558e746d593..7af22ba5c670bc46813351c3b087835a4e5b6445 100644 (file)
@@ -691,8 +691,7 @@ public class AbsoluteLayout extends AbstractLayout implements
         // handle children
         for (Element childComponent : design.children()) {
             Attributes attr = childComponent.attributes();
-            DesignSynchronizable newChild = designContext
-                    .createChild(childComponent);
+            Component newChild = designContext.createChild(childComponent);
             StringBuilder css = new StringBuilder();
             if (attr.hasKey(ATTR_TOP)) {
                 css.append("top:").append(attr.get(ATTR_TOP)).append(";");
@@ -727,10 +726,9 @@ public class AbsoluteLayout extends AbstractLayout implements
         // handle children
         Element designElement = design;
         for (Component child : this) {
-            DesignSynchronizable childComponent = (DesignSynchronizable) child;
-            Element childNode = designContext.createNode(childComponent);
+            Element childNode = designContext.createNode(child);
             designElement.appendChild(childNode);
-            childComponent.synchronizeToDesign(childNode, designContext);
+            child.synchronizeToDesign(childNode, designContext);
             // handle position
             ComponentPosition position = getPosition(child);
             writePositionAttribute(childNode, ATTR_TOP, position.getTopUnits()
index adbb6d7fe7bd36e98ceefd4e5c769ff36e94351c..18cd1f5fa45edb65e101879b0c1f2ffc97987863 100644 (file)
@@ -69,7 +69,7 @@ import com.vaadin.util.ReflectTools;
  */
 @SuppressWarnings("serial")
 public abstract class AbstractComponent extends AbstractClientConnector
-        implements DesignSynchronizable {
+        implements Component {
 
     /* Private members */
 
@@ -917,8 +917,8 @@ public abstract class AbstractComponent extends AbstractClientConnector
      * (non-Javadoc)
      * 
      * @see
-     * com.vaadin.ui.DesignSynchronizable#synchronizeFromDesign(org.jsoup.nodes
-     * .Element, com.vaadin.ui.declarative.DesignContext)
+     * com.vaadin.ui.Component#synchronizeFromDesign(org.jsoup.nodes.Element,
+     * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
     public void synchronizeFromDesign(Element design,
@@ -1090,8 +1090,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
      *            the default instance of the class for fetching the default
      *            values
      */
-    private void writeSize(Attributes attributes,
-            DesignSynchronizable defaultInstance) {
+    private void writeSize(Attributes attributes, Component defaultInstance) {
         if (hasEqualSize(defaultInstance)) {
             // we have default values -> ignore
             return;
@@ -1211,9 +1210,8 @@ public abstract class AbstractComponent extends AbstractClientConnector
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.DesignSynchronizable#synchronizeToDesign(org.jsoup.nodes
-     * .Element, com.vaadin.ui.declarative.DesignContext)
+     * @see com.vaadin.ui.Component#synchronizeToDesign(org.jsoup.nodes.Element,
+     * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
     public void synchronizeToDesign(Element design, DesignContext designContext) {
index afe7a65d67eb5d39be2d2798be7f84b762733e90..d2a302cff5adafd5db2a3d265712cc32fcf2d073 100644 (file)
@@ -23,7 +23,6 @@ import java.util.logging.Logger;
 
 import org.jsoup.nodes.Attributes;
 import org.jsoup.nodes.Element;
-import org.jsoup.nodes.Node;
 
 import com.vaadin.event.LayoutEvents.LayoutClickEvent;
 import com.vaadin.event.LayoutEvents.LayoutClickListener;
@@ -494,43 +493,40 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
             setMargin(def.getMargin().getBitMask() != 0);
         }
         // handle children
-        for (Node childComponent : design.childNodes()) {
-            if (childComponent instanceof Element) {
-                Attributes attr = childComponent.attributes();
-                DesignSynchronizable newChild = designContext
-                        .createChild((Element) childComponent);
-                addComponent(newChild);
-                // handle alignment
-                int bitMask = 0;
-                if (attr.hasKey(":middle")) {
-                    bitMask += AlignmentInfo.Bits.ALIGNMENT_VERTICAL_CENTER;
-                } else if (attr.hasKey(":bottom")) {
-                    bitMask += AlignmentInfo.Bits.ALIGNMENT_BOTTOM;
-                } else {
-                    bitMask += AlignmentInfo.Bits.ALIGNMENT_TOP;
-                }
-                if (attr.hasKey(":center")) {
-                    bitMask += AlignmentInfo.Bits.ALIGNMENT_HORIZONTAL_CENTER;
-                } else if (attr.hasKey(":right")) {
-                    bitMask += AlignmentInfo.Bits.ALIGNMENT_RIGHT;
-                } else {
-                    bitMask += AlignmentInfo.Bits.ALIGNMENT_LEFT;
-                }
-                setComponentAlignment(newChild, new Alignment(bitMask));
-                // handle expand ratio
-                if (attr.hasKey(":expand")) {
-                    String value = attr.get(":expand");
-                    if (value.length() > 0) {
-                        try {
-                            float ratio = Float.valueOf(value);
-                            setExpandRatio(newChild, ratio);
-                        } catch (NumberFormatException nfe) {
-                            getLogger().info(
-                                    "Failed to parse expand ratio " + value);
-                        }
-                    } else {
-                        setExpandRatio(newChild, 1.0f);
+        for (Element childComponent : design.children()) {
+            Attributes attr = childComponent.attributes();
+            Component newChild = designContext.createChild(childComponent);
+            addComponent(newChild);
+            // handle alignment
+            int bitMask = 0;
+            if (attr.hasKey(":middle")) {
+                bitMask += AlignmentInfo.Bits.ALIGNMENT_VERTICAL_CENTER;
+            } else if (attr.hasKey(":bottom")) {
+                bitMask += AlignmentInfo.Bits.ALIGNMENT_BOTTOM;
+            } else {
+                bitMask += AlignmentInfo.Bits.ALIGNMENT_TOP;
+            }
+            if (attr.hasKey(":center")) {
+                bitMask += AlignmentInfo.Bits.ALIGNMENT_HORIZONTAL_CENTER;
+            } else if (attr.hasKey(":right")) {
+                bitMask += AlignmentInfo.Bits.ALIGNMENT_RIGHT;
+            } else {
+                bitMask += AlignmentInfo.Bits.ALIGNMENT_LEFT;
+            }
+            setComponentAlignment(newChild, new Alignment(bitMask));
+            // handle expand ratio
+            if (attr.hasKey(":expand")) {
+                String value = attr.get(":expand");
+                if (value.length() > 0) {
+                    try {
+                        float ratio = Float.valueOf(value);
+                        setExpandRatio(newChild, ratio);
+                    } catch (NumberFormatException nfe) {
+                        getLogger().info(
+                                "Failed to parse expand ratio " + value);
                     }
+                } else {
+                    setExpandRatio(newChild, 1.0f);
                 }
             }
         }
@@ -556,8 +552,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
         // handle children
         Element designElement = design;
         for (Component child : this) {
-            DesignSynchronizable childComponent = (DesignSynchronizable) child;
-            Element childNode = designContext.createNode(childComponent);
+            Element childNode = designContext.createNode(child);
             designElement.appendChild(childNode);
             // handle alignment
             Alignment alignment = getComponentAlignment(child);
index c6e78447d56f29431ce15452bddc15b5a18eb2d5..6c8d4fcde2c6765a65e8ac657ac6d642ff69aca7 100644 (file)
@@ -299,8 +299,7 @@ public abstract class AbstractSingleComponentContainer extends
                     + " can have only one child component.");
         } else if (childCount == 1) {
             Element childElement = design.children().get(0);
-            DesignSynchronizable newChild = designContext
-                    .createChild(childElement);
+            Component newChild = designContext.createChild(childElement);
             setContent(newChild);
         } else {
             setContent(null);
@@ -319,7 +318,7 @@ public abstract class AbstractSingleComponentContainer extends
         // synchronize default attributes (also clears children and attributes)
         super.synchronizeToDesign(design, designContext);
         // handle child component
-        DesignSynchronizable child = (DesignSynchronizable) getContent();
+        Component child = getContent();
         if (child != null) {
             Element childNode = designContext.createNode(child);
             design.appendChild(childNode);
index 46366eda8c0ef77c79fd8f6d029528ff244047cd..82666613bbee7902e667ce0d81cba627d6988a4b 100644 (file)
@@ -670,7 +670,7 @@ public class Button extends AbstractComponent implements
      * (non-Javadoc)
      * 
      * @see
-     * com.vaadin.ui.DesignSynchronizable#synchronizeFromDesign(org.jsoup.nodes
+     * com.vaadin.ui.AbstractComponent#synchronizeFromDesign(org.jsoup.nodes
      * .Element, com.vaadin.ui.declarative.DesignContext)
      */
     @Override
@@ -719,8 +719,8 @@ public class Button extends AbstractComponent implements
      * (non-Javadoc)
      * 
      * @see
-     * com.vaadin.ui.DesignSynchronizable#synchronizeToDesign(org.jsoup.nodes
-     * .Element, com.vaadin.ui.declarative.DesignContext)
+     * com.vaadin.ui.AbstractComponent#synchronizeToDesign(org.jsoup.nodes.Element
+     * , com.vaadin.ui.declarative.DesignContext)
      */
     @Override
     public void synchronizeToDesign(Element design, DesignContext designContext) {
index e10b5e1cd9267ef17d2469b985ccc9f40d246fca..024c3eb433e8b1bd8d7719054e18def0e07859c9 100644 (file)
@@ -19,6 +19,8 @@ package com.vaadin.ui;
 import java.io.Serializable;
 import java.util.Locale;
 
+import org.jsoup.nodes.Element;
+
 import com.vaadin.event.ConnectorEvent;
 import com.vaadin.event.ConnectorEventListener;
 import com.vaadin.event.FieldEvents;
@@ -27,6 +29,7 @@ import com.vaadin.server.ErrorMessage;
 import com.vaadin.server.Resource;
 import com.vaadin.server.Sizeable;
 import com.vaadin.server.VariableOwner;
+import com.vaadin.ui.declarative.DesignContext;
 
 /**
  * {@code Component} is the top-level interface that is and must be implemented
@@ -726,6 +729,40 @@ public interface Component extends ClientConnector, Sizeable, Serializable {
      */
     public String getDescription();
 
+    /* Declarative support */
+
+    /**
+     * Update the component state based on the given design. The component is
+     * responsible not only for updating itself but also ensuring that its
+     * children update their state based on the design.
+     * <p>
+     * This method must not modify the design.
+     * 
+     * @since 7.4
+     * @param design
+     *            The design as HTML to obtain the state from
+     * @param designContext
+     *            The DesignContext instance used for parsing the design
+     */
+    public void synchronizeFromDesign(Element design,
+            DesignContext designContext);
+
+    /**
+     * Update the given design based on the component state. The component is
+     * responsible not only for updating itself but also for ensuring its
+     * children update themselves in the correct position in the design. The
+     * caller of this method should not assume that contents of the
+     * <code>design</code> parameter are presented.
+     * <p>
+     * This method must not modify the component state.
+     * 
+     * @since 7.4
+     * @param design
+     *            The design as HTML to update with the current state
+     * @param designContext
+     */
+    public void synchronizeToDesign(Element design, DesignContext designContext);
+
     /* Component event framework */
 
     /**
index 33b8c9fcbcaa86036584e9dd97d7a59da5145ada..0b4e9cda7baf2722bd72e45c10e7d9ddf3864017 100644 (file)
@@ -377,8 +377,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
         removeAllComponents();
         // handle children
         for (Element childComponent : design.children()) {
-            DesignSynchronizable newChild = designContext
-                    .createChild(childComponent);
+            Component newChild = designContext.createChild(childComponent);
             addComponent(newChild);
         }
     }
@@ -397,8 +396,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
         // handle children
         Element designElement = design;
         for (Component child : this) {
-            DesignSynchronizable childComponent = (DesignSynchronizable) child;
-            Element childNode = designContext.createNode(childComponent);
+            Element childNode = designContext.createNode(child);
             designElement.appendChild(childNode);
         }
     }
diff --git a/server/src/com/vaadin/ui/DesignSynchronizable.java b/server/src/com/vaadin/ui/DesignSynchronizable.java
deleted file mode 100644 (file)
index 91533cc..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.ui;
-
-import org.jsoup.nodes.Element;
-
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Interface to be implemented by all the components that can be read from or
- * written to HTML design representation. TODO: add reference to VisualDesigner
- * 
- * @since 7.4
- * 
- * @author Vaadin Ltd
- */
-public interface DesignSynchronizable extends Component {
-
-    /**
-     * Update the component state based on the given design. The component is
-     * responsible not only for updating itself but also ensuring that its
-     * children update their state based on the design.
-     * <p>
-     * This method must not modify the design.
-     * 
-     * @since 7.4
-     * @param design
-     *            The design as HTML to obtain the state from
-     * @param designContext
-     *            The DesignContext instance used for parsing the design
-     */
-    public void synchronizeFromDesign(Element design,
-            DesignContext designContext);
-
-    /**
-     * Update the given design based on the component state. The component is
-     * responsible not only for updating itself but also for ensuring its
-     * children update themselves in the correct position in the design. The
-     * caller of this method should not assume that contents of the
-     * <code>design</code> parameter are presented.
-     * <p>
-     * This method must not modify the component state.
-     * 
-     * @since 7.4
-     * @param design
-     *            The design as HTML to update with the current state
-     * @param designContext
-     */
-    public void synchronizeToDesign(Element design, DesignContext designContext);
-}
index 6001e30446a7e5e68c932cd5d13b20b0e0de882c..a4d9da752d8d846c7995933e201193b408e776cf 100644 (file)
@@ -579,7 +579,7 @@ public class Label extends AbstractComponent implements Property<String>,
      * (non-Javadoc)
      * 
      * @see
-     * com.vaadin.ui.DesignSynchronizable#synchronizeFromDesign(org.jsoup.nodes
+     * com.vaadin.ui.AbstractComponent#synchronizeFromDesign(org.jsoup.nodes
      * .Element, com.vaadin.ui.declarative.DesignContext)
      */
     @Override
@@ -608,8 +608,8 @@ public class Label extends AbstractComponent implements Property<String>,
      * (non-Javadoc)
      * 
      * @see
-     * com.vaadin.ui.DesignSynchronizable#synchronizeToDesign(org.jsoup.nodes
-     * .Element, com.vaadin.ui.declarative.DesignContext)
+     * com.vaadin.ui.AbstractComponent#synchronizeToDesign(org.jsoup.nodes.Element
+     * , com.vaadin.ui.declarative.DesignContext)
      */
     @Override
     public void synchronizeToDesign(Element design, DesignContext designContext) {
index dd9beb07f0c849e0322ef77f853696049b8c5d4b..121ba89e06056e4661276ab226f1f18d0f45e3d2 100644 (file)
@@ -1503,7 +1503,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
         }
         // create the component that is in tab content
         Element content = tabElement.child(0);
-        DesignSynchronizable child = designContext.createChild(content);
+        Component child = designContext.createChild(content);
         Tab tab = this.addTab(child);
         tab.setVisible(DesignAttributeHandler.readAttribute("visible", attr,
                 tab.isVisible(), Boolean.class));
@@ -1548,8 +1548,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
         // create element for tab
         Element tabElement = design.appendElement("tab");
         // add tab content
-        tabElement.appendChild(designContext
-                .createNode((DesignSynchronizable) tab.getComponent()));
+        tabElement.appendChild(designContext.createNode(tab.getComponent()));
         Attributes attr = tabElement.attributes();
         // write attributes
         DesignAttributeHandler.writeAttribute("visible", attr, tab.isVisible(),
index f70a79447f009592965d3a5775a001ded74d1c94..b410fd00016dc89f19a0353b8c2b039b3145198a 100644 (file)
@@ -49,7 +49,7 @@ import com.vaadin.server.FontAwesome;
 import com.vaadin.server.Resource;
 import com.vaadin.server.ThemeResource;
 import com.vaadin.shared.util.SharedUtil;
-import com.vaadin.ui.DesignSynchronizable;
+import com.vaadin.ui.Component;
 
 /**
  * Default attribute handler implementation used when parsing designs to
@@ -104,9 +104,8 @@ public class DesignAttributeHandler implements Serializable {
      *            values
      * @return true on success
      */
-    public static boolean readAttribute(DesignSynchronizable component,
-            String attribute, Attributes attributes,
-            DesignSynchronizable defaultInstance) {
+    public static boolean readAttribute(Component component, String attribute,
+            Attributes attributes, Component defaultInstance) {
         String value = null;
         if (component == null || attribute == null || attributes == null
                 || defaultInstance == null) {
@@ -213,9 +212,8 @@ public class DesignAttributeHandler implements Serializable {
      * @param defaultInstance
      *            the default instance for comparing default values
      */
-    public static void writeAttribute(DesignSynchronizable component,
-            String attribute, Attributes attr,
-            DesignSynchronizable defaultInstance) {
+    public static void writeAttribute(Component component, String attribute,
+            Attributes attr, Component defaultInstance) {
         Method getter = findGetterForAttribute(component.getClass(), attribute);
         if (getter == null) {
             getLogger().warning(
index 988dc7654ecad1ca823981ea28987c13eafaa322..753a2d87ba6101dff3315018172608b1340b02fc 100644 (file)
@@ -29,7 +29,6 @@ import org.jsoup.nodes.Element;
 import org.jsoup.nodes.Node;
 
 import com.vaadin.ui.Component;
-import com.vaadin.ui.DesignSynchronizable;
 
 /**
  * This class contains contextual information that is collected when a component
@@ -47,19 +46,19 @@ public class DesignContext implements Serializable {
             .synchronizedMap(new HashMap<Class<?>, Object>());
 
     // The root component of the component hierarchy
-    private DesignSynchronizable componentRoot = null;
+    private Component componentRoot = null;
     // Attribute names for global id and caption and the prefix name for a local
     // id
     public static final String ID_ATTRIBUTE = "id";
     public static final String CAPTION_ATTRIBUTE = "caption";
     public static final String LOCAL_ID_ATTRIBUTE = "_id";
     // Mappings from ids to components. Modified when synchronizing from design.
-    private Map<String, DesignSynchronizable> idToComponent = new HashMap<String, DesignSynchronizable>();
-    private Map<String, DesignSynchronizable> localIdToComponent = new HashMap<String, DesignSynchronizable>();
-    private Map<String, DesignSynchronizable> captionToComponent = new HashMap<String, DesignSynchronizable>();
+    private Map<String, Component> idToComponent = new HashMap<String, Component>();
+    private Map<String, Component> localIdToComponent = new HashMap<String, Component>();
+    private Map<String, Component> captionToComponent = new HashMap<String, Component>();
     // Mapping from components to local ids. Accessed when synchronizing to
     // design. Modified when synchronizing from design.
-    private Map<DesignSynchronizable, String> componentToLocalId = new HashMap<DesignSynchronizable, String>();
+    private Map<Component, String> componentToLocalId = new HashMap<Component, String>();
     private Document doc; // required for calling createElement(String)
     // namespace mappings
     private Map<String, String> packageToPrefix = new HashMap<String, String>();
@@ -94,7 +93,7 @@ public class DesignContext implements Serializable {
      *            The local id of the component
      * @return a component whose local id equals localId
      */
-    public DesignSynchronizable getComponentByLocalId(String localId) {
+    public Component getComponentByLocalId(String localId) {
         return localIdToComponent.get(localId);
     }
 
@@ -106,7 +105,7 @@ public class DesignContext implements Serializable {
      *            The global id of the component
      * @return a component whose global id equals globalId
      */
-    public DesignSynchronizable getComponentById(String globalId) {
+    public Component getComponentById(String globalId) {
         return idToComponent.get(globalId);
     }
 
@@ -118,7 +117,7 @@ public class DesignContext implements Serializable {
      *            The caption of the component
      * @return a component whose caption equals the caption given as a parameter
      */
-    public DesignSynchronizable getComponentByCaption(String caption) {
+    public Component getComponentByCaption(String caption) {
         return captionToComponent.get(caption);
     }
 
@@ -142,8 +141,8 @@ public class DesignContext implements Serializable {
      * @return true, if there already was a global id mapping from the string to
      *         some component.
      */
-    private boolean mapId(String globalId, DesignSynchronizable component) {
-        DesignSynchronizable oldComponent = idToComponent.get(globalId);
+    private boolean mapId(String globalId, Component component) {
+        Component oldComponent = idToComponent.get(globalId);
         if (oldComponent != null && !oldComponent.equals(component)) {
             oldComponent.setId(null);
         }
@@ -174,7 +173,7 @@ public class DesignContext implements Serializable {
      *         some component or from the component to some string. Otherwise
      *         returns false.
      */
-    private boolean mapLocalId(String localId, DesignSynchronizable component) {
+    private boolean mapLocalId(String localId, Component component) {
         return twoWayMap(localId, component, localIdToComponent,
                 componentToLocalId);
     }
@@ -196,7 +195,7 @@ public class DesignContext implements Serializable {
      * @return true, if there already was a caption mapping from the string to
      *         some component.
      */
-    private boolean mapCaption(String caption, DesignSynchronizable component) {
+    private boolean mapCaption(String caption, Component component) {
         return captionToComponent.put(caption, component) != null;
     }
 
@@ -337,12 +336,12 @@ public class DesignContext implements Serializable {
      * rooted at the returned Node.
      * 
      * @param childComponent
-     *            A component implementing the DesignSynchronizable interface.
+     *            The component with state that is synchronized in to the node
      * @return An html tree node corresponding to the given component. The tag
      *         name of the created node is derived from the class name of
      *         childComponent.
      */
-    public Element createNode(DesignSynchronizable childComponent) {
+    public Element createNode(Component childComponent) {
         Class<?> componentClass = childComponent.getClass();
         String packageName = componentClass.getPackage().getName();
         String prefix = packageToPrefix.get(packageName);
@@ -391,18 +390,18 @@ public class DesignContext implements Serializable {
     }
 
     /**
-     * Creates a DesignSynchronizable object corresponding to the given html
-     * node. Also calls synchronizeFromDesign() for the created node, in effect
-     * creating the entire component hierarchy rooted at the returned component.
+     * Creates a Component corresponding to the given html node. Also calls
+     * synchronizeFromDesign() for the created node, in effect creating the
+     * entire component hierarchy rooted at the returned component.
      * 
      * @param componentDesign
      *            The html tree node containing the description of the component
      *            to be created.
-     * @return a DesignSynchronizable object corresponding to componentDesign
+     * @return a Component corresponding to componentDesign
      */
-    public DesignSynchronizable createChild(Element componentDesign) {
+    public Component createChild(Element componentDesign) {
         // Create the component.
-        DesignSynchronizable component = instantiateComponent(componentDesign);
+        Component component = instantiateComponent(componentDesign);
         synchronizeAndRegister(component, componentDesign);
         fireComponentCreatedEvent(componentToLocalId.get(component), component);
         return component;
@@ -421,7 +420,7 @@ public class DesignContext implements Serializable {
      * @param componentDesign
      *            The html tree node containing the description of the component
      */
-    public void synchronizeAndRegister(DesignSynchronizable component,
+    public void synchronizeAndRegister(Component component,
             Element componentDesign) {
         component.synchronizeFromDesign(componentDesign, this);
         // Get the ids and the caption of the component and store them in the
@@ -451,20 +450,19 @@ public class DesignContext implements Serializable {
     }
 
     /**
-     * Creates a DesignSynchronizable component corresponding to the given node.
-     * Does not set the attributes for the created object.
+     * Creates a Component corresponding to the given node. Does not set the
+     * attributes for the created object.
      * 
      * @param node
      *            a node of an html tree
-     * @return a DesignSynchronizable object corresponding to node, with no
-     *         attributes set.
+     * @return a Component corresponding to node, with no attributes set.
      */
-    private DesignSynchronizable instantiateComponent(Node node) {
+    private Component instantiateComponent(Node node) {
         // Extract the package and class names.
         String qualifiedClassName = tagNameToClassName(node);
         try {
-            Class<? extends DesignSynchronizable> componentClass = resolveComponentClass(qualifiedClassName);
-            DesignSynchronizable newComponent = componentClass.newInstance();
+            Class<? extends Component> componentClass = resolveComponentClass(qualifiedClassName);
+            Component newComponent = componentClass.newInstance();
             return newComponent;
         } catch (Exception e) {
             throw new DesignException("No component class could be found for "
@@ -519,14 +517,14 @@ public class DesignContext implements Serializable {
     }
 
     @SuppressWarnings("unchecked")
-    private Class<? extends DesignSynchronizable> resolveComponentClass(
+    private Class<? extends Component> resolveComponentClass(
             String qualifiedClassName) throws ClassNotFoundException {
         Class<?> componentClass = null;
         componentClass = Class.forName(qualifiedClassName);
 
-        // Check that we're dealing with a DesignSynchronizable component.
-        if (isDesignSynchronizable(componentClass)) {
-            return (Class<? extends DesignSynchronizable>) componentClass;
+        // Check that we're dealing with a Component.
+        if (isComponent(componentClass)) {
+            return (Class<? extends Component>) componentClass;
         } else {
             throw new IllegalArgumentException(String.format(
                     "Resolved class %s is not a %s.", componentClass.getName(),
@@ -543,9 +541,9 @@ public class DesignContext implements Serializable {
      * @return {@code true} if the given {@link Class} is a {@link Component},
      *         {@code false} otherwise.
      */
-    private static boolean isDesignSynchronizable(Class<?> componentClass) {
+    private static boolean isComponent(Class<?> componentClass) {
         if (componentClass != null) {
-            return DesignSynchronizable.class.isAssignableFrom(componentClass);
+            return Component.class.isAssignableFrom(componentClass);
         } else {
             return false;
         }
@@ -556,14 +554,14 @@ public class DesignContext implements Serializable {
      * 
      * @return
      */
-    public DesignSynchronizable getComponentRoot() {
+    public Component getComponentRoot() {
         return componentRoot;
     }
 
     /**
      * Sets the root component of a created component hierarchy.
      */
-    public void setComponentRoot(DesignSynchronizable componentRoot) {
+    public void setComponentRoot(Component componentRoot) {
         this.componentRoot = componentRoot;
     }
 
@@ -597,8 +595,7 @@ public class DesignContext implements Serializable {
      * @param component
      *            the component that was created
      */
-    private void fireComponentCreatedEvent(String localId,
-            DesignSynchronizable component) {
+    private void fireComponentCreatedEvent(String localId, Component component) {
         ComponentCreatedEvent event = new ComponentCreatedEvent(localId,
                 component);
         for (ComponentCreationListener listener : listeners) {
@@ -631,7 +628,7 @@ public class DesignContext implements Serializable {
      */
     public class ComponentCreatedEvent implements Serializable {
         private String localId;
-        private DesignSynchronizable component;
+        private Component component;
         private DesignContext context;
 
         /**
@@ -642,8 +639,7 @@ public class DesignContext implements Serializable {
          * @param component
          *            the created component
          */
-        private ComponentCreatedEvent(String localId,
-                DesignSynchronizable component) {
+        private ComponentCreatedEvent(String localId, Component component) {
             this.localId = localId;
             this.component = component;
             context = DesignContext.this;
@@ -663,7 +659,7 @@ public class DesignContext implements Serializable {
          * 
          * @return the component
          */
-        public DesignSynchronizable getComponent() {
+        public Component getComponent() {
             return component;
         }
     }
index 862e93e8ff15d5e563b10bcfe896838c18d29416..b3ef2f15c7dd7941d9e12afa05ac6261106a1d70 100644 (file)
@@ -30,7 +30,7 @@ import org.jsoup.nodes.Node;
 import org.jsoup.parser.Parser;
 import org.jsoup.select.Elements;
 
-import com.vaadin.ui.DesignSynchronizable;
+import com.vaadin.ui.Component;
 import com.vaadin.ui.declarative.DesignContext.ComponentCreatedEvent;
 import com.vaadin.ui.declarative.DesignContext.ComponentCreationListener;
 
@@ -91,8 +91,7 @@ public class LayoutHandler implements Serializable {
      *         object returned by this method.
      * @throws IOException
      */
-    public static DesignContext parse(InputStream html,
-            DesignSynchronizable rootInstance) {
+    public static DesignContext parse(InputStream html, Component rootInstance) {
         Document doc;
         try {
             doc = Jsoup.parse(html, "UTF-8", "", Parser.htmlParser());
@@ -143,8 +142,7 @@ public class LayoutHandler implements Serializable {
      *         object returned by this method.
      * @throws IOException
      */
-    public static DesignContext parse(String html,
-            DesignSynchronizable rootInstance) {
+    public static DesignContext parse(String html, Component rootInstance) {
         Document doc = Jsoup.parse(html);
         return parse(doc, rootInstance);
     }
@@ -161,12 +159,10 @@ public class LayoutHandler implements Serializable {
      *            optional component root instance with some member fields. The
      *            type must match the type of the root element in the design.
      *            The member fields whose type is assignable from
-     *            {@link DesignSynchronizable} are set when parsing the
-     *            component tree
+     *            {@link Component} are set when parsing the component tree
      * 
      */
-    private static DesignContext parse(Document doc,
-            DesignSynchronizable componentRoot) {
+    private static DesignContext parse(Document doc, Component componentRoot) {
         DesignContext designContext = new DesignContext(doc);
         designContext.getPrefixes(doc);
         // No special handling for a document without a body element - should be
@@ -243,7 +239,7 @@ public class LayoutHandler implements Serializable {
         // Append the design under <body> in the html tree. createNode
         // creates the entire component hierarchy rooted at the
         // given root node.
-        DesignSynchronizable root = designContext.getComponentRoot();
+        Component root = designContext.getComponentRoot();
         Node rootNode = designContext.createNode(root);
         body.appendChild(rootNode);
         return doc;
index 1c4d50cc554809f8ed5ffc2b86ef8b0b3cdac676..0c7ac506017b8c2fe33cb1e08a12f9836aeaebdf 100644 (file)
@@ -28,7 +28,7 @@ import org.jsoup.nodes.Node;
 import org.junit.Test;
 
 import com.vaadin.ui.Button;
-import com.vaadin.ui.DesignSynchronizable;
+import com.vaadin.ui.Component;
 import com.vaadin.ui.HorizontalLayout;
 import com.vaadin.ui.Label;
 import com.vaadin.ui.NativeButton;
@@ -149,7 +149,7 @@ public class ParseLayoutTest extends TestCase {
      * component hierarchy rooted at context.getComponentRoot().
      */
     private void checkHierarchy(DesignContext context) {
-        DesignSynchronizable root = context.getComponentRoot();
+        Component root = context.getComponentRoot();
         VerticalLayout vlayout = (VerticalLayout) root;
         int numComponents = vlayout.getComponentCount();
         assertEquals("Wrong number of child components", 3, numComponents);
index 12c3a6045104c5a0c16480a25ce583d3500cc39c..ce054007a6aea5d5a5d11580bb95a195a636b10a 100644 (file)
@@ -27,7 +27,6 @@ import com.vaadin.server.Sizeable;
 import com.vaadin.ui.AbsoluteLayout;
 import com.vaadin.ui.AbsoluteLayout.ComponentPosition;
 import com.vaadin.ui.Component;
-import com.vaadin.ui.DesignSynchronizable;
 import com.vaadin.ui.declarative.DesignContext;
 
 /**
@@ -79,7 +78,7 @@ public class TestSynchronizeFromDesign extends TestCase {
     private AbsoluteLayout createLayout() {
         DesignContext ctx = new DesignContext();
         Element design = createDesign();
-        DesignSynchronizable child = ctx.createChild(design);
+        Component child = ctx.createChild(design);
         return (AbsoluteLayout) child;
     }
 
index 6e57aac95bd1919c51e851df5017756c0e3f859a..2b3d4cbdacfb878fc77f105045c69e09a2041c60 100644 (file)
@@ -22,7 +22,7 @@ import org.jsoup.nodes.Element;
 import org.jsoup.parser.Tag;
 
 import com.vaadin.ui.Alignment;
-import com.vaadin.ui.DesignSynchronizable;
+import com.vaadin.ui.Component;
 import com.vaadin.ui.VerticalLayout;
 import com.vaadin.ui.declarative.DesignContext;
 
@@ -80,7 +80,7 @@ public class TestSynchronizeFromDesign extends TestCase {
             String... alignments) {
         DesignContext ctx = new DesignContext();
         Element design = createDesign(expandRatio, margin, alignments);
-        DesignSynchronizable child = ctx.createChild(design);
+        Component child = ctx.createChild(design);
         return (VerticalLayout) child;
     }
 
index 0e1b964b2e08b993c08a2eaf72a7d09a659521ee..e9694f01707d42804e70eee0945be876fe67f38c 100644 (file)
@@ -21,8 +21,8 @@ import org.jsoup.nodes.Attributes;
 import org.jsoup.nodes.Element;
 import org.jsoup.parser.Tag;
 
+import com.vaadin.ui.Component;
 import com.vaadin.ui.CssLayout;
-import com.vaadin.ui.DesignSynchronizable;
 import com.vaadin.ui.declarative.DesignContext;
 
 /**
@@ -47,7 +47,7 @@ public class TestSynchronizeFromDesign extends TestCase {
     private CssLayout createLayout() {
         DesignContext ctx = new DesignContext();
         Element design = createDesign();
-        DesignSynchronizable child = ctx.createChild(design);
+        Component child = ctx.createChild(design);
         return (CssLayout) child;
     }