|
|
@ -16,6 +16,8 @@ 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; |
|
|
@ -53,9 +55,10 @@ 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(){ |
|
|
|
return regComboBox; |
|
|
|
return regComboBox; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -68,25 +71,21 @@ public class RegPane extends BasicPane { |
|
|
|
this.initComponents(); |
|
|
|
this.initComponents(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initComponents() { |
|
|
|
private void initComponents(){ |
|
|
|
this.setLayout(new BorderLayout()); |
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
|
|
|
JPanel contentPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(); |
|
|
|
|
|
|
|
this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
|
|
|
|
|
|
|
this.add(contentPane, BorderLayout.NORTH); |
|
|
|
|
|
|
|
contentPane.add(new UILabel(Inter.getLocText("FR-Designer_Input_Rule"))); |
|
|
|
regComboBox = new UIComboBox(regType); |
|
|
|
regComboBox = new UIComboBox(regType); |
|
|
|
|
|
|
|
regComboBox.setPreferredSize(new Dimension(140, 20)); |
|
|
|
regComboBox.setRenderer(listCellRender); |
|
|
|
regComboBox.setRenderer(listCellRender); |
|
|
|
|
|
|
|
UILabel uiLabel = new UILabel(); |
|
|
|
|
|
|
|
uiLabel.setPreferredSize(new Dimension(20, 20)); |
|
|
|
|
|
|
|
contentPane.add(uiLabel); |
|
|
|
|
|
|
|
contentPane.add(regComboBox); |
|
|
|
|
|
|
|
|
|
|
|
double f = TableLayout.FILL; |
|
|
|
regErrorMsgPane = new RegErrorMsgPane(); |
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
|
|
|
|
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Input_Rule") + " "), regComboBox}, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
double[] rowSize = {p}; |
|
|
|
|
|
|
|
double[] columnSize = {p, f}; |
|
|
|
|
|
|
|
int[][] rowCount = {{1, 1}}; |
|
|
|
|
|
|
|
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_LARGE); |
|
|
|
|
|
|
|
panel.setBorder(BorderFactory.createEmptyBorder(8, 0, 0, 0)); |
|
|
|
|
|
|
|
this.add(panel, BorderLayout.NORTH); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
@ -94,26 +93,35 @@ public class RegPane extends BasicPane { |
|
|
|
cardPane.add((regLengthPane = new RegLengthPane()), "Length"); |
|
|
|
cardPane.add((regLengthPane = new RegLengthPane()), "Length"); |
|
|
|
cardPane.add((regPhonePane = new RegPhonePane()), "Phone"); |
|
|
|
cardPane.add((regPhonePane = new RegPhonePane()), "Phone"); |
|
|
|
cardPane.add((customRegRexPane = new CustomRegRexPane()), "Custom"); |
|
|
|
cardPane.add((customRegRexPane = new CustomRegRexPane()), "Custom"); |
|
|
|
cardPane.setBorder(BorderFactory.createEmptyBorder(8, 12, 0, 0)); |
|
|
|
|
|
|
|
this.add(cardPane, BorderLayout.CENTER); |
|
|
|
this.add(cardPane, BorderLayout.CENTER); |
|
|
|
regComboBox.addActionListener(new ActionListener() { |
|
|
|
this.add(regErrorMsgPane, BorderLayout.SOUTH); |
|
|
|
|
|
|
|
regComboBox.addActionListener(new ActionListener(){ |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
RegExp regExp = (RegExp) regComboBox.getSelectedItem(); |
|
|
|
RegExp regExp = (RegExp)regComboBox.getSelectedItem(); |
|
|
|
if (regExp instanceof PhoneReg) { |
|
|
|
if(regExp instanceof PhoneReg) { |
|
|
|
|
|
|
|
cardPane.setPreferredSize(new Dimension(220, 30)); |
|
|
|
Object selectItem = regPhonePane.dataTypeComboBox.getSelectedItem(); |
|
|
|
Object selectItem = regPhonePane.dataTypeComboBox.getSelectedItem(); |
|
|
|
String regString = selectItem == null ? StringUtils.EMPTY : selectItem.toString(); |
|
|
|
String regString = selectItem == null ? StringUtils.EMPTY : selectItem.toString(); |
|
|
|
firePhoneRegAction(regString); |
|
|
|
firePhoneRegAction(regString); |
|
|
|
detailedCardLayout.show(cardPane, "Phone"); |
|
|
|
detailedCardLayout.show(cardPane, "Phone"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (regExp instanceof LengthReg) { |
|
|
|
if (regExp instanceof LengthReg){ |
|
|
|
|
|
|
|
cardPane.setPreferredSize(new Dimension(220, 60)); |
|
|
|
detailedCardLayout.show(cardPane, "Length"); |
|
|
|
detailedCardLayout.show(cardPane, "Length"); |
|
|
|
} else if (regExp instanceof CustomReg) { |
|
|
|
} else if (regExp instanceof CustomReg){ |
|
|
|
|
|
|
|
cardPane.setPreferredSize(new Dimension(220, 30)); |
|
|
|
detailedCardLayout.show(cardPane, "Custom"); |
|
|
|
detailedCardLayout.show(cardPane, "Custom"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
cardPane.setPreferredSize(new Dimension(0,0 )); |
|
|
|
detailedCardLayout.show(cardPane, "Default"); |
|
|
|
detailedCardLayout.show(cardPane, "Default"); |
|
|
|
} |
|
|
|
} |
|
|
|
fireRegChangeAction(); |
|
|
|
fireRegChangeAction(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(regExp instanceof NoneReg){ |
|
|
|
|
|
|
|
regErrorMsgPane.setVisible(false); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
regErrorMsgPane.setVisible(true); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -146,19 +154,21 @@ 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) { |
|
|
|
return regPhonePane.update(); |
|
|
|
return regPhonePane.update(); |
|
|
|
} else if (regExp instanceof NoneReg || regExp instanceof MailReg || regExp instanceof IDCardReg |
|
|
|
} else if(regExp instanceof NoneReg || regExp instanceof MailReg || regExp instanceof IDCardReg |
|
|
|
|| regExp instanceof PostCardReg || regExp instanceof PhoneReg || regExp instanceof MobileReg) { |
|
|
|
|| regExp instanceof PostCardReg || regExp instanceof PhoneReg || regExp instanceof MobileReg) { |
|
|
|
return regExp; |
|
|
|
return regExp; |
|
|
|
} else if (regExp instanceof CustomReg) { |
|
|
|
} |
|
|
|
|
|
|
|
else if (regExp instanceof CustomReg){ |
|
|
|
if (customRegRexPane.isEmpty()) { |
|
|
|
if (customRegRexPane.isEmpty()) { |
|
|
|
return new NoneReg(); |
|
|
|
return new NoneReg(); |
|
|
|
} |
|
|
|
} |
|
|
@ -177,7 +187,7 @@ public class RegPane extends BasicPane { |
|
|
|
private static class DefaultRegPane extends DisplayPane { |
|
|
|
private static class DefaultRegPane extends DisplayPane { |
|
|
|
public RegExp regRex; |
|
|
|
public RegExp regRex; |
|
|
|
|
|
|
|
|
|
|
|
public DefaultRegPane() { |
|
|
|
public DefaultRegPane(){ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -203,7 +213,10 @@ public class RegPane extends BasicPane { |
|
|
|
* 添加电话规则监听器 |
|
|
|
* 添加电话规则监听器 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param listener 监听器 |
|
|
|
* @param listener 监听器 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* |
|
|
|
* @date 2014-12-3-下午7:30:55 |
|
|
|
* @date 2014-12-3-下午7:30:55 |
|
|
|
|
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void addPhoneRegListener(PhoneRegListener listener) { |
|
|
|
public void addPhoneRegListener(PhoneRegListener listener) { |
|
|
|
this.listenerList.add(PhoneRegListener.class, listener); |
|
|
|
this.listenerList.add(PhoneRegListener.class, listener); |
|
|
@ -213,7 +226,10 @@ public class RegPane extends BasicPane { |
|
|
|
* 移除电话规则监听器 |
|
|
|
* 移除电话规则监听器 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param listener 监听器 |
|
|
|
* @param listener 监听器 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* |
|
|
|
* @date 2014-12-3-下午7:30:55 |
|
|
|
* @date 2014-12-3-下午7:30:55 |
|
|
|
|
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void removePhoneRegListener(PhoneRegListener listener) { |
|
|
|
public void removePhoneRegListener(PhoneRegListener listener) { |
|
|
|
this.listenerList.remove(PhoneRegListener.class, listener); |
|
|
|
this.listenerList.remove(PhoneRegListener.class, listener); |
|
|
@ -223,7 +239,10 @@ public class RegPane extends BasicPane { |
|
|
|
* 添加正则监听器 |
|
|
|
* 添加正则监听器 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param listener 监听器 |
|
|
|
* @param listener 监听器 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* |
|
|
|
* @date 2014-12-3-下午7:29:48 |
|
|
|
* @date 2014-12-3-下午7:29:48 |
|
|
|
|
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void addRegChangeListener(RegChangeListener listener) { |
|
|
|
public void addRegChangeListener(RegChangeListener listener) { |
|
|
|
this.listenerList.add(RegChangeListener.class, listener); |
|
|
|
this.listenerList.add(RegChangeListener.class, listener); |
|
|
@ -233,7 +252,10 @@ public class RegPane extends BasicPane { |
|
|
|
* 移除正则监听器 |
|
|
|
* 移除正则监听器 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param listener 监听器 |
|
|
|
* @param listener 监听器 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* |
|
|
|
* @date 2014-12-3-下午7:29:48 |
|
|
|
* @date 2014-12-3-下午7:29:48 |
|
|
|
|
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void removeRegChangeListener(RegChangeListener listener) { |
|
|
|
public void removeRegChangeListener(RegChangeListener listener) { |
|
|
|
this.listenerList.remove(RegChangeListener.class, listener); |
|
|
|
this.listenerList.remove(RegChangeListener.class, listener); |
|
|
@ -241,45 +263,41 @@ public class RegPane extends BasicPane { |
|
|
|
|
|
|
|
|
|
|
|
public class PhoneRegEvent extends EventObject { |
|
|
|
public class PhoneRegEvent extends EventObject { |
|
|
|
private String phoneRegString; |
|
|
|
private String phoneRegString; |
|
|
|
|
|
|
|
|
|
|
|
public PhoneRegEvent(Object source, String phoneRegString) { |
|
|
|
public PhoneRegEvent(Object source, String phoneRegString) { |
|
|
|
super(source); |
|
|
|
super(source); |
|
|
|
this.setPhoneRegString(phoneRegString); |
|
|
|
this.setPhoneRegString(phoneRegString); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setPhoneRegString(String phoneRegString) { |
|
|
|
public void setPhoneRegString(String phoneRegString) { |
|
|
|
this.phoneRegString = phoneRegString; |
|
|
|
this.phoneRegString = phoneRegString; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getPhoneRegString() { |
|
|
|
public String getPhoneRegString() { |
|
|
|
return phoneRegString; |
|
|
|
return phoneRegString; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class RegChangeEvent extends EventObject { |
|
|
|
public class RegChangeEvent extends EventObject { |
|
|
|
private String regString; |
|
|
|
private String regString; |
|
|
|
|
|
|
|
|
|
|
|
public RegChangeEvent(Object source, String regString) { |
|
|
|
public RegChangeEvent(Object source, String regString) { |
|
|
|
super(source); |
|
|
|
super(source); |
|
|
|
this.setRegString(regString); |
|
|
|
this.setRegString(regString); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setRegString(String regString) { |
|
|
|
public void setRegString(String regString) { |
|
|
|
this.regString = regString; |
|
|
|
this.regString = regString; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getRegString() { |
|
|
|
public String getRegString() { |
|
|
|
return regString; |
|
|
|
return regString; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public interface PhoneRegListener extends EventListener { |
|
|
|
public interface PhoneRegListener extends EventListener{ |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 电话规则变化监听 |
|
|
|
* 电话规则变化监听 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param e 变化事件 |
|
|
|
* @param e 变化事件 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* |
|
|
|
* @date 2014-12-3-下午7:29:01 |
|
|
|
* @date 2014-12-3-下午7:29:01 |
|
|
|
|
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void phoneRegChangeAction(PhoneRegEvent e); |
|
|
|
void phoneRegChangeAction(PhoneRegEvent e); |
|
|
|
|
|
|
|
|
|
|
@ -290,29 +308,28 @@ public class RegPane extends BasicPane { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 正则表达规则变化监听 |
|
|
|
* 正则表达规则变化监听 |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* |
|
|
|
* @date 2014-12-3-下午7:29:01 |
|
|
|
* @date 2014-12-3-下午7:29:01 |
|
|
|
|
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void regChangeAction(); |
|
|
|
void regChangeAction(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void firePhoneRegAction(String phoneReg) { |
|
|
|
protected void firePhoneRegAction(String phoneReg) { |
|
|
|
Object[] listeners = listenerList.getListenerList(); |
|
|
|
Object[] listeners = listenerList.getListenerList(); |
|
|
|
for (int i = listeners.length - 2; i >= 0; i -= 2) { |
|
|
|
for (int i = listeners.length-2; i>=0; i-=2) { |
|
|
|
if (listeners[i] == PhoneRegListener.class) { |
|
|
|
if (listeners[i]==PhoneRegListener.class) { |
|
|
|
((PhoneRegListener) listeners[i + 1]).phoneRegChangeAction(new PhoneRegEvent(this, phoneReg)); |
|
|
|
((PhoneRegListener)listeners[i+1]).phoneRegChangeAction(new PhoneRegEvent(this , phoneReg)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void fireRegChangeAction() { |
|
|
|
protected void fireRegChangeAction() { |
|
|
|
Object[] listeners = listenerList.getListenerList(); |
|
|
|
Object[] listeners = listenerList.getListenerList(); |
|
|
|
for (int i = listeners.length - 2; i >= 0; i -= 2) { |
|
|
|
for (int i = listeners.length-2; i>=0; i-=2) { |
|
|
|
if (listeners[i] == RegChangeListener.class) { |
|
|
|
if (listeners[i]==RegChangeListener.class) { |
|
|
|
((RegChangeListener) listeners[i + 1]).regChangeAction(); |
|
|
|
((RegChangeListener)listeners[i+1]).regChangeAction(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private class RegPhonePane extends DisplayPane { |
|
|
|
private class RegPhonePane extends DisplayPane { |
|
|
|
private static final String EMB_REG1 = "025-85679591"; |
|
|
|
private static final String EMB_REG1 = "025-85679591"; |
|
|
|
private static final String EMB_REG2 = "02585679591"; |
|
|
|
private static final String EMB_REG2 = "02585679591"; |
|
|
@ -322,19 +339,20 @@ public class RegPane extends BasicPane { |
|
|
|
|
|
|
|
|
|
|
|
private UIComboBox dataTypeComboBox; |
|
|
|
private UIComboBox dataTypeComboBox; |
|
|
|
private final String[] dataType = {EMB_REG1, EMB_REG2, EMB_REG3, Inter.getLocText("FR-Designer_Custom")}; |
|
|
|
private final String[] dataType = {EMB_REG1, EMB_REG2, EMB_REG3, Inter.getLocText("FR-Designer_Custom")}; |
|
|
|
DefaultComboBoxModel DefaultComboBoxModel = new DefaultComboBoxModel(dataType); |
|
|
|
DefaultComboBoxModel DefaultComboBoxModel= new DefaultComboBoxModel(dataType); |
|
|
|
|
|
|
|
|
|
|
|
public RegPhonePane() { |
|
|
|
public RegPhonePane() { |
|
|
|
this.setLayout(FRGUIPaneFactory.createLabelFlowLayout()); |
|
|
|
this.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 5)); |
|
|
|
this.add(new UILabel(Inter.getLocText("FR-Designer_Data_Type") + ":")); |
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
dataTypeComboBox = new UIComboBox(DefaultComboBoxModel); |
|
|
|
dataTypeComboBox = new UIComboBox(DefaultComboBoxModel); |
|
|
|
JTextField editFiled = (JTextField) (dataTypeComboBox.getEditor().getEditorComponent()); |
|
|
|
JTextField editFiled = (JTextField)(dataTypeComboBox.getEditor().getEditorComponent()); |
|
|
|
|
|
|
|
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{new UILabel(Inter.getLocText("FR-Designer_Data_Type")), dataTypeComboBox}}, TableLayoutHelper.FILL_LASTCOLUMN, 18, 7); |
|
|
|
|
|
|
|
this.add(panel); |
|
|
|
editFiled.setDocument(new LimitedDocument(LIMIT_LENGTH, REG_PATTERN)); |
|
|
|
editFiled.setDocument(new LimitedDocument(LIMIT_LENGTH, REG_PATTERN)); |
|
|
|
dataTypeComboBox.addItemListener(new ItemListener() { |
|
|
|
dataTypeComboBox.addItemListener(new ItemListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void itemStateChanged(ItemEvent e) { |
|
|
|
public void itemStateChanged(ItemEvent e) { |
|
|
|
if (e.getStateChange() == ItemEvent.SELECTED) { |
|
|
|
if(e.getStateChange() == ItemEvent.SELECTED) { |
|
|
|
if (ComparatorUtils.equals(e.getItem(), dataType[3])) { |
|
|
|
if(ComparatorUtils.equals(e.getItem(), dataType[3])) { |
|
|
|
dataTypeComboBox.setSelectedItem(null); |
|
|
|
dataTypeComboBox.setSelectedItem(null); |
|
|
|
dataTypeComboBox.setEditable(true); |
|
|
|
dataTypeComboBox.setEditable(true); |
|
|
|
firePhoneRegAction(EMB_REG1); |
|
|
|
firePhoneRegAction(EMB_REG1); |
|
|
@ -347,9 +365,7 @@ public class RegPane extends BasicPane { |
|
|
|
}); |
|
|
|
}); |
|
|
|
dataTypeComboBox.setSelectedIndex(0); |
|
|
|
dataTypeComboBox.setSelectedIndex(0); |
|
|
|
firePhoneRegAction(dataTypeComboBox.getSelectedItem().toString()); |
|
|
|
firePhoneRegAction(dataTypeComboBox.getSelectedItem().toString()); |
|
|
|
this.add(dataTypeComboBox); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected String title4PopupWindow() { |
|
|
|
protected String title4PopupWindow() { |
|
|
|
return "PHONE"; |
|
|
|
return "PHONE"; |
|
|
@ -357,17 +373,17 @@ public class RegPane extends BasicPane { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void populate(RegExp regRex) { |
|
|
|
public void populate(RegExp regRex) { |
|
|
|
if (!(regRex instanceof PhoneReg)) { |
|
|
|
if(!(regRex instanceof PhoneReg)) { |
|
|
|
return; |
|
|
|
return ; |
|
|
|
} |
|
|
|
} |
|
|
|
String regstr = ((PhoneReg) regRex).getRegString(); |
|
|
|
String regstr = ((PhoneReg)regRex).getRegString(); |
|
|
|
if (checkEmbedded(regstr)) { |
|
|
|
if (checkEmbedded(regstr)){ |
|
|
|
DefaultComboBoxModel.addElement(regstr); |
|
|
|
DefaultComboBoxModel.addElement(regstr); |
|
|
|
} |
|
|
|
} |
|
|
|
dataTypeComboBox.setSelectedItem(((PhoneReg) regRex).getRegString()); |
|
|
|
dataTypeComboBox.setSelectedItem(((PhoneReg)regRex).getRegString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean checkEmbedded(String regstr) { |
|
|
|
private boolean checkEmbedded(String regstr){ |
|
|
|
return !ComparatorUtils.equals(EMB_REG1, regstr) && |
|
|
|
return !ComparatorUtils.equals(EMB_REG1, regstr) && |
|
|
|
!ComparatorUtils.equals(EMB_REG2, regstr) && |
|
|
|
!ComparatorUtils.equals(EMB_REG2, regstr) && |
|
|
|
!ComparatorUtils.equals(EMB_REG3, regstr); |
|
|
|
!ComparatorUtils.equals(EMB_REG3, regstr); |
|
|
@ -376,7 +392,7 @@ public class RegPane extends BasicPane { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public RegExp update() { |
|
|
|
public RegExp update() { |
|
|
|
PhoneReg regRex = new PhoneReg(); |
|
|
|
PhoneReg regRex = new PhoneReg(); |
|
|
|
regRex.setRegString((String) (dataTypeComboBox.getSelectedItem())); |
|
|
|
regRex.setRegString((String)(dataTypeComboBox.getSelectedItem())); |
|
|
|
return regRex; |
|
|
|
return regRex; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -385,22 +401,25 @@ public class RegPane extends BasicPane { |
|
|
|
private UISpinner minLenSpinner; |
|
|
|
private UISpinner minLenSpinner; |
|
|
|
private UISpinner maxLenSpinner; |
|
|
|
private UISpinner maxLenSpinner; |
|
|
|
|
|
|
|
|
|
|
|
public RegLengthPane() { |
|
|
|
public RegLengthPane(){ |
|
|
|
this.setLayout(new BorderLayout()); |
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
|
|
|
this.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 5)); |
|
|
|
|
|
|
|
this.setPreferredSize(new Dimension(210, 56)); |
|
|
|
minLenSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, 0); |
|
|
|
minLenSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, 0); |
|
|
|
maxLenSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, 0); |
|
|
|
maxLenSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, 0); |
|
|
|
double f = TableLayout.FILL; |
|
|
|
double f = TableLayout.FILL; |
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Reg_Min_Length")), minLenSpinner}, |
|
|
|
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Reg_Min_Length") + ":"), minLenSpinner }, |
|
|
|
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Reg_Max_Length")), maxLenSpinner}, |
|
|
|
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Reg_Max_Length") + ":"), maxLenSpinner}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
double[] rowSize = {p, p}; |
|
|
|
double[] rowSize = {p, p}; |
|
|
|
double[] columnSize = {p, f}; |
|
|
|
double[] columnSize = {p,f}; |
|
|
|
int[][] rowCount = {{1, 1}, {1, 1}}; |
|
|
|
int[][] rowCount = {{1, 1},{1, 1}}; |
|
|
|
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 8, 5); |
|
|
|
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_MEDIUM); |
|
|
|
|
|
|
|
this.add(panel); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.add(panel, BorderLayout.CENTER); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -410,20 +429,20 @@ public class RegPane extends BasicPane { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void populate(RegExp regRex) { |
|
|
|
public void populate(RegExp regRex) { |
|
|
|
if (!(regRex instanceof LengthReg)) { |
|
|
|
if (!(regRex instanceof LengthReg)){ |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int minLength = ((LengthReg) regRex).getMinLen(); |
|
|
|
int minLength = ((LengthReg)regRex).getMinLen(); |
|
|
|
int maxLength = ((LengthReg) regRex).getMaxLen(); |
|
|
|
int maxLength = ((LengthReg)regRex).getMaxLen(); |
|
|
|
minLenSpinner.setValue(minLength); |
|
|
|
minLenSpinner.setValue(minLength); |
|
|
|
maxLenSpinner.setValue(maxLength); |
|
|
|
maxLenSpinner.setValue(maxLength); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public RegExp update() { |
|
|
|
public RegExp update() { |
|
|
|
int startLength = ((Number) minLenSpinner.getValue()).intValue(); |
|
|
|
int startLength = ((Number)minLenSpinner.getValue()).intValue(); |
|
|
|
int endLength = ((Number) maxLenSpinner.getValue()).intValue(); |
|
|
|
int endLength = ((Number)maxLenSpinner.getValue()).intValue(); |
|
|
|
LengthReg regRex = new LengthReg(); |
|
|
|
LengthReg regRex = new LengthReg(); |
|
|
|
regRex.setMinLen(startLength); |
|
|
|
regRex.setMinLen(startLength); |
|
|
|
regRex.setMaxLen(endLength); |
|
|
|
regRex.setMaxLen(endLength); |
|
|
@ -432,22 +451,14 @@ public class RegPane extends BasicPane { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static class CustomRegRexPane extends DisplayPane { |
|
|
|
private static class CustomRegRexPane extends DisplayPane{ |
|
|
|
private UITextField regTextField; |
|
|
|
private UITextField regTextField; |
|
|
|
|
|
|
|
|
|
|
|
public CustomRegRexPane() { |
|
|
|
public CustomRegRexPane(){ |
|
|
|
this.setLayout(new BorderLayout()); |
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
regTextField = new UITextField(12); |
|
|
|
this.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 5)); |
|
|
|
|
|
|
|
regTextField = new UITextField(); |
|
|
|
double f = TableLayout.FILL; |
|
|
|
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{new UILabel(Inter.getLocText("FR-Designer_Reg_Expressions")), regTextField}}, TableLayoutHelper.FILL_LASTCOLUMN, 18, 7); |
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
|
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
|
|
|
|
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Reg_Expressions")), regTextField}, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
double[] rowSize = {p}; |
|
|
|
|
|
|
|
double[] columnSize = {p, f}; |
|
|
|
|
|
|
|
int[][] rowCount = {{1, 1}}; |
|
|
|
|
|
|
|
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 2, 1); |
|
|
|
|
|
|
|
this.add(panel); |
|
|
|
this.add(panel); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -458,7 +469,7 @@ public class RegPane extends BasicPane { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void populate(RegExp regRex) { |
|
|
|
public void populate(RegExp regRex) { |
|
|
|
if (!(regRex instanceof CustomReg)) { |
|
|
|
if (!(regRex instanceof CustomReg)){ |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
regTextField.setText(regRex.toRegText()); |
|
|
|
regTextField.setText(regRex.toRegText()); |
|
|
@ -474,26 +485,77 @@ public class RegPane extends BasicPane { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ListCellRenderer listCellRender = new UIComboBoxRenderer() { |
|
|
|
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 |
|
|
|
@Override |
|
|
|
public Component getListCellRendererComponent(JList list, Object value, |
|
|
|
public Component getListCellRendererComponent(JList list, Object value, |
|
|
|
int index, boolean isSelected, boolean cellHasFocus) { |
|
|
|
int index, boolean isSelected, boolean cellHasFocus) { |
|
|
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
|
|
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
|
|
|
if (value instanceof NoneReg) { |
|
|
|
if (value instanceof NoneReg){ |
|
|
|
this.setText(Inter.getLocText("FR-Designer_None")); |
|
|
|
this.setText(Inter.getLocText("FR-Designer_None")); |
|
|
|
} else if (value instanceof LengthReg) { |
|
|
|
} else if (value instanceof LengthReg){ |
|
|
|
this.setText(Inter.getLocText("FR-Designer_Length")); |
|
|
|
this.setText(Inter.getLocText("FR-Designer_Length")); |
|
|
|
} else if (value instanceof MailReg) { |
|
|
|
} else if (value instanceof MailReg){ |
|
|
|
this.setText(Inter.getLocText("FR-Designer_Email")); |
|
|
|
this.setText(Inter.getLocText("FR-Designer_Email")); |
|
|
|
} else if (value instanceof PhoneReg) { |
|
|
|
} else if (value instanceof PhoneReg){ |
|
|
|
this.setText(Inter.getLocText("FR-Designer_Phone")); |
|
|
|
this.setText(Inter.getLocText("FR-Designer_Phone")); |
|
|
|
} else if (value instanceof MobileReg) { |
|
|
|
} else if (value instanceof MobileReg) { |
|
|
|
this.setText(Inter.getLocText("FR-Designer_MobilePhone")); |
|
|
|
this.setText(Inter.getLocText("FR-Designer_MobilePhone")); |
|
|
|
} else if (value instanceof IDCardReg) { |
|
|
|
} else if (value instanceof IDCardReg){ |
|
|
|
this.setText(Inter.getLocText("FR-Designer_IDCard")); |
|
|
|
this.setText(Inter.getLocText("FR-Designer_IDCard")); |
|
|
|
} else if (value instanceof PostCardReg) { |
|
|
|
} else if (value instanceof PostCardReg){ |
|
|
|
this.setText(Inter.getLocText("FR-Designer_PostCode")); |
|
|
|
this.setText(Inter.getLocText("FR-Designer_PostCode")); |
|
|
|
} else if (value instanceof CustomReg) { |
|
|
|
} else if (value instanceof CustomReg){ |
|
|
|
this.setText(Inter.getLocText("FR-Designer_Custom")); |
|
|
|
this.setText(Inter.getLocText("FR-Designer_Custom")); |
|
|
|
} |
|
|
|
} |
|
|
|
return this; |
|
|
|
return this; |
|
|
|