eas再ListUIPIEx中新增工具欄按鈕並進行監聽操作
阿新 • • 發佈:2018-12-26
問題背景
有這麼一個需求,需要再eas中新增一個工具欄按鈕,批量操作選中的資料,工具欄是toolBar,按鈕是KDWorkButton。
操作實戰
話不多說,直接實操。
1.首先要拓展對應的ListUIPIEx類
public class ManufactureOrderTechnicsListUIPIEx extends ManufactureOrderTechnicsListUI
2.新建一個button
KDWorkButton btnBatchClose = new KDWorkButton("※批量關閉※");
3.在onload裡面把button新增toolbar並新增監聽事件
//新增到toolBar
this.toolBar.add(this.btnBatchClose);
//新增按鍵監聽
this.btnBatchClose.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
//新增處理方法
btnBatchClose_do();
}
});
4.監聽選擇的list
List listId = getSelectedIdValues(); if ( listId == null || listId.size() == 0 ) { MsgBox.showInfo("請至少選擇一個生產訂單!"); SysUtil.abort(); }
5.彈出提示框,使用者選擇確認則處理業務請求
if(MsgBox.showConfirm2("確定要批量關閉?")==0){//0確定 2取消
ManufactureOrderSyncFacadeFactory.getRemoteInstance().actionBatchClose(listId);
MsgBox.showInfo("已經批量關閉:"+listId.toString());
}
6.重新整理列表,一句話搞定,不呼叫則不會重新整理,這樣使用者看不到變更。
super.refreshList();
idList轉換為String
*.如果你需要把idList轉換成String,方便拼接sql語句的話,可以參考這個
ListToString和MapToString
完整程式碼
public class ManufactureOrderTechnicsListUIPIEx extends ManufactureOrderTechnicsListUI{
private static final long serialVersionUID = 7187774245891364263L;
KDWorkButton btnBatchClose = new KDWorkButton("※批量關閉※");
public ManufactureOrderTechnicsListUIPIEx() throws Exception
{
super();
}
public void onLoad() throws Exception
{
super.onLoad();
//新增到toolBar
this.toolBar.add(this.btnBatchClose);
//新增按鍵監聽
this.btnBatchClose.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
try
{
//新增處理方法
btnBatchClose_do();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
});
}
//處理方法
private void btnBatchClose_do() throws Exception
{
List listId = getSelectedIdValues();
if ( listId == null || listId.size() == 0 )
{
MsgBox.showInfo("請至少選擇一個生產訂單!");
SysUtil.abort();
}
if(MsgBox.showConfirm2("確定要批量關閉?")==0){//0確定 2取消
ManufactureOrderSyncFacadeFactory.getRemoteInstance().actionBatchClose(listId);
MsgBox.showInfo("已經批量關閉:"+listId.toString());
}
super.refreshList();
}
}
效果展示