use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class AbstractComponentLoader method loadContainer.
protected Optional<InstanceContainer> loadContainer(Element element, @Nullable String property) {
String containerId = element.attributeValue("dataContainer");
// For instance, a component is placed within the Form component
if (Strings.isNullOrEmpty(containerId) && property != null) {
containerId = getParentDataContainer(element);
}
if (!Strings.isNullOrEmpty(containerId)) {
if (property == null) {
throw new GuiDevelopmentException(String.format("Can't set container '%s' for component '%s' because 'property' " + "attribute is not defined", containerId, element.attributeValue("id")), context);
}
FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
return Optional.of(screenData.getContainer(containerId));
}
return Optional.empty();
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class AbstractComponentLoader method loadOptionsContainer.
protected Optional<CollectionContainer> loadOptionsContainer(Element element) {
String containerId = element.attributeValue("optionsContainer");
if (containerId != null) {
FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
InstanceContainer container = screenData.getContainer(containerId);
if (!(container instanceof CollectionContainer)) {
throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context);
}
return Optional.of((CollectionContainer) container);
}
return Optional.empty();
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class AbstractComponentLoader method loadShortcutFromAlias.
@Nullable
protected String loadShortcutFromAlias(String shortcut) {
if (shortcut.endsWith("_SHORTCUT}")) {
PropertyShortcutLoader propertyShortcutLoader = applicationContext.getBean(PropertyShortcutLoader.class);
String alias = shortcut.substring(2, shortcut.length() - 1);
if (propertyShortcutLoader.contains(alias)) {
return propertyShortcutLoader.getShortcut(alias);
} else {
String message = String.format("An error occurred while loading shortcut. " + "Can't find shortcut for alias \"%s\"", alias);
throw new GuiDevelopmentException(message, context);
}
}
return null;
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class AbstractComponentLoader method loadFormatter.
@Nullable
protected Formatter<?> loadFormatter(Element element) {
Element formatterElement = element.element("formatter");
if (formatterElement == null) {
return null;
}
int size = formatterElement.elements().size();
if (size != 1) {
throw new GuiDevelopmentException("Only one formatter needs to be defined. " + "The current number of formatters is " + size, getContext(), "Component ID", resultComponent.getId());
}
Element childElement = formatterElement.elements().get(0);
FormatterLoadFactory loadFactory = applicationContext.getBean(FormatterLoadFactory.class);
if (loadFactory.isFormatter(childElement)) {
return loadFactory.createFormatter(childElement);
}
return null;
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class AbstractDataGridLoader method loadAggregation.
@SuppressWarnings("unchecked")
protected void loadAggregation(DataGrid.Column column, Element columnElement) {
Element aggregationElement = columnElement.element("aggregation");
if (aggregationElement != null) {
AggregationInfo aggregation = new AggregationInfo();
aggregation.setPropertyPath(column.getPropertyPath());
loadAggregationType(aggregation, aggregationElement);
loadValueDescription(column, aggregationElement);
Formatter formatter = loadFormatter(aggregationElement);
aggregation.setFormatter(formatter == null ? (Formatter<Object>) column.getDescriptionProvider() : formatter);
column.setAggregation(aggregation);
loadStrategyClass(aggregation, aggregationElement);
if (aggregation.getType() == null && aggregation.getStrategy() == null) {
throw new GuiDevelopmentException("Incorrect aggregation - type or strategyClass is required", context);
}
}
}
Aggregations