eas再ListUIPIEx中添加工具栏按钮并进行监听操作

版权声明:powered by 大狼狗郑锴/Moshow魔手 https://blog.csdn.net/moshowgame/article/details/84789921

问题背景

有这么一个需求,需要再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();
	}

}

效果展示

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/moshowgame/article/details/84789921