forked from fanruan/design
Browse Source
* commit 'd0c317b32aac38f9d9392e5eeb5225adbe5af64d': 代码修改 REPORT-3735 [9.0一轮回归]文本控件中错误提示自动变为正则表达式内容master
superman
7 years ago
8 changed files with 141 additions and 114 deletions
@ -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()); |
||||
} |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue