use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class AbstractTableLoader method loadTableData.
protected void loadTableData() {
TableDataHolder holder = initTableDataHolder();
if (!holder.isContainerLoaded() && holder.getMetaClass() == null) {
throw new GuiDevelopmentException("Table doesn't have data binding", context, "Table ID", element.attributeValue("id"));
}
List<Table.Column> availableColumns;
Element columnsElement = element.element("columns");
if (columnsElement != null) {
FetchPlan fetchPlan = holder.getFetchPlan();
if (fetchPlan == null) {
fetchPlan = getViewRepository().getFetchPlan(holder.getMetaClass(), FetchPlan.BASE);
}
availableColumns = loadColumns(resultComponent, columnsElement, holder.getMetaClass(), fetchPlan);
} else {
availableColumns = new ArrayList<>();
}
for (Table.Column column : availableColumns) {
loadRequired(resultComponent, column);
}
setupDataContainer(holder);
if (resultComponent.getItems() == null) {
// noinspection unchecked
resultComponent.setItems(createEmptyTableItems(holder.getMetaClass()));
}
for (Table.Column column : availableColumns) {
if (column.getXmlDescriptor() != null) {
String generatorMethod = column.getXmlDescriptor().attributeValue("generator");
if (StringUtils.isNotEmpty(generatorMethod)) {
// noinspection unchecked
resultComponent.addGeneratedColumn(String.valueOf(column), applicationContext.getBean(DeclarativeColumnGenerator.class, resultComponent, generatorMethod));
}
}
}
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class BrowserFrameLoader method loadSrcdocFile.
protected void loadSrcdocFile(BrowserFrame resultComponent, Element element) {
String srcdocFile = element.attributeValue("srcdocFile");
if (StringUtils.isNotEmpty(srcdocFile)) {
if (StringUtils.isNotEmpty(resultComponent.getSrcdoc())) {
throw new GuiDevelopmentException("'Srcdoc' and 'srcdocFile' cannot be used in the same time for BrowserFrame", context);
}
Resources resources = applicationContext.getBean(Resources.class);
String resource = resources.getResourceAsString(srcdocFile);
if (resource == null) {
String msg = String.format("Can't load srcdocFile in BrowserFrame. The file with given path not found: %s", srcdocFile);
throw new GuiDevelopmentException(msg, context);
}
resultComponent.setSrcdoc(resource);
}
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class CalendarLoader method loadDataContainer.
@SuppressWarnings("unchecked")
protected void loadDataContainer(Calendar component, Element element) {
String containerId = element.attributeValue("dataContainer");
if (Strings.isNullOrEmpty(containerId)) {
return;
}
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);
}
component.setEventProvider(new ContainerCalendarEventProvider<>(((CollectionContainer) container)));
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class CalendarLoader method loadStartDate.
protected void loadStartDate(Calendar resultComponent, Element element) {
String startDateAttribute = element.attributeValue("startDate");
if (StringUtils.isNotEmpty(startDateAttribute)) {
try {
Date date = parseDateOrDateTime(startDateAttribute);
Object startDate = convertToType(date, resultComponent.getDatatype().getJavaClass());
resultComponent.setStartDate(startDate);
} catch (ParseException e) {
throw new GuiDevelopmentException("'startDate' parsing error for calendar: " + startDateAttribute, context, "Calendar ID", resultComponent.getId());
}
}
}
use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class TreeTableLoader method createContainerTableSource.
@SuppressWarnings("unchecked")
@Override
protected ContainerTableItems createContainerTableSource(CollectionContainer container) {
Element rowsEl = element.element("rows");
String hierarchyProperty = element.attributeValue("hierarchyProperty");
if (hierarchyProperty == null && rowsEl != null) {
hierarchyProperty = rowsEl.attributeValue("hierarchyProperty");
}
if (Strings.isNullOrEmpty(hierarchyProperty)) {
throw new GuiDevelopmentException("TreeTable doesn't have 'hierarchyProperty' attribute", context, "TreeTable ID", element.attributeValue("id"));
}
String showOrphansAttr = element.attributeValue("showOrphans");
boolean showOrphans = showOrphansAttr == null || Boolean.parseBoolean(showOrphansAttr);
return new ContainerTreeTableItems(container, hierarchyProperty, showOrphans);
}
Aggregations