Example #1
0
  /**
   * @param child
   * @param govVector
   * @param objLevel
   * @param govLevel
   * @param classindices
   * @param typeindices
   * @param classname
   * @return NULL if error occurs relating to gorInfo creation, or NULL if object is NOT to be
   *     processed. Otherwise, return a valid ClassTypeInfo object with all appropriate settings.
   */
  protected ClassTypeInfo incrementClassTypeIndices(
      Object child,
      GuiObjectVector govVector,
      int govLevel,
      int objLevel,
      Hashtable classindices,
      Hashtable typeindices,
      String classname) {
    Log.info("GCI: getting child GOR info. GOV level:" + govLevel);
    ClassTypeInfo cti = new ClassTypeInfo();
    final String TOOLTIP_SUFFIX = "TOOLTIP";
    cti.classname = classname;
    try {
      cti.gorInfo = govVector.getChildGuiObjectRecognition(govLevel);
    } catch (ArrayIndexOutOfBoundsException x) {
      Log.debug(
          "GCI: sought govLevel:"
              + govLevel
              + ", exceeds 0-based recognition path information:"
              + govVector.getPathVector());
      return null;
    }
    GuiClassData classdata = govVector.getGuiClassData();
    cti.typeclass = classdata.getMappedClassType(classname, child);

    // bypass panels that harbor tooltip(s)
    Object tooltip = null;
    String tooltipclass = null;
    String tooltipmapped = null;
    String gortypeclass = cti.gorInfo.getClassValue();
    // only perform check if we are NOT looking for a tooltip
    if ((gortypeclass == null)
        || (gortypeclass != null && !gortypeclass.toUpperCase().endsWith(TOOLTIP_SUFFIX))) {
      try {
        Log.info("GCI.incrementClassTypeIndices evaluating possible TOOLTIP container...");
        if (classdata.isToolTipContainerType(cti.typeclass)) {
          Object[] childsChildren = govVector.getChildObjects(child);
          if (childsChildren != null && childsChildren.length > 0) {
            tooltip = childsChildren[0];
            tooltipclass = cti.gorInfo.getObjectClassName(tooltip);
            try {
              if (tooltipclass.toUpperCase().endsWith(TOOLTIP_SUFFIX)) {
                Log.info("GCI.incrementClassTypeIndices bypassing active TOOLTIP class!");
                return null; // skip panel with tooltip
              }
              tooltipmapped = classdata.getMappedClassType(tooltipclass, tooltip);
              if (tooltipmapped.toUpperCase().endsWith(TOOLTIP_SUFFIX)) {
                Log.info("GCI.incrementClassTypeIndices bypassing active TOOLTIP type!");
                return null; // skip panel with tooltip
              }
            } catch (Exception x) {
              Log.debug(
                  "GCI.incrementClassTypeIndices ToolTip test IGNORING "
                      + x.getClass().getSimpleName());
            }
          }
        }
        Log.info("GCI.incrementClassTypeIndices container NOT a TOOLTIP container.");
      } catch (Exception x) {
        Log.debug(
            "GCI.incrementClassTypeIndices ToolTip Container test IGNORING "
                + x.getClass().getSimpleName());
      }
    }
    // increment class index counters for the retrieved class?
    Log.info("GCI: incrementing class indices for:" + classname);
    Integer classindex = (Integer) classindices.get(classname);
    classindex = (classindex == null) ? new Integer(1) : new Integer(classindex.intValue() + 1);
    classindices.put(classname, classindex);
    cti.classindex = classindex.intValue();
    Log.info("GCI: classindices.put(" + classname + ", " + classindex + ")");

    Integer absclassindex = (Integer) absindices.get(classname);
    absclassindex =
        (absclassindex == null) ? new Integer(1) : new Integer(absclassindex.intValue() + 1);
    absindices.put(classname, absclassindex);
    cti.absoluteclassindex = absclassindex.intValue();
    Log.info("GCI: absindices.put(" + classname + ", " + absclassindex + ")");

    // also increment the Type index counter if it is equivalent to a known type
    String gorClassType = cti.gorInfo.getClassValue();
    Log.info("GCI: " + classname + " mappedClassType: " + cti.typeclass);
    Integer typeindex = new Integer(0);
    Integer abstypeindex = new Integer(0);

    if (cti.typeclass instanceof String) {
      StringTokenizer toker = new StringTokenizer(cti.typeclass, classdata.DEFAULT_TYPE_SEPARATOR);
      String atoken = null;
      Integer tmptypeindex = null;
      Integer tmpabstypeindex = null;

      while (toker.hasMoreTokens()) {
        atoken = toker.nextToken().toUpperCase().trim();
        tmptypeindex = (Integer) typeindices.get(atoken);
        Log.info("GCI: getting: " + atoken + ", " + tmptypeindex);
        tmptypeindex =
            (tmptypeindex == null) ? new Integer(1) : new Integer(tmptypeindex.intValue() + 1);
        Log.index(
            "GCI: ... "
                + StringUtils.getSpaces(new Integer(objLevel))
                + atoken
                + ":"
                + tmptypeindex);
        typeindices.put(atoken, tmptypeindex);
        tmpabstypeindex = (Integer) absindices.get(atoken);
        tmpabstypeindex =
            (tmpabstypeindex == null)
                ? new Integer(1)
                : new Integer(tmpabstypeindex.intValue() + 1);
        absindices.put(atoken, tmpabstypeindex);
        Log.info("TYPE:absindices.put(" + atoken + ", " + tmpabstypeindex + ")");

        // use the correct typeindex for the classtype that matches recognition string
        if (atoken.equalsIgnoreCase(gorClassType)) {
          typeindex = tmptypeindex;
          cti.typeindex = typeindex.intValue();
          abstypeindex = tmpabstypeindex;
          cti.absolutetypeindex = abstypeindex.intValue();
        }
      }
    }
    return cti;
  }