/// <summary> /// Returns the data that should be placed in the JTable /// at the given row and column. </summary> /// <param name="row"> the row for which to return data. </param> /// <param name="col"> the column for which to return data. </param> /// <returns> the data that should be placed in the JTable at the given row and col. </returns> public virtual object getValueAt(int row, int col) { if (_sortOrder != null) { row = _sortOrder[row]; } StateCU_CropCharacteristics crop = (StateCU_CropCharacteristics)_data.get(row); if (__singleCrop) { switch (col) { case __COL_NAME: return(crop.getName()); case __COL_DAY_PCT: if (__blaneyCriddle == null) { return(new int?(0)); } if (__dayNotPercent) { return(new int?(__blaneyCriddle.getNckcp(row))); } else { return(new int?(__blaneyCriddle.getNckca(row))); } case __COL_VALUE: if (__blaneyCriddle == null) { return(new double?(0)); } if (__dayNotPercent) { return(new double?(__blaneyCriddle.getCkcp(row))); } else { return(new double?(__blaneyCriddle.getCkca(row))); } } } else { switch (col) { case __COL_NAME: return(crop.getName()); case __COL_GDATE1: return(new int?(crop.getGdate1())); case __COL_GDATE2: return(new int?(crop.getGdate2())); case __COL_GDATE3: return(new int?(crop.getGdate3())); case __COL_GDATE4: return(new int?(crop.getGdate4())); case __COL_GDATE5: return(new int?(crop.getGdate5())); case __COL_GDATES: return(new int?(crop.getGdates())); case __COL_TMOIS1: return(new double?(crop.getTmois1())); case __COL_TMOIS2: return(new double?(crop.getTmois2())); case __COL_MAD: return(new double?(crop.getMad())); case __COL_IRX: return(new double?(crop.getIrx())); case __COL_FRX: return(new double?(crop.getFrx())); case __COL_AWC: return(new double?(crop.getAwc())); case __COL_APD: return(new double?(crop.getApd())); case __COL_TFLAG1: return(new int?(crop.getTflg1())); case __COL_TFLAG2: return(new int?(crop.getTflg2())); case __COL_CUT2: return(new int?(crop.getCut2())); case __COL_CUT3: return(new int?(crop.getCut3())); } } return(""); }
/// <summary> /// Processes a table selection (either via a mouse press or programmatically /// from selectTableIndex() by writing the old data back to the data set component /// and getting the next selection's data out of the data and displaying it /// on the form. </summary> /// <param name="index"> the index of the reservoir to display on the form. </param> private void processTableSelection(int index) { __lastCropIndex = __currentCropIndex; __currentCropIndex = __worksheet.getOriginalRowNumber(index); saveLastRecord(); if (__worksheet.getSelectedRow() == -1) { nothingSelected(); return; } somethingSelected(); StateCU_CropCharacteristics crop = (StateCU_CropCharacteristics)__cropsVector[__currentCropIndex]; __cropIDJTextField.setText(crop.getID()); __nameJTextField.setText(crop.getName()); StateCU_Util.checkAndSet(crop.getGdate1(), __plantMonthJTextField); StateCU_Util.checkAndSet(crop.getGdate2(), __plantDayJTextField); StateCU_Util.checkAndSet(crop.getGdate3(), __harvestMonthJTextField); StateCU_Util.checkAndSet(crop.getGdate4(), __harvestDayJTextField); StateCU_Util.checkAndSet(crop.getGdate5(), __daysToCoverJTextField); StateCU_Util.checkAndSet(crop.getGdates(), __seasonLengthJTextField); StateCU_Util.checkAndSet(crop.getTmois1(), __earliestValueJTextField); StateCU_Util.checkAndSet(crop.getTmois2(), __latestValueJTextField); StateCU_Util.checkAndSet(crop.getFrx(), __maxRootFeetJTextField); StateCU_Util.checkAndSet(crop.getApd(), __maxAppDepthJTextField); StateCU_Util.checkAndSet(crop.getCut2(), __firstDaysBetweenJTextField); StateCU_Util.checkAndSet(crop.getCut3(), __secondDaysBetweenJTextField); int flag = crop.getTflg1(); if (flag == -999) { flag = 3; } __earliestFlagComboBox.select(flag); flag = crop.getTflg2(); if (flag == -999) { flag = 3; } __latestFlagComboBox.select(flag); int bcindex = StateCU_Util.indexOfName(__blaneyVector, crop.getID()); StateCU_BlaneyCriddle bc = null; if (bcindex != -1) { bc = (StateCU_BlaneyCriddle)__blaneyVector[bcindex]; if (bc.getFlag().Equals("Percent", StringComparison.OrdinalIgnoreCase)) { __coeffWorksheet.setColumnName(3, "PERCENT"); } else { __coeffWorksheet.setColumnName(3, "DAY"); } } __blaneyModel.setBlaneyCriddle(bc); }