【NC57】添加自定义按钮(上传附件为例)

1:创建按钮实例*SubFileButton*

public class SubFileButton {

	public ButtonVO getButtonVO(){
		ButtonVO btnVo = new ButtonVO();
		btnVo.setBtnNo(102);
		btnVo.setBtnCode("SubFileButton");
		btnVo.setBtnName("附件");
		btnVo.setBtnChinaName("附件");
	       btnVo.setChildAry(new int[]{});
		btnVo.setOperateStatus(new int[]{
				 IBillOperate.OP_ALL
		});        
		return btnVo;
	} 
}

2:定义按钮系统标识 可不定义

/**
  *
  *该接口用于存放按钮常量
  *@author author
  *@version tempProject version
  */ 
  public interface  ICustomizeButton{
    
        public final static int SubFileButton = 102;
        
  }

3:*ClientUI*中进行自定义按钮初始化

 @Override
	protected void initPrivateButton() {
			 SubFileButton subFileButton = new SubFileButton();
			this.addPrivateButton(subFileButton.getButtonVO());
			super.initPrivateButton();
 
	}

4:*EventHander*:中进行按钮动作编写

protected void onBoElse(int intBtn) throws Exception {
	switch (intBtn) {
		case 102 :
			 onBoSubFileButton();
			break; 
	}
}
private void onBoSubFileButton() throws BusinessException {
	DocumentActionz file=new DocumentActionz();
  try {
		Object pro  = getCurAggVo().getParentVO().getAttributeValue("vdef7");
		file.showDocument(pro.toString());
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
}

5:在此附上附件按钮的Dialog

/** <a href="http://www.cpupk.com/decompiler">Eclipse Class Decompiler</a> plugin, Copyright (c) 2017 Chen Chao. */
package nc.ui.jzpm.selfbuttons;
import java.awt.BorderLayout;

import nc.ui.arap.bx.actions.BXDefaultAction;
import nc.ui.er.pub.BillWorkPageConst;
import nc.ui.hr.comp.attachment.AttachmentDialog;
import nc.ui.pub.beans.UIDialog;
import nc.ui.pub.filesystem.FileManageUI;
import nc.vo.ml.NCLangRes4VoTransl;
import nc.vo.pub.BusinessException;


/**
 * @author twei
 * 
 * nc.ui.arap.bx.actions.DocumentAction
 */
public class DocumentActionz extends BXDefaultAction {
	private AttachmentDialog attachmentDialog;
	private boolean blUsePower = true;
	private int iFileBtnUsable = 0;
	private String strObjectType;
	public void showDocument(String pk) throws BusinessException {
		boolean isEdit=false;
		if(pk!=null&&!pk.equals("")){
		 isEdit =true;
		this.showModal(pk, isEdit);
		}else {
			isEdit =false;
		this.showErrorMsg(("没有选择上传附件的单据"));
		 
		}
		// 29
		 
	}// 30

	private void showModal(String headpk, boolean isEdit) {
		 
		this.attachmentDialog = new AttachmentDialog( this.getParent(), headpk, this.strObjectType);// 82
		this.attachmentDialog.setFileBtnUsable(this.iFileBtnUsable);// 89
		this.attachmentDialog.setUsePower(this.blUsePower);// 91
		this.attachmentDialog.showModal();// 93
	}// 41

	private void updateButton(FileManageUI manageUI, boolean isEdit) {
		manageUI.setCreateNewFolderEnable(isEdit);// 43
		manageUI.setDeleteNodeEnable(isEdit);// 44
		manageUI.setUploadFileEnable(isEdit);// 45
	}// 46
}
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值