package com.vci.client.oq.ui;
|
|
import java.awt.BorderLayout;
|
import java.awt.Component;
|
import java.awt.FlowLayout;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.util.LinkedHashMap;
|
import java.util.LinkedList;
|
|
import com.vci.client.common.providers.ServiceProvider;
|
import com.vci.client.oq.QTClient;
|
import com.vci.client.oq.QTDClient;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
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.VCIJLabel;
|
import com.vci.client.ui.swing.components.VCIJPanel;
|
import com.vci.client.ui.swing.components.VCIJTextField;
|
import com.vci.client.ui.swing.components.table.AbstractVCIJTableDataProvider;
|
import com.vci.client.ui.swing.components.table.VCIJTableNode;
|
import com.vci.client.ui.swing.components.table.VCIJTablePanel;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.omd.qtm.QTInfo;
|
import com.vci.mw.ClientContextVariable;
|
|
public class SelectorQTDialog extends VCIJDialog {
|
|
private VCIJButton btnOk = VCISwingUtil.createVCIJButton("ok", "确定", "确定", "accept.png");
|
private VCIJButton btnCancel = VCISwingUtil.createVCIJButton("cancel", "取消", "取消", "cancel.png");
|
private VCIJTextField attrText = new VCIJTextField("");
|
private VCIJLabel attrLable = new VCIJLabel();
|
private VCIJPanel northPanel= new VCIJPanel();
|
private QTInfo item;
|
|
public QTInfo getItem() {
|
return item;
|
}
|
|
public void setItem(QTInfo item) {
|
this.item = item;
|
}
|
|
private String attr;
|
|
public String getAttr() {
|
return attr;
|
}
|
|
public void setAttr(String attr) {
|
this.attr = attr;
|
}
|
|
private Component parentComponent = null;
|
|
public SelectorQTDialog(Component parentComponent) {
|
super(ClientContextVariable.getFrame(), true);
|
init();
|
//setSize(UIHelper.DIALOG_DEFAULT_WIDTH, UIHelper.DIALOG_DEFAULT_HEIGHT); // modify by zgy 2015-02-13 [oq不不建议引用uif工程]
|
setSize(700,500);
|
this.parentComponent = parentComponent;
|
setLocationRelativeTo(parentComponent);
|
setVisible(true);
|
}
|
|
public void init() {
|
setLayout(new BorderLayout());
|
this.setTitle("选择查询模板");
|
attrLable.setText("输入查询字段:");
|
northPanel.add(attrLable);
|
northPanel.add(attrText);
|
add(northPanel, BorderLayout.NORTH);
|
add(tablePanel(), BorderLayout.CENTER);
|
initAction();// 初始化按钮点击事件
|
}
|
|
private LinkedList<VCIJButton> selfCustomButtons = new LinkedList<VCIJButton>();
|
{
|
selfCustomButtons.add(btnOk);
|
selfCustomButtons.add(btnCancel);
|
}
|
|
MyDataProvider dataProvider = new MyDataProvider();
|
VCIJTablePanel<QTInfo> tablePanel = new VCIJTablePanel<QTInfo>(dataProvider);
|
|
private VCIJPanel tablePanel() {
|
int startIndex = dataProvider.getDataColumnStartIndex();
|
LinkedHashMap<Integer, Integer> widthMaps = new LinkedHashMap<Integer, Integer>();
|
widthMaps.put(startIndex++, 300);
|
widthMaps.put(startIndex++, 300);
|
tablePanel.setColumnWidthMaps(widthMaps);
|
tablePanel.setCustomButtons(selfCustomButtons);
|
tablePanel.setShowPaging(true);
|
tablePanel.setCustomButtonFlowAlign(FlowLayout.CENTER);
|
tablePanel.setPageButtonFlowAlign(FlowLayout.CENTER);
|
tablePanel.setShowExport(false);
|
tablePanel.buildTablePanel();
|
tablePanel.refreshTableData();
|
return tablePanel;
|
}
|
|
class MyDataProvider extends AbstractVCIJTableDataProvider<QTInfo> {
|
QTInfo[] allQts = null;
|
@Override
|
public QTInfo[] getDatas(int arg0, int arg1) {
|
try {
|
allQts = ServiceProvider.getOMDService().getQTDService().getAllQTs();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
//UIFUtils.showErrorMessage(ClientContextVariable.getFrame(), e); // modify by zgy 2015-02-13 [oq不不建议引用uif工程]
|
}
|
// TODO Auto-generated method stub
|
return allQts;
|
}
|
|
@Override
|
public VCIJTableNode<QTInfo> getNewRowNode(QTInfo QtObj) {
|
// TODO Auto-generated method stub
|
VCIJTableNode<QTInfo> node = new VCIJTableNode<QTInfo>(QtObj);
|
node.setPropertyValue(getSpecialColumns()[0], QtObj.qtName);
|
node.setPropertyValue(getSpecialColumns()[1], QtObj.btmName);
|
return node;
|
}
|
|
@Override
|
public String[] getSpecialColumns() {
|
// TODO Auto-generated method stub
|
return "查询模板名称, 业务类型或链接类型".split(",");
|
}
|
|
@Override
|
public int getTotal() {
|
// TODO Auto-generated method stub
|
return allQts.length;
|
}
|
|
}
|
|
private void initAction() {
|
btnCancel.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
// TODO Auto-generated method stub
|
cancelButton_ActionPerformed(e);
|
}
|
});
|
btnOk.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
// TODO Auto-generated method stub
|
addButton_ActionPerformed();
|
}
|
});
|
}
|
|
/**
|
* 确认按钮事件
|
* <p>
|
* Description:
|
* </p>
|
*
|
* @author heyj
|
* @time 2014-3-25
|
*/
|
private void addButton_ActionPerformed() {
|
int len = tablePanel.getSelectedRowIndexs().length;
|
if (len == 0) {
|
VCIOptionPane.showMessage(this, "请选择查询模板再进行操作!");
|
return;
|
}
|
if (len > 1) {
|
VCIOptionPane.showMessage(this, "一次只能选择一个查询模板进行操作");
|
return;
|
}
|
if(attrText.getText()==null||attrText.getText().equals("")){
|
VCIOptionPane.showMessage(this, "请填写输入查询字段");
|
return;
|
}
|
QTInfo obj = tablePanel.getSelectedRowObjects().get(0);
|
this.setItem(obj);
|
this.setAttr(attrText.getText());
|
this.dispose();
|
}
|
/**
|
* 取消按钮事件
|
*
|
* @param e
|
*/
|
private void cancelButton_ActionPerformed(ActionEvent e) {
|
this.item = null;
|
this.dispose();
|
}
|
|
}
|