From c7fad3e33622cba47735c586e7647048320f4556 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 1 Aug 2016 11:44:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E6=A0=A1=E9=AA=8C=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/designer/creator/XTextEditor.java | 79 ++++++++++--------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/designer_form/src/com/fr/design/designer/creator/XTextEditor.java b/designer_form/src/com/fr/design/designer/creator/XTextEditor.java index 5586728e2..2d068ccb1 100644 --- a/designer_form/src/com/fr/design/designer/creator/XTextEditor.java +++ b/designer_form/src/com/fr/design/designer/creator/XTextEditor.java @@ -24,6 +24,7 @@ import com.fr.general.FRFont; import com.fr.general.Inter; import com.fr.stable.ArrayUtils; import com.fr.stable.Constants; +import com.fr.stable.StringUtils; import jdk.nashorn.internal.runtime.regexp.joni.Regex; /** @@ -38,51 +39,53 @@ public class XTextEditor extends XWrapperedFieldEditor { /** * 控件的属性列表 + * * @return 此控件所用的属性列表 * @throws IntrospectionException 异常 */ @Override - public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { - CRPropertyDescriptor widgetValue=new CRPropertyDescriptor("widgetValue", this.data.getClass()).setI18NName( - Inter.getLocText(new String[]{"FR-Designer_Widget", "Value"})).setEditorClass( - WidgetValueEditor.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"); - CRPropertyDescriptor regex= new CRPropertyDescriptor("regex", this.data.getClass()).setI18NName( - Inter.getLocText("FR-Designer_Input_Rule")).setEditorClass(RegexEditor.class).putKeyValue( - "renderer", RegexCellRencerer.class).putKeyValue(XCreatorConstants.PROPERTY_VALIDATE, "FR-Designer_Validate"); - CRPropertyDescriptor regErrorMessage=new CRPropertyDescriptor("regErrorMessage", this.data.getClass()).setI18NName( - Inter.getLocText("Verify-Message")).putKeyValue(XCreatorConstants.PROPERTY_VALIDATE, "FR-Designer_Validate"); - CRPropertyDescriptor waterMark= new CRPropertyDescriptor("waterMark", this.data.getClass()).setI18NName( - Inter.getLocText("FR-Designer_WaterMark")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, - "Advanced"); - CRPropertyDescriptor[] sup=(CRPropertyDescriptor[]) ArrayUtils.addAll(new CRPropertyDescriptor[] {widgetValue},super.supportedDescriptor()); - Boolean displayRegField = true; - RegExp reg = ((TextEditor) toData()).getRegex(); - if(reg == null || reg.toRegText().equals("")){ - displayRegField = false; - } - return displayRegField? (CRPropertyDescriptor[]) ArrayUtils.addAll(sup, - new CRPropertyDescriptor[] {regex, regErrorMessage, waterMark} ): - (CRPropertyDescriptor[]) ArrayUtils.addAll(sup,new CRPropertyDescriptor[] {regex, waterMark}); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); + public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { + CRPropertyDescriptor widgetValue = new CRPropertyDescriptor("widgetValue", this.data.getClass()).setI18NName( + Inter.getLocText(new String[]{"FR-Designer_Widget", "Value"})).setEditorClass( + WidgetValueEditor.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"); + CRPropertyDescriptor regex = new CRPropertyDescriptor("regex", this.data.getClass()).setI18NName( + Inter.getLocText("FR-Designer_Input_Rule")).setEditorClass(RegexEditor.class).putKeyValue( + "renderer", RegexCellRencerer.class).putKeyValue(XCreatorConstants.PROPERTY_VALIDATE, "FR-Designer_Validate"); + CRPropertyDescriptor regErrorMessage = new CRPropertyDescriptor("regErrorMessage", this.data.getClass()).setI18NName( + Inter.getLocText("Verify-Message")).putKeyValue(XCreatorConstants.PROPERTY_VALIDATE, "FR-Designer_Validate"); + CRPropertyDescriptor waterMark = new CRPropertyDescriptor("waterMark", this.data.getClass()).setI18NName( + Inter.getLocText("FR-Designer_WaterMark")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, + "Advanced"); + CRPropertyDescriptor[] sup = (CRPropertyDescriptor[]) ArrayUtils.addAll(new CRPropertyDescriptor[]{widgetValue}, super.supportedDescriptor()); + Boolean displayRegField = true; + RegExp reg = ((TextEditor) toData()).getRegex(); + if (reg == null || !StringUtils.isNotEmpty(reg.toRegText())) { - TextEditor area = (TextEditor) data; - if (area.getWidgetValue() != null) { - Graphics2D g2d = (Graphics2D) g.create(); - BaseUtils.drawStringStyleInRotation(g2d, this.getWidth(), this.getHeight(), area.getWidgetValue() - .toString(), Style.getInstance(FRFont.getInstance()).deriveHorizontalAlignment(Constants.LEFT) - .deriveTextStyle(Style.TEXTSTYLE_SINGLELINE), ScreenResolution.getScreenResolution()); - } - } + displayRegField = false; + } + return displayRegField ? (CRPropertyDescriptor[]) ArrayUtils.addAll(sup, + new CRPropertyDescriptor[]{regex, regErrorMessage, waterMark}) : + (CRPropertyDescriptor[]) ArrayUtils.addAll(sup, new CRPropertyDescriptor[]{regex, waterMark}); + } + + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + + TextEditor area = (TextEditor) data; + if (area.getWidgetValue() != null) { + Graphics2D g2d = (Graphics2D) g.create(); + BaseUtils.drawStringStyleInRotation(g2d, this.getWidth(), this.getHeight(), area.getWidgetValue() + .toString(), Style.getInstance(FRFont.getInstance()).deriveHorizontalAlignment(Constants.LEFT) + .deriveTextStyle(Style.TEXTSTYLE_SINGLELINE), ScreenResolution.getScreenResolution()); + } + } @Override - protected JComponent initEditor() { - setBorder(FIELDBORDER); - return this; - } + protected JComponent initEditor() { + setBorder(FIELDBORDER); + return this; + } @Override protected String getIconName() {