From 438457acdfdc0b0ea8c5405e1ac12a6a4602136e Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 29 Oct 2019 18:05:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3=E5=92=8C=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/basic/AccessiblePropertyEditor.java | 34 ++++++++++++++++++- .../work/form/basic/EncoderCellRenderer.java | 7 ++-- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/fanruan/api/design/work/form/basic/AccessiblePropertyEditor.java b/src/main/java/com/fanruan/api/design/work/form/basic/AccessiblePropertyEditor.java index 94f56c7..abc8799 100644 --- a/src/main/java/com/fanruan/api/design/work/form/basic/AccessiblePropertyEditor.java +++ b/src/main/java/com/fanruan/api/design/work/form/basic/AccessiblePropertyEditor.java @@ -1,15 +1,47 @@ package com.fanruan.api.design.work.form.basic; +import com.fr.design.Exception.ValidationException; import com.fr.design.mainframe.widget.accessibles.AccessibleEditor; /** * @author Kalven * @version 10.0 * Created by Kalven on 2019/9/4 - * 可以通过按钮或其他方式进去编辑面板的编辑器 + * 控件属性值的编辑器 */ public class AccessiblePropertyEditor extends com.fr.design.mainframe.widget.accessibles.AccessiblePropertyEditor { public AccessiblePropertyEditor(AccessibleEditor editor) { super(editor); } + + + /** + * 给编辑器设置值 + * + * @param o 待设置的值 + */ + @Override + public void setValue(Object o) { + super.setValue(o); + } + + /** + * 获取编辑器的值 + * + * @return 编辑器的值 + */ + @Override + public Object getValue() { + return super.getValue(); + } + + /** + * 检验编辑器输入的值是否合法 + * + * @throws ValidationException 值不合法则抛出此异常 + */ + @Override + public void validateValue() throws ValidationException { + super.validateValue(); + } } diff --git a/src/main/java/com/fanruan/api/design/work/form/basic/EncoderCellRenderer.java b/src/main/java/com/fanruan/api/design/work/form/basic/EncoderCellRenderer.java index 7655a22..3bfdfdf 100644 --- a/src/main/java/com/fanruan/api/design/work/form/basic/EncoderCellRenderer.java +++ b/src/main/java/com/fanruan/api/design/work/form/basic/EncoderCellRenderer.java @@ -9,11 +9,11 @@ import java.awt.*; * @author Kalven * @version 10.0 * Created by Kalven on 2019/9/4 - * 根据控件属性渲染单元格 + * 控件属性值的渲染器,可以把一个复杂的对象渲染成文本或者其他一些可读的形式 */ public class EncoderCellRenderer extends GenericCellRenderer { - private static int LEFT = 1; + private static final int LEFT = 1; protected Encoder encoder; protected Object value; @@ -28,14 +28,13 @@ public class EncoderCellRenderer extends GenericCellRenderer { g.setColor(getBackground()); g.fillRect(0, 0, width, height); - int x = LEFT; g.setColor(getForeground()); FontMetrics fm = g.getFontMetrics(); int y = ((height - fm.getHeight()) / 2) + fm.getAscent(); String txt = getValueText(); if (txt != null) { - g.drawString(txt, x, y); + g.drawString(txt, LEFT, y); } if (getBorder() != null) { getBorder().paintBorder(this, g, 0, 0, width, height);