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.
138 lines
4.2 KiB
138 lines
4.2 KiB
5 years ago
|
package com.fanruan.api.design.work.form.creator;
|
||
|
|
||
5 years ago
|
import com.fanruan.api.design.DesignKit;
|
||
5 years ago
|
import com.fanruan.api.design.work.form.macro.XCreatorConstants;
|
||
|
import com.fanruan.api.report.form.category.BaseBorderStyleWidget;
|
||
|
import com.fanruan.api.util.StringKit;
|
||
|
import com.fr.common.annotations.Compatible;
|
||
|
import com.fr.design.border.UIRoundedBorder;
|
||
|
import com.fr.design.mainframe.widget.editors.BackgroundEditor;
|
||
|
import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor;
|
||
|
import com.fr.design.mainframe.widget.renderer.BackgroundRenderer;
|
||
|
import com.fr.form.ui.PaddingMargin;
|
||
|
import com.fr.general.act.BorderPacker;
|
||
|
import com.fr.stable.Constants;
|
||
|
import com.fr.stable.core.PropertyChangeAdapter;
|
||
|
|
||
|
import java.awt.*;
|
||
|
|
||
|
/**
|
||
|
* @author richie
|
||
|
* @version 10.0
|
||
|
* Created by richie on 2019/10/28
|
||
5 years ago
|
* 带有样式设置的控件操作类
|
||
5 years ago
|
*/
|
||
5 years ago
|
public abstract class XOpenStyleCreator extends XOpenCreator {
|
||
5 years ago
|
|
||
|
private static final Dimension BORDER_PREFERRED_SIZE = new Dimension(250, 150);
|
||
|
|
||
5 years ago
|
public XOpenStyleCreator(BaseBorderStyleWidget widget) {
|
||
5 years ago
|
super(widget, BORDER_PREFERRED_SIZE);
|
||
|
}
|
||
|
|
||
5 years ago
|
public XOpenStyleCreator(BaseBorderStyleWidget widget, Dimension size) {
|
||
5 years ago
|
super(widget, size);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public Attribute[] attributes() {
|
||
|
return new Attribute[]{
|
||
|
Attribute.newAttribute("borderStyle", toData().getClass())
|
||
|
.editorClass(borderStyleEditorClass())
|
||
5 years ago
|
.i18n(DesignKit.i18nText("Fine-Design_Report_Engine_Style"))
|
||
5 years ago
|
.keyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced")
|
||
|
.listener(new PropertyChangeAdapter() {
|
||
|
@Override
|
||
|
public void propertyChange() {
|
||
|
initStyle();
|
||
|
}
|
||
|
}),
|
||
|
Attribute.newAttribute("background", toData().getClass())
|
||
|
.editorClass(backgroundEditorClass())
|
||
|
.rendererClass(backgroundRendererClass())
|
||
5 years ago
|
.i18n(DesignKit.i18nText("Fine-Design_Basic_Background"))
|
||
5 years ago
|
.keyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced")
|
||
|
.listener(new PropertyChangeAdapter() {
|
||
|
@Override
|
||
|
public void propertyChange() {
|
||
|
initStyle();
|
||
|
}
|
||
|
})
|
||
|
|
||
|
};
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 边框和样式编辑器,可以重载该方法自定义自己的样式编辑器
|
||
|
*
|
||
|
* @return 边框和样式编辑器
|
||
|
*/
|
||
|
protected Class<?> borderStyleEditorClass() {
|
||
|
return WLayoutBorderStyleEditor.class;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 背景编辑器,可以重载该方法自定义自己的背景编辑器
|
||
|
*
|
||
|
* @return 背景编辑器
|
||
|
*/
|
||
|
protected Class<?> backgroundEditorClass() {
|
||
|
return BackgroundEditor.class;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 背景渲染器,可以重载该方法自定义自己的背景渲染器
|
||
|
*
|
||
|
* @return 背景渲染器
|
||
|
*/
|
||
|
protected Class<?> backgroundRendererClass() {
|
||
|
return BackgroundRenderer.class;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public BaseBorderStyleWidget toData() {
|
||
|
return (BaseBorderStyleWidget) data;
|
||
|
}
|
||
|
|
||
|
@Compatible
|
||
|
protected void initStyle() {
|
||
|
initBorderStyle();
|
||
|
}
|
||
|
|
||
|
@Compatible
|
||
|
protected void initBorderStyle() {
|
||
|
BorderPacker style = toData().getBorderStyle();
|
||
|
if (style != null && style.getBorder() != Constants.LINE_NONE) {
|
||
|
this.setBorder(new UIRoundedBorder(style.getBorder(), style.getColor(), style.getBorderRadius()));
|
||
|
} else {
|
||
|
this.setBorder(DEFAULT_BORDER);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected String getIconName() {
|
||
|
return StringKit.EMPTY;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 内边距
|
||
|
*
|
||
|
* @return 同上
|
||
|
*/
|
||
|
@Override
|
||
|
public Insets getInsets() {
|
||
|
PaddingMargin padding = toData().getMargin();
|
||
|
if (padding == null) {
|
||
|
return new Insets(0, 0, 0, 0);
|
||
|
}
|
||
|
return new Insets(padding.getTop(), padding.getLeft(), padding.getBottom(), padding.getRight());
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* data属性改变触发其他操作
|
||
|
*/
|
||
|
public void firePropertyChange() {
|
||
|
|
||
|
}
|
||
|
}
|