From 95b199b57ed52ef65c319401056793bfd72a9a9b Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 1 Aug 2016 15:47:06 +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 --- .../widget/ui/FieldEditorDefinePane.java | 19 ++ .../widget/ui/NumberEditorDefinePane.java | 46 ++-- .../widget/ui/TextFieldEditorDefinePane.java | 226 ++++++++---------- 3 files changed, 138 insertions(+), 153 deletions(-) diff --git a/designer/src/com/fr/design/widget/ui/FieldEditorDefinePane.java b/designer/src/com/fr/design/widget/ui/FieldEditorDefinePane.java index 23cf15e12b..eebd9c4f07 100644 --- a/designer/src/com/fr/design/widget/ui/FieldEditorDefinePane.java +++ b/designer/src/com/fr/design/widget/ui/FieldEditorDefinePane.java @@ -26,6 +26,7 @@ public abstract class FieldEditorDefinePane extends Abstr private UICheckBox allowBlankCheckBox; // richer:错误信息,是所有控件共有的属性,所以放到这里来 private UITextField errorMsgTextField; + private UITextField regErrorMsgTextField; public FieldEditorDefinePane() { this.initComponents(); @@ -33,6 +34,20 @@ public abstract class FieldEditorDefinePane extends Abstr protected void initComponents() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); + regErrorMsgTextField = new UITextField(16); + regErrorMsgTextField.getDocument().addDocumentListener(new DocumentListener() { + public void changedUpdate(DocumentEvent e) { + regErrorMsgTextField.setToolTipText(regErrorMsgTextField.getText()); + } + + public void insertUpdate(DocumentEvent e) { + regErrorMsgTextField.setToolTipText(regErrorMsgTextField.getText()); + } + + public void removeUpdate(DocumentEvent e) { + regErrorMsgTextField.setToolTipText(regErrorMsgTextField.getText()); + } + }); //JPanel firstPanel = FRGUIPaneFactory.createBorderLayout_M_Pane(); allowBlankCheckBox = new UICheckBox(Inter.getLocText("Allow_Blank")); @@ -125,4 +140,8 @@ public abstract class FieldEditorDefinePane extends Abstr return errorMsgTextField; } + public UITextField getRegErrorMsgTextField() { + return regErrorMsgTextField; + } + } \ No newline at end of file diff --git a/designer/src/com/fr/design/widget/ui/NumberEditorDefinePane.java b/designer/src/com/fr/design/widget/ui/NumberEditorDefinePane.java index e4261061b2..26d34065c6 100644 --- a/designer/src/com/fr/design/widget/ui/NumberEditorDefinePane.java +++ b/designer/src/com/fr/design/widget/ui/NumberEditorDefinePane.java @@ -42,7 +42,6 @@ public class NumberEditorDefinePane extends FieldEditorDefinePane private com.fr.design.editor.editor.IntegerEditor decimalLength; private JPanel limitNumberPane; private WaterMarkDictPane waterMarkDictPane; - private UITextField regErrorMsgTextField; private ActionListener actionListener1 = new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -125,9 +124,9 @@ public class NumberEditorDefinePane extends FieldEditorDefinePane @Override public void stateChanged(ChangeEvent e) { if (setMaxValueCheckBox.isSelected()) { - if (setMinValueCheckBox.isSelected()) { - minValueModel.setMaximum(Double.parseDouble("" + maxValueSpinner.getValue())); - } + if (setMinValueCheckBox.isSelected()) { + minValueModel.setMaximum(Double.parseDouble("" + maxValueSpinner.getValue())); + } } } }; @@ -137,9 +136,9 @@ public class NumberEditorDefinePane extends FieldEditorDefinePane @Override public void stateChanged(ChangeEvent e) { if (setMinValueCheckBox.isSelected()) { - if (setMaxValueCheckBox.isSelected()) { - maxValueModel.setMinimum(Double.parseDouble("" + minValueSpinner.getValue())); - } + if (setMaxValueCheckBox.isSelected()) { + maxValueModel.setMinimum(Double.parseDouble("" + minValueSpinner.getValue())); + } } } }; @@ -168,12 +167,12 @@ public class NumberEditorDefinePane extends FieldEditorDefinePane northPane.add(waterMarkDictPane); JPanel centerPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Validate")); JPanel validatePane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); - validatePane.setPreferredSize(new Dimension(400,200)); + validatePane.setPreferredSize(new Dimension(400, 200)); centerPane.add(validatePane); content.add(northPane, BorderLayout.NORTH); content.add(centerPane, BorderLayout.CENTER); validatePane.add(GUICoreUtils.createFlowPane(getAllowBlankCheckBox(), FlowLayout.LEFT)); - validatePane.add(GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText(new String[]{"Error", "Tooltips"}) + ":"),getErrorMsgTextField()}, FlowLayout.LEFT,24)); + validatePane.add(GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText(new String[]{"Error", "Tooltips"}) + ":"), getErrorMsgTextField()}, FlowLayout.LEFT, 24)); this.allowDecimalsCheckBox = new UICheckBox(Inter.getLocText("Allow_Decimals")); this.decimalLength = new com.fr.design.editor.editor.IntegerEditor(); @@ -205,24 +204,7 @@ public class NumberEditorDefinePane extends FieldEditorDefinePane this.minValueSpinner.setVisible(false); this.setMinValueCheckBox.addActionListener(actionListener4); this.minValueSpinner.addChangeListener(changeListener2); - - regErrorMsgTextField = new UITextField(16); - validatePane.add(GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText(new String[]{"Error", "Tooltips"}) + ":"),regErrorMsgTextField}, FlowLayout.LEFT,24)); - - regErrorMsgTextField.getDocument().addDocumentListener(new DocumentListener() { - - public void changedUpdate(DocumentEvent e) { - regErrorMsgTextField.setToolTipText(regErrorMsgTextField.getText()); - } - - public void insertUpdate(DocumentEvent e) { - regErrorMsgTextField.setToolTipText(regErrorMsgTextField.getText()); - } - - public void removeUpdate(DocumentEvent e) { - regErrorMsgTextField.setToolTipText(regErrorMsgTextField.getText()); - } - }); + validatePane.add(GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText(new String[]{"Error", "Tooltips"}) + ":"), getRegErrorMsgTextField()}, FlowLayout.LEFT, 24)); return content; } @@ -258,7 +240,7 @@ public class NumberEditorDefinePane extends FieldEditorDefinePane minValueSpinner.setVisible(true); minValueSpinner.setValue(new Double(e.getMinValue())); } - this.regErrorMsgTextField.setText(e.getRegErrorMessage()); + this.getRegErrorMsgTextField().setText(e.getRegErrorMessage()); this.waterMarkDictPane.populate(e); } @@ -286,7 +268,7 @@ public class NumberEditorDefinePane extends FieldEditorDefinePane this.waterMarkDictPane.update(ob); - ob.setRegErrorMessage(this.regErrorMsgTextField.getText()); + ob.setRegErrorMessage(this.getRegErrorMsgTextField().getText()); return ob; } @@ -315,7 +297,9 @@ public class NumberEditorDefinePane extends FieldEditorDefinePane df.setAllowsInvalid(false); } } + @Override - public void addAllowBlankPane(UICheckBox allowBlankCheckBox,JPanel errorMsgPane){} + public void addAllowBlankPane(UICheckBox allowBlankCheckBox, JPanel errorMsgPane) { + } - } \ No newline at end of file +} \ 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 ecee0612b0..2399a90cec 100644 --- a/designer/src/com/fr/design/widget/ui/TextFieldEditorDefinePane.java +++ b/designer/src/com/fr/design/widget/ui/TextFieldEditorDefinePane.java @@ -22,125 +22,107 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; public class TextFieldEditorDefinePane extends FieldEditorDefinePane { - protected RegPane regPane; - private WaterMarkDictPane waterMarkDictPane; - private UITextField regErrorMsgTextField; - - public TextFieldEditorDefinePane() { - this.initComponents(); - } - - @Override - protected JPanel setFirstContentPane() { - JPanel attrPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - attrPane.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4)); - JPanel contenter = FRGUIPaneFactory.createBorderLayout_S_Pane(); - contenter.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4)); - attrPane.add(contenter); - JPanel regErrorMsgPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); - regErrorMsgTextField = new UITextField(16); - regErrorMsgPane.add(GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText(new String[]{"Error", "Tooltips"}) + ":"),regErrorMsgTextField}, FlowLayout.LEFT,24)); - - regErrorMsgTextField.getDocument().addDocumentListener(new DocumentListener() { - - public void changedUpdate(DocumentEvent e) { - regErrorMsgTextField.setToolTipText(regErrorMsgTextField.getText()); - } - - public void insertUpdate(DocumentEvent e) { - regErrorMsgTextField.setToolTipText(regErrorMsgTextField.getText()); - } - - public void removeUpdate(DocumentEvent e) { - regErrorMsgTextField.setToolTipText(regErrorMsgTextField.getText()); - } - }); - regPane = createRegPane(); - final RegPane.RegChangeListener rl = new RegPane.RegChangeListener() { - - @Override - public void regChangeAction() { - waterMarkDictPane.setWaterMark(""); - regPane.removeRegChangeListener(this); - } - }; - final RegPane.PhoneRegListener pl = new RegPane.PhoneRegListener() { - public void phoneRegChangeAction(RegPane.PhoneRegEvent e) { - if (StringUtils.isNotEmpty(e.getPhoneRegString()) - && StringUtils.isEmpty(waterMarkDictPane.getWaterMark())) { - waterMarkDictPane.setWaterMark(Inter.getLocText("Example") + ":" + e.getPhoneRegString()); - regPane.addRegChangeListener(rl); - } - } - }; - regPane.addPhoneRegListener(pl); - JPanel basicPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Validate")); - JPanel validateContent = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); - getAllowBlankCheckBox().setPreferredSize(new Dimension(444,40)); - validateContent.add(GUICoreUtils.createFlowPane(getAllowBlankCheckBox(), FlowLayout.LEFT)); - validateContent.add(GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText(new String[]{"Error", "Tooltips"}) + ":"),getErrorMsgTextField()}, FlowLayout.LEFT,24)); - validateContent.add(GUICoreUtils.createFlowPane(regPane, FlowLayout.LEFT)); - validateContent.add(GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText(new String[]{"Error", "Tooltips"}) + ":"),regErrorMsgTextField}, FlowLayout.LEFT,24)); - basicPane.add(validateContent); - JPanel advancedPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Advanced")); - waterMarkDictPane = new WaterMarkDictPane(); - waterMarkDictPane.addInputKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { - regPane.removePhoneRegListener(pl); - regPane.removeRegChangeListener(rl); - waterMarkDictPane.removeInputKeyListener(this); - } - }); - //监听填写规则下拉框的值的变化 - regPane.getRegComboBox().addActionListener(new ActionListener(){ - public void actionPerformed(ActionEvent e) { - RegExp regExp = (RegExp)regPane.getRegComboBox().getSelectedItem(); - if(regExp instanceof NoneReg){ - regErrorMsgTextField.setEnabled(false); - }else{ - regErrorMsgTextField.setEnabled(true); - } - - } - }); - advancedPane.add(waterMarkDictPane); - contenter.add(advancedPane, BorderLayout.NORTH); - contenter.add(basicPane, BorderLayout.CENTER); - return attrPane; - } - - protected RegPane createRegPane() { - return new RegPane(); - } - - @Override - protected String title4PopupWindow() { - return "text"; - } - - @Override - protected void populateSubFieldEditorBean(TextEditor e) { - this.regPane.populate(e.getRegex()); - regErrorMsgTextField.setText(e.getRegErrorMessage()); - waterMarkDictPane.populate(e); - } - - @Override - protected TextEditor updateSubFieldEditorBean() { - TextEditor ob = newTextEditorInstance(); - ob.setRegErrorMessage(this.regErrorMsgTextField.getText()); - ob.setRegex(this.regPane.update()); - waterMarkDictPane.update(ob); - - return ob; - } - - protected TextEditor newTextEditorInstance() { - return new TextEditor(); - } - - @Override - public void addAllowBlankPane(UICheckBox allowBlankCheckBox, JPanel errorMsgPane){} - - - } \ No newline at end of file + protected RegPane regPane; + private WaterMarkDictPane waterMarkDictPane; + + public TextFieldEditorDefinePane() { + this.initComponents(); + } + + @Override + protected JPanel setFirstContentPane() { + JPanel attrPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + attrPane.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4)); + JPanel contenter = FRGUIPaneFactory.createBorderLayout_S_Pane(); + contenter.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4)); + attrPane.add(contenter); + regPane = createRegPane(); + final RegPane.RegChangeListener rl = new RegPane.RegChangeListener() { + + @Override + public void regChangeAction() { + waterMarkDictPane.setWaterMark(""); + regPane.removeRegChangeListener(this); + } + }; + final RegPane.PhoneRegListener pl = new RegPane.PhoneRegListener() { + public void phoneRegChangeAction(RegPane.PhoneRegEvent e) { + if (StringUtils.isNotEmpty(e.getPhoneRegString()) + && StringUtils.isEmpty(waterMarkDictPane.getWaterMark())) { + waterMarkDictPane.setWaterMark(Inter.getLocText("Example") + ":" + e.getPhoneRegString()); + regPane.addRegChangeListener(rl); + } + } + }; + regPane.addPhoneRegListener(pl); + JPanel basicPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Validate")); + JPanel validateContent = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); + getAllowBlankCheckBox().setPreferredSize(new Dimension(444, 40)); + validateContent.add(GUICoreUtils.createFlowPane(getAllowBlankCheckBox(), FlowLayout.LEFT)); + validateContent.add(GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText(new String[]{"Error", "Tooltips"}) + ":"), getErrorMsgTextField()}, FlowLayout.LEFT, 24)); + validateContent.add(GUICoreUtils.createFlowPane(regPane, FlowLayout.LEFT)); + validateContent.add(GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText(new String[]{"Error", "Tooltips"}) + ":"), getRegErrorMsgTextField()}, FlowLayout.LEFT, 24)); + basicPane.add(validateContent); + JPanel advancedPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Advanced")); + waterMarkDictPane = new WaterMarkDictPane(); + waterMarkDictPane.addInputKeyListener(new KeyAdapter() { + public void keyTyped(KeyEvent e) { + regPane.removePhoneRegListener(pl); + regPane.removeRegChangeListener(rl); + waterMarkDictPane.removeInputKeyListener(this); + } + }); + //监听填写规则下拉框的值的变化 + regPane.getRegComboBox().addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + RegExp regExp = (RegExp) regPane.getRegComboBox().getSelectedItem(); + if (!StringUtils.isNotEmpty(regExp.toRegText())) { + getRegErrorMsgTextField().setEnabled(false); + } else { + getRegErrorMsgTextField().setEnabled(true); + } + + } + }); + advancedPane.add(waterMarkDictPane); + contenter.add(advancedPane, BorderLayout.NORTH); + contenter.add(basicPane, BorderLayout.CENTER); + return attrPane; + } + + protected RegPane createRegPane() { + return new RegPane(); + } + + @Override + protected String title4PopupWindow() { + return "text"; + } + + @Override + protected void populateSubFieldEditorBean(TextEditor e) { + this.regPane.populate(e.getRegex()); + getRegErrorMsgTextField().setText(e.getRegErrorMessage()); + waterMarkDictPane.populate(e); + } + + @Override + protected TextEditor updateSubFieldEditorBean() { + TextEditor ob = newTextEditorInstance(); + ob.setRegErrorMessage(this.getRegErrorMsgTextField().getText()); + ob.setRegex(this.regPane.update()); + waterMarkDictPane.update(ob); + + return ob; + } + + protected TextEditor newTextEditorInstance() { + return new TextEditor(); + } + + @Override + public void addAllowBlankPane(UICheckBox allowBlankCheckBox, JPanel errorMsgPane) { + } + + +} \ No newline at end of file