Search in sources :

Example 1 with HasPresentationModelChangeSupport

use of org.robobinding.presentationmodel.HasPresentationModelChangeSupport in project RoboBinding by RoboBinding.

the class PresentationModelObjectLoader method load.

public AbstractPresentationModelObject load(Object presentationModel) {
    if (presentationModel instanceof HasPresentationModelChangeSupport) {
        Preconditions.checkNotNull(((HasPresentationModelChangeSupport) presentationModel).getPresentationModelChangeSupport(), "The PresentationModelChangeSupport from presentationModel.getPresentationModelChangeSupport() must not be null");
    }
    String presentationModelObjectClassName = getObjectClassName(presentationModel.getClass().getName());
    Class<?> presentationModelObjectType;
    try {
        presentationModelObjectType = Class.forName(presentationModelObjectClassName);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(MessageFormat.format("The source code for ''{0}'' is not generated. Is Java annotation processing(source code generation) correctly configured?", presentationModelObjectClassName));
    }
    try {
        return (AbstractPresentationModelObject) ConstructorUtils.invokeConstructor(presentationModelObjectType, presentationModel);
    } catch (NoSuchMethodException e) {
        throw new Bug("This is a bug of constructor code generation", e);
    } catch (IllegalAccessException e) {
        throw new Bug("This is a bug of constructor code generation", e);
    } catch (InvocationTargetException e) {
        throw new Bug("This is a bug of constructor code generation", e);
    } catch (InstantiationException e) {
        throw new Bug("This is a bug of constructor code generation", e);
    }
}
Also used : Bug(org.robobinding.Bug) AbstractPresentationModelObject(org.robobinding.presentationmodel.AbstractPresentationModelObject) HasPresentationModelChangeSupport(org.robobinding.presentationmodel.HasPresentationModelChangeSupport) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with HasPresentationModelChangeSupport

use of org.robobinding.presentationmodel.HasPresentationModelChangeSupport in project RoboBinding by RoboBinding.

the class PresentationModel_AutoGenerationTest method observePropertyChange.

private void observePropertyChange(Object presentationModel, String propertyName) {
    PresentationModelChangeSupport changeSupport = ((HasPresentationModelChangeSupport) presentationModel).getPresentationModelChangeSupport();
    changeSupport.addPropertyChangeListener(propertyName, propertyChangeListenerTester);
}
Also used : HasPresentationModelChangeSupport(org.robobinding.presentationmodel.HasPresentationModelChangeSupport) PresentationModelChangeSupport(org.robobinding.presentationmodel.PresentationModelChangeSupport) HasPresentationModelChangeSupport(org.robobinding.presentationmodel.HasPresentationModelChangeSupport)

Aggregations

HasPresentationModelChangeSupport (org.robobinding.presentationmodel.HasPresentationModelChangeSupport)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Bug (org.robobinding.Bug)1 AbstractPresentationModelObject (org.robobinding.presentationmodel.AbstractPresentationModelObject)1 PresentationModelChangeSupport (org.robobinding.presentationmodel.PresentationModelChangeSupport)1