home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / JDesignerPro / Jdp3_0.exe / data1.cab / Program_Files / Applications / Layouts / JDPLayout14.java < prev    next >
Encoding:
Text File  |  1999-04-09  |  8.9 KB  |  269 lines

  1. \*    //
  2.     //  Main initialization method
  3.     //
  4.     public void <compName>Main() {
  5.  
  6.         <compName>SetGridSettings();
  7.  
  8.     }
  9.  
  10. \*    //
  11.     //  Load the grid with the specified parameters and selected data
  12.     //
  13.     public void <compName>LoadGridFromWhereClause(String whereClause) {
  14.  
  15.         int fPos = whereClause.indexOf("WHERE ");
  16.         whereClause = " AND" + whereClause.substring(fPos+5);
  17.         String[] keys = new String[0];
  18.  
  19.         <compName>LoadGridMain(keys, whereClause);
  20.     }
  21.  
  22. \*    //
  23.     //  Load the grid with the specified parameters and selected data
  24.     //
  25.     public void <compName>LoadGrid(String[] keys) {
  26.  
  27.         <compName>LoadGridMain(keys, null);
  28.     }
  29.  
  30. \*R    //
  31.     //  Load the grid with the specified parameters and selected data
  32.     //
  33.     void <compName>LoadGridMain(String[] keys, String whereClause) {
  34.  
  35.         JDPTextGrid tableContents = <compName>;
  36.  
  37.         StringTokenizer stok;
  38.         int recCount = 0;
  39.         Vector results = new Vector();
  40.         String sep = jaggSQL.getSEP();
  41.         int actualRows = 0;
  42.         String row;
  43.         double[][] worksubTotal;
  44.         double[][] workgrandTotal;
  45. >119        int columnCount = <columnCount>;
  46. <jaggPrefs>
  47.  
  48.         Vector columns = new Vector();
  49.         Vector indexes = new Vector();
  50.  
  51. >100        String SQL = <SELECT>;
  52.  
  53.         user.mainmsg.setStatusMsg(JDPLang.get("Message0"), 0);
  54.  
  55.         recCount = jaggSQL.execSQL(SQL, results);
  56.  
  57.         if(recCount == -1) {
  58.             user.u.setSqlMessage(jaggSQL,SQL);
  59.             return;
  60.         }
  61.  
  62.         //
  63.         //  Initialise result arrays
  64.         //
  65.         actualRows = jaggSQL.getRowCount();
  66.         tableContents.currentText = new String[columnCount][actualRows+30];
  67.         tableContents.cellFont = new Font[columnCount][actualRows+30];
  68.         tableContents.gridColor = Color.white;
  69.         boolean[] totalThisColumn = new boolean[columnCount];
  70.         
  71.         String[] lastItem = new String[columnCount];
  72. >125        boolean[] subTotal = new boolean[<>];
  73. >125        boolean[] grandTotal = new boolean[<>];
  74. >126        int orderBy = <>;
  75. >127        subTotal[<>] = <>;
  76. >128        grandTotal[<>] = <>;
  77. >129        totalThisColumn[<>] = <>;
  78.         //
  79.         //  Load arrays and result List
  80.         //
  81.         worksubTotal = new double[1][1];
  82.         workgrandTotal = new double[1][1];
  83.         int xOffset = 0;
  84.         int    xIncrement = 0;
  85.         int titlePos = (int)(columnCount/2)-1;
  86.         if (titlePos < 0) titlePos = 0;
  87. >124        tableContents.currentText[titlePos][1] = "<>";
  88.         tableContents.cellFont[titlePos][1] = new Font(user.plainFont.getName(),Font.BOLD,user.plainFont.getSize()+4);
  89.         for (int iy=0; iy<columnCount; iy++) {
  90.             tableContents.cellFont[iy][3] = user.boldFont;
  91.         }
  92. >101        tableContents.currentText[<ix>][3] = "<>";
  93.         xOffset = 4;
  94.         worksubTotal = new double[orderBy][columnCount];
  95.         workgrandTotal = new double[orderBy][columnCount];
  96.         int ix;
  97.         String tempText;
  98.         for (ix=0; ix<actualRows; ix++) {
  99.             row = (String)results.elementAt(ix);
  100.             if ((row != null) && (row.trim().compareTo("") != 0)) {
  101.                 stok = new StringTokenizer(row,sep);
  102.                 for (int iy=0; iy<columnCount; iy++) {
  103.                     tempText = stok.nextToken().trim();
  104.                     tableContents.currentText[iy][ix+xOffset] = tempText;
  105. >053                    <tableContents.currentText[iy][ix+xOffset] = stok.nextToken().trim();>
  106.                     if (tableContents.maskEdit[iy] != null) {
  107.                         if (tableContents.maskType[iy] == "Float") {
  108.                             tableContents.currentText[iy][ix+xOffset] = JDPMaskEditMain.formatFloat(tableContents.currentText[iy][ix+xOffset],tableContents.maskEdit[iy]);
  109.                         } else {
  110.                             tableContents.currentText[iy][ix+xOffset] = JDPMaskEditMain.formatString(tableContents.currentText[iy][ix+xOffset],tableContents.maskEdit[iy]);
  111.                         }
  112.                     }
  113.                 }
  114.                 for (int iy=columnCount-1; iy>=0; iy--) {
  115.                     String thisItem = tableContents.currentText[iy][ix+xOffset];
  116.                     if ((orderBy > iy) && (ix > 0)) {
  117.                         if (thisItem.equals(lastItem[iy])) {
  118.                             tableContents.currentText[iy][ix+xOffset] = "";
  119.                         } else {
  120.                             if (subTotal[iy]) {
  121.                                 for (int iz=0; iz<columnCount; iz++) {
  122.                                     tableContents.currentText[iz][ix+xOffset+1] = tableContents.currentText[iz][ix+xOffset];
  123.                                     tableContents.currentText[iz][ix+xOffset] = "";
  124.                                     tableContents.cellFont[iz][ix+xOffset+1] = tableContents.cellFont[iz][ix+xOffset];
  125.                                     tableContents.cellFont[iz][ix+xOffset] = null;
  126.                                 }
  127.                                 tableContents.currentText[iy][ix+xOffset] = JDPLang.get("Report0");
  128.                                 tableContents.cellFont[iy][ix+xOffset] = user.boldFont;
  129.                                 for (int iw=iy+1; iw<columnCount; iw++) {
  130.                                     if (totalThisColumn[iw]) {
  131.                                         tableContents.currentText[iw][ix+xOffset] = JDPMaskEditMain.formatFloat(worksubTotal[iy][iw],tableContents.maskEdit[iw]);
  132.                                         tableContents.cellFont[iw][ix+xOffset] = user.boldFont;
  133.                                     }
  134.                                     worksubTotal[iy][iw] = 0;
  135.                                 }
  136.                                 xOffset += 1;
  137.                             }
  138.                             tableContents.currentText[iy][ix+xOffset] = thisItem;
  139.                         }
  140.                     }
  141.                     if ((orderBy > 0) && (ix > 0)) {
  142.                         try {
  143.                             double tempfloat = Double.valueOf(JDPMaskEditMain.stripFloat(lastItem[iy])).doubleValue();
  144.                             for (int iz=0; iz<orderBy; iz++) {
  145.                                 worksubTotal[iz][iy] += tempfloat;
  146.                                 workgrandTotal[iz][iy] += tempfloat;
  147.                             }
  148.                         } catch(Exception e) { 
  149.                         }
  150.                     }
  151.                     lastItem[iy] = thisItem;
  152.                 }
  153.             }
  154.         }
  155.  
  156.         for (int iy=0; iy<columnCount; iy++) {
  157.             try {
  158.                 double tempfloat = Double.valueOf(JDPMaskEditMain.stripFloat(lastItem[iy])).doubleValue();
  159.                 for (int iz=0; iz<orderBy; iz++) {
  160.                     worksubTotal[iz][iy] += tempfloat;
  161.                     workgrandTotal[iz][iy] += tempfloat;
  162.                 }
  163.             } catch(Exception e) { 
  164.             }
  165.         }
  166.         for (int iy=columnCount-1; iy>=0; iy--) {
  167.             if (orderBy > iy) {
  168.                 if (subTotal[iy]) {
  169.                     tableContents.currentText[iy][ix+xOffset] = JDPLang.get("Report0");
  170.                     tableContents.cellFont[iy][ix+xOffset] = user.boldFont;
  171.                     for (int iw=iy+1; iw<columnCount; iw++) {
  172.                         if (totalThisColumn[iw]) {
  173.                             tableContents.currentText[iw][ix+xOffset] = JDPMaskEditMain.formatFloat(worksubTotal[iy][iw],tableContents.maskEdit[iw]);
  174.                             tableContents.cellFont[iw][ix+xOffset] = user.boldFont;
  175.                         }
  176.                     }
  177.                     xOffset += 1;
  178.                 }
  179.             }
  180.         }
  181.         for (int iy=columnCount-1; iy>=0; iy--) {
  182.             if (orderBy > iy) {
  183.                 if (grandTotal[iy]) {
  184.                     tableContents.currentText[iy][ix+xOffset] = JDPLang.get("Report1");
  185.                     tableContents.cellFont[iy][ix+xOffset] = user.boldFont;
  186.                     for (int iw=iy+1; iw<columnCount; iw++) {
  187.                         if (totalThisColumn[iw]) {
  188.                             tableContents.currentText[iw][ix+xOffset] = JDPMaskEditMain.formatFloat(workgrandTotal[iy][iw],tableContents.maskEdit[iw]);
  189.                             tableContents.cellFont[iw][ix+xOffset] = user.boldFont;
  190.                         }
  191.                     }
  192.                     xOffset++;
  193.                 }
  194.             }
  195.         }
  196.  
  197.         tableContents.newTable();
  198.  
  199.         //
  200.         //  Clear status message
  201.         //
  202.         user.mainmsg.clearStatusMsg();
  203.     }
  204.  
  205. \*R    //
  206.     //  Load the grid with the blank rows to allow data entry
  207.     //
  208.     public void <compName>LoadEmptyGrid() {
  209.  
  210.         JDPTextGrid tableContents = <compName>;
  211. >119        int columnCount = <columnCount>;
  212.  
  213.         tableContents.currentText = new String[columnCount][50];
  214.         tableContents.cellChanged = null;
  215.         tableContents.rowChanged = null;
  216.         tableContents.columnSelected = null;
  217.         tableContents.rowKey = new String[50][1];
  218.         tableContents.newTable();
  219.         tableContents.totalDataRows = 0;
  220.     }
  221.  
  222. \*R    //
  223.     //  Set up the parameters for this grid
  224.     //
  225.     void <compName>SetGridSettings() {
  226.  
  227.         if (<compName> == null) {
  228.             <compName> = new JDPTextGrid(user);
  229.         } 
  230.         JDPTextGrid tableContents = <compName>;
  231. >119        int columnCount = <columnCount>;
  232.  
  233.         tableContents.columnHeader = null;
  234.         tableContents.columnHeaderStyle = new int[columnCount];
  235.         tableContents.columnStyle = new int[columnCount];
  236.         tableContents.columnHeaderColor = new Color[columnCount];
  237.         tableContents.columnColor = new Color[columnCount];
  238.         tableContents.columnBGColor = new Color[columnCount];
  239.         tableContents.gridColor = Color.white;
  240.         tableContents.columnProtected = new boolean[columnCount];
  241.         tableContents.columnWidth = new int[columnCount];
  242.         tableContents.rightJustify = new boolean[columnCount];
  243.         tableContents.rowHeader = null;
  244.         tableContents.columnHeight = null;
  245.         tableContents.maskEdit = new String[columnCount];
  246.         tableContents.maskType = new String[columnCount];
  247.         for (int ix=0; ix<columnCount; ix++) {
  248.             tableContents.columnHeaderStyle[ix] = Font.BOLD;
  249.             tableContents.columnStyle[ix] = Font.PLAIN;
  250.             tableContents.columnHeaderColor[ix] = Color.black;
  251.             tableContents.columnColor[ix] = Color.black;
  252.             tableContents.columnBGColor[ix] = Color.white;
  253.             tableContents.columnStyle[ix] = Font.PLAIN;
  254.         }
  255. >102        tableContents.columnHeaderStyle[<ix>] = <>;
  256. >103        tableContents.columnStyle[<ix>] = <>;
  257. >104        tableContents.columnHeaderColor[<ix>] = user.u._cvtcolor("<>");
  258. >105        tableContents.columnColor[<ix>] = user.u._cvtcolor("<>");
  259. >106        tableContents.columnBGColor[<ix>] = user.u._cvtcolor("<>");
  260. >107        tableContents.columnProtected[<ix>] = <>;
  261. >108        tableContents.columnWidth[<ix>] = <>;
  262. >109        tableContents.rightJustify[<ix>] = <>;
  263. >170        tableContents.maskEdit[<ix>] = "<>";
  264. >171        tableContents.maskType[<ix>] = "<>";
  265.         
  266.         <compName>LoadEmptyGrid();
  267.     }
  268.  
  269.