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.
114 lines
4.1 KiB
114 lines
4.1 KiB
package com.fanruan.api.design.work.form.creator; |
|
|
|
import com.fanruan.api.design.DesignKit; |
|
import com.fanruan.api.design.work.form.macro.XCreatorConstants; |
|
import com.fanruan.api.util.ArrayKit; |
|
import com.fr.design.designer.creator.CRPropertyDescriptor; |
|
import com.fr.design.designer.creator.XCreator; |
|
import com.fr.design.designer.creator.XWidgetCreator; |
|
import com.fr.design.mainframe.FormDesigner; |
|
import com.fr.form.ui.Widget; |
|
import com.fr.stable.core.PropertyChangeAdapter; |
|
|
|
import javax.swing.*; |
|
import java.awt.*; |
|
import java.beans.IntrospectionException; |
|
|
|
/** |
|
* @author richie |
|
* @version 10.0 |
|
* Created by richie on 2019-09-10 |
|
*/ |
|
public abstract class XOpenCreator extends XWidgetCreator { |
|
|
|
public XOpenCreator(Widget widget, Dimension size) { |
|
super(widget, size); |
|
} |
|
|
|
final public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
|
CRPropertyDescriptor[] basic = new CRPropertyDescriptor[]{ |
|
new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(DesignKit.i18nText("Fine-Design_Form_Form_Widget_Name")), |
|
new CRPropertyDescriptor("enabled", this.data.getClass()).setI18NName(DesignKit.i18nText("Fine-Design_Report_Enabled")) |
|
.setPropertyChangeListener(new PropertyChangeAdapter() { |
|
|
|
@Override |
|
public void propertyChange() { |
|
setEnabled(toData().isEnabled()); |
|
} |
|
}), |
|
new CRPropertyDescriptor("visible", this.data.getClass()).setI18NName( |
|
DesignKit.i18nText("Fine-Design_Form_Widget_Visible")).setPropertyChangeListener(new PropertyChangeAdapter() { |
|
|
|
@Override |
|
public void propertyChange() { |
|
makeVisible(toData().isVisible()); |
|
} |
|
}), |
|
new CRPropertyDescriptor("labelName", this.data.getClass(), "getLabelName", "setLabelName") |
|
.setI18NName(DesignKit.i18nText("Fine-Design_Form_Label_Name")) |
|
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced") |
|
}; |
|
Attribute[] attributes = attributes(); |
|
CRPropertyDescriptor[] current = new CRPropertyDescriptor[attributes.length]; |
|
for (int i = 0, len = attributes.length; i < len; i++) { |
|
current[i] = attributes[i].toPropertyDescriptor(); |
|
} |
|
return ArrayKit.addAll(basic, current); |
|
} |
|
|
|
/** |
|
* 控件支持的属性以及操作设置这些属性的方法,使用反射调用属性的设置方法。 |
|
* 示例:如果不显示的传入读取和写入方法,则默认调用"get+属性名"或者"set+属性名"的方法。 |
|
* |
|
* @return 控件支持的属性以及操作设置这些属性的方法集合 |
|
*/ |
|
public abstract Attribute[] attributes(); |
|
|
|
/** |
|
* 待说明 |
|
* |
|
* @return 待说明 |
|
*/ |
|
public Widget toData() { |
|
return this.data; |
|
} |
|
|
|
/** |
|
* 根据Widget的属性值初始化XCreator的属性值 |
|
*/ |
|
@Override |
|
protected void initXCreatorProperties() { |
|
this.setEnabled(toData().isEnabled()); |
|
} |
|
|
|
/** |
|
* 待说明 |
|
*/ |
|
public void recalculateChildrenSize() { |
|
} |
|
|
|
|
|
protected void makeVisible(boolean visible) { |
|
|
|
} |
|
|
|
public void paint(Graphics g) { |
|
AlphaComposite composite = this.data.isVisible() ? (AlphaComposite) ((Graphics2D) g).getComposite() : AlphaComposite.getInstance(AlphaComposite.SRC_OVER, HALF_OPACITY); |
|
((Graphics2D) g).setComposite(composite); |
|
super.paint(g); |
|
} |
|
|
|
/** |
|
* 重命名 |
|
* |
|
* @param designer 表单设计器 |
|
* @param creator 当前组件 |
|
*/ |
|
public void ChangeCreatorName(FormDesigner designer, XCreator creator) { |
|
String oldName = creator.toData().getWidgetName(); |
|
String value = JOptionPane.showInputDialog(designer, DesignKit.i18nText("Fine-Design_Form_Change_Widget_Name_Discription"), oldName); |
|
if (value != null) { |
|
designer.renameCreator(creator, value); |
|
} |
|
} |
|
}
|
|
|