use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class AbstractDataGridLoader method loadColumn.
protected Column loadColumn(DataGrid component, Element element, MetaClass metaClass) {
String id = element.attributeValue("id");
String property = element.attributeValue("property");
if (id == null) {
if (property != null) {
id = property;
} else {
throw new GuiDevelopmentException("A column must have whether id or property specified", context, "DataGrid ID", component.getId());
}
}
Column column;
if (property != null) {
MetaPropertyPath metaPropertyPath = getMetadataTools().resolveMetaPropertyPathOrNull(metaClass, property);
column = component.addColumn(id, metaPropertyPath);
} else {
column = component.addColumn(id, null);
}
String expandRatio = element.attributeValue("expandRatio");
if (StringUtils.isNotEmpty(expandRatio)) {
column.setExpandRatio(Integer.parseInt(expandRatio));
}
String collapsed = element.attributeValue("collapsed");
if (StringUtils.isNotEmpty(collapsed)) {
column.setCollapsed(Boolean.parseBoolean(collapsed));
}
String collapsible = element.attributeValue("collapsible");
if (StringUtils.isNotEmpty(collapsible)) {
column.setCollapsible(Boolean.parseBoolean(collapsible));
}
String collapsingToggleCaption = element.attributeValue("collapsingToggleCaption");
if (StringUtils.isNotEmpty(collapsingToggleCaption)) {
collapsingToggleCaption = loadResourceString(collapsingToggleCaption);
column.setCollapsingToggleCaption(collapsingToggleCaption);
}
String sortable = element.attributeValue("sortable");
if (StringUtils.isNotEmpty(sortable)) {
column.setSortable(Boolean.parseBoolean(sortable));
}
String resizable = element.attributeValue("resizable");
if (StringUtils.isNotEmpty(resizable)) {
column.setResizable(Boolean.parseBoolean(resizable));
}
String editable = element.attributeValue("editable");
if (StringUtils.isNotEmpty(editable)) {
column.setEditable(Boolean.parseBoolean(editable));
}
String sort = element.attributeValue("sort");
if (StringUtils.isNotBlank(sort)) {
loadColumnSort(component, column, sort);
}
String caption = loadCaption(element);
if (caption == null) {
String columnCaption;
if (column.getPropertyPath() != null) {
MetaProperty metaProperty = column.getPropertyPath().getMetaProperty();
String propertyName = metaProperty.getName();
MetaClass propertyMetaClass = getMetadataTools().getPropertyEnclosingMetaClass(column.getPropertyPath());
columnCaption = getMessageTools().getPropertyCaption(propertyMetaClass, propertyName);
} else {
Class<?> declaringClass = metaClass.getJavaClass();
String className = declaringClass.getName();
int i = className.lastIndexOf('.');
if (i > -1) {
className = className.substring(i + 1);
}
columnCaption = getMessages().getMessage(declaringClass, className + "." + id);
}
column.setCaption(columnCaption);
} else {
column.setCaption(caption);
}
((Component.HasXmlDescriptor) column).setXmlDescriptor(element);
Integer width = loadSizeInPx(element, "width");
if (width != null) {
column.setWidth(width);
}
Integer minimumWidth = loadSizeInPx(element, "minimumWidth");
if (minimumWidth != null) {
column.setMinimumWidth(minimumWidth);
}
Integer maximumWidth = loadSizeInPx(element, "maximumWidth");
if (maximumWidth != null) {
column.setMaximumWidth(maximumWidth);
}
loadColumnVisualDisplay(column, element);
loadAggregation(column, element);
return column;
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class AbstractDataGridLoader method loadStrategyClass.
protected void loadStrategyClass(AggregationInfo aggregation, Element aggregationElement) {
String strategyClass = aggregationElement.attributeValue("strategyClass");
if (StringUtils.isNotEmpty(strategyClass)) {
Class<?> aggregationClass = getClassManager().findClass(strategyClass);
if (aggregationClass == null) {
throw new GuiDevelopmentException(String.format("Class %s is not found", strategyClass), context);
}
try {
Constructor<?> constructor = aggregationClass.getDeclaredConstructor();
AggregationStrategy customStrategy = (AggregationStrategy) constructor.newInstance();
applicationContext.getAutowireCapableBeanFactory().autowireBean(customStrategy);
aggregation.setStrategy(customStrategy);
} catch (Exception e) {
throw new RuntimeException("Unable to instantiate strategy for aggregation", e);
}
}
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class PivotTableLoader method loadDataContainer.
protected void loadDataContainer(PivotTable pivotTable, Element element) {
String dataContainerId = element.attributeValue("dataContainer");
if (StringUtils.isNotEmpty(dataContainerId)) {
FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
CollectionContainer dataContainer;
InstanceContainer container = screenData.getContainer(dataContainerId);
if (container instanceof CollectionContainer) {
dataContainer = (CollectionContainer) container;
} else {
throw new GuiDevelopmentException("Not a CollectionContainer: " + dataContainerId, context);
}
pivotTable.setDataProvider(new ContainerDataProvider(dataContainer));
}
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class ScreenSettingsFacetProvider method loadComponentIds.
protected List<String> loadComponentIds(ComponentLoader.ComponentContext context, Element root) {
Element componentsElement = root.element("components");
if (componentsElement == null) {
return Collections.emptyList();
}
List<Element> components = componentsElement.elements("component");
List<String> result = new ArrayList<>(components.size());
for (Element element : components) {
String id = element.attributeValue("id");
if (id == null) {
throw new GuiDevelopmentException("ScreenSettings component does not define an id", context);
}
result.add(id);
}
return result;
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class TokenListLoader method loadLookup.
protected void loadLookup(TokenList component, Element element) {
Element lookupElement = element.element("lookup");
if (lookupElement == null) {
throw new GuiDevelopmentException("'tokenList' must contain 'lookup' element", context, "TokenList ID", element.attributeValue("id"));
}
loadOptionsContainer(component, lookupElement);
loadLookupCaptionProperty(component, lookupElement);
String lookup = lookupElement.attributeValue("lookup");
if (StringUtils.isNotEmpty(lookup)) {
component.setLookup(Boolean.parseBoolean(lookup));
if (component.isLookup()) {
String lookupScreen = lookupElement.attributeValue("lookupScreen");
if (StringUtils.isNotEmpty(lookupScreen)) {
component.setLookupScreen(lookupScreen);
}
loadLookupOpenMode(component, lookupElement);
}
}
String multiSelect = lookupElement.attributeValue("multiselect");
if (StringUtils.isNotEmpty(multiSelect)) {
component.setMultiSelect(Boolean.parseBoolean(multiSelect));
}
String inputPrompt = lookupElement.attributeValue("inputPrompt");
if (StringUtils.isNotEmpty(inputPrompt)) {
component.setLookupInputPrompt(loadResourceString(inputPrompt));
}
loadFilterMode(component, lookupElement);
}
Aggregations