package com.vci.client.omd.attribpool.ui;
|
|
import java.awt.BorderLayout;
|
import java.awt.Dimension;
|
import java.awt.GridBagConstraints;
|
import java.awt.GridBagLayout;
|
import java.awt.Insets;
|
import java.util.HashMap;
|
import javax.swing.BorderFactory;
|
import javax.swing.JCheckBox;
|
import javax.swing.JComboBox;
|
import javax.swing.JLabel;
|
import javax.swing.JPanel;
|
import javax.swing.JScrollPane;
|
|
import com.vci.client.common.datatype.VTBoolean;
|
import com.vci.corba.omd.atm.AttribItem;
|
|
public class VTBooleanPanel extends VTDataTypePanel{
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = -3163232240849784069L;
|
private JCheckBox cbNull;
|
private JComboBox combDefValue;
|
private HashMap<String, String> detailInfoMap = null;
|
|
public VTBooleanPanel(){
|
initUI();
|
addListener();
|
}
|
|
private void initUI(){
|
|
this.setLayout(new GridBagLayout());
|
JPanel leftPanel = new JPanel();
|
JPanel rightPanel = new JPanel();
|
|
GridBagConstraints gb = new GridBagConstraints();
|
gb.gridx = 0;
|
gb.gridy = 0;
|
gb.weightx = 1.0;
|
gb.weighty = 1.0;
|
gb.fill = GridBagConstraints.BOTH;
|
|
this.add(leftPanel, gb);
|
gb.gridx = 1;
|
this.add(rightPanel, gb);
|
leftPanel.setPreferredSize(new Dimension(this.getSize().width/2,
|
this.getSize().height));
|
rightPanel.setPreferredSize(new Dimension(this.getSize().width/2,
|
this.getSize().height));
|
|
//设置左边panel的控件
|
leftPanel.setBorder(BorderFactory.createTitledBorder("VTBoolean"));
|
leftPanel.setLayout(new BorderLayout());
|
JPanel leftPanel2 = new JPanel();
|
|
JScrollPane spLP1 = new JScrollPane();
|
spLP1.setBorder(null);
|
JScrollPane spLP2 = new JScrollPane();
|
spLP2.setBorder(null);
|
spLP2.setViewportView(leftPanel2);
|
|
leftPanel.add(spLP1, BorderLayout.NORTH);
|
leftPanel.add(spLP2, BorderLayout.CENTER);
|
|
cbNull = new JCheckBox("允许为空");
|
cbNull.setSelected(true);
|
// cbFixLen = new JCheckBox("定长");
|
// leftPanel1.add(cbFixLen);
|
|
leftPanel2.setLayout(new GridBagLayout());
|
GridBagConstraints g = new GridBagConstraints();
|
g.insets = new Insets(15, 10, 5, 10);
|
g.gridx = 0;
|
g.gridy = 0;
|
g.anchor = GridBagConstraints.WEST;//add by caill 2016.1.15将“默认值”一列左对齐
|
leftPanel2.add(cbNull,g); //add by caill 2016.1.15将“允许为空”放到“默认值”的上面
|
g.gridy = 1;
|
leftPanel2.add(new JLabel("默认值"), g);
|
combDefValue = new JComboBox();
|
combDefValue.addItem("false");
|
combDefValue.addItem("true");
|
combDefValue.setSelectedItem(String.valueOf(VTBoolean.defaultValue));
|
combDefValue.setPreferredSize(new Dimension(187, 20));
|
GridBagConstraints g1 = new GridBagConstraints();
|
g1.insets = new Insets(15, 10, 5, 10);
|
g1.gridx = 1;
|
g1.gridy = 1;
|
g1.gridwidth = GridBagConstraints.REMAINDER;
|
leftPanel2.add(combDefValue, g1);
|
|
//设置右边panel的控件
|
rightPanel.setBorder(BorderFactory.createTitledBorder("值域"));
|
rightPanel.setLayout(new GridBagLayout());
|
|
JPanel rightPanel1 = new JPanel();
|
JPanel rightPanel2 = new JPanel();
|
JPanel rightPanel3 = new JPanel();
|
|
GridBagConstraints gRight = new GridBagConstraints();
|
gRight.gridx = 0;
|
gRight.gridy = 0;
|
gRight.weightx = 1.0;
|
gRight.weighty = 1.0;
|
gRight.fill = GridBagConstraints.BOTH;
|
|
JScrollPane spRP1 = new JScrollPane();
|
spRP1.setBorder(null);
|
spRP1.setViewportView(rightPanel1);
|
JScrollPane spRP2 = new JScrollPane();
|
spRP2.setBorder(null);
|
spRP2.setViewportView(rightPanel2);
|
JScrollPane spRP3 = new JScrollPane();
|
spRP3.setBorder(null);
|
spRP3.setViewportView(rightPanel3);
|
|
rightPanel.add(spRP1, gRight);
|
gRight.gridy = 1;
|
rightPanel.add(spRP2, gRight);
|
gRight.gridy = 2;
|
rightPanel.add(spRP3, gRight);
|
|
rightPanel3.setLayout(new GridBagLayout());
|
}
|
|
public void addListener(){
|
}
|
|
/**
|
* 获取VTDataType的详细信息
|
* @return
|
*/
|
public HashMap<String, String> getDetailInfo(){
|
detailInfoMap = new HashMap<String, String>();
|
String otherValue = "";
|
|
detailInfoMap.put(VTDataTypePanel.DEFVALUE, (String)combDefValue.getSelectedItem());
|
if(cbNull.isSelected()){
|
otherValue += VTDataTypePanel.ALLOWNULL + " = yes;";
|
}else{
|
otherValue += VTDataTypePanel.ALLOWNULL + " = no;";
|
}
|
|
// if(cbFixLen.isSelected()){
|
// otherValue += VTDataTypePanel.ISFIXLEN + " = yes;";
|
// }else{
|
// otherValue += VTDataTypePanel.ISFIXLEN + " = no;";
|
// }
|
|
otherValue = otherValue.substring(0, otherValue.lastIndexOf(";"));
|
detailInfoMap.put(VTDataTypePanel.OTHER, otherValue);
|
|
return detailInfoMap;
|
}
|
|
/**
|
* 根据当前状态(查看,创建,修改), 设置相关组件的显示情况
|
* @param flag
|
*/
|
public void updataUIStatus(AttribItem abItem, int flag){
|
if(abItem != null){
|
combDefValue.setSelectedItem(abItem.defValue);
|
}
|
if(flag == 0){
|
cbNull.setEnabled(false);
|
// cbFixLen.setEnabled(false);
|
combDefValue.setEditable(false);
|
}
|
|
if(flag == 1 || flag == 2){
|
cbNull.setEnabled(true);
|
// cbFixLen.setEnabled(true);
|
combDefValue.setEditable(true);
|
|
}
|
|
}
|
}
|