Search in sources :

Example 96 with GuiDevelopmentException

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

the class AbstractDataGridLoader method loadDataGridData.

protected void loadDataGridData() {
    DataGridDataHolder holder = initDataGridDataHolder();
    if (!holder.isContainerLoaded() && holder.getMetaClass() == null) {
        throw new GuiDevelopmentException("DataGrid doesn't have data binding", context, "DataGrid ID", element.attributeValue("id"));
    }
    Element columnsElement = element.element("columns");
    if (columnsElement != null) {
        FetchPlan fetchPlan = holder.getFetchPlan();
        if (fetchPlan == null) {
            fetchPlan = getViewRepository().getFetchPlan(holder.getMetaClass(), FetchPlan.LOCAL);
        }
        loadColumns(resultComponent, columnsElement, holder.getMetaClass(), fetchPlan);
    }
    setupDataContainer(holder);
    if (resultComponent.getItems() == null) {
        // noinspection unchecked
        resultComponent.setItems(createEmptyDataGridItems(holder.getMetaClass()));
    }
}
Also used : Element(org.dom4j.Element) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException)

Example 97 with GuiDevelopmentException

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

the class AbstractDataGridLoader method initDataGridDataHolder.

protected DataGridDataHolder initDataGridDataHolder() {
    DataGridDataHolder holder = new DataGridDataHolder();
    String containerId = element.attributeValue("dataContainer");
    if (Strings.isNullOrEmpty(containerId)) {
        loadMetaClass(element, holder::setMetaClass);
        return holder;
    }
    FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
    ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
    InstanceContainer container = screenData.getContainer(containerId);
    CollectionContainer collectionContainer;
    if (container instanceof CollectionContainer) {
        collectionContainer = (CollectionContainer) container;
    } else {
        throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context);
    }
    if (collectionContainer instanceof CollectionPropertyContainer) {
        initMasterDataLoaderListener((CollectionPropertyContainer) collectionContainer);
    }
    if (collectionContainer instanceof HasLoader) {
        holder.setDataLoader(((HasLoader) collectionContainer).getLoader());
    }
    holder.setMetaClass(collectionContainer.getEntityMetaClass());
    holder.setContainer(collectionContainer);
    holder.setFetchPlan(collectionContainer.getFetchPlan());
    return holder;
}
Also used : FrameOwner(io.jmix.ui.screen.FrameOwner) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException)

Example 98 with GuiDevelopmentException

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

the class RelatedEntitiesLoader method loadPropertyOption.

protected void loadPropertyOption(Element routeElement) {
    String property = loadString(routeElement, "name").orElseThrow(() -> new GuiDevelopmentException("Name attribute for related entities property is not specified", context, "componentId", resultComponent.getId()));
    String caption = loadResourceString(routeElement.attributeValue("caption"));
    String configurationName = loadResourceString(routeElement.attributeValue("configurationName"));
    String screen = routeElement.attributeValue("screen");
    if (StringUtils.isNotEmpty(screen)) {
        if (getWindowConfig().findWindowInfo(screen) == null) {
            throw new GuiDevelopmentException("Screen for custom route in related entities not found", context, "componentId", resultComponent.getId());
        }
    }
    resultComponent.addPropertyOption(new PropertyOption(property, caption, configurationName, screen));
}
Also used : PropertyOption(io.jmix.ui.sys.PropertyOption) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException)

Example 99 with GuiDevelopmentException

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

the class SideMenuLoader method loadSidePanel.

protected void loadSidePanel(SideMenu component, Element element) {
    String sidePanelId = element.attributeValue("sidePanel");
    if (StringUtils.isNotEmpty(sidePanelId)) {
        Component sidePanel = resultComponent.getFrame().getComponent(sidePanelId);
        if (sidePanel == null) {
            throw new GuiDevelopmentException("Unable to find sidePanel component for SideMenu", context, "sidePanel", sidePanelId);
        }
        component.setSidePanel(sidePanel);
    }
}
Also used : GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) Component(io.jmix.ui.component.Component)

Example 100 with GuiDevelopmentException

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

the class JavaScriptComponentLoader method loadDependencies.

protected void loadDependencies(JavaScriptComponent component, Element element) {
    Element dependenciesElement = element.element("dependencies");
    if (dependenciesElement == null) {
        return;
    }
    List<JavaScriptComponent.ClientDependency> dependencies = new ArrayList<>();
    for (Element dependency : dependenciesElement.elements("dependency")) {
        String path = dependency.attributeValue("path");
        if (Strings.isNullOrEmpty(path)) {
            throw new GuiDevelopmentException("No path provided for a JavaScriptComponent dependency", context);
        }
        String type = dependency.attributeValue("type");
        JavaScriptComponent.DependencyType dependencyType = !Strings.isNullOrEmpty(type) ? JavaScriptComponent.DependencyType.valueOf(type) : null;
        dependencies.add(new JavaScriptComponent.ClientDependency(path, dependencyType));
    }
    component.setDependencies(dependencies);
}
Also used : Element(org.dom4j.Element) ArrayList(java.util.ArrayList) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) JavaScriptComponent(io.jmix.ui.component.JavaScriptComponent)

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