/*
*
* @param jspUrl gwt jspUrl hr_Jsp jsp ,
* jspUrl jsp 。
* frame.el().setElementAttribute("src","hr_Jsp/rpt" + jspUrl+ ".jsp?data=" + data);
* @param data gwt
*/
public class ReportPrintDialog implements ClickHandler,Listener<BaseEvent>{
public Dialog d = new Dialog();
com.extjs.gxt.ui.client.widget.FramePanel frame = com.extjs.gxt.ui.client.widget.FramePanel.pop();
boolean autoprint = false;
boolean autocancel = false;
int autoprintmsecond = 7;
Html message = new Html("");
private String jspUrl;
private String data;
public ReportPrintDialog(){
init();
}
public void init(){
initWidget();
}
public void initWidget(){
frame.setId("__printingFrameX");
frame.setBorders(false);
d.setHeading(" ");
d.setIcon(AbstractImagePrototype.create(BaseResource.INSTANCE.print_16()));
d.setLayout(new RowLayout(Orientation.HORIZONTAL));
d.add(frame);
d.setSize(1024, 768);
d.setButtons(Dialog.YESNO);
d.getButtonById(Dialog.YES).setText(" ");
d.getButtonById(Dialog.NO).setText(" ");
d.getButtonById(Dialog.YES).setIcon(AbstractImagePrototype.create(BaseResource.INSTANCE.print_16()));
d.getButtonById(Dialog.YES).addListener(Events.Select, this);
d.getButtonById(Dialog.NO).addListener(Events.Select, this);
if(autoprint)
d.getButtonBar().add(message);
d.addDomHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
autocancel=true;
}} , ClickEvent.getType());
}
public com.extjs.gxt.ui.client.widget.FramePanel getFramePanel(){
com.extjs.gxt.ui.client.widget.FramePanel frame=this.frame;
return frame;
}
public void show(){
d.show();
d.setFocusWidget(d.getButtonById(Dialog.YES));
frame.el().setSize(1010, 750);
load();
if(autoprint){
Timer t = new Timer() {
int i = 0;
public void run() {
i++;
if(i >= autoprintmsecond){
cancel();
print();
message.setHtml("<a style=\"font-size: 14pt;\"><font color=\"#ff0000\"> </font> </a>");
}
if(autocancel){
cancel();
message.setHtml("");
}
else{
message.setHtml("<a style=\"font-size: 14pt;\"><font color=\"#ff0000\"> "+(autoprintmsecond-i)+" </font> </a>");
}
}
};
t.scheduleRepeating(1000);
}
}
@Override
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
}
@Override
public void handleEvent(BaseEvent be) {
// TODO Auto-generated method stub
if(be.getSource().equals(d.getButtonById(Dialog.NO))){
d.hide();
}
else if(be.getSource().equals(d.getButtonById(Dialog.YES))){
print();
}
}
public void print(){
if (GXT.isIE) {
printFrame_IE();
}
else{
printFrame();
}
}
// ie
public static native void printFrame() /*-{
var iframe = $doc.frames ? $doc.frames['__printingFrameX'] : $doc.getElementById('__printingFrameX');
var ifWin = iframe.contentWindow || iframe;
ifWin.print();
}-*/;
//ie frame
public static native void printFrame_IE()/*-{
$wnd.frames['__printingFrameX'].focus();
$wnd.frames['__printingFrameX'].print();
}-*/;
public void load(){
frame.el().setElementAttribute("src","hr_Jsp/rpt" + jspUrl+ ".jsp?data=" + data);
System.out.println("*******************" + "hr_Jsp/rpt" + jspUrl+ ".jsp?data=" + data);
}
public String getJspUrl() {
return jspUrl;
}
public void setJspUrl(String jspUrl) {
this.jspUrl = jspUrl;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
}