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