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.component;
 
 import java.util.List;
 
 
 public abstract class AbsComponentType implements IComponentType
 {
     protected ReportRequest rrequest;
 
     protected WabacusResponse wresponse;
     
     protected IComponentConfigBean comCfgBean;
 
     
     public AbsComponentType(AbsContainerType parentContainerType,IComponentConfigBean comCfgBean,ReportRequest rrequest)
     {
         this.=parentContainerType;
         this.=comCfgBean;
         this.=rrequest;
         if(rrequest!=null=rrequest.getWResponse();
     }
     
     public ReportRequest getReportRequest()
     {
         return ;
     }
     
     {
         return ;
     }
 
     public void setParentContainerType(AbsContainerType parentContainerType)
     {
         this.=parentContainerType;
     }
     
     {
         return this.;
     }
     
     protected boolean shouldDisplayMe()
     {
         if(!.checkPermission(this..getId(),null,null,.)) return false;
         AbsContainerConfigBean parentConfigBean=this..getParentContainer();
         while(parentConfigBean!=null)
         {
             if(!.checkPermission(parentConfigBean.getId(),null,null,.)) return false;
             if(!.checkPermission(parentConfigBean.getId(),.,null,.)) return false;
             parentConfigBean=parentConfigBean.getParentContainer();
         }
         return true;
     }
     
     protected String getTitleDisplayValue(String realtitle,String buttonsOnTitle)
     {
         realtitle=realtitle==null?"":realtitle.trim();
         buttonsOnTitle=buttonsOnTitle==null?"":buttonsOnTitle.trim();
         if(realtitle.equals("")&&buttonsOnTitle.equals("")) return "";
         String titlealign=null;
         if(!realtitle.trim().equals(""))
         {
             titlealign=.getTitlealign();
             titlealign=titlealign==null||titlealign.trim().equals("")?"left":titlealign.toLowerCase().trim();
         }
         String buttonalign=null;
         if(!buttonsOnTitle.trim().equals(""))
        {
            buttonsOnTitle="<span style=\"vertical-align:bottom;\">"+buttonsOnTitle+"</span>";
            buttonalign=.getButtonsBean().getAlign();
            buttonalign=buttonalign==null||buttonalign.trim().equals("")?"right":buttonalign.toLowerCase().trim();
        }
        StringBuffer resultBuf=new StringBuffer();
        resultBuf.append("<table class='cls-title-table' cellpadding='0' cellspacing='0' width='100%'>");
        resultBuf.append("<tr class='cls-title-tr'>");
        if(titlealign==null||buttonalign==null||titlealign.equals(buttonalign))
        {
            if(buttonalign==null)
            {
                resultBuf.append("<td align='"+titlealign+"'>");
                resultBuf.append(realtitle);
            }else if(titlealign==null)
            {
                resultBuf.append("<td align='"+buttonalign+"'>");
                resultBuf.append(buttonsOnTitle);
            }else
            {
                resultBuf.append("<td align='"+titlealign+"'>");
                if("left".equals(this..getButtonsBean().getTitleposition()))
                {
                    resultBuf.append(buttonsOnTitle);
                    resultBuf.append(WabacusAssistant.getInstance().getSpacingDisplayString(this..getButtonsBean().getButtonspacing()));
                }
                resultBuf.append(realtitle);
                if(!"left".equals(this..getButtonsBean().getTitleposition()))
                {
                    resultBuf.append(WabacusAssistant.getInstance().getSpacingDisplayString(this..getButtonsBean().getButtonspacing()));
                    resultBuf.append(buttonsOnTitle);
                }
            }
            resultBuf.append("</td>");
        }else
        {
            if(titlealign.equals("left"))
            {
                resultBuf.append("<td align='left' width='1%' nowrap>").append(realtitle).append("</td>");
                resultBuf.append("<td align='"+buttonalign+"' nowrap>").append(buttonsOnTitle).append("</td>");
            }else if(titlealign.equals("right"))
            {
                resultBuf.append("<td align='"+buttonalign+"' nowrap>").append(buttonsOnTitle).append("</td>");
                resultBuf.append("<td align='left' width='1%' nowrap>").append(realtitle).append("</td>");
            }else
            {
                if(buttonalign.equals("left")) resultBuf.append("<td align='left' width='1%' nowrap>").append(buttonsOnTitle).append("</td>");
                resultBuf.append("<td align='"+titlealign+"' nowrap>").append(realtitle).append("</td>");
                if(buttonalign.equals("right")) resultBuf.append("<td align='right' width='1%' nowrap>").append(buttonsOnTitle).append("</td>");
            }
        }
        resultBuf.append("</tr></table>");
        return resultBuf.toString();
    }
    
    {
        StringBuffer resultBuf=new StringBuffer();
        {
            String title=.getTitle();
            if(title!=null&&!title.trim().equals(""))
            {//需要显示title
                //resultBuf.append("<span class=\"cls-title\">").append(Tools.htmlEncode(title.trim())).append("</span>");
                resultBuf.append("<span class=\"cls-title\">").append(title.trim()).append("</span>");
            }
        }
        {
            String subtitle=.getSubtitle();
            if(subtitle!=null&&!subtitle.trim().equals(""))
            {
                if(resultBuf.length()>0)
                {
                    resultBuf.append("<span  style=\"margin-left:2px;\">&nbsp;</span>");
                }
                //resultBuf.append("<span class='cls-subtitle'>").append(Tools.htmlEncode(subtitle.trim())).append("</span>");
                resultBuf.append("<span class='cls-subtitle'>").append(subtitle.trim()).append("</span>");
            }
        }
        return resultBuf.toString();
    }
    
    public String showHeader()
    {
        StringBuffer resultBuf=new StringBuffer();
        if(this..getHeaderTplBean()==nullreturn "";
        resultBuf.append("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"");
        resultBuf.append("><tr><td>");
        String header=this.getRealHeaderFooterDisplayValue(this..getHeaderTplBean(),"header");
        if(header==null||header.trim().equals("")) return "";
        resultBuf.append(header);
        resultBuf.append("</td></tr></table>");
        return resultBuf.toString();
    }
    
    public String showFooter()
    {
        StringBuffer resultBuf=new StringBuffer();
        if(this..getFooterTplBean()==nullreturn "";
        resultBuf.append("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">");
        resultBuf.append("<tr><td>");
        String footer=getRealHeaderFooterDisplayValue(this..getFooterTplBean(),"footer");
        if(footer==null||footer.trim().equals("")) return "";
        resultBuf.append(footer);
        resultBuf.append("</td></tr></table>");
        return resultBuf.toString();
    }
    
    private String getRealHeaderFooterDisplayValue(TemplateBean headerFooterTpl,String type)
    {
        if(headerFooterTpl==nullreturn "";
        if(headerFooterTpl.getLstTagChildren()!=null&&headerFooterTpl.getLstTagChildren().size()>0)
        {
            return headerFooterTpl.getDisplayValue(,this);
        }
        String tplcontent=headerFooterTpl.getContent();
        if(tplcontent==null||tplcontent.trim().indexOf("i18n")!=0) return tplcontent;
        if(Tools.isDefineKey("i18n",tplcontent.trim()))
        {
            Object obj=.getI18NObjectValue(tplcontent.trim());
            if(obj==nullreturn "";
            if(!(obj instanceof TemplateBean)) return obj.toString();
            if("footer".equals(type))
            {
                ComponentAssistant.getInstance().validComponentFooterTpl(this.,(TemplateBean)obj);
            }else
            {
                ComponentAssistant.getInstance().validComponentHeaderTpl(this.,(TemplateBean)obj);
            }
            return ((TemplateBean)obj).getDisplayValue(,this);
        }
        return tplcontent;
    }
    
    protected String showContextMenu()
    {
        if(!this..shouldShowContextMenu()) return "";
        if(lstMenuButtons==null||lstMenuButtons.size()==0) return "";
        String prevgroup=null;
        String menustr;
        StringBuffer menuBuffer=new StringBuffer();
        for(AbsButtonType menuButton:lstMenuButtons)
        {
            if(menuButton==nullcontinue;
            menustr=ComponentAssistant.getInstance().showButtonMenu(this.,menuButton,,null);
            if(menustr==null||menustr.trim().equals("")) continue;
            if(prevgroup!=null)
            {
                if(!prevgroup.equals(menuButton.getMenugroup()))
                {
                    menuBuffer.append("<hr/>");
                    prevgroup=menuButton.getMenugroup();
                }
            }else
            {
                prevgroup=menuButton.getMenugroup();
            }
            menuBuffer.append(menustr);
        }
        menustr=menuBuffer.toString();
        if(menustr.endsWith("<hr/>"))
        {
            menustr=menustr.substring(0,menustr.length()-5);
        }
        menuBuffer=new StringBuffer();
        menuBuffer.append("<DIV class=\"contextmenu\" id=\"contextmenu_"+this..getGuid()+"\"");
        if(menustr.trim().equals(""))
        {
            menuBuffer.append(" isEmpty=\"true\"");
        }else
        {
            menuBuffer.append(" onmouseover=\"try{highlightmenuitem(event);}catch(e){}\"  onmouseout=\"try{lowlightmenuitem(event);}catch(e){}\"");
        }
        menuBuffer.append(">"+menustr+"</DIV>");
        return menuBuffer.toString();
    }
    
    protected String showMetaData()
    {
        if(.getShowtype()!=.return "";
        if(.getStringAttribute(this..getGuid()+"_showMetaData","").equals("true")) return "";
        .setAttribute(this..getGuid()+"_showMetaData","true");
        StringBuffer resultBuf=new StringBuffer();
        resultBuf.append(showMetaDataDisplayStringStart()).append(">");
        resultBuf.append(showMetaDataContentDisplayString());
        resultBuf.append("</span>");
        resultBuf.append(showContextMenu());
        return resultBuf.toString();
    }
    
    {
        StringBuffer resultBuf=new StringBuffer();
        resultBuf.append("<span id=\"").append(this..getGuid()).append("_metadata\" style=\"display:none;\"");
        resultBuf.append(" pageid=\"").append(this..getPageBean().getId()).append("\"");
        resultBuf.append(" componentid=\"").append(this..getId()).append("\"");
        resultBuf.append(" refreshComponentGuid=\"").append(this..getRefreshGuid()).append("\"");
        resultBuf.append(" componentTypeName=\"").append(getComponentTypeName()).append("\"");
        return resultBuf.toString();
    }
    protected abstract String getComponentTypeName();
    
    {
        return "";
    }
    
    public static IComponentType createComponentTypeObj(Class componentClass,AbsContainerType parentContainer,IComponentConfigBean ccbean,
            ReportRequest rrequest)
    {
        if(componentClass==nullreturn null;
        try
        {
            return (IComponentType)componentClass.getConstructor(
                    new Class[] { AbsContainerType.classIComponentConfigBean.classReportRequest.class }).newInstance(
                    new Object[] { parentContainerccbeanrrequest });
        }catch(Exception e)
        {
            throw new WabacusConfigLoadingException("创建组件"+componentClass.getName()+"对象失败",e);
        }
    }
New to GrepCode? Check out our FAQ X