/// <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];
            }
            double dval;
            int    ival;
            StateMod_InstreamFlowRight ifr = (StateMod_InstreamFlowRight)_data.get(row);

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

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

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

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

            case COL_DCR_AMT:
                dval = ((double?)value).Value;
                ifr.setDcrifr(dval);
                break;

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

                /*
                 * ival = ((Integer)value).intValue();
                 * ifr.setSwitch(ival);
                 * break;
                 */
                break;
            }

            base.setValueAt(value, row, col);
        }
Example #2
0
        /// <summary>
        /// Read instream flow rights information in and store in a list. </summary>
        /// <param name="filename"> Name of file to read. </param>
        /// <exception cref="Exception"> if there is an error reading the file. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static java.util.List<StateMod_InstreamFlowRight> readStateModFile(String filename) throws Exception
        public static IList <StateMod_InstreamFlowRight> readStateModFile(string filename)
        {
            string routine = "StateMod_InstreamFlowRight.readStateModFile";
            IList <StateMod_InstreamFlowRight> theInsfRights = new List <StateMod_InstreamFlowRight>();

            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;
            StateMod_InstreamFlowRight aRight = null;
            IList <object>             v      = new List <object>(6);

            Message.printStatus(1, routine, "Reading Instream Flow Rights File: " + filename);
            StreamReader @in = null;

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

                    aRight = new StateMod_InstreamFlowRight();

                    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.setDcrifr((double?)v[4]);
                    aRight.setSwitch((int?)v[5]);

                    theInsfRights.Add(aRight);
                }
            }
            catch (Exception e)
            {
                Message.printWarning(3, routine, e);
                throw e;
            }
            finally
            {
                if (@in != null)
                {
                    @in.Close();
                }
            }
            return(theInsfRights);
        }
Example #3
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_InstreamFlow_Right_JFrame.actionPerformed";

            string action = e.getActionCommand();

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

                if (last == null)
                {
                    aRight.setID(StateMod_Util.createNewID(__currentInstreamFlow.getID()));
                    aRight.setCgoto(__currentInstreamFlow.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 instream flow 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 selected 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();
            }
        }