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 / JDPLayout24.java < prev    next >
Encoding:
Text File  |  1999-04-09  |  9.0 KB  |  272 lines

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