示例#1
0
	/// <summary>
	/// Constructor. </summary>
	/// <param name="delaysVector"> the list of delays to show </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(IList<StateMod_DelayTable> delaysVector, StateMod_DelayTable delayTable, bool monthly_data, bool editable)
	{
		__monthly_data = monthly_data;
		JGUIUtil.setIcon(this, JGUIUtil.getIconImage());
		string interval = " (Monthly)";
		if (__monthly_data)
		{
			__window_type = StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY;
			__componentType = StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY;
		}
		else
		{
			__window_type = StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY;
			__componentType = StateMod_DataSet.COMP_DELAY_TABLES_DAILY;
			interval = " (Daily)";
		}
		StateMod_GUIUtil.setTitle(this, null, "Delay Tables" + interval, null);

		__delaysVector = delaysVector;

		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>
        /// 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>
        /// Return the downstream data set object by searching appropriate dataset lists. </summary>
        /// <param name="dataset"> the full dataset from which the destination should be extracted </param>
        public virtual StateMod_Data lookupDownstreamDataObject(StateMod_DataSet dataset)
        {
            string downstreamID = getIfrrdn();

            StateMod_OperationalRight_Metadata_SourceOrDestinationType[] downstreamTypes = new StateMod_OperationalRight_Metadata_SourceOrDestinationType[] { StateMod_OperationalRight_Metadata_SourceOrDestinationType.RIVER_NODE };
            IList <StateMod_Data> smdataList = new List <StateMod_Data>();

            for (int i = 0; i < downstreamTypes.Length; i++)
            {
                ((IList <StateMod_Data>)smdataList).AddRange(StateMod_Util.getDataList(downstreamTypes[i], dataset, downstreamID, true));
                if (smdataList.Count > 0)
                {
                    break;
                }
            }
            if (smdataList.Count == 1)
            {
                return(smdataList[0]);
            }
            else if (smdataList.Count == 0)
            {
                return(null);
            }
            else
            {
                throw new Exception("" + smdataList.Count + " data objects returned matching downstream \"" + downstreamID + "\" for instream flow \"" + getID() + " - one is expected.");
            }
        }
示例#4
0
        /// <summary>
        /// Compare two rights lists and see if they are the same. </summary>
        /// <param name="v1"> the first list of StateMod_ReservoirRight s to check.  Cannot be null. </param>
        /// <param name="v2"> the second list of StateMod_ReservoirRight s to check.  Cannot be null. </param>
        /// <returns> true if they are the same, false if not. </returns>
        public static bool Equals(IList <StateMod_ReservoirRight> v1, IList <StateMod_ReservoirRight> v2)
        {
            StateMod_ReservoirRight r1;
            StateMod_ReservoirRight r2;

            if (v1.Count != v2.Count)
            {
                //Message.printStatus(2, routine, "Lists are different sizes");
                return(false);
            }
            else
            {
                // sort the lists and compare item-by-item.  Any differences
                // and data will need to be saved back into the dataset.
                int size = v1.Count;
                //Message.printStatus(2, routine, "Lists are of size: " + size);
                IList <StateMod_ReservoirRight> v1Sort = StateMod_Util.sortStateMod_DataVector(v1);
                IList <StateMod_ReservoirRight> v2Sort = StateMod_Util.sortStateMod_DataVector(v2);
                //Message.printStatus(2, routine, "Lists have been sorted");

                for (int i = 0; i < size; i++)
                {
                    r1 = v1Sort[i];
                    r2 = v2Sort[i];
                    //Message.printStatus(2, routine, r1.toString());
                    //Message.printStatus(2, routine, r2.toString());
                    //Message.printStatus(2, routine, "Element " + i + " comparison: " + r1.compareTo(r2));
                    if (r1.CompareTo(r2) != 0)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
        /// <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>
        /// Fills the data type column according to the type of structure selected,
        /// the ID of that structure, and the interval that is selected. </summary>
        /// <param name="row"> the row of the data type column that is being dealt with </param>
        /// <param name="outputOnly"> whether to only display OUTPUT data types. </param>
        /// <param name="station_type"> the type of the station (column _COL_STATION_TYPE) </param>
        /// <param name="id"> the ID of the station (column _COL_ID) </param>
        /// <param name="interval_string"> the data interval (column _COL_INTERVAL ) </param>
        public virtual void fillDataTypeColumn(int row, bool outputOnly, string station_type, string id, string interval_string)
        {
            System.Collections.IList dataTypes = new List <object>();
            int interval = TimeInterval.MONTH;

            if (interval_string.Equals("Day", StringComparison.OrdinalIgnoreCase))
            {
                interval = TimeInterval.DAY;
            }

            if (station_type.Equals(StateMod_Util.STATION_TYPE_DIVERSION, StringComparison.OrdinalIgnoreCase))
            {
                dataTypes = StateMod_Util.getTimeSeriesDataTypes(StateMod_DataSet.COMP_DIVERSION_STATIONS, id, __dataset, "", interval, true, true, true, true, false, true);
            }
            else if (station_type.Equals(StateMod_Util.STATION_TYPE_INSTREAM_FLOW, StringComparison.OrdinalIgnoreCase))
            {
                dataTypes = StateMod_Util.getTimeSeriesDataTypes(StateMod_DataSet.COMP_INSTREAM_STATIONS, id, __dataset, "", interval, true, true, true, true, false, true);
            }
            else if (station_type.Equals(StateMod_Util.STATION_TYPE_RESERVOIR, StringComparison.OrdinalIgnoreCase))
            {
                if (outputOnly)
                {
                    dataTypes = StateMod_Util.getTimeSeriesDataTypes(StateMod_DataSet.COMP_RESERVOIR_STATIONS, id, __dataset, "", interval, false, false, true, true, false, true);
                }
                else
                {
                    dataTypes = StateMod_Util.getTimeSeriesDataTypes(StateMod_DataSet.COMP_RESERVOIR_STATIONS, id, __dataset, "", interval, true, true, true, true, false, true);
                }
            }
            else if (station_type.Equals(StateMod_Util.STATION_TYPE_STREAMGAGE, StringComparison.OrdinalIgnoreCase))
            {
                dataTypes = StateMod_Util.getTimeSeriesDataTypes(StateMod_DataSet.COMP_STREAMGAGE_STATIONS, id, __dataset, "", interval, true, true, true, true, false, true);
            }
            else if (station_type.Equals(StateMod_Util.STATION_TYPE_STREAMESTIMATE, StringComparison.OrdinalIgnoreCase))
            {
                dataTypes = StateMod_Util.getTimeSeriesDataTypes(StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS, id, __dataset, "", interval, true, true, true, true, false, true);
            }
            else if (station_type.Equals(StateMod_Util.STATION_TYPE_WELL, StringComparison.OrdinalIgnoreCase))
            {
                dataTypes = StateMod_Util.getTimeSeriesDataTypes(StateMod_DataSet.COMP_WELL_STATIONS, id, __dataset, "", interval, true, true, true, true, false, true);
            }

            if (__worksheet != null)
            {
                __worksheet.setCellSpecificJComboBoxValues(row, _COL_DATA_TYPE, dataTypes);
                System.Collections.IList v = __worksheet.getCellSpecificJComboBoxValues(row, _COL_DATA_TYPE);
                string s = null;
                if (v == null || v.Count == 0)
                {
                    s = "";
                }
                else
                {
                    s = (string)v[0];
                }
                setInternalValueAt(s, row, _COL_DATA_TYPE);
            }
        }
        /// <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>
 /// Used to set a numeric value in a JTextField.  This method will check the value
 /// and see if it is missing, and if so, will set the JTextField to "".  Otherwise
 /// the text field will be filled with the value of the specified double. </summary>
 /// <param name="d"> the double to check and possibly put in the text field. </param>
 /// <param name="textField"> the JTextField to put the value in. </param>
 public static void checkAndSet(double d, JTextField textField)
 {
     if (StateMod_Util.isMissing(d))
     {
         textField.setText("");
     }
     else
     {
         textField.setText("" + d);
     }
 }
 /// <summary>
 /// Used to set a numeric value in a JTextField.  This method will check the value
 /// and see if it is missing, and if so, will set the JTextField to "".  Otherwise
 /// the text field will be filled with the value of the specified int. </summary>
 /// <param name="i"> the int to check and possibly put in the text field. </param>
 /// <param name="textField"> the JTextField to put the value in. </param>
 public static void checkAndSet(int i, JTextField textField)
 {
     if (StateMod_Util.isMissing(i))
     {
         textField.setText("");
     }
     else
     {
         textField.setText("" + i);
     }
 }
        /// <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 in which the data is contained. </param>
        /// <param name="plan"> the plan for which to display return information. </param>
        /// <param name="editable"> whether the gui data is editable or not. </param>
        public StateMod_Plan_Return_JFrame(StateMod_DataSet dataset, StateMod_Plan plan, bool editable)
        {
            StateMod_GUIUtil.setTitle(this, dataset, plan.getName() + " - Plan Return Flow Table Assignment", null);
            JGUIUtil.setIcon(this, JGUIUtil.getIconImage());
            __currentPlan = plan;
            IList <StateMod_ReturnFlow> allReturns = (IList <StateMod_ReturnFlow>)dataset.getComponentForComponentType(StateMod_DataSet.COMP_PLAN_RETURN).getData();

            __currentPlanReturnList = (IList <StateMod_ReturnFlow>)StateMod_Util.getDataList(allReturns, plan.getID());
            Message.printStatus(2, "", "Have " + __currentPlanReturnList.Count + " return records for plan \"" + __currentPlan.getID() + "\" uniquetempvar.");
            __dataset = dataset;
            // TODO SAM 2011-01-02 For now editing is disabled...
            editable   = false;
            __editable = editable;
            setupGUI();
        }
        /// <summary>
        /// Constructor. </summary>
        /// <param name="dataset"> the dataset in which the data is contained. </param>
        /// <param name="res"> the Reservoir for which to display return information. </param>
        /// <param name="editable"> whether the gui data is editable or not. </param>
        public StateMod_Reservoir_Return_JFrame(StateMod_DataSet dataset, StateMod_Reservoir res, bool editable)
        {
            StateMod_GUIUtil.setTitle(this, dataset, res.getName() + " - Reservoir Return Flow Table Assignment", null);
            JGUIUtil.setIcon(this, JGUIUtil.getIconImage());
            __currentRes = res;
//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> allReturns = (java.util.List<StateMod_ReturnFlow>)dataset.getComponentForComponentType(StateMod_DataSet.COMP_RESERVOIR_RETURN).getData();
            IList <StateMod_ReturnFlow> allReturns = (IList <StateMod_ReturnFlow>)dataset.getComponentForComponentType(StateMod_DataSet.COMP_RESERVOIR_RETURN).getData();

            __currentResReturnList = (IList <StateMod_ReturnFlow>)StateMod_Util.getDataList(allReturns, res.getID());
            Message.printStatus(2, "", "Have " + __currentResReturnList.Count + " return records for reservoir \"" + __currentRes.getID() + "\" uniquetempvar.");
            //__dataset = dataset;
            // TODO SAM 2011-01-02 For now editing is disabled...
            editable   = false;
            __editable = editable;
            setupGUI();
        }
示例#14
0
	/// <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>
        /// Creates a list of the available IDs for a Vector of StateMod_Data-extending
        /// objects.  Reservoirs will include an identifier for each reservoir total and each account for the reservoir. </summary>
        /// <param name="nodes"> the nodes for which to create a list of IDs. </param>
        /// <param name="include_accounts"> If true, the </param>
        /// <returns> a Vector of Strings, each of which contains an ID followed by the name of Structure in parentheses </returns>
        private System.Collections.IList createAvailableIDsList(System.Collections.IList nodes)
        {
            System.Collections.IList v = new List <object>();

            int  num          = 0;
            bool is_reservoir = false;     // To allow check below

            if (nodes != null)
            {
                num = nodes.Count;
                if ((num > 0) && ((StateMod_Data)nodes[0]) is StateMod_Reservoir)
                {
                    is_reservoir = true;
                }
            }

            StateMod_Reservoir res = null;     // These are used if reservoirs.
            int nowner             = 0;
            int ia = 0;

            for (int i = 0; i < num; i++)
            {
                // Add the normal item...
                v.Add(StateMod_Util.formatDataLabel(((StateMod_Data)nodes[i]).getID(), ((StateMod_Data)nodes[i]).getName()));
                if (is_reservoir)
                {
                    // Also add reservoir owner/accounts...
                    res    = (StateMod_Reservoir)nodes[i];
                    nowner = res.getAccounts().Count;
                    for (ia = 0; ia < nowner; ia++)
                    {
                        v.Add(StateMod_Util.formatDataLabel(res.getID() + "-" + (ia + 1), res.getName() + " - " + res.getAccount(ia).getName()));
                    }
                }
            }
            return(v);
        }
示例#16
0
        /// <summary>
        /// Compare two return flow lists and see if they are the same. </summary>
        /// <param name="v1"> the first list of StateMod_ReturnFlow to check.  Cannot be null. </param>
        /// <param name="v2"> the second list of StateMod_ReturnFlow to check.  Cannot be null. </param>
        /// <returns> true if they are the same, false if not. </returns>
        public static bool Equals(IList <StateMod_ReturnFlow> v1, IList <StateMod_ReturnFlow> v2)
        {
            string routine = "StateMod_ReturnFlow.equals";
            StateMod_ReturnFlow rf1;
            StateMod_ReturnFlow rf2;

            if (v1.Count != v2.Count)
            {
                Message.printStatus(2, routine, "Return flow lists are different sizes");
                return(false);
            }
            else
            {
                // Sort the lists and compare item-by-item.  Any differences
                // and data will need to be saved back into the data set.
                int size = v1.Count;
                //Message.printStatus(2, routine, "Return flow lists are of size: " + size);
                IList <StateMod_ReturnFlow> v1Sort = StateMod_Util.sortStateMod_DataVector(v1);
                IList <StateMod_ReturnFlow> v2Sort = StateMod_Util.sortStateMod_DataVector(v2);
                //Message.printStatus(2, routine, "Return flow lists have been sorted");

                for (int i = 0; i < size; i++)
                {
                    rf1 = v1Sort[i];
                    rf2 = v2Sort[i];
                    Message.printStatus(2, routine, rf1.ToString());
                    Message.printStatus(2, routine, rf2.ToString());
                    //Message.printStatus(2, routine, "Element " + i + " comparison: " + rf1.compareTo(rf2));
                    if (rf1.CompareTo(rf2) != 0)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
示例#17
0
        /// <summary>
        /// Writes a list of StateMod_ReturnFlow objects to a list file.  A header is
        /// printed to the top of the file, containing the commands used to generate the
        /// file.  Any strings in the body of the file that contain the field delimiter will be wrapped in "...". </summary>
        /// <param name="filename"> the name of the file to which the data will be written. </param>
        /// <param name="delimiter"> the delimiter to use for separating field values. </param>
        /// <param name="update"> whether to update an existing file, retaining the current
        /// header (true) or to create a new file with a new header. </param>
        /// <param name="data"> the list of objects to write. </param>
        /// <param name="newComments"> new comments to add to the header (e.g., command file, HydroBase version). </param>
        /// <exception cref="Exception"> if an error occurs. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static void writeListFile(String filename, String delimiter, boolean update, java.util.List<StateMod_ReturnFlow> data, int componentType, java.util.List<String> newComments) throws Exception
        public static void writeListFile(string filename, string delimiter, bool update, IList <StateMod_ReturnFlow> data, int componentType, IList <string> newComments)
        {
            int size = 0;

            if (data != null)
            {
                size = data.Count;
            }

            IList <string> fields = new List <string>();

            fields.Add("ID");
            fields.Add("RiverNodeID");
            if (componentType == StateMod_DataSet.COMP_WELL_STATION_DEPLETION_TABLES)
            {
                fields.Add("DepletionPercent");
            }
            else
            {
                fields.Add("ReturnPercent");
            }
            fields.Add("DelayTableID");
            fields.Add("Comment");
            int fieldCount = fields.Count;

            string[] names   = new string[fieldCount];
            string[] formats = new string[fieldCount];
            int      comp    = componentType;
            string   s       = null;

            for (int i = 0; i < fieldCount; i++)
            {
                s          = fields[i];
                names[i]   = StateMod_Util.lookupPropValue(comp, "FieldName", s);
                formats[i] = StateMod_Util.lookupPropValue(comp, "Format", s);
            }

            string oldFile = null;

            if (update)
            {
                oldFile = IOUtil.getPathUsingWorkingDir(filename);
            }

            int                 j    = 0;
            PrintWriter         @out = null;
            StateMod_ReturnFlow rf   = null;
            IList <string>      commentIndicators = new List <string>(1);

            commentIndicators.Add("#");
            IList <string> ignoredCommentIndicators = new List <string>(1);

            ignoredCommentIndicators.Add("#>");
            string[]      line   = new string[fieldCount];
            StringBuilder buffer = new StringBuilder();

            try
            {
                // Add some basic comments at the top of the file.  However, do this to a copy of the
                // incoming comments so that they are not modified in the calling code.
                IList <string> newComments2 = null;
                if (newComments == null)
                {
                    newComments2 = new List <string>();
                }
                else
                {
                    newComments2 = new List <string>(newComments);
                }
                newComments2.Insert(0, "");
                if (componentType == StateMod_DataSet.COMP_DIVERSION_STATION_DELAY_TABLES)
                {
                    newComments2.Insert(1, "StateMod diversion delay (return) file.");
                    newComments2.Insert(2, "See also the associated diversion station file.");
                }
                else if (componentType == StateMod_DataSet.COMP_WELL_STATION_DEPLETION_TABLES)
                {
                    newComments2.Insert(1, "StateMod well depletion file.");
                    newComments2.Insert(2, "See also the associated well station and return files.");
                }
                else if (componentType == StateMod_DataSet.COMP_WELL_STATION_DELAY_TABLES)
                {
                    newComments2.Insert(1, "StateMod well delay (return) file.");
                    newComments2.Insert(2, "See also the associated well station and depletion files.");
                }
                newComments2.Insert(3, "");
                @out = IOUtil.processFileHeaders(oldFile, IOUtil.getPathUsingWorkingDir(filename), newComments2, commentIndicators, ignoredCommentIndicators, 0);

                for (int i = 0; i < fieldCount; i++)
                {
                    buffer.Append("\"" + names[i] + "\"");
                    if (i < (fieldCount - 1))
                    {
                        buffer.Append(delimiter);
                    }
                }

                @out.println(buffer.ToString());

                for (int i = 0; i < size; i++)
                {
                    rf = data[i];

                    line[0] = StringUtil.formatString(rf.getID(), formats[0]).Trim();
                    line[1] = StringUtil.formatString(rf.getCrtnid(), formats[1]).Trim();
                    line[2] = StringUtil.formatString(rf.getPcttot(), formats[2]).Trim();
                    line[3] = StringUtil.formatString(rf.getIrtndl(), formats[3]).Trim();
                    line[4] = StringUtil.formatString(rf.getComment(), formats[4]).Trim();

                    buffer = new StringBuilder();
                    for (j = 0; j < fieldCount; j++)
                    {
                        if (line[j].IndexOf(delimiter, StringComparison.Ordinal) > -1)
                        {
                            line[j] = "\"" + line[j] + "\"";
                        }
                        buffer.Append(line[j]);
                        if (j < (fieldCount - 1))
                        {
                            buffer.Append(delimiter);
                        }
                    }

                    @out.println(buffer.ToString());
                }
            }
            finally
            {
                if (@out != null)
                {
                    @out.flush();
                    @out.close();
                }
            }
        }
        /// <summary>
        /// Writes a list of StateMod_ReservoirAccount objects to a list file.  A header
        /// is printed to the top of the file, containing the commands used to generate the
        /// file.  Any strings in the body of the file that contain the field delimiter will be wrapped in "...". </summary>
        /// <param name="filename"> the name of the file to which the data will be written. </param>
        /// <param name="delimiter"> the delimiter to use for separating field values. </param>
        /// <param name="update"> whether to update an existing file, retaining the current
        /// header (true) or to create a new file with a new header. </param>
        /// <param name="data"> the list of objects to write. </param>
        /// <param name="newComments"> new comments to add to the top of the file. </param>
        /// <exception cref="Exception"> if an error occurs. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static void writeListFile(String filename, String delimiter, boolean update, java.util.List data, java.util.List newComments) throws Exception
        public static void writeListFile(string filename, string delimiter, bool update, System.Collections.IList data, System.Collections.IList newComments)
        {
            string routine = "StateMod_ReservoirAccount.writeListFile";
            int    size    = 0;

            if (data != null)
            {
                size = data.Count;
            }

            System.Collections.IList fields = new List <object>();
            fields.Add("ReservoirID");
            fields.Add("OwnerID");
            fields.Add("OwnerAccount");
            fields.Add("MaxStorage");
            fields.Add("InitialStorage");
            fields.Add("ProrateEvap");
            fields.Add("OwnershipTie");
            int fieldCount = fields.Count;

            string[] names   = new string[fieldCount];
            string[] formats = new string[fieldCount];
            int      comp    = StateMod_DataSet.COMP_RESERVOIR_STATION_ACCOUNTS;
            string   s       = null;

            for (int i = 0; i < fieldCount; i++)
            {
                s          = (string)fields[i];
                names[i]   = StateMod_Util.lookupPropValue(comp, "FieldName", s);
                formats[i] = StateMod_Util.lookupPropValue(comp, "Format", s);
            }

            string oldFile = null;

            if (update)
            {
                oldFile = IOUtil.getPathUsingWorkingDir(filename);
            }

            int j = 0;
            StateMod_ReservoirAccount acct = null;

            System.Collections.IList commentIndicators = new List <object>(1);
            commentIndicators.Add("#");
            System.Collections.IList ignoredCommentIndicators = new List <object>(1);
            ignoredCommentIndicators.Add("#>");
            string[]      line   = new string[fieldCount];
            StringBuilder buffer = new StringBuilder();
            PrintWriter   @out   = null;

            try
            {
                // Add some basic comments at the top of the file.  Do this to a copy of the
                // incoming comments so that they are not modified in the calling code.
                System.Collections.IList newComments2 = null;
                if (newComments == null)
                {
                    newComments2 = new List <object>();
                }
                else
                {
                    newComments2 = new List <object>(newComments);
                }
                newComments2.Insert(0, "");
                newComments2.Insert(1, "StateMod reservoir station accounts as a delimited list file.");
                newComments2.Insert(2, "See also the associated station, precipitation station, evaporation station,");
                newComments2.Insert(3, "content/area/seepage, and collection files.");
                newComments2.Insert(4, "");
                @out = IOUtil.processFileHeaders(oldFile, IOUtil.getPathUsingWorkingDir(filename), newComments2, commentIndicators, ignoredCommentIndicators, 0);

                for (int i = 0; i < fieldCount; i++)
                {
                    buffer.Append("\"" + names[i] + "\"");
                    if (i < (fieldCount - 1))
                    {
                        buffer.Append(delimiter);
                    }
                }

                @out.println(buffer.ToString());

                for (int i = 0; i < size; i++)
                {
                    acct = (StateMod_ReservoirAccount)data[i];

                    line[0] = StringUtil.formatString(acct.getCgoto(), formats[0]).Trim();
                    line[1] = StringUtil.formatString(acct.getID(), formats[1]).Trim();
                    line[2] = StringUtil.formatString(acct.getName(), formats[2]).Trim();
                    line[3] = StringUtil.formatString(acct.getOwnmax(), formats[3]).Trim();
                    line[4] = StringUtil.formatString(acct.getCurown(), formats[4]).Trim();
                    line[5] = StringUtil.formatString(acct.getPcteva(), formats[5]).Trim();
                    line[6] = StringUtil.formatString(acct.getN2own(), formats[6]).Trim();

                    buffer = new StringBuilder();
                    for (j = 0; j < fieldCount; j++)
                    {
                        if (line[j].IndexOf(delimiter, StringComparison.Ordinal) > -1)
                        {
                            line[j] = "\"" + line[j] + "\"";
                        }
                        buffer.Append(line[j]);
                        if (j < (fieldCount - 1))
                        {
                            buffer.Append(delimiter);
                        }
                    }

                    @out.println(buffer.ToString());
                }
            }
            catch (Exception e)
            {
                Message.printWarning(3, routine, e);
                throw e;
            }
            finally
            {
                if (@out != null)
                {
                    @out.flush();
                    @out.close();
                }
            }
        }
示例#19
0
        /// <summary>
        /// Writes a list of StateMod_DelayTable objects to a list file.  A header is
        /// printed to the top of the file, containing the commands used to generate the
        /// file.  Any strings in the body of the file that contain the field delimiter will be wrapped in "...". </summary>
        /// <param name="filename"> the name of the file to which the data will be written. </param>
        /// <param name="delimiter"> the delimiter to use for separating field values. </param>
        /// <param name="update"> whether to update an existing file, retaining the current
        /// header (true) or to create a new file with a new header. </param>
        /// <param name="data"> the list of objects to write. </param>
        /// <param name="newComments"> the list of new comments to write to the header, or null if none. </param>
        /// <param name="comp"> the component type being written (to distinguish between daily and monthly delay tables),
        /// either StateMod_DataSet.COMP_DELAY_TABLES_DAILY or StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY. </param>
        /// <exception cref="Exception"> if an error occurs. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static void writeListFile(String filename, String delimiter, boolean update, java.util.List<StateMod_DelayTable> data, java.util.List<String> newComments, int comp) throws Exception
        public static void writeListFile(string filename, string delimiter, bool update, IList <StateMod_DelayTable> data, IList <string> newComments, int comp)
        {
            int size = 0;

            if (data != null)
            {
                size = data.Count;
            }

            IList <string> fields = new List <string>();

            fields.Add("DelayTableID");
            fields.Add("Date");
            fields.Add("ReturnAmount");

            int fieldCount = fields.Count;

            string[] names   = new string[fieldCount];
            string[] formats = new string[fieldCount];
            string   s       = null;

            for (int i = 0; i < fieldCount; i++)
            {
                s          = (string)fields[i];
                names[i]   = StateMod_Util.lookupPropValue(comp, "FieldName", s);
                formats[i] = StateMod_Util.lookupPropValue(comp, "Format", s);
            }

            string oldFile = null;

            if (update)
            {
                oldFile = IOUtil.getPathUsingWorkingDir(filename);
            }

            int                 j                 = 0;
            int                 k                 = 0;
            int                 num               = 0;
            PrintWriter         @out              = null;
            StateMod_DelayTable delay             = null;
            IList <string>      commentIndicators = new List <string>(1);

            commentIndicators.Add("#");
            IList <string> ignoredCommentIndicators = new List <string>(1);

            ignoredCommentIndicators.Add("#>");
            string[]      line   = new string[fieldCount];
            string        id     = null;
            StringBuilder buffer = new StringBuilder();

            try
            {
                // Add some basic comments at the top of the file.  Do this to a copy of the
                // incoming comments so that they are not modified in the calling code.
                IList <string> newComments2 = null;
                if (newComments == null)
                {
                    newComments2 = new List <string>();
                }
                else
                {
                    newComments2 = new List <string>(newComments);
                }
                newComments2.Insert(0, "");
                if (comp == StateMod_DataSet.COMP_DELAY_TABLES_DAILY)
                {
                    newComments2.Insert(1, "StateMod delay tables (daily) as a delimited list file.");
                }
                else
                {
                    newComments2.Insert(1, "StateMod delay tables (monthly) as a delimited list file.");
                }
                newComments2.Insert(2, "");
                @out = IOUtil.processFileHeaders(IOUtil.getPathUsingWorkingDir(oldFile), IOUtil.getPathUsingWorkingDir(filename), newComments2, commentIndicators, ignoredCommentIndicators, 0);

                for (int i = 0; i < fieldCount; i++)
                {
                    buffer.Append("\"" + names[i] + "\"");
                    if (i < (fieldCount - 1))
                    {
                        buffer.Append(delimiter);
                    }
                }

                @out.println(buffer.ToString());

                for (int i = 0; i < size; i++)
                {
                    delay = (StateMod_DelayTable)data[i];

                    id  = delay.getID();
                    num = delay.getNdly();
                    for (j = 0; j < num; j++)
                    {
                        line[0] = StringUtil.formatString(id, formats[0]).Trim();
                        line[1] = StringUtil.formatString((j + 1), formats[1]).Trim();
                        line[2] = StringUtil.formatString(delay.getRet_val(j), formats[2]).Trim();

                        buffer = new StringBuilder();
                        for (k = 0; k < fieldCount; k++)
                        {
                            if (k > 0)
                            {
                                buffer.Append(delimiter);
                            }
                            if (line[k].IndexOf(delimiter, StringComparison.Ordinal) > -1)
                            {
                                line[k] = "\"" + line[k] + "\"";
                            }
                            buffer.Append(line[k]);
                        }

                        @out.println(buffer.ToString());
                    }
                }
                @out.flush();
                @out.close();
                @out = null;
            }
            catch (Exception e)
            {
                // TODO SAM 2009-01-11 Log it?
                throw e;
            }
            finally
            {
                if (@out != null)
                {
                    @out.flush();
                    @out.close();
                }
            }
        }
        /// <summary>
        /// Writes a list of StateMod_StreamGage objects to a list file.  A header is
        /// printed to the top of the file, containing the commands used to generate the
        /// file.  Any strings in the body of the file that contain the field delimiter will be wrapped in "...". </summary>
        /// <param name="filename"> the name of the file to which the data will be written. </param>
        /// <param name="delimiter"> the delimiter to use for separating field values. </param>
        /// <param name="update"> whether to update an existing file, retaining the current
        /// header (true) or to create a new file with a new header. </param>
        /// <param name="data"> the list of objects to write. </param>
        /// <param name="newComments"> list of comments to add at the top of the file. </param>
        /// <exception cref="Exception"> if an error occurs. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static void writeListFile(String filename, String delimiter, boolean update, java.util.List<StateMod_StreamGage> data, java.util.List<String> newComments) throws Exception
        public static void writeListFile(string filename, string delimiter, bool update, IList <StateMod_StreamGage> data, IList <string> newComments)
        {
            int size = 0;

            if (data != null)
            {
                size = data.Count;
            }

            IList <string> fields = new List <string>();

            fields.Add("ID");
            fields.Add("Name");
            fields.Add("NodeID");
            fields.Add("DailyID");
            int fieldCount = fields.Count;

            string[] names   = new string[fieldCount];
            string[] formats = new string[fieldCount];
            int      comp    = StateMod_DataSet.COMP_STREAMGAGE_STATIONS;
            string   s       = null;

            for (int i = 0; i < fieldCount; i++)
            {
                s          = fields[i];
                names[i]   = StateMod_Util.lookupPropValue(comp, "FieldName", s);
                formats[i] = StateMod_Util.lookupPropValue(comp, "Format", s);
            }

            string oldFile = null;

            if (update)
            {
                oldFile = IOUtil.getPathUsingWorkingDir(filename);
            }

            int                 j    = 0;
            PrintWriter         @out = null;
            StateMod_StreamGage gage = null;
            IList <string>      commentIndicators = new List <string>(1);

            commentIndicators.Add("#");
            IList <string> ignoredCommentIndicators = new List <string>(1);

            ignoredCommentIndicators.Add("#>");
            string[]      line   = new string[fieldCount];
            StringBuilder buffer = new StringBuilder();

            try
            {
                // Add some basic comments at the top of the file.  Do this to a copy of the
                // incoming comments so that they are not modified in the calling code.
                IList <string> newComments2 = null;
                if (newComments == null)
                {
                    newComments2 = new List <string>();
                }
                else
                {
                    newComments2 = new List <string>(newComments);
                }
                newComments2.Insert(0, "");
                newComments2.Insert(1, "StateMod stream gage stations as a delimited list file.");
                newComments2.Insert(2, "");
                @out = IOUtil.processFileHeaders(oldFile, IOUtil.getPathUsingWorkingDir(filename), newComments2, commentIndicators, ignoredCommentIndicators, 0);

                for (int i = 0; i < fieldCount; i++)
                {
                    if (i > 0)
                    {
                        buffer.Append(delimiter);
                    }
                    buffer.Append("\"" + names[i] + "\"");
                }

                @out.println(buffer.ToString());

                for (int i = 0; i < size; i++)
                {
                    gage = (StateMod_StreamGage)data[i];

                    line[0] = StringUtil.formatString(gage.getID(), formats[0]).Trim();
                    line[1] = StringUtil.formatString(gage.getName(), formats[1]).Trim();
                    line[2] = StringUtil.formatString(gage.getCgoto(), formats[2]).Trim();
                    line[3] = StringUtil.formatString(gage.getCrunidy(), formats[3]).Trim();

                    buffer = new StringBuilder();
                    for (j = 0; j < fieldCount; j++)
                    {
                        if (j > 0)
                        {
                            buffer.Append(delimiter);
                        }
                        if (line[j].IndexOf(delimiter, StringComparison.Ordinal) > -1)
                        {
                            line[j] = "\"" + line[j] + "\"";
                        }
                        buffer.Append(line[j]);
                    }

                    @out.println(buffer.ToString());
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (@out != null)
                {
                    @out.flush();
                    @out.close();
                }
            }
        }
        /// <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.
        }
        /// <summary>
        /// Sets up the GUI
        /// </summary>
        public virtual void setupGUI()
        {
            string routine = "setupGUI";

            addWindowListener(this);

            __addDepletion    = new JButton(__BUTTON_ADD_DEPLETION);
            __deleteDepletion = new JButton(__BUTTON_DELETE_DEPLETION);
            __deleteDepletion.setEnabled(false);
            __helpJButton = new JButton(__BUTTON_HELP);
            __helpJButton.setEnabled(false);
            __closeJButton = new JButton(__BUTTON_CLOSE);
            JButton cancelJButton = new JButton(__BUTTON_CANCEL);
            JButton applyJButton  = new JButton(__BUTTON_APPLY);

            // AWT portion
            GridBagLayout gb         = new GridBagLayout();
            JPanel        mainJPanel = new JPanel();

            mainJPanel.setLayout(gb);

            FlowLayout fl = new FlowLayout(FlowLayout.RIGHT);
            JPanel     p1 = new JPanel();

            p1.setLayout(fl);

            GridLayout gl         = new GridLayout(2, 2, 1, 1);
            JPanel     info_panel = new JPanel();

            info_panel.setLayout(gl);

            JPanel main_panel = new JPanel();

            main_panel.setLayout(new BorderLayout());

            info_panel.add(new JLabel("Well:"));
            info_panel.add(new JLabel(__currentWell.getID()));
            info_panel.add(new JLabel("Well name:"));
            info_panel.add(new JLabel(__currentWell.getName()));

            if (__editable)
            {
                p1.add(__addDepletion);
                p1.add(__deleteDepletion);
            }
            p1.add(applyJButton);
            p1.add(cancelJButton);
            //	p1.add(__helpJButton);
            p1.add(__closeJButton);

            PropList p = new PropList("StateMod_Well_Depletion_JFrame.JWorksheet");

            p.add("JWorksheet.ShowPopupMenu=true");
            p.add("JWorksheet.AllowCopy=true");
            p.add("JWorksheet.SelectionMode=SingleRowSelection");

            int[]            widths = null;
            JScrollWorksheet jsw    = null;

            try
            {
//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> nodes = (java.util.List<StateMod_RiverNetworkNode>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK).getData());
                IList <StateMod_RiverNetworkNode> nodes = (IList <StateMod_RiverNetworkNode>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK).getData());
                IList <StateMod_ReturnFlow>       v     = new List <StateMod_ReturnFlow>();
                IList <StateMod_ReturnFlow>       v2    = __currentWell.getDepletions();
                StateMod_ReturnFlow rf;
                for (int i = 0; i < v2.Count; i++)
                {
                    rf = (StateMod_ReturnFlow)v2[i].clone();
                    rf.setCrtnid(rf.getCrtnid() + StateMod_Util.findNameInVector(rf.getCrtnid(), nodes, true));
                    v.Add(rf);
                }

                StateMod_ReturnFlow_TableModel   tmw = new StateMod_ReturnFlow_TableModel(__dataset, v, __editable, false);
                StateMod_ReturnFlow_CellRenderer crw = new StateMod_ReturnFlow_CellRenderer(tmw);

                jsw         = new JScrollWorksheet(crw, tmw, p);
                __worksheet = jsw.getJWorksheet();

                IList <string> ids = StateMod_Util.createIdentifierListFromStateModData(nodes, true, null);
                __worksheet.setColumnJComboBoxValues(StateMod_ReturnFlow_TableModel.COL_RIVER_NODE, ids, false);

                IList <StateMod_DelayTable> delayIDs = null;
                if (__dataset.getIday() == 1)
                {
//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> delayIDs0 = (java.util.List<StateMod_DelayTable>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_DAILY).getData());
                    IList <StateMod_DelayTable> delayIDs0 = (IList <StateMod_DelayTable>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_DAILY).getData());
                    delayIDs = delayIDs0;
                }
                else
                {
//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> delayIDs0 = (java.util.List<StateMod_DelayTable>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY).getData());
                    IList <StateMod_DelayTable> delayIDs0 = (IList <StateMod_DelayTable>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY).getData());
                    delayIDs = delayIDs0;
                }
                ids = StateMod_Util.createIdentifierListFromStateModData(delayIDs, true, null);
                __worksheet.setColumnJComboBoxValues(StateMod_ReturnFlow_TableModel.COL_RETURN_ID, ids, false);
                widths = crw.getColumnWidths();
            }
            catch (Exception e)
            {
                Message.printWarning(2, routine, e);
                jsw         = new JScrollWorksheet(0, 0, p);
                __worksheet = jsw.getJWorksheet();
            }
            __worksheet.setPreferredScrollableViewportSize(null);

            __worksheet.setHourglassJFrame(this);
            __worksheet.addMouseListener(this);
            __worksheet.addKeyListener(this);

            main_panel.add(jsw, "Center");
            main_panel.add(p1, "South");
            JGUIUtil.addComponent(mainJPanel, info_panel, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
            JGUIUtil.addComponent(mainJPanel, main_panel, 0, 1, 10, 10, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.SOUTH);

            getContentPane().add(mainJPanel);

            JPanel bottomJPanel = new JPanel();

            bottomJPanel.setLayout(gb);
            __messageJTextField = new JTextField();
            __messageJTextField.setEditable(false);
            JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 0, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
            __statusJTextField = new JTextField(5);
            __statusJTextField.setEditable(false);
            JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            getContentPane().add("South", bottomJPanel);

            __addDepletion.addActionListener(this);
            __deleteDepletion.addActionListener(this);
            __closeJButton.addActionListener(this);
            __helpJButton.addActionListener(this);
            applyJButton.addActionListener(this);
            cancelJButton.addActionListener(this);

            pack();
            setSize(520, 280);
            JGUIUtil.center(this);
            setVisible(true);

            if (widths != null)
            {
                __worksheet.setColumnWidths(widths);
            }
        }
        /// <summary>
        /// Sets up the GUI.
        /// </summary>
        public virtual void setupGUI()
        {
            string routine = "setupGUI";

            addWindowListener(this);

            __addPrecip     = new JButton(__BUTTON_ADD_PRECIPITATION_STATION);
            __addEvap       = new JButton(__BUTTON_ADD_EVAPORATION_STATION);
            __deleteStation = new JButton(__BUTTON_DELETE_PRECIPITATION_STATION);
            __deleteStation.setEnabled(false);
            __helpJButton = new JButton(__BUTTON_HELP);
            __helpJButton.setEnabled(false);
            __closeJButton = new JButton(__BUTTON_CLOSE);
            JButton cancelJButton = new JButton(__BUTTON_CANCEL);
            JButton applyJButton  = new JButton(__BUTTON_APPLY);

            GridBagLayout gb       = new GridBagLayout();
            JPanel        bigPanel = new JPanel();

            bigPanel.setLayout(gb);

            FlowLayout fl = new FlowLayout(FlowLayout.RIGHT);
            JPanel     p1 = new JPanel();

            p1.setLayout(fl);

            GridLayout gl         = new GridLayout(2, 2, 1, 1);
            JPanel     info_panel = new JPanel();

            info_panel.setLayout(gl);

            JPanel main_panel = new JPanel();

            main_panel.setLayout(new BorderLayout());

            info_panel.add(new JLabel("Reservoir:"));
            info_panel.add(new JLabel(__currentRes.getID()));
            info_panel.add(new JLabel("Reservoir name:"));
            info_panel.add(new JLabel(__currentRes.getName()));

            if (__editable)
            {
                p1.add(__addPrecip);
                p1.add(__addEvap);
                p1.add(__deleteStation);
            }
            p1.add(applyJButton);
            p1.add(cancelJButton);
            //	p1.add(__helpJButton);
            p1.add(__closeJButton);

            PropList p = new PropList("StateMod_Reservoir_Climate_JFrame.JWorksheet");

            p.add("JWorksheet.ShowPopupMenu=true");
            p.add("JWorksheet.AllowCopy=true");
            p.add("JWorksheet.SelectionMode=SingleRowSelection");

            int[]            widthsP = null;
            JScrollWorksheet jswP    = null;
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<String> stations = StateMod_Util.createIdentifierListFromTS(combineData((java.util.List<RTi.TS.MonthTS>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY).getData(), (java.util.List<RTi.TS.MonthTS>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY).getData()), true, null);
            IList <string> stations = StateMod_Util.createIdentifierListFromTS(combineData((IList <MonthTS>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY).getData(), (IList <MonthTS>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY).getData()), true, null);

            try
            {
                IList <StateMod_ReservoirClimate> temp   = getPrecipitationStations(__currentRes.getClimates());
                IList <StateMod_ReservoirClimate> clones = new List <StateMod_ReservoirClimate>();
                StateMod_ReservoirClimate         r      = null;
                int size = temp.Count;
                for (int i = 0; i < size; i++)
                {
                    r = temp[i];
                    clones.Add((StateMod_ReservoirClimate)r.clone());
                }

                __tableModelP = new StateMod_ReservoirClimate_TableModel(clones, __editable, true);
                StateMod_ReservoirClimate_CellRenderer crr = new StateMod_ReservoirClimate_CellRenderer(__tableModelP);

                jswP         = new JScrollWorksheet(crr, __tableModelP, p);
                __worksheetP = jswP.getJWorksheet();

                __worksheetP.setColumnJComboBoxValues(StateMod_ReservoirClimate_TableModel.COL_STATION, stations, true);

                widthsP = crr.getColumnWidths();
            }
            catch (Exception e)
            {
                Message.printWarning(1, routine, "Error building worksheet.", this);
                Message.printWarning(2, routine, e);
                jswP         = new JScrollWorksheet(0, 0, p);
                __worksheetP = jswP.getJWorksheet();
            }
            __worksheetP.setPreferredScrollableViewportSize(null);

            __worksheetP.setHourglassJFrame(this);
            __worksheetP.addMouseListener(this);
            __worksheetP.addKeyListener(this);

            int[]            widthsE = null;
            JScrollWorksheet jswE    = null;

            try
            {
                IList <StateMod_ReservoirClimate> temp   = getEvaporationStations(__currentRes.getClimates());
                IList <StateMod_ReservoirClimate> clones = new List <StateMod_ReservoirClimate>();
                StateMod_ReservoirClimate         r      = null;
                int size = temp.Count;
                for (int i = 0; i < size; i++)
                {
                    r = temp[i];
                    clones.Add((StateMod_ReservoirClimate)r.clone());
                }

                __tableModelE = new StateMod_ReservoirClimate_TableModel(clones, __editable, true);
                StateMod_ReservoirClimate_CellRenderer crr = new StateMod_ReservoirClimate_CellRenderer(__tableModelE);

                jswE         = new JScrollWorksheet(crr, __tableModelE, p);
                __worksheetE = jswE.getJWorksheet();

                __worksheetE.setColumnJComboBoxValues(StateMod_ReservoirClimate_TableModel.COL_STATION, stations, true);
                widthsE = crr.getColumnWidths();
            }
            catch (Exception e)
            {
                Message.printWarning(1, routine, "Error building worksheet.", this);
                Message.printWarning(2, routine, e);
                jswE         = new JScrollWorksheet(0, 0, p);
                __worksheetE = jswE.getJWorksheet();
            }
            __worksheetE.setPreferredScrollableViewportSize(null);

            __worksheetE.setHourglassJFrame(this);
            __worksheetE.addMouseListener(this);
            __worksheetE.addKeyListener(this);

            JPanel worksheets = new JPanel();

            worksheets.setLayout(gb);

            JPanel panelP = new JPanel();

            panelP.setLayout(gb);
            panelP.setBorder(BorderFactory.createTitledBorder("Precipitation Stations"));
            JGUIUtil.addComponent(panelP, jswP, 0, 0, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);

            JPanel panelE = new JPanel();

            panelE.setLayout(gb);
            panelE.setBorder(BorderFactory.createTitledBorder("Evaporation Stations"));
            JGUIUtil.addComponent(panelE, jswE, 0, 0, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);

            JGUIUtil.addComponent(worksheets, panelP, 0, 0, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
            JGUIUtil.addComponent(worksheets, panelE, 0, 1, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);

            main_panel.add(worksheets, "Center");
            main_panel.add(p1, "South");

            // assemble parts
            JGUIUtil.addComponent(bigPanel, info_panel, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);

            JGUIUtil.addComponent(bigPanel, main_panel, 0, 1, 10, 10, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.SOUTH);
            __addEvap.addActionListener(this);
            __addPrecip.addActionListener(this);
            __deleteStation.addActionListener(this);
            __helpJButton.addActionListener(this);
            __closeJButton.addActionListener(this);
            applyJButton.addActionListener(this);
            cancelJButton.addActionListener(this);

            getContentPane().add(bigPanel);

            JPanel bottomJPanel = new JPanel();

            bottomJPanel.setLayout(gb);
            __messageJTextField = new JTextField();
            __messageJTextField.setEditable(false);
            JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 0, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
            __statusJTextField = new JTextField(5);
            __statusJTextField.setEditable(false);
            JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            getContentPane().add("South", bottomJPanel);

            pack();
            setSize(650, 400);
            JGUIUtil.center(this);
            setVisible(true);

            if (widthsP != null)
            {
                __worksheetP.setColumnWidths(widthsP);
            }
            if (widthsE != null)
            {
                __worksheetE.setColumnWidths(widthsE);
            }
        }
        /// <summary>
        /// Responds to action performed events. </summary>
        /// <param name="e"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent e)
        {
            string routine = "StateMod_RunReport_JFrame.actionPerformed";
            string action  = e.getActionCommand();

            if (action.Equals(__BUTTON_RUN_REPORT))
            {
                JRadioButton cb = getSelectedJRadioButton();
                if (cb == null)
                {
                    return;
                }
                StringBuilder sb = new StringBuilder("-report ");
                sb.Append(cb.getText());

                // now check if station id is needed; if so, append it
                if (cb == __xdgJRadioButton)
                {
                    sb.Append(" -");
                    sb.Append(StringUtil.getToken(__xdgSimpleJComboBox.getSelected(), " ", 0, 0));
                }
                else if (cb == __xrgJRadioButton)
                {
                    sb.Append(" -");
                    sb.Append(StringUtil.getToken(__xrgSimpleJComboBox.getSelected(), " ", 0, 0));
                }
                else if (cb == __xwgJRadioButton)
                {
                    sb.Append(" -");
                    sb.Append(StringUtil.getToken(__xwgSimpleJComboBox.getSelected(), " ", 0, 0));
                }

                string s = sb.ToString();
                try
                {         // Run the report using the process manager dialog.
                    // Pass in the main GUI class so that the modal process
                    // manager dialog is on top of that window.
                    Message.printStatus(1, routine, "Running statemod " + "with command line options: '" + sb + "'");
                    StateMod_Util.runStateMod(__dataset, s, true, __dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_MAIN));
                }
                catch (Exception)
                {
                    Message.printWarning(1, routine, "There was an error running:  \n" + s, this);
                }
            }
            else if (action.Equals(__BUTTON_CANCEL))
            {
                if (__dataset_wm != null)
                {
                    __dataset_wm.closeWindow(StateMod_DataSet_WindowManager.WINDOW_RUN_REPORT);
                }
                else
                {
                    JGUIUtil.close(this);
                }
            }
            else if (action.Equals(__BUTTON_HELP))
            {
                // REVISIT HELP (JTS - 2003-08-21)
            }
        }
        /// <summary>
        /// Writes a list of StateMod_RiverNetworkNode objects to a list file.  A header
        /// is printed to the top of the file, containing the commands used to generate the
        /// file.  Any strings in the body of the file that contain the field delimiter will be wrapped in "...". </summary>
        /// <param name="filename"> the name of the file to which the data will be written. </param>
        /// <param name="delimiter"> the delimiter to use for separating field values. </param>
        /// <param name="update"> whether to update an existing file, retaining the current
        /// header (true) or to create a new file with a new header. </param>
        /// <param name="data"> the list of objects to write. </param>
        /// <param name="newComments"> new comments to add to the file header. </param>
        /// <exception cref="Exception"> if an error occurs. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static void writeListFile(String filename, String delimiter, boolean update, java.util.List<StateMod_RiverNetworkNode> data, java.util.List<String> newComments) throws Exception
        public static void writeListFile(string filename, string delimiter, bool update, IList <StateMod_RiverNetworkNode> data, IList <string> newComments)
        {
            string routine = "StateMod_RiverNetworkNode.writeListFile";
            int    size    = 0;

            if (data != null)
            {
                size = data.Count;
            }

            IList <string> fields = new List <string>();

            fields.Add("ID");
            fields.Add("Name");
            fields.Add("DownstreamID");
            fields.Add("Comment");
            fields.Add("GWMaxRecharge");
            int fieldCount = fields.Count;

            string[] names   = new string[fieldCount];
            string[] formats = new string[fieldCount];
            int      comp    = StateMod_DataSet.COMP_RIVER_NETWORK;
            string   s       = null;

            for (int i = 0; i < fieldCount; i++)
            {
                s          = fields[i];
                names[i]   = StateMod_Util.lookupPropValue(comp, "FieldName", s);
                formats[i] = StateMod_Util.lookupPropValue(comp, "Format", s);
            }

            string oldFile = null;

            if (update)
            {
                oldFile = IOUtil.getPathUsingWorkingDir(filename);
            }

            int         j    = 0;
            PrintWriter @out = null;
            StateMod_RiverNetworkNode rnn = null;

            string[]       line = new string[fieldCount];
            IList <string> commentIndicators = new List <string>(1);

            commentIndicators.Add("#");
            IList <string> ignoredCommentIndicators = new List <string>(1);

            ignoredCommentIndicators.Add("#>");
            StringBuilder buffer = new StringBuilder();

            try
            {
                // Add some basic comments at the top of the file.  Do this to a copy of the
                // incoming comments so that they are not modified in the calling code.
                IList <string> newComments2 = null;
                if (newComments == null)
                {
                    newComments2 = new List <string>();
                }
                else
                {
                    newComments2 = new List <string>(newComments);
                }
                newComments2.Insert(0, "");
                newComments2.Insert(1, "StateMod river network as a delimited list file.");
                newComments2.Insert(2, "See also the generalized network file.");
                newComments2.Insert(3, "");
                @out = IOUtil.processFileHeaders(oldFile, IOUtil.getPathUsingWorkingDir(filename), newComments2, commentIndicators, ignoredCommentIndicators, 0);

                for (int i = 0; i < fieldCount; i++)
                {
                    if (i > 0)
                    {
                        buffer.Append(delimiter);
                    }
                    buffer.Append("\"" + names[i] + "\"");
                }

                @out.println(buffer.ToString());

                for (int i = 0; i < size; i++)
                {
                    rnn = (StateMod_RiverNetworkNode)data[i];

                    line[0] = StringUtil.formatString(rnn.getID(), formats[0]).Trim();
                    line[1] = StringUtil.formatString(rnn.getName(), formats[1]).Trim();
                    line[2] = StringUtil.formatString(rnn.getCstadn(), formats[2]).Trim();
                    line[3] = StringUtil.formatString(rnn.getComment(), formats[3]).Trim();
                    line[4] = StringUtil.formatString(rnn.getGwmaxr(), formats[4]).Trim();

                    buffer = new StringBuilder();
                    for (j = 0; j < fieldCount; j++)
                    {
                        if (j > 0)
                        {
                            buffer.Append(delimiter);
                        }
                        if (line[j].IndexOf(delimiter, StringComparison.Ordinal) > -1)
                        {
                            line[j] = "\"" + line[j] + "\"";
                        }
                        buffer.Append(line[j]);
                    }

                    @out.println(buffer.ToString());
                }
            }
            catch (Exception e)
            {
                Message.printWarning(3, routine, e);
                throw e;
            }
            finally
            {
                if (@out != null)
                {
                    @out.flush();
                    @out.close();
                }
            }
        }
        /// <summary>
        /// Sets up the GUI.
        /// </summary>
        private void setupGUI()
        {
            __xdgSimpleJComboBox = new SimpleJComboBox();

//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> diversionsVector = (java.util.List<StateMod_Diversion>) __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DIVERSION_STATIONS).getData();
            IList <StateMod_Diversion> diversionsVector = (IList <StateMod_Diversion>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DIVERSION_STATIONS).getData();
            IList <string>             list_names       = StateMod_Util.createIdentifierListFromStateModData(diversionsVector, true, null);
            int size = list_names.Count;

            for (int i = 0; i < size; i++)
            {
                __xdgSimpleJComboBox.add(list_names[i] + " - Diversion");
            }

//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> instreamFlowsVector = (java.util.List<StateMod_InstreamFlow>) __dataset.getComponentForComponentType(StateMod_DataSet.COMP_INSTREAM_STATIONS).getData();
            IList <StateMod_InstreamFlow> instreamFlowsVector = (IList <StateMod_InstreamFlow>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_INSTREAM_STATIONS).getData();

            list_names = StateMod_Util.createIdentifierListFromStateModData(instreamFlowsVector, true, null);
            size       = list_names.Count;
            for (int i = 0; i < size; i++)
            {
                __xdgSimpleJComboBox.add(list_names[i] + " - Instream Flow");
            }

//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> gageVector = (java.util.List<StateMod_StreamGage>) __dataset.getComponentForComponentType(StateMod_DataSet.COMP_STREAMGAGE_STATIONS).getData();
            IList <StateMod_StreamGage> gageVector = (IList <StateMod_StreamGage>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_STREAMGAGE_STATIONS).getData();

            list_names = StateMod_Util.createIdentifierListFromStateModData(gageVector, true, null);
            size       = list_names.Count;
            for (int i = 0; i < size; i++)
            {
                __xdgSimpleJComboBox.add(list_names[i] + " - Stream Gage");
            }

//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> estimateVector = (java.util.List<StateMod_StreamEstimate>) __dataset.getComponentForComponentType(StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS).getData();
            IList <StateMod_StreamEstimate> estimateVector = (IList <StateMod_StreamEstimate>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS).getData();

            list_names = StateMod_Util.createIdentifierListFromStateModData(estimateVector, true, null);
            size       = list_names.Count;
            for (int i = 0; i < size; i++)
            {
                __xdgSimpleJComboBox.add(list_names[i] + " - Stream Estimate");
            }

//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> reservoirsVector = (java.util.List<StateMod_Reservoir>) __dataset.getComponentForComponentType(StateMod_DataSet.COMP_RESERVOIR_STATIONS).getData();
            IList <StateMod_Reservoir> reservoirsVector = (IList <StateMod_Reservoir>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_RESERVOIR_STATIONS).getData();

            list_names           = StateMod_Util.createIdentifierListFromStateModData(reservoirsVector, true, null);
            size                 = list_names.Count;
            __xrgSimpleJComboBox = new SimpleJComboBox();
            for (int i = 0; i < size; i++)
            {
                __xrgSimpleJComboBox.add(list_names[i] + " - Reservoir");
            }

//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> wellsVector = (java.util.List<StateMod_Well>) __dataset.getComponentForComponentType(StateMod_DataSet.COMP_WELL_STATIONS).getData();
            IList <StateMod_Well> wellsVector = (IList <StateMod_Well>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_WELL_STATIONS).getData();

            list_names           = StateMod_Util.createIdentifierListFromStateModData(wellsVector, true, null);
            size                 = list_names.Count;
            __xwgSimpleJComboBox = new SimpleJComboBox();
            for (int i = 0; i < size; i++)
            {
                __xwgSimpleJComboBox.add(list_names[i] + " - Well");
            }

            // Define the button groups and add radio buttons to the group in the
            // order of the GUI...

            __general_ButtonGroup = new ButtonGroup();
            __general_ButtonGroup.add(__xstJRadioButton = new JRadioButton("-xst", false));
            __general_ButtonGroup.add(__xwbJRadioButton = new JRadioButton("-xwb", true));
            __general_ButtonGroup.add(__xwrJRadioButton = new JRadioButton("-xwr", false));
            __general_ButtonGroup.add(__xcuJRadioButton = new JRadioButton("-xcu", false));
            __compare_ButtonGroup = new ButtonGroup();
            __compare_ButtonGroup.add(__xdcJRadioButton = new JRadioButton("-xdc", true));
            __compare_ButtonGroup.add(__xrcJRadioButton = new JRadioButton("-xrc", false));
            __compare_ButtonGroup.add(__xwcJRadioButton = new JRadioButton("-xwc", false));
            __compare_ButtonGroup.add(__xscJRadioButton = new JRadioButton("-xsc", false));
            __graph_ButtonGroup = new ButtonGroup();
            __graph_ButtonGroup.add(__xdgJRadioButton = new JRadioButton("-xdg", true));
            __graph_ButtonGroup.add(__xrgJRadioButton = new JRadioButton("-xrg", false));
            __graph_ButtonGroup.add(__xwgJRadioButton = new JRadioButton("-xwg", false));
            __daily_ButtonGroup = new ButtonGroup();
            __daily_ButtonGroup.add(__xdyJRadioButton = new JRadioButton("-xdy", true));
            __daily_ButtonGroup.add(__xryJRadioButton = new JRadioButton("-xry", false));
            __daily_ButtonGroup.add(__xwyJRadioButton = new JRadioButton("-xwy", false));
            __other_ButtonGroup = new ButtonGroup();
            __other_ButtonGroup.add(__xnmJRadioButton = new JRadioButton("-xnm", true));
            __other_ButtonGroup.add(__xrxJRadioButton = new JRadioButton("-xrx", false));
            __other_ButtonGroup.add(__xspJRadioButton = new JRadioButton("-xsp", false));
            __other_ButtonGroup.add(__xbnJRadioButton = new JRadioButton("-xbn", false));

            // Set the selected item in the graph output, based on whether data
            // exists...

            bool something_selected = false;     // To help select a radio button

            if (__xdgSimpleJComboBox.getItemCount() == 0)
            {
                __xdgSimpleJComboBox.setEnabled(false);
            }
            else
            {
                __xdgSimpleJComboBox.select(0);
                __xdgJRadioButton.setSelected(true);
                something_selected = true;
            }
            if (__xrgSimpleJComboBox.getItemCount() == 0)
            {
                __xrgSimpleJComboBox.setEnabled(false);
            }
            else
            {
                __xrgSimpleJComboBox.select(0);
                if (!something_selected)
                {
                    __xrgJRadioButton.setSelected(true);
                    something_selected = true;
                }
            }
            if (__xwgSimpleJComboBox.getItemCount() == 0)
            {
                __xwgSimpleJComboBox.setEnabled(false);
            }
            else
            {
                __xwgSimpleJComboBox.select(0);
                if (!something_selected)
                {
                    __xwgJRadioButton.setSelected(true);
                }
            }

            __runStateModJButton = new JButton(__BUTTON_RUN_REPORT);
            __cancelJButton      = new JButton(__BUTTON_CANCEL);
            // REVISIT - enable when full help system is redesigned
            //__helpJButton = new JButton(__BUTTON_HELP);

            GridBagLayout gb        = new GridBagLayout();
            JPanel        mainPanel = new JPanel();

            mainPanel.setLayout(gb);

            int col1 = 0;
            int col2 = 1;
            int col3 = 2;
            int y;
            int bound = 2;     // buffer around components.

            __main_JTabbedPane = new JTabbedPane();

            __general_JPanel = new JPanel();
            __general_JPanel.setLayout(gb);
            __compare_JPanel = new JPanel();
            __compare_JPanel.setLayout(gb);
            __graph_JPanel = new JPanel();
            __graph_JPanel.setLayout(gb);
            __daily_JPanel = new JPanel();
            __daily_JPanel.setLayout(gb);
            __other_JPanel = new JPanel();
            __other_JPanel.setLayout(gb);

            /////////////////////////////////////////////////////////////
            // general panel
            /////////////////////////////////////////////////////////////
            y = 0;
            JGUIUtil.addComponent(__general_JPanel, new JLabel("Select one of the following report options." + "  Output files will have the extensions shown."), col1, y, 3, 1, 0, 0, 0, 0, bound, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            JGUIUtil.addComponent(__general_JPanel, __xstJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xstJLabel1 = new JLabel("Direct and Instream Flow Data (*.xdd)");
            __xstJLabel1.addMouseListener(this);
            JGUIUtil.addComponent(__general_JPanel, __xstJLabel1, col2, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xstJLabel2 = new JLabel("Reservoir Data - Total and by Account " + "(*.xre)");
            __xstJLabel2.addMouseListener(this);
            JGUIUtil.addComponent(__general_JPanel, __xstJLabel2, col2, ++y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xstJLabel3 = new JLabel("Operation Right Summary (*.xop)");
            __xstJLabel3.addMouseListener(this);
            JGUIUtil.addComponent(__general_JPanel, __xstJLabel3, col2, ++y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xstJLabel4 = new JLabel("Instream Flow Reach Summary (*.xir)");
            __xstJLabel4.addMouseListener(this);
            JGUIUtil.addComponent(__general_JPanel, __xstJLabel4, col2, ++y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xstJLabel5 = new JLabel("Well Summary (*.xwe)");
            __xstJLabel5.addMouseListener(this);
            JGUIUtil.addComponent(__general_JPanel, __xstJLabel5, col2, ++y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JGUIUtil.addComponent(__general_JPanel, __xwbJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xwbJLabel = new JLabel("Water balance (*.xwb) and " + "Ground Water Balance (*.xgw)");
            __xwbJLabel.addMouseListener(this);
            JGUIUtil.addComponent(__general_JPanel, __xwbJLabel, col2, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JGUIUtil.addComponent(__general_JPanel, __xwrJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xwrJLabel = new JLabel("Water rights list, sorted by basin " + "rank (*.xwr)");
            __xwrJLabel.addMouseListener(this);
            JGUIUtil.addComponent(__general_JPanel, __xwrJLabel, col2, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JGUIUtil.addComponent(__general_JPanel, __xcuJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xcuJLabel1 = new JLabel("Simulated Diversions and " + "Consumptive Use (*.xcu)");
            __xcuJLabel1.addMouseListener(this);
            JGUIUtil.addComponent(__general_JPanel, __xcuJLabel1, col2, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xcuJLabel2 = new JLabel("Water supply summary (*.xsu)");
            __xcuJLabel2.addMouseListener(this);
            JGUIUtil.addComponent(__general_JPanel, __xcuJLabel2, col2, ++y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xcuJLabel3 = new JLabel("Shortage Summary (*.xsh)");
            __xcuJLabel3.addMouseListener(this);
            JGUIUtil.addComponent(__general_JPanel, __xcuJLabel3, col2, ++y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xcuJLabel4 = new JLabel("CU by Water District (*.xwd)");
            __xcuJLabel4.addMouseListener(this);
            JGUIUtil.addComponent(__general_JPanel, __xcuJLabel4, col2, ++y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            /////////////////////////////////////////////////////////////
            // compare panel
            /////////////////////////////////////////////////////////////
            y = 0;
            JGUIUtil.addComponent(__compare_JPanel, new JLabel("Select one of the following report options." + "  Output files will have the extensions shown."), col1, y, 3, 1, 0, 0, 0, 0, bound, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JGUIUtil.addComponent(__compare_JPanel, __xdcJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xdcJLabel = new JLabel("Diversion comparison (*.xdc)");
            __xdcJLabel.addMouseListener(this);
            JGUIUtil.addComponent(__compare_JPanel, __xdcJLabel, col2, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JGUIUtil.addComponent(__compare_JPanel, __xrcJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xrcJLabel = new JLabel("Reservoir comparison (*.xrc)");
            __xrcJLabel.addMouseListener(this);
            JGUIUtil.addComponent(__compare_JPanel, __xrcJLabel, col2, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JGUIUtil.addComponent(__compare_JPanel, __xwcJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xwcJLabel = new JLabel("Well comparison (*.xwc)");
            __xwcJLabel.addMouseListener(this);
            JGUIUtil.addComponent(__compare_JPanel, __xwcJLabel, col2, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JGUIUtil.addComponent(__compare_JPanel, __xscJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xscJLabel = new JLabel("Stream flow gage comparison (*.xsc)");
            __xscJLabel.addMouseListener(this);
            JGUIUtil.addComponent(__compare_JPanel, __xscJLabel, col2, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            /////////////////////////////////////////////////////////////
            // graph panel
            /////////////////////////////////////////////////////////////
            y = 0;
            JGUIUtil.addComponent(__graph_JPanel, new JLabel("Select one of the following report options." + "  Output files will have the extensions shown."), col1, y, 3, 1, 0, 0, 0, 0, bound, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JGUIUtil.addComponent(__graph_JPanel, __xdgJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            JGUIUtil.addComponent(__graph_JPanel, __xdgSimpleJComboBox, col2, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST);
            __xdgSimpleJComboBox.addMouseListener(this);
            __xdgJLabel = new JLabel("Direct diversion, instream flow and " + "gage graph (*.xdg)");
            __xdgJLabel.addMouseListener(this);
            JGUIUtil.addComponent(__graph_JPanel, __xdgJLabel, col3, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JGUIUtil.addComponent(__graph_JPanel, __xrgJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            JGUIUtil.addComponent(__graph_JPanel, __xrgSimpleJComboBox, col2, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST);
            __xrgSimpleJComboBox.addMouseListener(this);
            __xrgJLabel = new JLabel("Reservoir graph (*.xrg)");
            __xrgJLabel.addMouseListener(this);
            JGUIUtil.addComponent(__graph_JPanel, __xrgJLabel, col3, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JGUIUtil.addComponent(__graph_JPanel, __xwgJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            JGUIUtil.addComponent(__graph_JPanel, __xwgSimpleJComboBox, col2, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST);
            __xwgSimpleJComboBox.addMouseListener(this);
            __xwgJLabel = new JLabel("Well graph (*.xwg)");
            __xwgJLabel.addMouseListener(this);
            JGUIUtil.addComponent(__graph_JPanel, __xwgJLabel, col3, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);


            /////////////////////////////////////////////////////////////
            // daily panel
            /////////////////////////////////////////////////////////////
            y = 0;
            JGUIUtil.addComponent(__daily_JPanel, new JLabel("Select one of the following report options." + "  Output files will have the extensions shown."), col1, y, 3, 1, 0, 0, 0, 0, bound, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JGUIUtil.addComponent(__daily_JPanel, __xdyJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xdyJLabel = new JLabel("Daily Direct Diversion and Instream Flow Data" + " (*.xdy)");
            __xdyJLabel.addMouseListener(this);
            JGUIUtil.addComponent(__daily_JPanel, __xdyJLabel, col2, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JGUIUtil.addComponent(__daily_JPanel, __xryJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xryJLabel = new JLabel("Daily Reservoir Data (*.xry)");
            __xryJLabel.addMouseListener(this);
            JGUIUtil.addComponent(__daily_JPanel, __xryJLabel, col2, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JGUIUtil.addComponent(__daily_JPanel, __xwyJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xwyJLabel = new JLabel("Daily Well Data (*.xwy)");
            __xwyJLabel.addMouseListener(this);
            JGUIUtil.addComponent(__daily_JPanel, __xwyJLabel, col2, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            /////////////////////////////////////////////////////////////
            // other panel
            /////////////////////////////////////////////////////////////
            y = 0;
            JGUIUtil.addComponent(__other_JPanel, new JLabel("Select one of the following report options." + "  Output files will have the extensions shown."), col1, y, 3, 1, 0, 0, 0, 0, bound, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JGUIUtil.addComponent(__other_JPanel, __xnmJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xnmJLabel1 = new JLabel("Detailed Node Accounting, monthly (*.xnm) and ");
            __xnmJLabel1.addMouseListener(this);
            JGUIUtil.addComponent(__other_JPanel, __xnmJLabel1, col3, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xnmJLabel2 = new JLabel("Summary Node Accounting, average (*.xna)");
            __xnmJLabel2.addMouseListener(this);
            JGUIUtil.addComponent(__other_JPanel, __xnmJLabel2, col3, ++y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JGUIUtil.addComponent(__other_JPanel, __xrxJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xrxJLabel = new JLabel("River data summary (*.xrx)");
            __xrxJLabel.addMouseListener(this);
            JGUIUtil.addComponent(__other_JPanel, __xrxJLabel, col3, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JGUIUtil.addComponent(__other_JPanel, __xspJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xspJLabel = new JLabel("Selected parameter printout," + " uses output control file (*.xsp)");
            __xspJLabel.addMouseListener(this);
            JGUIUtil.addComponent(__other_JPanel, __xspJLabel, col3, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JGUIUtil.addComponent(__other_JPanel, __xbnJRadioButton, col1, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __xbnJLabel = new JLabel("ASCII listing of Binary Direct and " + "Instream Data (*.xbn)");
            __xbnJLabel.addMouseListener(this);
            JGUIUtil.addComponent(__other_JPanel, __xbnJLabel, col3, y, 1, 1, 0, 0, 0, bound, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            __main_JTabbedPane.add("General", __general_JPanel);
            __main_JTabbedPane.add("Compare", __compare_JPanel);
            __main_JTabbedPane.add("Graph", __graph_JPanel);
            __main_JTabbedPane.add("Daily", __daily_JPanel);
            __main_JTabbedPane.add("Other", __other_JPanel);

            getContentPane().add("Center", __main_JTabbedPane);

            // add buttons
            JPanel p1 = new JPanel();

            p1.add(__runStateModJButton);
            p1.add(__cancelJButton);
            // REVISIT - add when full help system is redesigned.
            //p1.add(__helpJButton);
            //__helpJButton.setEnabled(false);
            //__helpJButton.addActionListener(this);
            __runStateModJButton.addActionListener(this);
            __cancelJButton.addActionListener(this);

            getContentPane().add("South", p1);

            if (__dataset_wm != null)
            {
                __dataset_wm.setWindowOpen(StateMod_DataSet_WindowManager.WINDOW_RUN_REPORT, this);
            }

            pack();
            JGUIUtil.center(this);
            setVisible(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_Reservoir_Return_JFrame::actionPerformed";

            string action = e.getActionCommand();

            if (action.Equals(__BUTTON_ADD_RETURN))
            {
                StateMod_ReturnFlow aReturn = new StateMod_ReturnFlow(StateMod_DataSet.COMP_RESERVOIR_RETURN);
                aReturn._isClone = true;
                StateMod_ReturnFlow last = (StateMod_ReturnFlow)__worksheet.getLastRowData();

                if (last == null)
                {
                    aReturn.setID(StateMod_Util.createNewID(__currentRes.getID()));
                    aReturn.setCgoto(__currentRes.getID());
                }
                else
                {
                    aReturn.setID(StateMod_Util.createNewID(last.getID()));
                    aReturn.setCgoto(last.getCgoto());
                }
                __worksheet.scrollToLastRow();
                __worksheet.addRow(aReturn);
                __worksheet.selectLastRow();
                __deleteReturn_JButton.setEnabled(true);
            }
            else if (action.Equals(__BUTTON_DEL_RETURN))
            {
                int row = __worksheet.getSelectedRow();
                if (row != -1)
                {
                    int x = (new ResponseJDialog(this, "Delete return", "Delete reservoir return?", ResponseJDialog.YES | ResponseJDialog.NO)).response();
                    if (x == ResponseJDialog.NO)
                    {
                        return;
                    }

                    __worksheet.cancelEditing();
                    __worksheet.deleteRow(row);
                    __deleteReturn_JButton.setEnabled(false);
                }
                else
                {
                    Message.printWarning(1, routine, "Must select desired return to delete.");
                }
            }
            else if (action.Equals(__BUTTON_CLOSE))
            {
                if (saveData())
                {
                    setVisible(false);
                    dispose();
                }
            }
            else if (action.Equals(__BUTTON_APPLY))
            {
                saveData();
            }
            else if (action.Equals(__BUTTON_CANCEL))
            {
                setVisible(false);
                dispose();
            }
            else if (e.getSource() == __help_JButton)
            {
                // TODO HELP (JTS - 2003-06-09)
            }
        }
示例#28
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_Well_Right_JFrame.actionPerformed";

            string action = e.getActionCommand();

            if (action.Equals(__BUTTON_ADD_RIGHT))
            {
                StateMod_WellRight aRight = new StateMod_WellRight();
                aRight._isClone = true;
                StateMod_WellRight last = (StateMod_WellRight)__worksheet.getLastRowData();

                if (last == null)
                {
                    aRight.setID(StateMod_Util.createNewID(__currentWell.getID()));
                    aRight.setCgoto(__currentWell.getID());
                }
                else
                {
                    aRight.setID(StateMod_Util.createNewID(last.getID()));
                    aRight.setCgoto(last.getCgoto());
                }
                __worksheet.addRow(aRight);
                __worksheet.scrollToLastRow();
                __worksheet.selectLastRow();
                __deleteRight.setEnabled(true);
            }
            else if (action.Equals(__BUTTON_DEL_RIGHT))
            {
                int row = __worksheet.getSelectedRow();
                if (row != -1)
                {
                    int x = (new ResponseJDialog(this, "Delete right", "Delete well right?", ResponseJDialog.YES | ResponseJDialog.NO)).response();
                    if (x == ResponseJDialog.NO)
                    {
                        return;
                    }

                    __worksheet.cancelEditing();
                    __worksheet.deleteRow(row);
                    __deleteRight.setEnabled(false);
                }
                else
                {
                    Message.printWarning(1, routine, "Must select desired right to delete.");
                }
            }
            else if (action.Equals(__BUTTON_HELP))
            {
                // REVISIT HELP (JTS - 2003-06-10)
            }
            else if (action.Equals(__BUTTON_CLOSE))
            {
                if (saveData())
                {
                    setVisible(false);
                    dispose();
                }
            }
            else if (action.Equals(__BUTTON_APPLY))
            {
                saveData();
            }
            else if (action.Equals(__BUTTON_CANCEL))
            {
                setVisible(false);
                dispose();
            }
        }
示例#29
0
        /// <summary>
        /// Writes a list of StateMod_ReservoirAreaCap objects to a list file.  A header
        /// is printed to the top of the file, containing the commands used to generate the
        /// file.  Any strings in the body of the file that contain the field delimiter will be wrapped in "...". </summary>
        /// <param name="filename"> the name of the file to which the data will be written. </param>
        /// <param name="delimiter"> the delimiter to use for separating field values. </param>
        /// <param name="update"> whether to update an existing file, retaining the current
        /// header (true) or to create a new file with a new header. </param>
        /// <param name="data"> the list of objects to write. </param>
        /// <param name="newComments"> new comments to add at the top of the file. </param>
        /// <exception cref="Exception"> if an error occurs. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static void writeListFile(String filename, String delimiter, boolean update, java.util.List<StateMod_ReservoirAreaCap> data, java.util.List<String> newComments) throws Exception
        public static void writeListFile(string filename, string delimiter, bool update, IList <StateMod_ReservoirAreaCap> data, IList <string> newComments)
        {
            string routine = "StateMod_ReservoirAreaCap.writeListFile";
            int    size    = 0;

            if (data != null)
            {
                size = data.Count;
            }

            IList <string> fields = new List <string>();

            fields.Add("ReservoirID");
            fields.Add("Content");
            fields.Add("Area");
            fields.Add("Seepage");
            int fieldCount = fields.Count;

            string[] names   = new string[fieldCount];
            string[] formats = new string[fieldCount];
            int      comp    = StateMod_Util.COMP_RESERVOIR_AREA_CAP;
            string   s       = null;

            for (int i = 0; i < fieldCount; i++)
            {
                s          = (string)fields[i];
                names[i]   = StateMod_Util.lookupPropValue(comp, "FieldName", s);
                formats[i] = StateMod_Util.lookupPropValue(comp, "Format", s);
            }

            string oldFile = null;

            if (update)
            {
                oldFile = IOUtil.getPathUsingWorkingDir(filename);
            }

            int         j    = 0;
            PrintWriter @out = null;
            StateMod_ReservoirAreaCap area = null;

            string[]       line = new string[fieldCount];
            IList <string> commentIndicators = new List <string>(1);

            commentIndicators.Add("#");
            IList <string> ignoredCommentIndicators = new List <string>(1);

            ignoredCommentIndicators.Add("#>");
            StringBuilder buffer = new StringBuilder();

            try
            {
                // Add some basic comments at the top of the file.  Do this to a copy of the
                // incoming comments so that they are not modified in the calling code.
                IList <string> newComments2 = null;
                if (newComments == null)
                {
                    newComments2 = new List <string>();
                }
                else
                {
                    newComments2 = new List <string>(newComments);
                }
                newComments2.Insert(0, "");
                newComments2.Insert(1, "StateMod reservoir content/area/seepage data as a delimited list file.");
                newComments2.Insert(2, "See also the associated station, account, precipitation station,");
                newComments2.Insert(3, "evaporation station, and collection files.");
                newComments2.Insert(4, "");
                @out = IOUtil.processFileHeaders(oldFile, IOUtil.getPathUsingWorkingDir(filename), newComments2, commentIndicators, ignoredCommentIndicators, 0);

                for (int i = 0; i < fieldCount; i++)
                {
                    if (i > 0)
                    {
                        buffer.Append(delimiter);
                    }
                    buffer.Append("\"" + names[i] + "\"");
                }

                @out.println(buffer.ToString());

                for (int i = 0; i < size; i++)
                {
                    area = (StateMod_ReservoirAreaCap)data[i];

                    line[0] = StringUtil.formatString(area.getCgoto(), formats[0]).Trim();
                    line[1] = StringUtil.formatString(area.getConten(), formats[1]).Trim();
                    line[2] = StringUtil.formatString(area.getSurarea(), formats[2]).Trim();
                    line[3] = StringUtil.formatString(area.getSeepage(), formats[3]).Trim();

                    buffer = new StringBuilder();
                    for (j = 0; j < fieldCount; j++)
                    {
                        if (j > 0)
                        {
                            buffer.Append(delimiter);
                        }
                        if (line[j].IndexOf(delimiter, StringComparison.Ordinal) > -1)
                        {
                            line[j] = "\"" + line[j] + "\"";
                        }
                        buffer.Append(line[j]);
                    }

                    @out.println(buffer.ToString());
                }
            }
            catch (Exception e)
            {
                Message.printWarning(3, routine, e);
                throw e;
            }
            finally
            {
                if (@out != null)
                {
                    @out.flush();
                    @out.close();
                }
            }
        }
示例#30
0
        /// <summary>
        /// Saves the input back into the dataset. </summary>
        /// <returns> true if the data was saved successfuly.  False if not. </returns>
        private bool saveData()
        {
            string routine = "StateMod_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);
        }