Browse Source
* commit '95b199b57ed52ef65c319401056793bfd72a9a9b': 控件校验完善 控件校验完善 控件校验完善 控件校验完善 控件校验提示优化和控件属性整理master
superman
9 years ago
25 changed files with 545 additions and 379 deletions
@ -1,91 +1,128 @@ |
|||||||
package com.fr.design.widget.ui; |
package com.fr.design.widget.ui; |
||||||
|
|
||||||
import com.fr.design.gui.frpane.RegPane; |
import com.fr.design.gui.frpane.RegPane; |
||||||
|
import com.fr.design.gui.icheckbox.UICheckBox; |
||||||
|
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.FRGUIPaneFactory; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
import com.fr.form.ui.TextEditor; |
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 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.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 RegPane regPane; |
||||||
private WaterMarkDictPane waterMarkDictPane; |
private WaterMarkDictPane waterMarkDictPane; |
||||||
|
|
||||||
public TextFieldEditorDefinePane() { |
public TextFieldEditorDefinePane() { |
||||||
this.initComponents(); |
this.initComponents(); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
protected JPanel setFirstContentPane() { |
protected JPanel setFirstContentPane() { |
||||||
JPanel attrPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
JPanel attrPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
attrPane.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0)); |
attrPane.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4)); |
||||||
JPanel contenter = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
JPanel contenter = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
contenter.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0)); |
contenter.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4)); |
||||||
attrPane.add(contenter, BorderLayout.NORTH); |
attrPane.add(contenter); |
||||||
regPane = createRegPane(); |
regPane = createRegPane(); |
||||||
final RegPane.RegChangeListener rl = new RegPane.RegChangeListener() { |
final RegPane.RegChangeListener rl = new RegPane.RegChangeListener() { |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void regChangeAction() { |
public void regChangeAction() { |
||||||
waterMarkDictPane.setWaterMark(""); |
waterMarkDictPane.setWaterMark(""); |
||||||
regPane.removeRegChangeListener(this); |
regPane.removeRegChangeListener(this); |
||||||
} |
} |
||||||
}; |
}; |
||||||
final RegPane.PhoneRegListener pl = new RegPane.PhoneRegListener() { |
final RegPane.PhoneRegListener pl = new RegPane.PhoneRegListener() { |
||||||
public void phoneRegChangeAction(RegPane.PhoneRegEvent e) { |
public void phoneRegChangeAction(RegPane.PhoneRegEvent e) { |
||||||
if (StringUtils.isNotEmpty(e.getPhoneRegString()) |
if (StringUtils.isNotEmpty(e.getPhoneRegString()) |
||||||
&& StringUtils.isEmpty(waterMarkDictPane.getWaterMark())) { |
&& StringUtils.isEmpty(waterMarkDictPane.getWaterMark())) { |
||||||
waterMarkDictPane.setWaterMark(Inter.getLocText("Example") + ":" + e.getPhoneRegString()); |
waterMarkDictPane.setWaterMark(Inter.getLocText("Example") + ":" + e.getPhoneRegString()); |
||||||
regPane.addRegChangeListener(rl); |
regPane.addRegChangeListener(rl); |
||||||
} |
} |
||||||
} |
} |
||||||
}; |
}; |
||||||
regPane.addPhoneRegListener(pl); |
regPane.addPhoneRegListener(pl); |
||||||
|
JPanel basicPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Validate")); |
||||||
waterMarkDictPane = new WaterMarkDictPane(); |
JPanel validateContent = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); |
||||||
waterMarkDictPane.addInputKeyListener(new KeyAdapter() { |
getAllowBlankCheckBox().setPreferredSize(new Dimension(444, 40)); |
||||||
public void keyTyped(KeyEvent e) { |
validateContent.add(GUICoreUtils.createFlowPane(getAllowBlankCheckBox(), FlowLayout.LEFT)); |
||||||
regPane.removePhoneRegListener(pl); |
validateContent.add(GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText(new String[]{"Error", "Tooltips"}) + ":"), getErrorMsgTextField()}, FlowLayout.LEFT, 24)); |
||||||
regPane.removeRegChangeListener(rl); |
validateContent.add(GUICoreUtils.createFlowPane(regPane, FlowLayout.LEFT)); |
||||||
waterMarkDictPane.removeInputKeyListener(this); |
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")); |
||||||
contenter.add(regPane, BorderLayout.NORTH); |
waterMarkDictPane = new WaterMarkDictPane(); |
||||||
contenter.add(waterMarkDictPane, BorderLayout.CENTER); |
waterMarkDictPane.addInputKeyListener(new KeyAdapter() { |
||||||
return attrPane; |
public void keyTyped(KeyEvent e) { |
||||||
} |
regPane.removePhoneRegListener(pl); |
||||||
|
regPane.removeRegChangeListener(rl); |
||||||
protected RegPane createRegPane() { |
waterMarkDictPane.removeInputKeyListener(this); |
||||||
return new RegPane(); |
} |
||||||
} |
}); |
||||||
|
//监听填写规则下拉框的值的变化
|
||||||
@Override |
regPane.getRegComboBox().addActionListener(new ActionListener() { |
||||||
protected String title4PopupWindow() { |
public void actionPerformed(ActionEvent e) { |
||||||
return "text"; |
RegExp regExp = (RegExp) regPane.getRegComboBox().getSelectedItem(); |
||||||
} |
if (!StringUtils.isNotEmpty(regExp.toRegText())) { |
||||||
|
getRegErrorMsgTextField().setEnabled(false); |
||||||
@Override |
} else { |
||||||
protected void populateSubFieldEditorBean(TextEditor e) { |
getRegErrorMsgTextField().setEnabled(true); |
||||||
this.regPane.populate(e.getRegex()); |
} |
||||||
waterMarkDictPane.populate(e); |
|
||||||
} |
} |
||||||
|
}); |
||||||
@Override |
advancedPane.add(waterMarkDictPane); |
||||||
protected TextEditor updateSubFieldEditorBean() { |
contenter.add(advancedPane, BorderLayout.NORTH); |
||||||
TextEditor ob = newTextEditorInstance(); |
contenter.add(basicPane, BorderLayout.CENTER); |
||||||
|
return attrPane; |
||||||
ob.setRegex(this.regPane.update()); |
} |
||||||
waterMarkDictPane.update(ob); |
|
||||||
|
protected RegPane createRegPane() { |
||||||
return ob; |
return new RegPane(); |
||||||
} |
} |
||||||
|
|
||||||
protected TextEditor newTextEditorInstance() { |
@Override |
||||||
return new TextEditor(); |
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) { |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
} |
} |
@ -1 +1 @@ |
|||||||
package com.fr.design.designer.creator;
import com.fr.form.ui.WriteAbleRepeatEditor;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import java.awt.*;
import java.beans.IntrospectionException;
/**
* Author : Shockway
* Date: 13-9-22
* Time: 上午10:40
*/
public abstract class XCustomWriteAbleRepeatEditor extends XWriteAbleRepeatEditor {
public XCustomWriteAbleRepeatEditor(WriteAbleRepeatEditor widget, Dimension initSize) {
super(widget, initSize);
}
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
return (CRPropertyDescriptor[]) ArrayUtils.addAll(super.supportedDescriptor(),
new CRPropertyDescriptor[] { new CRPropertyDescriptor("customData",
this.data.getClass()).setI18NName(Inter.getLocText("Form-Allow_CustomData"))});
}
} |
package com.fr.design.designer.creator;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.form.ui.WriteAbleRepeatEditor;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import java.awt.*;
import java.beans.IntrospectionException;
/**
* Author : Shockway
* Date: 13-9-22
* Time: 上午10:40
*/
public abstract class XCustomWriteAbleRepeatEditor extends XWriteAbleRepeatEditor {
public XCustomWriteAbleRepeatEditor(WriteAbleRepeatEditor widget, Dimension initSize) {
super(widget, initSize);
}
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
return (CRPropertyDescriptor[]) ArrayUtils.addAll(super.supportedDescriptor(),
new CRPropertyDescriptor[] { new CRPropertyDescriptor("customData",
this.data.getClass()).setI18NName(Inter.getLocText("Form-Allow_CustomData"))
.putKeyValue(XCreatorConstants.PROPERTY_VALIDATE, "FR-Designer_Validate")});
}
} |
Loading…
Reference in new issue