/// <summary> /// Set the Cgoto. </summary> /// <param name="s"> the new Cgoto. </param> public virtual void setCgoto(string s) { if (string.ReferenceEquals(s, null)) { return; } if (!s.Equals(_cgoto)) { if (!_isClone && !_isClone && _dataset != null) { _dataset.setDirty(_smdata_type, true); } _cgoto = s; } }
/// <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); }
/// <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); }
/// <summary> /// Responds to action performed events. </summary> /// <param name="e"> the ActionEvent that happened. </param> public virtual void actionPerformed(ActionEvent e) { string routine = "StateMod_RiverNetworkNode_JFrame.actionPerformed"; if (Message.isDebugOn) { Message.printDebug(1, routine, "In actionPerformed: " + e.getActionCommand()); } object source = e.getSource(); if (source == __closeJButton) { saveCurrentRecord(); int size = __riverNetworkNodesVector.Count; StateMod_RiverNetworkNode r = null; bool changed = false; for (int i = 0; i < size; i++) { r = __riverNetworkNodesVector[i]; if (!changed && r.changed()) { changed = true; } r.acceptChanges(); } if (changed) { __dataset.setDirty(StateMod_DataSet.COMP_RIVER_NETWORK, true); } if (__dataset_wm != null) { __dataset_wm.closeWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK); } else { JGUIUtil.close(this); } } else if (source == __applyJButton) { saveCurrentRecord(); int size = __riverNetworkNodesVector.Count; StateMod_RiverNetworkNode r = null; bool changed = false; for (int i = 0; i < size; i++) { r = __riverNetworkNodesVector[i]; if (!changed && r.changed()) { changed = true; } r.createBackup(); } if (changed) { __dataset.setDirty(StateMod_DataSet.COMP_RIVER_NETWORK, true); } } else if (source == __cancelJButton) { int size = __riverNetworkNodesVector.Count; StateMod_RiverNetworkNode r = null; for (int i = 0; i < size; i++) { r = __riverNetworkNodesVector[i]; r.restoreOriginal(); } if (__dataset_wm != null) { __dataset_wm.closeWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK); } else { JGUIUtil.close(this); } } else if (source == __helpJButton) { // REVISIT HELP (JTS - 2003-08-18) } else if (source == __searchIDJRadioButton) { __searchName.setEditable(false); __searchID.setEditable(true); } else if (source == __searchNameJRadioButton) { __searchName.setEditable(true); __searchID.setEditable(false); } else if (source == __showOnMap_JButton) { GeoRecord geoRecord = getSelectedRiverNetworkNode().getGeoRecord(); GRShape shape = geoRecord.getShape(); __dataset_wm.showOnMap(getSelectedRiverNetworkNode(), "Node: " + getSelectedRiverNetworkNode().getID() + " - " + getSelectedRiverNetworkNode().getName(), new GRLimits(shape.xmin, shape.ymin, shape.xmax, shape.ymax), geoRecord.getLayer().getProjection()); } else if (source == __showOnNetwork_JButton) { StateMod_Network_JFrame networkEditor = __dataset_wm.getNetworkEditor(); if (networkEditor != null) { HydrologyNode node = networkEditor.getNetworkJComponent().findNode(getSelectedRiverNetworkNode().getID(), false, false); if (node != null) { __dataset_wm.showOnNetwork(getSelectedRiverNetworkNode(), "Node: " + getSelectedRiverNetworkNode().getID() + " - " + getSelectedRiverNetworkNode().getName(), new GRLimits(node.getX(), node.getY(), node.getX(), node.getY())); } } } else if (source == __findNext) { searchWorksheet(__worksheet.getSelectedRow() + 1); } else if (source == __searchID || source == __searchName) { searchWorksheet(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_DelayTable_JFrame" + ".actionPerformed"; if (Message.isDebugOn) { Message.printDebug(1, routine, "In actionPerformed: " + e.getActionCommand()); } string action = e.getActionCommand(); if (action.Equals(__BUTTON_HELP)) { // REVISIT HELP (JTS - 2003-06-09) } else if (action.Equals(__BUTTON_CLOSE)) { closeWindow(); } else if (action.Equals(__BUTTON_APPLY)) { saveDelayTable(); int size = __delaysVector.Count; StateMod_DelayTable dt = null; bool changed = false; for (int i = 0; i < size; i++) { dt = (StateMod_DelayTable)__delaysVector[i]; if (!changed && dt.changed()) { changed = true; } dt.createBackup(); } if (changed) { __dataset.setDirty(__componentType, true); } } else if (action.Equals(__BUTTON_CANCEL)) { __worksheetR.deselectAll(); int size = __delaysVector.Count; StateMod_DelayTable dt = null; bool changed = false; for (int i = 0; i < size; i++) { dt = (StateMod_DelayTable)__delaysVector[i]; if (!changed && dt.changed()) { changed = true; } dt.restoreOriginal(); } if (__dataset_wm != null) { __dataset_wm.closeWindow(__window_type); } else { JGUIUtil.close(this); } } else if (action.Equals(__BUTTON_ADD_RETURN)) { int row = __worksheetR.getSelectedRow(); int total_num_rows = __worksheetR.getRowCount() - 1; if (row == -1) { row = total_num_rows; } if (row != -1) { if (row == total_num_rows) { int x = new ResponseJDialog(this, "Insert row", "Do you wish to add a new row above " + "the last row?\n" + "uniquetempvar.response(); if (x == ResponseJDialog.CANCEL) { return; } else if (x == ResponseJDialog.NO) { row += 1; } } __worksheetR.insertRowAt(new double?(0), row); __worksheetR.scrollToRow(row); __worksheetR.selectRow(row); } else { __worksheetR.addRow(new double?(0)); __worksheetR.scrollToRow(0); __worksheetR.selectRow(0); } __deleteReturn.setEnabled(true); } else if (action.Equals(__BUTTON_DELETE_RETURN)) { int row = __worksheetR.getSelectedRow(); if (row != -1) { int x = (new ResponseJDialog(this, "Delete Return", "Delete return?", ResponseJDialog.YES | ResponseJDialog.NO)).response(); if (x == ResponseJDialog.NO) { return; } //StateMod_DelayTable dt = (StateMod_DelayTable) //__worksheetL.getRowData( //__worksheetL.getSelectedRow()); __worksheetR.deleteRow(row); __deleteReturn.setEnabled(false); } else { Message.printWarning(1, routine, "Must select desired right to delete."); } } else if (e.getSource() == __findNextDelay) { searchLeftWorksheet(__worksheetL.getSelectedRow() + 1); } else if (e.getSource() == __searchID) { searchLeftWorksheet(); } else { if (__worksheetL.getSelectedRow() == -1) { new ResponseJDialog(this, "You must first select a delay from the list.", ResponseJDialog.OK); return; } else if (e.getSource() == __graphDelayJButton) { try { __worksheetR.deselectAll(); int index = __worksheetL.getSelectedRow(); if (index == -1) { return; } StateMod_DelayTable currentDelay = ((StateMod_DelayTable) __delaysVector[index]); int j; DateTime date; TSIdent tsident = new TSIdent(); tsident.setLocation(currentDelay.getID()); tsident.setSource("StateMod"); if (__monthly_data) { tsident.setInterval("Month"); } else { tsident.setInterval("Day"); } tsident.setType("Delay"); DateTime date1 = null; DateTime date2 = null; int interval_base; if (__monthly_data) { date1 = new DateTime(DateTime.PRECISION_MONTH); date2 = new DateTime(DateTime.PRECISION_MONTH); interval_base = TimeInterval.MONTH; } else { date1 = new DateTime(DateTime.PRECISION_DAY); date2 = new DateTime(DateTime.PRECISION_DAY); interval_base = TimeInterval.DAY; } date1.setMonth(1); date1.setYear(1); date2.setMonth(1); date2.setYear(1); date2.addInterval(interval_base, (currentDelay.getNdly() - 1)); TS ts = null; if (__monthly_data) { ts = new MonthTS(); } else { ts = new DayTS(); } ts.setDate1(date1); ts.setDate2(date2); ts.setIdentifier(tsident); if (__monthly_data) { ts.setDescription(ts.getLocation() + " Monthly Delay Table"); } else { ts.setDescription(ts.getLocation() + " Daily Delay Table"); } ts.setDataType("Delay"); ts.setDataUnits(currentDelay.getUnits()); ts.allocateDataSpace(); double max = 0.0; for (date = new DateTime(date1), j = 0; date.lessThanOrEqualTo(date2); date.addInterval(interval_base, 1), j++) { ts.setDataValue(date, currentDelay.getRet_val(j)); if (currentDelay.getRet_val(j) > max) { max = currentDelay.getRet_val(j); } } IList<TS> tslist = new List<TS>(); tslist.Add(ts); PropList graphProps = new PropList("TSView"); // If dealing with small values, use a high // of precision... if (max < 1.0) { graphProps.set("YAxisPrecision","6"); graphProps.set("OutputPrecision","6"); } else { graphProps.set("YAxisPrecision","3"); graphProps.set("OutputPrecision","3"); } graphProps.set("InitialView", "Graph"); graphProps.set("TotalWidth", "600"); graphProps.set("TotalHeight", "400"); if (__monthly_data) { graphProps.set("Title", ts.getLocation() + " Monthly Delay Table"); } else { graphProps.set("Title", ts.getLocation() + " Daily Delay Table"); } graphProps.set("DisplayFont", "Courier"); graphProps.set("DisplaySize", "11"); graphProps.set("PrintFont", "Courier"); graphProps.set("PrintSize", "7"); graphProps.set("PageLength", "100"); new TSViewJFrame(tslist, graphProps); } catch (Exception) { Message.printWarning(1, routine, "Unable to graph delay. "); } } } }