forked from fanruan/finekit
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.7 KiB
64 lines
1.7 KiB
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; |
|
|
|
/** |
|
* @author Bjorn |
|
* @version 10.0 |
|
* Created by Bjorn on 2019-09-23 |
|
*/ |
|
public class CalculateComboBox extends UIComboBox<String> { |
|
|
|
private static String[] functionName; |
|
|
|
static { |
|
String[] functionLocaleNames = DataFunctionType.getFunctionLocaleNames(); |
|
for (int i = 0; i < functionLocaleNames.length; i++) { |
|
functionLocaleNames[i] = DesignKit.i18nText(functionLocaleNames[i]); |
|
} |
|
functionName = functionLocaleNames; |
|
} |
|
|
|
|
|
public CalculateComboBox() { |
|
super(functionName); |
|
setSelectedIndex(0); |
|
} |
|
|
|
/** |
|
* 重置公式下拉选选中的值为第0个 |
|
*/ |
|
@Compatible |
|
public void reset() { |
|
this.setSelectedItem(0); |
|
} |
|
|
|
/** |
|
* 通过公式对象,更新界面的公式选择 |
|
*/ |
|
@Compatible |
|
public void populateBean(DataFunction function) { |
|
int index = DataFunctionType.getIndexByFunction(function); |
|
if (index > 0) { |
|
this.setSelectedIndex(index); |
|
} |
|
} |
|
|
|
/** |
|
* 根据界面选择的公式,返回公式对象 |
|
*/ |
|
@Compatible |
|
public DataFunction updateBean() { |
|
try { |
|
int selectIndex = getSelectedIndex(); |
|
return DataFunctionType.getFunctionByIndex(selectIndex); |
|
} catch (InstantiationException | IllegalAccessException e) { |
|
LogKit.error("Function Error"); |
|
} |
|
return null; |
|
} |
|
}
|
|
|