private ConnectorDecoratorView createConnectorDecoratorView() {
   ConnectorDecoratorView connectorDecoratorView = new ConnectorDecoratorView();
   DiagramCell diagramCell = getDiagramCell();
   if (diagramCell == null) {
     return connectorDecoratorView;
   }
   Mapper<? super SNode, ?> descendantMapper =
       getDiagramCell().getRootMapper().getDescendantMapper(getSNode());
   if (descendantMapper == null) {
     return connectorDecoratorView;
   }
   connectorDecoratorView.setSegments(
       ((PolyLineConnection) descendantMapper.getTarget()).getSegments());
   return connectorDecoratorView;
 }
 @Override
 protected void onDetach() {
   getTarget().children().clear();
   myPopupManager.dispose();
   myContext.unregister(this);
   super.onDetach();
 }
  @Override
  protected void registerSynchronizers(SynchronizersConfiguration conf) {
    super.registerSynchronizers(conf);

    conf.add(
        Synchronizers.forPropsTwoWay(getSource().value, ValueEditors.intProperty(getTarget())));
  }
    private Runnable replaceWith(final BinaryExpression newExpr) {
      final Mapper<?, ?> root = Mappers.getRoot(myMapper);

      BinaryExpression oldExpr = myMapper.getSource();
      oldExpr.replaceWith(newExpr);

      Expression left = oldExpr.left.get();
      if (left != null) {
        left.removeFromParent();
      }
      Expression right = oldExpr.right.get();
      if (right != null) {
        right.removeFromParent();
      }

      newExpr.left.set(left);
      newExpr.right.set(right);

      new ExprBinOpTransformer().balanceOnOperationChange(newExpr).parent().get();

      return CellActions.toEnd(
          ((BinaryExpressionMapper) root.getDescendantMapper(newExpr)).getTarget().sign);
    }
  @Override
  protected void registerSynchronizers(SynchronizersConfiguration conf) {
    super.registerSynchronizers(conf);

    ProjectionalRoleSynchronizer<ExpressionAstNode, Expression> leftSync =
        ExprSynchronizers.expressionSynchronizer(this, getSource().left, getTarget().left);
    leftSync.setDeleteHandler(
        new DeleteHandler() {
          @Override
          public boolean canDelete() {
            return true;
          }

          @Override
          public Runnable delete() {
            Mapper<?, ?> parentMapper = getParent();
            Expression right = getSource().right.get();
            right.removeFromParent();
            getSource().replaceWith(right);
            return CellActions.toFirstFocusable(
                (Cell) parentMapper.getDescendantMapper(right).getTarget());
          }
        });
    conf.add(leftSync);

    ProjectionalRoleSynchronizer<ExpressionAstNode, Expression> rightSync =
        ExprSynchronizers.expressionSynchronizer(this, getSource().right, getTarget().right);
    rightSync.setDeleteHandler(
        new DeleteHandler() {
          @Override
          public boolean canDelete() {
            return true;
          }

          @Override
          public Runnable delete() {
            Mapper<?, ?> parentMapper = getParent();
            Expression left = getSource().left.get();
            left.removeFromParent();
            getSource().replaceWith(left);
            return CellActions.toFirstFocusable(
                (Cell) parentMapper.getDescendantMapper(left).getTarget());
          }
        });

    conf.add(rightSync);
  }
  @Override
  protected void onAttach(MappingContext ctx) {
    super.onAttach(ctx);

    myContext.register(this);

    if (isAutoChildManagement()) {
      myChildMappers = createChildList();
      ObservableList<Cell> children = getSource().children();
      for (int i = 0; i < children.size(); i++) {
        childAdded(i, children.get(i));
      }
    }

    myPopupManager = createPopupManager();
    myPopupManager.attach(getSource());

    refreshProperties();
  }
  @Override
  protected void registerSynchronizers(SynchronizersConfiguration conf) {
    super.registerSynchronizers(conf);

    conf.add(Synchronizers.forPropsOneWay(Properties.TRUE, myTargetView.focusable()));
    conf.add(
        Synchronizers.<Cell, View>forSingleRole(
            this,
            Properties.<Cell>constant(getSource().root),
            new WritableProperty<View>() {
              @Override
              public void set(View value) {
                myTargetView.children().clear();
                if (value != null) {
                  myTargetView.children().add(value);
                }
              }
            },
            new MapperFactory<Cell, View>() {
              @Override
              public Mapper<? extends Cell, ? extends View> createMapper(Cell source) {
                return CellMappers.create(source, myContext);
              }
            }));
    conf.add(
        Synchronizers.forRegistration(
            new Supplier<Registration>() {
              @Override
              public Registration get() {
                ViewTrait redispatchTrait = createRedistpatchTrait();
                myContext.containerFocused().set(myTargetView.focused().get());
                return new CompositeRegistration(
                    getSource().addListener(createCellContainerListener()),
                    getSource()
                        .focusedCell
                        .addHandler(
                            new EventHandler<PropertyChangeEvent<Cell>>() {
                              @Override
                              public void onEvent(PropertyChangeEvent<Cell> event) {
                                if (event.getNewValue() != null) {
                                  myTargetView.container().focusedView().set(myTargetView);
                                }
                              }
                            }),
                    myTargetView
                        .focused()
                        .addHandler(
                            new EventHandler<PropertyChangeEvent<Boolean>>() {
                              @Override
                              public void onEvent(PropertyChangeEvent<Boolean> event) {
                                myContext.containerFocused().set(event.getNewValue());
                                for (TextCell cell : myWithCaret) {
                                  BaseCellMapper<?, ?> mapper =
                                      (BaseCellMapper<?, ?>) rootMapper().getDescendantMapper(cell);
                                  mapper.refreshProperties();
                                }
                                for (Cell cell : myHighlighted) {
                                  BaseCellMapper<?, ?> mapper =
                                      (BaseCellMapper<?, ?>) rootMapper().getDescendantMapper(cell);
                                  mapper.refreshProperties();
                                }
                              }
                            }),
                    getTarget().addTrait(redispatchTrait),
                    myPopupView.addTrait(redispatchTrait));
              }
            }));
  }
 @Override
 protected void onDetach() {
   super.onDetach();
   getSource().resetContainerPeer();
 }
 @Override
 protected void onAttach(MappingContext ctx) {
   super.onAttach(ctx);
   getSource().setCellContainerPeer(createContainerPeer());
 }
  @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;
              }
            }));
  }