private void executeChildren(EObject value) {
   // allow other adapters to execute first
   for (EStructuralFeature f : value.eClass().getEAllStructuralFeatures()) {
     try {
       Object v = value.eGet(f);
       if (v instanceof List) {
         executeChildren((List) v);
       } else if (v instanceof EObject) {
         executeIfNeeded((EObject) v);
       }
     } catch (Exception e) {
       // some getters may throw exceptions - ignore those
     }
   }
   executeIfNeeded(value);
 }
  @SuppressWarnings("unchecked")
  public void execute() {
    // if the object into which this value is being added has other adapters execute those first
    executeIfNeeded(object);

    // remove this adapter from the value - this adapter is a one-shot deal!
    value.eAdapters().remove(this);
    try {
      Object o = object.eGet(feature);
    } catch (Exception e1) {
      try {
        Object o = value.eGet(feature);
        // this is the inverse add of object into value
        o = value;
        value = object;
        object = (EObject) o;
      } catch (Exception e2) {
      }
    }
    // if there are any EObjects contained or referenced by this value, execute those adapters first
    executeChildren(value);

    // set the value in the object
    boolean valueChanged = false;
    final EList<EObject> list = feature.isMany() ? (EList<EObject>) object.eGet(feature) : null;
    if (list == null) valueChanged = object.eGet(feature) != value;
    else valueChanged = !list.contains(value);

    if (valueChanged) {
      TransactionalEditingDomain domain = getEditingDomain();
      if (domain == null) {
        if (list == null) object.eSet(feature, value);
        else list.add(value);
        // assign the value's ID if it has one:
        // because of changes made by cascading InsertionAdapters,
        // the object could now be contained in a resource and hence
        // the setID() will need to be executed on the command stack.
        domain = getEditingDomain();
        if (domain == null) {
          ModelUtil.setID(value);
        } else {
          domain
              .getCommandStack()
              .execute(
                  new RecordingCommand(domain) {
                    @Override
                    protected void doExecute() {
                      ModelUtil.setID(value);
                    }
                  });
        }
      } else {
        domain
            .getCommandStack()
            .execute(
                new RecordingCommand(domain) {
                  @Override
                  protected void doExecute() {
                    ExtendedPropertiesAdapter adapter =
                        (ExtendedPropertiesAdapter)
                            AdapterUtil.adapt(object, ExtendedPropertiesAdapter.class);
                    if (adapter != null) {
                      adapter.getFeatureDescriptor(feature).setValue(value);
                    } else {
                      if (list == null) object.eSet(feature, value);
                      else list.add(value);
                    }
                    // assign the value's ID if it has one
                    ModelUtil.setID(value);
                  }
                });
      }
    }
  }