Search in sources :

Example 1 with ScreenBuilders

use of com.haulmont.cuba.gui.ScreenBuilders in project cuba by cuba-platform.

the class WebLookupScreenFacet method createLookupBuilder.

protected LookupBuilder<E> createLookupBuilder(Frame owner) {
    LookupBuilder<E> builder;
    if (beanLocator == null) {
        throw new IllegalStateException("Unable to create LookupScreenFacet. BeanLocator is null");
    }
    ScreenBuilders screenBuilders = beanLocator.get(ScreenBuilders.class);
    if (entityClass != null) {
        builder = screenBuilders.lookup(entityClass, owner.getFrameOwner());
    } else if (listComponent != null) {
        builder = screenBuilders.lookup(listComponent);
    } else if (pickerField != null) {
        builder = screenBuilders.lookup(pickerField);
    } else {
        throw new IllegalStateException("Unable to create LookupScreen Facet. At least one of entityClass, listComponent or field must be specified");
    }
    if (screenClass != null) {
        builder = builder.withScreenClass(screenClass);
    } else {
        builder.withScreenId(screenId);
    }
    return builder;
}
Also used : ScreenBuilders(com.haulmont.cuba.gui.ScreenBuilders)

Example 2 with ScreenBuilders

use of com.haulmont.cuba.gui.ScreenBuilders in project cuba by cuba-platform.

the class WebEditorScreenFacet method createEditorBuilder.

@SuppressWarnings("unchecked")
protected EditorBuilder<E> createEditorBuilder(Frame owner, @Nullable E entityToEdit) {
    EditorBuilder<E> builder;
    ScreenBuilders screenBuilders = beanLocator.get(ScreenBuilders.class);
    if (entityClass != null) {
        builder = screenBuilders.editor(entityClass, owner.getFrameOwner());
    } else if (entityToEdit != null) {
        builder = (EditorBuilder<E>) screenBuilders.editor(entityToEdit.getClass(), owner.getFrameOwner());
    } else if (listComponent != null) {
        builder = screenBuilders.editor(listComponent);
    } else if (pickerField != null) {
        builder = screenBuilders.editor(pickerField);
    } else {
        throw new IllegalStateException("Unable to create EditorScreen Facet. At least one of entityClass, listComponent or field must be specified");
    }
    if (editMode == EditMode.CREATE) {
        builder.newEntity(entityToEdit);
    } else {
        if (entityToEdit != null) {
            builder.editEntity(entityToEdit);
        } else {
            throw new DevelopmentException("No entity to edit is passed for EditorScreen");
        }
    }
    if (screenClass != null) {
        builder = builder.withScreenClass(screenClass);
    } else {
        builder.withScreenId(screenId);
    }
    return builder;
}
Also used : EditorBuilder(com.haulmont.cuba.gui.builders.EditorBuilder) ScreenBuilders(com.haulmont.cuba.gui.ScreenBuilders) DevelopmentException(com.haulmont.cuba.core.global.DevelopmentException)

Aggregations

ScreenBuilders (com.haulmont.cuba.gui.ScreenBuilders)2 DevelopmentException (com.haulmont.cuba.core.global.DevelopmentException)1 EditorBuilder (com.haulmont.cuba.gui.builders.EditorBuilder)1