use of io.jmix.core.DevelopmentException 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.core.DevelopmentException in project jmix by jmix-framework.
the class DsContextLoader method loadProperties.
private void loadProperties(Element element, ValueDatasource datasource) {
Element propsEl = element.element("properties");
if (propsEl != null) {
for (Element propEl : propsEl.elements()) {
String name = propEl.attributeValue("name");
String className = propEl.attributeValue("class");
if (className != null) {
datasource.addProperty(name, ReflectionHelper.getClass(className));
} else {
String typeName = propEl.attributeValue("datatype");
Datatype datatype = typeName == null ? Datatypes.getNN(String.class) : Datatypes.get(typeName);
datasource.addProperty(name, datatype);
}
}
String idProperty = propsEl.attributeValue("idProperty");
if (idProperty != null) {
if (datasource.getMetaClass().findProperty(idProperty) == null)
throw new DevelopmentException(String.format("Property '%s' is not defined", idProperty));
datasource.setIdName(idProperty);
}
}
}
use of io.jmix.core.DevelopmentException in project jmix by jmix-framework.
the class DsContextLoader method loadHierarchicalDatasource.
protected Datasource loadHierarchicalDatasource(Element element) {
MetaClass metaClass = loadMetaClass(element);
if (metaClass == null)
throw new DevelopmentException("'class' attribute is not set for the datasource");
initCollectionDatasourceAttributes(element, metaClass);
HierarchicalDatasource datasource = builder.setDsClass(getDatasourceClass(element)).buildHierarchicalDatasource();
String hierarchyProperty = element.attributeValue("hierarchyProperty");
if (!StringUtils.isEmpty(hierarchyProperty)) {
datasource.setHierarchyPropertyName(hierarchyProperty);
}
if (datasource instanceof CollectionDatasource.Suspendable)
((CollectionDatasource.Suspendable) datasource).setSuspended(true);
loadQuery(element, datasource);
loadDatasources(element, datasource);
return datasource;
}
use of io.jmix.core.DevelopmentException in project jmix by jmix-framework.
the class DsContextLoader method loadCollectionDatasource.
protected CollectionDatasource loadCollectionDatasource(Element element) {
MetaClass metaClass = loadMetaClass(element);
if (metaClass == null)
throw new DevelopmentException("'class' attribute is not set for the datasource");
initCollectionDatasourceAttributes(element, metaClass);
CollectionDatasource datasource = builder.setDsClass(getDatasourceClass(element)).buildCollectionDatasource();
String maxResults = element.attributeValue("maxResults");
if (!StringUtils.isEmpty(maxResults))
datasource.setMaxResults(Integer.parseInt(maxResults));
if (datasource instanceof CollectionDatasource.Suspendable)
((CollectionDatasource.Suspendable) datasource).setSuspended(true);
loadQuery(element, datasource);
loadDatasources(element, datasource);
return datasource;
}
use of io.jmix.core.DevelopmentException in project jmix by jmix-framework.
the class EntityLookupAction method execute.
/**
* Executes the action.
*/
@SuppressWarnings("unchecked")
@Override
public void execute() {
MetaClass metaClass = entityPicker.getMetaClass();
if (metaClass == null) {
throw new DevelopmentException("Neither metaClass nor dataContainer/property is specified " + "for the EntityPicker", "action ID", getId());
}
LookupBuilder builder = screenBuilders.lookup(entityPicker);
builder = screenInitializer.initBuilder(builder);
if (selectValidator != null) {
builder = builder.withSelectValidator(selectValidator);
}
if (transformation != null) {
builder = builder.withTransformation(transformation);
}
Screen lookupScreen = builder.build();
screenInitializer.initScreen(lookupScreen);
lookupScreen.show();
}
Aggregations