From f42dc631ec6fc924764be30c718b175bfd0b1453 Mon Sep 17 00:00:00 2001 From: richie Date: Thu, 2 Jan 2020 19:49:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=8C=96API=E8=B0=83?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/component/chart/CalculateComboBox.java | 31 +++++++++++-------- .../ui/component/chart/DataFunctionType.java | 4 +-- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/fanruan/api/design/ui/component/chart/CalculateComboBox.java b/src/main/java/com/fanruan/api/design/ui/component/chart/CalculateComboBox.java index afc0b36..24131b8 100644 --- a/src/main/java/com/fanruan/api/design/ui/component/chart/CalculateComboBox.java +++ b/src/main/java/com/fanruan/api/design/ui/component/chart/CalculateComboBox.java @@ -1,32 +1,38 @@ package com.fanruan.api.design.ui.component.chart; +import com.fanruan.api.design.DesignKit; import com.fanruan.api.design.ui.component.UIComboBox; +import com.fanruan.api.log.LogKit; +import com.fr.common.annotations.Compatible; import com.fr.data.util.function.DataFunction; -import com.fr.design.i18n.Toolkit; -import com.fr.log.FineLoggerFactory; /** * @author Bjorn * @version 10.0 * Created by Bjorn on 2019-09-23 */ -public class CalculateComboBox extends UIComboBox { +public class CalculateComboBox extends UIComboBox { - private static String[] functionName = initItem(); + private static String[] functionName; - private static String[] initItem() { + static { String[] functionLocaleNames = DataFunctionType.getFunctionLocaleNames(); for (int i = 0; i < functionLocaleNames.length; i++) { - functionLocaleNames[i] = Toolkit.i18nText(functionLocaleNames[i]); + functionLocaleNames[i] = DesignKit.i18nText(functionLocaleNames[i]); } - return functionLocaleNames; + functionName = functionLocaleNames; } + public CalculateComboBox() { super(functionName); setSelectedIndex(0); } + /** + * 重置公式下拉选选中的值为第0个 + */ + @Compatible public void reset() { this.setSelectedItem(0); } @@ -34,6 +40,7 @@ public class CalculateComboBox extends UIComboBox { /** * 通过公式对象,更新界面的公式选择 */ + @Compatible public void populateBean(DataFunction function) { int index = DataFunctionType.getIndexByFunction(function); if (index > 0) { @@ -44,15 +51,13 @@ public class CalculateComboBox extends UIComboBox { /** * 根据界面选择的公式,返回公式对象 */ + @Compatible public DataFunction updateBean() { try { int selectIndex = getSelectedIndex(); - DataFunction functionByIndex = DataFunctionType.getFunctionByIndex(selectIndex); - return functionByIndex; - } catch (InstantiationException e) { - FineLoggerFactory.getLogger().error("Function Error"); - } catch (IllegalAccessException e) { - FineLoggerFactory.getLogger().error("Function Error"); + return DataFunctionType.getFunctionByIndex(selectIndex); + } catch (InstantiationException | IllegalAccessException e) { + LogKit.error("Function Error"); } return null; } diff --git a/src/main/java/com/fanruan/api/design/ui/component/chart/DataFunctionType.java b/src/main/java/com/fanruan/api/design/ui/component/chart/DataFunctionType.java index ce9bc0b..fe74bb5 100644 --- a/src/main/java/com/fanruan/api/design/ui/component/chart/DataFunctionType.java +++ b/src/main/java/com/fanruan/api/design/ui/component/chart/DataFunctionType.java @@ -1,5 +1,6 @@ package com.fanruan.api.design.ui.component.chart; +import com.fanruan.api.util.AssistKit; import com.fr.data.util.function.AverageFunction; import com.fr.data.util.function.CountFunction; import com.fr.data.util.function.DataFunction; @@ -7,7 +8,6 @@ import com.fr.data.util.function.MaxFunction; import com.fr.data.util.function.MinFunction; import com.fr.data.util.function.NoneFunction; import com.fr.data.util.function.SumFunction; -import com.fr.general.ComparatorUtils; /** * @author Bjorn @@ -39,7 +39,7 @@ public enum DataFunctionType { return NONE_FUNCTION_INDEX; } for (DataFunctionType dataFunctionType : DataFunctionType.values()) { - if (ComparatorUtils.equals(dataFunctionType.functionClass, function.getClass())) { + if (AssistKit.equals(dataFunctionType.functionClass, function.getClass())) { return dataFunctionType.ordinal(); } }