NC二开,在功能节点上新增自己的按钮,并弹框,展示数据的步骤
1、功能注册里找到节点本身的XML,在XML所属文件夹中有对应的.java文件
2、在XML中找一个按钮的来作为参照,改成自己需要的,在到java中田间action方法
<!-- 自己的按钮 -->
<bean id="myAction" class="nc.ui.ic.m4c.action.MyButtonAction">
<!-- model、editor属性名与按钮类对应 -->
<property name="model" ref="icBizModel" />
<property name="editorModel" ref="icBizEditorModel" />
<property name="editor" ref="card" />
</bean>
显示按钮组这里加上
<bean id="actionsOfCard" class="nc.ui.uif2.actions.StandAloneToftPanelActionContainer">
<constructor-arg ref="card" />
<property name="model" ref="icBizModel" />
<!-- 可以配置非编辑状态下和编辑状态下分别可见的Action,没有此需求时可以配置得一样 -->
<property name="actions">
<list>
<!-- 新增 -->
<ref bean="addMenu" />
<!-- 修改 -->
<ref bean="saleOuteditAction" />
<!-- 删除 -->
<ref bean="deleteAction" />
<!-- 复制 -->
<ref bean="copyAction" />
<!-- 分割 -->
<ref bean="separatorAction" />
<!-- 查询 -->
<ref bean="queryAction" />
<!-- 刷新 -->
<ref bean="refreshCardAction" />
<!-- 分割 -->
<ref bean="separatorAction" />
<!-- 维护 -->
<ref bean="maintainMenu" />
<!-- 签字按钮组 -->
<ref bean="signActionMenu" />
<!-- 关联功能 -->
<ref bean="relatFunctionBrowseAction_OUT" />
<!-- 分割 -->
<ref bean="separatorAction" />
<!-- 联查 -->
<ref bean="linkQryBrowseGroupAction" />
<!-- 分割 -->
<ref bean="separatorAction" />
<!-- 导入导出 -->
<ref bean="importExportAction" />
<!-- 打印 -->
<ref bean="printMngAction" />
<!-- 分割 -->
<ref bean="separatorAction" />
<!-- 分割 -->
<ref bean="myAction" />
</list>
</property>
.java文件中加入自己的Action,不然不显示按钮,其中参数可参考同文件中的其他按钮,一个模块的参数基本都一样 ,另外要在listAction中添加自己的Action(两个地方需要添加)
/* TODO自己的button*/
public MyButtonAction getMyAction() {
if (this.context.get("myAction") != null)
return (MyButtonAction)this.context.get("myAction");
MyButtonAction bean = new MyButtonAction();
this.context.put("myAction", bean);
bean.setModel(getIcBizModel());
bean.setEditorModel((ICGenBizEditorModel)findBeanInUIF2BeanFactory("icBizEditorModel"));
bean.setEditor(getCard());
setBeanFacotryIfBeanFacatoryAware(bean);
invokeInitializingBean(bean);
return bean;
}
private List getManagedList8() {
List list = new ArrayList(); list.add(getAddMenu()); list.add(getSaleOuteditAction()); list.add(getDeleteAction()); list.add(getCopyAction()); list.add((Action)findBeanInUIF2BeanFactory("separatorAction")); list.add((Action)findBeanInUIF2BeanFactory("queryAction")); list.add((Action)findBeanInUIF2BeanFactory("refreshCardAction")); list.add((Action)findBeanInUIF2BeanFactory("separatorAction")); list.add((Action)findBeanInUIF2BeanFactory("maintainMenu")); list.add((Action)findBeanInUIF2BeanFactory("signActionMenu")); list.add(getRelatFunctionBrowseAction_OUT()); list.add((Action)findBeanInUIF2BeanFactory("separatorAction")); list.add(getLinkQryBrowseGroupAction()); list.add((Action)findBeanInUIF2BeanFactory("separatorAction")); list.add((Action)findBeanInUIF2BeanFactory("importExportAction")); list.add(getPrintMngAction());list.add(getMyAction()); return list;
}
最后是自己的Action按钮方法和弹窗的方法
package nc.ui.ic.m4c.action;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import nc.bs.framework.common.NCLocator;
import nc.desktop.ui.WorkbenchEnvironment;
import nc.funcnode.ui.AbstractFunclet;
import nc.funcnode.ui.FuncletWindowLauncher;
import nc.itf.uap.IUAPQueryBS;
import nc.itf.uap.qrytemplate.IQueryTemplateQry;
import nc.jdbc.framework.processor.ArrayListProcessor;
import nc.sfbase.client.ClientToolKit;
import nc.ui.ic.general.model.ICGenBizEditorModel;
import nc.ui.ic.m4c.view.SaleOutBizView;
import nc.ui.ic.pub.model.ICBizModel;
import nc.ui.mmf.framework.util.FuncNodeLauncher;
import nc.ui.pub.beans.MessageDialog;
import nc.ui.pub.bill.BillCardPanel;
import nc.ui.uif2.NCAction;
import nc.ui.uif2.model.BillManageModel;
import nc.vo.ic.m4c.entity.SaleOutVO;
import nc.vo.querytemplate.QryTempletVOWithInfo;
import nc.vo.sm.funcreg.FuncRegisterVO;
@SuppressWarnings("restriction")
public class MyButtonAction extends NCAction {
//根据节点xml中其他按钮bean选择model、editor的类型
private ICBizModel model;
private ICGenBizEditorModel editorModel;
private SaleOutBizView editor;
/**
* 销售订单维护
*/
private static final long serialVersionUID = 1L;
public MyButtonAction(){
setCode("myAction");
super.setBtnName("测试按钮展示数据");
}
@Override
public void doAction(ActionEvent arg0) throws Exception {
//MessageDialog.showHintDlg(getModel().getContext().getEntranceUI(), "测试", "测试信息");
SaleOutVO out=(SaleOutVO) this.getModel().getSelectedData();
AbstractFunclet funclet = (AbstractFunclet) getModel().getContext()
.getEntranceUI();
SplitLineDialog dlg=new SplitLineDialog(funclet);
//dlg.showModal();
int res=dlg.initData(out.getBodys());
if(res==1){
dlg.showModal();
}
}
public ICBizModel getModel() {
return model;
}
public void setModel(ICBizModel model) {
this.model = model;
this.model.addAppEventListener(this); // 监听
}
public ICGenBizEditorModel getEditorModel() {
return editorModel;
}
public void setEditorModel(ICGenBizEditorModel saleOutBizView) {
this.editorModel = saleOutBizView;
}
public void setEditor(SaleOutBizView card) {
this.editor = card;
}
public SaleOutBizView getEditor() {
return editor;
}
}
弹框所需要的模板需要在模板里新建自己需要的模板,也可以根据需求调用其他模板,然后赋值操作就行,重要的地方代码里都有注释,也可以参考界面其他按钮的方法进行操作
package nc.ui.ic.m4c.action;
import java.awt.BorderLayout;
import java.awt.Container;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.swing.JPanel;
import nc.bs.framework.common.NCLocator;
import nc.funcnode.ui.AbstractFunclet;
import nc.itf.bd.supplier.baseinfo.ISupplierBaseInfoQryService;
import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.processor.ArrayListProcessor;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.pubitf.ic.m4c.ISaleOutRefQuery;
import nc.ui.pub.beans.UIDialog;
import nc.ui.pub.beans.UIPanel;
import nc.ui.pub.bill.BillCardPanel;
import nc.ui.pub.bill.BillEditEvent;
import nc.ui.pub.bill.BillEditListener;
import nc.ui.pub.bill.BillEditListener2;
import nc.vo.ic.m4c.entity.SaleOutBodyVO;
import nc.vo.ic.m4c.entity.SaleOutHeadVO;
import nc.vo.ic.m4c.entity.SaleOutVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.CircularlyAccessibleValueObject;
import nc.vo.pub.lang.UFBoolean;
/**
*
* @ClassName: SplitLineDialog
* @Description: TODO(拆行对话框)
* @author Administrator
* @version 1.0
*/
public class SplitLineDialog extends UIDialog implements BillEditListener,
BillEditListener2 {
private static final long serialVersionUID = 5064747027574608058L;
private AbstractFunclet parent;
/** UI JPanel */
private JPanel uiContentPane;
/** 按钮模板 */
private UIPanel btnUIPanel;
private BillCardPanel billPanel;
// 生产计划编制选择的表体行
private int row = -1;
// 生产计划编制选择 的表体行vo
private SaleOutHeadVO curBody = null;
public SplitLineDialog(AbstractFunclet parent) {
super(parent);
this.parent = parent;
this.initialize();
}
public int initData(SaleOutBodyVO[] bodys) throws BusinessException {
String cgeneralhid = bodys[0].getCgeneralhid();
IUAPQueryBS iquery = (IUAPQueryBS)NCLocator.getInstance().lookup(IUAPQueryBS.class);
// 创建VO
SaleOutHeadVO splivo = new SaleOutHeadVO();
//给VO赋值
String sql = "select vbillcode,fbillflag,vtrantypecode from ic_saleout_h where cgeneralhid = '"+cgeneralhid+"' and dr = 0";
List<HashMap<String, Object>> list = (List<HashMap<String, Object>>)iquery.executeQuery(sql,new MapListProcessor());
if(list.size()>0){
splivo.setVbillcode(String.valueOf(list.get(0).get("vbillcode")));
splivo.setFbillflag(Integer.parseInt(list.get(0).get("fbillflag").toString()));
splivo.setVtrantypecode(String.valueOf(list.get(0).get("vtrantypecode")));
}
//在界面上创建一一行
this.billPanel.getBillModel().addLine();
//将VO放入节点当中
String[] names = splivo.getAttributeNames();
for (String name : names) {
this.billPanel.setHeadItem(name, splivo.getAttributeValue(name));
}
this.billPanel.setHeadItem("fis3", UFBoolean.TRUE);
for(int i = 0;i<bodys.length;i++){
this.billPanel.getBillModel().setBodyRowVO(bodys[i], i);
}
return 1;
}
private void initialize() {
this.setName("mpsSplitDialog");
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.setTitle("数据展示");
int w = 1000;
int h = 600;
this.setBounds(500, 400, w, h);
this.setResizable(true);
// 设置模板
this.setContentPane(this.getUIContentPane());
}
private Container getUIContentPane() {
if (null == this.uiContentPane) {
this.uiContentPane = new JPanel();
this.uiContentPane.setName("UIDialogContentPane");
this.uiContentPane.setLayout(new BorderLayout());
this.getUIContentPane().add(this.getBillPanel(), "Center");
this.getUIContentPane().add(this.getBtnUIPanel(), "South");
}
return this.uiContentPane;
}
//单据模板pk查询
//select pk_billtemplet from pub_billtemplet where bill_templetcaption='单据模版名称'
private BillCardPanel getBillPanel() {
// TODO Auto-generated method stub
if (this.billPanel == null) {
this.billPanel = new BillCardPanel();
this.billPanel.setName("mpsSplitPanel");
this.billPanel.loadTemplet("1001Z8100000000008NZ");
this.billPanel.addEditListener(this);
this.billPanel.addBillEditListenerHeadTail(this);
this.billPanel.getBillTable().setSelectionMode(
javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
this.billPanel.setTatolRowShow(true);
this.billPanel.setBodyMenuShow(false);
}
return this.billPanel;
}
/**
* 按钮pannelgetter
*
* @return 按钮pannel
*/
public UIPanel getBtnUIPanel() {
if (this.btnUIPanel == null) {
this.btnUIPanel = new nc.ui.pub.beans.UIPanel();
this.btnUIPanel.setName("BtnUIPanel");
}
return this.btnUIPanel;
}
@Override
public boolean beforeEdit(BillEditEvent arg0) {
// TODO 自动生成的方法存根
return false;
}
@Override
public void afterEdit(BillEditEvent arg0) {
// TODO 自动生成的方法存根
}
@Override
public void bodyRowChange(BillEditEvent arg0) {
// TODO 自动生成的方法存根
}
}