/// <summary> /// Compare two rights lists and see if they are the same. </summary> /// <param name="v1"> the first list of StateMod_ReservoirRight s to check. Cannot be null. </param> /// <param name="v2"> the second list of StateMod_ReservoirRight s to check. Cannot be null. </param> /// <returns> true if they are the same, false if not. </returns> public static bool Equals(IList <StateMod_ReservoirRight> v1, IList <StateMod_ReservoirRight> v2) { StateMod_ReservoirRight r1; StateMod_ReservoirRight r2; if (v1.Count != v2.Count) { //Message.printStatus(2, routine, "Lists are different sizes"); return(false); } else { // sort the lists 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_ReservoirRight> v1Sort = StateMod_Util.sortStateMod_DataVector(v1); IList <StateMod_ReservoirRight> 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(2, routine, r1.toString()); //Message.printStatus(2, routine, r2.toString()); //Message.printStatus(2, routine, "Element " + i + " comparison: " + r1.compareTo(r2)); if (r1.CompareTo(r2) != 0) { return(false); } } } return(true); }
/// <summary> /// Compare two return flow lists and see if they are the same. </summary> /// <param name="v1"> the first list of StateMod_ReturnFlow to check. Cannot be null. </param> /// <param name="v2"> the second list of StateMod_ReturnFlow to check. Cannot be null. </param> /// <returns> true if they are the same, false if not. </returns> public static bool Equals(IList <StateMod_ReturnFlow> v1, IList <StateMod_ReturnFlow> v2) { string routine = "StateMod_ReturnFlow.equals"; StateMod_ReturnFlow rf1; StateMod_ReturnFlow rf2; if (v1.Count != v2.Count) { Message.printStatus(2, routine, "Return flow lists are different sizes"); return(false); } else { // Sort the lists and compare item-by-item. Any differences // and data will need to be saved back into the data set. int size = v1.Count; //Message.printStatus(2, routine, "Return flow lists are of size: " + size); IList <StateMod_ReturnFlow> v1Sort = StateMod_Util.sortStateMod_DataVector(v1); IList <StateMod_ReturnFlow> v2Sort = StateMod_Util.sortStateMod_DataVector(v2); //Message.printStatus(2, routine, "Return flow lists have been sorted"); for (int i = 0; i < size; i++) { rf1 = v1Sort[i]; rf2 = v2Sort[i]; Message.printStatus(2, routine, rf1.ToString()); Message.printStatus(2, routine, rf2.ToString()); //Message.printStatus(2, routine, "Element " + i + " comparison: " + rf1.compareTo(rf2)); if (rf1.CompareTo(rf2) != 0) { return(false); } } } return(true); }
/// <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_Well_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 //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> wv = (java.util.List<StateMod_WellRight>)__worksheet.getAllData(); IList <StateMod_WellRight> wv = (IList <StateMod_WellRight>)__worksheet.getAllData(); // w for worksheet IList <StateMod_WellRight> lv = (IList <StateMod_WellRight>)__currentWell.getRights(); // l for welL needToSave = !(StateMod_WellRight.Equals(wv, lv)); 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 //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>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_WELL_RIGHTS)).getData(); IList <StateMod_WellRight> wellRights = (IList <StateMod_WellRight>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_WELL_RIGHTS)).getData(); int size = lv.Count; StateMod_WellRight wr; for (int i = 0; i < size; i++) { wr = lv[i]; StateMod_Util.removeFromVector(wellRights, wr); } // now add the elements from the new Vector to the wellRights // Vector. size = wv.Count; StateMod_WellRight cwr = null; for (int i = 0; i < size; i++) { wr = (StateMod_WellRight)wv[i]; cwr = (StateMod_WellRight)wr.clone(); cwr._isClone = false; wellRights.Add(cwr); } // sort the wellRights Vector // REVISIT (JTS - 2003-10-10) // here we are sorting the full data array -- may be a performance // issue IList <StateMod_WellRight> sorted = StateMod_Util.sortStateMod_DataVector(wellRights); __dataset.getComponentForComponentType(StateMod_DataSet.COMP_WELL_RIGHTS).setData(sorted); __currentWell.disconnectRights(); __currentWell.connectRights(sorted); __dataset.setDirty(StateMod_DataSet.COMP_WELL_RIGHTS, true); return(true); }
/// <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_Diversion_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 dv = __currentDiv.getRights(); // d for diversion needToSave = !(StateMod_DiversionRight.Equals(wv, dv)); 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 diversionRights = (System.Collections.IList)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DIVERSION_RIGHTS)).getData(); int size = dv.Count; StateMod_DiversionRight dr; for (int i = 0; i < size; i++) { dr = (StateMod_DiversionRight)dv[i]; StateMod_Util.removeFromVector(diversionRights, dr); } // now add the elements from the new Vector to the diversionRights // Vector. size = wv.Count; StateMod_DiversionRight cdr = null; for (int i = 0; i < size; i++) { dr = (StateMod_DiversionRight)wv[i]; cdr = (StateMod_DiversionRight)dr.clone(); cdr._isClone = false; diversionRights.Add(cdr); } // sort the diversionRights 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(diversionRights); __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DIVERSION_RIGHTS).setData(sorted); __currentDiv.disconnectRights(); __currentDiv.connectRights(sorted); __dataset.setDirty(StateMod_DataSet.COMP_DIVERSION_RIGHTS, true); return(true); }