From 90ba97eed2668a192c652ab794be7b84ebdd5f92 Mon Sep 17 00:00:00 2001 From: "Wim.Zhai" Date: Tue, 5 Nov 2019 16:43:56 +0800 Subject: [PATCH] =?UTF-8?q?CHART-11231=20refactor:fix=20=E8=AF=8D=E4=BA=91?= =?UTF-8?q?=E3=80=81=E6=A1=86=E6=9E=B6=E5=9B=BE=E7=89=B9=E6=95=88=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=20=E6=9C=89=E7=BB=84=E4=BB=B6=E6=9C=AA=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=20NPE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/designer/other/zoom/ZoomPane.java | 44 ++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPane.java index 1a8f85df5..dfbf2d640 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPane.java @@ -165,10 +165,17 @@ public class ZoomPane extends BasicBeanPane { } private void checkCustomModePane() { + if (customModePane == null){ + return; + } customModePane.setVisible(modeTypeButtonGroup.getSelectedItem() == ZoomModeType.CUSTOM); } private void checkInitialDisplayCardPane() { + if (initialDisplayCardPane == null){ + return; + } + CardLayout cardLayout = (CardLayout) initialDisplayCardPane.getLayout(); if (ComparatorUtils.equals(initialDisplayTypeComboBox.getSelectedItem(), ZoomInitialDisplayType.TOP_CATEGORY)) { cardLayout.show(initialDisplayCardPane, ZoomInitialDisplayType.TOP_CATEGORY.toString()); @@ -180,16 +187,22 @@ public class ZoomPane extends BasicBeanPane { @Override public void populateBean(ZoomAttribute ob) { - modeTypeButtonGroup.setSelectedItem(ob.getModeType()); + if (modeTypeButtonGroup != null) { + modeTypeButtonGroup.setSelectedItem(ob.getModeType()); + } - initialDisplayTypeComboBox.setSelectedItem(ob.getInitialDisplayType()); + if (initialDisplayTypeComboBox != null){ + initialDisplayTypeComboBox.setSelectedItem(ob.getInitialDisplayType()); + } - topCategorySpinner.setValue(ob.getTopCategory()); + if (topCategorySpinner != null) { + topCategorySpinner.setValue(ob.getTopCategory()); + } - if (ob.getLeft() != null) { + if (ob.getLeft() != null && leftFormulaPane != null) { leftFormulaPane.populateBean(ob.getLeft().getContent()); } - if (ob.getRight() != null) { + if (ob.getRight() != null && rightFormulaPane != null) { rightFormulaPane.populateBean(ob.getRight().getContent()); } @@ -205,14 +218,25 @@ public class ZoomPane extends BasicBeanPane { public ZoomAttribute updateBean() { ZoomAttribute zoomAttribute = new ZoomAttribute(); - zoomAttribute.setModeType(modeTypeButtonGroup.getSelectedItem()); + if (modeTypeButtonGroup != null) { + zoomAttribute.setModeType(modeTypeButtonGroup.getSelectedItem()); + } + + if (initialDisplayTypeComboBox != null) { + zoomAttribute.setInitialDisplayType((ZoomInitialDisplayType) initialDisplayTypeComboBox.getSelectedItem()); + } - zoomAttribute.setInitialDisplayType((ZoomInitialDisplayType) initialDisplayTypeComboBox.getSelectedItem()); + if (topCategorySpinner != null){ + zoomAttribute.setTopCategory((int) topCategorySpinner.getValue()); + } - zoomAttribute.setTopCategory((int) topCategorySpinner.getValue()); + if (leftFormulaPane != null){ + zoomAttribute.setLeft(new StringFormula(leftFormulaPane.updateBean())); + } - zoomAttribute.setLeft(new StringFormula(leftFormulaPane.updateBean())); - zoomAttribute.setRight(new StringFormula(rightFormulaPane.updateBean())); + if (rightFormulaPane != null){ + zoomAttribute.setRight(new StringFormula(rightFormulaPane.updateBean())); + } if (selectionZoomGroup != null) { zoomAttribute.setSelectionZoom(selectionZoomGroup.getSelectedItem());