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();
}
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;
}
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;
}
Aggregations