Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* 
   * Copyright (C) 2010---2013 星星(wuweixing)<349446658@qq.com>
   * 
   * This file is part of Wabacus 
   * 
   * Wabacus is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Lesser General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 package com.wabacus.system.buttons;
 
 import java.util.List;
 
 
 public class DataExportButton extends WabacusButton
 {
     private String dataexporttype;
     
     public DataExportButton(IComponentConfigBean ccbean)
     {
         super(ccbean);
     }
 
     public String getDataexporttype()
     {
         return ;
     }
 
     public void setDataexporttype(String dataexporttype)
     {
         this.=dataexporttype;
     }
 
     public String getButtonType()
     {
         return ;
     }
     
     public boolean isExportBySpecifyApplicationids()
     {
         if(this.==nullreturn false;
         if(this. instanceof IButtonClickeventGeneratereturn true;//在<button/>标签内容中指定了要导出的应用
         if(this..toString().trim().equals("")) return false;
         return true;
     }
     
     public String showButton(ReportRequest rrequest,String dynclickevent)
     {
         return super.showButton(rrequest,getDataExportClickEvent(rrequest,null,this.));
     }
     
     public String showButton(ReportRequest rrequest,String dynclickevent,String button)
     {
         return super.showButton(rrequest,getDataExportClickEvent(rrequest,null,this.),button);
     }
 
     public String showMenu(ReportRequest rrequest,String dynclickevent)
     {
         return super.showMenu(rrequest,getDataExportClickEvent(rrequest,null,this.));
     }
 
     public String showButton(ReportRequest rrequest,String dataexporttype,String exportComponentIds,String button)
     {
         return super.showButton(rrequest,getDataExportClickEvent(rrequest,exportComponentIds,dataexporttype),button);
     }
     
     private String getDataExportClickEvent(ReportRequest rrequest,String exportComponentIds,String dataexporttype)
     {
         if(exportComponentIds==null||exportComponentIds.trim().equals(""))
         {
             exportComponentIds=this.getClickEvent(rrequest);//取到在<button></button>中指定的要导出的应用
         }
         if(exportComponentIds==null||exportComponentIds.trim().equals(""))
         {//如果即没有动态传入要导出的应用,也没有在<button/>中指定要导出的应用,则导出本组件
             if(this.==nullreturn "";
             exportComponentIds=this..getId();
         }
         List<StringlstTmp=Tools.parseStringToList(exportComponentIds,";",false);
         List<IComponentConfigBeanlstDataExportComBeans=new ArrayList<IComponentConfigBean>();
        IComponentConfigBean ccbeanTmp;
        for(String comidTmp:lstTmp)
        {
            if(comidTmp==null||comidTmp.trim().equals("")) continue;
            if(!rrequest.checkPermission(comidTmp,.,"type{"+dataexporttype+"}",.)) continue;
            if(rrequest.checkPermission(comidTmp,.,"type{"+dataexporttype+"}",.)) continue;
            if(comidTmp.equals(rrequest.getPagebean().getId()))
            {
                ccbeanTmp=rrequest.getPagebean();
            }else
            {
                ccbeanTmp=rrequest.getPagebean().getChildComponentBean(comidTmp,true);
            }
            if(ccbeanTmp==nullthrow new WabacusRuntimeException("在页面"+rrequest.getPagebean().getId()+"中不存在id为"+comidTmp+"的组件,无法导出其数据");
            lstDataExportComBeans.add(ccbeanTmp);
        }
        if(lstDataExportComBeans.size()==0) return "";
        ReportBean rbean=null;
        String componentids="";
        String includeApplicationids="";
        if(lstDataExportComBeans.size()==1&&lstDataExportComBeans.get(0) instanceof ReportBean)
        {
            rbean=(ReportBean)lstDataExportComBeans.get(0);
            componentids=rbean.getId();
            if(rbean.getDataExportsBean()==null)
            {
                includeApplicationids=rbean.getId();
            }else
            {
                includeApplicationids=rbean.getDataExportsBean().getIncludeApplicationids(dataexporttype);
                if(includeApplicationids==null||includeApplicationids.trim().equals("")) includeApplicationids=rbean.getId();
            }
        }else
        {
            String includeAppidsTmp;
            for(IComponentConfigBean ccbean:lstDataExportComBeans)
            {
                componentids+=ccbean.getId()+";";
                includeAppidsTmp=null;
                if(ccbean.getDataExportsBean()!=null)
                {
                    includeAppidsTmp=ccbean.getDataExportsBean().getIncludeApplicationids(dataexporttype);
                }
                if(includeAppidsTmp==null||includeAppidsTmp.trim().equals(""))
                {
                    includeAppidsTmp="";
                    if(ccbean instanceof AbsContainerConfigBean)
                    {
                        List<StringlstApplicationids=((AbsContainerConfigBean)ccbean).getLstAllChildApplicationIds(true);
                        for(String appidTmp:lstApplicationids)
                        {
                            includeAppidsTmp+=appidTmp+";";
                        }
                    }else
                    {
                        includeAppidsTmp=ccbean.getId()+";";
                    }
                }
                includeApplicationids+=includeAppidsTmp;
                if(!includeApplicationids.endsWith(";")) includeApplicationids=includeApplicationids+";";
            }
        }
        return getDataExportEvent(rrequest,rbean,componentids,includeApplicationids,dataexporttype);
    }
    
    private String getDataExportEvent(ReportRequest rrequest,ReportBean rbean,String componentids,String includeApplicationids,String exporttype)
    {
        String clickevent=null;
        String exporturl=null;
        if(..equals(exporttype.toLowerCase().trim()))
        {
            exporturl=.;
        }else if(..equals(exporttype.toLowerCase().trim()))
        {
            exporturl=.;
        }else if(..equals(exporttype.toLowerCase().trim()))
        {
            exporturl=.;
        }else
        {//Consts.DATAEXPORT_RICHEXCEL
            exporturl=.;
        }
        if(rbean!=null&&rbean.getDbean().isColselect())
        {
            StringBuffer paramsBuf=new StringBuffer();
            paramsBuf.append("{reportguid:\"").append(rbean.getGuid()).append("\"");
            paramsBuf.append(",includeApplicationids:\"").append(includeApplicationids).append("\"");
            paramsBuf.append(",skin:\"").append(rrequest.getPageskin()).append("\"");
            paramsBuf.append(",webroot:\"").append(.).append("\"");
            paramsBuf.append(",width:").append(rbean.getDbean().getColselectwidth());
            paramsBuf.append(",maxheight:").append(rbean.getDbean().getColselectmaxheight());
            paramsBuf.append(",showreport_onpage_url:\"").append(.).append("\"");
            paramsBuf.append(",showreport_dataexport_url:\"").append(exporturl).append("\"");
            paramsBuf.append("}");
            clickevent="createTreeObjHtml(this,'"+Tools.jsParamEncode(paramsBuf.toString())+"',event);";
        }else
        {
            
            clickevent="exportData('"+rrequest.getPagebean().getId()+"','"+componentids+"','"+includeApplicationids+"','"
                    +.+"','"+exporturl+"');";
        }
        return clickevent;
    }
    public void loadExtendConfig(XmlElementBean eleButtonBean)
    {
        super.loadExtendConfig(eleButtonBean);
        String dataexporttype=eleButtonBean.attributeValue("type");
        if(dataexporttype==null||dataexporttype.trim().equals(""))
        {
            throw new WabacusConfigLoadingException("加载报表"+.getPath()+"上的按钮"+this.
                    +"失败,此按钮为数据导出按钮,必须配置其dataexporttype属性,指定本按钮的数据导出类型");
        }
        dataexporttype=dataexporttype.trim();
        if(!..contains(dataexporttype))
        {
            throw new WabacusConfigLoadingException("加载报表"+.getPath()+"上的按钮"+this.+"失败,为此数据导出按钮配置的dataexporttype:"
                    +dataexporttype+"无效");
        }
        this.=dataexporttype;
    }    
New to GrepCode? Check out our FAQ X