Package org.eclipse.e4.xwt.metadata

Examples of org.eclipse.e4.xwt.metadata.IProperty


      //
      // Add to default property identified by the type
      //
      IMetaclass parentMetaclass = XWT.getMetaclass(parent);
      IProperty[] properties = parentMetaclass.getProperties();
      IProperty useProperty = null;
      int count = 0;
      Class<?> childType = childElement.getClass();

      for (IProperty property : properties) {
        Class<?> propertyType = property.getType();
        if (propertyType == null || propertyType == Object.class) {
          continue;
        }
        if (property.isContainement()) {
          useProperty = property;
          count++;
        }
      }
      if (count > 1) {
        StringBuilder builder = new StringBuilder();
        builder.append("Class has more containment properties: ");
        count = 0;
        for (IProperty property : properties) {
          Class<?> propertyType = property.getType();
          if (propertyType == null || propertyType == Object.class) {
            continue;
          }
          if (property.isContainement()) {
            if (count != 0) {
              builder.append(", ");
            }
            builder.append(property.getName());
            count++;
          }
        }
        throw new XWTException(
            "Class has more containment properties: ");
      }

      if (count == 0) {
        for (IProperty property : properties) {
          Class<?> propertyType = property.getType();
          if (propertyType == null || propertyType == Object.class) {
            continue;
          }
          if (propertyType.isArray()) {
            Class<?> dataType = propertyType.getComponentType();
            if (dataType.isAssignableFrom(childType)) {
              if (useProperty == null) {
                useProperty = property;
              }
              count++;
            }
          } else if (Collection.class.isAssignableFrom(propertyType)) {
            if (useProperty == null) {
              useProperty = property;
            }
            count++;
          } else if (propertyType.isAssignableFrom(childType)) {
            if (useProperty == null) {
              useProperty = property;
            }
            count++;
          }
        }
      }
      if (count == 1) {
        Class<?> propertyType = useProperty.getType();
        if (propertyType.isArray()) {
          Object[] existingValue = (Object[]) useProperty
              .getValue(parent);
          Class<?> dataType = propertyType.getComponentType();
          Object[] value = null;
          if (existingValue == null) {
            value = (Object[]) Array.newInstance(dataType, 1);
            value[0] = childElement;
          } else {
            value = (Object[]) Array.newInstance(dataType,
                existingValue.length + 1);
            System.arraycopy(existingValue, 0, value, 0,
                existingValue.length);
            value[existingValue.length] = childElement;
          }
          useProperty.setValue(parent, value);
        } else if (Collection.class.isAssignableFrom(propertyType)
            && !(childElement instanceof IBinding)) {
          Collection existingValue = (Collection) useProperty
              .getValue(parent);
          if (existingValue == null) {
            existingValue = new ArrayList();
          }
          existingValue.add(childElement);
          useProperty.setValue(parent, existingValue);
        } else if (propertyType.isAssignableFrom(childType)) {
          useProperty.setValue(parent, childElement);
        }
      }
    }
  }
View Full Code Here


            || propertyCache
                .containsKey(propertyName.toLowerCase())) {
          continue;
        }
        if (p.getPropertyType() != null) {
          IProperty property = (superClass != null ? superClass
              .findProperty(p.getName().toLowerCase()) : null);
          if (property != null && !property.isDefault()) {
            addProperty(property);
          } else {
            if (p.getWriteMethod() != null
                || !p.getPropertyType().isPrimitive()) {
              addProperty(new BeanProperty(p));
View Full Code Here

    if (type == null || propertyName == null || propertyName.indexOf(".") != -1) {
      return null;
    }
    try {
      IMetaclass metaclass = XWT.getMetaclass(type);
      IProperty property = metaclass.findProperty(propertyName);
      if (property != null) {
        return property.getType();
      }
    } catch (Exception e) {
      LoggerManager.log(e);
    }
    return null;
View Full Code Here

          return;
        }
      }
     
      IMetaclass metaclass = XWT.getMetaclass(type);
      IProperty property = metaclass.findProperty(propertyName);
      if (property != null) {
        property.setValue(target, value);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

    if (type == null || propertyName == null || propertyName.indexOf(".") != -1) {
      return true;
    }
    try {     
      IMetaclass metaclass = XWT.getMetaclass(type);
      IProperty property = metaclass.findProperty(propertyName);
      if (property != null) {
        return property.isReadOnly();
      }
    } catch (Exception e) {
      LoggerManager.log(e);
    }
    return true;
View Full Code Here

      }
    } catch (Exception e) {
      throw new XWTException(e);
    }
    IMetaclass mateclass = XWT.getMetaclass(type);
    IProperty property = mateclass.findProperty(propertyName);
    if (property instanceof EventProperty) {
      return true;
    }
    return false;
  }
View Full Code Here

      } catch (Exception e) {
        throw new XWTException(e);
      }
    }
    IMetaclass mateclass = XWT.getMetaclass(control);
    IProperty property = mateclass.findProperty(propertyName);
    if (property instanceof EventProperty) {
      return new EventPropertyObservableValue(control,
          (EventProperty) property);
    }
    return null;
View Full Code Here

   *
   * @param javaclass
   */
  static public Object getPropertyValue(Object uiElement, String propertyName) {
    IMetaclass metaclass = XWT.getMetaclass(uiElement);
    IProperty property = metaclass.findProperty(propertyName);
    if (property == null) {
      return null;
    }
    return XWTLoaderManager.getActive().getPropertyValue(uiElement,
        property);
View Full Code Here

   * @param javaclass
   */
  static public void setPropertyValue(Object uiElement, String propertyName,
      Object value) {
    IMetaclass metaclass = XWT.getMetaclass(uiElement);
    IProperty property = metaclass.findProperty(propertyName);
    if (property == null) {
      throw new XWTException("Property " + propertyName + " not found.");
    }
    XWTLoaderManager.getActive().setPropertyValue(uiElement, property,
        value);
View Full Code Here

        case SourceToTarget:
          addValidatorToStrategy(sourceToTarget, validator);
          break;
        case TargetToSource:
          addValidatorToStrategy(targetToSource,
              new InverseValidationRule(validator));
          break;
        case Both:
        default:
          addValidatorToStrategy(sourceToTarget, validator);
          addValidatorToStrategy(targetToSource,
              new InverseValidationRule(validator));
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.e4.xwt.metadata.IProperty

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.