/// <summary> /// Sets up the data Vectors to display the location climate station data in the GUI. /// </summary> private void setupData() { int num = 0; int size = _data.size(); StateCU_Location l = null; string id = null; __data = new System.Collections.IList[__COLUMNS]; for (int i = 0; i < __COLUMNS; i++) { __data[i] = new List <object>(); } int rows = 0; for (int i = 0; i < size; i++) { l = (StateCU_Location)_data.get(i); id = l.getID(); num = l.getNumClimateStations(); for (int j = 0; j < num; j++) { __data[__COL_ID].Add(id); __data[__COL_STA_ID].Add(l.getClimateStationID(j)); __data[__COL_TEMP_WT].Add(new double?(l.getTemperatureStationWeight(j))); __data[__COL_PRECIP_WT].Add(new double?(l.getPrecipitationStationWeight(j))); __data[__COL_ORO_TEMP_ADJ].Add(new double?(l.getOrographicTemperatureAdjustment(j))); __data[__COL_ORO_PRECIP_ADJ].Add(new double?(l.getOrographicPrecipitationAdjustment(j))); rows++; } } _rows = rows; }
public virtual void setRights(StateCU_Location location, System.Collections.IList rights) { __parentLocation = location; __rights = rights; _rows = __rights.Count; fireTableDataChanged(); }
public virtual void setStations(StateCU_Location location, System.Collections.IList stations) { __parentLocation = location; __stations = stations; _rows = location.getNumClimateStations(); fireTableDataChanged(); }
/// <summary> /// Called when the cancel button is pressed. This discards any changes made to the data objects. /// </summary> protected internal override void cancel() { StateCU_Location station = null; int size = _data.Count; for (int i = 0; i < size; i++) { station = (StateCU_Location)_data[i]; station.restoreOriginal(); } }
/// <summary> /// Called when the Apply button is pressed. This commits any changes to the data /// objects. /// </summary> protected internal override void apply() { StateCU_Location station = null; int size = _data.Count; for (int i = 0; i < size; i++) { station = (StateCU_Location)_data[i]; station.createBackup(); } }
public virtual void setDelay(StateCU_Location location, StateCU_DelayTableAssignment dta) { __parentLocation = location; __delays = dta; if (dta == null) { _rows = 0; } else { _rows = dta.getNumDelayTables(); } fireTableDataChanged(); }
/// <summary> /// Performs general and specific data checks on location data. </summary> /// <param name="props"> A property list for specific properties. </param> /// <param name="data_vector"> Vector of data to check. </param> private void checkLocationData(PropList props, System.Collections.IList data_vector) { // Create elements for the checks and check file string[] header = StateCU_Location.getDataHeader(); System.Collections.IList data = new List <object>(); string title = "CU Location"; // Perform the general validation using the Data Table Model StateCU_Data_TableModel tm; try { tm = new StateCU_Location_TableModel(data_vector, false, false); } catch (Exception e) { Message.printWarning(3, "StateCU_ComponentDataCheck.checkLocationData", e); return; } System.Collections.IList @checked = performDataValidation(tm, title); //String [] columnHeader = getDataTableModelColumnHeader( tm ); string[] columnHeader = getColumnHeader(tm); // Do specific checks int size = 0; if (data_vector != null) { size = data_vector.Count; } data = doSpecificDataChecks(data_vector, props); // Add the data and checks to the check file. // Provides basic header information for this data check table string info = "The following " + title + " (" + data.Count + " out of " + size + ") have no ....."; // Create data models for Check file CheckFile_DataModel dm = new CheckFile_DataModel(data, header, title, info, data.Count, size); CheckFile_DataModel gen_dm = new CheckFile_DataModel(@checked, columnHeader, title + " Missing or Invalid Data", "", __gen_problems, size); __check_file.addData(dm, gen_dm); }
/// <summary> /// From AbstractTableMode. 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]; } if (__singleLocation) { switch (col) { case 1: case 2: StateCU_Location location = (StateCU_Location)_data.get(row); switch (col) { case 1: return(location.getID()); case 2: return(location.getName()); } case 3: return(new double?(__delays.getDelayTablePercent(row))); case 4: return(__delays.getDelayTableID(row)); case 5: return(__parentLocation.getClimateStationID(row)); case 6: int index = StateCU_Util.IndexOf(__stations, __parentLocation.getClimateStationID(row)); if (index == -1) { return("N/A"); } return(((StateCU_ClimateStation)__stations[row]).getName()); case 7: return(new double?(__parentLocation.getPrecipitationStationWeight(row))); case 8: return(new double?(__parentLocation.getTemperatureStationWeight(row))); case 9: case 10: case 11: case 12: case 13: StateMod_DiversionRight right = (StateMod_DiversionRight)__rights[row]; switch (col) { case 9: return(right.getID()); case 10: return(right.getName()); case 11: return(Convert.ToDouble(right.getIrtem())); case 12: return(new double?(right.getDcrdiv())); case 13: return(new int?(right.getSwitch())); } default: return(""); } } else { StateCU_Location location = (StateCU_Location)_data.get(row); switch (col) { case __COL_ID: return(location.getID()); case __COL_NAME: return(location.getName()); case __COL_ELEVATION: return(new double?(location.getElevation())); case __COL_LATITUDE: return(new double?(location.getLatitude())); case __COL_REGION1: return(location.getRegion1()); case __COL_REGION2: return(location.getRegion2()); case __COL_NUM_STA: return(new int?(location.getNumClimateStations())); case __COL_AWC: return(new double?(location.getAwc())); } } return(""); }
/// <summary> /// Sets up the data Vectors to display the location collection data in the GUI. /// </summary> private void setupData() { int?div = null; int[] years = null; int yearArrayLen = 0; int nculoc = _data.size(); int nParts = 0; int nIdTypes = 0; StateCU_Location culoc = null; string colType = null; string id = null; string partType = null; System.Collections.IList ids = null; System.Collections.IList idTypes = null; string idType = null; __data = new System.Collections.IList[__COLUMNS]; for (int i = 0; i < __COLUMNS; i++) { __data[i] = new List <object>(); } int rows = 0; for (int i = 0; i < nculoc; i++) { culoc = (StateCU_Location)_data.get(i); id = culoc.getID(); div = new int?(culoc.getCollectionDiv()); years = culoc.getCollectionYears(); colType = culoc.getCollectionType(); partType = culoc.getCollectionPartType(); if (years == null) { yearArrayLen = 1; // Cause the loop below to go through once } else { yearArrayLen = years.Length; } for (int j = 0; j < yearArrayLen; j++) { // Part IDs for the year if ((years == null) || (years.Length == 0)) { ids = culoc.getCollectionPartIDsForYear(0); } else { ids = culoc.getCollectionPartIDsForYear(years[j]); } // Part ID types for the year. idTypes = culoc.getCollectionPartIDTypes(); if (ids == null) { nParts = 0; } else { nParts = ids.Count; } if (idTypes == null) { nIdTypes = 0; } else { nIdTypes = idTypes.Count; } for (int k = 0; k < nParts; k++) { __data[__COL_ID].Add(id); __data[__COL_DIV].Add(div); __data[__COL_YEAR].Add(new int?(years[j])); __data[__COL_COL_TYPE].Add(colType); __data[__COL_PART_TYPE].Add(partType); __data[__COL_PART_ID].Add(ids[k]); idType = ""; if (nIdTypes != 0) { idType = (string)idTypes[k]; // Should align with ids.get(k) } __data[__COL_PART_ID_TYPE].Add(idType); rows++; } } } _rows = rows; }