diff --git a/modules/gui/src/com/haulmont/cuba/gui/components/RuntimePropertiesFrame.java b/modules/gui/src/com/haulmont/cuba/gui/components/RuntimePropertiesFrame.java index 61d6b461af..3899ed09b6 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/components/RuntimePropertiesFrame.java +++ b/modules/gui/src/com/haulmont/cuba/gui/components/RuntimePropertiesFrame.java @@ -15,6 +15,7 @@ import com.haulmont.chile.core.model.MetaPropertyPath; import com.haulmont.chile.core.model.Range; import com.haulmont.cuba.core.entity.CategoryAttributeValue; import com.haulmont.cuba.core.global.AppBeans; +import com.haulmont.cuba.core.global.DevelopmentException; import com.haulmont.cuba.core.global.View; import com.haulmont.cuba.core.sys.SetValueEntity; import com.haulmont.cuba.gui.AppConfig; @@ -56,11 +57,7 @@ public class RuntimePropertiesFrame extends AbstractWindow { @Override public void init(Map params) { - String dsId = (String) params.get("runtimeDs"); - Preconditions.checkNotNullArgument(dsId, "runtimePropsDatasource is not set"); - - String categoriesDsId = (String) params.get("categoriesDs"); - Preconditions.checkNotNullArgument(categoriesDsId, "categoriesDs is not set"); + initDatasources(params); rows = (String) params.get("rows"); cols = (String) params.get("cols"); @@ -70,14 +67,28 @@ public class RuntimePropertiesFrame extends AbstractWindow { if (StringUtils.isEmpty(fieldWidth)) { fieldWidth = DEFAULT_FIELD_WIDTH; } - rds = getDsContext().get(dsId); - categoriesDs = getDsContext().get(categoriesDsId); contentPane = getComponent("contentPane"); initCategoryField(); loadComponent(rds); } + protected void initDatasources(Map params) { + String dsId = (String) params.get("runtimeDs"); + if (dsId == null) + throw new DevelopmentException("runtimeProperties initialization error: runtimeDs is not provided"); + rds = getDsContext().get(dsId); + if (rds == null) + throw new DevelopmentException("runtimeProperties initialization error: runtimeDs '" + dsId + "' does not exists"); + + String categoriesDsId = (String) params.get("categoriesDs"); + if (categoriesDsId == null) + throw new DevelopmentException("runtimeProperties initialization error: categoriesDs is not provided"); + categoriesDs = getDsContext().get(categoriesDsId); + if (categoriesDs == null) + throw new DevelopmentException("runtimeProperties initialization error: categoriesDs '" + categoriesDsId + "' does not exists"); + } + private void initCategoryField() { categoryFieldGroup = AppConfig.getFactory().createComponent(FieldGroup.NAME); categoryFieldGroup.setId("categoryFieldGroup"); diff --git a/modules/gui/src/com/haulmont/cuba/gui/data/impl/RuntimePropsDatasourceImpl.java b/modules/gui/src/com/haulmont/cuba/gui/data/impl/RuntimePropsDatasourceImpl.java index 0980d73e85..d28a9d5762 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/data/impl/RuntimePropsDatasourceImpl.java +++ b/modules/gui/src/com/haulmont/cuba/gui/data/impl/RuntimePropsDatasourceImpl.java @@ -10,6 +10,7 @@ import com.haulmont.chile.core.model.MetaProperty; import com.haulmont.cuba.core.entity.*; import com.haulmont.cuba.core.global.*; import com.haulmont.cuba.core.sys.SetValueEntity; +import com.haulmont.cuba.gui.GuiDevelopmentException; import com.haulmont.cuba.gui.data.*; import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; @@ -389,6 +390,8 @@ public class RuntimePropsDatasourceImpl protected void setMainDs(String name) { mainDs = dsContext.get(name); + if (mainDs == null) + throw new DevelopmentException("runtimePropsDatasource initialization error: mainDs '" + name + "' does not exists"); mainDs.addListener( new DsListenerAdapter() { @Override