Search in sources :

Example 1 with ComponentModel

use of com.github.bordertech.wcomponents.ComponentModel in project wcomponents by BorderTech.

the class ObjectGraphDump method visitComponentModel.

/**
 * Visits all the fields in the given ComponentModel.
 *
 * @param node the ObjectGraphNode containing the ComponentModel.
 */
private void visitComponentModel(final ObjectGraphNode node) {
    ComponentModel model = (ComponentModel) node.getValue();
    ComponentModel sharedModel = null;
    List<Field> fieldList = ReflectionUtil.getAllFields(node.getValue(), true, false);
    Field[] fields = fieldList.toArray(new Field[fieldList.size()]);
    for (int i = 0; i < fields.length; i++) {
        if (ComponentModel.class.equals(fields[i].getDeclaringClass()) && "sharedModel".equals(fields[i].getName())) {
            sharedModel = (ComponentModel) readField(fields[i], model);
            break;
        }
    }
    visitComplexTypeWithDiff(node, sharedModel);
}
Also used : Field(java.lang.reflect.Field) ComponentModel(com.github.bordertech.wcomponents.ComponentModel)

Example 2 with ComponentModel

use of com.github.bordertech.wcomponents.ComponentModel in project wcomponents by BorderTech.

the class UicStats method createStat.

/**
 * Creates statistics for a component in the given context.
 *
 * @param comp the component.
 * @return the stats for the given component in the given context.
 */
private Stat createStat(final WComponent comp) {
    Stat stat = new Stat();
    stat.setClassName(comp.getClass().getName());
    stat.setName(comp.getId());
    if (stat.getName() == null) {
        stat.setName("Unknown");
    }
    if (comp instanceof AbstractWComponent) {
        Object obj = AbstractWComponent.replaceWComponent((AbstractWComponent) comp);
        if (obj instanceof AbstractWComponent.WComponentRef) {
            stat.setRef(obj.toString());
        }
    }
    ComponentModel model = (ComponentModel) uic.getModel(comp);
    stat.setModelState(Stat.MDL_NONE);
    if (model != null) {
        if (comp.isDefaultState()) {
            stat.setModelState(Stat.MDL_DEFAULT);
        } else {
            addSerializationStat(model, stat);
        }
    }
    return stat;
}
Also used : AbstractWComponent(com.github.bordertech.wcomponents.AbstractWComponent) ComponentModel(com.github.bordertech.wcomponents.ComponentModel)

Aggregations

ComponentModel (com.github.bordertech.wcomponents.ComponentModel)2 AbstractWComponent (com.github.bordertech.wcomponents.AbstractWComponent)1 Field (java.lang.reflect.Field)1