/// <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_Plan_WellAugmentation wellAug = (StateMod_Plan_WellAugmentation)_data.get(row);

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

            case COL_WELL_RIGHT_ID:
                wellAug.setCistatW((string)value);
                break;

            case COL_WELL_STRUCTURE_ID:
                wellAug.setCistatS((string)value);
                break;

            case COL_COMMENT:
                wellAug.setComment((string)value);
                break;
            }
            base.setValueAt(value, row, col);
        }
        /// <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. </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_Plan_WellAugmentation wellAug = (StateMod_Plan_WellAugmentation)_data.get(row);

            switch (col)
            {
            case COL_PLAN_ID:
                return(wellAug.getID());

            case COL_WELL_RIGHT_ID:
                return(wellAug.getCistatW());

            case COL_WELL_STRUCTURE_ID:
                return(wellAug.getCistatS());

            case COL_COMMENT:
                return(wellAug.getComment());

            default:
                return("");
            }

            /*
             * if (!__showTotals) {
             *      row = ((Integer)__rowMap.get(row)).intValue();
             * }
             * return __data[col].get(row);
             */
        }
Exemplo n.º 3
0
        /// <summary>
        /// Clones the data object. </summary>
        /// <returns> a cloned object. </returns>
        public override object clone()
        {
            StateMod_Plan_WellAugmentation rf = (StateMod_Plan_WellAugmentation)base.clone();

            rf._isClone = true;

            return(rf);
        }
Exemplo n.º 4
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_Plan_WellAugmentation rf = (StateMod_Plan_WellAugmentation)_original;

            base.restoreOriginal();

            __cistatW = rf.__cistatW;
            __cistatS = rf.__cistatS;
            _isClone  = false;
            _original = null;
        }
        /// <summary>
        /// Called when the cancel button is pressed.  This discards any changes made to the data objects.
        /// </summary>
        protected internal override void cancel()
        {
            StateMod_Plan_WellAugmentation wellAug = null;
            int size = _data.Count;

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

            for (int i = 0; i < size; i++)
            {
                wellAug = (StateMod_Plan_WellAugmentation)_data[i];
                wellAug.createBackup();
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Compares this object to another object based on the well structure ID and well right ID. </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_Plan_WellAugmentation rf = (StateMod_Plan_WellAugmentation)data;

            // Strip off trailing "- name" - may be present if comparing in UI

            string cistatS = __cistatS;
            int    index   = cistatS.IndexOf(" - ", StringComparison.Ordinal);

            if (index > 0)
            {
                cistatS = cistatS.Substring(0, index).Trim();
            }

            string cistatS2 = rf.__cistatS;

            index = cistatS2.IndexOf(" - ", StringComparison.Ordinal);
            if (index > 0)
            {
                cistatS2 = cistatS2.Substring(0, index).Trim();
            }

            res = cistatS.CompareTo(cistatS2);
            if (res != 0)
            {
                return(res);
            }

            string cistatW = __cistatW;

            index = cistatW.IndexOf(" - ", StringComparison.Ordinal);
            if (index > 0)
            {
                cistatW = cistatW.Substring(0, index).Trim();
            }

            string cistatW2 = rf.__cistatW;

            index = cistatW2.IndexOf(" - ", StringComparison.Ordinal);
            if (index > 0)
            {
                cistatW2 = cistatW2.Substring(0, index).Trim();
            }

            return(cistatW.CompareTo(cistatW2));
        }
Exemplo n.º 8
0
 /// <summary>
 /// Tests to see if two return flows are equal.  Strings are compared with case sensitivity. </summary>
 /// <param name="rf"> the return flow to compare. </param>
 /// <returns> true if they are equal, false otherwise. </returns>
 public virtual bool Equals(StateMod_Plan_WellAugmentation rf)
 {
     if (!base.Equals(rf))
     {
         return(false);
     }
     if (rf.__cistatW.Equals(__cistatW) && rf.__cistatS.Equals(__cistatS))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 9
0
        /// <summary>
        /// Write well augmentation data to a StateMod file.  History header information
        /// is also maintained by calling this routine. </summary>
        /// <param name="instrfile"> input file from which previous history should be taken </param>
        /// <param name="outstrfile"> output file to which to write </param>
        /// <param name="wellAugList"> list of plans to write. </param>
        /// <param name="newComments"> addition comments which should be included in history </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 instrfile, String outstrfile, java.util.List<StateMod_Plan_WellAugmentation> wellAugList, java.util.List<String> newComments) throws Exception
        public static void writeStateModFile(string instrfile, string outstrfile, IList <StateMod_Plan_WellAugmentation> wellAugList, IList <string> newComments)
        {
            string         routine           = "StateMod_Plan_WellAugmentation.writeStateModFile";
            IList <string> commentIndicators = new List <string>(1);

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

            ignoredCommentIndicators.Add("#>");
            PrintWriter @out = null;
            string      comment;

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

                int    i;
                string iline;
                string cmnt = "#>";
                // This format follows historical conventions found in example files, limited by StateMod ID lengths
                string formatLine1 = "%-12.12s %-12.12s %-12.12s"; // Comment only written if not blank
                StateMod_Plan_WellAugmentation wellAug = null;
                IList <object> v = new List <object>(11);          // Reuse for all output lines.

                @out.println(cmnt);
                @out.println(cmnt + "*************************************************");
                @out.println(cmnt + "  StateMod Well Augmentation Plan Data");
                @out.println(cmnt);
                @out.println(cmnt + "  Free format; however historical format based on StateMod");
                @out.println(cmnt + "               identifier string lengths is used for consistency.");
                @out.println(cmnt);
                @out.println(cmnt + "  Plan ID      cistatP :  Plan identifier");
                @out.println(cmnt + "  WellRightID  cistatW :  Well right identifier");
                @out.println(cmnt + "  Well ID      cistatS :  Well (structure) identifier");
                @out.println(cmnt + "  Comment              :  Optional comments");
                @out.println(cmnt + "                          Double quote to faciliate free-format processing.");
                @out.println(cmnt);
                @out.println(cmnt + " Plan ID    WellRightID    Well ID        Comment");
                @out.println(cmnt + "---------exb----------exb----------exb-------------------------------e");
                @out.println(cmnt + "EndHeader");

                int num = 0;
                if (wellAugList != null)
                {
                    num = wellAugList.Count;
                }
                for (i = 0; i < num; i++)
                {
                    wellAug = wellAugList[i];
                    if (wellAug == null)
                    {
                        continue;
                    }

                    // line 1
                    v.Clear();
                    v.Add(wellAug.getID());
                    v.Add(wellAug.getCistatW());
                    v.Add(wellAug.getCistatS());
                    comment = wellAug.getComment().Trim();
                    if (comment.Length > 0)
                    {
                        comment = " \"" + comment + "\"";
                    }
                    iline = StringUtil.formatString(v, formatLine1) + comment;
                    @out.println(iline);
                }
            }
            catch (Exception e)
            {
                Message.printWarning(3, routine, e);
                throw e;
            }
            finally
            {
                if (@out != null)
                {
                    @out.flush();
                    @out.close();
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Writes a list of StateMod_Plan_WellAugmentation 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_Plan_WellAugmentation> data, int componentType, java.util.List<String> newComments) throws Exception
        public static void writeListFile(string filename, string delimiter, bool update, IList <StateMod_Plan_WellAugmentation> data, int componentType, IList <string> newComments)
        {
            int size = 0;

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

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

            fields.Add("PlanID");
            fields.Add("WellRightID");
            fields.Add("WellStructureID");
            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_Plan_WellAugmentation wellAug = 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, "");
                newComments2.Insert(1, "StateMod well augmentation plan data file.");
                newComments2.Insert(2, "See also the associated plan station file.");
                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++)
                {
                    wellAug = data[i];

                    line[0] = StringUtil.formatString(wellAug.getID(), formats[0]).Trim();
                    line[1] = StringUtil.formatString(wellAug.getCistatW(), formats[1]).Trim();
                    line[2] = StringUtil.formatString(wellAug.getCistatS(), formats[2]).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());
                }
                @out.flush();
                @out.close();
            }
            finally
            {
                if (@out != null)
                {
                    @out.flush();
                    @out.close();
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Read return information in and store in a list. </summary>
        /// <param name="filename"> filename for data file to read </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_Plan_WellAugmentation> readStateModFile(String filename) throws Exception
        public static IList <StateMod_Plan_WellAugmentation> readStateModFile(string filename)
        {
            string         routine = "StateMod_Plan_WellAugmentation.readStateModFile";
            string         iline   = null;
            IList <string> v       = new List <string>(9);
            IList <StateMod_Plan_WellAugmentation> theWellAugs = new List <StateMod_Plan_WellAugmentation>();
            int linecount = 0;

            StateMod_Plan_WellAugmentation aWellAug = null;
            StreamReader @in = null;

            Message.printStatus(2, routine, "Reading well augmentation plan 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 < 3)
                    {
                        Message.printStatus(2, routine, "Ignoring line " + linecount + " not enough data values.  Have " + size + " expecting 3");
                        ++errorCount;
                        continue;
                    }
                    // Uncomment if testing...
                    //Message.printStatus ( 2, routine, "" + v );

                    // Allocate new plan node and set the values
                    aWellAug = new StateMod_Plan_WellAugmentation();
                    aWellAug.setID(v[0].Trim());
                    aWellAug.setName(v[0].Trim());             // Same as ID
                    aWellAug.setCistatW(v[1].Trim());
                    aWellAug.setCistatS(v[2].Trim());
                    if (v.Count > 3)
                    {
                        aWellAug.setComment(v[3].Trim());
                    }

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

                    aWellAug.setDirty(false);

                    // Add the return to the list of returns
                    theWellAugs.Add(aWellAug);
                }
            }
            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(theWellAugs);
        }