Change-Id: I86fcf9062804c7eb71d460d2003a3f5eb8d775ebtags/7.4.0.beta1
@@ -35,16 +35,16 @@ import com.vaadin.ui.declarative.DesignContext.ComponentCreatedEvent; | |||
import com.vaadin.ui.declarative.DesignContext.ComponentCreationListener; | |||
/** | |||
* LayoutHandler is used for parsing a component hierarchy from an html file | |||
* and, conversely, for generating an html tree representation corresponding to | |||
* a given component hierarchy. For both parsing and tree generation the | |||
* component hierarchy must contain a single root. | |||
* Design is used for parsing a component hierarchy from an html file and, | |||
* conversely, for generating an html tree representation corresponding to a | |||
* given component hierarchy. For both parsing and tree generation the component | |||
* hierarchy must contain a single root. | |||
* | |||
* | |||
* @since 7.4 | |||
* @author Vaadin Ltd | |||
*/ | |||
public class LayoutHandler implements Serializable { | |||
public class Design implements Serializable { | |||
/** | |||
* Constructs a component hierarchy from the design specified as an html | |||
* document. The component hierarchy must contain exactly one top-level |
@@ -13,7 +13,7 @@ | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.tests.layoutparser; | |||
package com.vaadin.tests.design; | |||
import org.junit.Ignore; | |||
@@ -13,7 +13,7 @@ | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.tests.layoutparser; | |||
package com.vaadin.tests.design; | |||
import org.junit.Ignore; | |||
@@ -13,15 +13,15 @@ | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.tests.layoutparser; | |||
package com.vaadin.tests.design; | |||
import java.io.FileInputStream; | |||
import java.io.FileNotFoundException; | |||
import junit.framework.TestCase; | |||
import com.vaadin.ui.declarative.Design; | |||
import com.vaadin.ui.declarative.DesignContext; | |||
import com.vaadin.ui.declarative.LayoutHandler; | |||
/** | |||
* Just top level test case that contains all synchronizable components | |||
@@ -32,9 +32,9 @@ public class ParseAllSupportedComponentsTest extends TestCase { | |||
public void testParsing() { | |||
try { | |||
DesignContext ctx = LayoutHandler | |||
DesignContext ctx = Design | |||
.parse(new FileInputStream( | |||
"server/tests/src/com/vaadin/tests/layoutparser/all-components.html")); | |||
"server/tests/src/com/vaadin/tests/design/all-components.html")); | |||
assertNotNull("The returned design context can not be null", ctx); | |||
assertNotNull("the component root can not be null", | |||
ctx.getComponentRoot()); |
@@ -13,7 +13,7 @@ | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.tests.layoutparser; | |||
package com.vaadin.tests.design; | |||
import java.io.FileInputStream; | |||
import java.io.FileNotFoundException; | |||
@@ -35,9 +35,9 @@ import com.vaadin.ui.NativeButton; | |||
import com.vaadin.ui.TextArea; | |||
import com.vaadin.ui.TextField; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.ui.declarative.Design; | |||
import com.vaadin.ui.declarative.DesignContext; | |||
import com.vaadin.ui.declarative.DesignException; | |||
import com.vaadin.ui.declarative.LayoutHandler; | |||
/** | |||
* A test for checking that parsing a layout preserves the IDs and the mapping | |||
@@ -54,9 +54,8 @@ public class ParseLayoutTest extends TestCase { | |||
@Override | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
ctx = LayoutHandler | |||
.parse(new FileInputStream( | |||
"server/tests/src/com/vaadin/tests/layoutparser/testFile.html")); | |||
ctx = Design.parse(new FileInputStream( | |||
"server/tests/src/com/vaadin/tests/design/testFile.html")); | |||
} | |||
/* | |||
@@ -79,8 +78,8 @@ public class ParseLayoutTest extends TestCase { | |||
*/ | |||
@Test | |||
public void testThatSerializationPreservesProperties() throws IOException { | |||
Document doc = LayoutHandler.createHtml(ctx); | |||
DesignContext newContext = LayoutHandler.parse(doc.toString()); | |||
Document doc = Design.createHtml(ctx); | |||
DesignContext newContext = Design.parse(doc.toString()); | |||
// Check that the elements can still be found by id and caption | |||
findElements(newContext); | |||
checkHierarchy(newContext); | |||
@@ -116,8 +115,8 @@ public class ParseLayoutTest extends TestCase { | |||
public void testFieldBinding() throws IOException { | |||
LayoutTemplate template = new LayoutTemplate(); | |||
InputStream htmlFile = new FileInputStream( | |||
"server/tests/src/com/vaadin/tests/layoutparser/testFile.html"); | |||
LayoutHandler.parse(htmlFile, template); | |||
"server/tests/src/com/vaadin/tests/design/testFile.html"); | |||
Design.parse(htmlFile, template); | |||
assertNotNull(template.getFirstButton()); | |||
assertNotNull(template.getSecondButton()); | |||
assertNotNull(template.getYetanotherbutton()); | |||
@@ -134,9 +133,9 @@ public class ParseLayoutTest extends TestCase { | |||
public void testUnboundFields() throws IOException { | |||
InvalidLayoutTemplate template = new InvalidLayoutTemplate(); | |||
InputStream htmlFile = new FileInputStream( | |||
"server/tests/src/com/vaadin/tests/layoutparser/testFile.html"); | |||
"server/tests/src/com/vaadin/tests/design/testFile.html"); | |||
try { | |||
LayoutHandler.parse(htmlFile, template); | |||
Design.parse(htmlFile, template); | |||
// we are expecting an exception | |||
fail(); | |||
} catch (DesignException e) { |
@@ -13,7 +13,7 @@ | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.tests.layoutparser; | |||
package com.vaadin.tests.design; | |||
import java.util.Locale; | |||
@@ -28,7 +28,7 @@ import com.vaadin.ui.HorizontalLayout; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.ui.declarative.DesignContext; | |||
import com.vaadin.ui.declarative.LayoutHandler; | |||
import com.vaadin.ui.declarative.Design; | |||
/** | |||
* Tests the handling of the locale property in parsing and html generation. | |||
@@ -73,7 +73,7 @@ public class TestLocale extends TestCase { | |||
hlayout2.addComponent(l2); | |||
ctx.setComponentRoot(vLayout); | |||
// create the html tree corresponding to the component hierarchy | |||
Document doc = LayoutHandler.createHtml(ctx); | |||
Document doc = Design.createHtml(ctx); | |||
// check the created html | |||
Element body = doc.body(); | |||
Element evLayout = body.child(0); | |||
@@ -131,7 +131,7 @@ public class TestLocale extends TestCase { | |||
// parse the created document and check the constructed component | |||
// hierarchy | |||
VerticalLayout vLayout = (VerticalLayout) LayoutHandler.parse( | |||
VerticalLayout vLayout = (VerticalLayout) Design.parse( | |||
doc.toString()).getComponentRoot(); | |||
assertEquals("Wrong locale.", new Locale("en", "US"), | |||
vLayout.getLocale()); |