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.
137 lines
4.2 KiB
137 lines
4.2 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.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 |
|
* 带有样式设置的控件操作类 |
|
*/ |
|
public abstract class XOpenStyleCreator extends XOpenCreator { |
|
|
|
private static final Dimension BORDER_PREFERRED_SIZE = new Dimension(250, 150); |
|
|
|
public XOpenStyleCreator(BaseBorderStyleWidget widget) { |
|
super(widget, BORDER_PREFERRED_SIZE); |
|
} |
|
|
|
public XOpenStyleCreator(BaseBorderStyleWidget widget, Dimension size) { |
|
super(widget, size); |
|
} |
|
|
|
@Override |
|
public Attribute[] attributes() { |
|
return new Attribute[]{ |
|
Attribute.newAttribute("borderStyle", toData().getClass()) |
|
.editorClass(borderStyleEditorClass()) |
|
.i18n(DesignKit.i18nText("Fine-Design_Report_Engine_Style")) |
|
.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()) |
|
.i18n(DesignKit.i18nText("Fine-Design_Basic_Background")) |
|
.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() { |
|
|
|
} |
|
}
|
|
|