home *** CD-ROM | disk | FTP | other *** search
Wrap
>XXX0454 Total lines for the build status message calculation //-------------------------------------------------------------------- // >001// Module: <JDPModule> >002// Description: <Class Description> // //-------------------------------------------------------------------- import java.awt.*; import java.applet.*; import java.util.*; >003public class <JDPUserBill> extends JDPClassLayout { JDPUser user; JDPJagg jaggSQL; JDPTextGrid tableContents; JDPWhereClause jdpWhereClause; JDPPopupMessage popuppanel; JDPMaskEdit JDPMaskEditMain; String[] psortChoice; String[] pdisplayChoice; int itemIndex; boolean insertRequested = false; boolean deleteRequested = false; String pfromWhereClause; String[][] rowKey; int totalRows; int keyCount; int prevColumnCount; >119 int columnCount = <columnCount>; >052 Vector value<name>; Vector pmatchUsing; Vector pactualmatchUsing; public void InitClass(JDPUser user, Panel targetPanel, String moduleParameter) { this.user = user; // // Set JAGG settings for this class // jaggSQL = new JDPJagg(user.jaggPath); jaggSQL.setNULL("space"); >996 jaggSQL.setMRW("<maxRows>"); >998 jaggSQL.setDSN("<datasource>"); >984 jaggSQL.setUID("<>"); >985 jaggSQL.setPWD("<>"); setLayout(new BorderLayout()); setFont(user.plainFont); popuppanel = new JDPPopupMessage(user,targetPanel); targetPanel.add(popuppanel); Panel mainPanel = new Panel(); mainPanel.setLayout(new BorderLayout()); Panel centerMainPanel = new Panel(); centerMainPanel.setLayout(new BorderLayout()); // // Create a new instance of a Grid // tableContents = new JDPTextGrid(user); mainPanel.add("Center",tableContents); centerMainPanel.add("Center",mainPanel); // // Add buttons to the bottom of the panel // if (moduleParameter.compareTo("Inquiry") == 0) { } else { >015 String buttons[] = {<" Apply ","Reset","New","Copy","Remove">}; >047 int icons[] = {<>}; JDPButtons btns = new JDPButtons(user, buttons, icons, JDPButtons.HORIZONTAL); centerMainPanel.add("South",btns); >046 popuppanel.addComponent(btns.button[<0>],"<>","<>"); } // // Define parameters for JDPWhereClause // >016 String[] pchooseFrom = new String[<7>]; >017 pchooseFrom[<0>] = "<Account Name>"; >018 String[] pactualchooseFrom = new String[<7>]; >019 pactualchooseFrom[<0>] = "<username>"; >024 boolean[] constantIsString = new boolean[<7>]; >025 constantIsString[<0>] = <true>; >026 int[] constantLength = new int[<7>]; >027 constantLength[<0>] = <20>; loadMatchUsing(); // // Add JDPWhereClause search panel // if (pchooseFrom.length > 0) { >028 jdpWhereClause = new JDPWhereClause(user, targetPanel, "<UserBill>", false, "<pinitChoice>", pchooseFrom, pactualchooseFrom, pmatchUsing, pactualmatchUsing, null, null, constantLength, constantIsString); centerMainPanel.add("North",jdpWhereClause); } >030 add("Center",new JDPChiselFramePanel(user,"<User Billing Details>",centerMainPanel,"North")); setGridSettings(); JDPMaskEditMain = new JDPMaskEdit(); loadGrid(); // // Add the handle to this panel to the global vector so other panels can // access this one // user.gParm.addElement(this); } // // Handle screen events // public boolean handleEvent(Event e) { switch (e.id) { case Event.ACTION_EVENT: if (e.target instanceof Button) { String choice = (String)e.arg; if (choice.trim().compareTo("Apply") == 0) { if (checkFields()) { checkRows(); } return true; } if (choice.trim().compareTo("Reset") == 0) { loadGrid(); return true; } if (choice.trim().compareTo("Remove") == 0) { >054 String removeMsg = "<>"; if (removeMsg.equals("") || user.mainmsg.getStatusMsg().equals(removeMsg)) { deleteRequested = true; checkRows(); } else { user.mainmsg.setStatusMsg(removeMsg,15); } return true; } if (choice.trim().compareTo("Search") == 0) { newSearch(); return true; } return false; } if (e.target instanceof Choice) { return true; } if (e.target instanceof TextField) { if ((jdpWhereClause != null) && (e.target.equals(jdpWhereClause.matchConstant))) { newSearch(); return true; } checkFields(); return true; } return false; case Event.KEY_RELEASE: >069 if (e.target.equals(tableContents) && tableContents.getCurrentColumn() == <colNo>) JDPMaskEditMain.format<String>(tableContents,"<mask>"); return true; case Event.WINDOW_EXPOSE: if (e.target instanceof JDPTabSelectPanel) { // // This is where you place code to get executed when this panel is // reactivated from the tab menu // return true; } return false; case Event.MOUSE_MOVE: case Event.MOUSE_ENTER: case Event.MOUSE_EXIT: popuppanel.postEvent(e); return false; default: return false; } } // // Retrieve the handle to another panel so as to be able to interact with it // public void retrieveHandle() { for (int ix=0; ix<user.gParm.size(); ix++) { // // Activate the next four lines of code to retrieve the handle to another // Panel within your JDP system. Of course you should declare the variable // at the top of this source instead of within this method so you can // access it from all the methods within this class. You only need to // substitute DemoClass with the name ouf your class. You should call this // method from somewhere else in this class. To access a variable from // your resulting class use: // if (DemoClassHandle != null) mynewvar = demoClassHandle.variable; // // if (user.gParm.elementAt(ix) instanceof DemoClass19) { // DemoClass19 DemoClassHandle = (DemoClass19)user.gParm.elementAt(ix); // return; // } } } // // The search button was pressed so rerun the query with the new search criteria // public void newSearch() { loadGrid(); } // // The check each rows that has changed and issue an update to the database // public void checkRows() { int changedCount = 0; int insertedCount = 0; int deletedCount = 0; int cCount = 1; int iCount = 1; boolean reload = false; for (int ix=0; ix<tableContents.rowChanged.length; ix++) { if (deleteRequested && tableContents.rowSelected[ix]) { deletedCount++; } else if (tableContents.rowChanged[ix]) { if (ix >= totalRows) { insertedCount++; } else { changedCount++; } } } for (int ix=0; ix<tableContents.rowChanged.length; ix++) { if (deleteRequested && tableContents.rowSelected[ix]) { user.mainmsg.setStatusMsg("Deleting row " + Integer.toString(iCount++) + " of " + Integer.toString(deletedCount) + "...", 0); saveData(ix); } else if (tableContents.rowChanged[ix]) { insertRequested = false; if (ix >= totalRows) { insertRequested = true; user.mainmsg.setStatusMsg("Inserting row " + Integer.toString(iCount++) + " of " + Integer.toString(insertedCount) + "...", 0); } else { user.mainmsg.setStatusMsg("Updating row " + Integer.toString(cCount++) + " of " + Integer.toString(changedCount) + "...", 0); } if (saveData(ix)) { reload = true; } insertRequested = false; tableContents.rowChanged[ix] = false; } } if ((deletedCount > 0) || (insertedCount > 0) || reload) { loadGrid(); } deleteRequested = false; } // // Save the selected item // boolean saveData(int tableRow) { int recCount = 0; Vector results = new Vector(); String sep = jaggSQL.getSEP(); String SQL = ""; String prevSQL = null; if (insertRequested) { >121 SQL = <INSERT INTO >; } else { if (deleteRequested) { >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 = {"Reload","Update"}; int[] icons = {JDPButton.UNDO,JDPButton.SAVE}; JDPMessageDialog d = new JDPMessageDialog(user, user.jdpMainWindow, "Update failed...", "The record has been changed by another user...",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 (insertRequested) { user.mainmsg.setStatusMsg("Record successfully added.",3); } else if (deleteRequested) { user.mainmsg.setStatusMsg("Record successfully removed.",3); } else { user.mainmsg.setStatusMsg("Record successfully updated.",3); } } else { user.u.setSqlMessage(jaggSQL,SQL); } if (prevSQL != null) { return true; } return false; } // // Load the grid with the specified parameters and selected data // public void loadGrid() { StringTokenizer stok; int recCount = 0; Vector results = new Vector(); String sep = jaggSQL.getSEP(); int actualRows = 0; String row; Vector columns = new Vector(); Vector indexes = new Vector(); >100 String SQL = <SELECT>; user.mainmsg.setStatusMsg("Accessing database...", 0); recCount = jaggSQL.execSQL(SQL, results); if(recCount == -1) { user.u.setSqlMessage(jaggSQL,SQL); return; } // // If we haven't already initialise the grid settings // if (columnCount != prevColumnCount) { prevColumnCount = columnCount; setGridSettings(); } // // Initialise result arrays // totalRows = jaggSQL.getRowCount(); actualRows = jaggSQL.getRowCount()+20; tableContents.currentText = new String[columnCount][actualRows]; tableContents.cellChanged = null; tableContents.rowChanged = null; tableContents.columnSelected = null; >120 keyCount = <keycount>; 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++) { 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>) && (value<field>.indexOf(tempText) >= 0)) tableContents.currentText[iy][ix] = tableContents.pullDownList[<1>][0].getItem(value<field>.indexOf(tempText)); >069 if (iy == <1>) JDPMaskEditMain.format<String>(tableContents,iy,ix,"<mask>"); } } } tableContents.newTable(); // // Clear status message // user.mainmsg.clearStatusMsg(); } // // Load the grid with the blank rows to allow data entry // public void loadEmptyGrid() { tableContents.currentText = new String[columnCount][50]; tableContents.cellChanged = null; tableContents.rowChanged = null; tableContents.columnSelected = null; rowKey = new String[50][keyCount]; tableContents.newTable(); totalRows = 0; } // // Set up the parameters for this grid // void setGridSettings() { 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.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; } >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("<>"); >107 tableContents.columnProtected[<ix>] = <>; >108 tableContents.columnWidth[<ix>] = <>; >109 tableContents.rightJustify[<ix>] = <>; loadChoices(); loadEmptyGrid(); } // // Load the Search Layout pulldown choices // void loadMatchUsing() { pmatchUsing = new Vector(); pactualmatchUsing = new Vector(); >020 pmatchUsing.addElement(new Vector()); >022 pactualmatchUsing.addElement(new Vector()); >021 ((Vector)pmatchUsing.elementAt(<0>)).addElement("<Begins with>"); >023 ((Vector)pactualmatchUsing.elementAt(<0>)).addElement("< like >"); } // // Load all of the Screen Choices // public void loadChoices() { tableContents.isPullDownCol = new boolean[columnCount]; tableContents.pullDownList = new List[columnCount][1]; >049 tableContents.isPullDownCol[<1>] = true; >049 tableContents.pullDownList[<1>][0] = new List(); >050 >051 new JDPLoadChoice(user,jaggSQL,tableContents.pullDownList[<1>][0],"<choicecolumnname>","<actualcolumnname>","<tablename>","<whereclause>",value<columnname>); } // // Perform component validations // public boolean checkFields() { return true; } }