Search in sources :

Example 21 with GuiDevelopmentException

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

the class StockChartLoader method loadDataSet.

protected void loadDataSet(DataSet dataSet, Element dataSetElement) {
    loadFieldMappings(dataSet, dataSetElement);
    loadStockEvents(dataSet, dataSetElement);
    String id = dataSetElement.attributeValue("id");
    if (StringUtils.isNotEmpty(id)) {
        dataSet.setId(id);
    }
    checkMultipleDatasources(dataSetElement);
    String categoryField = dataSetElement.attributeValue("categoryField");
    if (StringUtils.isNotEmpty(categoryField)) {
        dataSet.setCategoryField(categoryField);
    }
    String color = dataSetElement.attributeValue("color");
    if (StringUtils.isNotEmpty(color)) {
        dataSet.setColor(Color.valueOf(color));
    }
    String compared = dataSetElement.attributeValue("compared");
    if (StringUtils.isNotEmpty(compared)) {
        dataSet.setCompared(Boolean.valueOf(compared));
    }
    String dataContainerId = dataSetElement.attributeValue("dataContainer");
    if (StringUtils.isNotEmpty(dataContainerId)) {
        FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
        ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
        CollectionContainer dataContainer;
        InstanceContainer container = screenData.getContainer(dataContainerId);
        if (container instanceof CollectionContainer) {
            dataContainer = (CollectionContainer) container;
        } else {
            throw new GuiDevelopmentException("Not a CollectionContainer: " + dataContainerId, context);
        }
        dataSet.setDataProvider(new ContainerDataProvider(dataContainer));
    }
    String showInCompare = dataSetElement.attributeValue("showInCompare");
    if (StringUtils.isNotEmpty(showInCompare)) {
        dataSet.setShowInCompare(Boolean.valueOf(showInCompare));
    }
    String showInSelect = dataSetElement.attributeValue("showInSelect");
    if (StringUtils.isNotEmpty(showInSelect)) {
        dataSet.setShowInSelect(Boolean.valueOf(showInSelect));
    }
    String title = dataSetElement.attributeValue("title");
    if (StringUtils.isNotEmpty(title)) {
        dataSet.setTitle(title);
    }
}
Also used : FrameOwner(io.jmix.ui.screen.FrameOwner) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) CollectionContainer(io.jmix.ui.model.CollectionContainer) InstanceContainer(io.jmix.ui.model.InstanceContainer) ContainerDataProvider(io.jmix.ui.data.impl.ContainerDataProvider) ScreenData(io.jmix.ui.model.ScreenData)

Example 22 with GuiDevelopmentException

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

the class StockChartLoader method checkMultipleDatasources.

protected void checkMultipleDatasources(Element dataSetElement) {
    String datasource = dataSetElement.attributeValue("datasource");
    String dataContainer = dataSetElement.attributeValue("dataContainer");
    Element dataElement = element.element("data");
    boolean isDatasourceProperty = StringUtils.isNotEmpty(datasource);
    boolean isDataContainerProperty = StringUtils.isNotEmpty(dataContainer);
    if ((isDatasourceProperty && isDataContainerProperty) || (dataElement != null && (isDatasourceProperty || isDataContainerProperty))) {
        throw new GuiDevelopmentException(String.format("You cannot use chart '%s' with simultaneously defined: data element, datasource and " + "dataContainer properties", resultComponent.getId()), context);
    }
}
Also used : Element(org.dom4j.Element) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException)

Example 23 with GuiDevelopmentException

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

the class StockChartLoader method loadConfiguration.

protected void loadConfiguration(StockChart chart, Element element) {
    loadCategoryAxesSettings(chart, element);
    loadChartCursorSettings(chart, element);
    loadChartScrollbarSettings(chart, element);
    loadDataSetSelector(chart, element);
    loadLegendSettings(chart, element);
    loadPanels(chart, element);
    loadPanelsSettings(chart, element);
    loadPeriodSelector(chart, element);
    loadStockEventsSettings(chart, element);
    loadValueAxesSettings(chart, element);
    String addClassNames = element.attributeValue("addClassNames");
    if (StringUtils.isNotEmpty(addClassNames)) {
        chart.setAddClassNames(Boolean.valueOf(addClassNames));
    }
    String animationPlayed = element.attributeValue("animationPlayed");
    if (StringUtils.isNotEmpty(animationPlayed)) {
        chart.setAnimationPlayed(Boolean.valueOf(animationPlayed));
    }
    String autoResize = element.attributeValue("autoResize");
    if (StringUtils.isNotEmpty(autoResize)) {
        chart.setAutoResize(Boolean.valueOf(autoResize));
    }
    Element balloonElement = element.element("balloon");
    if (balloonElement != null) {
        chart.setBalloon(loadBalloon(balloonElement));
    }
    String classNamePrefix = element.attributeValue("classNamePrefix");
    if (StringUtils.isNotEmpty(classNamePrefix)) {
        chart.setClassNamePrefix(classNamePrefix);
    }
    Element colorsElement = element.element("colors");
    if (colorsElement != null) {
        List<Color> colors = loadColors(colorsElement);
        if (CollectionUtils.isNotEmpty(colors)) {
            chart.setColors(colors);
        }
    }
    String comparedDataSets = element.attributeValue("comparedDataSets");
    if (comparedDataSets != null) {
        chart.setComparedDataSets(Arrays.asList(comparedDataSets.split(",")));
    }
    String dataDateFormat = element.attributeValue("dataDateFormat");
    if (StringUtils.isNotEmpty(dataDateFormat)) {
        chart.setDataDateFormat(dataDateFormat);
    }
    Element dataSetsElement = element.element("dataSets");
    if (dataSetsElement != null) {
        chart.setDataSets(loadDataSets(dataSetsElement));
    }
    Element exportElement = element.element("export");
    if (exportElement != null) {
        chart.setExport(loadExport(exportElement));
    }
    String extendToFullPeriod = element.attributeValue("extendToFullPeriod");
    if (StringUtils.isNotEmpty(extendToFullPeriod)) {
        chart.setExtendToFullPeriod(Boolean.valueOf(extendToFullPeriod));
    }
    String firstDayOfWeek = element.attributeValue("firstDayOfWeek");
    if (StringUtils.isNotEmpty(firstDayOfWeek)) {
        chart.setFirstDayOfWeek(Integer.valueOf(firstDayOfWeek));
    }
    String glueToTheEnd = element.attributeValue("glueToTheEnd");
    if (StringUtils.isNotEmpty(glueToTheEnd)) {
        chart.setGlueToTheEnd(Boolean.valueOf(glueToTheEnd));
    }
    String language = element.attributeValue("language");
    if (StringUtils.isNotEmpty(language)) {
        chart.setLanguage(language);
    }
    String mainDataSet = element.attributeValue("mainDataSet");
    if (StringUtils.isNotEmpty(mainDataSet)) {
        chart.setMainDataSet(mainDataSet);
    }
    String mouseWheelScrollEnabled = element.attributeValue("mouseWheelScrollEnabled");
    if (StringUtils.isNotEmpty(mouseWheelScrollEnabled)) {
        chart.setMouseWheelScrollEnabled(Boolean.valueOf(mouseWheelScrollEnabled));
    }
    String processTimeout = element.attributeValue("processTimeout");
    if (StringUtils.isNotEmpty(processTimeout)) {
        chart.setProcessTimeout(Integer.valueOf(processTimeout));
    }
    String theme = element.attributeValue("theme");
    if (StringUtils.isNotEmpty(theme)) {
        chart.setTheme(ChartTheme.valueOf(theme));
    }
    String zoomOutOnDataSetChange = element.attributeValue("zoomOutOnDataSetChange");
    if (StringUtils.isNotEmpty(zoomOutOnDataSetChange)) {
        chart.setZoomOutOnDataSetChange(Boolean.valueOf(zoomOutOnDataSetChange));
    }
    Element nativeJson = element.element("nativeJson");
    if (nativeJson != null) {
        String nativeJsonString = nativeJson.getTextTrim();
        try {
            JsonParser parser = new JsonParser();
            parser.parse(nativeJsonString);
        } catch (JsonSyntaxException e) {
            throw new GuiDevelopmentException("Unable to parse JSON from XML chart configuration", context);
        }
        resultComponent.setNativeJson(nativeJsonString);
    }
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) Element(org.dom4j.Element) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) JsonParser(com.google.gson.JsonParser)

Example 24 with GuiDevelopmentException

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

the class AbstractChartLoader method loadConfiguration.

protected void loadConfiguration(T chart, Element element) {
    loadBaseProperties(chart, element);
    Element responsiveElement = element.element("responsive");
    if (responsiveElement != null) {
        Responsive responsive = new Responsive();
        loadResponsive(responsive, responsiveElement);
        chart.setResponsive(responsive);
    }
    Element nativeJson = element.element("nativeJson");
    if (nativeJson != null) {
        String nativeJsonString = nativeJson.getTextTrim();
        try {
            JsonParser parser = new JsonParser();
            parser.parse(nativeJsonString);
        } catch (JsonSyntaxException e) {
            throw new GuiDevelopmentException("Unable to parse JSON from XML chart configuration", context);
        }
        resultComponent.setNativeJson(nativeJsonString);
    }
}
Also used : Responsive(io.jmix.charts.model.settings.Responsive) JsonSyntaxException(com.google.gson.JsonSyntaxException) Element(org.dom4j.Element) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) JsonParser(com.google.gson.JsonParser)

Example 25 with GuiDevelopmentException

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

the class AbstractScreenFacet 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 Screen target action with id '%s'", actionId), owner.getId());
    }
    ((BaseAction) action).addActionPerformedListener(e -> show());
}
Also used : Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) BaseAction(io.jmix.ui.action.BaseAction)

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