package com.vci.client.uif.engine.client;
|
|
import java.awt.BorderLayout;
|
import java.awt.Component;
|
import java.awt.Frame;
|
import java.awt.Image;
|
import java.awt.Window;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.util.HashMap;
|
import javax.swing.JDialog;
|
|
import com.vci.client.ui.swing.VCISwingUtil;
|
import com.vci.client.ui.swing.components.VCIJButton;
|
import com.vci.client.ui.swing.components.VCIJOptionPane;
|
import com.vci.client.ui.swing.components.VCIJPanel;
|
import com.vci.client.uif.engine.client.tableArea.TablePanel;
|
import com.vci.client.uif.engine.client.tree.TreePanel;
|
|
/**
|
* 添加按钮事件中使用的选择窗口
|
* @author VCI-STGK006
|
*
|
*/
|
public class ChooseBusinessObjectDialog extends JDialog {
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 7337695196482233220L;
|
|
/**
|
* 图标
|
*/
|
private Image img = VCISwingUtil.createImageIcon("search.png").getImage();
|
/**
|
* 父窗口
|
*/
|
private Window owner = null;
|
/**
|
* ui上下文
|
*/
|
private String context = "";
|
/**
|
* 显示类型
|
*/
|
private String type = "";
|
/**
|
* 显示中选中类型的oid
|
*/
|
private String oid = "";
|
/**
|
* UILayoutPanel
|
*/
|
private UILayoutPanel uipl = null;
|
/**
|
* 是否可以多选
|
*/
|
private boolean multiplechoice = false;
|
/**
|
* 用户选择数据
|
*/
|
private Object[] selectedDatas = null;
|
/**
|
* 是确定还是取消
|
*/
|
private boolean isOk = false;
|
|
/**
|
* 查询选择窗口
|
* @param owner
|
* @param context ui上下文
|
* @param type 显示类型
|
* @param multiplechoice 是否可以多选
|
* @param oid sourceOID
|
*/
|
public ChooseBusinessObjectDialog(Frame owner, String type, String context, boolean multiplechoice,String oid){
|
super(owner, "选择", true);
|
this.owner = owner;
|
this.context = context;
|
this.type = type;
|
this.oid = oid;
|
this.multiplechoice = multiplechoice;
|
init();
|
}
|
|
private HashMap<String, String> souceMap = null;
|
/**
|
*
|
* @Title :
|
* @Description :
|
* @param owner
|
* @param type
|
* @param context
|
* @param multiplechoice
|
* @param oid
|
* @param souceMap //Add by zhonggy 2015-08 (计价系统提出需求,by xiejun)
|
*/
|
public ChooseBusinessObjectDialog(Frame owner, String type, String context, boolean multiplechoice,String oid,HashMap<String, String> souceMap){
|
super(owner, "选择", true);
|
this.owner = owner;
|
this.context = context;
|
this.type = type;
|
this.oid = oid;
|
this.multiplechoice = multiplechoice;
|
this.souceMap = souceMap;
|
init();
|
}
|
|
/**
|
* 绘制窗体
|
*/
|
public void init(){
|
setIconImage(img);
|
setLayout(new BorderLayout());
|
add(getCenterDataPanel(), BorderLayout.CENTER);
|
add(getSouthButtonPanel(), BorderLayout.SOUTH);
|
setSize(UIHelper.DIALOG_DEFAULT_WIDTH, UIHelper.DIALOG_DEFAULT_HEIGHT);
|
setLocationRelativeTo(owner);
|
setVisible(true);
|
}
|
|
/**
|
* 创建数据区域
|
* @return
|
*/
|
private VCIJPanel getCenterDataPanel(){
|
VCIJPanel pal = new VCIJPanel(new BorderLayout());
|
//HashMap<String, String> map = new HashMap<String, String>();
|
if (souceMap == null) {
|
souceMap = new HashMap<String, String>();
|
}
|
souceMap.put(UIHelper.TYPE, type);
|
souceMap.put(UIHelper.CONTEXT, context);
|
souceMap.put(UIHelper.OID, oid);
|
//map.put(UIHelper.OID, map.get(UIHelper.OID));
|
// 加入来源参数
|
//map.put("fromType", type);
|
//map.put("fromContext", context);
|
//map.put("fromObjectId", map.get(UIHelper.OID));
|
|
UILayoutPanel uipl = getUILayoutPanel(souceMap);
|
pal.add(uipl, BorderLayout.CENTER);
|
return pal;
|
}
|
|
private UILayoutPanel getUILayoutPanel(HashMap<String, String> map){
|
uipl = new UILayoutPanel(map);
|
uipl.setDataValueMap(map);
|
uipl.prep();
|
uipl.initMainPanel();
|
return uipl;
|
}
|
|
/**
|
* 创建按钮区域
|
* @return
|
*/
|
private VCIJPanel getSouthButtonPanel(){
|
VCIJPanel pal = new VCIJPanel();
|
VCIJButton btnOk = VCISwingUtil.createVCIJButton("ok", "确定", "确定", "accept.png");
|
VCIJButton btnCancel = VCISwingUtil.createVCIJButton("cancel", "取消", "取消", "cancel.png");
|
btnOk.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
ok();
|
}
|
});
|
btnCancel.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
cancel();
|
}
|
});
|
pal.add(btnOk);
|
pal.add(btnCancel);
|
return pal;
|
}
|
|
/**
|
* 确定事件
|
*/
|
public void ok(){
|
Component compt = uipl.getTabPanel();
|
Object[] objs = null;
|
if(compt instanceof TablePanel){
|
TablePanel tablePanel = (TablePanel) compt;
|
objs = tablePanel.getTablePanelModel().getSelectObjects();
|
}else if(compt instanceof TreePanel){
|
TreePanel panel = (TreePanel ) compt;
|
Object obj = panel.getSelectTreeNode().getObj();
|
objs=new Object[]{obj};
|
}
|
if(objs == null || objs.length <= 0) {
|
VCIJOptionPane.showError(this, "请先选择数据!");
|
return;
|
}
|
if(!multiplechoice){
|
if(objs.length > 1) {
|
VCIJOptionPane.showError(this, "一次只能选择一条数据!");
|
return;
|
}
|
}
|
this.selectedDatas = objs;
|
this.isOk = true;
|
this.dispose();
|
}
|
/**
|
* 关闭窗口
|
*/
|
private void cancel(){
|
this.dispose();
|
}
|
|
/**
|
* 是否继续执行操作
|
* @return
|
*/
|
public boolean isOk(){
|
return this.isOk;
|
}
|
|
/**
|
* 得到用户选择的数据
|
* @return
|
*/
|
public Object[] getSelectedData(){
|
return this.selectedDatas;
|
}
|
}
|