protected T read(String design) { try { return (T) Design.read(new ByteArrayInputStream(design.getBytes("UTF-8"))); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
@Test(expected = DesignException.class) public void fieldsCannotBeBoundToAnInvalidTemplate() throws IOException { InvalidLayoutTemplate template = new InvalidLayoutTemplate(); InputStream htmlFile = new FileInputStream("server/tests/src/com/vaadin/tests/design/testFile.html"); Design.read(htmlFile, template); }
public TaskOptionLayout(Task task) { Design.read(this); Responsive.makeResponsive(this); scheduleStartDate.setResolution(Resolution.MINUTE); scheduleEndDate.setResolution(Resolution.MINUTE); setDefaultScheduler(task); binder.setItemDataSource(task); binder.bind(scheduleStartDate, "scheduleStartDate"); binder.bind(scheduleEndDate, "scheduleEndDate"); binder.setBuffered(true); }
@Test public void fieldsAreBoundToATemplate() throws IOException { LayoutTemplate template = new LayoutTemplate(); InputStream htmlFile = new FileInputStream("server/tests/src/com/vaadin/tests/design/testFile.html"); Design.read(htmlFile, template); assertNotNull(template.getFirstButton()); assertNotNull(template.getSecondButton()); assertNotNull(template.getYetanotherbutton()); assertNotNull(template.getClickme()); assertEquals("Native click me", template.getFirstButton().getCaption()); }
protected String write(T object, boolean writeData) { try { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); DesignContext dc = new DesignContext(); if (writeData) { dc.setShouldWriteDataDelegate(DeclarativeTestBaseBase.ALWAYS_WRITE_DATA); } dc.setRootComponent(object); Design.write(dc, outputStream); return outputStream.toString("UTF-8"); } catch (Exception e) { throw new RuntimeException(e); } }
public Design() { com.vaadin.ui.declarative.Design.read(this); }
public MatchDesign() { Design.read(this); }
@Before public void setUp() throws Exception { ctx = Design.read( new FileInputStream("server/tests/src/com/vaadin/tests/design/testFile.html"), null); }
private ByteArrayOutputStream serializeDesign(DesignContext context) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); Design.write(context, out); return out; }
private DesignContext deSerializeDesign(ByteArrayOutputStream out) { ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); return Design.read(in, null); }
public SalesOverviewDesign() { Design.read(this); }