package com.vci.client.portal.UI;
|
|
import java.awt.BorderLayout;
|
import java.awt.FlowLayout;
|
import java.awt.GridBagConstraints;
|
import java.awt.GridBagLayout;
|
import java.awt.Insets;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.util.regex.Matcher;
|
import java.util.regex.Pattern;
|
|
import javax.swing.JButton;
|
import javax.swing.JCheckBox;
|
import javax.swing.JLabel;
|
import javax.swing.JOptionPane;
|
import javax.swing.JPanel;
|
import javax.swing.JScrollPane;
|
import javax.swing.JTextArea;
|
import javax.swing.border.EmptyBorder;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.portal.utility.UITools;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
import com.vci.client.ui.swing.components.VCIJDialog;
|
import com.vci.client.ui.swing.components.VCIJIntegerTextField;
|
import com.vci.client.ui.swing.components.VCIJOptionPane;
|
import com.vci.client.ui.swing.components.VCIJTextArea;
|
import com.vci.client.ui.swing.components.VCIJTextField;
|
import com.vci.common.utility.ObjectUtility;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.portal.data.PLUILayout;
|
import com.vci.corba.portal.data.PLTabPage;
|
|
/**
|
* 页签定义窗口
|
*
|
*/
|
public class TabDialog extends VCIJDialog {
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = -3571272652368874388L;
|
|
private final JPanel contentPanel = new JPanel();
|
|
private JButton okButton;
|
private JButton cancelButton;
|
private JLabel label;
|
private VCIJTextField plcode;
|
private JLabel label_1;
|
private VCIJTextField plname;
|
private JLabel label_2;
|
private VCIJIntegerTextField plseq;
|
private JCheckBox plisopen;
|
private JLabel label_3;
|
private JScrollPane scrollPane;
|
private VCIJTextArea pldesc;
|
|
private JLabel lblParser;
|
private JTextArea txtUIParser;
|
private JLabel lblUIParserNote;
|
private final String lblUIParserNoteContent = "" +
|
"<html>" +
|
"<p color='red'>示例:java_cs:xxx;java_bs:xxx;net_cs:xxx;net_bs:xxx;mobile_cs:xx;mobile_bs:xxx;</p>" +
|
"<p color='blue'>1、用英文半角分号;分隔各组值;(这里结尾的是中文字符的分号)</p>" +
|
"<p color='blue'>2、每组用英文半角冒号:分隔单一扩展属性名称及属性值;</p>" +
|
"<p color='blue'>3、其中的xxx是各种解析类的完整类型名称(完全限定名);</p>" +
|
"<p color='blue'>4、输入时,不要敲回车换行;</p>" +
|
"<p><br/></p>" +
|
"</html>";
|
|
private JLabel lblExtAttrs;
|
private VCIJTextArea txtExtAtt;
|
private JLabel lblExtAttrNote;
|
private final String lblExtAttrNoteContent = "" +
|
"<html>" +
|
"<p color='red'>示例:ext1:xx;ext2;ext3:xx;ext4:xxx;extn:xxx;</p>" +
|
"<p color='blue'>1、用英文半角分号;分隔各组值;</p>" +
|
"<p color='blue'>2、每组用英文半角冒号:分隔单一扩展属性名称及属性值;</p>" +
|
"<p color='blue'>3、可以定义任意组,但总字符长度不得超过4000;</p>" +
|
"<p color='blue'>4、输入时,不要敲回车换行;</p>" +
|
"<p><br/></p>" +
|
"</html>";
|
|
private final PLUILayout plpagelayoutdefination;
|
private final boolean editflag;
|
private final PLTabPage editPLTabPage;
|
private JLabel lblNewLabel;
|
private JScrollPane scrollPane_1;
|
private VCIJTextArea plOpenExpression;
|
private JLabel label_4;
|
private JScrollPane scrollPane_2;
|
private VCIJTextArea plLabel;
|
private final short areaType ;
|
public TabDialog(PLUILayout plpagelayoutdefination,boolean editflag,PLTabPage ptp, short areaType) {
|
super(LogonApplication.frame,true);
|
setTitle("页签窗口");
|
this.plpagelayoutdefination = plpagelayoutdefination;
|
this.editflag = editflag;
|
this.editPLTabPage = ptp;
|
this.areaType = areaType;
|
setBounds(100, 100, 750, 600);
|
init();
|
actionListener();
|
initData();
|
this.setLocationRelativeTo(null);
|
this.setVisible(true);
|
}
|
private void init() {
|
getContentPane().setLayout(new BorderLayout());
|
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
GridBagLayout gbl_contentPanel = new GridBagLayout();
|
gbl_contentPanel.columnWidths = new int[]{0, 92, 0, 0, 0, 0};
|
gbl_contentPanel.rowHeights = new int[]{0, 0, 0, 0, 0, 0};
|
gbl_contentPanel.columnWeights = new double[]{0.0, 0.0, 1.0, 0.0, 1.0, Double.MIN_VALUE};
|
gbl_contentPanel.rowWeights = new double[]{0.0, 0.0, 1.0, 1.0, 1.0, Double.MIN_VALUE};
|
contentPanel.setLayout(gbl_contentPanel);
|
{
|
label = new JLabel("页面编码");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.insets = new Insets(0, 0, 5, 5);
|
gbc_label.gridx = 1;
|
gbc_label.gridy = 0;
|
contentPanel.add(label, gbc_label);
|
}
|
{
|
plcode = new VCIJTextField(true);
|
GridBagConstraints gbc_textField = new GridBagConstraints();
|
gbc_textField.insets = new Insets(0, 0, 5, 5);
|
gbc_textField.fill = GridBagConstraints.HORIZONTAL;
|
gbc_textField.gridx = 2;
|
gbc_textField.gridy = 0;
|
contentPanel.add(plcode, gbc_textField);
|
plcode.setColumns(10);
|
}
|
{
|
label_1 = new JLabel("名称");
|
GridBagConstraints gbc_label_1 = new GridBagConstraints();
|
gbc_label_1.anchor = GridBagConstraints.EAST;
|
gbc_label_1.insets = new Insets(0, 0, 5, 5);
|
gbc_label_1.gridx = 3;
|
gbc_label_1.gridy = 0;
|
contentPanel.add(label_1, gbc_label_1);
|
}
|
{
|
plname = new VCIJTextField(true);
|
GridBagConstraints gbc_textField_1 = new GridBagConstraints();
|
gbc_textField_1.insets = new Insets(0, 0, 5, 0);
|
gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
|
gbc_textField_1.gridx = 4;
|
gbc_textField_1.gridy = 0;
|
contentPanel.add(plname, gbc_textField_1);
|
plname.setColumns(10);
|
}
|
{
|
label_2 = new JLabel("序号");
|
GridBagConstraints gbc_label_2 = new GridBagConstraints();
|
gbc_label_2.insets = new Insets(0, 0, 5, 5);
|
gbc_label_2.gridx = 1;
|
gbc_label_2.gridy = 1;
|
contentPanel.add(label_2, gbc_label_2);
|
}
|
{
|
plseq = new VCIJIntegerTextField("");
|
plseq.setRequired(true);
|
GridBagConstraints gbc_textField_2 = new GridBagConstraints();
|
gbc_textField_2.insets = new Insets(0, 0, 5, 5);
|
gbc_textField_2.fill = GridBagConstraints.HORIZONTAL;
|
gbc_textField_2.gridx = 2;
|
gbc_textField_2.gridy = 1;
|
contentPanel.add(plseq, gbc_textField_2);
|
plseq.setColumns(10);
|
}
|
{
|
plisopen = new JCheckBox("启用");
|
GridBagConstraints gbc_checkBox = new GridBagConstraints();
|
gbc_checkBox.insets = new Insets(0, 0, 5, 0);
|
gbc_checkBox.gridx = 4;
|
gbc_checkBox.gridy = 1;
|
contentPanel.add(plisopen, gbc_checkBox);
|
}
|
{
|
lblNewLabel = new JLabel("显示表达式");
|
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
|
gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
|
gbc_lblNewLabel.gridx = 1;
|
gbc_lblNewLabel.gridy = 2;
|
contentPanel.add(lblNewLabel, gbc_lblNewLabel);
|
}
|
{
|
scrollPane_1 = new JScrollPane();
|
GridBagConstraints gbc_scrollPane_1 = new GridBagConstraints();
|
gbc_scrollPane_1.gridwidth = 3;
|
gbc_scrollPane_1.insets = new Insets(0, 0, 5, 0);
|
gbc_scrollPane_1.fill = GridBagConstraints.BOTH;
|
gbc_scrollPane_1.gridx = 2;
|
gbc_scrollPane_1.gridy = 2;
|
contentPanel.add(scrollPane_1, gbc_scrollPane_1);
|
{
|
plOpenExpression = new VCIJTextArea();
|
plOpenExpression.setRows(3);
|
plOpenExpression.setWrapStyleWord(true);
|
plOpenExpression.setLineWrap(true);
|
scrollPane_1.setViewportView(plOpenExpression);
|
}
|
}
|
{
|
label_4 = new JLabel("国际化标准");
|
GridBagConstraints gbc_label_4 = new GridBagConstraints();
|
gbc_label_4.insets = new Insets(0, 0, 5, 5);
|
gbc_label_4.gridx = 1;
|
gbc_label_4.gridy = 3;
|
contentPanel.add(label_4, gbc_label_4);
|
}
|
{
|
scrollPane_2 = new JScrollPane();
|
GridBagConstraints gbc_scrollPane_2 = new GridBagConstraints();
|
gbc_scrollPane_2.gridwidth = 3;
|
gbc_scrollPane_2.insets = new Insets(0, 0, 5, 0);
|
gbc_scrollPane_2.fill = GridBagConstraints.BOTH;
|
gbc_scrollPane_2.gridx = 2;
|
gbc_scrollPane_2.gridy = 3;
|
contentPanel.add(scrollPane_2, gbc_scrollPane_2);
|
{
|
plLabel = new VCIJTextArea();
|
plLabel.setRows(3);
|
plLabel.setWrapStyleWord(true);
|
plLabel.setLineWrap(true);
|
scrollPane_2.setViewportView(plLabel);
|
}
|
}
|
{
|
label_3 = new JLabel("描述");
|
GridBagConstraints gbc_label_3 = new GridBagConstraints();
|
gbc_label_3.insets = new Insets(0, 0, 0, 5);
|
gbc_label_3.gridx = 1;
|
gbc_label_3.gridy = 4;
|
contentPanel.add(label_3, gbc_label_3);
|
}
|
{
|
scrollPane = new JScrollPane();
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
gbc_scrollPane.gridwidth = 3;
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
gbc_scrollPane.gridx = 2;
|
gbc_scrollPane.gridy = 4;
|
contentPanel.add(scrollPane, gbc_scrollPane);
|
{
|
pldesc = new VCIJTextArea();
|
pldesc.setRows(3);
|
pldesc.setWrapStyleWord(true);
|
pldesc.setLineWrap(true);
|
scrollPane.setViewportView(pldesc);
|
}
|
}
|
|
{
|
lblParser = new JLabel("UI解析类");
|
GridBagConstraints gbc_label_3 = new GridBagConstraints();
|
gbc_label_3.insets = new Insets(0, 0, 0, 5);
|
gbc_label_3.gridx = 1;
|
gbc_label_3.gridy = 5;
|
contentPanel.add(lblParser, gbc_label_3);
|
}
|
{
|
scrollPane = new JScrollPane();
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
gbc_scrollPane.gridwidth = 3;
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
gbc_scrollPane.gridx = 2;
|
gbc_scrollPane.gridy = 5;
|
contentPanel.add(scrollPane, gbc_scrollPane);
|
{
|
txtUIParser = new JTextArea();
|
txtUIParser.setRows(3);
|
txtUIParser.setWrapStyleWord(true);
|
txtUIParser.setLineWrap(true);
|
scrollPane.setViewportView(txtUIParser);
|
}
|
}
|
{
|
lblUIParserNote = new JLabel(lblUIParserNoteContent);
|
GridBagConstraints gbc_label_3 = new GridBagConstraints();
|
gbc_label_3.insets = new Insets(0, 0, 0, 5);
|
gbc_label_3.fill = GridBagConstraints.HORIZONTAL;
|
gbc_label_3.gridwidth = 3;
|
gbc_label_3.gridx = 2;
|
gbc_label_3.gridy = 6;
|
contentPanel.add(lblUIParserNote, gbc_label_3);
|
}
|
|
{
|
lblExtAttrs = new JLabel("扩展属性");
|
GridBagConstraints gbc_label_3 = new GridBagConstraints();
|
gbc_label_3.insets = new Insets(0, 0, 0, 5);
|
gbc_label_3.gridx = 1;
|
gbc_label_3.gridy = 7;
|
contentPanel.add(lblExtAttrs, gbc_label_3);
|
}
|
{
|
scrollPane = new JScrollPane();
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
gbc_scrollPane.gridwidth = 3;
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
gbc_scrollPane.gridx = 2;
|
gbc_scrollPane.gridy = 7;
|
contentPanel.add(scrollPane, gbc_scrollPane);
|
{
|
txtExtAtt = new VCIJTextArea();
|
txtExtAtt.setRows(3);
|
txtExtAtt.setWrapStyleWord(true);
|
txtExtAtt.setLineWrap(true);
|
scrollPane.setViewportView(txtExtAtt);
|
}
|
}
|
|
{
|
lblExtAttrNote = new JLabel(lblExtAttrNoteContent);
|
GridBagConstraints gbc_label_3 = new GridBagConstraints();
|
gbc_label_3.insets = new Insets(0, 0, 0, 5);
|
gbc_label_3.fill = GridBagConstraints.HORIZONTAL;
|
gbc_label_3.gridwidth = 3;
|
gbc_label_3.gridx = 2;
|
gbc_label_3.gridy = 8;
|
contentPanel.add(lblExtAttrNote, gbc_label_3);
|
}
|
|
{
|
JPanel buttonPane = new JPanel();
|
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
{
|
okButton = new JButton("保存");
|
buttonPane.add(okButton);
|
}
|
{
|
cancelButton = new JButton("关闭");
|
buttonPane.add(cancelButton);
|
}
|
}
|
}
|
private void actionListener(){
|
okButton.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
PLTabPage plTabPage = new PLTabPage();
|
setPlTabPageObj(plTabPage);
|
plTabPage.plCreateUser = LogonApplication.getUserEntityObject().getUserName();
|
plTabPage.plModifyUser = LogonApplication.getUserEntityObject().getUserName();
|
plTabPage.plAreaType = areaType;
|
|
if(checkEdit(plTabPage)){
|
return;
|
}
|
save(plTabPage, editflag);
|
}
|
|
private void save(PLTabPage plTabPage, boolean editFlag) {
|
DialogResult res = DialogResult.CANCEL;
|
try {
|
boolean saveFlag = false;
|
if(editFlag){
|
saveFlag = UITools.getService().updatePLTabPage(plTabPage);
|
} else {
|
saveFlag = UITools.getService().savePLTabPage(plTabPage);
|
}
|
if(saveFlag){
|
res = DialogResult.OK;
|
VCIOptionPane.showMessage(TabDialog.this, "保存成功!");
|
} else {
|
res = DialogResult.CANCEL;
|
VCIOptionPane.showMessage(TabDialog.this, "保存失败!");
|
}
|
close(res);
|
} catch (VCIError e) {
|
e.printStackTrace();
|
VCIOptionPane.showMessage(TabDialog.this, "保存的过程发生错误!\n" + e.getMessage() + "");
|
}
|
}
|
private void close(DialogResult res){
|
setDialogResult(res);
|
setVisible(false);
|
dispose();
|
}
|
private void setPlTabPageObj(PLTabPage plTabPage) {
|
if(editflag){
|
plTabPage.plOId = editPLTabPage.plOId;
|
} else {
|
plTabPage.plOId = ObjectUtility.getNewObjectID36();
|
}
|
plTabPage.plCode = plcode.getText().trim();
|
plTabPage.plName = plname.getText().trim();
|
if(plisopen.isSelected()){
|
plTabPage.plIsOpen = 1;
|
}else{
|
plTabPage.plIsOpen = 0;
|
}
|
plTabPage.plName = plname.getText().trim();
|
plTabPage.plDesc = pldesc.getText();
|
plTabPage.plSeq = Short.valueOf(plseq.getText());
|
plTabPage.plContextOId = plpagelayoutdefination.plOId;
|
plTabPage.plLabel = plLabel.getText();
|
plTabPage.plOpenExpression = plOpenExpression.getText();
|
plTabPage.plUIParser = txtUIParser.getText().trim().replace(" ", "");// 移除空格
|
plTabPage.plExtAttr = txtExtAtt.getText().trim().replace(" ", "");// 移除空格
|
}
|
});
|
cancelButton.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
dispose();
|
}
|
});
|
}
|
|
private void initData(){
|
if(editPLTabPage==null){
|
return;
|
}
|
|
plcode.setText(editPLTabPage.plCode);
|
plname.setText(editPLTabPage.plName);
|
plseq.setText(String.valueOf(editPLTabPage.plSeq));
|
if(editPLTabPage.plIsOpen==1){
|
plisopen.setSelected(true);
|
}
|
plLabel.setText(editPLTabPage.plLabel);
|
plOpenExpression.setText(editPLTabPage.plOpenExpression);
|
pldesc.setText(editPLTabPage.plDesc);
|
txtUIParser.setText(editPLTabPage.plUIParser);
|
txtExtAtt.setText(editPLTabPage.plExtAttr);
|
}
|
private boolean isNumber(String str) {
|
Pattern pa = Pattern.compile("[0-9]*");
|
Matcher mt = pa.matcher(str);
|
if(mt.matches()==false){
|
return false;
|
}else{
|
return true;
|
}
|
}
|
private boolean checkEdit(PLTabPage plTabPage) {
|
boolean flag = false;
|
if(plseq.getText().trim()==null||"".equals(plseq.getText().trim())){
|
VCIOptionPane.showMessage(LogonApplication.frame, "序号不能为空!");
|
flag =true;
|
}
|
else if(!isNumber(plseq.getText().trim())){
|
VCIOptionPane.showMessage(LogonApplication.frame, "序号只能是数字,请重新填写!");
|
flag =true;
|
}
|
else if(!checkTabPageUIParserIsOk(plTabPage)){
|
VCIOptionPane.showMessage(LogonApplication.frame, "UI解析类格式不正确,请重新填写!");
|
flag = true;
|
}
|
else if(!checkTabPageExtAttrIsOk(plTabPage)){
|
//给出提示,对于mpm配置可以允许其保存,具体解析mpm自己控制 by liucq
|
int confirm = VCIOptionPane.showConfirmDialog(LogonApplication.frame, "扩展属性数据格式不正确\n是否继续保存?", "系统提示", JOptionPane.YES_NO_OPTION);
|
if(confirm == JOptionPane.NO_OPTION){
|
flag = true;
|
}
|
// VCIOptionPane.showMessage(LogonApplication.frame, "扩展属性数据格式不正确,请重新填写!");
|
// flag = true;
|
}
|
|
try {
|
PLTabPage[] tps = UITools.getService().getTabPagesByContextIdAndType(plpagelayoutdefination.plOId, this.areaType);
|
boolean seqExist = false;
|
boolean nameExist = false;
|
boolean codeExist = false;
|
for (PLTabPage tp : tps) {
|
if(tp.plSeq == plTabPage.plSeq && !tp.plOId.equals(plTabPage.plOId)){
|
seqExist = true;
|
break;
|
}
|
if(tp.plName.equalsIgnoreCase(plTabPage.plName) && !tp.plOId.equals(plTabPage.plOId)){
|
nameExist = true;
|
break;
|
}
|
if(tp.plCode.equalsIgnoreCase(plTabPage.plCode) && !tp.plOId.equals(plTabPage.plOId)){
|
codeExist = true;
|
break;
|
}
|
}
|
if(seqExist){
|
VCIJOptionPane.showMessage(this, "序号重复!");
|
flag = true;
|
} else if(nameExist){
|
VCIJOptionPane.showMessage(this, "名称重复!");
|
flag = true;
|
} else if(codeExist){
|
VCIJOptionPane.showMessage(this, "页面编码重复!");
|
flag = true;
|
} else {
|
flag = false;
|
}
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
|
return flag;
|
}
|
|
private boolean checkTabPageUIParserIsOk(PLTabPage tabPage){
|
// 数据格式: java_cs:xxx;java_bs:xxx;net_cs:xxx;net_bs:xxx;mobile_cs:xx;mobile_bs:xxx;
|
String uiParser = tabPage.plUIParser;
|
return checkExtValIsOk(uiParser);
|
}
|
private boolean checkTabPageExtAttrIsOk(PLTabPage tabPage){
|
// 数据格式:ext1:xx;ext2;ext3:xx;ext4:xxx;extn:xxx;
|
String extAttr = tabPage.plExtAttr;
|
return checkExtValIsOk(extAttr);
|
}
|
private boolean checkExtValIsOk(String value){
|
boolean res = true;
|
if(value == null || "".equals(value)){
|
return res;
|
}
|
Pattern ptn = Pattern.compile("([\\w\\.\\_\\-\\+]+:[\\w\\.\\_\\-\\+]+(;)?)+");
|
res = ptn.matcher(value).matches();
|
return res;
|
}
|
}
|