コード例 #1
0
        /// <summary>
        /// Performs data checks on diversion rights data. </summary>
        /// <param name="props"> A property list for specific properties
        /// on checking this data. </param>
        /// <param name="der_vector"> Vector of data to check. </param>
        private void checkDiversionRightsData(PropList props, System.Collections.IList der_vector)
        {
            // create elements for the checks and check file
            string[] header = StateMod_DiversionRight.getDataHeader();
            System.Collections.IList data = new List <object>();
            string title = "Diversion Rights";

            // Perform the general validation using the Data Table Model
            StateMod_Data_TableModel tm = new StateMod_DiversionRight_Data_TableModel(der_vector, false);

            System.Collections.IList @checked = performDataValidation(tm, title);
            //String [] columnHeader = getDataTableModelColumnHeader( tm );
            string[] columnHeader = getColumnHeader(tm);

            //	 do specific checks
            int size = 0;

            if (der_vector != null)
            {
                size = der_vector.Count;
            }
            data = doSpecificDataChecks(der_vector, props);
            // add the data and checks to the check file
            // provides basic header information for this data check table
            string info = "The following diversion rights (" + data.Count +
                          " out of " + size +
                          ") have no .....";

            // create data models for Check file
            CheckFile_DataModel dm     = new CheckFile_DataModel(data, header, title, info, data.Count, size);
            CheckFile_DataModel gen_dm = new CheckFile_DataModel(@checked, columnHeader, title + " Missing or Invalid Data", "", __gen_problems, size);

            __check_file.addData(dm, gen_dm);
        }
コード例 #2
0
        /// <summary>
        /// Returns the data that should be placed in the JTable at the given row
        /// and column. </summary>
        /// <param name="row"> the row for which to return data. </param>
        /// <param name="col"> the column for which to return data.  This is base 0. </param>
        /// <returns> the data that should be placed in the JTable at the given row and col. </returns>
        public virtual object getValueAt(int row, int col)
        {
            if (_sortOrder != null)
            {
                row = _sortOrder[row];
            }
            StateMod_DiversionRight dr = (StateMod_DiversionRight)_data.get(row);

            switch (col)
            {
            case COL_RIGHT_ID:
                return(dr.getID());

            case COL_RIGHT_NAME:
                return(dr.getName());

            case COL_STRUCT_ID:
                return(dr.getCgoto());

            case COL_ADMIN_NUM:
                return(dr.getIrtem());

            case COL_DCR_AMT:
                return(new double?(dr.getDcrdiv()));

            case COL_ON_OFF:
                return(new int?(dr.getSwitch()));

            default:
                return("");
            }
        }
コード例 #3
0
        /// <summary>
        /// Compares this object to another StateMod_Data object based on the sorted
        /// order from the StateMod_Data variables, and then by irtem and dcrdiv, in that order. </summary>
        /// <param name="data"> the object to compare against. </param>
        /// <returns> 0 if they are the same, 1 if this object is greater than the other object, or -1 if it is less. </returns>
        public virtual int CompareTo(StateMod_Data data)
        {
            int res = base.CompareTo(data);

            if (res != 0)
            {
                return(res);
            }

            StateMod_DiversionRight right = (StateMod_DiversionRight)data;

            res = _irtem.CompareTo(right.getIrtem());
            if (res == 0)
            {
                double dcrdiv = right.getDcrdiv();
                if (dcrdiv == _dcrdiv)
                {
                    return(0);
                }
                else if (_dcrdiv < dcrdiv)
                {
                    return(-1);
                }
                else
                {
                    return(1);
                }
            }
            else
            {
                return(res);
            }
        }
コード例 #4
0
        /// <summary>
        /// Parses the diversion rights file and returns a Vector of StateMod_DiversionRight objects. </summary>
        /// <param name="filename"> the diversion rights file to parse. </param>
        /// <returns> a Vector of StateMod_DiversionRight objects. </returns>
        /// <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 java.util.List<StateMod_DiversionRight> readStateModFile(String filename) throws Exception
        public static IList <StateMod_DiversionRight> readStateModFile(string filename)
        {
            string routine = "StateMod_DiversionRight.readStateModFile";
            IList <StateMod_DiversionRight> theDivRights = new List <StateMod_DiversionRight> ();

            int[]                   format_0  = new int[] { StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER };
            int[]                   format_0w = new int[] { 12, 24, 12, 16, 8, 8 };
            string                  iline     = null;
            IList <object>          v         = new List <object>(6);
            StreamReader            @in       = null;
            StateMod_DiversionRight aRight    = null;

            Message.printStatus(2, routine, "Reading diversion rights file: " + filename);

            try
            {
                @in = new StreamReader(IOUtil.getPathUsingWorkingDir(filename));
                while (!string.ReferenceEquals((iline = @in.ReadLine()), null))
                {
                    // check for comments
                    if (iline.StartsWith("#", StringComparison.Ordinal) || iline.Trim().Length == 0)
                    {
                        continue;
                    }

                    aRight = new StateMod_DiversionRight();

                    if (Message.isDebugOn)
                    {
                        Message.printDebug(50, routine, "iline: " + iline);
                    }
                    StringUtil.fixedRead(iline, format_0, format_0w, v);
                    aRight.setID(((string)v[0]).Trim());
                    aRight.setName(((string)v[1]).Trim());
                    aRight.setCgoto(((string)v[2]).Trim());
                    aRight.setIrtem(((string)v[3]).Trim());
                    aRight.setDcrdiv((double?)v[4]);
                    aRight.setSwitch((int?)v[5]);
                    // Mark as clean because set methods may have marked dirty...
                    aRight.setDirty(false);
                    theDivRights.Add(aRight);
                }
            }
            catch (Exception e)
            {
                Message.printWarning(3, routine, e);
                throw e;
            }
            finally
            {
                if (@in != null)
                {
                    @in.Close();
                }
            }
            return(theDivRights);
        }
コード例 #5
0
        /// <summary>
        /// Clones the data object. </summary>
        /// <returns> a cloned object. </returns>
        public override object clone()
        {
            StateMod_DiversionRight right = (StateMod_DiversionRight)base.clone();

            right._irtem   = _irtem;
            right._dcrdiv  = _dcrdiv;
            right._isClone = true;

            return(right);
        }
        /// <summary>
        /// Called when the cancel button is pressed.  This discards any changes made to the data objects.
        /// </summary>
        protected internal override void cancel()
        {
            StateMod_DiversionRight right = null;
            int size = _data.Count;

            for (int i = 0; i < size; i++)
            {
                right = (StateMod_DiversionRight)_data[i];
                right.restoreOriginal();
            }
        }
        /// <summary>
        /// Called when the Apply button is pressed. This commits any changes to the data objects.
        /// </summary>
        protected internal override void apply()
        {
            StateMod_DiversionRight right = null;
            int size = _data.Count;

            for (int i = 0; i < size; i++)
            {
                right = (StateMod_DiversionRight)_data[i];
                right.createBackup();
            }
        }
コード例 #8
0
        /// <summary>
        /// Clones the data object. </summary>
        /// <returns> a cloned object. </returns>
        //public override object clone()
        //{
        //	StateMod_DiversionRight right = (StateMod_DiversionRight)base.clone();
        //	right._irtem = _irtem;
        //	right._dcrdiv = _dcrdiv;
        //	right._isClone = true;

        //	return right;
        //}

        /// <summary>
        /// Compares this object to another StateMod_Data object based on the sorted
        /// order from the StateMod_Data variables, and then by irtem and dcrdiv, in that order. </summary>
        /// <param name="data"> the object to compare against. </param>
        /// <returns> 0 if they are the same, 1 if this object is greater than the other object, or -1 if it is less. </returns>
        //public virtual int CompareTo(StateMod_Data data)
        //{
        //	int res = base.CompareTo(data);
        //	if (res != 0)
        //	{
        //		return res;
        //	}

        //	StateMod_DiversionRight right = (StateMod_DiversionRight)data;

        //	res = _irtem.CompareTo(right.getIrtem());
        //	if (res == 0)
        //	{
        //		double dcrdiv = right.getDcrdiv();
        //		if (dcrdiv == _dcrdiv)
        //		{
        //			return 0;
        //		}
        //		else if (_dcrdiv < dcrdiv)
        //		{
        //			return -1;
        //		}
        //		else
        //		{
        //			return 1;
        //		}
        //	}
        //	else
        //	{
        //		return res;
        //	}
        //}

        /// <summary>
        /// Creates a copy of the object for later use in checking to see if it was changed in a GUI.
        /// </summary>
        //public virtual void createBackup()
        //{
        //	_original = (StateMod_DiversionRight)clone();
        //	((StateMod_DiversionRight)_original)._isClone = false;
        //	_isClone = true;
        //}

        /// <summary>
        /// Compare two rights list and see if they are the same. </summary>
        /// <param name="v1"> the first list of StateMod_DiversionRight to check.  Cannot be null. </param>
        /// <param name="v2"> the second list of StateMod_DiversionRight to check.  Cannot be null. </param>
        /// <returns> true if they are the same, false if not. </returns>
        //public static bool Equals(IList<StateMod_DiversionRight> v1, IList<StateMod_DiversionRight> v2)
        //{
        //	string routine = "StateMod_DiversionRight.equals(Vector, Vector)";
        //	StateMod_DiversionRight r1;
        //	StateMod_DiversionRight r2;
        //	if (v1.Count != v2.Count)
        //	{
        //		Message.printStatus(1, 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_DiversionRight> v1Sort = StateMod_Util.sortStateMod_DataVector(v1);
        //		IList<StateMod_DiversionRight> 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;
        //}

        /// <summary>
        /// Tests to see if two diversion rights are equal.  Strings are compared with case sensitivity. </summary>
        /// <param name="right"> the right to compare. </param>
        /// <returns> true if they are equal, false otherwise. </returns>
        public virtual bool Equals(StateMod_DiversionRight right)
        {
            if (!base.Equals(right))
            {
                return(false);
            }
            if (right._irtem.Equals(_irtem) && right._dcrdiv == _dcrdiv)
            {
                return(true);
            }
            return(false);
        }
コード例 #9
0
        /// <summary>
        /// Cancels any changes made to this object within a GUI since createBackup()
        /// was called and sets _original to null.
        /// </summary>
        public override void restoreOriginal()
        {
            StateMod_DiversionRight d = (StateMod_DiversionRight)_original;

            base.restoreOriginal();

            _irtem  = d._irtem;
            _dcrdiv = d._dcrdiv;

            _isClone  = false;
            _original = null;
        }
コード例 #10
0
        /// <summary>
        /// Inserts the specified value into the table at the given position. </summary>
        /// <param name="value"> the object to store in the table cell. </param>
        /// <param name="row"> the row of the cell in which to place the object. </param>
        /// <param name="col"> the column of the cell in which to place the object. </param>
        public virtual void setValueAt(object value, int row, int col)
        {
            if (_sortOrder != null)
            {
                row = _sortOrder[row];
            }
            double dval;
            int    ival;
            int    index;

            StateMod_DiversionRight dr = (StateMod_DiversionRight)_data.get(row);

            switch (col)
            {
            case COL_RIGHT_ID:
                dr.setID((string)value);
                break;

            case COL_RIGHT_NAME:
                dr.setName((string)value);
                break;

            case COL_STRUCT_ID:
                dr.setCgoto((string)value);
                break;

            case COL_ADMIN_NUM:
                dr.setIrtem((string)value);
                break;

            case COL_DCR_AMT:
                dval = ((double?)value).Value;
                dr.setDcrdiv(dval);
                break;

            case COL_ON_OFF:
                if (value is int?)
                {
                    ival = ((int?)value).Value;
                    dr.setSwitch(ival);
                }
                else if (value is string)
                {
                    string onOff = (string)value;
                    index = onOff.IndexOf(" -", StringComparison.Ordinal);
                    ival  = (Convert.ToInt32(onOff.Substring(0, index)));
                    dr.setSwitch(ival);
                }
                break;
            }

            base.setValueAt(value, row, col);
        }
コード例 #11
0
        /// <summary>
        /// Returns the data that should be placed in the JTable at the given row
        /// and column. </summary>
        /// <param name="row"> the row for which to return data. </param>
        /// <param name="col"> the column for which to return data.  This is base 0. </param>
        /// <returns> the data that should be placed in the JTable at the given row and col. </returns>
        public virtual object getValueAt(int row, int col)
        {
            if (_sortOrder != null)
            {
                row = _sortOrder[row];
            }
            StateMod_DiversionRight dr = (StateMod_DiversionRight)_data.get(row);

            // necessary for table models that display rights for 1+ diversions,
            // so that the -1st column (ID) can also be displayed.  By doing it
            // this way, code can be shared between the two kinds of table models
            // and less maintenance is necessary.
            if (!__singleDiversion)
            {
                col--;
            }

            switch (col)
            {
            case COL_DIVERSION_ID:
                return(dr.getCgoto());

            case COL_RIGHT_ID:
                return(dr.getID());

            case COL_RIGHT_NAME:
                return(dr.getName());

            case COL_STRUCT_ID:
                return(dr.getCgoto());

            case COL_ADMIN_NUM:
                return(dr.getIrtem());

            case COL_DCR_AMT:
                return(new double?(dr.getDcrdiv()));

            case COL_ON_OFF:
                return(new int?(dr.getSwitch()));

            default:
                return("");
            }
        }
コード例 #12
0
        /// <summary>
        /// Inserts the specified value into the table at the given position. </summary>
        /// <param name="value"> the object to store in the table cell. </param>
        /// <param name="row"> the row of the cell in which to place the object. </param>
        /// <param name="col"> the column of the cell in which to place the object. </param>
        public virtual void setValueAt(object value, int row, int col)
        {
            if (_sortOrder != null)
            {
                row = _sortOrder[row];
            }
            double dval;
            int    ival;
            int    index;

            // necessary for table models that display rights for 1+ diversions,
            // so that the -1st column (ID) can also be displayed.  By doing it
            // this way, code can be shared between the two kinds of table models
            // and less maintenance is necessary.
            if (!__singleDiversion)
            {
                col--;
            }

            StateMod_DiversionRight dr = (StateMod_DiversionRight)_data.get(row);

            switch (col)
            {
            case COL_DIVERSION_ID:
                dr.setCgoto((string)value);
                break;

            case COL_RIGHT_ID:
                dr.setID((string)value);
                break;

            case COL_RIGHT_NAME:
                dr.setName((string)value);
                break;

            case COL_STRUCT_ID:
                dr.setCgoto((string)value);
                break;

            case COL_ADMIN_NUM:
                dr.setIrtem((string)value);
                break;

            case COL_DCR_AMT:
                dval = ((double?)value).Value;
                dr.setDcrdiv(dval);
                break;

            case COL_ON_OFF:
                if (value is int?)
                {
                    ival = ((int?)value).Value;
                    dr.setSwitch(ival);
                }
                else if (value is string)
                {
                    string onOff = (string)value;
                    index = onOff.IndexOf(" -", StringComparison.Ordinal);
                    ival  = (Convert.ToInt32(onOff.Substring(0, index)));
                    dr.setSwitch(ival);
                }
                break;
            }

            if (!__singleDiversion)
            {
                col++;
            }

            base.setValueAt(value, row, col);
        }
コード例 #13
0
        /// <summary>
        /// Writes a diversion rights file. </summary>
        /// <param name="infile"> the original file </param>
        /// <param name="outfile"> the new file to write </param>
        /// <param name="theRights"> a Vector of StateMod_DiversionRight objects to right </param>
        /// <param name="newComments"> new comments to add to the header </param>
        /// <param name="useOldAdminNumFormat"> whether to use the old admin num format or not </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 writeStateModFile(String infile, String outfile, java.util.List<StateMod_DiversionRight> theRights, java.util.List<String> newComments, boolean useOldAdminNumFormat) throws Exception
        public static void writeStateModFile(string infile, string outfile, IList <StateMod_DiversionRight> theRights, IList <string> newComments, bool useOldAdminNumFormat)
        {
            IList <string> commentIndicators = new List <string>(1);

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

            ignoredCommentIndicators.Add("#>");
            PrintWriter @out    = null;
            string      routine = "StateMod_DiversionRight.writeStateModFile";

            Message.printStatus(2, routine, "Writing diversion rights to: " + outfile);

            try
            {
                @out = IOUtil.processFileHeaders(IOUtil.getPathUsingWorkingDir(infile), IOUtil.getPathUsingWorkingDir(outfile), newComments, commentIndicators, ignoredCommentIndicators, 0);

                string iline;
                string cmnt     = "#>";
                string format_0 = null;
                if (useOldAdminNumFormat)
                {
                    format_0 = "%-12.12s%-24.24s%-12.12s%-12.12s    %8.2F%8d";
                }
                else
                {
                    format_0 = "%-12.12s%-24.24s%-12.12s%16.16s%8.2F%8d";
                }
                StateMod_DiversionRight right = null;
                IList <object>          v     = new List <object>(6);

                // print out the non-permanent header
                @out.println(cmnt);
                @out.println(cmnt + "***************************************************");
                @out.println(cmnt + " StateMod Direct Diversion Rights File");
                @out.println(cmnt);
                @out.println(cmnt + "     format:  (a12, a24, a12, f16.5, f8.2, i8)");
                @out.println(cmnt);
                @out.println(cmnt + "     ID       cidvri:  Diversion right ID ");
                @out.println(cmnt + "     Name      named:  Diversion right name");
                @out.println(cmnt + "     Struct    cgoto:  Direct Diversion Structure ID associated with this right");
                @out.println(cmnt + "     Admin #   irtem:  Administration number");
                @out.println(cmnt + "                       (small is senior).");
                @out.println(cmnt + "     Decree   dcrdiv:  Decreed amount (cfs)");
                @out.println(cmnt + "     On/Off   idvrsw:  Switch 0 = off, 1 = on");
                @out.println(cmnt + "                       YYYY = on for years >= YYYY.");
                @out.println(cmnt + "                       -YYYY = off for years > YYYY.");
                @out.println(cmnt);
                @out.println(cmnt + "   ID            Name              Struct            Admin #   Decree  On/Off");
                @out.println(cmnt + "EndHeader");
                @out.println(cmnt + "---------eb----------------------eb----------eb--------------eb------eb------e");

                int num = 0;
                if (theRights != null)
                {
                    num = theRights.Count;
                }
                for (int i = 0; i < num; i++)
                {
                    right = (StateMod_DiversionRight)theRights[i];
                    if (right == null)
                    {
                        continue;
                    }
                    v.Clear();
                    v.Add(right.getID());
                    v.Add(right.getName());
                    v.Add(right.getCgoto());
                    v.Add(right.getIrtem());
                    v.Add(new double?(right.getDcrdiv()));
                    v.Add(new int?(right.getSwitch()));
                    iline = StringUtil.formatString(v, format_0);
                    @out.println(iline);
                }
            }
            catch (Exception e)
            {
                Message.printWarning(3, routine, e);
                throw e;
            }
            finally
            {
                if (@out != null)
                {
                    @out.flush();
                    @out.close();
                }
            }
        }
コード例 #14
0
        /// <summary>
        /// Writes a list of StateMod_Diversion 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"> comments to add at the top of the file (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_DiversionRight> data, java.util.List<String> newComments) throws Exception
        public static void writeListFile(string filename, string delimiter, bool update, IList <StateMod_DiversionRight> data, IList <string> newComments)
        {
            string routine = "StateMod_DiversionRight.writeListFile";
            int    size    = 0;

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

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

            fields.Add("ID");
            fields.Add("Name");
            fields.Add("StationID");
            fields.Add("AdministrationNumber");
            fields.Add("Decree");
            fields.Add("OnOff");

            int fieldCount = fields.Count;

            string[] names   = new string[fieldCount];
            string[] formats = new string[fieldCount];
            int      comp    = StateMod_DataSet.COMP_DIVERSION_RIGHTS;
            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;
            StateMod_DiversionRight right             = 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();
            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.
                IList <string> newComments2 = null;
                if (newComments == null)
                {
                    newComments2 = new List <string>();
                }
                else
                {
                    newComments2 = new List <string>(newComments);
                }
                newComments2.Insert(0, "");
                newComments2.Insert(1, "StateMod diversion rights 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++)
                {
                    right = data[i];

                    line[0] = StringUtil.formatString(right.getID(), formats[0]).Trim();
                    line[1] = StringUtil.formatString(right.getName(), formats[1]).Trim();
                    line[2] = StringUtil.formatString(right.getCgoto(), formats[2]).Trim();
                    line[3] = StringUtil.formatString(right.getIrtem(), formats[3]).Trim();
                    line[4] = StringUtil.formatString(right.getDcrdiv(), formats[4]).Trim();
                    line[5] = StringUtil.formatString(right.getSwitch(), formats[5]).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();
                }
            }
        }
コード例 #15
0
 /// <summary>
 /// Return a list of on/off switch option strings, for use in GUIs.
 /// The options are of the form "0" if include_notes is false and "0 - Off", if include_notes is true. </summary>
 /// <returns> a list of on/off switch option strings, for use in GUIs. </returns>
 /// <param name="include_notes"> Indicate whether notes should be added after the parameter values. </param>
 public static IList <string> getIrsrswChoices(bool include_notes)
 {
     return(StateMod_DiversionRight.getIdvrswChoices(include_notes));
 }
コード例 #16
0
 /// <summary>
 /// Return the default on/off switch choice.  This can be used by GUI code
 /// to pick a default for a new reservoir. </summary>
 /// <returns> the default reservoir on/off choice. </returns>
 public static string getIrsrswDefault(bool include_notes)
 {
     return(StateMod_DiversionRight.getIdvrswDefault(include_notes));
 }
コード例 #17
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void saveComponent(RTi.Util.IO.DataSetComponent comp, String oldFilename,String newFilename, java.util.List<String> comments) throws Exception
        private void saveComponent(DataSetComponent comp, string oldFilename, string newFilename, IList <string> comments)
        {
            bool   daily = false;
            int    type  = comp.getComponentType();
            object data  = comp.getData();
            string name  = null;

            switch (type)
            {
            ////////////////////////////////////////////////////////
            // StateMod_* classes
            case StateMod_DataSet.COMP_CONTROL:
                StateMod_DataSet.writeStateModControlFile(__dataset, oldFilename, newFilename, comments);
                name = "Control";
                break;

            case StateMod_DataSet.COMP_DELAY_TABLES_DAILY:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DelayTable> delayTablesDaily = (java.util.List<StateMod_DelayTable>)data;
                IList <StateMod_DelayTable> delayTablesDaily = (IList <StateMod_DelayTable>)data;
                StateMod_DelayTable.writeStateModFile(oldFilename, newFilename, delayTablesDaily, comments, __dataset.getInterv(), -1);
                name = "Delay Tables Daily";
                break;

            case StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DelayTable> delayTablesMonthly = (java.util.List<StateMod_DelayTable>)data;
                IList <StateMod_DelayTable> delayTablesMonthly = (IList <StateMod_DelayTable>)data;
                StateMod_DelayTable.writeStateModFile(oldFilename, newFilename, delayTablesMonthly, comments, __dataset.getInterv(), -1);
                name = "Delay Tables Monthly";
                break;

            case StateMod_DataSet.COMP_DIVERSION_STATIONS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Diversion> diversionStations = (java.util.List<StateMod_Diversion>)data;
                IList <StateMod_Diversion> diversionStations = (IList <StateMod_Diversion>)data;
                StateMod_Diversion.writeStateModFile(oldFilename, newFilename, diversionStations, comments, daily);
                name = "Diversion";
                break;

            case StateMod_DataSet.COMP_DIVERSION_RIGHTS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DiversionRight> diversionRights = (java.util.List<StateMod_DiversionRight>)data;
                IList <StateMod_DiversionRight> diversionRights = (IList <StateMod_DiversionRight>)data;
                StateMod_DiversionRight.writeStateModFile(oldFilename, newFilename, diversionRights, comments, daily);
                name = "Diversion Rights";
                break;

            case StateMod_DataSet.COMP_INSTREAM_STATIONS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_InstreamFlow> instreamFlow = (java.util.List<StateMod_InstreamFlow>)data;
                IList <StateMod_InstreamFlow> instreamFlow = (IList <StateMod_InstreamFlow>)data;
                StateMod_InstreamFlow.writeStateModFile(oldFilename, newFilename, instreamFlow, comments, daily);
                name = "Instream";
                break;

            case StateMod_DataSet.COMP_INSTREAM_RIGHTS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_InstreamFlowRight> instreamFlowRights = (java.util.List<StateMod_InstreamFlowRight>)data;
                IList <StateMod_InstreamFlowRight> instreamFlowRights = (IList <StateMod_InstreamFlowRight>)data;
                StateMod_InstreamFlowRight.writeStateModFile(oldFilename, newFilename, instreamFlowRights, comments);
                name = "Instream Rights";
                break;

            case StateMod_DataSet.COMP_OPERATION_RIGHTS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_OperationalRight> operationalRights = (java.util.List<StateMod_OperationalRight>)data;
                IList <StateMod_OperationalRight> operationalRights = (IList <StateMod_OperationalRight>)data;
                // 2 is the file version (introduced for StateMod version 12 change)
                StateMod_OperationalRight.writeStateModFile(oldFilename, newFilename, 2, operationalRights, comments, __dataset);
                name = "Operational Rights";
                break;

            case StateMod_DataSet.COMP_PLANS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Plan> planStations = (java.util.List<StateMod_Plan>)data;
                IList <StateMod_Plan> planStations = (IList <StateMod_Plan>)data;
                StateMod_Plan.writeStateModFile(oldFilename, newFilename, planStations, comments);
                name = "Plan";
                break;

            case StateMod_DataSet.COMP_RESERVOIR_STATIONS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Reservoir> reservoirStations = (java.util.List<StateMod_Reservoir>)data;
                IList <StateMod_Reservoir> reservoirStations = (IList <StateMod_Reservoir>)data;
                StateMod_Reservoir.writeStateModFile(oldFilename, newFilename, reservoirStations, comments, daily);
                name = "Reservoir";
                break;

            case StateMod_DataSet.COMP_RESERVOIR_RIGHTS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_ReservoirRight> reservoirRights = (java.util.List<StateMod_ReservoirRight>)data;
                IList <StateMod_ReservoirRight> reservoirRights = (IList <StateMod_ReservoirRight>)data;
                StateMod_ReservoirRight.writeStateModFile(oldFilename, newFilename, reservoirRights, comments);
                name = "Reservoir Rights";
                break;

            case StateMod_DataSet.COMP_RESPONSE:
                StateMod_DataSet.writeStateModFile(__dataset, oldFilename, newFilename, comments);
                name = "Response";
                break;

            case StateMod_DataSet.COMP_RIVER_NETWORK:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_RiverNetworkNode> riverNodes = (java.util.List<StateMod_RiverNetworkNode>)data;
                IList <StateMod_RiverNetworkNode> riverNodes = (IList <StateMod_RiverNetworkNode>)data;
                StateMod_RiverNetworkNode.writeStateModFile(oldFilename, newFilename, riverNodes, comments, true);
                name = "River Network";
                break;

            case StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_StreamEstimate> streamEstimateStations = (java.util.List<StateMod_StreamEstimate>)data;
                IList <StateMod_StreamEstimate> streamEstimateStations = (IList <StateMod_StreamEstimate>)data;
                StateMod_StreamEstimate.writeStateModFile(oldFilename, newFilename, streamEstimateStations, comments, daily);
                name = "Stream Estimate";
                break;

            case StateMod_DataSet.COMP_STREAMESTIMATE_COEFFICIENTS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_StreamEstimate_Coefficients> streamEstimateCoefficients = (java.util.List<StateMod_StreamEstimate_Coefficients>)data;
                IList <StateMod_StreamEstimate_Coefficients> streamEstimateCoefficients = (IList <StateMod_StreamEstimate_Coefficients>)data;
                StateMod_StreamEstimate_Coefficients.writeStateModFile(oldFilename, newFilename, streamEstimateCoefficients, comments);
                name = "Stream Estimate Coefficients";
                break;

            case StateMod_DataSet.COMP_STREAMGAGE_STATIONS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_StreamGage> streamGageStations = (java.util.List<StateMod_StreamGage>)data;
                IList <StateMod_StreamGage> streamGageStations = (IList <StateMod_StreamGage>)data;
                StateMod_StreamGage.writeStateModFile(oldFilename, newFilename, streamGageStations, comments, daily);
                name = "Streamgage Stations";
                break;

            case StateMod_DataSet.COMP_WELL_STATIONS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Well> wellStations = (java.util.List<StateMod_Well>)data;
                IList <StateMod_Well> wellStations = (IList <StateMod_Well>)data;
                StateMod_Well.writeStateModFile(oldFilename, newFilename, wellStations, comments);
                name = "Well";
                break;

            case StateMod_DataSet.COMP_WELL_RIGHTS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_WellRight> wellRights = (java.util.List<StateMod_WellRight>)data;
                IList <StateMod_WellRight> wellRights = (IList <StateMod_WellRight>)data;
                StateMod_WellRight.writeStateModFile(oldFilename, newFilename, wellRights, comments, (PropList)null);
                name = "Well Rights";
                break;

            //////////////////////////////////////////////////////
            // StateMod Time Series
            case StateMod_DataSet.COMP_CONSUMPTIVE_WATER_REQUIREMENT_TS_DAILY:
            case StateMod_DataSet.COMP_CONSUMPTIVE_WATER_REQUIREMENT_TS_MONTHLY:
            case StateMod_DataSet.COMP_DEMAND_TS_DAILY:
            case StateMod_DataSet.COMP_DEMAND_TS_AVERAGE_MONTHLY:
            case StateMod_DataSet.COMP_DEMAND_TS_MONTHLY:
            case StateMod_DataSet.COMP_DEMAND_TS_OVERRIDE_MONTHLY:
            case StateMod_DataSet.COMP_DIVERSION_TS_DAILY:
            case StateMod_DataSet.COMP_DIVERSION_TS_MONTHLY:
            case StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY:
            case StateMod_DataSet.COMP_INSTREAM_DEMAND_TS_AVERAGE_MONTHLY:
            case StateMod_DataSet.COMP_INSTREAM_DEMAND_TS_DAILY:
            case StateMod_DataSet.COMP_INSTREAM_DEMAND_TS_MONTHLY:
            case StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY:
            case StateMod_DataSet.COMP_RESERVOIR_CONTENT_TS_DAILY:
            case StateMod_DataSet.COMP_RESERVOIR_CONTENT_TS_MONTHLY:
            case StateMod_DataSet.COMP_RESERVOIR_TARGET_TS_DAILY:
            case StateMod_DataSet.COMP_RESERVOIR_TARGET_TS_MONTHLY:
            case StateMod_DataSet.COMP_STREAMESTIMATE_NATURAL_FLOW_TS_DAILY:
            case StateMod_DataSet.COMP_STREAMESTIMATE_NATURAL_FLOW_TS_MONTHLY:
            case StateMod_DataSet.COMP_STREAMGAGE_NATURAL_FLOW_TS_DAILY:
            case StateMod_DataSet.COMP_STREAMGAGE_NATURAL_FLOW_TS_MONTHLY:
            case StateMod_DataSet.COMP_STREAMGAGE_HISTORICAL_TS_DAILY:
            case StateMod_DataSet.COMP_STREAMGAGE_HISTORICAL_TS_MONTHLY:
            case StateMod_DataSet.COMP_WELL_DEMAND_TS_DAILY:
            case StateMod_DataSet.COMP_WELL_DEMAND_TS_MONTHLY:
            case StateMod_DataSet.COMP_WELL_PUMPING_TS_DAILY:
            case StateMod_DataSet.COMP_WELL_PUMPING_TS_MONTHLY:
                double   missing  = -999.0;
                YearType yearType = null;
                if (__dataset.getCyrl() == YearType.CALENDAR)
                {
                    yearType = YearType.CALENDAR;
                }
                else if (__dataset.getCyrl() == YearType.WATER)
                {
                    yearType = YearType.WATER;
                }
                else if (__dataset.getCyrl() == YearType.NOV_TO_OCT)
                {
                    yearType = YearType.NOV_TO_OCT;
                }
                int precision = 2;

                // Do the following to avoid warnings
                IList <TS> tslist = null;
                if (data != null)
                {
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<RTi.TS.TS> tslist0 = (java.util.List<RTi.TS.TS>)data;
                    IList <TS> tslist0 = (IList <TS>)data;
                    if (tslist0.Count > 0)
                    {
                        TS ts = tslist0[0];
                        missing = ts.getMissing();
                    }
                    tslist = tslist0;
                }

                StateMod_TS.writeTimeSeriesList(oldFilename, newFilename, comments, tslist, null, null, yearType, missing, precision);
                name = "TS (" + type + ")";
                break;

            default:
                name = "(something: " + type + ")";
                break;
            }
            comp.setDirty(false);
            Message.printStatus(1, "", "Component '" + name + "' written");
        }
コード例 #18
0
        /// <summary>
        /// Checks the data to make sure that all the data are valid. </summary>
        /// <returns> 0 if the data are valid, 1 if errors exist and -1 if non-fatal errors
        /// exist. </returns>
        private int checkInput()
        {
            string routine = "StateMod_Diversion_Right_JFrame.checkInput";

            System.Collections.IList v = __worksheet.getAllData();

            int size = v.Count;
            StateMod_DiversionRight right = null;
            string warning = "";
            string id;
            string name;
            string divID;
            string adminNum;
            int    fatalCount = 0;

            for (int i = 0; i < size; i++)
            {
                right = (StateMod_DiversionRight)(v[i]);

                id       = right.getID();
                name     = right.getName();
                divID    = right.getCgoto();
                adminNum = right.getIrtem();

                if (id.Length > 12)
                {
                    warning += "\nDiversion right ID (" + id + ") is "
                               + "longer than 12 characters.";
                    fatalCount++;
                }

                if (id.IndexOf(" ", StringComparison.Ordinal) > -1 || id.IndexOf("-", StringComparison.Ordinal) > -1)
                {
                    warning += "\nDiversion right ID (" + id + ") cannot "
                               + "contain spaces or dashes.";
                    fatalCount++;
                }

                if (name.Length > 24)
                {
                    warning += "\nDiversion name (" + name + ") is "
                               + "longer than 24 characters.";
                    fatalCount++;
                }

                if (divID.Length > 12)
                {
                    warning += "\nDiversion ID associated with right ("
                               + divID + ") is longer than 12 characters.";
                }

                if (!StringUtil.isDouble(adminNum))
                {
                    warning += "\nAdministration number (" + adminNum + ") is not a number.";
                    fatalCount++;
                }

                // decreed amount is not checked to be a double because that
                // is enforced by the worksheet and its table model

                // on/off is not checked to be an integer because that is
                // enforced by the worksheet and its table model
            }
            // REVISIT - if daily time series are supplied, check for time series
            // and allow creation if not available.
            if (warning.Length > 0)
            {
                warning += "\nCorrect or Cancel.";
                Message.printWarning(1, routine, warning, this);
                if (fatalCount > 0)
                {
                    // Fatal errors...
                    Message.printStatus(1, routine, "Returning 1 from checkInput()");
                    return(1);
                }
                else
                {         // Nonfatal errors...
                    Message.printStatus(1, routine, "Returning -1 from checkInput()");
                    return(-1);
                }
            }
            else
            {     // No errors...
                Message.printStatus(1, routine, "Returning 0 from checkInput()");
                return(0);
            }
        }
コード例 #19
0
        /// <summary>
        /// Saves the input back into the dataset. </summary>
        /// <returns> true if the data was saved successfuly.  False if not. </returns>
        private bool saveData()
        {
            string routine = "StateMod_Diversion_Right_JFrame.saveData";

            if (!__worksheet.stopEditing())
            {
                // don't save if there are errors.
                Message.printWarning(1, routine, "There are errors in the data " + "that must be corrected before data can be saved.", this);
                return(false);
            }

            if (checkInput() > 0)
            {
                return(false);
            }

            // now only save data if any are different.
            bool needToSave = false;

            // if the Vectors are differently-sized, they're different
            System.Collections.IList wv = __worksheet.getAllData();     // w for worksheet
            System.Collections.IList dv = __currentDiv.getRights();     // d for diversion

            needToSave = !(StateMod_DiversionRight.Equals(wv, dv));

            Message.printStatus(1, routine, "Saving? .........[" + needToSave + "]");

            if (!needToSave)
            {
                // there's nothing different -- users may even have deleted
                // some rights and added back in identical values
                return(true);
            }

            // at this point, remove the old diversion rights from the original
            // component Vector
            System.Collections.IList diversionRights = (System.Collections.IList)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DIVERSION_RIGHTS)).getData();
            int size = dv.Count;
            StateMod_DiversionRight dr;

            for (int i = 0; i < size; i++)
            {
                dr = (StateMod_DiversionRight)dv[i];
                StateMod_Util.removeFromVector(diversionRights, dr);
            }

            // now add the elements from the new Vector to the diversionRights
            // Vector.
            size = wv.Count;
            StateMod_DiversionRight cdr = null;

            for (int i = 0; i < size; i++)
            {
                dr           = (StateMod_DiversionRight)wv[i];
                cdr          = (StateMod_DiversionRight)dr.clone();
                cdr._isClone = false;
                diversionRights.Add(cdr);
            }

            // sort the diversionRights Vector
            // REVISIT (JTS - 2003-10-10)
            // here we are sorting the full data array -- may be a performance
            // issue
            System.Collections.IList sorted = StateMod_Util.sortStateMod_DataVector(diversionRights);
            __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DIVERSION_RIGHTS).setData(sorted);
            __currentDiv.disconnectRights();
            __currentDiv.connectRights(sorted);
            __dataset.setDirty(StateMod_DataSet.COMP_DIVERSION_RIGHTS, true);
            return(true);
        }
コード例 #20
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_Diversion_Right_JFrame::actionPerformed";

            string action = e.getActionCommand();

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

                if (last == null)
                {
                    aRight.setID(StateMod_Util.createNewID(__currentDiv.getID()));
                    aRight.setCgoto(__currentDiv.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 Diversion Right", "Delete diversion 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_CLOSE))
            {
                if (saveData())
                {
                    setVisible(false);
                    dispose();
                }
            }
            else if (action.Equals(__BUTTON_APPLY))
            {
                saveData();
            }
            else if (action.Equals(__BUTTON_CANCEL))
            {
                setVisible(false);
                dispose();
            }
            else if (action.Equals(__BUTTON_HELP))
            {
                // REVISIT (JTS - 2003-06-10)
            }
        }