home *** CD-ROM | disk | FTP | other *** search
- \* //
- // Main initialization method
- //
- public void <compName>Main() {
-
- <compName>SetGridSettings();
- <compName>WhereClauseMain();
- <compName>SearchResultsMain();
- // <compName>LoadGrid(null);
-
- }
-
- \* //
- // Load the grid with the specified parameters and selected data
- //
- public void <compName>LoadGridFromWhereClause(String whereClause) {
-
- int fPos = whereClause.indexOf("WHERE ");
- whereClause = " AND" + whereClause.substring(fPos+5);
- String[] keys = new String[0];
-
- <compName>LoadGridMain(keys, whereClause);
- }
-
- \* //
- // Load the grid with the specified parameters and selected data
- //
- public void <compName>LoadGrid(String[] keys) {
-
- <compName>LoadGridMain(keys, null);
- }
-
- \*R //
- // Load the grid with the specified parameters and selected data
- //
- void <compName>LoadGridMain(String[] keys, String whereClause) {
-
- JDPTextGrid tableContents = <compName>GL1;
-
- StringTokenizer stok;
- int recCount = 0;
- Vector results = new Vector();
- String sep = jaggSQL.getSEP();
- int actualRows = 0;
- String row;
- double[][] worksubTotal;
- double[][] workgrandTotal;
- >119 int columnCount = <columnCount>;
- <jaggPrefs>
-
- Vector columns = new Vector();
- Vector indexes = new Vector();
-
- >100 String SQL = <SELECT>;
-
- user.mainmsg.setStatusMsg(JDPLang.get("Message0"), 0);
-
- recCount = jaggSQL.execSQL(SQL, results);
-
- if(recCount == -1) {
- user.u.setSqlMessage(jaggSQL,SQL);
- return;
- }
-
- //
- // Initialise result arrays
- //
- actualRows = jaggSQL.getRowCount();
- tableContents.currentText = new String[columnCount][actualRows*3+20];
- tableContents.cellFont = new Font[columnCount][actualRows*3+20];
- tableContents.gridColor = Color.white;
- boolean[] totalThisColumn = new boolean[columnCount];
-
- String[] lastItem = new String[columnCount];
- >125 boolean[] subTotal = new boolean[<>];
- >125 boolean[] grandTotal = new boolean[<>];
- >126 int orderBy = <>;
- >127 subTotal[<>] = <>;
- >128 grandTotal[<>] = <>;
- >129 totalThisColumn[<>] = <>;
- //
- // Load arrays and result List
- //
- worksubTotal = new double[1][1];
- workgrandTotal = new double[1][1];
- int xOffset = 0;
- int xIncrement = 0;
- int titlePos = (int)(columnCount/2)-1;
- if (titlePos < 0) titlePos = 0;
- >124 tableContents.currentText[titlePos][1] = "<>";
- tableContents.cellFont[titlePos][1] = new Font(user.plainFont.getName(),Font.BOLD,user.plainFont.getSize()+4);
- for (int iy=0; iy<columnCount; iy++) {
- tableContents.cellFont[iy][3] = user.boldFont;
- }
- >101 tableContents.currentText[<ix>][3] = "<>";
- xOffset = 4;
- worksubTotal = new double[orderBy][columnCount];
- workgrandTotal = new double[orderBy][columnCount];
- int ix;
- String tempText;
- for (ix=0; ix<actualRows; ix++) {
- row = (String)results.elementAt(ix);
- if ((row != null) && (row.trim().compareTo("") != 0)) {
- stok = new StringTokenizer(row,sep);
- for (int iy=0; iy<columnCount; iy++) {
- tempText = stok.nextToken().trim();
- tableContents.currentText[iy][ix+xOffset] = tempText;
- >053 <tableContents.currentText[iy][ix+xOffset] = stok.nextToken().trim();>
- if (tableContents.maskEdit[iy] != null) {
- if (tableContents.maskType[iy] == "Float") {
- tableContents.currentText[iy][ix+xOffset] = JDPMaskEditMain.formatFloat(tableContents.currentText[iy][ix+xOffset],tableContents.maskEdit[iy]);
- } else {
- tableContents.currentText[iy][ix+xOffset] = JDPMaskEditMain.formatString(tableContents.currentText[iy][ix+xOffset],tableContents.maskEdit[iy]);
- }
- }
- }
- for (int iy=columnCount-1; iy>=0; iy--) {
- String thisItem = tableContents.currentText[iy][ix+xOffset];
- if ((orderBy > iy) && (ix > 0)) {
- if (thisItem.equals(lastItem[iy])) {
- tableContents.currentText[iy][ix+xOffset] = "";
- } else {
- if (subTotal[iy]) {
- for (int iz=0; iz<columnCount; iz++) {
- tableContents.currentText[iz][ix+xOffset+1] = tableContents.currentText[iz][ix+xOffset];
- tableContents.currentText[iz][ix+xOffset] = "";
- tableContents.cellFont[iz][ix+xOffset+1] = tableContents.cellFont[iz][ix+xOffset];
- tableContents.cellFont[iz][ix+xOffset] = null;
- }
- tableContents.currentText[iy][ix+xOffset] = JDPLang.get("Report0");
- tableContents.cellFont[iy][ix+xOffset] = user.boldFont;
- for (int iw=iy+1; iw<columnCount; iw++) {
- if (totalThisColumn[iw]) {
- tableContents.currentText[iw][ix+xOffset] = JDPMaskEditMain.formatFloat(worksubTotal[iy][iw],tableContents.maskEdit[iw]);
- tableContents.cellFont[iw][ix+xOffset] = user.boldFont;
- }
- worksubTotal[iy][iw] = 0;
- }
- xOffset += 1;
- }
- tableContents.currentText[iy][ix+xOffset] = thisItem;
- }
- }
- if ((orderBy > 0) && (ix > 0)) {
- try {
- double tempfloat = Double.valueOf(JDPMaskEditMain.stripFloat(lastItem[iy])).doubleValue();
- for (int iz=0; iz<orderBy; iz++) {
- worksubTotal[iz][iy] += tempfloat;
- workgrandTotal[iz][iy] += tempfloat;
- }
- } catch(Exception e) {
- }
- }
- lastItem[iy] = thisItem;
- }
- }
- }
-
- for (int iy=0; iy<columnCount; iy++) {
- try {
- double tempfloat = Double.valueOf(JDPMaskEditMain.stripFloat(lastItem[iy])).doubleValue();
- for (int iz=0; iz<orderBy; iz++) {
- worksubTotal[iz][iy] += tempfloat;
- workgrandTotal[iz][iy] += tempfloat;
- }
- } catch(Exception e) {
- }
- }
- for (int iy=columnCount-1; iy>=0; iy--) {
- if (orderBy > iy) {
- if (subTotal[iy]) {
- tableContents.currentText[iy][ix+xOffset] = JDPLang.get("Report0");
- tableContents.cellFont[iy][ix+xOffset] = user.boldFont;
- for (int iw=iy+1; iw<columnCount; iw++) {
- if (totalThisColumn[iw]) {
- tableContents.currentText[iw][ix+xOffset] = JDPMaskEditMain.formatFloat(worksubTotal[iy][iw],tableContents.maskEdit[iw]);
- tableContents.cellFont[iw][ix+xOffset] = user.boldFont;
- }
- }
- xOffset += 1;
- }
- }
- }
- for (int iy=columnCount-1; iy>=0; iy--) {
- if (orderBy > iy) {
- if (grandTotal[iy]) {
- tableContents.currentText[iy][ix+xOffset] = JDPLang.get("Report1");
- tableContents.cellFont[iy][ix+xOffset] = user.boldFont;
- for (int iw=iy+1; iw<columnCount; iw++) {
- if (totalThisColumn[iw]) {
- tableContents.currentText[iw][ix+xOffset] = JDPMaskEditMain.formatFloat(workgrandTotal[iy][iw],tableContents.maskEdit[iw]);
- tableContents.cellFont[iw][ix+xOffset] = user.boldFont;
- }
- }
- xOffset++;
- }
- }
- }
-
- tableContents.newTable();
-
- //
- // Clear status message
- //
- user.mainmsg.clearStatusMsg();
- }
-
- \*R //
- // Load the grid with the blank rows to allow data entry
- //
- public void <compName>LoadEmptyGrid() {
-
- JDPTextGrid tableContents = <compName>GL1;
- >119 int columnCount = <columnCount>;
-
- tableContents.currentText = new String[columnCount][50];
- tableContents.cellChanged = null;
- tableContents.rowChanged = null;
- tableContents.columnSelected = null;
- tableContents.rowKey = new String[50][1];
- tableContents.newTable();
- tableContents.totalDataRows = 0;
- }
-
- \*R //
- // Set up the parameters for this grid
- //
- void <compName>SetGridSettings() {
-
- if (<compName> == null) {
- <compName> = new JDPTextGrid(user);
- }
- JDPTextGrid tableContents = <compName>GL1;
- >119 int columnCount = <columnCount>;
-
- tableContents.columnHeader = null;
- tableContents.columnHeaderStyle = new int[columnCount];
- tableContents.columnStyle = new int[columnCount];
- tableContents.columnHeaderColor = new Color[columnCount];
- tableContents.columnColor = new Color[columnCount];
- tableContents.columnBGColor = new Color[columnCount];
- tableContents.gridColor = Color.white;
- tableContents.columnProtected = new boolean[columnCount];
- tableContents.columnWidth = new int[columnCount];
- tableContents.rightJustify = new boolean[columnCount];
- tableContents.rowHeader = null;
- tableContents.columnHeight = null;
- tableContents.maskEdit = new String[columnCount];
- tableContents.maskType = new String[columnCount];
- for (int ix=0; ix<columnCount; ix++) {
- tableContents.columnHeaderStyle[ix] = Font.BOLD;
- tableContents.columnStyle[ix] = Font.PLAIN;
- tableContents.columnHeaderColor[ix] = Color.black;
- tableContents.columnColor[ix] = Color.black;
- tableContents.columnBGColor[ix] = Color.white;
- tableContents.columnStyle[ix] = Font.PLAIN;
- }
- >102 tableContents.columnHeaderStyle[<ix>] = <>;
- >103 tableContents.columnStyle[<ix>] = <>;
- >104 tableContents.columnHeaderColor[<ix>] = user.u._cvtcolor("<>");
- >105 tableContents.columnColor[<ix>] = user.u._cvtcolor("<>");
- >106 tableContents.columnBGColor[<ix>] = user.u._cvtcolor("<>");
- >107 tableContents.columnProtected[<ix>] = <>;
- >108 tableContents.columnWidth[<ix>] = <>;
- >109 tableContents.rightJustify[<ix>] = <>;
- >170 tableContents.maskEdit[<ix>] = "<>";
- >171 tableContents.maskType[<ix>] = "<>";
-
- <compName>LoadEmptyGrid();
- }
-
-