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);
}
}
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);
}
}
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);
}
}
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);
}
}
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());
}
Aggregations