private final int getColumnIndex(final String columnName) {
    final int elementId = getAD_Element_ID(columnName);

    for (int i = 0; i < displayedInfoColumns.size(); i++) {
      final I_AD_InfoColumn ic = displayedInfoColumns.get(i);
      if (elementId == ic.getAD_Element_ID()) {
        return i;
      }
    }
    return -1;
  }
 private static int getIndexByColumnName(
     final List<I_AD_InfoColumn> infoColumns, final String columnName) {
   for (int i = 0; i < infoColumns.size(); i++) {
     final I_AD_InfoColumn ic = infoColumns.get(i);
     final String icColumnName = ic.getColumnName();
     if (columnName.equals(icColumnName)) {
       return i;
     }
   }
   return -1;
 }
 public final IInfoQueryCriteria getParameterByColumnNameOrNull(final String columnName) {
   Check.assumeNotEmpty(columnName, "columnName not null");
   for (final IInfoQueryCriteria param : displayedParameters) {
     final I_AD_InfoColumn infoColumn = param.getAD_InfoColumn();
     final String infoColumnName = infoColumn.getColumnName();
     if (columnName.equals(infoColumnName)) {
       return param;
     }
   }
   return null;
 }
        private void windowOpened0(final IInfoQueryCriteria parameter) {
          final I_AD_InfoColumn infoColumn = parameter.getAD_InfoColumn();
          if (infoColumn == null) {
            return; // shall not happen...
          }

          final String defaultValue = infoColumn.getDefaultValue();

          // search for first not null component
          for (int i = 0; i < parameter.getParameterCount(); i++) {
            final Component editor = getEditorComponentOrNull(parameter, i);
            if (editor == null) {
              continue;
            }

            // add general listeners on parameter components
            editor.addKeyListener(
                new KeyAdapter() {
                  @Override
                  public void keyReleased(final KeyEvent e) {
                    if (KeyEvent.VK_ENTER == e.getKeyCode()) {
                      // each field shall execute query on enter
                      executeQuery();
                    }
                  }
                });

            // we are focusing on field which as "SearchText" as default value
            if (defaultValue == null || defaultValue.indexOf(ATTR_SearchText) < 0) {
              return;
            }

            editor.requestFocus();

            final String text = parameter.getText();
            if (!Check.isEmpty(text, true)) {
              executeQueryOnInit();
            }
          }
        }
  private IInfoQueryCriteria getInfoQueryCriteria(
      final I_AD_InfoColumn infoColumn, final boolean getDefaultIfNotFound) {
    final int infoColumnId = infoColumn.getAD_InfoColumn_ID();
    if (criteriasById.containsKey(infoColumnId)) {
      return criteriasById.get(infoColumnId);
    }

    final IInfoQueryCriteria criteria;
    final String classname = infoColumn.getClassname();
    if (Check.isEmpty(classname, true)) {
      if (getDefaultIfNotFound) {
        criteria = new InfoQueryCriteriaGeneral();
      } else {
        return null;
      }
    } else {
      criteria = Util.getInstance(IInfoQueryCriteria.class, classname);
    }

    criteria.init(this, infoColumn, searchText);
    criteriasById.put(infoColumnId, criteria);

    return criteria;
  }
  private Info_Column createColumnInfo(final I_AD_InfoColumn field) {
    final Properties ctx = getCtx();

    String columnName = field.getAD_Element().getColumnName();
    String name = msgBL.translate(ctx, columnName);
    final int displayType = field.getAD_Reference_ID();
    Class<?> colClass = DisplayType.getClass(displayType, true);
    String colSQL =
        Check.isEmpty(field.getDisplayField(), true)
            ? field.getSelectClause()
            : field.getDisplayField();
    String idColSQL = null;

    if (DisplayType.isLookup(field.getAD_Reference_ID())) {
      colClass = KeyNamePair.class;
      idColSQL = field.getSelectClause();
      final String displayColumnSQL =
          MLookupFactory.getLookupEmbed(
              ctx,
              colSQL, // BaseColumn
              null, // BaseTable
              field.getAD_Reference_ID(),
              field.getAD_Reference_Value_ID());
      if (!Check.isEmpty(displayColumnSQL, true)) {
        colSQL = "(" + displayColumnSQL + ")";
      }
    }
    if (DisplayType.List == field.getAD_Reference_ID()) {
      columnName = field.getName();
    }
    if (columnName.endsWith("_ID")
        && DisplayType.ID == field.getAD_Reference_ID()) // should be only ID, 02883
    {
      name = " ";
      colClass = IDColumn.class;
    }

    final Info_Column ic = new Info_Column(name, columnName, colClass);
    ic.setDisplayType(displayType);
    ic.setIDcolSQL(idColSQL);
    ic.setColSQL(colSQL);
    ic.setColumnName(columnName);

    //
    // Check/Load Column Controller
    final IInfoColumnController columnController = getInfoColumnControllerOrNull(field);
    if (columnController != null) {
      ic.setColumnController(columnController);
      columnController.customize(this, ic);
    }

    return ic;
  }
  private void initInfo() {
    displayedInfoColumns = adInfoWindowDAO.retrieveDisplayedColumns(infoWindow);

    final Info_Column[] layout = new Info_Column[displayedInfoColumns.size()];

    //
    // Setup Layout
    int keyColumnIndex = -1;
    for (int i = 0; i < displayedInfoColumns.size(); i++) {
      final I_AD_InfoColumn field = displayedInfoColumns.get(i);
      layout[i] = createColumnInfo(field);
      if (layout[i].getColClass() == IDColumn.class && !field.isTree()) {
        keyColumnIndex = i;
      }
    }

    // No KeyColumnIndex found. Pick the first ID column
    if (keyColumnIndex < 0) {
      int count = 0;
      for (final Info_Column infoColumn : layout) {
        if (infoColumn.isIDcol()) {
          keyColumnIndex = count;
          break;
        } else {
          count++;
        }
      }
    }

    //
    // Setup dependent columns
    // NOTE: we need to do this after we initialized the layout
    for (int i = 0; i < displayedInfoColumns.size(); i++) {
      final Info_Column infoColumn = layout[i];
      final IInfoColumnController columnController = infoColumn.getColumnController();
      if (columnController == null) {
        continue;
      }
      final List<String> dependsOnColumnNames = columnController.getDependsOnColumnNames();
      if (dependsOnColumnNames == null || dependsOnColumnNames.isEmpty()) {
        continue;
      }

      for (final String dependsOnColumnName : dependsOnColumnNames) {
        final int dependsOnColumnIndex =
            getIndexByColumnName(displayedInfoColumns, dependsOnColumnName);
        if (dependsOnColumnIndex < 0) {
          log.log(
              Level.WARNING,
              "Cannot find column name '"
                  + dependsOnColumnName
                  + "' required as dependency for "
                  + columnController);
          continue;
        }

        final List<Info_Column> dependentColumns =
            layout[dependsOnColumnIndex].getDependentColumns();
        if (!dependentColumns.contains(infoColumn)) {
          dependentColumns.add(infoColumn);
        }
      }
    }

    // Create Grid
    final StringBuffer where = new StringBuffer();
    where.append(infoWindow.getOtherClause());
    if (!Check.isEmpty(p_whereClause, true)) {
      if (!Check.isEmpty(where.toString())) {
        where.append(" AND ");
      }
      where.append("(").append(p_whereClause).append(")");
    }

    //
    final String sqlFromClause = adInfoWindowBL.getSqlFrom(infoWindow);
    prepareTable(layout, sqlFromClause, where.toString(), infoWindow.getOrderByClause());
    setKeyColumnIndex(keyColumnIndex);
    setShowTotals(adInfoWindowBL.isShowTotals(infoWindow));

    initAddonPanel();

    //
    // Notify controllers that Info window was initialized
    for (final Info_Column infoColumn : p_layout) {
      final IInfoColumnController controller = infoColumn.getColumnController();
      if (controller == null) {
        continue;
      }

      controller.afterInfoWindowInit(this);
    }
  } // initInfo
  private void initParameters() {
    final List<I_AD_InfoColumn> paramInfoColumns = adInfoWindowDAO.retrieveQueryColumns(infoWindow);
    for (final I_AD_InfoColumn col : paramInfoColumns) {
      if (!Check.isEmpty(col.getParameterDisplayLogic(), true)) {
        final ILogicExpression expression =
            expressionFactory.compileOrDefault(
                col.getParameterDisplayLogic(), ILogicExpression.FALSE, ILogicExpression.class);

        // don't fail on missing parameter because we want to be compatible with old
        // org.compiere.util.Evaluator.evaluateLogic(Evaluatee, String) method
        final boolean ignoreUnparsable = true;
        if (!expression.evaluate(ctx, ignoreUnparsable)) {
          // this parameter will never-ever be displayed
          continue;
        }
      }

      if (col.isParameterNextLine() && !criteriasBySelectClause.isEmpty()) {
        addComponentToParameters(null, true);
      }
      //
      final String selectSql = col.getSelectClause();

      final IInfoQueryCriteria criteria =
          getInfoQueryCriteria(col, true); // retrieve default if not found
      // Add criteria to map
      {
        String name = selectSql;
        final int i = 1;
        while (criteriasBySelectClause.containsKey(name)) {
          name = selectSql + "#" + i;
        }
        criteriasBySelectClause.put(name, criteria);
      }

      //
      // Add criteria to Displayed Parameters
      displayedParameters.add(criteria);

      //
      // Iterate criterias and add editor fields to Parameters panel
      for (int i = 0; i < criteria.getParameterCount(); i++) {
        final Component editor = (Component) criteria.getParameterComponent(i);
        if (editor instanceof VLookup) {
          final VLookup lookup = (VLookup) editor;
          lookup.enableLookupAutocomplete();
        }

        //
        // Label
        final String labelText = criteria.getLabel(i);
        if (!Check.isEmpty(labelText)) {
          addComponentToParameters(labelText, false);
        }

        //
        // Parameter
        addComponentToParameters(editor, false);

        //
        // Parameter To
        final Component editor2 = (Component) criteria.getParameterToComponent(i);
        if (col.isRange() && editor2 != null) {
          addComponentToParameters(" - ", false);
          addComponentToParameters(editor2, false);
        }
      }
    }
  }