home *** CD-ROM | disk | FTP | other *** search
Wrap
\* // // Main initialization method // public void <compName>Main() { <compName>SetGridSettings(); <compName>WhereClauseMain(); <compName>SearchResultsMain(); // <compName>LoadGrid(new String[0]); } \* // // 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; >119 int columnCount = <columnCount>; Vector columns = new Vector(); Vector indexes = new Vector(); >100 String SQL = <SELECT>; if (whereClause != null) { SQL += whereClause; } user.mainmsg.setStatusMsg(JDPLang.get("Message0"), 0); <jaggPrefs> recCount = jaggSQL.execSQL(SQL, results); if(recCount == -1) { user.u.setSqlMessage(jaggSQL,SQL); return; } // // Initialise result arrays // tableContents.totalDataRows = jaggSQL.getRowCount(); actualRows = jaggSQL.getRowCount()+20; tableContents.currentText = new String[columnCount][actualRows]; tableContents.cellChanged = null; tableContents.rowChanged = null; tableContents.columnSelected = null; >120 int keyCount = <keycount>; tableContents.rowKey = new String[actualRows][keyCount]; tableContents.recordLockValue = new String[actualRows]; // // Load key array and grid array // String tempText; for (int ix=0; ix<actualRows-20; ix++) { row = (String)results.elementAt(ix); if ((row != null) && (row.trim().compareTo("") != 0)) { stok = new StringTokenizer(row,sep); >162 tableContents.recordLockValue[ix] = stok.nextToken().trim(); for (int iy=0; iy<keyCount; iy++) { tableContents.rowKey[ix][iy] = stok.nextToken().trim(); } for (int iy=0; iy<columnCount; iy++) { tempText = stok.nextToken().trim(); tableContents.currentText[iy][ix] = tempText; >053 if ((iy == <1>) && (tableContents.pullDownValue[<1>][0].indexOf(tempText) >= 0)) tableContents.currentText[iy][ix] = tableContents.pullDownList[<1>][0].getItem(tableContents.pullDownValue[<1>][0].indexOf(tempText)); >071 if (iy == <1>) tableContents.currentText[iy][ix] = (tableContents.currentText[iy][ix].equals("<checkedValue>"))?"Y":"N"; >069 if (iy == <1>) JDPMaskEditMain.format<String>(tableContents,iy,ix,"<mask>"); >069 if (iy == <1>) tableContents.setEditMask("<String>",iy,"<mask>"); } } } for (int ix=actualRows-20; ix<actualRows; ix++) { for (int iy=0; iy<keys.length; iy++) { tableContents.rowKey[ix][iy] = keys[iy]; } } tableContents.newTable(); // // Clear status message // user.mainmsg.clearStatusMsg(); } \* // // Check each row that has changed and issue an update to the database // public void <compName>UpdateRowsFromWhereClause(String whereClause) { int fPos = whereClause.indexOf("WHERE "); whereClause = " AND" + whereClause.substring(fPos+5); String[] keys = new String[0]; <compName>UpdateRowsMain(keys, whereClause); } \* // // Check each row that has changed and issue an update to the database // public void <compName>UpdateRows(String[] keys) { <compName>UpdateRowsMain(keys, null); } \* // // Check each row that has changed and issue an update to the database // void <compName>UpdateRowsMain(String[] keys, String whereClause) { JDPTextGrid tableContents = <compName>GL1; int changedCount = 0; int insertedCount = 0; int cCount = 1; int iCount = 1; boolean reload = false; for (int ix=0; ix<tableContents.rowChanged.length; ix++) { if (tableContents.rowChanged[ix]) { if (ix >= tableContents.totalDataRows) { insertedCount++; } else { changedCount++; } } } for (int ix=0; ix<tableContents.rowChanged.length; ix++) { if (tableContents.rowChanged[ix]) { if (ix >= tableContents.totalDataRows) { user.mainmsg.setStatusMsg(JDPLang.get("Message7",iCount++,insertedCount), 0); <compName>SaveData(ix,"I"); } else { user.mainmsg.setStatusMsg(JDPLang.get("Message8",cCount++,changedCount), 0); if (<compName>SaveData(ix,"U")) { reload = true; } } tableContents.rowChanged[ix] = false; } } if (insertedCount > 0 || reload) { <compName>LoadGridMain(keys, whereClause); } } \* // // Delete any of the selected rows // public void <compName>DeleteRowsFromWhereClause(String whereClause) { int fPos = whereClause.indexOf("WHERE "); whereClause = " AND" + whereClause.substring(fPos+5); String[] keys = new String[0]; <compName>DeleteRowsMain(keys, whereClause); } \* // // Check each row that has changed and issue an update to the database // public void <compName>DeleteRows(String[] keys) { <compName>DeleteRowsMain(keys, null); } \* // // Check each row that has changed and issue an update to the database // void <compName>DeleteRowsMain(String[] keys, String whereClause) { JDPTextGrid tableContents = <compName>GL1; int deletedCount = 0; int cCount = 1; int iCount = 1; for (int ix=0; ix<tableContents.rowChanged.length; ix++) { if (tableContents.rowSelected[ix]) { deletedCount++; } } for (int ix=0; ix<tableContents.rowChanged.length; ix++) { if (tableContents.rowSelected[ix]) { user.mainmsg.setStatusMsg(JDPLang.get("Message9",iCount++,deletedCount), 0); <compName>SaveData(ix,"D"); } } if (deletedCount > 0) { <compName>LoadGridMain(keys, whereClause); } } \*R // // Save the selected item // boolean <compName>SaveData(int tableRow, String action) { JDPTextGrid tableContents = <compName>GL1; int recCount = 0; Vector results = new Vector(); String sep = jaggSQL.getSEP(); String SQL = ""; String prevSQL = null; <jaggPrefs> if (action.equals("I")) { >121 SQL = <INSERT INTO >; } else { if (action.equals("D")) { >122 SQL = <DELETE FROM >; if (tableContents.recordLockValue[tableRow] != null) { prevSQL = SQL; >163 SQL += " AND <colname> = " + tableContents.recordLockValue[tableRow]; } } else { >123 SQL = <UPDATE >; if (tableContents.recordLockValue[tableRow] != null) { prevSQL = SQL; >163 SQL += " AND <colname> = " + tableContents.recordLockValue[tableRow]; } } } recCount = jaggSQL.execSQL(SQL, results); if (user.DEBUG) System.out.println("saveData CNT: "+Integer.toString(recCount)); if (recCount == 0 && prevSQL != null) { String[] buttons = {JDPLang.get("Reload"),JDPLang.get("Update")}; int[] icons = {JDPButton.UNDO,JDPButton.SAVE}; JDPMessageDialog d = new JDPMessageDialog(user, user.jdpMainWindow, JDPLang.get("Dialog0"), JDPLang.get("Dialog1"), buttons, icons); d.display(); if (d.getPressedButton() == 1) { results = new Vector(); recCount = jaggSQL.execSQL(prevSQL, results); } else { return true; } } if(recCount == -1) { user.u.setSqlMessage(jaggSQL,SQL); return false; } if(recCount == 1) { if (action.equals("I")) { user.mainmsg.setStatusMsg(JDPLang.get("Message4"),3); } else if (action.equals("D")) { user.mainmsg.setStatusMsg(JDPLang.get("Message5"),3); } else { user.mainmsg.setStatusMsg(JDPLang.get("Message6"),3); } } else { user.u.setSqlMessage(jaggSQL,SQL); } if (prevSQL != null) { return true; } return false; } \*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; tableContents.setSortingEnabled(true); } \*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.fieldTypeCol = new int[columnCount]; tableContents.columnHeader = new String[columnCount]; 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.columnProtected = new boolean[columnCount]; tableContents.columnDisabled = new boolean[columnCount]; tableContents.columnWidth = new int[columnCount]; tableContents.rightJustify = new boolean[columnCount]; tableContents.rowHeader = null; tableContents.columnHeight = null; 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; } >110 tableContents.setFieldTypeCol(<ix>,JDPTextGrid.<TEXTFIELD>); >107 tableContents.columnProtected[<ix>] = <>; >107 tableContents.columnDisabled[<ix>] = <>; >108 tableContents.columnWidth[<ix>] = <>; >109 tableContents.rightJustify[<ix>] = <>; >101 tableContents.columnHeader[<ix>] = "<>"; >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("<>"); <compName>LoadEmptyGrid(); <compName>LoadChoices(); } \*R // // Load all of the Screen Choices // void <compName>LoadChoices() { JDPTextGrid tableContents = <compName>GL1; >119 int columnCount = <columnCount>; <jaggPrefs> tableContents.isPullDownCol = new boolean[columnCount]; tableContents.pullDownColType = new int[columnCount]; tableContents.pullDownList = new List[columnCount][1]; >049 tableContents.isPullDownCol[<1>] = true; >049 tableContents.pullDownColType[<1>] = JDPTextGrid.REGULAR; >049 tableContents.pullDownList[<1>][0] = new List(); >070 tableContents.isPullDownCol[<1>] = true; >070 tableContents.pullDownColType[<1>] = JDPTextGrid.DATE; >050 >051 new JDPLoadChoice(user,jaggSQL,tableContents.pullDownList[<1>][0],"<choicecolumnname>","<actualcolumnname>","<tablename>","<whereclause>",tableContents.pullDownValue[<1>][0]); }