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
}