Browse Source

控件校验完善

master
kerry 8 years ago
parent
commit
95b199b57e
  1. 19
      designer/src/com/fr/design/widget/ui/FieldEditorDefinePane.java
  2. 34
      designer/src/com/fr/design/widget/ui/NumberEditorDefinePane.java
  3. 46
      designer/src/com/fr/design/widget/ui/TextFieldEditorDefinePane.java

19
designer/src/com/fr/design/widget/ui/FieldEditorDefinePane.java

@ -26,6 +26,7 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
private UICheckBox allowBlankCheckBox; private UICheckBox allowBlankCheckBox;
// richer:错误信息,是所有控件共有的属性,所以放到这里来 // richer:错误信息,是所有控件共有的属性,所以放到这里来
private UITextField errorMsgTextField; private UITextField errorMsgTextField;
private UITextField regErrorMsgTextField;
public FieldEditorDefinePane() { public FieldEditorDefinePane() {
this.initComponents(); this.initComponents();
@ -33,6 +34,20 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
protected void initComponents() { protected void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); 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(); //JPanel firstPanel = FRGUIPaneFactory.createBorderLayout_M_Pane();
allowBlankCheckBox = new UICheckBox(Inter.getLocText("Allow_Blank")); allowBlankCheckBox = new UICheckBox(Inter.getLocText("Allow_Blank"));
@ -125,4 +140,8 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
return errorMsgTextField; return errorMsgTextField;
} }
public UITextField getRegErrorMsgTextField() {
return regErrorMsgTextField;
}
} }

34
designer/src/com/fr/design/widget/ui/NumberEditorDefinePane.java

@ -42,7 +42,6 @@ public class NumberEditorDefinePane extends FieldEditorDefinePane<NumberEditor>
private com.fr.design.editor.editor.IntegerEditor decimalLength; private com.fr.design.editor.editor.IntegerEditor decimalLength;
private JPanel limitNumberPane; private JPanel limitNumberPane;
private WaterMarkDictPane waterMarkDictPane; private WaterMarkDictPane waterMarkDictPane;
private UITextField regErrorMsgTextField;
private ActionListener actionListener1 = new ActionListener() { private ActionListener actionListener1 = new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -168,12 +167,12 @@ public class NumberEditorDefinePane extends FieldEditorDefinePane<NumberEditor>
northPane.add(waterMarkDictPane); northPane.add(waterMarkDictPane);
JPanel centerPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Validate")); JPanel centerPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Validate"));
JPanel validatePane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); JPanel validatePane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
validatePane.setPreferredSize(new Dimension(400,200)); validatePane.setPreferredSize(new Dimension(400, 200));
centerPane.add(validatePane); centerPane.add(validatePane);
content.add(northPane, BorderLayout.NORTH); content.add(northPane, BorderLayout.NORTH);
content.add(centerPane, BorderLayout.CENTER); content.add(centerPane, BorderLayout.CENTER);
validatePane.add(GUICoreUtils.createFlowPane(getAllowBlankCheckBox(), FlowLayout.LEFT)); 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.allowDecimalsCheckBox = new UICheckBox(Inter.getLocText("Allow_Decimals"));
this.decimalLength = new com.fr.design.editor.editor.IntegerEditor(); this.decimalLength = new com.fr.design.editor.editor.IntegerEditor();
@ -205,24 +204,7 @@ public class NumberEditorDefinePane extends FieldEditorDefinePane<NumberEditor>
this.minValueSpinner.setVisible(false); this.minValueSpinner.setVisible(false);
this.setMinValueCheckBox.addActionListener(actionListener4); this.setMinValueCheckBox.addActionListener(actionListener4);
this.minValueSpinner.addChangeListener(changeListener2); this.minValueSpinner.addChangeListener(changeListener2);
validatePane.add(GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText(new String[]{"Error", "Tooltips"}) + ":"), getRegErrorMsgTextField()}, FlowLayout.LEFT, 24));
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());
}
});
return content; return content;
} }
@ -258,7 +240,7 @@ public class NumberEditorDefinePane extends FieldEditorDefinePane<NumberEditor>
minValueSpinner.setVisible(true); minValueSpinner.setVisible(true);
minValueSpinner.setValue(new Double(e.getMinValue())); minValueSpinner.setValue(new Double(e.getMinValue()));
} }
this.regErrorMsgTextField.setText(e.getRegErrorMessage()); this.getRegErrorMsgTextField().setText(e.getRegErrorMessage());
this.waterMarkDictPane.populate(e); this.waterMarkDictPane.populate(e);
} }
@ -286,7 +268,7 @@ public class NumberEditorDefinePane extends FieldEditorDefinePane<NumberEditor>
this.waterMarkDictPane.update(ob); this.waterMarkDictPane.update(ob);
ob.setRegErrorMessage(this.regErrorMsgTextField.getText()); ob.setRegErrorMessage(this.getRegErrorMsgTextField().getText());
return ob; return ob;
} }
@ -315,7 +297,9 @@ public class NumberEditorDefinePane extends FieldEditorDefinePane<NumberEditor>
df.setAllowsInvalid(false); df.setAllowsInvalid(false);
} }
} }
@Override
public void addAllowBlankPane(UICheckBox allowBlankCheckBox,JPanel errorMsgPane){}
@Override
public void addAllowBlankPane(UICheckBox allowBlankCheckBox, JPanel errorMsgPane) {
} }
}

46
designer/src/com/fr/design/widget/ui/TextFieldEditorDefinePane.java

@ -24,7 +24,6 @@ import java.awt.event.KeyEvent;
public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor> { public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor> {
protected RegPane regPane; protected RegPane regPane;
private WaterMarkDictPane waterMarkDictPane; private WaterMarkDictPane waterMarkDictPane;
private UITextField regErrorMsgTextField;
public TextFieldEditorDefinePane() { public TextFieldEditorDefinePane() {
this.initComponents(); this.initComponents();
@ -37,24 +36,6 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor>
JPanel contenter = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel contenter = FRGUIPaneFactory.createBorderLayout_S_Pane();
contenter.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4)); contenter.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4));
attrPane.add(contenter); 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(); regPane = createRegPane();
final RegPane.RegChangeListener rl = new RegPane.RegChangeListener() { final RegPane.RegChangeListener rl = new RegPane.RegChangeListener() {
@ -76,11 +57,11 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor>
regPane.addPhoneRegListener(pl); regPane.addPhoneRegListener(pl);
JPanel basicPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Validate")); JPanel basicPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Validate"));
JPanel validateContent = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); JPanel validateContent = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
getAllowBlankCheckBox().setPreferredSize(new Dimension(444,40)); getAllowBlankCheckBox().setPreferredSize(new Dimension(444, 40));
validateContent.add(GUICoreUtils.createFlowPane(getAllowBlankCheckBox(), FlowLayout.LEFT)); 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(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(regPane, FlowLayout.LEFT));
validateContent.add(GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText(new String[]{"Error", "Tooltips"}) + ":"),regErrorMsgTextField}, FlowLayout.LEFT,24)); validateContent.add(GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText(new String[]{"Error", "Tooltips"}) + ":"), getRegErrorMsgTextField()}, FlowLayout.LEFT, 24));
basicPane.add(validateContent); basicPane.add(validateContent);
JPanel advancedPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Advanced")); JPanel advancedPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Advanced"));
waterMarkDictPane = new WaterMarkDictPane(); waterMarkDictPane = new WaterMarkDictPane();
@ -92,13 +73,13 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor>
} }
}); });
//监听填写规则下拉框的值的变化 //监听填写规则下拉框的值的变化
regPane.getRegComboBox().addActionListener(new ActionListener(){ regPane.getRegComboBox().addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
RegExp regExp = (RegExp)regPane.getRegComboBox().getSelectedItem(); RegExp regExp = (RegExp) regPane.getRegComboBox().getSelectedItem();
if(regExp instanceof NoneReg){ if (!StringUtils.isNotEmpty(regExp.toRegText())) {
regErrorMsgTextField.setEnabled(false); getRegErrorMsgTextField().setEnabled(false);
}else{ } else {
regErrorMsgTextField.setEnabled(true); getRegErrorMsgTextField().setEnabled(true);
} }
} }
@ -121,14 +102,14 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor>
@Override @Override
protected void populateSubFieldEditorBean(TextEditor e) { protected void populateSubFieldEditorBean(TextEditor e) {
this.regPane.populate(e.getRegex()); this.regPane.populate(e.getRegex());
regErrorMsgTextField.setText(e.getRegErrorMessage()); getRegErrorMsgTextField().setText(e.getRegErrorMessage());
waterMarkDictPane.populate(e); waterMarkDictPane.populate(e);
} }
@Override @Override
protected TextEditor updateSubFieldEditorBean() { protected TextEditor updateSubFieldEditorBean() {
TextEditor ob = newTextEditorInstance(); TextEditor ob = newTextEditorInstance();
ob.setRegErrorMessage(this.regErrorMsgTextField.getText()); ob.setRegErrorMessage(this.getRegErrorMsgTextField().getText());
ob.setRegex(this.regPane.update()); ob.setRegex(this.regPane.update());
waterMarkDictPane.update(ob); waterMarkDictPane.update(ob);
@ -140,7 +121,8 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor>
} }
@Override @Override
public void addAllowBlankPane(UICheckBox allowBlankCheckBox, JPanel errorMsgPane){} public void addAllowBlankPane(UICheckBox allowBlankCheckBox, JPanel errorMsgPane) {
}
} }
Loading…
Cancel
Save