/// <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; StateMod_WellRight wellr = (StateMod_WellRight)_data.get(row); // necessary for table models that display rights for 1+ wells 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 (!__singleWell) { col--; } switch (col) { case COL_WELL_ID: wellr.setCgoto((string)value); break; case COL_RIGHT_ID: wellr.setID((string)value); break; case COL_RIGHT_NAME: wellr.setName((string)value); break; case COL_STRUCT_ID: wellr.setCgoto((string)value); break; case COL_ADMIN_NUM: wellr.setIrtem((string)value); break; case COL_DCR_AMT: if (value is string) { try { dval = (Convert.ToDouble((string)value)); } catch (Exception e) { Message.printWarning(2, "setValue", e); return; } } else { dval = ((double?)value).Value; } wellr.setDcrdivw(dval); break; case COL_ON_OFF: if (value is int?) { ival = ((int?)value).Value; wellr.setSwitch(ival); } else if (value is string) { string onOff = (string)value; int index = onOff.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(onOff.Substring(0, index))); wellr.setSwitch(ival); } break; } if (!__singleWell) { col++; } 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_Well_Right_JFrame.actionPerformed"; string action = e.getActionCommand(); if (action.Equals(__BUTTON_ADD_RIGHT)) { StateMod_WellRight aRight = new StateMod_WellRight(); aRight._isClone = true; StateMod_WellRight last = (StateMod_WellRight)__worksheet.getLastRowData(); if (last == null) { aRight.setID(StateMod_Util.createNewID(__currentWell.getID())); aRight.setCgoto(__currentWell.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 right", "Delete well 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_HELP)) { // REVISIT HELP (JTS - 2003-06-10) } 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(); } }
/// <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; StateMod_WellRight wellr = (StateMod_WellRight)_data.get(row); switch (col) { case COL_RIGHT_ID: wellr.setID((string)value); break; case COL_RIGHT_NAME: wellr.setName((string)value); break; case COL_STRUCT_ID: wellr.setCgoto((string)value); break; case COL_ADMIN_NUM: wellr.setIrtem((string)value); break; case COL_DCR_AMT: if (value is string) { try { dval = (Convert.ToDouble((string)value)); } catch (Exception e) { Message.printWarning(2, "setValue", e); return; } } else { dval = ((double?)value).Value; } wellr.setDcrdivw(dval); break; case COL_ON_OFF: if (value is int?) { ival = ((int?)value).Value; wellr.setSwitch(ival); } else if (value is string) { string onOff = (string)value; int index = onOff.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(onOff.Substring(0, index))); wellr.setSwitch(ival); } break; } base.setValueAt(value, row, col); }