Browse Source

Merge pull request #1169 in BA/design from ~KERRY/design:release/9.0 to release/9.0

* commit 'd0c317b32aac38f9d9392e5eeb5225adbe5af64d':
  代码修改
  REPORT-3735 [9.0一轮回归]文本控件中错误提示自动变为正则表达式内容
master
superman 7 years ago
parent
commit
8488adcc43
  1. 5
      designer/src/com/fr/design/widget/ui/PasswordDefinePane.java
  2. 5
      designer/src/com/fr/design/widget/ui/TextAreaDefinePane.java
  3. 20
      designer/src/com/fr/design/widget/ui/TextFieldEditorDefinePane.java
  4. 108
      designer_base/src/com/fr/design/gui/frpane/RegFieldPane.java
  5. 72
      designer_base/src/com/fr/design/gui/frpane/RegPane.java
  6. 13
      designer_form/src/com/fr/design/widget/ui/designer/PasswordDefinePane.java
  7. 9
      designer_form/src/com/fr/design/widget/ui/designer/TextAreaDefinePane.java
  8. 23
      designer_form/src/com/fr/design/widget/ui/designer/TextFieldEditorDefinePane.java

5
designer/src/com/fr/design/widget/ui/PasswordDefinePane.java

@ -1,5 +1,6 @@
package com.fr.design.widget.ui; package com.fr.design.widget.ui;
import com.fr.design.gui.frpane.RegFieldPane;
import com.fr.design.gui.frpane.RegPane; import com.fr.design.gui.frpane.RegPane;
import com.fr.form.ui.Password; import com.fr.form.ui.Password;
import com.fr.form.ui.TextEditor; import com.fr.form.ui.TextEditor;
@ -12,7 +13,7 @@ public class PasswordDefinePane extends TextFieldEditorDefinePane {
return new Password(); return new Password();
} }
protected RegPane createRegPane() { protected RegFieldPane createRegPane() {
return new RegPane(RegPane.PASSWORD_REG_TYPE); return new RegFieldPane(RegPane.PASSWORD_REG_TYPE);
} }
} }

5
designer/src/com/fr/design/widget/ui/TextAreaDefinePane.java

@ -1,5 +1,6 @@
package com.fr.design.widget.ui; package com.fr.design.widget.ui;
import com.fr.design.gui.frpane.RegFieldPane;
import com.fr.design.gui.frpane.RegPane; import com.fr.design.gui.frpane.RegPane;
import com.fr.form.ui.TextArea; import com.fr.form.ui.TextArea;
import com.fr.form.ui.TextEditor; import com.fr.form.ui.TextEditor;
@ -12,7 +13,7 @@ public class TextAreaDefinePane extends TextFieldEditorDefinePane {
return new TextArea(); return new TextArea();
} }
protected RegPane createRegPane() { protected RegFieldPane createRegPane() {
return new RegPane(RegPane.TEXTAREA_REG_TYPE); return new RegFieldPane(RegPane.TEXTAREA_REG_TYPE);
} }
} }

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

@ -1,5 +1,6 @@
package com.fr.design.widget.ui; package com.fr.design.widget.ui;
import com.fr.design.gui.frpane.RegFieldPane;
import com.fr.design.gui.frpane.RegPane; import com.fr.design.gui.frpane.RegPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.form.ui.TextEditor; import com.fr.form.ui.TextEditor;
@ -9,13 +10,11 @@ import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor> { public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor> {
protected RegPane regPane; protected RegFieldPane regPane;
private WaterMarkDictPane waterMarkDictPane; private WaterMarkDictPane waterMarkDictPane;
public TextFieldEditorDefinePane() { public TextFieldEditorDefinePane() {
@ -51,13 +50,6 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor>
waterMarkDictPane.removeInputKeyListener(this); 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(); JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane();
waterMarkDictPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); waterMarkDictPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
content.add(waterMarkDictPane, BorderLayout.CENTER); content.add(waterMarkDictPane, BorderLayout.CENTER);
@ -70,8 +62,8 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor>
} }
protected RegPane createRegPane() { protected RegFieldPane createRegPane() {
return new RegPane(); return new RegFieldPane();
} }
@Override @Override
@ -81,14 +73,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);
waterMarkDictPane.populate(e); waterMarkDictPane.populate(e);
} }
@Override @Override
protected TextEditor updateSubFieldEditorBean() { protected TextEditor updateSubFieldEditorBean() {
TextEditor ob = newTextEditorInstance(); TextEditor ob = newTextEditorInstance();
ob.setRegex(this.regPane.update()); this.regPane.update(ob);
waterMarkDictPane.update(ob); waterMarkDictPane.update(ob);
return ob; return ob;

108
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 "RegErrorMsg";
}
public void populate(TextEditor textEditor) {
regErrorMsgField.setText(textEditor.getRegErrorMessage());
}
public void update(TextEditor textEditor) {
textEditor.setRegErrorMessage(regErrorMsgField.getText());
}
}
}

72
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 com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -55,7 +53,6 @@ public class RegPane extends BasicPane {
private RegPhonePane regPhonePane; private RegPhonePane regPhonePane;
private DefaultRegPane defaultRegPane; private DefaultRegPane defaultRegPane;
private CustomRegRexPane customRegRexPane; private CustomRegRexPane customRegRexPane;
protected RegErrorMsgPane regErrorMsgPane;
public UIComboBox getRegComboBox(){ public UIComboBox getRegComboBox(){
@ -78,9 +75,10 @@ public class RegPane extends BasicPane {
regComboBox.setRenderer(listCellRender); 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); 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(); JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
regErrorMsgPane = new RegErrorMsgPane();
final JPanel cardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); final JPanel cardPane = FRGUIPaneFactory.createCardLayout_S_Pane();
detailedCardLayout = new CardLayout(); detailedCardLayout = new CardLayout();
cardPane.setLayout(detailedCardLayout); cardPane.setLayout(detailedCardLayout);
@ -89,8 +87,8 @@ public class RegPane extends BasicPane {
cardPane.add((regPhonePane = new RegPhonePane()), "Phone"); cardPane.add((regPhonePane = new RegPhonePane()), "Phone");
cardPane.add((customRegRexPane = new CustomRegRexPane()), "Custom"); cardPane.add((customRegRexPane = new CustomRegRexPane()), "Custom");
centerPane.add(cardPane, BorderLayout.NORTH); centerPane.add(cardPane, BorderLayout.NORTH);
centerPane.add(regErrorMsgPane, BorderLayout.CENTER); jPanel.add(centerPane, BorderLayout.CENTER);
this.add(centerPane, BorderLayout.CENTER); this.add(jPanel, BorderLayout.NORTH);
regComboBox.addActionListener(new ActionListener(){ regComboBox.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
RegExp regExp = (RegExp)regComboBox.getSelectedItem(); RegExp regExp = (RegExp)regComboBox.getSelectedItem();
@ -113,11 +111,6 @@ public class RegPane extends BasicPane {
} }
fireRegChangeAction(); fireRegChangeAction();
} }
if(regExp instanceof NoneReg){
regErrorMsgPane.setVisible(false);
return;
}
regErrorMsgPane.setVisible(true);
} }
}); });
} }
@ -150,12 +143,10 @@ public class RegPane extends BasicPane {
} else { } else {
defaultRegPane.populate(regex); defaultRegPane.populate(regex);
} }
regErrorMsgPane.populate(regex);
} }
public RegExp update(){ public RegExp update(){
RegExp regExp = (RegExp)regComboBox.getSelectedItem(); RegExp regExp = (RegExp)regComboBox.getSelectedItem();
regErrorMsgPane.update();
if (regExp instanceof LengthReg){ if (regExp instanceof LengthReg){
return regLengthPane.update(); return regLengthPane.update();
} else if(regExp instanceof PhoneReg) { } else if(regExp instanceof PhoneReg) {
@ -174,6 +165,9 @@ public class RegPane extends BasicPane {
} }
} }
private static abstract class DisplayPane extends BasicPane { private static abstract class DisplayPane extends BasicPane {
public abstract void populate(RegExp regRex); 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(){ ListCellRenderer listCellRender = new UIComboBoxRenderer(){
@Override @Override

13
designer_form/src/com/fr/design/widget/ui/designer/PasswordDefinePane.java

@ -1,9 +1,9 @@
package com.fr.design.widget.ui.designer; package com.fr.design.widget.ui.designer;
import com.fr.design.designer.creator.XCreator; 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.frpane.RegPane;
import com.fr.form.ui.Password;
import com.fr.form.ui.TextEditor;
public class PasswordDefinePane extends TextFieldEditorDefinePane { public class PasswordDefinePane extends TextFieldEditorDefinePane {
@ -12,12 +12,7 @@ public class PasswordDefinePane extends TextFieldEditorDefinePane {
} }
private static final long serialVersionUID = 4737910705071750562L; private static final long serialVersionUID = 4737910705071750562L;
@Override protected RegFieldPane createRegPane() {
protected TextEditor newTextEditorInstance() { return new RegFieldPane(RegPane.PASSWORD_REG_TYPE);
return new Password();
}
protected RegPane createRegPane() {
return new RegPane(RegPane.PASSWORD_REG_TYPE);
} }
} }

9
designer_form/src/com/fr/design/widget/ui/designer/TextAreaDefinePane.java

@ -1,6 +1,7 @@
package com.fr.design.widget.ui.designer; package com.fr.design.widget.ui.designer;
import com.fr.design.designer.creator.XCreator; 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.frpane.RegPane;
import com.fr.form.ui.TextArea; import com.fr.form.ui.TextArea;
import com.fr.form.ui.TextEditor; import com.fr.form.ui.TextEditor;
@ -10,12 +11,8 @@ public class TextAreaDefinePane extends TextFieldEditorDefinePane {
public TextAreaDefinePane(XCreator xCreator) { public TextAreaDefinePane(XCreator xCreator) {
super(xCreator); super(xCreator);
} }
@Override
protected TextEditor newTextEditorInstance() {
return new TextArea();
}
protected RegPane createRegPane() { protected RegFieldPane createRegPane() {
return new RegPane(RegPane.TEXTAREA_REG_TYPE); return new RegFieldPane(RegPane.TEXTAREA_REG_TYPE);
} }
} }

23
designer_form/src/com/fr/design/widget/ui/designer/TextFieldEditorDefinePane.java

@ -1,6 +1,7 @@
package com.fr.design.widget.ui.designer; package com.fr.design.widget.ui.designer;
import com.fr.design.designer.creator.XCreator; 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.frpane.RegPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
@ -17,7 +18,7 @@ import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor> { public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor> {
protected RegPane regPane; protected RegFieldPane regPane;
private UITextField waterMarkDictPane; private UITextField waterMarkDictPane;
FormWidgetValuePane formWidgetValuePane; FormWidgetValuePane formWidgetValuePane;
@ -55,15 +56,6 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor>
waterMarkDictPane.removeKeyListener(this); 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); formWidgetValuePane = new FormWidgetValuePane(creator.toData(), false);
double f = TableLayout.FILL; double f = TableLayout.FILL;
@ -90,8 +82,8 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor>
protected RegPane createRegPane() { protected RegFieldPane createRegPane() {
return new RegPane(); return new RegFieldPane();
} }
@Override @Override
@ -101,7 +93,7 @@ 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);
waterMarkDictPane.setText(e.getWaterMark()); waterMarkDictPane.setText(e.getWaterMark());
formWidgetValuePane.populate(e); formWidgetValuePane.populate(e);
} }
@ -109,14 +101,11 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor>
@Override @Override
protected TextEditor updateSubFieldEditorBean() { protected TextEditor updateSubFieldEditorBean() {
TextEditor ob = (TextEditor)creator.toData(); TextEditor ob = (TextEditor)creator.toData();
ob.setRegex(this.regPane.update()); this.regPane.update(ob);
ob.setWaterMark(waterMarkDictPane.getText()); ob.setWaterMark(waterMarkDictPane.getText());
formWidgetValuePane.update(ob); formWidgetValuePane.update(ob);
return ob; return ob;
} }
protected TextEditor newTextEditorInstance() {
return new TextEditor();
}
} }
Loading…
Cancel
Save