Пример #1
0
 /** Sets the render modes from annot. */
 protected void setRenderModesFromAnnot() {
   List<MacroInfo> allanots =
       de.micromata.genome.util.runtime.ClassUtils.findClassAnnotations(
           getClass(), MacroInfo.class);
   for (MacroInfo mi : allanots) {
     if (mi.renderFlags().length > 0) {
       int flags = 0;
       for (GWikiMacroRenderFlags rf : mi.renderFlags()) {
         flags |= rf.getFlag();
       }
       setRenderModes(flags);
       return;
     }
   }
 }
Пример #2
0
  @Override
  public GWikiMacroInfo getMacroInfo() {
    if (GWikiMacroWithInfo.class.isAssignableFrom(clazz) == true) {
      return ((GWikiMacroWithInfo) createInstance()).getMacroInfo();
    }

    List<MacroInfo> anots =
        de.micromata.genome.util.runtime.ClassUtils.findClassAnnotations(clazz, MacroInfo.class);
    //    Map<String, MacroParamInfo> params = new HashMap<>();
    List<MacroParamInfo> paramlist = new ArrayList<>();
    Set<String> paramNames = new HashSet<>();
    String info = null;
    int renderFlags = 0;
    for (MacroInfo mi : anots) {
      if (StringUtils.isBlank(info) == true) {
        info = mi.info();
      }
      for (MacroInfoParam pi : mi.params()) {
        if (paramNames.contains(pi.name()) == true) {
          continue;
        }
        paramNames.add(pi.name());

        paramlist.add(new MacroParamInfo(pi));
      }
      for (GWikiMacroRenderFlags rf : mi.renderFlags()) {
        renderFlags |= rf.getFlag();
      }
    }
    int collectedRenderFlags = renderFlags;
    String macinfo = info;
    GWikiMacroClassFactory fac = this;
    return new GWikiMacroInfoBase() {

      @Override
      public String getInfo() {
        return macinfo;
      }

      @Override
      public boolean hasBody() {
        return fac.hasBody();
      }

      @Override
      public boolean evalBody() {
        return fac.evalBody();
      }

      @Override
      public boolean isRteMacro() {
        return fac.isRteMacro();
      }

      @Override
      public List<MacroParamInfo> getParamInfos() {
        return paramlist;
      }

      @Override
      public int getRenderFlags() {
        return collectedRenderFlags;
      }
    };
  }