protected PropertyDefinition getPropertyDefinition(
      FieldSelection fieldSelection, Property property) {
    List<String> propertyPath = getPropertyPath(property.getContextElement());
    if (propertyPath.isEmpty()) {
      return null;
    }

    ContextElement currentElement = null;
    for (ContextElement contextRoot : fieldSelection.getContextElements()) {
      if (contextRoot.getName().equals(propertyPath.get(0))) {
        currentElement = contextRoot;
      }
    }

    propertyPath.remove(0);
    if (currentElement == null) {
      return null;
    }

    while (propertyPath.size() > 0) {
      String name = propertyPath.get(0);
      propertyPath.remove(0);
      currentElement = findByName(currentElement, name);
    }

    for (PropertyDefinition definition : currentElement.getProperties()) {
      if (definition.getName().equals(property.getName())) {
        return definition;
      }
    }

    return null;
  }
示例#2
0
  protected Context findContext(Property property) {
    DataContextElement element = property.getContextElement();
    if (element instanceof DataContextRoot) {
      // TODO : Add a container reference to Context
      return (Context) element.eContainer();
    }

    return findContext(element);
  }