package com.vci.client.portal.UI.v3.comptdesign;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.FlowLayout;
import java.awt.Frame;
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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.swing.ButtonGroup;
import javax.swing.DefaultListModel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import com.vci.client.portal.UI.ClickEventInfoPanel;
import com.vci.client.portal.UI.v3.comptdesign.compt.BaseComptPanel;
import com.vci.client.portal.UI.v3.comptdesign.compt.CustomComptPanel;
import com.vci.client.portal.UI.v3.comptdesign.compt.FormComptPanel;
import com.vci.client.portal.UI.v3.comptdesign.compt.SubUIComptPanel;
import com.vci.client.portal.UI.v3.comptdesign.compt.TableComptPanel;
import com.vci.client.portal.UI.v3.comptdesign.compt.TreeComptPanel;
import com.vci.client.portal.UI.v3.comptdesign.compt.TreeTableComptPanel;
import com.vci.client.portal.utility.PLDefination;
import com.vci.client.portal.utility.UITools;
import com.vci.client.ui.swing.VCISwingUtil;
import com.vci.client.ui.swing.components.VCIJButton;
import com.vci.client.ui.swing.components.VCIJDialog;
import com.vci.client.ui.swing.components.VCIJIntegerTextField;
import com.vci.client.ui.swing.components.VCIJLabel;
import com.vci.client.ui.swing.components.VCIJOptionPane;
import com.vci.client.ui.swing.components.VCIJPanel;
import com.vci.client.ui.swing.components.VCIJRadioButton;
import com.vci.client.ui.swing.components.VCIJScrollPane;
import com.vci.client.ui.swing.components.VCIJTextArea;
import com.vci.client.ui.swing.components.VCIJTextField;
import com.vci.common.portal.enums.ComponentType;
import com.vci.common.utility.ObjectUtility;
import com.vci.corba.common.VCIError;
import com.vci.corba.portal.data.PLPageDefination;
import com.vci.corba.portal.data.PLTabPage;
public class UIComptDesignDialog extends VCIJDialog {
/**
*
*/
private static final long serialVersionUID = -1149485725224247322L;
private String title = "页面设计窗口";
private int width = 750;
private int height = 700;
private Component relativeToCompt = null;
private PLTabPage tabPage = null;
private PLPageDefination pageDefination = null;
private VCIJLabel lblName = new VCIJLabel("名称");
private VCIJTextField txtName = new VCIJTextField(true);
private VCIJLabel lblSeq = new VCIJLabel("编号");
private VCIJIntegerTextField txtSeq = new VCIJIntegerTextField("");
private VCIJLabel lblDesc = new VCIJLabel("描述");
private VCIJTextArea txtDesc = new VCIJTextArea(false);
private VCIJLabel lblUIParser = new VCIJLabel("UI解析类型");
private VCIJTextArea txtUIParser = new VCIJTextArea(false);
private final String lblUIParserNoteContent = "" +
"" +
"
示例:java_cs:xxx;java_bs:xxx;net_cs:xxx;net_bs:xxx;mobile_cs:xx;mobile_bs:xxx;
" +
"1、用英文半角分号;分隔各组值;(这里结尾的是中文字符的分号)
" +
"2、每组用英文半角冒号:分隔单一扩展属性名称及属性值;
" +
"3、其中的xxx是各种解析类的完整类型名称(完全限定名);
" +
"4、输入时,不要敲回车换行;
" +
"
" +
"";
private VCIJLabel lblExtAttrs = new VCIJLabel("扩展属性");
private VCIJTextArea txtExtAttrs = new VCIJTextArea(false);
private final String lblExtAttrNoteContent = "" +
"" +
"示例:ext1:xx;ext2;ext3:xx;ext4:xxx;extn:xxx;
" +
"1、用英文半角分号;分隔各组值;
" +
"2、每组用英文半角冒号:分隔单一扩展属性名称及属性值;
" +
"3、可以定义任意组,但总字符长度不得超过4000;
" +
"4、输入时,不要敲回车换行;
" +
"
" +
"";
private VCIJLabel lblComptType = new VCIJLabel("模板类型");
private ButtonGroup rbtnComptTypeGroup = new ButtonGroup();
private VCIJRadioButton rbtnComptTypeTable = new VCIJRadioButton("Table(表格)");
private VCIJRadioButton rbtnComptTypeCustom= new VCIJRadioButton("Custom(自定义模板)");
private VCIJRadioButton rbtnComptTypeTreeTable = new VCIJRadioButton("TreeTable(树表)");
private VCIJRadioButton rbtnComptTypeForm = new VCIJRadioButton("Form(表单)");
private VCIJRadioButton rbtnComptTypeTree = new VCIJRadioButton("Tree(树)");
private VCIJRadioButton rbtnComptTypeUI = new VCIJRadioButton("UILayout(UI定义)");
private VCIJLabel lblShowType = new VCIJLabel("显示类型");
private ButtonGroup rbtnShowTypeGroup = new ButtonGroup();
private VCIJRadioButton rbtnShowTypeNotShow = new VCIJRadioButton("不显示");
private VCIJRadioButton rbtnShowTypeShowRole= new VCIJRadioButton("显示角色");
private VCIJRadioButton rbtnShowTypeShowFolder = new VCIJRadioButton("显示Folder");
private VCIJPanel dynamicContentPanel = new VCIJPanel(new BorderLayout());
// 表格 组件
private TableComptPanel tableComptPanel = null;
// 自定义 组件
private CustomComptPanel customComptPanel = null;
// TreeTable 组件
private TreeTableComptPanel treeTableComptPanel = null;
// 表单 组件
private FormComptPanel formComptPanel = null;
// Tree 组件
private TreeComptPanel treeComptPanel = null;
// 子UI 组件
private SubUIComptPanel subUIComptPanel = null;
// 组件类型对应的组件实例Map
private Map uiComptPanelMap = new HashMap();
// 组件类型对应的rbtnMap
private Map comptTypeToRbtnMap = new HashMap();
private ClickEventInfoPanel eventInfoPanel = null;
private VCIJButton btnOk = VCISwingUtil.createVCIJButton("ok", "确定", "确定", "accept.png", new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
btnOk_actionPerformed(e);
}
});
private VCIJButton btnCancel = VCISwingUtil.createVCIJButton("cancel", "取消", "取消", "cancel.png", new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
btnCancel_actionPerformed(e);
}
});
public UIComptDesignDialog(Dialog ownerDialg, boolean modal){
super(ownerDialg, modal);
}
public UIComptDesignDialog(Frame ownerFrame, boolean modal){
super(ownerFrame, modal);
}
public void buildDialog(){
init();
initDataToUI();
}
private void init(){
setLayout(new BorderLayout());
getContentPane().setLayout(new BorderLayout());
initComptTypeToRbtnMap();
add(getNorthNormalInfoPanel(), BorderLayout.NORTH);
add(getCenterDynamicContentPanel(), BorderLayout.CENTER);
add(getSouthButtonPanel(), BorderLayout.SOUTH);
rbtnComptTypeTable.setSelected(true);
rbtnComptTypeTable.doClick();
setLocationAndSize();
}
private void initComptTypeToRbtnMap(){
comptTypeToRbtnMap.put(ComponentType.Table, rbtnComptTypeTable);
comptTypeToRbtnMap.put(ComponentType.Custom, rbtnComptTypeCustom);
comptTypeToRbtnMap.put(ComponentType.TreeTable, rbtnComptTypeTreeTable);
comptTypeToRbtnMap.put(ComponentType.Form, rbtnComptTypeForm);
comptTypeToRbtnMap.put(ComponentType.Tree, rbtnComptTypeTree);
comptTypeToRbtnMap.put(ComponentType.UILayout, rbtnComptTypeUI);
}
private void initDataToUI(){
if(getPageDefination() == null) return;
PLPageDefination pd = getPageDefination();
PLDefination d = null;
try {
d = UITools.getPLDefination(pd.plDefination);
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
txtName.setText(pd.name);
txtSeq.setText(String.valueOf(pd.seq));
txtDesc.setText(pd.desc);
if(d != null){
txtUIParser.setText(d.getUiParser());
txtExtAttrs.setText(d.getExtAttr());
if ("1".equals(d.getNavigatorType())) {
rbtnShowTypeNotShow.setSelected(true);
rbtnShowTypeNotShow.doClick();
} else if("2".equals(d.getNavigatorType())){
rbtnShowTypeShowRole.setSelected(true);
rbtnShowTypeShowRole.doClick();
} else if("3".equals(d.getNavigatorType())){
rbtnShowTypeShowFolder.setSelected(true);
rbtnShowTypeShowFolder.doClick();
}
}
ComponentType comptType = ComponentType.getByVal(Integer.valueOf(d.getTemplateType()));
if(comptTypeToRbtnMap.containsKey(comptType)){
VCIJRadioButton rbtn = comptTypeToRbtnMap.get(comptType);
rbtn.setSelected(true);
rbtn.doClick();
}
initEventData(d);
}
private void initEventData(PLDefination d){
String eventKey = d.getEventKey();
String[] eventKeySplit = eventKey.split(",");
String eventValue = d.getEventValue();
String[] eventValueSplit = eventValue.split(",");
String listValue = "";
for(int i=0;i keyList = new ArrayList();
Map keyMap = new HashMap();
for(int i=0;i es : keyMap.entrySet()){
String key = es.getKey();
String value = es.getValue();
eventKey += key+",";
eventValue += value+",";
}
if(eventKey!=null&&!"".equals(eventKey)){
d.setEventKey(eventKey.substring(0,eventKey.length()-1));
d.setEventValue(eventValue.substring(0,eventValue.length()-1));
}else{
d.setEventKey("");
d.setEventValue("");
}
return d;
}
private void fetchEventValue(DefaultListModel listModel, int size,
List keyList,Map keyMap) {
for(int j=0;j