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.config.component;
 
 import java.util.List;
 import java.util.Map;
 
 
 {
     private final static ComponentConfigLoadAssistant instance=new ComponentConfigLoadAssistant();
 
     private ComponentConfigLoadAssistant()
     {}
 
     public static ComponentConfigLoadAssistant getInstance()
     {
         return ;
     }
 
     public void checkAndAddButtons(ReportBean reportbean,Class buttonType,String defaultkey)
     {
         ButtonsBean bbeans=reportbean.getButtonsBean();
         if(bbeans==null)
         {
             bbeans=new ButtonsBean(reportbean);
             reportbean.setButtonsBean(bbeans);
         }
         List<AbsButtonTypelstButtons=bbeans.getAllCertainTypeButtonsList(buttonType);
         if((lstButtons==null||lstButtons.size()==0)&&defaultkey!=null&&!defaultkey.trim().equals(""))
         {
             AbsButtonType buttonObj=Config.getInstance().getResourceButton(null,reportbean,defaultkey,buttonType);
             if(buttonObj.getName()==null||buttonObj.getName().trim().equals(""))
             {
                 buttonObj.setName(buttonType.getName()+"_"+(int)(Math.random()*10000));
             }
             ComponentConfigLoadManager.addButtonToPositions(reportbean,buttonObj);
         }
     }
     
     public String createComponentRefreshGuidByRefreshId(PageBean pbean,String componentId,String refreshid)
     {
         IComponentConfigBean ccbean=pbean.getChildComponentBean(componentId,true);
         if(ccbean==nullthrow new WabacusRuntimeException("在页面"+pbean.getId()+"中没有取到id为"+componentId+"的组件");
         if(refreshid==null||refreshid.trim().equals("")) refreshid=componentId;
         String refreshGuid=null;
         if(refreshid.equals(pbean.getId()))
         {
             refreshGuid=pbean.getGuid();
         }else if(refreshid.equals(componentId))
         {
             refreshGuid=ccbean.getGuid();
         }else
         {
             IComponentConfigBean refreshContainerObj=pbean.getChildComponentBean(refreshid,true);
             if(!(refreshContainerObj instanceof AbsContainerConfigBean))
             {
                 throw new WabacusRuntimeException("生成组件"+ccbean.getGuid()+"的refreshGuid失败,其refreshid:"+refreshid+"即不是自己的ID,也不是父容器的ID");
             }
             refreshGuid=((AbsContainerConfigBean)refreshContainerObj).getChildRefreshGuid(componentId);
         }
         return refreshGuid;
     }
     
     public void validateApplicationRefreshid(IApplicationConfigBean applicationBean)
     {
         if(applicationBean.getRefreshid()==null||applicationBean.getRefreshid().trim().equals("")) return;
        if(applicationBean.getRefreshid().trim().equals(applicationBean.getId())) return;
        IComponentConfigBean refreshComponentBean=null;
        if(applicationBean.getPageBean().getId().equals(applicationBean.getRefreshid()))
        {
            refreshComponentBean=applicationBean.getPageBean();
        }else
        {
            refreshComponentBean=applicationBean.getPageBean().getChildComponentBean(applicationBean.getRefreshid(),true);
        }
        if(refreshComponentBean==null)
        {
            throw new WabacusConfigLoadingException(applicationBean.getPath()+"的refreshid:"+applicationBean.getRefreshid()+"对应的组件不存在");
        }
        if(!(refreshComponentBean instanceof AbsContainerConfigBean))
        {
            throw new WabacusConfigLoadingException(applicationBean.getPath()+"的refreshid:"+applicationBean.getRefreshid()
                    +"对应的组件不是容器,不能将其它应用配置为此应用的刷新组件");
        }
        if(((AbsContainerConfigBean)refreshComponentBean).getChildComponentBean(applicationBean.getId(),true)==null)
        {
            throw new WabacusConfigLoadingException(applicationBean.getPath()+"的refreshid:"+applicationBean.getRefreshid()+"对应的容器不是当前应用的父容器");
        }
    }
    
    public boolean isStaticTemplateResource(String template)
    {
        if(Tools.isDefineKey("classpath",template)) return true;
        if(Tools.isDefineKey("$",template)) return true;
        if(Tools.isDefineKey("absolute",template)) return true;
        if(Tools.isDefineKey("relative",template)) return true;
        
        return false;
    }
    
    {
        TemplateBean tplBean=null;
        template=template==null?"":template.trim();
        if(Tools.isDefineKey("$",template))
        {
            tplBean=(TemplateBean)Config.getInstance().getResourceObject(null,pbean,template,true);
        }else
        {//取html/htm文件中的模板
            tplBean=Config.getInstance().getFileTemplate(template);
            if(tplBean==null)
            {
                tplBean=TemplateParser.parseTemplateByPath(template);
                if(tplBean!=null) Config.getInstance().addFileTemplate(template,tplBean);
            }
        }
        return tplBean;
    }
    
    public Object[] parseIncludeApplicationids(IComponentConfigBean ccbeanOwner,List<StringlstConfigApplicationids)
    {
        if(ccbeanOwner instanceof AbsContainerConfigBean)
        {
            if(lstConfigApplicationids==null||lstConfigApplicationids.size()==0)
            {
                lstConfigApplicationids=((AbsContainerConfigBean)ccbeanOwner).getLstAllChildApplicationIds(true);
            }
        }else if(lstConfigApplicationids==null||lstConfigApplicationids.size()==0)
        {
            lstConfigApplicationids=new ArrayList<String>();
            lstConfigApplicationids.add(ccbeanOwner.getId());
            
        }
        StringBuffer appidsBuf=new StringBuffer();
        List<StringlstAppids=new ArrayList<String>();
        Map<String,IntegermReportidsAndPagesize=new HashMap<String,Integer>();
        for(String appidTmp:lstConfigApplicationids)
        {
            if(appidTmp==null||appidTmp.trim().equals("")||lstAppids.contains(appidTmp.trim())) continue;
            appidTmp=appidTmp.trim();
            int idxLeft=appidTmp.indexOf("{");
            int idxRight=appidTmp.indexOf("}");
            int ipagesize=.;
            if(idxLeft>0&&idxRight==appidTmp.length()-1)
            {
                String pagesize=appidTmp.substring(idxLeft+1,idxRight).trim();
                appidTmp=appidTmp.substring(0,idxLeft).trim();
                if(appidTmp.equals("")) continue;
                if(!pagesize.equals("")) ipagesize=Integer.parseInt(pagesize);
            }
            ReportBean rbean=ccbeanOwner.getPageBean().getReportChild(appidTmp,true);
            if(rbean!=nullmReportidsAndPagesize.put(appidTmp,ipagesize);//当前应用是报表
            if(ccbeanOwner.getPageBean().getApplicationChild(appidTmp,true)==null)
            {
                throw new WabacusConfigLoadingException("加载组件"+ccbeanOwner.getPath()+"上的打印配置失败,其include属性配置的应用ID"+appidTmp+"不存在");
            }
            lstAppids.add(appidTmp);
            appidsBuf.append(appidTmp+";");
        }
//        {//如果是报表,且没有在include中指定其id,则加上
//            mReportidsAndPagesize.put(ccbeanOwner.getId(),Integer.MIN_VALUE);//用默认值
        return new Object[] { appidsBuf.toString(), lstAppidsmReportidsAndPagesize };
    }
    
    public List<ConditionBeancloneLstConditionBeans(AbsConfigBean parent,List<ConditionBeanlstConditions)
    {
        if(lstConditions==nullreturn null;
        List<ConditionBeanlstConNew=new ArrayList<ConditionBean>();
        for(ConditionBean cbTmp:lstConditions)
        {
            lstConNew.add((ConditionBean)cbTmp.clone(parent));
        }
        return lstConNew;
    }
New to GrepCode? Check out our FAQ X