第一步:编写扩展类,继承自com.kingdee.bos.ctrl.extendcontrols.KDCommonPromptDialog
如下示例:
package com.kingdee.eas.custom.medianterface.client;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.ctrl.extendcontrols.KDCommonPromptDialog;
import com.kingdee.bos.ctrl.swing.KDWorkButton;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.custom.util.MediaUtil;
import com.kingdee.eas.fi.cas.PaymentBillFactory;
import com.kingdee.eas.fi.cas.PaymentBillInfo;
/**
* 在标准F7弹出窗的toolbar上添加一个按钮,并实现按钮的功能
* @author Tommy.Xiao
*/
public class UserKDCommonPromptDialog extends KDCommonPromptDialog {
public UserKDCommonPromptDialog() {
super();
}
// @Override
protected void dialogInit() {
super.dialogInit();
//请在此处修改F7弹出窗口,可进行添加按钮,菜单等
addUriButton();
}
protected void addUriButton()
{
KDWorkButton bar = new KDWorkButton();
bar.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
//实现按钮功能
ActionUri_actionPerformed(e);
}});
bar.setText("查看影像 ");
getSkinRootPane().getBarPartAreaOfOrientation(1).getToolBars()[0].add(bar);
}
protected void ActionUri_actionPerformed(ActionEvent e )
{
ArrayList list = getSelectedIdValues();
if(list.size() > 0){
String id = list.get(0).toString();
String oql = "select * where id='" + id + "'";
try {
PaymentBillInfo payment = PaymentBillFactory.getRemoteInstance().getPaymentBillInfo(oql);
String barcode = payment.getBarcode();
MediaUtil.viewImg(barcode);
} catch (EASBizException e1) {
e1.printStackTrace();
} catch (BOSException e1) {
e1.printStackTrace();
}
}
}
}
第二步:选中单据上的F7控制。设置其defaultF7UIName属性值上一步定义的类全路径。示例如下:
第三步:发布上一步修改的UI元数据。在其扩展类的onload()方法中添加以下代码:
QueryAgent agent = new QueryAgent();
MetaDataPK pk = new MetaDataPK("com.kingdee.eas.custom.medianterface.app", "PaymentBillMediaQuery"); //具体的Query根据实际情况填写
agent.setQueryInfoPK(pk);
UserKDCommonPromptDialog userF7 = new UserKDCommonPromptDialog();
userF7.setQueryInfo(agent.getQueryInfo());
kDBizPayment.setSelector(userF7);
示例如下:
package com.kingdee.eas.fi.fa.manage.client;
import com.kingdee.bos.ctrl.extendcontrols.QueryAgent;
import com.kingdee.bos.metadata.MetaDataPK;
import com.kingdee.eas.custom.medianterface.client.UserKDCommonPromptDialog;
public class FaCurCardEditUICTEx extends FaCurCardEditUI{
public FaCurCardEditUICTEx() throws Exception {
super();
}
@Override
public void onLoad() throws Exception {
super.onLoad();
QueryAgent agent = new QueryAgent();
MetaDataPK pk = new MetaDataPK("com.kingdee.eas.custom.medianterface.app", "PaymentBillMediaQuery");
agent.setQueryInfoPK(pk);
UserKDCommonPromptDialog userF7 = new UserKDCommonPromptDialog();
userF7.setQueryInfo(agent.getQueryInfo());
kDBizPayment.setSelector(userF7);
}
}