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 = "" +
|
"<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 VCIJLabel lblExtAttrs = new VCIJLabel("扩展属性");
|
private VCIJTextArea txtExtAttrs = new VCIJTextArea(false);
|
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 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<ComponentType, BaseComptPanel> uiComptPanelMap = new HashMap<ComponentType, BaseComptPanel>();
|
// 组件类型对应的rbtnMap
|
private Map<ComponentType, VCIJRadioButton> comptTypeToRbtnMap = new HashMap<ComponentType, VCIJRadioButton>();
|
|
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<eventKeySplit.length;i++){
|
String[] eventValueSplits = eventValueSplit[i].split(";");
|
for(int j=0;j<eventValueSplits.length;j++){
|
if(!"".equals(eventKeySplit[i])){
|
listValue = eventKeySplit[i] + ":" + eventValueSplits[j];
|
eventInfoPanel.getListModel().addElement(listValue);
|
}
|
}
|
}
|
}
|
|
private VCIJPanel getNorthNormalInfoPanel(){
|
VCIJPanel pal = new VCIJPanel();
|
pal.setBorder(new EmptyBorder(5, 5, 5, 5));
|
GridBagLayout gbl_contentPanel = new GridBagLayout();
|
pal.setLayout(gbl_contentPanel);
|
|
GridBagConstraints gbc_label_9 = new GridBagConstraints();
|
gbc_label_9.insets = new Insets(0, 0, 0, 0);
|
gbc_label_9.gridx = 1;
|
gbc_label_9.gridy = 0;
|
pal.add(lblName, gbc_label_9);
|
|
txtName = new VCIJTextField(true);
|
GridBagConstraints gbc_nameTxt = new GridBagConstraints();
|
gbc_nameTxt.insets = new Insets(0, 0, 0, 0);
|
gbc_nameTxt.fill = GridBagConstraints.BOTH;
|
gbc_nameTxt.gridx = 2;
|
gbc_nameTxt.gridy = 0;
|
pal.add(txtName, gbc_nameTxt);
|
|
GridBagConstraints gbc_label_11 = new GridBagConstraints();
|
gbc_label_11.insets = new Insets(1, 0, 0, 0);
|
gbc_label_11.gridx = 1;
|
gbc_label_11.gridy = 1;
|
pal.add(lblSeq, gbc_label_11);
|
|
txtSeq = new VCIJIntegerTextField("");
|
txtSeq.setRequired(true);
|
GridBagConstraints gbc_seqTxt = new GridBagConstraints();
|
gbc_seqTxt.insets = new Insets(1, 0, 0, 0);
|
gbc_seqTxt.fill = GridBagConstraints.BOTH;
|
gbc_seqTxt.gridx = 2;
|
gbc_seqTxt.gridy = 1;
|
gbc_seqTxt.weightx = 1.0;
|
pal.add(txtSeq, gbc_seqTxt);
|
|
GridBagConstraints gbc_label_10 = new GridBagConstraints();
|
gbc_label_10.insets = new Insets(0, 0, 0, 0);
|
gbc_label_10.gridx = 3;
|
gbc_label_10.gridy = 0;
|
pal.add(lblDesc, gbc_label_10);
|
|
VCIJScrollPane scrollPane = new VCIJScrollPane();
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
gbc_scrollPane.gridheight = 2;
|
gbc_scrollPane.insets = new Insets(0, 0, 0, 0);
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
gbc_scrollPane.gridx = 4;
|
gbc_scrollPane.gridy = 0;
|
gbc_scrollPane.weightx = 1.0;
|
pal.add(scrollPane, gbc_scrollPane);
|
|
txtDesc = new VCIJTextArea();
|
txtDesc.setRows(2);
|
txtDesc.setWrapStyleWord(true);
|
txtDesc.setLineWrap(true);
|
scrollPane.setViewportView(txtDesc);
|
|
|
/************************ UI解析类、扩展属性定义 ****************************/
|
{
|
gbc_scrollPane = new GridBagConstraints();
|
gbc_scrollPane.insets = new Insets(1, 0, 0, 0);
|
gbc_scrollPane.gridx = 1;
|
gbc_scrollPane.gridy = 3;
|
pal.add(lblUIParser, gbc_scrollPane);
|
}
|
{
|
scrollPane = new VCIJScrollPane();
|
gbc_scrollPane = new GridBagConstraints();
|
gbc_scrollPane.insets = new Insets(1, 0, 0, 0);
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
gbc_scrollPane.gridx = 2;
|
gbc_scrollPane.gridy = 3;
|
pal.add(scrollPane, gbc_scrollPane);
|
{
|
txtUIParser = new VCIJTextArea();
|
txtUIParser.setRows(2);
|
txtUIParser.setWrapStyleWord(true);
|
txtUIParser.setLineWrap(true);
|
txtUIParser.setToolTipText(lblUIParserNoteContent);
|
scrollPane.setViewportView(txtUIParser);
|
}
|
}
|
|
{
|
GridBagConstraints gbc_label_3 = new GridBagConstraints();
|
gbc_label_3.insets = new Insets(0, 0, 0, 0);
|
gbc_label_3.gridx = 3;
|
gbc_label_3.gridy = 3;
|
pal.add(lblExtAttrs, gbc_label_3);
|
}
|
{
|
scrollPane = new VCIJScrollPane();
|
gbc_scrollPane = new GridBagConstraints();
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
gbc_scrollPane.gridx = 4;
|
gbc_scrollPane.gridy = 3;
|
gbc_scrollPane.weightx = 4.0;
|
pal.add(scrollPane, gbc_scrollPane);
|
{
|
txtExtAttrs = new VCIJTextArea();
|
txtExtAttrs.setRows(2);
|
txtExtAttrs.setWrapStyleWord(true);
|
txtExtAttrs.setLineWrap(true);
|
txtExtAttrs.setToolTipText(lblExtAttrNoteContent);
|
scrollPane.setViewportView(txtExtAttrs);
|
}
|
}
|
/************************ UI解析类、扩展属性定义 ****************************/
|
{
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.insets = new Insets(0, 0, 0, 0);
|
gbc_label.gridx = 1;
|
gbc_label.gridy = 5;
|
pal.add(lblComptType, gbc_label);
|
}
|
{
|
VCIJPanel panel = new VCIJPanel(new FlowLayout(FlowLayout.LEFT));
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
gbc_panel.insets = new Insets(0, 0, 0, 0);
|
gbc_panel.gridwidth = 2;
|
gbc_panel.fill = GridBagConstraints.BOTH;
|
gbc_panel.gridx = 2;
|
gbc_panel.gridy = 5;
|
pal.add(panel, gbc_panel);
|
{
|
panel.add(rbtnComptTypeTable);
|
}
|
{
|
panel.add(rbtnComptTypeCustom);
|
}
|
{
|
panel.add(rbtnComptTypeTreeTable);
|
}
|
|
VCIJPanel panel2 = new VCIJPanel(new FlowLayout(FlowLayout.LEFT));
|
GridBagConstraints gbc_panel2 = new GridBagConstraints();
|
gbc_panel2.insets = new Insets(0, 0, 0, 0);
|
gbc_panel2.gridwidth = 2;
|
gbc_panel2.fill = GridBagConstraints.BOTH;
|
gbc_panel2.gridx = 2;
|
gbc_panel2.gridy = 6;
|
pal.add(panel2, gbc_panel2);
|
{
|
panel2.add(rbtnComptTypeForm);
|
}
|
{
|
panel2.add(rbtnComptTypeTree);
|
}
|
{
|
panel2.add(rbtnComptTypeUI);
|
}
|
|
rbtnComptTypeGroup.add(rbtnComptTypeTable);
|
rbtnComptTypeGroup.add(rbtnComptTypeCustom);
|
rbtnComptTypeGroup.add(rbtnComptTypeTreeTable);
|
rbtnComptTypeGroup.add(rbtnComptTypeForm);
|
rbtnComptTypeGroup.add(rbtnComptTypeTree);
|
rbtnComptTypeGroup.add(rbtnComptTypeUI);
|
initComptTypeRbtnActionListener();
|
}
|
|
GridBagConstraints gbc_label_2 = new GridBagConstraints();
|
gbc_label_2.insets = new Insets(0, 0, 0, 0);
|
gbc_label_2.gridx = 1;
|
gbc_label_2.gridy = 7;
|
pal.add(lblShowType, gbc_label_2);
|
|
VCIJPanel panel_1 = new VCIJPanel();
|
FlowLayout flowLayout = (FlowLayout) panel_1.getLayout();
|
flowLayout.setAlignment(FlowLayout.LEFT);
|
GridBagConstraints gbc_panel_1 = new GridBagConstraints();
|
gbc_panel_1.gridwidth = 2;
|
gbc_panel_1.fill = GridBagConstraints.BOTH;
|
gbc_panel_1.gridx = 2;
|
gbc_panel_1.gridy = 7;
|
pal.add(panel_1, gbc_panel_1);
|
|
|
rbtnShowTypeNotShow.setSelected(true);
|
panel_1.add(rbtnShowTypeNotShow);
|
rbtnShowTypeGroup.add(rbtnShowTypeNotShow);
|
|
panel_1.add(rbtnShowTypeShowRole);
|
rbtnShowTypeGroup.add(rbtnShowTypeShowRole);
|
|
panel_1.add(rbtnShowTypeShowFolder);
|
rbtnShowTypeGroup.add(rbtnShowTypeShowFolder);
|
|
return pal;
|
}
|
|
private void initComptTypeRbtnActionListener(){
|
ActionListener al = new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
rbtnComptType_actionPerformed(e);
|
}
|
};
|
rbtnComptTypeTable.setObj(ComponentType.Table);
|
rbtnComptTypeCustom.setObj(ComponentType.Custom);
|
rbtnComptTypeTreeTable.setObj(ComponentType.TreeTable);
|
rbtnComptTypeForm.setObj(ComponentType.Form);
|
rbtnComptTypeTree.setObj(ComponentType.Tree);
|
rbtnComptTypeUI.setObj(ComponentType.UILayout);
|
|
rbtnComptTypeTable.addActionListener(al);
|
rbtnComptTypeCustom.addActionListener(al);
|
rbtnComptTypeTreeTable.addActionListener(al);
|
rbtnComptTypeForm.addActionListener(al);
|
rbtnComptTypeTree.addActionListener(al);
|
rbtnComptTypeUI.addActionListener(al);
|
}
|
|
private ComponentType lastComponentType = null;
|
private BaseComptPanel lastComptPanel = null;
|
|
private void rbtnComptType_actionPerformed(ActionEvent e){
|
VCIJRadioButton rbtn = (VCIJRadioButton)e.getSource();
|
ComponentType comptType = (ComponentType) rbtn.getObj();
|
if(lastComponentType != null && comptType.getIntVal() == lastComponentType.getIntVal()){
|
return;
|
}
|
lastComponentType = comptType;
|
changeDyanmicContentPanel(comptType);
|
}
|
|
private void changeDyanmicContentPanel(ComponentType comptType){
|
BaseComptPanel comptPanel = tableComptPanel;
|
if(uiComptPanelMap.containsKey(comptType)){
|
comptPanel = uiComptPanelMap.get(comptType);
|
} else {
|
comptPanel = initComptPanelToMap(comptType);
|
}
|
if(lastComptPanel != null){
|
lastComptPanel.hidePopupDialog();
|
}
|
lastComptPanel = comptPanel;
|
|
dynamicContentPanel.removeAll();
|
dynamicContentPanel.add(comptPanel, BorderLayout.CENTER);
|
try {
|
comptPanel.setDataToUI(getPageDefination());
|
} catch (Throwable e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
dynamicContentPanel.updateUI();
|
if(getContentPane() instanceof JPanel){
|
((JPanel)getContentPane()).updateUI();
|
}
|
}
|
|
private BaseComptPanel initComptPanelToMap(ComponentType comptType){
|
BaseComptPanel res = null;
|
if(ComponentType.Table.getIntVal() == comptType.getIntVal()){
|
tableComptPanel = new TableComptPanel(this);
|
res = tableComptPanel;
|
|
uiComptPanelMap.put(ComponentType.Table, tableComptPanel);
|
}else if(ComponentType.Custom.getIntVal() == comptType.getIntVal()){
|
customComptPanel = new CustomComptPanel(this);
|
res = customComptPanel;
|
|
uiComptPanelMap.put(ComponentType.Custom, customComptPanel);
|
}else if(ComponentType.TreeTable.getIntVal() == comptType.getIntVal()){
|
treeTableComptPanel = new TreeTableComptPanel(this);
|
res = treeTableComptPanel;
|
|
uiComptPanelMap.put(ComponentType.TreeTable, treeTableComptPanel);
|
}else if(ComponentType.Form.getIntVal() == comptType.getIntVal()){
|
formComptPanel = new FormComptPanel(this);
|
res = formComptPanel;
|
|
uiComptPanelMap.put(ComponentType.Form, formComptPanel);
|
}else if(ComponentType.Tree.getIntVal() == comptType.getIntVal()){
|
treeComptPanel = new TreeComptPanel(this);
|
res = treeComptPanel;
|
|
uiComptPanelMap.put(ComponentType.Tree, treeComptPanel);
|
}else if(ComponentType.UILayout.getIntVal() == comptType.getIntVal()){
|
subUIComptPanel = new SubUIComptPanel(this);
|
res = subUIComptPanel;
|
|
uiComptPanelMap.put(ComponentType.UILayout, subUIComptPanel);
|
}
|
res.buildPanel();
|
res.initActionListener();
|
return res;
|
}
|
private VCIJPanel getCenterDynamicContentPanel(){
|
dynamicContentPanel = new VCIJPanel(new BorderLayout());
|
return dynamicContentPanel;
|
}
|
|
private VCIJPanel getSouthButtonPanel(){
|
VCIJPanel palRes = new VCIJPanel(new BorderLayout());
|
VCIJPanel pal = new VCIJPanel();
|
pal.add(btnOk);
|
pal.add(btnCancel);
|
|
eventInfoPanel = new ClickEventInfoPanel();
|
palRes.add(eventInfoPanel, BorderLayout.CENTER);
|
palRes.add(pal, BorderLayout.SOUTH);
|
return palRes;
|
}
|
|
private void setLocationAndSize(){
|
setTitle(getTitle());
|
setSize(getWidth(), getHeight());
|
setLocationRelativeTo(getRelativeToCompt());
|
}
|
|
private void btnOk_actionPerformed(ActionEvent e){
|
try{
|
PLPageDefination pd = getPageDefination();
|
PLDefination d = null;
|
boolean isEdit = (pd != null);
|
if(isEdit){
|
d = UITools.getPLDefination(pd.plDefination);
|
} else {
|
pd = new PLPageDefination();
|
d = new PLDefination();
|
pd.plTabPageOId = getTabPage().plOId;
|
pd.plOId = ObjectUtility.getNewObjectID36();
|
}
|
if(!baseInfoIsOk(pd, isEdit)){
|
return;
|
}
|
setUIValueToObject(pd, d);
|
if(!newPLDefinationIsOk(pd, isEdit)){
|
return;
|
}
|
BaseComptPanel comptPanel = getLastComptPanel();
|
|
// 检查各个组件内部的数据是否有效
|
if(!comptPanel.checkInputIsOk()){
|
return;
|
}
|
|
d = comptPanel.getNewPLDefination(d);
|
d = setEventDataToPLDefination(d);
|
pd.plDefination = UITools.getPLDefinationText(d);
|
|
boolean res = false;
|
if(isEdit){
|
res = UITools.getService().updatePLPageDefination(pd);
|
} else {
|
res = UITools.getService().savePLPageDefination(pd);
|
}
|
if(res){
|
close(DialogResult.OK);
|
}
|
}catch(Throwable ex){
|
//TODO
|
ex.printStackTrace();
|
}
|
}
|
|
private boolean baseInfoIsOk(PLPageDefination pd, boolean isEdit) throws VCIError{
|
boolean res = false;
|
if(!checkRequiredIsOk(lblName, txtName)){
|
return false;
|
}
|
else if(!checkRequiredIsOk(lblSeq, txtSeq)){
|
return false;
|
}
|
res = true;
|
return res;
|
}
|
|
private boolean checkRequiredIsOk(VCIJLabel lbl, VCIJTextField txt){
|
boolean res = false;
|
String text = txt.getText();
|
if("".equals(text) && txt.isRequired()){
|
txt.requestFocus();
|
VCIJOptionPane.showMessage(this, lbl.getText() + " 不能为空!");
|
res = false;
|
} else {
|
res = true;
|
}
|
return res;
|
}
|
|
private boolean newPLDefinationIsOk(PLPageDefination pd, boolean isEdit) throws VCIError{
|
boolean res = false;
|
boolean nameExist = false;
|
boolean seqExist = false;
|
PLPageDefination[] pds = UITools.getService().getPLPageDefinationsByPageContextOId(getTabPage().plOId);
|
for (PLPageDefination pdGet : pds) {
|
if(!isEdit){
|
if(pd.name.equals(pdGet.name)){
|
nameExist = true;
|
} else if(pd.seq == pdGet.seq){
|
seqExist = true;
|
}
|
} else {
|
if(!pd.plOId.equals(pdGet.plOId)){
|
if(pd.name.equals(pdGet.name)){
|
nameExist = true;
|
} else if(pd.seq == pdGet.seq){
|
seqExist = true;
|
}
|
}
|
}
|
if(nameExist || seqExist){
|
break;
|
}
|
}
|
if(nameExist){
|
txtName.requestFocus();
|
VCIJOptionPane.showMessage(this, lblName.getText() + " 已经存在!");
|
return false;
|
}
|
|
if(seqExist){
|
txtSeq.requestFocus();
|
VCIJOptionPane.showMessage(this, lblSeq.getText() + " 已经存在!");
|
return false;
|
}
|
res = true;
|
return res;
|
}
|
private PLDefination setEventDataToPLDefination(PLDefination d){
|
DefaultListModel listModel = eventInfoPanel.getListModel();
|
int size = listModel.getSize();
|
List<String> keyList = new ArrayList<String>();
|
Map<String,String> keyMap = new HashMap<String,String>();
|
for(int i=0;i<size;i++){
|
String elementAt = (String) listModel.getElementAt(i);
|
String[] split = elementAt.split(":");
|
if(!keyList.contains(split[0])){
|
keyList.add(split[0]);
|
}
|
}
|
fetchEventValue(listModel, size, keyList,keyMap);
|
String eventKey = "";
|
String eventValue = "";
|
for(Entry<String, String> 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<String> keyList,Map<String,String> keyMap) {
|
for(int j=0;j<keyList.size();j++){
|
String eventValue="";
|
String eventKey = keyList.get(j);
|
for(int i=0;i<size;i++){
|
String elementAt = (String) listModel.getElementAt(i);
|
String[] split = elementAt.split(":");
|
if(eventKey.equals(split[0])){
|
eventValue += split[1]+";";
|
}
|
}
|
keyMap.put(eventKey, eventValue.substring(0,eventValue.length()-1));
|
}
|
}
|
private BaseComptPanel getLastComptPanel(){
|
return lastComptPanel;
|
}
|
private void setUIValueToObject(PLPageDefination pd, PLDefination d){
|
pd.name = txtName.getText().trim();
|
pd.seq = Short.valueOf(txtSeq.getText().trim());
|
pd.desc = txtDesc.getText().trim();
|
|
d.setName(txtName.getText().trim());
|
d.setUiParser(txtUIParser.getText().trim());
|
d.setExtAttr(txtExtAttrs.getText().trim());
|
d.setTemplateType(String.valueOf(lastComponentType.getIntVal()));
|
}
|
|
private void btnCancel_actionPerformed(ActionEvent e){
|
close(DialogResult.CANCEL);
|
}
|
|
private void close(DialogResult dialogRes){
|
setDialogResult(dialogRes);
|
setVisible(false);
|
dispose();
|
}
|
|
public String getTitle() {
|
return title;
|
}
|
public void setTitle(String title) {
|
this.title = title;
|
}
|
public int getWidth() {
|
return width;
|
}
|
public void setWidth(int width) {
|
this.width = width;
|
}
|
public int getHeight() {
|
return height;
|
}
|
public void setHeight(int height) {
|
this.height = height;
|
}
|
public Component getRelativeToCompt() {
|
return relativeToCompt;
|
}
|
public void setRelativeToCompt(Component relativeToCompt) {
|
this.relativeToCompt = relativeToCompt;
|
}
|
public PLTabPage getTabPage() {
|
return tabPage;
|
}
|
public void setTabPage(PLTabPage tabPage) {
|
this.tabPage = tabPage;
|
}
|
public PLPageDefination getPageDefination() {
|
return pageDefination;
|
}
|
public void setPageDefination(PLPageDefination pageDefination) {
|
this.pageDefination = pageDefination;
|
}
|
}
|