/// <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> /// Checks to see if any data has changed in the delay table and if so, writes /// the delay table back into the StateMod_DelayTable object. /// </summary> private void saveDelayTable() { int index = __currentIndex; if (index < 0) { return; } //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<System.Nullable<double>> v = (java.util.List<System.Nullable<double>>)__worksheetR.getAllData(); IList<double?> v = (IList<double?>)__worksheetR.getAllData(); /* StateMod_DelayTable dt = (StateMod_DelayTable)__worksheetL.getRowData(index); Vector dv = dt.getRet_val(); boolean needToSave = false; if (wv.size() != dv.size()) { // definitely save needToSave = true; } else { int size = wv.size(); Double d1; Double d2; for (int i = 0; i < size; i++) { d1 = (Double)wv.elementAt(i); d2 = (Double)dv.elementAt(i); if (d1.compareTo(d2) != 0) { needToSave = true; i = size + 1; } } } Message.printStatus(1, routine, "Saving? .........[" + needToSave +"]"); if (!needToSave) { return; } Vector clone = new Vector(); int size = wv.size(); for (int i = 0; i < size; i++) { clone.add(new Double(((Double)wv.elementAt(i)).doubleValue())); } dt.setRet_val(clone); */ __delaysVector[index].setRet_val(v); }
/// <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_Reservoir_Return_JFrame.checkInput"; //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> v = (java.util.List<StateMod_ReturnFlow>)__worksheet.getAllData(); IList <StateMod_ReturnFlow> v = (IList <StateMod_ReturnFlow>)__worksheet.getAllData(); int size = v.Count; StateMod_ReturnFlow aReturn = null; string warning = ""; string id; string riverNodeID; //double percent; //String tableID; int fatalCount = 0; //String comment; for (int i = 0; i < size; i++) { aReturn = v[i]; id = aReturn.getID(); riverNodeID = aReturn.getCrtnid(); //percent = aReturn.getPcttot(); //tableID = "" + aReturn.getIrtndl(); //comment = aReturn.getComment(); // TODO SAM 2011-01-02 Need to implement validators if (id.Length > 12) { warning += "\nReservoir ID (" + id + ") is longer than 12 characters."; fatalCount++; } if (id.IndexOf(" ", StringComparison.Ordinal) > -1 || id.IndexOf("-", StringComparison.Ordinal) > -1) { warning += "\nReservoir ID (" + id + ") cannot contain spaces or dashes."; fatalCount++; } if (riverNodeID.Length > 12) { warning += "River node ID (" + riverNodeID + ") is longer than 12 characters."; } } 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(2, routine, "Returning 0 from checkInput()"); return(0); } }
/// <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_Reservoir_Owner_JFrame.checkInput"; //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> v = (java.util.List<StateMod_ReservoirAccount>)__worksheet.getAllData(); IList <StateMod_ReservoirAccount> v = (IList <StateMod_ReservoirAccount>)__worksheet.getAllData(); int size = v.Count; StateMod_ReservoirAccount acct = null; string warning = ""; string id; string name; int fatalCount = 0; int lastID = 0; int currID = 0; if (size > 0) { acct = v[0]; id = acct.getID(); if (!id.Trim().Equals("1")) { warning += "\nThe first reservoir account must have " + "an ID of '1', not '" + id + "'"; fatalCount++; } } for (int i = 0; i < size; i++) { acct = v[i]; id = acct.getID(); if (i == 0) { lastID = (Convert.ToInt32(id)); } else { currID = (Convert.ToInt32(id)); if (currID > (lastID + 1)) { warning += "\nOwner ID values must be " + "consecutive (row #" + (i) + " is " + lastID + ", row #" + (i + 1) + " is " + currID + ")"; fatalCount++; } lastID = currID; } name = acct.getName(); if (id.Length > 12) { warning += "\nReservoir acct ID (" + id + ") is " + "longer than 12 characters."; fatalCount++; } if (id.IndexOf(" ", StringComparison.Ordinal) > -1 || id.IndexOf("-", StringComparison.Ordinal) > -1) { warning += "\nReservoir acct ID (" + id + ") cannot " + "contain spaces or dashes."; fatalCount++; } if (name.Length > 24) { warning += "\nReservoir name (" + name + ") is " + "longer than 24 characters."; fatalCount++; } /* REVISIT SAM 2004-10-29 should be enforced by the table * model since it is a choice * ownerTie = acct.getN2owns(); * if (ownerTie == null) { * warning += "\nMust fill in Ownership Tie."; * fatalCount++; * } */ // the rest are handled automatically by the worksheet } // 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> /// 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_AreaCap_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_ReservoirAreaCap> wv = (java.util.List<StateMod_ReservoirAreaCap>)__worksheet.getAllData(); IList <StateMod_ReservoirAreaCap> wv = (IList <StateMod_ReservoirAreaCap>)__worksheet.getAllData(); // w for worksheet IList <StateMod_ReservoirAreaCap> rv = __currentRes.getAreaCaps(); needToSave = !(StateMod_ReservoirAreaCap.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_ReservoirAreaCap> clone = new List <StateMod_ReservoirAreaCap>(); for (int i = 0; i < size; i++) { clone.Add((StateMod_ReservoirAreaCap)wv[i].clone()); } __currentRes.setAreaCaps(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_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> /// 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(JWorksheet worksheet, string name) { string routine = "StateMod_Reservoir_Climate_JFrame.checkInput"; //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> v = (java.util.List<StateMod_ReservoirClimate>)worksheet.getAllData(); IList <StateMod_ReservoirClimate> v = (IList <StateMod_ReservoirClimate>)worksheet.getAllData(); int size = v.Count; StateMod_ReservoirClimate acct = null; string warning = ""; string id; int fatalCount = 0; for (int i = 0; i < size; i++) { acct = (v[i]); id = acct.getID(); if (id.Length > 12) { warning += "\n" + name + " reservoir climate ID (" + id + ") is " + "longer than 12 characters."; fatalCount++; } if (id.IndexOf(" ", StringComparison.Ordinal) > -1 || id.IndexOf("-", StringComparison.Ordinal) > -1) { warning += "\n" + name + " reservoir climate ID (" + id + ") cannot " + "contain spaces or dashes."; fatalCount++; } // the rest are handled automatically by the worksheet } // 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> /// 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_Plan_Return_JFrame.checkInput"; System.Collections.IList v = __worksheet.getAllData(); int size = v.Count; StateMod_ReturnFlow aReturn = null; string warning = ""; string id; string riverNodeID; double percent; string tableID; int fatalCount = 0; string comment; for (int i = 0; i < size; i++) { aReturn = (StateMod_ReturnFlow)(v[i]); id = aReturn.getID(); riverNodeID = aReturn.getCrtnid(); percent = aReturn.getPcttot(); tableID = "" + aReturn.getIrtndl(); comment = aReturn.getComment(); // TODO SAM 2011-01-02 Need to implement validators if (id.Length > 12) { warning += "\nPlan ID (" + id + ") is longer than 12 characters."; fatalCount++; } if (id.IndexOf(" ", StringComparison.Ordinal) > -1 || id.IndexOf("-", StringComparison.Ordinal) > -1) { warning += "\nPlan ID (" + id + ") cannot contain spaces or dashes."; fatalCount++; } if (riverNodeID.Length > 12) { warning += "River node ID (" + riverNodeID + ") is longer than 12 characters."; } } 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(2, routine, "Returning 0 from checkInput()"); return(0); } }
/// <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_Well_Right_JFrame.checkInput"; //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> v = (java.util.List<StateMod_WellRight>)__worksheet.getAllData(); IList <StateMod_WellRight> v = (IList <StateMod_WellRight>)__worksheet.getAllData(); int size = v.Count; StateMod_WellRight right = null; string warning = ""; string id; string name; string wellID; string adminNum; int fatalCount = 0; for (int i = 0; i < size; i++) { right = (StateMod_WellRight)(v[i]); id = right.getID(); name = right.getName(); wellID = right.getCgoto(); adminNum = right.getIrtem(); if (id.Length > 12) { warning += "\nWell right ID (" + id + ") is " + "longer than 12 characters."; fatalCount++; } if (id.IndexOf(" ", StringComparison.Ordinal) > -1 || id.IndexOf("-", StringComparison.Ordinal) > -1) { warning += "\nWell right ID (" + id + ") cannot " + "contain spaces or dashes."; fatalCount++; } if (name.Length > 24) { warning += "\nWell name (" + name + ") is " + "longer than 24 characters."; fatalCount++; } if (wellID.Length > 12) { warning += "\nWell ID associated with right (" + wellID + ") is longer than 12 characters."; } if (!StringUtil.isDouble(adminNum)) { warning += "\nAdministration number (" + adminNum + ") is not a number."; fatalCount++; } // the rest are handled by the worksheet } // 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> /// 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); }
/// <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_Reservoir_Right_JFrame.checkInput"; //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> v = (java.util.List<StateMod_ReservoirRight>)__worksheet.getAllData(); IList <StateMod_ReservoirRight> v = (IList <StateMod_ReservoirRight>)__worksheet.getAllData(); int size = v.Count; StateMod_ReservoirRight right = null; string warning = ""; string id; string name; string resID; string adminNum; int fatalCount = 0; for (int i = 0; i < size; i++) { right = (StateMod_ReservoirRight)(v[i]); id = right.getID(); name = right.getName(); resID = right.getCgoto(); adminNum = right.getRtem(); //copID = right.getCopid(); if (id.Length > 12) { warning += "\nReservoir right ID (" + id + ") is " + "longer than 12 characters."; fatalCount++; } if (id.IndexOf(" ", StringComparison.Ordinal) > -1 || id.IndexOf("-", StringComparison.Ordinal) > -1) { warning += "\nReservoir right ID (" + id + ") cannot " + "contain spaces or dashes."; fatalCount++; } if (name.Length > 24) { warning += "\nReservoir name (" + name + ") is " + "longer than 24 characters."; fatalCount++; } if (resID.Length > 12) { warning += "\nReservoir ID associated with right (" + resID + ") is longer than 12 characters."; } if (!StringUtil.isDouble(adminNum)) { warning += "\nAdministration number (" + adminNum + ") is not a number."; fatalCount++; } /* REVISIT SAM 2004-10-29 These don't need to be checked * because they are enforced by the table model? * * switchx = right.getSwitch(); * iresco = right.getIresco(); * ityrstr = right.getItyrstr(); * n2fill = right.getN2fill(); * * if (switchx == null) { * warning += "\nMust fill in On/Off switch."; * fatalCount++; * } * if (iresco == null) { * warning += "\nMust fill in Accounts served."; * fatalCount++; * } * if (ityrstr == null) { * warning += "\nMust fill in Right type."; * fatalCount++; * } * if (n2fill == null) { * warning += "\nMust fill in Fill type."; * fatalCount++; * } */ // copid is not handled yet // decreed amount is not checked to be a double 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="ae"> the ActionEvent that happened. </param> public virtual void actionPerformed(ActionEvent ae) { string routine = "StateMod_OutputControl_JFrame.actionPerformed"; string action = ae.getActionCommand(); if (action.Equals(__BUTTON_ADD_ROW)) { if (!__tableModel.canAddNewRow()) { return; } __dirty = true; int row = __worksheet.getRowCount(); StateMod_GraphNode n = new StateMod_GraphNode(); __worksheet.addRow(n); n.setType(""); n.setID(""); n.setSwitch(-1); __tableModel.setDirty(true); // when a row is added, mark the second and third columns // as uneditable. They will be set to editable as soon as // the user enters a value in the first column __worksheet.setCellEditable(row, 1, false); __worksheet.setCellEditable(row, 2, false); } else if (action.Equals(__BUTTON_CLEAR_LIST)) { __dirty = true; __worksheet.clear(); setMessages("Add station to list.", "Ready"); __tableModel.setDirty(true); } else if (action.Equals(__BUTTON_CLOSE)) { closeWindow(); } else if (action.Equals(__BUTTON_DELETE_ROW)) { int[] rows = __worksheet.getSelectedRows(); int length = rows.Length; __tableModel.setDirty(true); if (length == 0) { return; } for (int i = (length - 1); i >= 0; i--) { __worksheet.deleteRow(rows[i]); } __dirty = true; setMessages("Time series list has changed.", "Ready"); } else if (action.Equals(__BUTTON_HELP)) { // REVISIT HELP (JTS - 2003-07-09) } else if (action.Equals(__BUTTON_SAVE_FILE)) { JGUIUtil.setWaitCursor(this, true); string lastDirectorySelected = JGUIUtil.getLastFileDialogDirectory(); JFileChooser fc = null; if (!string.ReferenceEquals(lastDirectorySelected, null)) { fc = new JFileChooser(lastDirectorySelected); } else { fc = new JFileChooser(); } fc.setDialogTitle("Select Output Control File"); SimpleFileFilter @out = new SimpleFileFilter("out", "StateMod Output Control Files"); fc.addChoosableFileFilter(@out); SimpleFileFilter tpl = new SimpleFileFilter("tpo", "StateMod Output Control Files"); fc.addChoosableFileFilter(tpl); SimpleFileFilter xou = new SimpleFileFilter("xou", "StateMod Output Control Files"); fc.addChoosableFileFilter(xou); fc.setAcceptAllFileFilterUsed(false); fc.setFileFilter(tpl); fc.setDialogType(JFileChooser.SAVE_DIALOG); JGUIUtil.setWaitCursor(this, false); int retVal = fc.showSaveDialog(this); if (retVal != JFileChooser.APPROVE_OPTION) { return; } string currDir = (fc.getCurrentDirectory()).ToString(); if (!currDir.Equals(lastDirectorySelected, StringComparison.OrdinalIgnoreCase)) { JGUIUtil.setLastFileDialogDirectory(currDir); } string filename = fc.getSelectedFile().getName(); FileFilter ff = fc.getFileFilter(); if (ff == @out) { filename = IOUtil.enforceFileExtension(filename, "out"); } else if (ff == tpl) { filename = IOUtil.enforceFileExtension(filename, "tpo"); } else if (ff == xou) { filename = IOUtil.enforceFileExtension(filename, "xou"); } __dirty = false; __tableModel.setDirty(false); System.Collections.IList theGraphNodes = __worksheet.getAllData(); try { StateMod_GraphNode.writeStateModOutputControlFile(null, currDir + File.separator + filename, theGraphNodes, null); } catch (Exception e) { Message.printWarning(1, routine, "Error saving output control file\n" + "\"" + currDir + File.separator + filename + "\"", this); Message.printWarning(2, routine, e); } } else if (action.Equals(__BUTTON_LOAD_FILE)) { JGUIUtil.setWaitCursor(this, true); string lastDirectorySelected = JGUIUtil.getLastFileDialogDirectory(); JFileChooser fc = null; if (!string.ReferenceEquals(lastDirectorySelected, null)) { fc = new JFileChooser(lastDirectorySelected); } else { fc = new JFileChooser(); } fc.setDialogTitle("Select Output Control File"); SimpleFileFilter @out = new SimpleFileFilter("out", "StateMod Output Control Files"); fc.addChoosableFileFilter(@out); SimpleFileFilter tpl = new SimpleFileFilter("tpo", "StateMod Output Control Files"); fc.addChoosableFileFilter(tpl); SimpleFileFilter xou = new SimpleFileFilter("xou", "StateMod Output Control Files"); fc.addChoosableFileFilter(xou); fc.setAcceptAllFileFilterUsed(false); fc.setFileFilter(tpl); fc.setDialogType(JFileChooser.OPEN_DIALOG); JGUIUtil.setWaitCursor(this, false); int retVal = fc.showOpenDialog(this); if (retVal != JFileChooser.APPROVE_OPTION) { return; } string currDir = (fc.getCurrentDirectory()).ToString(); if (!currDir.Equals(lastDirectorySelected, StringComparison.OrdinalIgnoreCase)) { JGUIUtil.setLastFileDialogDirectory(currDir); } string filename = fc.getSelectedFile().getName(); JGUIUtil.setWaitCursor(this, true); __dirty = false; System.Collections.IList theGraphNodes = new List <object>(20, 1); try { __worksheet.clear(); __tableModel.setDirty(false); StateMod_GraphNode.readStateModOutputControlFile(theGraphNodes, currDir + File.separator + filename); int size = theGraphNodes.Count; StateMod_GraphNode g = null; int row = 0; for (int i = 0; i < size; i++) { row = __worksheet.getRowCount(); g = (StateMod_GraphNode)theGraphNodes[i]; if (i == 0) { if (g.getID().Equals("All")) { __useAllJCheckBox.setSelected(true); } else { __useAllJCheckBox.setSelected(false); } } __worksheet.addRow(g); __tableModel.fillIDColumn(row, g.getType()); } __worksheet.setData(theGraphNodes); } catch (Exception e) { Message.printWarning(1, routine, "Error loading output control file\n" + "\"" + currDir + File.separator + filename + "\"", this); Message.printWarning(2, routine, e); } JGUIUtil.setWaitCursor(this, false); } else if (action.Equals(__CHECKBOX_USE_ALL)) { // if the use all checkbox is selected, subtle changes from the // default functionality are made. The buttons to add and // delete rows are disabled, and the ID of the only record // in the worksheet is set to "All". This ID value is used // in the table model to determine when the checkbox is // selected. In addition, the ComboBox functionality of the // first and third data columns is turned off. if (__useAllJCheckBox.isSelected()) { __addRowButton.setEnabled(false); __deleteRowButton.setEnabled(false); __worksheet.setColumnJComboBoxValues(0, null); __worksheet.setColumnJComboBoxValues(2, null); __worksheet.clear(); StateMod_GraphNode g = new StateMod_GraphNode(); g.setID("All"); __worksheet.setCellEditable(0, 0, false); __worksheet.setCellEditable(0, 1, false); __worksheet.setCellEditable(0, 2, false); __worksheet.addRow(g); } else { __addRowButton.setEnabled(true); __deleteRowButton.setEnabled(true); System.Collections.IList v = StateMod_Util.arrayToList(StateMod_GraphNode.node_types); v.Add("Other"); __worksheet.setColumnJComboBoxValues(0, v); __worksheet.clear(); System.Collections.IList offOn = new List <object>(); offOn.Add("Off"); offOn.Add("On"); __worksheet.setCellEditable(0, 0, true); __worksheet.setColumnJComboBoxValues(2, offOn); } } }
/// <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); } }