package nc.ui.arap.bill;

import java.awt.Desktop;
import java.net.URI;
import java.net.URL;

import nc.bs.framework.common.InvocationInfoProxy;
import nc.bs.framework.common.NCLocator;
import nc.itf.th.IThOcrService;
import nc.sfbase.client.ClientToolKit;
import nc.ui.pub.bill.BillCardPanel;
import nc.ui.pub.bill.BillItemHyperlinkEvent;
import nc.ui.pub.bill.BillItemHyperlinkListener;
import nc.ui.pub.bill.BillListPanel;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;

public class LinkHyperListener implements BillItemHyperlinkListener{

	private BillCardPanel billCardPanel;
	private BillListPanel billListPanel;
	private String billmaker = InvocationInfoProxy.getInstance().getUserId();
	
	public LinkHyperListener(BillCardPanel billCardPanel) {
        this.billCardPanel = billCardPanel;
    }
	public LinkHyperListener(BillListPanel billListPanel) {
		this.billListPanel = billListPanel;
	}

	
	@Override
	public void hyperlink(BillItemHyperlinkEvent event) {
			try {
				if ("def41".equals(event.getItem().getKey())) {
					String val = event.getValue().toString();
					if(val.indexOf("mypiaojia") != -1){
						IThOcrService  ocrservice = (IThOcrService) NCLocator.getInstance().lookup(IThOcrService.class.getName());
						val += "&token="+ocrservice.getToken(billmaker);
					}
					//改成使用默认浏览器
					//ClientToolKit.showDocument(new URL(val), "_blank");
					Desktop.getDesktop().browse(new URI(val));
				}
				if ("def22".equals(event.getItem().getKey())) {
					String val = event.getValue().toString();
	
					//改成使用默认浏览器
					//ClientToolKit.showDocument(new URL(val), "_blank");
					Desktop.getDesktop().browse(new URI(val));
				}
			} catch (Exception e) {
				ExceptionUtils.wrappBusinessException(e.getMessage());
			}
		
	}


}
