/// <summary> /// Responds to action events. </summary> /// <param name="event"> the ActionEvent that happened. </param> public virtual void actionPerformed(ActionEvent @event) { string routine = "StateMod_Data_JFrame.actionPerformed"; string action = @event.getActionCommand(); if (action.Equals(_BUTTON_APPLY)) { _worksheet.stopEditing(); apply(); } else if (action.Equals(_BUTTON_CANCEL)) { _worksheet.cancelEditing(); cancel(); closeJFrame(); } else if (action.Equals(_BUTTON_EXPORT)) { string[] s = getFilenameAndFormat(); if (s == null) { // user cancelled return; } IList <string> v = formatOutput(s[1], true, true); try { export(s[0], v); } catch (Exception e) { Message.printWarning(1, routine, "Error exporting data."); Message.printWarning(2, routine, e); } } else if (action.Equals(_BUTTON_OK)) { _worksheet.stopEditing(); apply(); closeJFrame(); } else if (action.Equals(_BUTTON_PRINT)) { print(); } }
/// <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_ReturnFlow_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 lists 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_ReturnFlow> wv = (java.util.List<StateMod_ReturnFlow>)__worksheet.getAllData(); IList <StateMod_ReturnFlow> wv = (IList <StateMod_ReturnFlow>)__worksheet.getAllData(); // w for worksheet System.Collections.IList dv = __currentDiv.getReturnFlows(); // d for diversion needToSave = !(StateMod_ReturnFlow.Equals(wv, dv)); Message.printStatus(1, routine, "Saving? .........[" + needToSave + "]"); if (!needToSave) { // there's nothing different -- users may even have deleted // some return flow locations and added back in identical values return(true); } // clone the objects from the worksheet vector and assign them // to the diversion object as its new return flows. int size = wv.Count; IList <StateMod_ReturnFlow> clone = new List <StateMod_ReturnFlow>(); StateMod_ReturnFlow rf = null; StateMod_ReturnFlow crf = null; for (int i = 0; i < size; i++) { rf = wv[i]; crf = (StateMod_ReturnFlow)rf.clone(); rf.setCrtnid(StringUtil.getToken(rf.getCrtnid(), " ", StringUtil.DELIM_SKIP_BLANKS, 0)); crf._isClone = false; clone.Add(crf); } __currentDiv.setReturnFlow(clone); __dataset.setDirty(StateMod_DataSet.COMP_DIVERSION_STATIONS, 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_Well_ReturnFlow_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 lv = __currentWell.getReturnFlows(); // l for welL needToSave = !(StateMod_ReturnFlow.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); } // clone the objects from the worksheet vector and assign them // to the well object as its new return flows. int size = wv.Count; System.Collections.IList clone = new List <object>(); StateMod_ReturnFlow rf; StateMod_ReturnFlow crf = null; for (int i = 0; i < size; i++) { rf = (StateMod_ReturnFlow)wv[i]; crf = (StateMod_ReturnFlow)rf.clone(); crf.setCrtnid(StringUtil.getToken(rf.getCrtnid(), " ", StringUtil.DELIM_SKIP_BLANKS, 0)); crf._isClone = false; clone.Add(crf); } __currentWell.setReturnFlows(clone); __dataset.setDirty(StateMod_DataSet.COMP_WELL_STATIONS, 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_Reservoir_Owner_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_ReservoirAccount> wv = (java.util.List<StateMod_ReservoirAccount>)__worksheet.getAllData(); IList <StateMod_ReservoirAccount> wv = (IList <StateMod_ReservoirAccount>)__worksheet.getAllData(); // w for worksheet IList <StateMod_ReservoirAccount> rv = __currentRes.getAccounts(); // i for instream flow needToSave = !(StateMod_ReservoirAccount.Equals(wv, rv)); 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); } // now add the elements from the new Vector to the reservoirRights // Vector. int size = wv.Count; IList <StateMod_ReservoirAccount> clone = new List <StateMod_ReservoirAccount>(); StateMod_ReservoirAccount ra; for (int i = 0; i < size; i++) { ra = (StateMod_ReservoirAccount)wv[i].clone(); clone.Add(ra); } __currentRes.setAccounts(clone); __dataset.setDirty(StateMod_DataSet.COMP_RESERVOIR_STATIONS, true); return(true); }
private int checkInput() { if (!__worksheetR.stopEditing()) { return 1; } return 0; /* int size = __worksheetR.getRowCount(); String warning = ""; int fatalCount = 0; for (int i = 0; i < size; i++) { if (!StringUtil.isDouble()) { warning += "\nAdministration number (" + adminNum + ") is not a number."; fatalCount++; } */ }
/// <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_Reservoir_Climate_JFrame.saveData"; if (!__worksheetP.stopEditing()) { // don't save if there are errors. Message.printWarning(1, routine, "There are errors in the " + "precipitation data " + "that must be corrected before data can be saved.", this); return(false); } if (!__worksheetE.stopEditing()) { // don't save if there are errors. Message.printWarning(1, routine, "There are errors in the " + "evaporation data " + "that must be corrected before data can be saved.", this); return(false); } if (checkInput(__worksheetP, "Precipitation") > 0) { return(false); } if (checkInput(__worksheetE, "Evaporation") > 0) { return(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_ReservoirClimate> wv1 = (java.util.List<StateMod_ReservoirClimate>)__worksheetP.getAllData(); IList <StateMod_ReservoirClimate> wv1 = (IList <StateMod_ReservoirClimate>)__worksheetP.getAllData(); // w for worksheet IList <StateMod_ReservoirClimate> rv1 = getPrecipitationStations(__currentRes.getClimates()); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_ReservoirClimate> wv2 = (java.util.List<StateMod_ReservoirClimate>)__worksheetE.getAllData(); IList <StateMod_ReservoirClimate> wv2 = (IList <StateMod_ReservoirClimate>)__worksheetE.getAllData(); // w for worksheet IList <StateMod_ReservoirClimate> rv2 = getEvaporationStations(__currentRes.getClimates()); bool needToSave1 = !(StateMod_ReservoirClimate.Equals(wv1, rv1)); bool needToSave2 = !(StateMod_ReservoirClimate.Equals(wv2, rv2)); Message.printStatus(1, routine, "Saving Precip? .......[" + needToSave1 + "]"); Message.printStatus(1, routine, "Saving Evap? .........[" + needToSave2 + "]"); if (!needToSave1 && !needToSave2) { // there's nothing different -- users may even have deleted // some rights and added back in identical values return(true); } int size = wv1.Count; IList <StateMod_ReservoirClimate> clone = new List <StateMod_ReservoirClimate>(); StateMod_ReservoirClimate r = null; StateMod_ReservoirClimate cr = null; for (int i = 0; i < size; i++) { r = wv1[i]; cr = (StateMod_ReservoirClimate)r.clone(); cr._isClone = false; clone.Add(cr); } size = wv2.Count; for (int i = 0; i < size; i++) { r = wv2[i]; cr = (StateMod_ReservoirClimate)r.clone(); cr._isClone = false; clone.Add(cr); } __currentRes.setClimates(clone); __dataset.setDirty(StateMod_DataSet.COMP_DIVERSION_STATIONS, 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_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); }