/// <summary> /// Parses the diversion rights file and returns a Vector of StateMod_DiversionRight objects. </summary> /// <param name="filename"> the diversion rights file to parse. </param> /// <returns> a Vector of StateMod_DiversionRight objects. </returns> /// <exception cref="Exception"> if an error occurs </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static java.util.List<StateMod_DiversionRight> readStateModFile(String filename) throws Exception public static IList <StateMod_DiversionRight> readStateModFile(string filename) { string routine = "StateMod_DiversionRight.readStateModFile"; IList <StateMod_DiversionRight> theDivRights = new List <StateMod_DiversionRight> (); int[] format_0 = new int[] { StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER }; int[] format_0w = new int[] { 12, 24, 12, 16, 8, 8 }; string iline = null; IList <object> v = new List <object>(6); StreamReader @in = null; StateMod_DiversionRight aRight = null; Message.printStatus(2, routine, "Reading diversion rights file: " + filename); try { @in = new StreamReader(IOUtil.getPathUsingWorkingDir(filename)); while (!string.ReferenceEquals((iline = @in.ReadLine()), null)) { // check for comments if (iline.StartsWith("#", StringComparison.Ordinal) || iline.Trim().Length == 0) { continue; } aRight = new StateMod_DiversionRight(); if (Message.isDebugOn) { Message.printDebug(50, routine, "iline: " + iline); } StringUtil.fixedRead(iline, format_0, format_0w, v); aRight.setID(((string)v[0]).Trim()); aRight.setName(((string)v[1]).Trim()); aRight.setCgoto(((string)v[2]).Trim()); aRight.setIrtem(((string)v[3]).Trim()); aRight.setDcrdiv((double?)v[4]); aRight.setSwitch((int?)v[5]); // Mark as clean because set methods may have marked dirty... aRight.setDirty(false); theDivRights.Add(aRight); } } catch (Exception e) { Message.printWarning(3, routine, e); throw e; } finally { if (@in != null) { @in.Close(); } } return(theDivRights); }
/// <summary> /// Inserts the specified value into the table at the given position. </summary> /// <param name="value"> the object to store in the table cell. </param> /// <param name="row"> the row of the cell in which to place the object. </param> /// <param name="col"> the column of the cell in which to place the object. </param> public virtual void setValueAt(object value, int row, int col) { if (_sortOrder != null) { row = _sortOrder[row]; } double dval; int ival; int index; StateMod_DiversionRight dr = (StateMod_DiversionRight)_data.get(row); switch (col) { case COL_RIGHT_ID: dr.setID((string)value); break; case COL_RIGHT_NAME: dr.setName((string)value); break; case COL_STRUCT_ID: dr.setCgoto((string)value); break; case COL_ADMIN_NUM: dr.setIrtem((string)value); break; case COL_DCR_AMT: dval = ((double?)value).Value; dr.setDcrdiv(dval); break; case COL_ON_OFF: if (value is int?) { ival = ((int?)value).Value; dr.setSwitch(ival); } else if (value is string) { string onOff = (string)value; index = onOff.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(onOff.Substring(0, index))); dr.setSwitch(ival); } break; } base.setValueAt(value, row, col); }
/// <summary> /// Responds to action performed events. </summary> /// <param name="e"> the ActionEvent that happened. </param> public virtual void actionPerformed(ActionEvent e) { string routine = "StateMod_Diversion_Right_JFrame::actionPerformed"; string action = e.getActionCommand(); if (action.Equals(__BUTTON_ADD_RIGHT)) { StateMod_DiversionRight aRight = new StateMod_DiversionRight(); aRight._isClone = true; StateMod_DiversionRight last = (StateMod_DiversionRight)__worksheet.getLastRowData(); if (last == null) { aRight.setID(StateMod_Util.createNewID(__currentDiv.getID())); aRight.setCgoto(__currentDiv.getID()); } else { aRight.setID(StateMod_Util.createNewID(last.getID())); aRight.setCgoto(last.getCgoto()); } __worksheet.addRow(aRight); __worksheet.scrollToLastRow(); __worksheet.selectLastRow(); __deleteRight.setEnabled(true); } else if (action.Equals(__BUTTON_DEL_RIGHT)) { int row = __worksheet.getSelectedRow(); if (row != -1) { int x = (new ResponseJDialog(this, "Delete Diversion Right", "Delete diversion right?", ResponseJDialog.YES | ResponseJDialog.NO)).response(); if (x == ResponseJDialog.NO) { return; } __worksheet.cancelEditing(); __worksheet.deleteRow(row); __deleteRight.setEnabled(false); } else { Message.printWarning(1, routine, "Must select desired right to delete."); } } else if (action.Equals(__BUTTON_CLOSE)) { if (saveData()) { setVisible(false); dispose(); } } else if (action.Equals(__BUTTON_APPLY)) { saveData(); } else if (action.Equals(__BUTTON_CANCEL)) { setVisible(false); dispose(); } else if (action.Equals(__BUTTON_HELP)) { // REVISIT (JTS - 2003-06-10) } }
/// <summary> /// Inserts the specified value into the table at the given position. </summary> /// <param name="value"> the object to store in the table cell. </param> /// <param name="row"> the row of the cell in which to place the object. </param> /// <param name="col"> the column of the cell in which to place the object. </param> public virtual void setValueAt(object value, int row, int col) { if (_sortOrder != null) { row = _sortOrder[row]; } double dval; int ival; int index; // necessary for table models that display rights for 1+ diversions, // so that the -1st column (ID) can also be displayed. By doing it // this way, code can be shared between the two kinds of table models // and less maintenance is necessary. if (!__singleDiversion) { col--; } StateMod_DiversionRight dr = (StateMod_DiversionRight)_data.get(row); switch (col) { case COL_DIVERSION_ID: dr.setCgoto((string)value); break; case COL_RIGHT_ID: dr.setID((string)value); break; case COL_RIGHT_NAME: dr.setName((string)value); break; case COL_STRUCT_ID: dr.setCgoto((string)value); break; case COL_ADMIN_NUM: dr.setIrtem((string)value); break; case COL_DCR_AMT: dval = ((double?)value).Value; dr.setDcrdiv(dval); break; case COL_ON_OFF: if (value is int?) { ival = ((int?)value).Value; dr.setSwitch(ival); } else if (value is string) { string onOff = (string)value; index = onOff.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(onOff.Substring(0, index))); dr.setSwitch(ival); } break; } if (!__singleDiversion) { col++; } base.setValueAt(value, row, col); }