コード例 #1
0
  @Override
  protected void registerSynchronizers(SynchronizersConfiguration conf) {
    super.registerSynchronizers(conf);

    conf.add(
        Synchronizers.forPropsTwoWay(getSource().value, ValueEditors.intProperty(getTarget())));
  }
コード例 #2
0
  @Override
  protected void registerSynchronizers(SynchronizersConfiguration conf) {
    super.registerSynchronizers(conf);

    Property<String> text = createCell("test", null);
    Property<Integer> x = new ValueProperty<>(75);
    createCell("75", new IntegerHandler(x));
    Property<Integer> y = new ValueProperty<>(75);
    createCell("75", new IntegerHandler(y));
    final Property<Integer> num = new ValueProperty<>(2);
    createCell("2", new IntegerHandler(num));

    myProperties = new ContentProperties(x, y);

    conf.add(Synchronizers.forPropsTwoWay(text, myContent.name));
    conf.add(
        Synchronizers.forProperty(
            num,
            new Runnable() {
              @Override
              public void run() {
                Integer value = num.get();
                int size = myContent.items.size();
                if (value < size) {
                  for (int i = 0; i < size - value; i++) {
                    myContent.items.remove(0);
                  }
                }
                if (value > size) {
                  for (int i = 0; i < value - size; i++) {
                    myContent.items.add(new ContentItem());
                  }
                }
              }
            }));

    conf.add(
        Synchronizers.forConstantRole(
            this,
            getSource(),
            myView.children(),
            new MapperFactory<Diagram, View>() {
              @Override
              public Mapper<? extends Diagram, ? extends View> createMapper(Diagram source) {
                return new DiagramMapper(
                    source,
                    new MapperFactory<Block, View>() {
                      @Override
                      public Mapper<? extends Block, ? extends View> createMapper(Block source) {
                        return new BlockWithContentMapper(source, myContent, myProperties);
                      }
                    });
              }
            }));

    conf.add(
        Synchronizers.forRegistration(
            new Supplier<Registration>() {
              @Override
              public Registration get() {
                for (Runnable r : myViewAdders) {
                  r.run();
                }
                return Registration.EMPTY;
              }
            }));
  }