package nc.ui.pubapp.uif2app.actions;

import java.awt.event.ActionEvent;
import java.util.UUID;


import nc.bs.pub.filesystem.IFileSystemActionConst;
import nc.bs.uif2.IActionCode;
import nc.ui.ml.NCLangRes;
import nc.ui.pub.beans.MessageDialog;
import nc.ui.pub.bill.BillCardPanel;
import nc.ui.uif2.NCAction;
import nc.ui.uif2.actions.ActionInitializer;
import nc.ui.uif2.editor.BillForm;
import nc.ui.uif2.model.AbstractUIAppModel;

public class InvoiceSelectAction extends NCAction implements IFileSystemActionConst{
	private static final long serialVersionUID = 4674049033047277460L;
	private AbstractUIAppModel model;
	public BillForm editor;
	private MultiSelectDialog  multiSelectDialog= null;
	public BillForm getEditor() {
		return editor;
	}

	public void setEditor(BillForm editor) {
		this.editor = editor;
	}
	
	public AbstractUIAppModel getModel() {
		return this.model;
	}

	public void setModel(AbstractUIAppModel model) {
		this.model = model;
		this.model.addAppEventListener(this);
	}
	
	
	public InvoiceSelectAction() {
		super();
		ActionInitializer.initializeAction(this, IActionCode.FILE);
		 this.setBtnName("从发票云获取发票");
	        this.setCode("invoiceSelectAction");
	       
	}
	@Override
	public void doAction(ActionEvent arg0){
		try {
			BillCardPanel cpanel=editor.getBillCardPanel();
			String vdef17 = (String) cpanel.getHeadItem("vdef17").getValueObject();
			String rootPath = null;
			if(vdef17 != null){
				rootPath = vdef17;
			}else {
				rootPath = UUID.randomUUID().toString();
				cpanel.setHeadItem("vdef17", rootPath);
			}
			multiSelectDialog = new MultiSelectDialog(editor);
			multiSelectDialog.showModal();
		} catch (Exception e) {
			MessageDialog.showErrorDlg(null, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
					,e.getMessage());
		}
		
	}

}
