/// <summary>
        /// Sets up the data to be displayed in the table. </summary>
        /// <param name="data"> a Vector of StateMod_DelayTable objects from which the data to b
        /// be displayed in the table will be gathered. </param>

        /*
         * private void setupData(List data) {
         *      int num = 0;
         *      int size = data.size();
         *      StateMod_DelayTable dt = null;
         *      String id = null;
         *      __data = new List[__COLUMNS];
         *      for (int i = 0; i < __COLUMNS; i++) {
         *              __data[i] = new Vector();
         *      }
         *
         *      __rowMap = new Vector();
         *
         *      double total = 0;
         *      int rowCount = 0;
         *      for (int i = 0; i < size; i++) {
         *              total = 0;
         *              dt = (StateMod_DelayTable)data.get(i);
         *              id = dt.getID();
         *              num = dt.getNdly();
         *              for (int j = 0; j < num; j++) {
         *                      __data[COL_PLAN_ID].add(id);
         *                      __data[COL_RIVER_NODE_ID].add(new Integer(j + 1));
         *                      __data[COL_PERCENT_RETURN].add( new Double(dt.getRet_val(j)));
         *                      total += dt.getRet_val(j);
         *                      __rowMap.add(new Integer(rowCount));
         *                      rowCount++;
         *              }
         *
         *              __data[COL_PLAN_ID].add("TOTAL " + id);
         *              __data[COL_RIVER_NODE_ID].add(new Integer(-999));
         *              __data[COL_PERCENT_RETURN].add(new Double(total));
         *
         *              rowCount++;
         *      }
         *      _rows = rowCount;
         * }
         */

        /// <summary>
        /// Sets the value at the specified position to the specified value. </summary>
        /// <param name="value"> the value to set the cell to. </param>
        /// <param name="row"> the row of the cell for which to set the value. </param>
        /// <param name="col"> the col of the cell for which to set the value. </param>
        public virtual void setValueAt(object value, int row, int col)
        {
            if (_sortOrder != null)
            {
                row = _sortOrder[row];
            }

            StateMod_ReturnFlow rf = (StateMod_ReturnFlow)_data.get(row);

            switch (col)
            {
            case COL_PLAN_ID:
                rf.setID((string)value);
                break;

            case COL_RIVER_NODE_ID:
                rf.setCrtnid((string)value);
                break;

            case COL_PERCENT_RETURN:
                rf.setPcttot((double?)value);
                break;

            case COL_DELAY_TABLE_ID:
                rf.setIrtndl((string)value);
                break;

            case COL_COMMENT:
                rf.setComment((string)value);
                break;
            }
            base.setValueAt(value, row, col);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Read return information in and store in a list. </summary>
        /// <param name="filename"> filename containing return flow information </param>
        /// <param name="smdataCompType"> the StateMod_DataSet component type, passed to the constructor of StateMod_ReturnFlow
        /// objects. </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 java.util.List<StateMod_ReturnFlow> readStateModFile(String filename, int smdataCompType) throws Exception
        public static IList <StateMod_ReturnFlow> readStateModFile(string filename, int smdataCompType)
        {
            string         routine = "StateMod_ReturnFlow.readStateModFile";
            string         iline   = null;
            IList <string> v;
            IList <StateMod_ReturnFlow> theReturns = new List <StateMod_ReturnFlow>();
            int linecount = 0;

            StateMod_ReturnFlow aReturn = null;
            StreamReader        @in     = null;

            Message.printStatus(2, routine, "Reading return file: " + filename);
            int size       = 0;
            int errorCount = 0;

            try
            {
                @in = new StreamReader(IOUtil.getPathUsingWorkingDir(filename));
                while (!string.ReferenceEquals((iline = @in.ReadLine()), null))
                {
                    ++linecount;
                    // check for comments
                    if (iline.StartsWith("#", StringComparison.Ordinal) || (iline.Trim().Length == 0))
                    {
                        // Special dynamic header comments written by software and blank lines - no need to keep
                        continue;
                    }
                    if (Message.isDebugOn)
                    {
                        Message.printDebug(50, routine, "line: " + iline);
                    }
                    // Break the line using whitespace, while allowing for quoted strings...
                    v    = StringUtil.breakStringList(iline, " \t", StringUtil.DELIM_ALLOW_STRINGS | StringUtil.DELIM_SKIP_BLANKS);
                    size = 0;
                    if (v != null)
                    {
                        size = v.Count;
                    }
                    if (size < 4)
                    {
                        Message.printStatus(2, routine, "Ignoring line " + linecount + " not enough data values.  Have " + size + " expecting 4+");
                        ++errorCount;
                        continue;
                    }
                    // Uncomment if testing...
                    //Message.printStatus ( 2, routine, "" + v );

                    // Allocate new plan node and set the values
                    aReturn = new StateMod_ReturnFlow(smdataCompType);
                    aReturn.setID(v[0].Trim());
                    aReturn.setName(v[0].Trim());             // Same as ID
                    aReturn.setCrtnid(v[1].Trim());
                    aReturn.setCgoto(v[1].Trim());            // Redundant
                    aReturn.setPcttot(v[2].Trim());
                    aReturn.setIrtndl(v[3].Trim());
                    if (v.Count > 4)
                    {
                        aReturn.setComment(v[4].Trim());
                    }

                    // Set the return to not dirty because it was just initialized...

                    aReturn.setDirty(false);

                    // Add the return to the list of returns
                    theReturns.Add(aReturn);
                }
            }
            catch (Exception e)
            {
                Message.printWarning(3, routine, "Error reading line " + linecount + " \"" + iline + "\" uniquetempvar.");
                Message.printWarning(3, routine, e);
                throw e;
            }
            finally
            {
                if (@in != null)
                {
                    @in.Close();
                }
            }
            if (errorCount > 0)
            {
                throw new Exception("There were " + errorCount + " errors processing the data - refer to log file.");
            }
            return(theReturns);
        }