Search in sources :

Example 1 with ScreenBuilders

use of io.jmix.ui.ScreenBuilders in project jmix by jmix-framework.

the class SelectValueDialog method lookupActionPerformed.

@SuppressWarnings("unchecked")
protected void lookupActionPerformed(Action.ActionPerformedEvent actionPerformedEvent) {
    // noinspection unchecked
    EntityPicker<Object> entityPicker = (EntityPicker<Object>) actionPerformedEvent.getComponent();
    ScreenBuilders screenBuilders = getApplicationContext().getBean(ScreenBuilders.class);
    LookupBuilder<Object> builder = screenBuilders.lookup(entityPicker).withSelectHandler(items -> {
        if (CollectionUtils.isNotEmpty(items)) {
            for (Object item : items) {
                if (item != null && !valueExists((V) item)) {
                    this.addValueToLayout((V) item);
                }
            }
        }
        entityPicker.setValue(null);
    });
    if (!Strings.isNullOrEmpty(context.getLookupScreenId())) {
        builder.withScreenId(context.getLookupScreenId());
    }
    builder.show();
}
Also used : ScreenBuilders(io.jmix.ui.ScreenBuilders)

Example 2 with ScreenBuilders

use of io.jmix.ui.ScreenBuilders in project jmix by jmix-framework.

the class EditorScreenFacetImpl method createEditorBuilder.

@SuppressWarnings("unchecked")
protected EditorBuilder<E> createEditorBuilder(Frame owner, @Nullable E entityToEdit) {
    EditorBuilder<E> builder;
    ScreenBuilders screenBuilders = applicationContext.getBean(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 (entityPicker != null) {
        builder = screenBuilders.editor(entityPicker);
    } else {
        throw new IllegalStateException("Unable to create EditorScreenFacet. At least one of entityClass," + "listComponent or field must be specified");
    }
    if (editMode == EditMode.CREATE) {
        builder.newEntity(entityProvider != null ? entityToEdit : null);
    } 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(io.jmix.ui.builder.EditorBuilder) ScreenBuilders(io.jmix.ui.ScreenBuilders) DevelopmentException(io.jmix.core.DevelopmentException)

Example 3 with ScreenBuilders

use of io.jmix.ui.ScreenBuilders in project jmix by jmix-framework.

the class LookupScreenFacetImpl method createLookupBuilder.

protected LookupBuilder<E> createLookupBuilder(Frame owner) {
    LookupBuilder<E> builder;
    if (applicationContext == null) {
        throw new IllegalStateException("Unable to create LookupScreenFacet. ApplicationContext is null");
    }
    ScreenBuilders screenBuilders = applicationContext.getBean(ScreenBuilders.class);
    if (entityClass != null) {
        builder = screenBuilders.lookup(entityClass, owner.getFrameOwner());
    } else if (listComponent != null) {
        builder = screenBuilders.lookup(listComponent);
    } else if (entityPicker != null) {
        builder = screenBuilders.lookup(entityPicker);
    } else {
        throw new IllegalStateException("Unable to create LookupScreenFacet. 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(io.jmix.ui.ScreenBuilders)

Aggregations

ScreenBuilders (io.jmix.ui.ScreenBuilders)3 DevelopmentException (io.jmix.core.DevelopmentException)1 EditorBuilder (io.jmix.ui.builder.EditorBuilder)1