From 6dcf9dc9636d8be4c09f185975dc7fe1e6e889b4 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 4 Sep 2017 10:45:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-3735=20[9.0=E4=B8=80=E8=BD=AE?= =?UTF-8?q?=E5=9B=9E=E5=BD=92]=E6=96=87=E6=9C=AC=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8F=98=E4=B8=BA=E6=AD=A3=E5=88=99=E8=A1=A8=E8=BE=BE=E5=BC=8F?= =?UTF-8?q?=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/widget/ui/PasswordDefinePane.java | 5 +- .../design/widget/ui/TextAreaDefinePane.java | 5 +- .../widget/ui/TextFieldEditorDefinePane.java | 20 +--- .../fr/design/gui/frpane/RegFieldPane.java | 108 ++++++++++++++++++ .../src/com/fr/design/gui/frpane/RegPane.java | 72 ++---------- .../ui/designer/PasswordDefinePane.java | 13 +-- .../ui/designer/TextAreaDefinePane.java | 9 +- .../designer/TextFieldEditorDefinePane.java | 23 +--- 8 files changed, 141 insertions(+), 114 deletions(-) create mode 100644 designer_base/src/com/fr/design/gui/frpane/RegFieldPane.java diff --git a/designer/src/com/fr/design/widget/ui/PasswordDefinePane.java b/designer/src/com/fr/design/widget/ui/PasswordDefinePane.java index c8b285b64..c8112b751 100644 --- a/designer/src/com/fr/design/widget/ui/PasswordDefinePane.java +++ b/designer/src/com/fr/design/widget/ui/PasswordDefinePane.java @@ -1,5 +1,6 @@ package com.fr.design.widget.ui; +import com.fr.design.gui.frpane.RegFieldPane; import com.fr.design.gui.frpane.RegPane; import com.fr.form.ui.Password; import com.fr.form.ui.TextEditor; @@ -12,7 +13,7 @@ public class PasswordDefinePane extends TextFieldEditorDefinePane { return new Password(); } - protected RegPane createRegPane() { - return new RegPane(RegPane.PASSWORD_REG_TYPE); + protected RegFieldPane createRegPane() { + return new RegFieldPane(RegPane.PASSWORD_REG_TYPE); } } \ No newline at end of file diff --git a/designer/src/com/fr/design/widget/ui/TextAreaDefinePane.java b/designer/src/com/fr/design/widget/ui/TextAreaDefinePane.java index da2c2a07b..d83a99e1b 100644 --- a/designer/src/com/fr/design/widget/ui/TextAreaDefinePane.java +++ b/designer/src/com/fr/design/widget/ui/TextAreaDefinePane.java @@ -1,5 +1,6 @@ package com.fr.design.widget.ui; +import com.fr.design.gui.frpane.RegFieldPane; import com.fr.design.gui.frpane.RegPane; import com.fr.form.ui.TextArea; import com.fr.form.ui.TextEditor; @@ -12,7 +13,7 @@ public class TextAreaDefinePane extends TextFieldEditorDefinePane { return new TextArea(); } - protected RegPane createRegPane() { - return new RegPane(RegPane.TEXTAREA_REG_TYPE); + protected RegFieldPane createRegPane() { + return new RegFieldPane(RegPane.TEXTAREA_REG_TYPE); } } \ No newline at end of file diff --git a/designer/src/com/fr/design/widget/ui/TextFieldEditorDefinePane.java b/designer/src/com/fr/design/widget/ui/TextFieldEditorDefinePane.java index 0f2a41907..33981226d 100644 --- a/designer/src/com/fr/design/widget/ui/TextFieldEditorDefinePane.java +++ b/designer/src/com/fr/design/widget/ui/TextFieldEditorDefinePane.java @@ -1,5 +1,6 @@ package com.fr.design.widget.ui; +import com.fr.design.gui.frpane.RegFieldPane; import com.fr.design.gui.frpane.RegPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.form.ui.TextEditor; @@ -9,13 +10,11 @@ import com.fr.stable.StringUtils; import javax.swing.*; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; public class TextFieldEditorDefinePane extends FieldEditorDefinePane { - protected RegPane regPane; + protected RegFieldPane regPane; private WaterMarkDictPane waterMarkDictPane; public TextFieldEditorDefinePane() { @@ -51,13 +50,6 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane waterMarkDictPane.removeInputKeyListener(this); } }); - //监听填写规则下拉框的值的变化 - regPane.getRegComboBox().addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - RegExp regExp = (RegExp) regPane.getRegComboBox().getSelectedItem(); - - } - }); JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane(); waterMarkDictPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); content.add(waterMarkDictPane, BorderLayout.CENTER); @@ -70,8 +62,8 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane } - protected RegPane createRegPane() { - return new RegPane(); + protected RegFieldPane createRegPane() { + return new RegFieldPane(); } @Override @@ -81,14 +73,14 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane @Override protected void populateSubFieldEditorBean(TextEditor e) { - this.regPane.populate(e.getRegex()); + this.regPane.populate(e); waterMarkDictPane.populate(e); } @Override protected TextEditor updateSubFieldEditorBean() { TextEditor ob = newTextEditorInstance(); - ob.setRegex(this.regPane.update()); + this.regPane.update(ob); waterMarkDictPane.update(ob); return ob; diff --git a/designer_base/src/com/fr/design/gui/frpane/RegFieldPane.java b/designer_base/src/com/fr/design/gui/frpane/RegFieldPane.java new file mode 100644 index 000000000..ae91035d8 --- /dev/null +++ b/designer_base/src/com/fr/design/gui/frpane/RegFieldPane.java @@ -0,0 +1,108 @@ +package com.fr.design.gui.frpane; + +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.form.ui.TextEditor; +import com.fr.form.ui.reg.NoneReg; +import com.fr.form.ui.reg.RegExp; +import com.fr.general.Inter; + +import javax.swing.*; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import java.awt.*; + +/** + * Created by kerry on 2017/9/4. + */ +public class RegFieldPane extends RegPane { + protected RegErrorMsgPane regErrorMsgPane; + + public RegFieldPane(){ + this(ALL_REG_TYPE); + } + + public RegFieldPane(RegExp[] types) { + super(types); + initComponents(); + } + + public void initComponents() { + regErrorMsgPane = new RegErrorMsgPane(); + final RegChangeListener regChangeListener = new RegChangeListener() { + + @Override + public void regChangeAction() { + RegExp regExp = (RegExp)getRegComboBox().getSelectedItem(); + if(regExp instanceof NoneReg){ + regErrorMsgPane.setVisible(false); + return; + } + regErrorMsgPane.setVisible(true); + } + }; + this.addRegChangeListener(regChangeListener); + this.add(regErrorMsgPane, BorderLayout.CENTER); + } + + @Override + protected String title4PopupWindow() { + return "RegFieldPane"; + } + + public void populate(TextEditor textEditor) { + populate(textEditor.getRegex()); + regErrorMsgPane.populate(textEditor); + } + + public void update(TextEditor textEditor) { + textEditor.setRegex(update()); + regErrorMsgPane.update(textEditor); + } + + private static class RegErrorMsgPane extends BasicPane { + private UITextField regErrorMsgField; + + public RegErrorMsgPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); + initRegErrorMsgField(); + JPanel panel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{new UILabel(Inter.getLocText("FR-Designer_Widget_Error_Tip")), regErrorMsgField}}, TableLayoutHelper.FILL_LASTCOLUMN, 18, 7); + this.add(panel); + } + + private void initRegErrorMsgField() { + regErrorMsgField = new UITextField(); + regErrorMsgField.getDocument().addDocumentListener(new DocumentListener() { + public void changedUpdate(DocumentEvent e) { + regErrorMsgField.setToolTipText(regErrorMsgField.getText()); + } + + public void insertUpdate(DocumentEvent e) { + regErrorMsgField.setToolTipText(regErrorMsgField.getText()); + } + + public void removeUpdate(DocumentEvent e) { + regErrorMsgField.setToolTipText(regErrorMsgField.getText()); + } + }); + } + + @Override + protected String title4PopupWindow() { + return "CUSTOM"; + } + + public void populate(TextEditor textEditor) { + regErrorMsgField.setText(textEditor.getRegErrorMessage()); + } + + public void update(TextEditor textEditor) { + textEditor.setRegErrorMessage(regErrorMsgField.getText()); + } + } + +} diff --git a/designer_base/src/com/fr/design/gui/frpane/RegPane.java b/designer_base/src/com/fr/design/gui/frpane/RegPane.java index c6e16bbe9..84201cdef 100644 --- a/designer_base/src/com/fr/design/gui/frpane/RegPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/RegPane.java @@ -16,8 +16,6 @@ import com.fr.general.Inter; import com.fr.stable.StringUtils; import javax.swing.*; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -55,7 +53,6 @@ public class RegPane extends BasicPane { private RegPhonePane regPhonePane; private DefaultRegPane defaultRegPane; private CustomRegRexPane customRegRexPane; - protected RegErrorMsgPane regErrorMsgPane; public UIComboBox getRegComboBox(){ @@ -78,9 +75,10 @@ public class RegPane extends BasicPane { regComboBox.setRenderer(listCellRender); JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{new UILabel(Inter.getLocText("FR-Designer_Input_Rule")), regComboBox}}, TableLayoutHelper.FILL_LASTCOLUMN, 18, 7); - this.add(contentPane, BorderLayout.NORTH); + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + + jPanel.add(contentPane, BorderLayout.NORTH); JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - regErrorMsgPane = new RegErrorMsgPane(); final JPanel cardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); detailedCardLayout = new CardLayout(); cardPane.setLayout(detailedCardLayout); @@ -89,8 +87,8 @@ public class RegPane extends BasicPane { cardPane.add((regPhonePane = new RegPhonePane()), "Phone"); cardPane.add((customRegRexPane = new CustomRegRexPane()), "Custom"); centerPane.add(cardPane, BorderLayout.NORTH); - centerPane.add(regErrorMsgPane, BorderLayout.CENTER); - this.add(centerPane, BorderLayout.CENTER); + jPanel.add(centerPane, BorderLayout.CENTER); + this.add(jPanel, BorderLayout.NORTH); regComboBox.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { RegExp regExp = (RegExp)regComboBox.getSelectedItem(); @@ -113,11 +111,6 @@ public class RegPane extends BasicPane { } fireRegChangeAction(); } - if(regExp instanceof NoneReg){ - regErrorMsgPane.setVisible(false); - return; - } - regErrorMsgPane.setVisible(true); } }); } @@ -150,12 +143,10 @@ public class RegPane extends BasicPane { } else { defaultRegPane.populate(regex); } - regErrorMsgPane.populate(regex); } public RegExp update(){ RegExp regExp = (RegExp)regComboBox.getSelectedItem(); - regErrorMsgPane.update(); if (regExp instanceof LengthReg){ return regLengthPane.update(); } else if(regExp instanceof PhoneReg) { @@ -174,6 +165,9 @@ public class RegPane extends BasicPane { } } + + + private static abstract class DisplayPane extends BasicPane { public abstract void populate(RegExp regRex); @@ -481,56 +475,6 @@ public class RegPane extends BasicPane { } } - private static class RegErrorMsgPane extends DisplayPane{ - private UITextField regErrorMsgField; - - public RegErrorMsgPane(){ - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); - initRegErrorMsgField(); - JPanel panel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{new UILabel(Inter.getLocText("FR-Designer_Widget_Error_Tip")), regErrorMsgField}}, TableLayoutHelper.FILL_LASTCOLUMN, 18, 7); - this.add(panel); - } - - private void initRegErrorMsgField(){ - regErrorMsgField = new UITextField(); - regErrorMsgField.getDocument().addDocumentListener(new DocumentListener() { - public void changedUpdate(DocumentEvent e) { - regErrorMsgField.setToolTipText(regErrorMsgField.getText()); - } - - public void insertUpdate(DocumentEvent e) { - regErrorMsgField.setToolTipText(regErrorMsgField.getText()); - } - - public void removeUpdate(DocumentEvent e) { - regErrorMsgField.setToolTipText(regErrorMsgField.getText()); - } - }); - } - - @Override - protected String title4PopupWindow() { - return "CUSTOM"; - } - - @Override - public void populate(RegExp regRex) { - if (!(regRex instanceof CustomReg)){ - return; - } - regErrorMsgField.setText(regRex.toRegText()); - } - - @Override - public RegExp update() { - return new CustomReg(regErrorMsgField.getText()); - } - - public boolean isEmpty() { - return StringUtils.isEmpty(regErrorMsgField.getText()); - } - } ListCellRenderer listCellRender = new UIComboBoxRenderer(){ @Override diff --git a/designer_form/src/com/fr/design/widget/ui/designer/PasswordDefinePane.java b/designer_form/src/com/fr/design/widget/ui/designer/PasswordDefinePane.java index e3c529b43..c01f30d33 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/PasswordDefinePane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/PasswordDefinePane.java @@ -1,9 +1,9 @@ package com.fr.design.widget.ui.designer; import com.fr.design.designer.creator.XCreator; +import com.fr.design.gui.frpane.RegFieldPane; import com.fr.design.gui.frpane.RegPane; -import com.fr.form.ui.Password; -import com.fr.form.ui.TextEditor; + public class PasswordDefinePane extends TextFieldEditorDefinePane { @@ -12,12 +12,7 @@ public class PasswordDefinePane extends TextFieldEditorDefinePane { } private static final long serialVersionUID = 4737910705071750562L; - @Override - protected TextEditor newTextEditorInstance() { - return new Password(); - } - - protected RegPane createRegPane() { - return new RegPane(RegPane.PASSWORD_REG_TYPE); + protected RegFieldPane createRegPane() { + return new RegFieldPane(RegPane.PASSWORD_REG_TYPE); } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/widget/ui/designer/TextAreaDefinePane.java b/designer_form/src/com/fr/design/widget/ui/designer/TextAreaDefinePane.java index 0fc4d617e..211db396b 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/TextAreaDefinePane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/TextAreaDefinePane.java @@ -1,6 +1,7 @@ package com.fr.design.widget.ui.designer; import com.fr.design.designer.creator.XCreator; +import com.fr.design.gui.frpane.RegFieldPane; import com.fr.design.gui.frpane.RegPane; import com.fr.form.ui.TextArea; import com.fr.form.ui.TextEditor; @@ -10,12 +11,8 @@ public class TextAreaDefinePane extends TextFieldEditorDefinePane { public TextAreaDefinePane(XCreator xCreator) { super(xCreator); } - @Override - protected TextEditor newTextEditorInstance() { - return new TextArea(); - } - protected RegPane createRegPane() { - return new RegPane(RegPane.TEXTAREA_REG_TYPE); + protected RegFieldPane createRegPane() { + return new RegFieldPane(RegPane.TEXTAREA_REG_TYPE); } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/widget/ui/designer/TextFieldEditorDefinePane.java b/designer_form/src/com/fr/design/widget/ui/designer/TextFieldEditorDefinePane.java index cc5abe66e..7ea30f871 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/TextFieldEditorDefinePane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/TextFieldEditorDefinePane.java @@ -1,6 +1,7 @@ package com.fr.design.widget.ui.designer; import com.fr.design.designer.creator.XCreator; +import com.fr.design.gui.frpane.RegFieldPane; import com.fr.design.gui.frpane.RegPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; @@ -17,7 +18,7 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; public class TextFieldEditorDefinePane extends FieldEditorDefinePane { - protected RegPane regPane; + protected RegFieldPane regPane; private UITextField waterMarkDictPane; FormWidgetValuePane formWidgetValuePane; @@ -55,15 +56,6 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane waterMarkDictPane.removeKeyListener(this); } }); - //监听填写规则下拉框的值的变化 -// regPane.getRegComboBox().addActionListener(new ActionListener() { -// public void actionPerformed(ActionEvent e) { -// RegExp regExp = (RegExp) regPane.getRegComboBox().getSelectedItem(); -//// regErrorMsgTextField.setEnabled(regExp.errorMessageEditable()); -// -// } -// }); - formWidgetValuePane = new FormWidgetValuePane(creator.toData(), false); double f = TableLayout.FILL; @@ -90,8 +82,8 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane - protected RegPane createRegPane() { - return new RegPane(); + protected RegFieldPane createRegPane() { + return new RegFieldPane(); } @Override @@ -101,7 +93,7 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane @Override protected void populateSubFieldEditorBean(TextEditor e) { - this.regPane.populate(e.getRegex()); + this.regPane.populate(e); waterMarkDictPane.setText(e.getWaterMark()); formWidgetValuePane.populate(e); } @@ -109,14 +101,11 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane @Override protected TextEditor updateSubFieldEditorBean() { TextEditor ob = (TextEditor)creator.toData(); - ob.setRegex(this.regPane.update()); + this.regPane.update(ob); ob.setWaterMark(waterMarkDictPane.getText()); formWidgetValuePane.update(ob); return ob; } - protected TextEditor newTextEditorInstance() { - return new TextEditor(); - } } \ No newline at end of file From d0c317b32aac38f9d9392e5eeb5225adbe5af64d Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 4 Sep 2017 11:00:05 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/gui/frpane/RegFieldPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/gui/frpane/RegFieldPane.java b/designer_base/src/com/fr/design/gui/frpane/RegFieldPane.java index ae91035d8..6768d0dfd 100644 --- a/designer_base/src/com/fr/design/gui/frpane/RegFieldPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/RegFieldPane.java @@ -93,7 +93,7 @@ public class RegFieldPane extends RegPane { @Override protected String title4PopupWindow() { - return "CUSTOM"; + return "RegErrorMsg"; } public void populate(TextEditor textEditor) {