给分录添加按钮以及相应的事件_BIM开发

给分录添加按钮原理如下:在(EditUI)编辑界面的空白处添加一个WorkButton按键,然后将其绑定到分录上,这样在了客户端显示的时候显示到分录上方

分为以下几步:1.用设计工具给界面添加按钮,同时绑定action事件

2.在java视图添加按钮绑定代码(直接重写initWorkButton方法),以及对应的action事件

如下是我写的实例,我给分录添加了两个新的按钮btnEntrysUpdate和btnEntrysAddNew

已经对应的方法

protected void initWorkButton() {
	super.initWorkButton();
	

	
	//添加修改班组成员和新增劳务人员两个btn
	//2018年9月17日12:26:00 邓天天
	//start
	kDContainer1.addButton(this.btnEntrysUpdate);
	btnEntrysUpdate.setText("修改班组成员");
	btnEntrysUpdate.setVisible(true);
	btnEntrysUpdate.setEnabled(true);
	kDContainer1.addButton(this.btnEntrysAddNew);
	btnEntrysAddNew.setText("新增劳务人员");
	btnEntrysAddNew.setVisible(true);
	btnEntrysAddNew.setEnabled(true);
	//end
	
	}
	//2018年9月17日13:24:54
	//start
	//新建劳务职员 
	@Override
	public void actionEntrysAddNew_actionPerformed(ActionEvent e)
		throws Exception {
		// TODO Auto-generated method stub
		super.actionEntrysAddNew_actionPerformed(e);
		UIContext uiContext = new  UIContext(this);
		uiContext.put("ID", null);
		IUIWindow uiWindow = null;
		
		if ((SwingUtilities.getWindowAncestor(this) != null)
			&& (SwingUtilities.getWindowAncestor(this) instanceof JDialog)) {
			uiWindow = UIFactory.createUIFactory("com.kingdee.eas.base.uiframe.client.UINewTabFactory").create(
				"com.kingdee.eas.ec.basedata.client.ServiceStaffTableEditUI", uiContext, null, OprtState.ADDNEW);				
		} else {
			uiWindow = UIFactory.createUIFactory(
			"com.kingdee.eas.base.uiframe.client.UIModelDialogFactory")
			.create("com.kingdee.eas.ec.basedata.client.ServiceStaffTableEditUI", uiContext, null, OprtState.ADDNEW);
		}
		uiWindow.show();
		
		/*uiWindow = UIFactory.createUIFactory("com.kingdee.eas.base.uiframe.client.UINewTabFactory").create(
			"com.kingdee.eas.ec.basedata.client.ServiceStaffTableEditUI", uiContext, null, OprtState.ADDNEW);*/
		
	}
	//修改班组成员
	@Override
	public void actionEntrysUpdate_actionPerformed(ActionEvent e)
		throws Exception {
		// TODO Auto-generated method stub
		super.actionEntrysUpdate_actionPerformed(e);
		String id = null;
		
		if(kdtEntries.isValid()==false){
			MsgBox.showInfo("班组成员为空,请您先新建班组成员");
			SysUtil.abort();
		}
		
		int row = kdtEntries.getSelectManager().getActiveRowIndex();
		Object obj = kdtEntries.getCell(row, "labourPerson").getValue();
		if(obj instanceof ServiceStaffTableInfo){
			ServiceStaffTableInfo info = (ServiceStaffTableInfo) obj;
			id = info.getId().toString();
		}
        if(id!=null){
        	UIContext uiContext = new UIContext(this);
	uiContext.put("ID", id);			
	IUIWindow uiWindow = null;
	if ((SwingUtilities.getWindowAncestor(this) != null)
		&& (SwingUtilities.getWindowAncestor(this) instanceof JDialog)) {
		uiWindow = UIFactory.createUIFactory("com.kingdee.eas.base.uiframe.client.UINewTabFactory").create(
			"com.kingdee.eas.ec.basedata.client.ServiceStaffTableEditUI", uiContext, null, OprtState.EDIT);				
	} else {
		uiWindow = UIFactory.createUIFactory(
		"com.kingdee.eas.base.uiframe.client.UIModelDialogFactory")
		.create("com.kingdee.eas.ec.basedata.client.ServiceStaffTableEditUI", uiContext, null, OprtState.EDIT);
	}
	uiWindow.show();
        }else{
        	MsgBox.showInfo("请先选择需要修改的班组成员!");
	SysUtil.abort();
        }
	
	}
	//end
发布了35 篇原创文章 · 获赞 19 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/m0_37628958/article/details/82804433