static private MPrintFormatItem[] createItems(Properties ctx,MPrintFormat format){
  s_log.fine("From window Tab ...");
  ArrayList<MPrintFormatItem> list=new ArrayList<MPrintFormatItem>();
  String sql="SELECT AD_Column_ID " + "FROM AD_Field " + "WHERE AD_Tab_ID=(SELECT MIN(AD_Tab_ID) FROM AD_Tab WHERE AD_Table_ID=?)"+ " AND IsEncrypted='N' AND ObscureType IS NULL "+ "ORDER BY COALESCE(IsDisplayed,'N') DESC, SortNo, SeqNo, Name";
  PreparedStatement pstmt=null;
  ResultSet rs=null;
  try {
    pstmt=DB.prepareStatement(sql,format.get_TrxName());
    pstmt.setInt(1,format.getAD_Table_ID());
    rs=pstmt.executeQuery();
    int seqNo=1;
    while (rs.next()) {
      MPrintFormatItem pfi=MPrintFormatItem.createFromColumn(format,rs.getInt(1),seqNo++);
      if (pfi != null) {
        list.add(pfi);
        s_log.finest("Tab: " + pfi);
      }
    }
  }
 catch (  SQLException e) {
    s_log.log(Level.SEVERE,"(tab) - " + sql,e);
  }
 finally {
    DB.close(rs,pstmt);
    rs=null;
    pstmt=null;
  }
  if (list.size() == 0) {
    s_log.fine("From Table ...");
    sql="SELECT AD_Column_ID " + "FROM AD_Column " + "WHERE AD_Table_ID=? "+ "ORDER BY IsIdentifier DESC, SeqNo, Name";
    try {
      pstmt=DB.prepareStatement(sql,format.get_TrxName());
      pstmt.setInt(1,format.getAD_Table_ID());
      rs=pstmt.executeQuery();
      int seqNo=1;
      while (rs.next()) {
        MPrintFormatItem pfi=MPrintFormatItem.createFromColumn(format,rs.getInt(1),seqNo++);
        if (pfi != null) {
          list.add(pfi);
          s_log.finest("Table: " + pfi);
        }
      }
    }
 catch (    SQLException e) {
      s_log.log(Level.SEVERE,"(table) - " + sql,e);
    }
 finally {
      DB.close(rs,pstmt);
      rs=null;
      pstmt=null;
    }
  }
  MPrintFormatItem[] retValue=new MPrintFormatItem[list.size()];
  list.toArray(retValue);
  s_log.info(format + " - #" + retValue.length);
  return retValue;
}

static private MPrintFormatItem [ ] createItems ( Properties ctx , MPrintFormat format ) { s_log . fine ( "From window Tab ..." ) ; ArrayList < MPrintFormatItem > list = new ArrayList < MPrintFormatItem > ( ) ; String sql = "SELECT AD_Column_ID " + "FROM AD_Field " + "WHERE AD_Tab_ID=(SELECT MIN(AD_Tab_ID) FROM AD_Tab WHERE AD_Table_ID=?)" + " AND IsEncrypted='N' AND ObscureType IS NULL " + "ORDER BY COALESCE(IsDisplayed,'N') DESC, SortNo, SeqNo, Name" ; PreparedStatement pstmt = null ; ResultSet rs = null ; try { pstmt = DB . prepareStatement ( sql , format . get_TrxName ( ) ) ; pstmt . setInt ( 1 , format . getAD_Table_ID ( ) ) ; rs = pstmt . executeQuery ( ) ; int seqNo = 1 ; while ( rs . next ( ) ) { MPrintFormatItem pfi = MPrintFormatItem . createFromColumn ( format , rs . getInt ( 1 ) , seqNo ++ ) ; if ( pfi != null ) { list . add ( pfi ) ; s_log . finest ( "Tab: " + pfi ) ; } } } catch ( SQLException e ) { s_log . log ( Level . SEVERE , "(tab) - " + sql , e ) ; } finally { DB . close ( rs , pstmt ) ; rs = null ; pstmt = null ; } if ( list . size ( ) == 0 ) { s_log . fine ( "From Table ..." ) ; sql = "SELECT AD_Column_ID " + "FROM AD_Column " + "WHERE AD_Table_ID=? " + "ORDER BY IsIdentifier DESC, SeqNo, Name" ; try { pstmt = DB . prepareStatement ( sql , format . get_TrxName ( ) ) ; pstmt . setInt ( 1 , format . getAD_Table_ID ( ) ) ; rs = pstmt . executeQuery ( ) ; int seqNo = 1 ; while ( rs . next ( ) ) { MPrintFormatItem pfi = MPrintFormatItem . createFromColumn ( format , rs . getInt ( 1 ) , seqNo ++ ) ; if ( pfi != null ) { list . add ( pfi ) ; s_log . finest ( "Table: " + pfi ) ; } } } catch ( SQLException e ) { s_log . log ( Level . SEVERE , "(table) - " + sql , e ) ; } finally { DB . close ( rs , pstmt ) ; rs = null ; pstmt = null ; } } MPrintFormatItem [ ] retValue = new MPrintFormatItem [ list . size ( ) ] ; list . toArray ( retValue ) ; s_log . info ( format + " - #" + retValue . length ) ; return retValue ; }
create items . using the display order of fields in some tab
