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.
88 lines
2.7 KiB
88 lines
2.7 KiB
package com.fr.design.parameter; |
|
|
|
import com.fr.base.Parameter; |
|
import com.fr.base.ParameterConfig; |
|
import com.fr.design.gui.controlpane.JListControlPane; |
|
import com.fr.design.gui.controlpane.NameableCreator; |
|
import com.fr.design.gui.controlpane.NameableSelfCreator; |
|
import com.fr.design.gui.controlpane.UnrepeatedNameHelper; |
|
import com.fr.design.i18n.Toolkit; |
|
import com.fr.stable.Nameable; |
|
import com.fr.stable.core.PropertyChangeAdapter; |
|
|
|
import java.util.Arrays; |
|
import java.util.Collection; |
|
|
|
public class ParameterArrayPane extends JListControlPane { |
|
|
|
private static final String DEFAULT_PARAMETER_NAME_PREFIX = "para"; |
|
|
|
/** |
|
* Constructor. |
|
*/ |
|
public ParameterArrayPane() { |
|
super(); |
|
this.addModNameActionListener((index, oldName, newName) -> populateSelectedValue()); |
|
this.addEditingListener(new PropertyChangeAdapter() { |
|
public void propertyChange() { |
|
checkName(); |
|
} |
|
}); |
|
} |
|
|
|
@Override |
|
public String getEmptyNameTip() { |
|
return Toolkit.i18nText("Fine-Design_Basic_Empty_Parameter_Name"); |
|
} |
|
|
|
@Override |
|
public String getDuplicatedNameTip() { |
|
return Toolkit.i18nText("Fine-Design_Basic_Duplicate_Parameter_Name"); |
|
} |
|
|
|
@Override |
|
public Collection getExtraItemsToCheckNameRepeat() { |
|
return Arrays.asList(ParameterConfig.getInstance().getGlobalParameters()); |
|
} |
|
|
|
@Override |
|
protected String title4PopupWindow() { |
|
return Toolkit.i18nText("Fine-Design_Basic_Engine_Schedule_Template_Parameter"); |
|
} |
|
|
|
/** |
|
* 创建模板参数设置组件 |
|
* |
|
* @return 模板参数设置组件 |
|
*/ |
|
public NameableCreator[] createNameableCreators() { |
|
return new NameableCreator[]{ |
|
new NameableSelfCreator(Toolkit.i18nText("Fine-Design_Basic_Engine_Parameter_Name"), Parameter.class, ParameterPane.class) { |
|
public Parameter createNameable(UnrepeatedNameHelper helper) { |
|
// 返回参数设置面板. |
|
return new Parameter(helper.createUnrepeatedName(DEFAULT_PARAMETER_NAME_PREFIX)); |
|
} |
|
|
|
@Override |
|
public String createTooltip() { |
|
return null; |
|
} |
|
} |
|
}; |
|
} |
|
|
|
|
|
/** |
|
* 更新参数 |
|
* |
|
* @return 更新后的参数 |
|
*/ |
|
public Parameter[] updateParameters() { |
|
// Nameable[]居然不能强转成Parameter[],一定要这么写... |
|
Nameable[] res = this.update(); |
|
Parameter[] res_array = new Parameter[res.length]; |
|
Arrays.asList(res).toArray(res_array); |
|
|
|
return res_array; |
|
} |
|
}
|
|
|