package com.vci.client.portal.NewUI;
|
|
import java.awt.BorderLayout;
|
import java.awt.FlowLayout;
|
|
import javax.swing.JButton;
|
import javax.swing.JDialog;
|
import javax.swing.JPanel;
|
import javax.swing.border.EmptyBorder;
|
import java.awt.GridBagLayout;
|
import javax.swing.JLabel;
|
import java.awt.GridBagConstraints;
|
import javax.swing.JTextField;
|
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.JCheckBox;
|
import javax.swing.JScrollPane;
|
import javax.swing.JTextArea;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.portal.utility.UITools;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
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 JDialog {
|
|
private final JPanel contentPanel = new JPanel();
|
|
private JButton okButton;
|
private JButton cancelButton;
|
private JLabel label;
|
private JTextField plcode;
|
private JLabel label_1;
|
private JTextField plname;
|
private JLabel label_2;
|
private JTextField plseq;
|
private JCheckBox plisopen;
|
private JLabel label_3;
|
private JScrollPane scrollPane;
|
private JTextArea pldesc;
|
private PLUILayout plpagelayoutdefination;
|
private boolean editflag;
|
private PLTabPage pltabpage;
|
private JLabel lblNewLabel;
|
private JScrollPane scrollPane_1;
|
private JTextArea plOpenExpression;
|
private JLabel label_4;
|
private JScrollPane scrollPane_2;
|
private JTextArea plLabel;
|
private short areaType ;
|
private boolean closeFlag = false;
|
|
public boolean isCloseFlag() {
|
return closeFlag;
|
}
|
public void setCloseFlag(boolean closeFlag) {
|
this.closeFlag = closeFlag;
|
}
|
public TabDialog(PLUILayout plpagelayoutdefination,boolean editflag,PLTabPage ptp,short areaType) {
|
super(LogonApplication.frame,true);
|
setTitle("页迁窗口");
|
this.plpagelayoutdefination = plpagelayoutdefination;
|
this.editflag = editflag;
|
this.pltabpage = ptp;
|
this.areaType = areaType;
|
setBounds(100, 100, 450, 300);
|
if(!editflag){
|
init();
|
}
|
}
|
public JPanel 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, 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, 0.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 JTextField();
|
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 JTextField();
|
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 JTextField();
|
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 JTextArea();
|
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 JTextArea();
|
scrollPane_2.setViewportView(plLabel);
|
}
|
}
|
{
|
label_3 = new JLabel("描述");
|
GridBagConstraints gbc_label_3 = new GridBagConstraints();
|
gbc_label_3.insets = new Insets(0, 0, 5, 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.insets = new Insets(0, 0, 5, 0);
|
gbc_scrollPane.gridwidth = 3;
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
gbc_scrollPane.gridx = 2;
|
gbc_scrollPane.gridy = 4;
|
contentPanel.add(scrollPane, gbc_scrollPane);
|
{
|
pldesc = new JTextArea();
|
scrollPane.setViewportView(pldesc);
|
}
|
}
|
{
|
if(editflag){
|
okButton = new JButton("保存");
|
okButton.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
edit();
|
VCIOptionPane.showMessage(LogonApplication.frame, "保存成功!");
|
closeFlag = true;
|
}
|
});
|
GridBagConstraints gbc_button = new GridBagConstraints();
|
gbc_button.insets = new Insets(0, 0, 0, 5);
|
gbc_button.gridx = 2;
|
gbc_button.gridy = 5;
|
contentPanel.add(okButton, gbc_button);
|
}
|
}
|
{
|
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);
|
}
|
}
|
actionListener();
|
initData();
|
return contentPanel;
|
}
|
private void actionListener(){
|
okButton.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
if(checkEdit()){
|
return;
|
}
|
if(editflag){
|
edit();
|
}else{
|
save();
|
}
|
dispose();
|
}
|
});
|
cancelButton.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
dispose();
|
}
|
});
|
}
|
private void edit() {
|
PLTabPage plTabPage = new PLTabPage();
|
plTabPage.plOId = pltabpage.plOId;
|
setPlTabPageObj(plTabPage);
|
plTabPage.plCreateUser = pltabpage.plCreateUser;
|
plTabPage.plModifyUser = LogonApplication.getUserEntityObject().getUserName();
|
plTabPage.plAreaType = areaType;
|
try {
|
boolean flag = UITools.getService().updatePLTabPage(plTabPage);
|
closeFlag = flag;
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
|
private void save() {
|
PLTabPage plTabPage = new PLTabPage();
|
plTabPage.plOId = ObjectUtility.getNewObjectID36();
|
setPlTabPageObj(plTabPage);
|
plTabPage.plCreateUser = LogonApplication.getUserEntityObject().getUserName();
|
plTabPage.plModifyUser = LogonApplication.getUserEntityObject().getUserName();
|
plTabPage.plAreaType = areaType;
|
try {
|
boolean flag = UITools.getService().savePLTabPage(plTabPage);
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
|
private void setPlTabPageObj(PLTabPage plTabPage) {
|
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();
|
}
|
private void initData(){
|
if(pltabpage==null){
|
return;
|
}
|
|
plcode.setText(pltabpage.plCode);
|
plname.setText(pltabpage.plName);
|
plseq.setText(String.valueOf(pltabpage.plSeq));
|
if(pltabpage.plIsOpen==1){
|
plisopen.setSelected(true);
|
}
|
plLabel.setText(pltabpage.plLabel);
|
plOpenExpression.setText(pltabpage.plOpenExpression);
|
pldesc.setText(pltabpage.plDesc);
|
}
|
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() {
|
boolean flag = false;
|
if(plseq.getText().trim()==null||"".equals(plseq.getText().trim())){
|
VCIOptionPane.showMessage(LogonApplication.frame, "编号不能为空!");
|
flag =true;
|
}
|
if(!isNumber(plseq.getText().trim())){
|
VCIOptionPane.showMessage(LogonApplication.frame, "请填写数字!");
|
flag =true;
|
}
|
return flag;
|
}
|
}
|