/// <summary> /// Performs data checks on instream flow right data. </summary> /// <param name="props"> A property list for specific properties /// on checking this data. </param> /// <param name="data_vector"> Vector of data to check. </param> private void checkInstreamFlowRightData(PropList props, System.Collections.IList data_vector) { // Create elements for the checks and check file string[] header = StateMod_InstreamFlowRight.getDataHeader(); System.Collections.IList data = new List <object>(); string title = "Instream Flow Right"; // Perform the general validation using the Data Table Model StateMod_Data_TableModel tm = new StateMod_InstreamFlowRight_Data_TableModel(data_vector, false); 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> /// 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]; } StateMod_InstreamFlowRight infr = (StateMod_InstreamFlowRight)_data.get(row); switch (col) { case COL_RIGHT_ID: return(infr.getID()); case COL_RIGHT_NAME: return(infr.getName()); case COL_STRUCT_ID: return(infr.getCgoto()); case COL_ADMIN_NUM: return(infr.getIrtem()); case COL_DCR_AMT: return(new double?(infr.getDcrifr())); case COL_ON_OFF: return(new int?(infr.getSwitch())); default: return(""); } }
/// <summary> /// Compares this object to another StateMod_Data object based on the sorted /// order from the StateMod_Data variables, and then by irtem and dcrifr, in that order. </summary> /// <param name="data"> the object to compare against. </param> /// <returns> 0 if they are the same, 1 if this object is greater than the other object, or -1 if it is less. </returns> public virtual int CompareTo(StateMod_Data data) { int res = base.CompareTo(data); if (res != 0) { return(res); } StateMod_InstreamFlowRight right = (StateMod_InstreamFlowRight)data; res = _irtem.CompareTo(right.getIrtem()); if (res == 0) { double dcrifr = right.getDcrifr(); if (dcrifr == _dcrifr) { return(0); } else if (_dcrifr < dcrifr) { return(-1); } else { return(1); } } else { return(res); } }
/// <summary> /// Clones the data object. </summary> /// <returns> a cloned object. </returns> public override object clone() { StateMod_InstreamFlowRight right = (StateMod_InstreamFlowRight)base.clone(); right._isClone = true; return(right); }
/// <summary> /// Adds a right for the instream flow station. /// </summary> public virtual void addRight(StateMod_InstreamFlowRight right) { if (right == null) { return; } _rights.Add(right); }
/// <summary> /// Sets the value at the specified position to the specified value. </summary> /// <param name="value"> the value to set the cell to. </param> /// <param name="row"> the row of the cell for which to set the value. </param> /// <param name="col"> the col of the cell for which to set the value. </param> public virtual void setValueAt(object value, int row, int col) { if (_sortOrder != null) { row = _sortOrder[row]; } double dval; int ival; StateMod_InstreamFlowRight ifr = (StateMod_InstreamFlowRight)_data.get(row); switch (col) { case COL_RIGHT_ID: ifr.setID((string)value); break; case COL_RIGHT_NAME: ifr.setName((string)value); break; case COL_STRUCT_ID: ifr.setCgoto((string)value); break; case COL_ADMIN_NUM: ifr.setIrtem((string)value); break; case COL_DCR_AMT: dval = ((double?)value).Value; ifr.setDcrifr(dval); break; case COL_ON_OFF: if (value is int?) { ival = ((int?)value).Value; ifr.setSwitch(ival); } else if (value is string) { string onOff = (string)value; int index = onOff.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(onOff.Substring(0, index))); ifr.setSwitch(ival); } /* * ival = ((Integer)value).intValue(); * ifr.setSwitch(ival); * break; */ break; } base.setValueAt(value, row, col); }
/// <summary> /// Called when the cancel button is pressed. This discards any changes made to the data objects. /// </summary> protected internal override void cancel() { StateMod_InstreamFlowRight isf = null; int size = _data.Count; for (int i = 0; i < size; i++) { isf = (StateMod_InstreamFlowRight)_data[i]; isf.restoreOriginal(); } }
/// <summary> /// Called when the Apply button is pressed. This commits any changes to the data objects. /// </summary> protected internal override void apply() { StateMod_InstreamFlowRight isf = null; int size = _data.Count; for (int i = 0; i < size; i++) { isf = (StateMod_InstreamFlowRight)_data[i]; isf.createBackup(); } }
/// <summary> /// Clones the data object. </summary> /// <returns> a cloned object. </returns> //public override object clone() //{ // StateMod_InstreamFlowRight right = (StateMod_InstreamFlowRight)base.clone(); // right._isClone = true; // return right; //} /// <summary> /// Creates a copy of the object for later use in checking to see if it was changed in a GUI. /// </summary> //public virtual void createBackup() //{ // _original = (StateMod_InstreamFlowRight)clone(); // ((StateMod_InstreamFlowRight)_original)._isClone = false; // _isClone = true; //} /// <summary> /// Compares this object to another StateMod_Data object based on the sorted /// order from the StateMod_Data variables, and then by irtem and dcrifr, in that order. </summary> /// <param name="data"> the object to compare against. </param> /// <returns> 0 if they are the same, 1 if this object is greater than the other object, or -1 if it is less. </returns> //public virtual int CompareTo(StateMod_Data data) //{ // int res = base.CompareTo(data); // if (res != 0) // { // return res; // } // StateMod_InstreamFlowRight right = (StateMod_InstreamFlowRight)data; // res = _irtem.CompareTo(right.getIrtem()); // if (res == 0) // { // double dcrifr = right.getDcrifr(); // if (dcrifr == _dcrifr) // { // return 0; // } // else if (_dcrifr < dcrifr) // { // return -1; // } // else // { // return 1; // } // } // else // { // return res; // } //} /// <summary> /// Compare two rights lists and see if they are the same. </summary> /// <param name="v1"> the first list of StateMod_InstreamFlowRights to check. Cannot be null. </param> /// <param name="v2"> the second list of StateMod_InstreamFlowRights to check. Cannot be null. </param> /// <returns> true if they are the same, false if not. </returns> //public static bool Equals(IList<StateMod_InstreamFlowRight> v1, IList<StateMod_InstreamFlowRight> v2) //{ // string routine = "StateMod_InstreamFlowRight.equals(Vector, Vector)"; // StateMod_InstreamFlowRight r1; // StateMod_InstreamFlowRight r2; // if (v1.Count != v2.Count) // { // Message.printStatus(1, routine, "Lists are different sizes"); // return false; // } // else // { // // sort the Vectors and compare item-by-item. Any differences // // and data will need to be saved back into the dataset. // int size = v1.Count; // Message.printStatus(2, routine, "Lists are of size: " + size); // IList<StateMod_InstreamFlowRight> v1Sort = StateMod_Util.sortStateMod_DataVector(v1); // IList<StateMod_InstreamFlowRight> v2Sort = StateMod_Util.sortStateMod_DataVector(v2); // Message.printStatus(2, routine, "Lists have been sorted"); // for (int i = 0; i < size; i++) // { // r1 = v1Sort[i]; // r2 = v2Sort[i]; // Message.printStatus(1, routine, r1.ToString()); // Message.printStatus(1, routine, r2.ToString()); // Message.printStatus(1, routine, "Element " + i + " comparison: " + r1.CompareTo(r2)); // if (r1.CompareTo(r2) != 0) // { // return false; // } // } // } // return true; //} /// <summary> /// Tests to see if two instream flow rights are equal. Strings are compared with case sensitivity. </summary> /// <param name="right"> the right to compare. </param> /// <returns> true if they are equal, false otherwise. </returns> public virtual bool Equals(StateMod_InstreamFlowRight right) { if (!base.Equals(right)) { return(false); } if (right._irtem.Equals(_irtem) && right._dcrifr == _dcrifr) { return(true); } return(false); }
/// <summary> /// Read instream flow rights information in and store in a list. </summary> /// <param name="filename"> Name of file to read. </param> /// <exception cref="Exception"> if there is an error reading the file. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static java.util.List<StateMod_InstreamFlowRight> readStateModFile(String filename) throws Exception public static IList <StateMod_InstreamFlowRight> readStateModFile(string filename) { string routine = "StateMod_InstreamFlowRight.readStateModFile"; IList <StateMod_InstreamFlowRight> theInsfRights = new List <StateMod_InstreamFlowRight>(); 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; StateMod_InstreamFlowRight aRight = null; IList <object> v = new List <object>(6); Message.printStatus(1, routine, "Reading Instream Flow Rights File: " + filename); StreamReader @in = null; try { @in = new StreamReader(filename); while (!string.ReferenceEquals((iline = @in.ReadLine()), null)) { // check for comments if (iline.StartsWith("#", StringComparison.Ordinal) || iline.Trim().Length == 0) { continue; } aRight = new StateMod_InstreamFlowRight(); 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.setDcrifr((double?)v[4]); aRight.setSwitch((int?)v[5]); theInsfRights.Add(aRight); } } catch (Exception e) { Message.printWarning(3, routine, e); throw e; } finally { if (@in != null) { @in.Close(); } } return(theInsfRights); }
// TODO - in the GUI need to decide if the right is actually removed from the main list /// <summary> /// Remove right from list. A comparison on the ID is made. </summary> /// <param name="right"> Right to remove. Note that the right is only removed from the /// list for this instream flow station and must also be removed from the main instream flow right list. </param> public virtual void disconnectRight(StateMod_InstreamFlowRight right) { if (right == null) { return; } int size = _rights.Count; StateMod_InstreamFlowRight right2; // Assume that more than on instance can exist, even though this is not allowed... for (int i = 0; i < size; i++) { right2 = _rights[i]; if (right2.getID().Equals(right.getID(), StringComparison.OrdinalIgnoreCase)) { _rights.RemoveAt(i); } } }
/// <summary> /// Writes a list of StateMod_InstreamFlowRight objects to a list file. A header /// is printed to the top of the file, containing the commands used to generate the /// file. Any strings in the body of the file that contain the field delimiter will be wrapped in "...". </summary> /// <param name="filename"> the name of the file to which the data will be written. </param> /// <param name="delimiter"> the delimiter to use for separating field values. </param> /// <param name="update"> whether to update an existing file, retaining the current /// header (true) or to create a new file with a new header. </param> /// <param name="data"> the list of objects to write. </param> /// <param name="newComments"> comments to add to the the file header. </param> /// <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 void writeListFile(String filename, String delimiter, boolean update, java.util.List<StateMod_InstreamFlowRight> data, java.util.List<String> newComments) throws Exception public static void writeListFile(string filename, string delimiter, bool update, IList <StateMod_InstreamFlowRight> data, IList <string> newComments) { string routine = "StateMod_IntreamFlowRight.writeListFile"; int size = 0; if (data != null) { size = data.Count; } IList <string> fields = new List <string>(); fields.Add("ID"); fields.Add("Name"); fields.Add("StationID"); fields.Add("AdministrationNumber"); fields.Add("Decree"); fields.Add("OnOff"); int fieldCount = fields.Count; string[] names = new string[fieldCount]; string[] formats = new string[fieldCount]; int comp = StateMod_DataSet.COMP_INSTREAM_RIGHTS; string s = null; for (int i = 0; i < fieldCount; i++) { s = fields[i]; names[i] = StateMod_Util.lookupPropValue(comp, "FieldName", s); formats[i] = StateMod_Util.lookupPropValue(comp, "Format", s); } string oldFile = null; if (update) { oldFile = IOUtil.getPathUsingWorkingDir(filename); } int j = 0; PrintWriter @out = null; StateMod_InstreamFlowRight right = null; IList <string> commentIndicators = new List <string>(1); commentIndicators.Add("#"); IList <string> ignoredCommentIndicators = new List <string>(1); ignoredCommentIndicators.Add("#>"); string[] line = new string[fieldCount]; StringBuilder buffer = new StringBuilder(); try { // Add some basic comments at the top of the file. Do this to a copy of the // incoming comments so that they are not modified in the calling code. IList <string> newComments2 = null; if (newComments == null) { newComments2 = new List <string>(); } else { newComments2 = new List <string>(newComments); } newComments2.Insert(0, ""); newComments2.Insert(1, "StateMod instream flow rights as a delimited list file."); newComments2.Insert(2, ""); @out = IOUtil.processFileHeaders(oldFile, IOUtil.getPathUsingWorkingDir(filename), newComments2, commentIndicators, ignoredCommentIndicators, 0); for (int i = 0; i < fieldCount; i++) { if (i > 0) { buffer.Append(delimiter); } buffer.Append("\"" + names[i] + "\""); } @out.println(buffer.ToString()); for (int i = 0; i < size; i++) { right = data[i]; line[0] = StringUtil.formatString(right.getID(), formats[0]).Trim(); line[1] = StringUtil.formatString(right.getName(), formats[1]).Trim(); line[2] = StringUtil.formatString(right.getCgoto(), formats[2]).Trim(); line[3] = StringUtil.formatString(right.getIrtem(), formats[3]).Trim(); line[4] = StringUtil.formatString(right.getDcrifr(), formats[4]).Trim(); line[5] = StringUtil.formatString(right.getSwitch(), formats[5]).Trim(); buffer = new StringBuilder(); for (j = 0; j < fieldCount; j++) { if (j > 0) { buffer.Append(delimiter); } if (line[j].IndexOf(delimiter, StringComparison.Ordinal) > -1) { line[j] = "\"" + line[j] + "\""; } buffer.Append(line[j]); } @out.println(buffer.ToString()); } } catch (Exception e) { Message.printWarning(3, routine, e); throw e; } finally { if (@out != null) { @out.flush(); @out.close(); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void saveComponent(RTi.Util.IO.DataSetComponent comp, String oldFilename,String newFilename, java.util.List<String> comments) throws Exception private void saveComponent(DataSetComponent comp, string oldFilename, string newFilename, IList <string> comments) { bool daily = false; int type = comp.getComponentType(); object data = comp.getData(); string name = null; switch (type) { //////////////////////////////////////////////////////// // StateMod_* classes case StateMod_DataSet.COMP_CONTROL: StateMod_DataSet.writeStateModControlFile(__dataset, oldFilename, newFilename, comments); name = "Control"; break; case StateMod_DataSet.COMP_DELAY_TABLES_DAILY: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DelayTable> delayTablesDaily = (java.util.List<StateMod_DelayTable>)data; IList <StateMod_DelayTable> delayTablesDaily = (IList <StateMod_DelayTable>)data; StateMod_DelayTable.writeStateModFile(oldFilename, newFilename, delayTablesDaily, comments, __dataset.getInterv(), -1); name = "Delay Tables Daily"; break; case StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DelayTable> delayTablesMonthly = (java.util.List<StateMod_DelayTable>)data; IList <StateMod_DelayTable> delayTablesMonthly = (IList <StateMod_DelayTable>)data; StateMod_DelayTable.writeStateModFile(oldFilename, newFilename, delayTablesMonthly, comments, __dataset.getInterv(), -1); name = "Delay Tables Monthly"; break; case StateMod_DataSet.COMP_DIVERSION_STATIONS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Diversion> diversionStations = (java.util.List<StateMod_Diversion>)data; IList <StateMod_Diversion> diversionStations = (IList <StateMod_Diversion>)data; StateMod_Diversion.writeStateModFile(oldFilename, newFilename, diversionStations, comments, daily); name = "Diversion"; break; case StateMod_DataSet.COMP_DIVERSION_RIGHTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DiversionRight> diversionRights = (java.util.List<StateMod_DiversionRight>)data; IList <StateMod_DiversionRight> diversionRights = (IList <StateMod_DiversionRight>)data; StateMod_DiversionRight.writeStateModFile(oldFilename, newFilename, diversionRights, comments, daily); name = "Diversion Rights"; break; case StateMod_DataSet.COMP_INSTREAM_STATIONS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_InstreamFlow> instreamFlow = (java.util.List<StateMod_InstreamFlow>)data; IList <StateMod_InstreamFlow> instreamFlow = (IList <StateMod_InstreamFlow>)data; StateMod_InstreamFlow.writeStateModFile(oldFilename, newFilename, instreamFlow, comments, daily); name = "Instream"; break; case StateMod_DataSet.COMP_INSTREAM_RIGHTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_InstreamFlowRight> instreamFlowRights = (java.util.List<StateMod_InstreamFlowRight>)data; IList <StateMod_InstreamFlowRight> instreamFlowRights = (IList <StateMod_InstreamFlowRight>)data; StateMod_InstreamFlowRight.writeStateModFile(oldFilename, newFilename, instreamFlowRights, comments); name = "Instream Rights"; break; case StateMod_DataSet.COMP_OPERATION_RIGHTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_OperationalRight> operationalRights = (java.util.List<StateMod_OperationalRight>)data; IList <StateMod_OperationalRight> operationalRights = (IList <StateMod_OperationalRight>)data; // 2 is the file version (introduced for StateMod version 12 change) StateMod_OperationalRight.writeStateModFile(oldFilename, newFilename, 2, operationalRights, comments, __dataset); name = "Operational Rights"; break; case StateMod_DataSet.COMP_PLANS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Plan> planStations = (java.util.List<StateMod_Plan>)data; IList <StateMod_Plan> planStations = (IList <StateMod_Plan>)data; StateMod_Plan.writeStateModFile(oldFilename, newFilename, planStations, comments); name = "Plan"; break; case StateMod_DataSet.COMP_RESERVOIR_STATIONS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Reservoir> reservoirStations = (java.util.List<StateMod_Reservoir>)data; IList <StateMod_Reservoir> reservoirStations = (IList <StateMod_Reservoir>)data; StateMod_Reservoir.writeStateModFile(oldFilename, newFilename, reservoirStations, comments, daily); name = "Reservoir"; break; case StateMod_DataSet.COMP_RESERVOIR_RIGHTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_ReservoirRight> reservoirRights = (java.util.List<StateMod_ReservoirRight>)data; IList <StateMod_ReservoirRight> reservoirRights = (IList <StateMod_ReservoirRight>)data; StateMod_ReservoirRight.writeStateModFile(oldFilename, newFilename, reservoirRights, comments); name = "Reservoir Rights"; break; case StateMod_DataSet.COMP_RESPONSE: StateMod_DataSet.writeStateModFile(__dataset, oldFilename, newFilename, comments); name = "Response"; break; case StateMod_DataSet.COMP_RIVER_NETWORK: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_RiverNetworkNode> riverNodes = (java.util.List<StateMod_RiverNetworkNode>)data; IList <StateMod_RiverNetworkNode> riverNodes = (IList <StateMod_RiverNetworkNode>)data; StateMod_RiverNetworkNode.writeStateModFile(oldFilename, newFilename, riverNodes, comments, true); name = "River Network"; break; case StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_StreamEstimate> streamEstimateStations = (java.util.List<StateMod_StreamEstimate>)data; IList <StateMod_StreamEstimate> streamEstimateStations = (IList <StateMod_StreamEstimate>)data; StateMod_StreamEstimate.writeStateModFile(oldFilename, newFilename, streamEstimateStations, comments, daily); name = "Stream Estimate"; break; case StateMod_DataSet.COMP_STREAMESTIMATE_COEFFICIENTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_StreamEstimate_Coefficients> streamEstimateCoefficients = (java.util.List<StateMod_StreamEstimate_Coefficients>)data; IList <StateMod_StreamEstimate_Coefficients> streamEstimateCoefficients = (IList <StateMod_StreamEstimate_Coefficients>)data; StateMod_StreamEstimate_Coefficients.writeStateModFile(oldFilename, newFilename, streamEstimateCoefficients, comments); name = "Stream Estimate Coefficients"; break; case StateMod_DataSet.COMP_STREAMGAGE_STATIONS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_StreamGage> streamGageStations = (java.util.List<StateMod_StreamGage>)data; IList <StateMod_StreamGage> streamGageStations = (IList <StateMod_StreamGage>)data; StateMod_StreamGage.writeStateModFile(oldFilename, newFilename, streamGageStations, comments, daily); name = "Streamgage Stations"; break; case StateMod_DataSet.COMP_WELL_STATIONS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Well> wellStations = (java.util.List<StateMod_Well>)data; IList <StateMod_Well> wellStations = (IList <StateMod_Well>)data; StateMod_Well.writeStateModFile(oldFilename, newFilename, wellStations, comments); name = "Well"; break; case StateMod_DataSet.COMP_WELL_RIGHTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_WellRight> wellRights = (java.util.List<StateMod_WellRight>)data; IList <StateMod_WellRight> wellRights = (IList <StateMod_WellRight>)data; StateMod_WellRight.writeStateModFile(oldFilename, newFilename, wellRights, comments, (PropList)null); name = "Well Rights"; break; ////////////////////////////////////////////////////// // StateMod Time Series case StateMod_DataSet.COMP_CONSUMPTIVE_WATER_REQUIREMENT_TS_DAILY: case StateMod_DataSet.COMP_CONSUMPTIVE_WATER_REQUIREMENT_TS_MONTHLY: case StateMod_DataSet.COMP_DEMAND_TS_DAILY: case StateMod_DataSet.COMP_DEMAND_TS_AVERAGE_MONTHLY: case StateMod_DataSet.COMP_DEMAND_TS_MONTHLY: case StateMod_DataSet.COMP_DEMAND_TS_OVERRIDE_MONTHLY: case StateMod_DataSet.COMP_DIVERSION_TS_DAILY: case StateMod_DataSet.COMP_DIVERSION_TS_MONTHLY: case StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY: case StateMod_DataSet.COMP_INSTREAM_DEMAND_TS_AVERAGE_MONTHLY: case StateMod_DataSet.COMP_INSTREAM_DEMAND_TS_DAILY: case StateMod_DataSet.COMP_INSTREAM_DEMAND_TS_MONTHLY: case StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY: case StateMod_DataSet.COMP_RESERVOIR_CONTENT_TS_DAILY: case StateMod_DataSet.COMP_RESERVOIR_CONTENT_TS_MONTHLY: case StateMod_DataSet.COMP_RESERVOIR_TARGET_TS_DAILY: case StateMod_DataSet.COMP_RESERVOIR_TARGET_TS_MONTHLY: case StateMod_DataSet.COMP_STREAMESTIMATE_NATURAL_FLOW_TS_DAILY: case StateMod_DataSet.COMP_STREAMESTIMATE_NATURAL_FLOW_TS_MONTHLY: case StateMod_DataSet.COMP_STREAMGAGE_NATURAL_FLOW_TS_DAILY: case StateMod_DataSet.COMP_STREAMGAGE_NATURAL_FLOW_TS_MONTHLY: case StateMod_DataSet.COMP_STREAMGAGE_HISTORICAL_TS_DAILY: case StateMod_DataSet.COMP_STREAMGAGE_HISTORICAL_TS_MONTHLY: case StateMod_DataSet.COMP_WELL_DEMAND_TS_DAILY: case StateMod_DataSet.COMP_WELL_DEMAND_TS_MONTHLY: case StateMod_DataSet.COMP_WELL_PUMPING_TS_DAILY: case StateMod_DataSet.COMP_WELL_PUMPING_TS_MONTHLY: double missing = -999.0; YearType yearType = null; if (__dataset.getCyrl() == YearType.CALENDAR) { yearType = YearType.CALENDAR; } else if (__dataset.getCyrl() == YearType.WATER) { yearType = YearType.WATER; } else if (__dataset.getCyrl() == YearType.NOV_TO_OCT) { yearType = YearType.NOV_TO_OCT; } int precision = 2; // Do the following to avoid warnings IList <TS> tslist = null; if (data != null) { //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<RTi.TS.TS> tslist0 = (java.util.List<RTi.TS.TS>)data; IList <TS> tslist0 = (IList <TS>)data; if (tslist0.Count > 0) { TS ts = tslist0[0]; missing = ts.getMissing(); } tslist = tslist0; } StateMod_TS.writeTimeSeriesList(oldFilename, newFilename, comments, tslist, null, null, yearType, missing, precision); name = "TS (" + type + ")"; break; default: name = "(something: " + type + ")"; break; } comp.setDirty(false); Message.printStatus(1, "", "Component '" + name + "' written"); }
/// <summary> /// Saves the input back into the dataset. </summary> /// <returns> true if the data was saved successfuly. False if not. </returns> private bool saveData() { string routine = "StateMod_InstreamFlow_Right_JFrame.saveData"; if (!__worksheet.stopEditing()) { // don't save if there are errors. Message.printWarning(1, routine, "There are errors in the data " + "that must be corrected before data can be saved.", this); return(false); } if (checkInput() > 0) { return(false); } // now only save data if any are different. bool needToSave = false; // if the Vectors are differently-sized, they're different System.Collections.IList wv = __worksheet.getAllData(); // w for worksheet System.Collections.IList iv = __currentInstreamFlow.getRights(); // i for instream flow needToSave = !(StateMod_InstreamFlowRight.Equals(wv, iv)); Message.printStatus(1, routine, "Saving? .........[" + needToSave + "]"); if (!needToSave) { // there's nothing different -- users may even have deleted // some rights and added back in identical values return(true); } // at this point, remove the old diversion rights from the original // component Vector System.Collections.IList instreamFlowRights = (System.Collections.IList)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_INSTREAM_RIGHTS)).getData(); int size = iv.Count; StateMod_InstreamFlowRight ir; for (int i = 0; i < size; i++) { ir = (StateMod_InstreamFlowRight)iv[i]; StateMod_Util.removeFromVector(instreamFlowRights, ir); } // now add the elements from the new Vector to the instreamFlowRights // Vector. size = wv.Count; StateMod_InstreamFlowRight cir = null; for (int i = 0; i < size; i++) { ir = (StateMod_InstreamFlowRight)wv[i]; cir = (StateMod_InstreamFlowRight)(ir.clone()); cir._isClone = false; instreamFlowRights.Add(cir); } // sort the instreamFlowRights Vector // REVISIT (JTS - 2003-10-10) // here we are sorting the full data array -- may be a performance // issue System.Collections.IList sorted = StateMod_Util.sortStateMod_DataVector(instreamFlowRights); __dataset.getComponentForComponentType(StateMod_DataSet.COMP_INSTREAM_RIGHTS).setData(sorted); __currentInstreamFlow.disconnectRights(); __currentInstreamFlow.connectRights(sorted); __dataset.setDirty(StateMod_DataSet.COMP_INSTREAM_RIGHTS, true); return(true); }
/// <summary> /// Checks the data to make sure that all the data are valid. </summary> /// <returns> 0 if the data are valid, 1 if errors exist and -1 if non-fatal errors /// exist. </returns> private int checkInput() { string routine = "StateMod_InstreamFlow_Right_JFrame.checkInput"; System.Collections.IList v = __worksheet.getAllData(); int size = v.Count; StateMod_InstreamFlowRight right = null; string warning = ""; string id; string name; string isfID; string adminNum; int fatalCount = 0; for (int i = 0; i < size; i++) { right = (StateMod_InstreamFlowRight)(v[i]); id = right.getID(); name = right.getName(); isfID = right.getCgoto(); adminNum = right.getIrtem(); if (id.Length > 12) { warning += "\nInstream flow right ID (" + id + ") is longer than 12 characters."; fatalCount++; } if (id.IndexOf(" ", StringComparison.Ordinal) > -1 || id.IndexOf("-", StringComparison.Ordinal) > -1) { warning += "\nInstream flow right ID (" + id + ") cannot contain spaces or dashes."; fatalCount++; } if (name.Length > 24) { warning += "\nInstream flow name (" + name + ") is " + "longer than 24 characters."; fatalCount++; } if (isfID.Length > 12) { warning += "\nInstream flow ID associated with right (" + isfID + ") is longer than 12 characters."; } if (!StringUtil.isDouble(adminNum)) { warning += "\nAdministration number (" + adminNum + ") is not a number."; fatalCount++; } // decreed amount is not checked to be a double because that // is enforced by the worksheet and its table model // on/off is not checked to be an integer because that is // enforced by the worksheet and its table model } // REVISIT - if daily time series are supplied, check for time series // and allow creation if not available. if (warning.Length > 0) { warning += "\nCorrect or Cancel."; Message.printWarning(1, routine, warning, this); if (fatalCount > 0) { // Fatal errors... Message.printStatus(1, routine, "Returning 1 from checkInput()"); return(1); } else { // Nonfatal errors... Message.printStatus(1, routine, "Returning -1 from checkInput()"); return(-1); } } else { // No errors... Message.printStatus(1, routine, "Returning 0 from checkInput()"); return(0); } }
/// <summary> /// Responds to action performed events. </summary> /// <param name="e"> the ActionEvent that happened. </param> public virtual void actionPerformed(ActionEvent e) { string routine = "StateMod_InstreamFlow_Right_JFrame.actionPerformed"; string action = e.getActionCommand(); if (action.Equals(__BUTTON_ADD_RIGHT)) { StateMod_InstreamFlowRight aRight = new StateMod_InstreamFlowRight(); aRight._isClone = true; StateMod_InstreamFlowRight last = (StateMod_InstreamFlowRight)__worksheet.getLastRowData(); if (last == null) { aRight.setID(StateMod_Util.createNewID(__currentInstreamFlow.getID())); aRight.setCgoto(__currentInstreamFlow.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 instream flow 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 selected 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(); } }