/// <summary> /// Constructor. </summary> /// <param name="dataset"> the dataset containing the data to show in the form. </param> /// <param name="editable"> whether the data on the gui can be edited or not. </param> public StateMod_RiverNetworkNode_JFrame(StateMod_DataSet dataset, StateMod_RiverNetworkNode node, bool editable) : base("") { JGUIUtil.setIcon(this, JGUIUtil.getIconImage()); StateMod_GUIUtil.setTitle(this, dataset, "River Network Nodes", null); __dataset = dataset; __riverNetworkNodeComponent = __dataset.getComponentForComponentType(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> riverNetworkNodesList = (java.util.List<StateMod_RiverNetworkNode>)__riverNetworkNodeComponent.getData(); IList <StateMod_RiverNetworkNode> riverNetworkNodesList = (IList <StateMod_RiverNetworkNode>)__riverNetworkNodeComponent.getData(); __riverNetworkNodesVector = riverNetworkNodesList; int size = __riverNetworkNodesVector.Count; StateMod_RiverNetworkNode r = null; for (int i = 0; i < size; i++) { r = (StateMod_RiverNetworkNode)__riverNetworkNodesVector[i]; r.createBackup(); } string id = node.getID(); int index = StateMod_Util.locateIndexFromID(id, __riverNetworkNodesVector); __editable = editable; setupGUI(index); }
/// <summary> /// Constructor. </summary> /// <param name="title"> Title for JFrame. If null, an appropriate default is used. </param> /// <param name="dataset"> dataset containing data to display </param> /// <param name="station"> StateCU_ClimateStation object to display </param> /// <param name="editable"> whether the display should be editable or not. </param> public StateCU_ClimateStation_JFrame(string title, StateCU_DataSet dataset, StateCU_ClimateStation station, bool editable) { if (string.ReferenceEquals(title, null)) { setTitle("StateCU Climate Stations"); } else { setTitle(title); } __dataset = dataset; __currentStationIndex = -1; __stationComponent = __dataset.getComponentForComponentType(StateCU_DataSet.COMP_CLIMATE_STATIONS); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateCU_ClimateStation> stationsVector0 = (java.util.List<StateCU_ClimateStation>)__stationComponent.getData(); IList<StateCU_ClimateStation> stationsVector0 = (IList<StateCU_ClimateStation>)__stationComponent.getData(); __stationsVector = stationsVector0; string id = station.getID(); int index = StateCU_Util.IndexOf(__stationsVector, id); __editable = editable; setupGUI(index); }
/// <summary> /// Refresh a part of the JTree based on the component. This method is only /// designed to work with the detailed display. It is currently assumed that all /// components are represented in the tree, even if no data are listed below the group node. </summary> /// <param name="comp_type"> Component type being refreshed. Use the component groups. </param> public virtual void refresh(int comp_type) { string routine = "StateMod_DataSet_JTree.refresh"; if (!__display_data_objects) { return; } DataSetComponent comp = __dataset.getComponentForComponentType(comp_type); // Find the node... SimpleJTree_Node node = findNodeByName(comp.getComponentName()); if (node == null) { return; } // Remove the sub-nodes... try { removeChildren(node); } catch (Exception) { Message.printWarning(2, routine, "Error removing old nodes - error should not occur."); } // Now redraw the data... setFastAdd(true); displayDataSetComponent(comp, node); setFastAdd(false); }
/// <summary> /// Constructor. </summary> /// <param name="crop"> StateCU_CropCharacteristics object to display </param> /// <param name="editable"> whether the display should be editable or not. </param> public StateCU_CropCharacteristics_JFrame(StateCU_DataSet dataset, StateCU_CropCharacteristics crop, bool editable) : base(dataset.getBaseName() + " - StateCU GUI - Crop Characteristics") { __currentCropIndex = -1; __editable = editable; __dataset = dataset; __cropComponent = __dataset.getComponentForComponentType(StateCU_DataSet.COMP_CROP_CHARACTERISTICS); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateCU_CropCharacteristics> cropsVector0 = (java.util.List<StateCU_CropCharacteristics>)__cropComponent.getData(); IList <StateCU_CropCharacteristics> cropsVector0 = (IList <StateCU_CropCharacteristics>)__cropComponent.getData(); __cropsVector = cropsVector0; __blaneyComponent = __dataset.getComponentForComponentType(StateCU_DataSet.COMP_BLANEY_CRIDDLE); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateCU_BlaneyCriddle> blaneyVector0 = (java.util.List<StateCU_BlaneyCriddle>)__blaneyComponent.getData(); IList <StateCU_BlaneyCriddle> blaneyVector0 = (IList <StateCU_BlaneyCriddle>)__blaneyComponent.getData(); __blaneyVector = blaneyVector0; string id = crop.getID(); int index = StateCU_Util.IndexOf(__cropsVector, id); setupGUI(index); }
/// <param name="dataset"> StateMod dataset object. </param> /// <returns> validation results. </returns> public virtual StateMod_ComponentValidation validateComponent(StateMod_DataSet dataset) { StateMod_ComponentValidation validation = new StateMod_ComponentValidation(); string id = getID(); string name = getName(); string riverID = getCgoto(); string dailyID = getCrunidy(); // Make sure that basic information is not empty if (StateMod_Util.isMissing(id)) { validation.add(new StateMod_ComponentValidationProblem(this, "Stream estimate identifier is blank.", "Specify a station identifier.")); } if (StateMod_Util.isMissing(name)) { validation.add(new StateMod_ComponentValidationProblem(this, "Stream estimate \"" + id + "\" name is blank.", "Specify a station name to clarify data.")); } if (StateMod_Util.isMissing(riverID)) { validation.add(new StateMod_ComponentValidationProblem(this, "Stream estimate \"" + id + "\" river ID is blank.", "Specify a river ID to associate the station with a river network node.")); } else { // Verify that the river node is in the data set, if the network is available if (dataset != null) { DataSetComponent comp = dataset.getComponentForComponentType(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> rinList = (java.util.List<StateMod_RiverNetworkNode>)comp.getData(); IList <StateMod_RiverNetworkNode> rinList = (IList <StateMod_RiverNetworkNode>)comp.getData(); if ((rinList != null) && (rinList.Count > 0)) { if (StateMod_Util.IndexOf(rinList, riverID) < 0) { validation.add(new StateMod_ComponentValidationProblem(this, "Stream estimate \"" + id + "\" river network ID (" + riverID + ") is not found in the list of river network nodes.", "Specify a valid river network ID to associate the station with a river network node.")); } } } } // Verify that the daily ID is in the data set if (!StateMod_Util.isMissing(dailyID)) { if (dataset != null) { DataSetComponent comp = dataset.getComponentForComponentType(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> risList = (java.util.List<StateMod_StreamGage>)comp.getData(); IList <StateMod_StreamGage> risList = (IList <StateMod_StreamGage>)comp.getData(); if ((risList != null) && (risList.Count > 0)) { if (!dailyID.Equals("0") && !dailyID.Equals("3") && !dailyID.Equals("4") && (StateMod_Util.IndexOf(risList, dailyID) < 0)) { validation.add(new StateMod_ComponentValidationProblem(this, "Stream estimate \"" + id + "\" daily ID (" + dailyID + ") is not 0, 3, or 4 and is not found in the list of stream gages.", "Specify the daily ID as 0, 3, 4, or that matches a stream gage ID.")); } } } } return(validation); }
/// <summary> /// Helper method to return the data vector for the component /// type. This is maintained by the StateMod dataset. </summary> /// <param name="type"> Component type to get data for. </param> /// <returns> Vector of data for a specific component. </returns> private System.Collections.IList getComponentData(int type) { DataSetComponent comp = __dataset.getComponentForComponentType(type); System.Collections.IList data_vector = (System.Collections.IList)comp.getData(); return(data_vector); }
/// <summary> /// Helper method to return the data list for the component /// type. This is maintained by the StateCU dataset. </summary> /// <param name="type"> Component type to get data for. </param> /// <returns> list of data for a specific component. </returns> private IList <object> getComponentData(int type) { DataSetComponent comp = __dataset.getComponentForComponentType(type); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<Object> data_vector = (java.util.List<Object>)comp.getData(); IList <object> data_vector = (IList <object>)comp.getData(); return(data_vector); }
// TODO SAM 2010-12-18 Needs an editable parameter like for other data files /// <summary> /// Constructor for output control </summary> /// <param name="dataset"> the dataset containing the data </param> public StateMod_OutputControl_JFrame(StateMod_DataSet dataset) { StateMod_GUIUtil.setTitle(this, dataset, "Output Control", null); JGUIUtil.setIcon(this, JGUIUtil.getIconImage()); __dataset = dataset; __riverNetworkComp = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK); setupGUI(); }
/// <param name="dataset"> StateMod dataset object. </param> /// <returns> validation results. </returns> public virtual StateMod_ComponentValidation validateComponent(StateMod_DataSet dataset) { StateMod_ComponentValidation validation = new StateMod_ComponentValidation(); string id = getID(); string name = getName(); string cgoto = getCgoto(); string irtem = getIrtem(); double dcrifr = getDcrifr(); // Make sure that basic information is not empty if (StateMod_Util.isMissing(id)) { validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow right identifier is blank.", "Specify a instream flow right identifier.")); } if (StateMod_Util.isMissing(name)) { validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow right \"" + id + "\" name is blank.", "Specify an instream flow right name to clarify data.")); } if (StateMod_Util.isMissing(cgoto)) { validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow right \"" + id + "\" station ID is blank.", "Specify an instream flow station to associate with the instream flow right.")); } else { // Verify that the instream flow station is in the data set, if the network is available DataSetComponent comp2 = dataset.getComponentForComponentType(StateMod_DataSet.COMP_INSTREAM_STATIONS); System.Collections.IList ifsList = (System.Collections.IList)comp2.getData(); if ((ifsList != null) && (ifsList.Count > 0)) { if (StateMod_Util.IndexOf(ifsList, cgoto) < 0) { validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow right \"" + id + "\" associated instream flow (" + cgoto + ") is not found in the list of instream flow stations.", "Specify a valid instream flow station ID to associate with the instream flow right.")); } } } if (StateMod_Util.isMissing(irtem)) { validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow right \"" + id + "\" administration number is blank.", "Specify an administration number NNNNN.NNNNN.")); } else if (!StringUtil.isDouble(irtem)) { validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow right \"" + id + "\" administration number (" + irtem + ") is invalid.", "Specify an administration number NNNNN.NNNNN.")); } else { double irtemd = double.Parse(irtem); if (irtemd < 0) { validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow right \"" + id + "\" administration number (" + irtem + ") is invalid.", "Specify an administration number NNNNN.NNNNN.")); } } if (!(dcrifr >= 0.0)) { validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow right \"" + id + "\" decree (" + StringUtil.formatString(dcrifr, "%.2f") + ") is invalid.", "Specify the decree as a number >= 0.")); } return(validation); }
/// <param name="dataset"> StateMod dataset object. </param> /// <returns> validation results. </returns> public virtual StateMod_ComponentValidation validateComponent(StateMod_DataSet dataset) { StateMod_ComponentValidation validation = new StateMod_ComponentValidation(); string id = getID(); string name = getName(); string riverID = getCgoto(); string dailyID = getCrunidy(); // Make sure that basic information is not empty if (StateMod_Util.isMissing(id)) { validation.add(new StateMod_ComponentValidationProblem(this, "Stream gage identifier is blank.", "Specify a station identifier.")); } if (StateMod_Util.isMissing(name)) { validation.add(new StateMod_ComponentValidationProblem(this, "Stream gage \"" + id + "\" name is blank.", "Specify a station name to clarify data.")); } if (StateMod_Util.isMissing(riverID)) { validation.add(new StateMod_ComponentValidationProblem(this, "Stream gage \"" + id + "\" river ID is blank.", "Specify a river ID to associate the station with a river network node.")); } else { // Verify that the river node is in the data set, if the network is available if (dataset != null) { DataSetComponent comp = dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK); System.Collections.IList rinList = (System.Collections.IList)comp.getData(); if ((rinList != null) && (rinList.Count > 0)) { if (StateMod_Util.IndexOf(rinList, riverID) < 0) { validation.add(new StateMod_ComponentValidationProblem(this, "Stream gage \"" + id + "\" river network ID (" + riverID + ") is not found in the list of river network nodes.", "Specify a valid river network ID to associate the station with a river network node.")); } } } } // Verify that the daily ID is in the data set if (!StateMod_Util.isMissing(dailyID)) { if (dataset != null) { DataSetComponent comp = dataset.getComponentForComponentType(StateMod_DataSet.COMP_STREAMGAGE_STATIONS); System.Collections.IList risList = (System.Collections.IList)comp.getData(); if ((risList != null) && (risList.Count > 0)) { if (!dailyID.Equals("0") && !dailyID.Equals("3") && !dailyID.Equals("4") && (StateMod_Util.IndexOf(risList, dailyID) < 0)) { validation.add(new StateMod_ComponentValidationProblem(this, "Stream gage \"" + id + "\" daily ID (" + dailyID + ") is not 0, 3, or 4 and is not found in the list of stream gages.", "Specify the daily ID as 0, 3, 4, or that matches a stream gage ID.")); } } } } return(validation); }
/// <summary> /// Constructor. This builds the model for displaying the given component data. </summary> /// <param name="dataset"> StateMod_DataSet that is being displayed. If not a group /// component, the group component will be determined. </param> /// <param name="comp"> the DataSetComponent to be displayed. </param> /// <exception cref="Exception"> an invalid component is passed in. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public StateMod_DataSetComponent_TableModel(StateMod_DataSet dataset, RTi.Util.IO.DataSetComponent comp) throws Exception public StateMod_DataSetComponent_TableModel(StateMod_DataSet dataset, DataSetComponent comp) { System.Collections.IList data = null; string routine = "StateMod_DataSetComponent_TableModel"; // Make sure that the list is for a group component... if ((comp != null) && !comp.isGroup()) { __component_group = comp.getParentComponent(); //Message.printStatus ( 1, routine, //"Component is not a group. Parent is: " +__component_group); } else { __component_group = comp; } if (__component_group == null) { _rows = 0; _data = null; return; } // Figure out the data component that is actually used to get the list // of data objects. For example, if working on climate stations, there // is no list with the group so we need to use the climate stations // component list... int comptype = dataset.lookupPrimaryComponentTypeForComponentGroup(__component_group.getComponentType()); if (comptype >= 0) { __component = dataset.getComponentForComponentType(comptype); } else { comp = null; Message.printWarning(2, routine, "Unable to find primary component for group: " + __component_group.getComponentName()); } if (__component == null) { _rows = 0; } else { data = ((System.Collections.IList)__component.getData()); if (data == null) { _rows = 0; } else { _rows = data.Count; } } _data = data; }
/// <param name="dataset"> StateMod dataset object. </param> /// <returns> Validation results. </returns> public virtual StateMod_ComponentValidation validateComponent(StateMod_DataSet dataset) { StateMod_ComponentValidation validation = new StateMod_ComponentValidation(); string id = getID(); string name = getName(); string downstreamRiverID = getCstadn(); double gwmaxr = getGwmaxr(); // Make sure that basic information is not empty if (StateMod_Util.isMissing(id)) { validation.add(new StateMod_ComponentValidationProblem(this, "River node identifier is blank.", "Specify a river node identifier.")); } if (StateMod_Util.isMissing(name)) { validation.add(new StateMod_ComponentValidationProblem(this, "River node \"" + id + "\" name is blank.", "Specify a river node name to clarify data.")); } // Get the network list if available for checks below DataSetComponent comp = null; System.Collections.IList rinList = null; if (dataset != null) { comp = dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK); rinList = (System.Collections.IList)comp.getData(); if ((rinList != null) && (rinList.Count == 0)) { // Set to null to simplify checks below rinList = null; } } if (StateMod_Util.isMissing(downstreamRiverID) && !name.Equals("END", StringComparison.OrdinalIgnoreCase) && !name.EndsWith("_END", StringComparison.Ordinal)) { validation.add(new StateMod_ComponentValidationProblem(this, "River node \"" + id + "\" downstream node ID is blank.", "Specify a downstream node ID.")); } else { // Verify that the downstream river node is in the data set, if the network is available - skip this // check for the end node. if ((rinList != null) && !name.Equals("END", StringComparison.OrdinalIgnoreCase) && !name.EndsWith("_END", StringComparison.Ordinal)) { if (StateMod_Util.IndexOf(rinList, downstreamRiverID) < 0) { validation.add(new StateMod_ComponentValidationProblem(this, "River node \"" + id + "\" downstream node ID (" + downstreamRiverID + ") is not found in the list of river network nodes.", "Specify a valid river network ID for the downstream node.")); } } } if (!StateMod_Util.isMissing(gwmaxr) && !(gwmaxr >= 0.0)) { validation.add(new StateMod_ComponentValidationProblem(this, "River node \"" + id + "\" maximum groundwater recharge (" + StringUtil.formatString(gwmaxr, "%.2f") + ") is invalid.", "Specify the maximum groundwater recharge as a number >= 0.")); } return(validation); }
/// <summary> /// Constructor. </summary> /// <param name="dataset"> the dataset for which to display data set component information. </param> /// <exception cref="Exception"> if an invalid data or dmi was passed in. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public StateMod_Response_TableModel(StateMod_DataSet dataset) throws Exception public StateMod_Response_TableModel(StateMod_DataSet dataset) { __dataset = dataset; // get the array of the ints that refer to the groups in // the data set. int[] groups = __dataset.getComponentGroupNumbers(); System.Collections.IList ints = new List <object>(); DataSetComponent dsc = null; System.Collections.IList v = null; // Go through each of the groups and get their data out. Group data // consists of the DataSetComponents the group contains. For each // of the group's DataSetComponents, if it has data, then add its // component type to the accumulation vector. for (int i = 0; i < groups.Length; i++) { dsc = __dataset.getComponentForComponentType(groups[i]); v = (System.Collections.IList)dsc.getData(); if (v == null) { v = new List <object>(); } for (int j = 0; j < v.Count; j++) { dsc = (DataSetComponent)v[j]; // the following makes sure that the response file // is not added here ... the response file is added // below because it must always be in the GUI. if (dsc.getComponentType() != StateMod_DataSet.COMP_RESPONSE && dsc.isVisible()) { ints.Add(new int?(dsc.getComponentType())); } } } // now transfer the numbers of the DataSetComponents with data into // an int array from the Vector. __data = new int[ints.Count + 1]; __data[0] = StateMod_DataSet.COMP_RESPONSE; for (int i = 0; i < ints.Count; i++) { __data[i + 1] = ((int?)ints[i]).Value; } _rows = __data.Length; }
/// <summary> /// Constructor. </summary> /// <param name="dataset"> the dataset for which to display information in the worksheet. </param> /// <exception cref="Exception"> if an invalid data or dmi was passed in. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public StateMod_Save_TableModel(StateMod_DataSet dataset) throws Exception public StateMod_Save_TableModel(StateMod_DataSet dataset) { __dataset = dataset; // get the array of the ints that refer to the groups in // the data set. int[] groups = __dataset.getComponentGroupNumbers(); System.Collections.IList ints = new List <object>(); DataSetComponent dsc = null; System.Collections.IList v = null; // Go through each of the groups and get their data out. Group data // consists of the DataSetComponents the group contains. For each // of the group's DataSetComponents, if it has data, then add its // component type to the accumulation vector. for (int i = 0; i < groups.Length; i++) { dsc = __dataset.getComponentForComponentType(groups[i]); v = (System.Collections.IList)dsc.getData(); if (v == null) { v = new List <object>(); } for (int j = 0; j < v.Count; j++) { dsc = (DataSetComponent)v[j]; // get the dirty components -- they can be saved // (or not). if (dsc.isDirty()) { ints.Add(new int?(dsc.getComponentType())); } } } // now transfer the numbers of the DataSetComponents with data into // an int array from the Vector. __data = new int[ints.Count]; for (int i = 0; i < ints.Count; i++) { __data[i] = ((int?)ints[i]).Value; } _rows = __data.Length; }
/// <summary> /// Constructor. </summary> /// <param name="dataset"> the dataset containing the data to display </param> /// <param name="dataset_wm"> the dataset window manager or null if the data set windows /// are not being managed. </param> /// <param name="delayTable"> the delay table to display. </param> /// <param name="monthly_data"> If true, display the monthly delay tables. If false, /// display the daily delay tables. </param> /// <param name="editable"> whether the data is editable or not </param> public StateMod_DelayTable_JFrame(StateMod_DataSet dataset, StateMod_DataSet_WindowManager dataset_wm, StateMod_DelayTable delayTable, bool monthly_data, bool editable) { __dataset = dataset; __dataset_wm = dataset_wm; __monthly_data = monthly_data; JGUIUtil.setIcon(this, JGUIUtil.getIconImage()); string interval = " (Monthly)"; if (__monthly_data) { __window_type = StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY; __delayComponent = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY); __componentType = StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY; } else { __window_type = StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY; __delayComponent = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_DAILY); __componentType = StateMod_DataSet.COMP_DELAY_TABLES_DAILY; interval = " (Daily)"; } StateMod_GUIUtil.setTitle(this, dataset, "Delay Tables" + interval, null); //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> delaysList = (java.util.List<StateMod_DelayTable>)__delayComponent.getData(); IList<StateMod_DelayTable> delaysList = (IList<StateMod_DelayTable>)__delayComponent.getData(); __delaysVector = delaysList; int size = __delaysVector.Count; StateMod_DelayTable dt = null; for (int i = 0; i < size; i++) { dt = __delaysVector[i]; dt.createBackup(); } string id = delayTable.getID(); int index = StateMod_Util.IndexOf(__delaysVector, id); __editable = editable; setupGUI(index); }
/// <summary> /// Save the data, meaning save the file names in the data components. /// </summary> private bool saveData() { bool dirty = false; // No file name changes detected. if (checkInput() == 1) { return(false); // No save because of errors. } // Set the file names back into the components and mark the components // dirty if the name has changed. int size = __worksheet.getModel().getRowCount(); DataSetComponent comp2 = null; string file_name, file_name2; int comp_type; for (int i = 0; i < size; i++) { // Get the component corresponding to the line... comp_type = ((StateMod_Response_TableModel)__worksheet.getModel()).getComponentTypeForRow(i); file_name = ((string)__worksheet.getValueAt(i, StateMod_Response_TableModel.COL_NAME)).Trim(); // Get the component from the original data... comp2 = __dataset.getComponentForComponentType(comp_type); file_name2 = comp2.getDataFileName(); // Compare the old and new and set if different... if (!file_name.Equals(file_name2)) { comp2.setDataFileName(file_name); dirty = true; comp2.setDirty(true); __something_changed = true; } } if (dirty) { __dataset.getComponentForComponentType(StateMod_DataSet.COMP_RESPONSE).setDirty(true); } return(true); }
/// <summary> /// Perform the query. Currently only diversion stations are supported. /// </summary> private void doQuery() { string routine = "StateMod_QueryTool_JFrame.doQuery", message; InputFilter_JPanel ifp = __input_filter_diversion_JPanel; InputFilter filter = null; int size; // Size of data Vector int i; // Loop for data items. DataSetComponent comp = null; string where, @operator, input; int where_length = 0; // Length of "where", to optimize code. bool do_int, do_double, do_string; string input_string; // Data parameters to check, as int input_int; // transferred from the data objects. double input_double; bool do_ID, do_Name, do_RiverNodeID, do_OnOff, do_Capacity, do_ReplaceResOption, do_DailyID, do_UserName, do_DemandType, do_EffAnnual, do_Area, do_UseType, do_DemandSource; bool[] matches = null; // Indicates if a data item matches all // the filter criteria. bool item_matches; // Indicates whether the itme matches a // single filter criteria. bool[] @checked = null; // Indicates whether a data item has // already been checked for a criteria. // If checked and false, then a "true" // should not reset the false. int nfg = 0; // Number of filter groups. do_int = false; // Whether the data item is an integer. do_double = false; // Whether the data item is a double. do_string = false; // Whether the data item is a string. StateMod_Diversion dds = null; __status_JTextField.setText(__Wait); JGUIUtil.setWaitCursor(this, true); if (ifp is StateMod_Diversion_InputFilter_JPanel) { input_int = StateMod_Util.MISSING_INT; input_double = StateMod_Util.MISSING_DOUBLE; input_string = StateMod_Util.MISSING_STRING; comp = __dataset.getComponentForComponentType(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> dds_Vector = (java.util.List<StateMod_Diversion>)comp.getData(); IList <StateMod_Diversion> dds_Vector = (IList <StateMod_Diversion>)comp.getData(); size = 0; if (dds_Vector != null) { size = dds_Vector.Count; } // REVISIT SAM 2004-10-27 Remove when debugging is complete //Message.printStatus ( 2, routine, //"Searching " + size + " diversion stations." ); // Initialize the arrays indicating if data objects have been // checked and whether they matched the filter(s)... if (size > 0) { matches = new bool[size]; @checked = new bool[size]; } for (i = 0; i < size; i++) { matches[i] = false; @checked[i] = false; } // Loop through the where clauses... nfg = ifp.getNumFilterGroups(); for (int ifg = 0; ifg < nfg; ifg++) { // Get the filter information... filter = ifp.getInputFilter(ifg); where = filter.getWhereInternal(); where_length = where.Length; @operator = ifp.getOperator(ifg); input = filter.getInput(false); // REVISIT SAM 2004-10-27 Remove when debugging is // complete //Message.printStatus ( 2, routine, //"where=" + where + " operator=" + operator + //" input=" + input ); // Initialize flags to indicate what data will be // checked... do_int = false; do_double = false; do_string = false; do_ID = false; do_Name = false; do_RiverNodeID = false; do_OnOff = false; do_Capacity = false; do_ReplaceResOption = false; do_DailyID = false; do_UserName = false; do_DemandType = false; do_EffAnnual = false; do_Area = false; do_UseType = false; do_DemandSource = false; // The following checks on "where" need to match the // input filter internal where labels assigned in // StateMod_Diversion_InputFilter_JPanel. // List in the order of the StateMod documentation... if (where.Equals("ID", StringComparison.OrdinalIgnoreCase)) { do_string = true; do_ID = true; } else if (where.Equals("Name", StringComparison.OrdinalIgnoreCase)) { do_string = true; do_Name = true; } else if (where.Equals("RiverNodeID", StringComparison.OrdinalIgnoreCase)) { do_string = true; do_RiverNodeID = true; } else if (where.Equals("OnOff", StringComparison.OrdinalIgnoreCase) && StringUtil.isInteger(input)) { do_int = true; do_OnOff = true; } else if (where.Equals("Capacity", StringComparison.OrdinalIgnoreCase) && StringUtil.isDouble(input)) { do_double = true; do_Capacity = true; } else if (where.Equals("ReplaceResOption", StringComparison.OrdinalIgnoreCase) && StringUtil.isInteger(input)) { do_int = true; do_ReplaceResOption = true; } else if (where.Equals("DailyID", StringComparison.OrdinalIgnoreCase)) { do_string = true; do_DailyID = true; } else if (where.Equals("UserName", StringComparison.OrdinalIgnoreCase)) { do_string = true; do_UserName = true; } else if (where.Equals("DemandType", StringComparison.OrdinalIgnoreCase)) { do_int = true; do_DemandType = true; } else if (where.Equals("EffAnnual", StringComparison.OrdinalIgnoreCase) && StringUtil.isDouble(input)) { do_double = true; do_EffAnnual = true; } else if (where.Equals("Area", StringComparison.OrdinalIgnoreCase) && StringUtil.isDouble(input)) { do_double = true; do_Area = true; } else if (where.Equals("UseType", StringComparison.OrdinalIgnoreCase) && StringUtil.isInteger(input)) { do_int = true; do_UseType = true; } else if (where.Equals("DemandSource", StringComparison.OrdinalIgnoreCase) && StringUtil.isInteger(input)) { do_int = true; do_DemandSource = true; } else if (where_length == 0) { // WIll match anything. } else { // Unrecognized where... continue; } // REVISIT SAM 2004-10-27 Remove when debugging is // complete /* * Message.printStatus ( 2, routine, * "do_string=" + do_string + " do_int=" + do_int + * "do_double=" + do_double + * " " + do_ID + * " " + do_Name + * " " + do_RiverNodeID + * " " + do_OnOff + * " " + do_Capacity + * " " + do_ReplaceResOption + * " " + do_DailyID + * " " + do_UserName + * " " + do_DemandType + * " " + do_EffAnnual + * " " + do_Area + * " " + do_UseType + * " " + do_DemandSource ); */ for (i = 0; i < size; i++) { dds = (StateMod_Diversion)dds_Vector[i]; // Get the specific data to compare... if (do_ID) { input_string = dds.getID(); } else if (do_Name) { input_string = dds.getName(); } else if (do_RiverNodeID) { input_string = dds.getCgoto(); } else if (do_OnOff) { input_int = dds.getSwitch(); } else if (do_Capacity) { input_double = dds.getDivcap(); } else if (do_ReplaceResOption) { input_int = dds.getIreptype(); } else if (do_DailyID) { input_string = dds.getCdividy(); } else if (do_UserName) { input_string = dds.getUsername(); } else if (do_DemandType) { input_int = dds.getIdvcom(); } else if (do_EffAnnual) { input_double = dds.getDivefc(); } else if (do_Area) { input_double = dds.getArea(); } else if (do_UseType) { input_int = dds.getIrturn(); } else if (do_DemandSource) { input_int = dds.getDemsrc(); } else { // Unrecognized... continue; } // Compare the data with the input filter... item_matches = false; if (do_string) { item_matches = filter.matches(input_string, @operator, true); } else if (do_int) { item_matches = filter.matches(input_int, @operator); } else if (do_double) { item_matches = filter.matches(input_double, @operator); } if (where_length == 0) { // Always consider a match... item_matches = true; } if (item_matches && (!@checked[i] || (@checked[i] && matches[i]))) { // So far the item matches all // filters... matches[i] = true; } else if (@checked[i] && !item_matches) { // Does not match this filter to reset // result to false... matches[i] = false; } // Indicate that we have checked the item // against at least one filter... @checked[i] = true; } } // Get a count so the Vector can be sized appropriately (this // should be fast)... int match_count = 0; for (i = 0; i < size; i++) { if (matches[i]) { ++match_count; } } // Loop through and set up the matches_Vector... __matches_Vector = null; if (match_count > 0) { __matches_Vector = new List <StateMod_Diversion> (match_count); for (i = 0; i < size; i++) { if (matches[i]) { // The diversion station matches so add // to the list... __matches_Vector.Add(dds_Vector[i]); } } } message = "Matched " + match_count + " diversion stations (from original " + size + ")."; Message.printStatus(2, routine, message); __message_JTextField.setText(message); __status_JTextField.setText(__Ready); JGUIUtil.setWaitCursor(this, false); } if (__matches_Vector == null) { __display_JButton.setEnabled(false); } else { __display_JButton.setEnabled(true); } }
/// <param name="dataset"> StateMod dataset object. </param> /// <returns> validation results. </returns> public virtual StateMod_ComponentValidation validateComponent(StateMod_DataSet dataset) { StateMod_ComponentValidation validation = new StateMod_ComponentValidation(); string id = getID(); string name = getName(); string cgoto = getCgoto(); string irtem = getRtem(); double dcrres = getDcrres(); int iresco = getIresco(); int ityrsr = getItyrstr(); int n2fill = getN2fill(); string copid = getCopid(); // Make sure that basic information is not empty if (StateMod_Util.isMissing(id)) { validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right identifier is blank.", "Specify a reservoir right identifier.")); } if (StateMod_Util.isMissing(name)) { validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right \"" + id + "\" name is blank.", "Specify a reservoir right name to clarify data.")); } if (StateMod_Util.isMissing(cgoto)) { validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right \"" + id + "\" reservoir station ID is blank.", "Specify a reservoir station to associate with the reservoir right.")); } else { // Verify that the reservoir station is in the data set, if the network is available DataSetComponent comp2 = dataset.getComponentForComponentType(StateMod_DataSet.COMP_RESERVOIR_STATIONS); System.Collections.IList resList = (System.Collections.IList)comp2.getData(); if ((resList != null) && (resList.Count > 0)) { if (StateMod_Util.IndexOf(resList, cgoto) < 0) { validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right \"" + id + "\" associated reservoir (" + cgoto + ") is not found in the list of reservoir stations.", "Specify a valid reservoir station ID to associate with the reservoir right.")); } } } if (StateMod_Util.isMissing(irtem)) { validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right \"" + id + "\" administration number is blank.", "Specify an administration number NNNNN.NNNNN.")); } else if (!StringUtil.isDouble(irtem)) { validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right \"" + id + "\" administration number (" + irtem + ") is invalid.", "Specify an administration number NNNNN.NNNNN.")); } else { double irtemd = double.Parse(irtem); if (irtemd < 0) { validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right \"" + id + "\" administration number (" + irtem + ") is invalid.", "Specify an administration number NNNNN.NNNNN.")); } } if (!(dcrres >= 0.0)) { validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right \"" + id + "\" decree (" + StringUtil.formatString(dcrres, "%.2f") + ") is invalid.", "Specify the decree as a number >= 0.")); } IList <string> choices = getIrescoChoices(false); if (StringUtil.indexOfIgnoreCase(choices, "" + iresco) < 0) { validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir \"" + id + "\" ownership code (" + iresco + ") is invalid.", "Specify the ownership code as one of " + choices)); } choices = getItyrsrChoices(false); if (StringUtil.indexOfIgnoreCase(choices, "" + ityrsr) < 0) { validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir \"" + id + "\" right type (" + ityrsr + ") is invalid.", "Specify the right type as one of " + choices)); } choices = getN2fillChoices(false); if (StringUtil.indexOfIgnoreCase(choices, "" + n2fill) < 0) { validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir \"" + id + "\" first fill type (" + n2fill + ") is invalid.", "Specify the first fill type as one of " + choices)); } if (ityrsr == -1) { if (StateMod_Util.isMissing(copid)) { validation.add(new StateMod_ComponentValidationProblem(this, "Reservoir right out-of-priority associated operational right identifier is blank.", "Specify an operational right identifier.")); } } return(validation); }
/// <summary> /// Checks the text fields for validity before they are saved back into the data object. </summary> /// <returns> 0 if the text fields are okay, 1 if fatal errors exist, and -1 if only non-fatal errors exist. </returns> private int checkInput() { string routine = "StateMod_Response_JFrame.checkInput"; string warning = ""; int fatal_count = 0; // Check to make sure that no two files have the same name... int size = __worksheet.getModel().getRowCount(); DataSetComponent comp = null, comp2 = null; string file_name, file_name2; for (int i = 0; i < size; i++) { // Get the component corresponding to the line. comp = __dataset_copy.getComponentForComponentType(((StateMod_Response_TableModel)__worksheet.getModel()).getComponentTypeForRow(i)); file_name = ((string)__worksheet.getValueAt(i, StateMod_Response_TableModel.COL_NAME)).Trim(); if (file_name.Equals(__dataset_copy.BLANK_FILE_NAME, StringComparison.OrdinalIgnoreCase) && comp.hasData()) { if (comp.getComponentType() != StateMod_DataSet.COMP_NETWORK) { warning += "\n" + comp.getComponentName() + " has data but no file name is specified."; ++fatal_count; } } // Check for duplicate file names. In particular with the new // response file format, there is no need for "dum" empty files. for (int j = 0; j < size; j++) { if (i == j) { continue; } comp2 = __dataset_copy.getComponentForComponentType(((StateMod_Response_TableModel)__worksheet.getModel()).getComponentTypeForRow(j)); file_name2 = ((string)__worksheet.getValueAt(j, StateMod_Response_TableModel.COL_NAME)).Trim(); if (file_name2.Equals(file_name, StringComparison.OrdinalIgnoreCase) && !file_name2.Equals(__dataset_copy.BLANK_FILE_NAME, StringComparison.OrdinalIgnoreCase)) { // Stream gage and stream estimate stations can be the same file name... if (((comp.getComponentType() == StateMod_DataSet.COMP_STREAMGAGE_STATIONS) && (comp2.getComponentType() == StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS)) || ((comp.getComponentType() == StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS) && (comp2.getComponentType() == StateMod_DataSet.COMP_STREAMGAGE_STATIONS))) { // TODO SAM 2006-03-04 Need to finalize how the gage and estimate files are handled. //&& //!__dataset_copy.isFreeFormat() ) { // No need for a warning because the single file is split internally when read... } else { warning += "\n" + comp.getComponentName() + " file name (" + file_name + ") is the same as another component."; ++fatal_count; } // No need to look at more files... break; } } // Compare against the original copy... // Warn that time series file names cannot be changed from the // original because time series were not read in... comp2 = __dataset.getComponentForComponentType(comp.getComponentType()); file_name2 = comp2.getDataFileName(); if (!file_name.Equals(file_name2) && !__dataset.areTSRead() && __dataset.isDynamicTSComponent(comp.getComponentType())) { warning += "\n" + comp.getComponentName() + " time series were not read in - cannot change file name."; ++fatal_count; } } if (warning.Length > 0) { warning = "\nResponse file: " + warning + "\nCorrect or Cancel."; Message.printWarning(1, routine, warning, this); if (fatal_count > 0) { // Fatal errors... return(1); } else { // Nonfatal errors... return(-1); } } else { // No errors... return(0); } }
/// <summary> /// Checks to see if the mouse event would trigger display of the popup menu. /// The popup menu does not display if it is null. </summary> /// <param name="e"> the MouseEvent that happened. </param> private void showPopupMenu(MouseEvent e) { string routine = "StateMod_DataSet_JTree.showPopupMenu"; if (!e.isPopupTrigger() || !__display_data_objects) { // Do not do anything... return; } TreePath path = getPathForLocation(e.getX(), e.getY()); if (path == null) { return; } __popup_Node = (SimpleJTree_Node)path.getLastPathComponent(); // First remove the menu items that are currently in the menu... __popup_JPopupMenu.removeAll(); object data = null; // Data object associated with the node DataSetComponent comp2; // Used to check components in groups. // Now reset the popup menu based on the selected node... if (__display_data_objects) { // Get the data for the node. If the node is a data object, // the type can be checked to know what to display. // The tree is displaying data objects so the popup will show // specific JFrames for each data group. If the group folder // was selected, then display the JFrame showing the first item // selected. If a specific data item in the group was selected, // then show the specific data item. JMenuItem item; data = __popup_Node.getData(); if (data is DataSetComponent) { // Specific checks need to be done to identify the component group... DataSetComponent comp = (DataSetComponent)data; int comp_type = comp.getComponentType(); if (comp_type == StateMod_DataSet.COMP_CONTROL_GROUP) { // For now display the control file information only... comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_CONTROL); if (comp2.hasData()) { item = new SimpleJMenuItem("Control Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_STREAMGAGE_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_STREAMGAGE_STATIONS); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Stream Gage Station Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_DELAY_TABLE_MONTHLY_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Delay Table Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_DELAY_TABLE_DAILY_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Delay Table Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_DIVERSION_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DIVERSION_STATIONS); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Diversion Properties", this); __popup_JPopupMenu.add(item); } } else if ((comp_type == StateMod_DataSet.COMP_PRECIPITATION_GROUP)) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Precipitation Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_EVAPORATION_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Evaporation Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_RESERVOIR_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_RESERVOIR_STATIONS); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Reservoir Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_INSTREAM_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_INSTREAM_STATIONS); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Instream Flow Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_WELL_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_WELL_STATIONS); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Well Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_PLAN_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_PLANS); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Plan Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_STREAMESTIMATE_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Stream Estimate Station Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_RIVER_NETWORK_GROUP) { // Only add if data are available... comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("River Network Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_OPERATION_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_OPERATION_RIGHTS); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Operation Rights Properties", this); __popup_JPopupMenu.add(item); } } } // The data are a specific data instance so display the // properties for the specific item if a primary data item. // Control... nothing for now. else if (data is StateMod_StreamGage) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_DelayTable) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_Diversion) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); __popup_JPopupMenu.add(new SimpleJMenuItem(__SUMMARIZE_HOW1 + "\"" + __popup_Node.getText() + "\"" + __SUMMARIZE_HOW2, this)); } else if (data is MonthTS) { // Precipitation or evaporation time series... __popup_JPopupMenu.add(new SimpleJMenuItem(__popup_Node.getText() + __PROPERTIES, this)); __popup_JPopupMenu.add(new SimpleJMenuItem(__SUMMARIZE_HOW1 + "\"" + __popup_Node.getText() + "\"" + __SUMMARIZE_HOW2, this)); } else if (data is StateMod_Reservoir) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_InstreamFlow) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_Well) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_Plan) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_StreamEstimate) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_OperationalRight) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_RiverNetworkNode) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } // Others (e.g., San Juan Sediment) supported later.... else { Message.printWarning(2, routine, "Node data is not recognized"); return; } } // Now display the popup so that the user can select the appropriate menu item... Point pt = JGUIUtil.computeOptimalPosition(e.getPoint(), e.getComponent(), __popup_JPopupMenu); __popup_JPopupMenu.show(e.getComponent(), pt.x, pt.y); }
/// <summary> /// Display the primary data for a component. This method is called when adding nodes under a group node. </summary> /// <param name="comp"> Component to display data. </param> /// <param name="node"> Parent node to display under. </param> private bool displayDataSetComponent(DataSetComponent comp, SimpleJTree_Node node) { string routine = "StateMod_DataSet_JTree.displayDataSetComponent"; bool hadData = false; // No data for component... string label = ""; int primary_type = __dataset.lookupPrimaryComponentTypeForComponentGroup(comp.getComponentType()); if (primary_type >= 0) { comp = __dataset.getComponentForComponentType(primary_type); } // Revisit - later may enable even if a component does // not have data - for example have an "Add" popup... if ((comp == null) || !comp.isVisible() || !comp.hasData()) { return(hadData); } object data_Object = comp.getData(); if (data_Object == null) { return(hadData); } System.Collections.IList data = null; if (data_Object is System.Collections.IList) { data = (System.Collections.IList)comp.getData(); } else { // Continue (REVISIT - what components would this happen for?)... Message.printWarning(2, routine, "Unexpected non-Vector for " + comp.getComponentName()); return(hadData); } StateCU_Data cudata; StateMod_Data smdata; SimpleJTree_Node node2 = null; TS tsdata; int dsize = 0; if (data != null) { dsize = data.Count; } for (int idata = 0; idata < dsize; idata++) { data_Object = data[idata]; if (data_Object is StateMod_Data) { smdata = (StateMod_Data)data[idata]; label = StateMod_Util.formatDataLabel(smdata.getID(), smdata.getName()); node2 = new SimpleJTree_Node(label); node2.setData(smdata); } else if (data_Object is StateCU_Data) { cudata = (StateCU_Data)data[idata]; label = StateMod_Util.formatDataLabel(cudata.getID(), cudata.getName()); node2 = new SimpleJTree_Node(label); node2.setData(cudata); } else if (data_Object is TS) { tsdata = (TS)data[idata]; label = StateMod_Util.formatDataLabel(tsdata.getLocation(), tsdata.getDescription()); node2 = new SimpleJTree_Node(label); node2.setData(tsdata); } try { addNode(node2, node); } catch (Exception e) { Message.printWarning(2, routine, "Error adding data \"" + label + "\""); Message.printWarning(2, routine, e); continue; } } if (dsize > 0) { hadData = true; } // Collapse the node because the lists are usually pretty long... try { collapseNode(node); } catch (Exception) { // Ignore. } return(hadData); // Needed in the calling code. }
/// <param name="dataset"> StateMod dataset object. </param> /// <returns> List of data that failed specific checks. </returns> public virtual StateMod_ComponentValidation validateComponent(StateMod_DataSet dataset) { StateMod_ComponentValidation validation = new StateMod_ComponentValidation(); string id = getID(); string name = getName(); string riverID = getCgoto(); string downstreamRiverID = getIfrrdn(); string dailyID = getCifridy(); int iifcom = getIifcom(); // Make sure that basic information is not empty if (StateMod_Util.isMissing(id)) { validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow station identifier is blank.", "Specify a station identifier.")); } if (StateMod_Util.isMissing(name)) { validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow station \"" + id + "\" name is blank.", "Specify an instream flow station name to clarify data.")); } // Get the network list if available for checks below DataSetComponent comp = null; System.Collections.IList rinList = null; if (dataset != null) { comp = dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK); rinList = (System.Collections.IList)comp.getData(); if ((rinList != null) && (rinList.Count == 0)) { // Set to null to simplify checks below rinList = null; } } if (StateMod_Util.isMissing(riverID)) { validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow station \"" + id + "\" river node ID is blank.", "Specify a river node ID to associate the instream flow station with a river network node.")); } else { // Verify that the river node is in the data set, if the network is available if (rinList != null) { if (StateMod_Util.IndexOf(rinList, riverID) < 0) { validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow station \"" + id + "\" river network ID (" + riverID + ") is not found in the list of river network nodes.", "Specify a valid river network ID to associate the instream flow station.")); } } } if (StateMod_Util.isMissing(downstreamRiverID)) { validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow station \"" + id + "\" downstream river node ID is blank.", "Specify a downstream river node ID to associate the instream flow station with a river network node.")); } else { // Verify that the river node is in the data set, if the network is available if (rinList != null) { if (StateMod_Util.IndexOf(rinList, downstreamRiverID) < 0) { validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow station \"" + id + "\" downstream river network ID (" + riverID + ") is not found in the list of river network nodes.", "Specify a valid river network ID to associate the instream flow station downstream node.")); } } } // Verify that the daily ID is in the data set (daily ID is allowed to be missing) if ((dataset != null) && !StateMod_Util.isMissing(dailyID)) { DataSetComponent comp2 = dataset.getComponentForComponentType(StateMod_DataSet.COMP_INSTREAM_STATIONS); System.Collections.IList ifsList = (System.Collections.IList)comp2.getData(); if (dailyID.Equals("0") || dailyID.Equals("3") || dailyID.Equals("4")) { // OK } else if ((ifsList != null) && (ifsList.Count > 0)) { // Check the instream flow station list if (StateMod_Util.IndexOf(ifsList, dailyID) < 0) { validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow station \"" + id + "\" daily ID (" + dailyID + ") is not 0, 3, or 4 and is not found in the list of instream flow stations.", "Specify the daily ID as 0, 3, 4, or a matching instream flow station ID.")); } } } IList <string> choices = getIifcomChoices(false); if (StringUtil.indexOfIgnoreCase(choices, "" + iifcom) < 0) { validation.add(new StateMod_ComponentValidationProblem(this, "Instream flow station \"" + id + "\" data type (" + iifcom + ") is invalid.", "Specify the data type as one of " + choices)); } // TODO SAM 2009-06-01) evaluate how to check rights (with getRights() or checking the rights data // set component). return(validation); }
/// <summary> /// Responds to action performed events sent by popup menus of the tree nodes. </summary> /// <param name="event"> the ActionEvent that happened. </param> public virtual void actionPerformed(ActionEvent @event) { string action = @event.getActionCommand(); string routine = "StateMod_DataSet_JTree.actionPerformed"; object data = __popup_Node.getData(); if (data is DataSetComponent) { DataSetComponent comp = (DataSetComponent)data; int comp_type = comp.getComponentType(); if (comp_type == StateMod_DataSet.COMP_CONTROL_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_CONTROL, __editable); } else if (comp_type == StateMod_DataSet.COMP_STREAMGAGE_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMGAGE, __editable); } else if (comp_type == StateMod_DataSet.COMP_DELAY_TABLE_MONTHLY_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY, __editable); } else if (comp_type == StateMod_DataSet.COMP_DELAY_TABLE_DAILY_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY, __editable); } else if (comp_type == StateMod_DataSet.COMP_DIVERSION_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DIVERSION, __editable); } else if (comp_type == StateMod_DataSet.COMP_PRECIPITATION_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_PRECIPITATION, __editable); } else if (comp_type == StateMod_DataSet.COMP_EVAPORATION_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_EVAPORATION, __editable); } else if (comp_type == StateMod_DataSet.COMP_RESERVOIR_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_RESERVOIR, __editable); } else if (comp_type == StateMod_DataSet.COMP_INSTREAM_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_INSTREAM, __editable); } else if (comp_type == StateMod_DataSet.COMP_WELL_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_WELL, __editable); } else if (comp_type == StateMod_DataSet.COMP_PLAN_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_PLAN, __editable); } else if (comp_type == StateMod_DataSet.COMP_STREAMESTIMATE_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMESTIMATE, __editable); } else if (comp_type == StateMod_DataSet.COMP_RIVER_NETWORK_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK, __editable); } else if (comp_type == StateMod_DataSet.COMP_OPERATION_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_OPERATIONAL_RIGHT, __editable); } } // Below here are specific instances of objects. Similar to above, // display the main window but then also select the specific object... else if (data is StateMod_StreamGage) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMGAGE, __editable); ((StateMod_StreamGage_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMGAGE)).selectID(((StateMod_StreamGage)data).getID()); } else if (data is StateMod_DelayTable) { StateMod_DelayTable dt = (StateMod_DelayTable)data; if (dt.isMonthly()) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY, __editable); ((StateMod_DelayTable_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY)).selectID(dt.getID()); } else { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY, __editable); ((StateMod_DelayTable_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY)).selectID(dt.getID()); } } else if (data is StateMod_Diversion) { if (action.IndexOf(__SUMMARIZE_HOW1, StringComparison.Ordinal) >= 0) { PropList props = new PropList("Diversion"); props.set("Title=" + ((StateMod_Diversion)data).getID() + " Diversion use in Data Set"); new ReportJFrame(__dataset.getDataObjectDetails(StateMod_DataSet.COMP_DIVERSION_STATIONS, ((StateMod_Diversion)data).getID()), props); } else { // Assume properties... __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DIVERSION, __editable); ((StateMod_Diversion_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_DIVERSION)).selectID(((StateMod_Diversion)data).getID()); } } else if (data is TS) { // Might be precipitation or evaporation. Check the data type to determine... TS ts = (TS)data; PropList props = new PropList("Precipitation/Evaporation"); if (action.IndexOf(__SUMMARIZE_HOW1, StringComparison.Ordinal) >= 0) { if (StringUtil.startsWithIgnoreCase(ts.getDataType(), "e")) { props.set("Title=" + ts.getLocation() + " Evaporation TS use in Data Set"); new ReportJFrame(__dataset.getDataObjectDetails(StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY, ts.getLocation()), props); } else if (StringUtil.startsWithIgnoreCase(ts.getDataType(), "p")) { props.set("Title=" + ts.getLocation() + " Precipitation TS use in Data Set"); new ReportJFrame(__dataset.getDataObjectDetails(StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY, ts.getLocation()), props); } } else if (action.IndexOf(__PROPERTIES, StringComparison.Ordinal) >= 0) { if (StringUtil.startsWithIgnoreCase(ts.getDataType(), "e")) { props.set("Title=Evaporation"); } else if (StringUtil.startsWithIgnoreCase(ts.getDataType(), "p")) { props.set("Title=Precipitation"); } props.set("InitialView=Graph"); props.set("GraphType=Bar"); System.Collections.IList tslist = new List <object>(1); tslist.Add(ts); try { new TSViewJFrame(tslist, props); } catch (Exception) { Message.printWarning(1, routine, "Error displaying data."); } } } else if (data is StateMod_Reservoir) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_RESERVOIR, __editable); ((StateMod_Reservoir_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_RESERVOIR)).selectID(((StateMod_Reservoir)data).getID()); } else if (data is StateMod_InstreamFlow) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_INSTREAM, __editable); ((StateMod_InstreamFlow_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_INSTREAM)).selectID(((StateMod_InstreamFlow)data).getID()); } else if (data is StateMod_Well) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_WELL, __editable); ((StateMod_Well_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_WELL)).selectID(((StateMod_Well)data).getID()); } else if (data is StateMod_Plan) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_PLAN, __editable); ((StateMod_Plan_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_PLAN)).selectID(((StateMod_Plan)data).getID()); } else if (data is StateMod_StreamEstimate) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMESTIMATE, __editable); ((StateMod_StreamEstimate_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMESTIMATE)).selectID(((StateMod_StreamEstimate)data).getID()); } else if (data is StateMod_RiverNetworkNode) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK, __editable); ((StateMod_RiverNetworkNode_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK)).selectID(((StateMod_RiverNetworkNode)data).getID()); } else if (data is StateMod_OperationalRight) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_OPERATIONAL_RIGHT, __editable); ((StateMod_OperationalRight_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_OPERATIONAL_RIGHT)).selectID(((StateMod_OperationalRight)data).getID()); } }
/// <summary> /// Display all the information in the data set. This can be called, for example, /// after a data set has been read. /// </summary> public virtual void displayDataSet() { string routine = "StateMod_DataSet_JTree.displayDataSet"; System.Collections.IList v = __dataset.getComponentGroups(); int size = 0; if (v != null) { size = v.Count; } SimpleJTree_Node node = null, node2 = null; DataSetComponent comp = null; bool hadData = false; bool isGroup = false; int type; // Add each component group... setFastAdd(true); Icon folder_Icon = getClosedIcon(); for (int i = 0; i < size; i++) { hadData = false; isGroup = false; comp = (DataSetComponent)v[i]; if ((comp == null) || !comp.isVisible()) { continue; } type = comp.getComponentType(); if (type == StateMod_DataSet.COMP_GEOVIEW_GROUP) { // Don't want to list the groups because there is no // way to display edit (or they are displayed elsewhere)... continue; } node = new SimpleJTree_Node(comp.getComponentName()); node.setData(comp); if (comp.isGroup()) { isGroup = true; } // To force groups to be folders, even if no data underneath... node.setIcon(folder_Icon); try { addNode(node); } catch (Exception e) { Message.printWarning(2, routine, "Error adding component group " + comp.getComponentName()); Message.printWarning(2, routine, e); continue; } if (__display_data_objects) { // Display the primary object in each group hadData = displayDataSetComponent(comp, node); } else { // Add the components in the group... System.Collections.IList v2 = (System.Collections.IList)comp.getData(); int size2 = 0; if (v2 != null) { size2 = v2.Count; } for (int j = 0; j < size2; j++) { comp = (DataSetComponent)v2[j]; if ((comp == null) || !comp.isVisible()) { continue; } node2 = new SimpleJTree_Node(comp.getComponentName()); node2.setData(comp); try { addNode(node2, node); } catch (Exception e) { Message.printWarning(2, routine, "Error adding component " + comp.getComponentName()); Message.printWarning(2, routine, e); continue; } } if (size2 > 0) { hadData = true; } } if (isGroup && !hadData) { node.setIcon(__folderIcon); } } setFastAdd(false); }
/// <summary> /// Save the data. </summary> /// <returns> true if the save was successful, false if not. </returns> private bool saveData() { string routine = "StateMod_Save_JDialog.saveData"; if (checkInput() == 1) { return(false); } // Else save the data... int[] selectedRows = __worksheet.getSelectedRows(); int comp_type; DataSetComponent comp = null; int error_count = 0; // Counter for save errors. string newFilename0 = null; // Used within path string newFilename = null; string oldFilename = null; IList <string> comments = new List <string>(); // TODO - add a checkbox to the display. //if ( __add_revision_comments_JCheckBox.isSelected() ) { comments.Add("Modification to data made interactively by user with " + IOUtil.getProgramName() + " " + IOUtil.getProgramVersion()); if (__updateCheckbox.isSelected()) { comments.Add("Updated by StateModGUI"); } //} for (int i = 0; i < selectedRows.Length; i++) { try { comp_type = __tableModel.getRowComponentNum(i); comp = (DataSetComponent)__dataset.getComponentForComponentType(comp_type); newFilename0 = comp.getDataFileName(); newFilename = __dataset.getDataFilePathAbsolute(comp); if (__updateCheckbox.isSelected()) { oldFilename = newFilename; } else { oldFilename = null; } if (comp_type == StateMod_DataSet.COMP_RESPONSE) { // TODO - need to track the original file name... StateMod_DataSet.writeStateModFile(__dataset, oldFilename, newFilename, comments); // Mark the component clean... comp.setDirty(false); } else if (newFilename0.Length == 0) { // SAM 2006-03-04... // Just set to not dirty. If someone sets a filename to blank and actually makes // changes, they don't know what they are doing. comp.setDirty(false); } else if (newFilename0.Length > 0) { try { saveComponent(comp, oldFilename, newFilename, comments); } catch (Exception e) { Message.printWarning(1, routine, "Error saving file \"" + newFilename + "\""); Message.printWarning(2, routine, e); } } } catch (Exception e) { Message.printWarning(1, routine, "Error saving " + comp.getComponentName() + " to \"" + newFilename + "\""); Message.printWarning(2, routine, e); ++error_count; } } if (error_count > 0) { return(false); } else { return(true); } }
//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> /// Checks to see if the mouse event would trigger display of the popup menu. /// The popup menu does not display if it is null. </summary> /// <param name="e"> the MouseEvent that happened. </param> private void showPopupMenu(MouseEvent e) { if (!e.isPopupTrigger() || !__display_data_objects) { // Do not do anything... return; } // Figure out which node is selected... TreePath path = getPathForLocation(e.getX(), e.getY()); if (path == null) { return; } __popup_Node = (SimpleJTree_Node)path.getLastPathComponent(); // First remove the menu items that are currently in the menu... __popup_JPopupMenu.removeAll(); object data = null; // Data object associated with the node // Now reset the popup menu based on the selected node... if (__display_data_objects) { // Get the data for the node. If the node is a data object, // the type can be checked to know what to display. // The tree is displaying data objects so the popup will show // specific JFrames for each data group. If the group folder // was selected, then display the JFrame showing the first item // selected. If a specific data item in the group was selected, // then show the specific data item. JMenuItem item; data = __popup_Node.getData(); if (data is DataSetComponent) { // Specific checks need to be done to identify the // component... DataSetComponent comp = (DataSetComponent)data; int comp_type = comp.getComponentType(); if (comp_type == StateCU_DataSet.COMP_CLIMATE_STATIONS_GROUP) { item = new SimpleJMenuItem("Climate Stations Properties", "Climate Stations Properties", this); __popup_JPopupMenu.add(item); } else if (comp_type == StateCU_DataSet.COMP_CROP_CHARACTERISTICS_GROUP) { item = new SimpleJMenuItem("Crop Properties", "Crop Properties", this); __popup_JPopupMenu.add(item); } else if (comp_type == StateCU_DataSet.COMP_DELAY_TABLES_GROUP) { item = new SimpleJMenuItem("Delay Tables Properties", "Delay Tables Properties", this); __popup_JPopupMenu.add(item); } else if (comp_type == StateCU_DataSet.COMP_CU_LOCATIONS_GROUP) { item = new SimpleJMenuItem("CU Locations Properties", "CU Locations Properties", this); __popup_JPopupMenu.add(item); } } // Check specific instances of the primary data object... else if (data is StateCU_ClimateStation) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", __popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateCU_CropCharacteristics) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", __popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_DelayTable) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", __popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateCU_Location) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", __popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else { return; } } // Now display the popup so that the user can select the appropriate // menu item... __popup_JPopupMenu.show(e.getComponent(), e.getX(), e.getY()); }
/// <summary> /// Handle action events from the popup menu. </summary> /// <param name="e"> ActionEvent to handle. </param> public virtual void actionPerformed(ActionEvent e) { object data = __popup_Node.getData(); bool editable = false; if (data is DataSetComponent) { DataSetComponent comp = (DataSetComponent)data; int comp_type = comp.getComponentType(); if (comp_type == StateCU_DataSet.COMP_CLIMATE_STATIONS_GROUP) { new StateCU_ClimateStation_JFrame("Climate Stations", __dataset, editable); } else if (comp_type == StateCU_DataSet.COMP_CROP_CHARACTERISTICS_GROUP) { new StateCU_CropCharacteristics_JFrame(__dataset, editable); } else if (comp_type == StateCU_DataSet.COMP_DELAY_TABLES_GROUP) { DataSetComponent comp2 = __dataset.getComponentForComponentType(StateCU_DataSet.COMP_DELAY_TABLES_MONTHLY); if (comp2 != null) { /* * REVISIT (JTS - 2003-10-06) * old constructor * new StateMod_DelayTable_JFrame( * "Delay Tables", (Vector)comp2.getData(), * true, editable); */ } } else if (comp_type == StateCU_DataSet.COMP_CU_LOCATIONS_GROUP) { // TODO SAM 2011-06-22 Need a way to pass a window manager new StateCU_Location_JFrame(__isStateCU, __dataset, null, editable); } } // Else, data are specific objects... else if (data is StateCU_ClimateStation) { new StateCU_ClimateStation_JFrame("Climate Stations", __dataset, (StateCU_ClimateStation)data, editable); } else if (data is StateCU_CropCharacteristics) { new StateCU_CropCharacteristics_JFrame(__dataset, (StateCU_CropCharacteristics)data, editable); } else if (data is StateMod_DelayTable) { DataSetComponent comp2 = __dataset.getComponentForComponentType(StateCU_DataSet.COMP_DELAY_TABLES_MONTHLY); if (comp2 != null) { /* * REVISIT (JTS - 2003-10-06) * old constructor * new StateMod_DelayTable_JFrame( * "Delay Tables", (Vector)comp2.getData(), * (StateMod_DelayTable)data, true, editable); */ } } else if (data is StateCU_Location) { new StateCU_Location_JFrame(false, __dataset, null, (StateCU_Location)data, editable); } }
/// <summary> /// Display all the information in the data set. This can be called, for example, /// after a data set has been read. /// </summary> public virtual void displayDataSet() { string routine = "StateCU_DataSet_JTree.displayDataSet"; System.Collections.IList v = __dataset.getComponentGroups(); int size = 0; if (v != null) { size = v.Count; } SimpleJTree_Node node = null, node2 = null; DataSetComponent comp = null; string name = ""; bool isGroup = false; bool hasData = false; int type; // Add each component group... setFastAdd(true); for (int i = 0; i < size; i++) { isGroup = false; hasData = false; comp = (DataSetComponent)v[i]; if ((comp == null) || !comp.isVisible()) { continue; } if (comp.isGroup()) { isGroup = true; } type = comp.getComponentType(); // Show the control data at the high level. if (type == StateCU_DataSet.COMP_GIS_GROUP) { // Don't want to list the GIS data... continue; } if ((type == StateCU_DataSet.COMP_GIS_GROUP) && __display_data_objects) { // Currently don't want to list GIS data in // results... continue; } node = new SimpleJTree_Node(comp.getComponentName()); node.setData(comp); try { addNode(node); } catch (Exception e) { Message.printWarning(2, routine, "Error adding component group " + comp.getComponentName()); Message.printWarning(2, routine, e); continue; } if (__display_data_objects) { // Display the primary object in each group int primary_type = __dataset.lookupPrimaryComponentTypeForComponentGroup(comp.getComponentType()); if (primary_type >= 0) { comp = __dataset.getComponentForComponentType(primary_type); } if ((comp == null) || !comp.isVisible()) { continue; } object data_Object = comp.getData(); if (data_Object == null) { continue; } System.Collections.IList data = null; if (data_Object is System.Collections.IList) { data = (System.Collections.IList)comp.getData(); } else { // Continue (REVISIT - what components would // this happen for?)... Message.printWarning(2, routine, "Unexpected non-Vector for " + comp.getComponentName()); } StateCU_Data cudata; StateMod_Data smdata; int dsize = 0; if (data != null) { dsize = data.Count; } for (int idata = 0; idata < dsize; idata++) { if (comp.getComponentType() == StateCU_DataSet.COMP_DELAY_TABLES_MONTHLY) { // StateMod data object so have to // handle separately because StateCU // uses the StateMod group... smdata = (StateMod_Data)data[idata]; name = smdata.getName(); node2 = new SimpleJTree_Node(name); node2.setData(smdata); } else { // StateCU data object... cudata = (StateCU_Data)data[idata]; name = cudata.getName(); node2 = new SimpleJTree_Node(name); node2.setData(cudata); } try { addNode(node2, node); } catch (Exception e) { Message.printWarning(2, routine, "Error adding data " + name); Message.printWarning(2, routine, e); continue; } } if (dsize > 0) { hasData = true; } // Collapse the node because the lists are // usually pretty long... try { collapseNode(node); } catch (Exception) { // Ignore. } } else { // Add the components in the group... Message.printStatus(1, "", "Not displaying data objects"); System.Collections.IList v2 = (System.Collections.IList)comp.getData(); int size2 = 0; if (v2 != null) { size2 = v2.Count; } Message.printStatus(1, "", "group has " + size2 + " subcomponents"); for (int j = 0; j < size2; j++) { comp = (DataSetComponent)v2[j]; if (!comp.isVisible()) { continue; } node2 = new SimpleJTree_Node(comp.getComponentName()); node2.setData(comp); try { addNode(node2, node); } catch (Exception e) { Message.printWarning(2, routine, "Error adding component " + comp.getComponentName()); Message.printWarning(2, routine, e); continue; } } if (size2 > 0) { hasData = true; } } if (isGroup && !hasData) { node.setIcon(__folderIcon); } } setFastAdd(false); }