use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class MessageDialogFacetImpl method subscribeOnAction.
protected void subscribeOnAction(Frame owner) {
Action action = ComponentsHelper.findAction(owner, actionId);
if (!(action instanceof BaseAction)) {
throw new GuiDevelopmentException(String.format("Unable to find Dialog target button with id '%s'", actionId), owner.getId());
}
((BaseAction) action).addActionPerformedListener(e -> show());
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class NotificationFacetImpl method subscribeOnAction.
protected void subscribeOnAction(Frame owner) {
Action action = ComponentsHelper.findAction(owner, actionId);
if (!(action instanceof BaseAction)) {
throw new GuiDevelopmentException(String.format("Unable to find Notification target action with id '%s'", actionId), owner.getId());
}
((BaseAction) action).addActionPerformedListener(e -> show());
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class FilterLoader method loadConfigurations.
protected void loadConfigurations(Filter component, Element element) {
Set<String> filterPaths = new HashSet<>();
getComponentContext().addPostInitTask((context1, window) -> {
ComponentsHelper.walkComponents(window, (visitingComponent, name) -> {
if (visitingComponent instanceof Filter) {
String path = FilterUtils.generateFilterPath((Filter) visitingComponent);
if (filterPaths.contains(path)) {
throw new GuiDevelopmentException("Filters with the same component path should have different ids", getComponentContext());
} else {
filterPaths.add(path);
}
}
});
component.loadConfigurationsAndApplyDefault();
});
Element configurationsElement = element.element("configurations");
if (configurationsElement != null) {
for (Element configurationElement : configurationsElement.elements("configuration")) {
loadConfiguration(component, configurationElement);
}
}
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class FormLoader method loadColumns.
protected void loadColumns(Form resultComponent, Element element) {
if (element.elements("column").isEmpty()) {
Iterable<ComponentPosition> rootComponents = loadComponents(element, null, null);
for (ComponentPosition component : rootComponents) {
resultComponent.add(component.getComponent(), 0, component.getColSpan(), component.getRowSpan());
}
} else {
List<Element> columnElements = element.elements("column");
if (element.elements().size() > columnElements.size()) {
String fieldGroupId = resultComponent.getId();
Map<String, Object> params = Strings.isNullOrEmpty(fieldGroupId) ? Collections.emptyMap() : ParamsMap.of("Form ID", fieldGroupId);
throw new GuiDevelopmentException("Form component elements have to be placed within its column.", context, params);
}
resultComponent.setColumns(columnElements.size());
int colIndex = 0;
for (Element columnElement : columnElements) {
String columnWidth = loadThemeString(columnElement.attributeValue("width"));
String flexAttr = columnElement.attributeValue("flex");
Float flex = null;
if (!Strings.isNullOrEmpty(flexAttr)) {
flex = Float.parseFloat(flexAttr);
resultComponent.setColumnFlex(colIndex, flex);
}
Iterable<ComponentPosition> columnComponents = loadComponents(columnElement, columnWidth, flex);
for (ComponentPosition component : columnComponents) {
resultComponent.add(component.getComponent(), colIndex, component.getColSpan(), component.getRowSpan());
}
loadChildrenCaptionAlignment(resultComponent, columnElement, colIndex);
loadChildrenCaptionWidth(resultComponent, columnElement, colIndex);
colIndex++;
}
}
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class AbstractTableLoader method loadColumn.
protected Table.Column loadColumn(Table component, Element element, MetaClass metaClass) {
Object id = loadColumnId(element, metaClass);
Table.Column column = component.addColumn(id);
String editable = element.attributeValue("editable");
if (StringUtils.isNotEmpty(editable)) {
column.setEditable(Boolean.parseBoolean(editable));
}
String collapsed = element.attributeValue("collapsed");
if (StringUtils.isNotEmpty(collapsed)) {
column.setCollapsed(Boolean.parseBoolean(collapsed));
}
String sortable = element.attributeValue("sortable");
if (StringUtils.isNotEmpty(sortable)) {
column.setSortable(Boolean.parseBoolean(sortable));
}
String sort = element.attributeValue("sort");
if (StringUtils.isNotBlank(sort)) {
loadColumnSort(column, sort);
}
loadCaption(column, element);
loadDescription(column, element);
if (column.getCaption() == null) {
String columnCaption;
if (column.getId() instanceof MetaPropertyPath) {
MetaPropertyPath mpp = (MetaPropertyPath) column.getId();
MetaProperty metaProperty = mpp.getMetaProperty();
String propertyName = metaProperty.getName();
MetaClass propertyMetaClass = getMetadataTools().getPropertyEnclosingMetaClass(mpp);
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);
}
column.setXmlDescriptor(element);
String expandRatio = element.attributeValue("expandRatio");
String width = loadThemeString(element.attributeValue("width"));
if (StringUtils.isNotEmpty(expandRatio)) {
column.setExpandRatio(Float.parseFloat(expandRatio));
if (StringUtils.isNotEmpty(width)) {
throw new GuiDevelopmentException("Properties 'width' and 'expandRatio' cannot be used simultaneously", context);
}
}
if (StringUtils.isNotEmpty(width)) {
if (StringUtils.endsWith(width, "px")) {
width = StringUtils.substring(width, 0, width.length() - 2);
}
try {
column.setWidth(Integer.parseInt(width));
} catch (NumberFormatException e) {
throw new GuiDevelopmentException("Property 'width' must contain only numeric value", context, "width", element.attributeValue("width"));
}
}
String align = element.attributeValue("align");
if (StringUtils.isNotEmpty(align)) {
column.setAlignment(Table.ColumnAlignment.valueOf(align));
}
column.setFormatter(loadFormatter(element));
loadAggregation(column, element);
loadMaxTextLength(column, element);
loadCaptionAsHtml(column, element);
return column;
}
Aggregations