Search in sources :

Example 51 with GuiDevelopmentException

use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.

the class DatePickerLoader method loadRangeStart.

protected void loadRangeStart(DatePicker resultComponent, Element element) {
    String rangeStart = element.attributeValue("rangeStart");
    if (StringUtils.isNotEmpty(rangeStart)) {
        try {
            Date date = parseDate(rangeStart);
            resultComponent.setRangeStart(getDateTimeTransformations().transformToType(date, getJavaType(resultComponent), null));
        } catch (ParseException e) {
            throw new GuiDevelopmentException("'rangeStart' parsing error for date picker: " + rangeStart, context, "DatePicker ID", resultComponent.getId());
        }
    }
}
Also used : GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) ParseException(java.text.ParseException) Date(java.util.Date)

Example 52 with GuiDevelopmentException

use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.

the class DatePickerLoader method loadRangeEnd.

protected void loadRangeEnd(DatePicker resultComponent, Element element) {
    String rangeEnd = element.attributeValue("rangeEnd");
    if (StringUtils.isNotEmpty(rangeEnd)) {
        try {
            Date date = parseDate(rangeEnd);
            resultComponent.setRangeEnd(getDateTimeTransformations().transformToType(date, getJavaType(resultComponent), null));
        } catch (ParseException e) {
            throw new GuiDevelopmentException("'rangeEnd' parsing error for date picker: " + rangeEnd, context, "DatePicker ID", resultComponent.getId());
        }
    }
}
Also used : GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) ParseException(java.text.ParseException) Date(java.util.Date)

Example 53 with GuiDevelopmentException

use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.

the class FileUploadFieldLoader method loadDropZone.

protected void loadDropZone(UploadField uploadField, Element element) {
    String dropZoneId = element.attributeValue("dropZone");
    if (StringUtils.isNotEmpty(dropZoneId)) {
        Component dropZone = findComponent(dropZoneId);
        if (dropZone instanceof BoxLayout) {
            uploadField.setDropZone(new UploadField.DropZone((BoxLayout) dropZone));
        } else if (dropZone != null) {
            throw new GuiDevelopmentException("Unsupported dropZone class " + dropZone.getClass().getName(), context);
        } else {
            throw new GuiDevelopmentException("Unable to find dropZone component with id: " + dropZoneId, context);
        }
    }
    String dropZonePrompt = element.attributeValue("dropZonePrompt");
    if (StringUtils.isNotEmpty(dropZonePrompt)) {
        uploadField.setDropZonePrompt(loadResourceString(dropZonePrompt));
    }
}
Also used : BoxLayout(io.jmix.ui.component.BoxLayout) SingleFileUploadField(io.jmix.ui.component.SingleFileUploadField) UploadField(io.jmix.ui.component.UploadField) FileUploadField(io.jmix.ui.component.FileUploadField) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) Component(io.jmix.ui.component.Component)

Example 54 with GuiDevelopmentException

use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.

the class GroupTableLoader method loadColumns.

@Override
protected List<Table.Column> loadColumns(Table component, Element columnsElement, MetaClass metaClass, FetchPlan fetchPlan) {
    List<Table.Column> columns = super.loadColumns(component, columnsElement, metaClass, fetchPlan);
    Element groupElement = columnsElement.element("group");
    if (groupElement != null) {
        final List<Object> groupProperties = new ArrayList<>(columns.size());
        List<Element> columnElements = groupElement.elements("column");
        for (Element columnElement : columnElements) {
            String visible = columnElement.attributeValue("visible");
            if (StringUtils.isEmpty(visible) || Boolean.parseBoolean(visible)) {
                Object id = loadColumnId(columnElement, metaClass);
                Table.Column column = component.getColumn(id.toString());
                if (column == null) {
                    column = loadColumn(component, columnElement, metaClass);
                }
                if (column.isCollapsed()) {
                    String msg = String.format("Can't group by collapsed column: %s", column.getId());
                    throw new GuiDevelopmentException(msg, context);
                }
                if (column instanceof GroupTable.GroupColumn && ((GroupTable.GroupColumn<?>) column).isGroupAllowed()) {
                    groupProperties.add(column.getId());
                }
            }
        }
        getComponentContext().addPostInitTask((context1, window) -> {
            // enable grouping columns from descriptor if columnReorderingAllowed = false
            boolean reorderDisabled = !component.getColumnReorderingAllowed();
            component.setColumnReorderingAllowed(true);
            ((GroupTable) component).groupBy(groupProperties.toArray());
            if (reorderDisabled) {
                component.setColumnReorderingAllowed(false);
            }
        });
    }
    return columns;
}
Also used : GroupTable(io.jmix.ui.component.GroupTable) Table(io.jmix.ui.component.Table) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) GroupTable(io.jmix.ui.component.GroupTable) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException)

Example 55 with GuiDevelopmentException

use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.

the class JpqlFilterLoader method loadCondition.

protected void loadCondition(JpqlFilter<?> component, Element element) {
    List<Element> conditions = element.elements("condition");
    if (conditions.size() != 1) {
        throw new GuiDevelopmentException("JPQL filter element must have exactly one 'condition' nested element", context);
    }
    Element jpqlElement = conditions.get(0).element("jpql");
    if (jpqlElement == null) {
        throw new GuiDevelopmentException("'condition' element must have exactly one 'jpql' nested element", context);
    }
    Element whereElement = jpqlElement.element("where");
    if (whereElement == null) {
        throw new GuiDevelopmentException("'jpql' element must have exactly one 'where' nested element", context);
    }
    Element joinElement = jpqlElement.element("join");
    component.setCondition(whereElement.getText(), joinElement != null ? joinElement.getText() : null);
}
Also used : Element(org.dom4j.Element) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException)

Aggregations

GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)106 Element (org.dom4j.Element)42 FrameOwner (io.jmix.ui.screen.FrameOwner)16 Component (io.jmix.ui.component.Component)13 InstanceContainer (io.jmix.ui.model.InstanceContainer)11 ScreenData (io.jmix.ui.model.ScreenData)11 CollectionContainer (io.jmix.ui.model.CollectionContainer)9 MetaClass (io.jmix.core.metamodel.model.MetaClass)8 Action (io.jmix.ui.action.Action)7 BaseAction (io.jmix.ui.action.BaseAction)6 ParseException (java.text.ParseException)6 Date (java.util.Date)6 Nullable (javax.annotation.Nullable)6 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)5 ComponentLoader (io.jmix.ui.xml.layout.ComponentLoader)5 ArrayList (java.util.ArrayList)5 Datasource (com.haulmont.cuba.gui.data.Datasource)4 Formatter (io.jmix.ui.component.formatter.Formatter)4 JsonParser (com.google.gson.JsonParser)3 JsonSyntaxException (com.google.gson.JsonSyntaxException)3