Package com.dooapp.fxform.reflection

Examples of com.dooapp.fxform.reflection.MultipleBeanSource


                    }

                    @Override
                    protected Object computeValue() {
                        if (source.get() != null && source.get() instanceof MultipleBeanSource) {
                            MultipleBeanSource multipleBeanSource = (MultipleBeanSource) source.get();
                            return multipleBeanSource.getSource(element);
                        }
                        return source.get();
                    }
                });
                // if something went wrong and we are not able to get element type, ignore it
View Full Code Here


    public List<Field> getProperties(Object source) {
        List<Field> result = new LinkedList<Field>();
        if (source != null) {
            if (source instanceof MultipleBeanSource) {
                MultipleBeanSource multipleBeanSource = (MultipleBeanSource) source;
                for (Object s : multipleBeanSource.getSources()) {
                    ReflectionUtils.fillFields(s.getClass(), result);
                }
            } else {
                ReflectionUtils.fillFields(source.getClass(), result);
            }
View Full Code Here

        Bean1 bean1 = new Bean1();
        Bean2 bean2 = new Bean2();
        ReflectionFieldProvider reflectionFieldProvider = new ReflectionFieldProvider();
        List<String> include = new ArrayList<String>();
        include.add(Bean1.class.getName() + "-property");
        List<Field> fields = reflectionFieldProvider.getProperties(new MultipleBeanSource(bean1, bean2), include);
        Assert.assertEquals(1, fields.size());
        Assert.assertEquals(fields.get(0), ReflectionUtils.getFieldByName(Bean1.class, "property"));
    }
View Full Code Here

    @Test
    public void testMultipleBeanSource() throws IllegalArgumentException {
        FXForm fxForm = new FXForm();
        Bean1 bean1 = new Bean1();
        Bean2 bean2 = new Bean2();
        fxForm.setSource(new MultipleBeanSource(bean1, bean2));
        Assert.assertEquals(3, fxForm.getElements().size());
    }
View Full Code Here

    public void testMultipleBeanSourceWithIncludeFilter() throws IllegalArgumentException {
        FXForm fxForm = new FXForm();
        Bean1 bean1 = new Bean1();
        Bean2 bean2 = new Bean2();
        fxForm.getFilters().add(new IncludeFilter(bean1.getClass().getName() + "-property"));
        fxForm.setSource(new MultipleBeanSource(bean1, bean2));
        Assert.assertEquals(1, fxForm.getFilteredElements().size());
        Assert.assertEquals(fxForm.getFilteredElements().get(0).getDeclaringClass(), Bean1.class);
        fxForm.getFilters().clear();
        fxForm.getFilters().add(new IncludeFilter(bean2.getClass().getName() + "-property"));
        Assert.assertEquals(1, fxForm.getFilteredElements().size());
View Full Code Here

    public void testMultipleBeanSourceWithExcludeFilter() throws IllegalArgumentException {
        FXForm fxForm = new FXForm();
        Bean1 bean1 = new Bean1();
        Bean2 bean2 = new Bean2();
        fxForm.getFilters().add(new ExcludeFilter(bean1.getClass().getName() + "-property"));
        fxForm.setSource(new MultipleBeanSource(bean1, bean2));
        Assert.assertEquals(2, fxForm.getFilteredElements().size());
        Assert.assertEquals(fxForm.getFilteredElements().get(0).getDeclaringClass(), Bean2.class);
        Assert.assertEquals(fxForm.getFilteredElements().get(1).getDeclaringClass(), Bean2.class);
    }
View Full Code Here

        FXForm fxForm = new FXForm();
        Bean1 bean1 = new Bean1();
        Bean2 bean2 = new Bean2();
        fxForm.getFilters().addAll(new ExcludeFilter(bean1.getClass().getName() + "-property"),
                new IncludeFilter(bean2.getClass().getName() + "-property"));
        fxForm.setSource(new MultipleBeanSource(bean1, bean2));
        Assert.assertEquals(1, fxForm.getFilteredElements().size());
        Assert.assertEquals(fxForm.getFilteredElements().get(0).getDeclaringClass(), Bean2.class);
    }
View Full Code Here

  @Test
  public void testThatReorderWorksWellWithSpecificFieldFilter() throws FilterException {
    Bean2 bean2 = new Bean2();
    FXForm fxForm = new FXFormBuilder().include("name", MyAddress.class.getName() + "-address").build
        ();
    fxForm.setSource(new MultipleBeanSource(bean2, bean2.getAddress()));
    ReorderFilter reorderFilter = new ReorderFilter("name", MyAddress.class.getName() + "-address");
    reorderFilter.filter(fxForm.getElements());
  }
View Full Code Here

        FXForm form = new FXFormBuilder<>()
                .includeAndReorder("firstName", "lastName", "age", "favoriteMovie", "coolDeveloper", "street", "city", "zip")
                .resourceBundle(Utils.SAMPLE)
                .build();
        User user = new User();
        form.setSource(new MultipleBeanSource(user, user.address.get()));

        root.getChildren().add(form);
        return root;
    }
View Full Code Here

                .categorizeAndInclude("firstName", "lastName", "age", "favoriteMovie", "coolDeveloper", "-Where ?", "street", "city", "zip")
                .resourceBundle(Utils.SAMPLE)
                .build();

        User user = new User();
        form.setSource(new MultipleBeanSource(user, user.address.get()));

        root.getChildren().add(form);
        return root;
    }
View Full Code Here

TOP

Related Classes of com.dooapp.fxform.reflection.MultipleBeanSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.