示例#1
0
        /// <summary>
        /// Constructor. </summary>
        /// <param name="data"> the data to display in the worksheet.  Can be null or empty, in
        /// which case an empty worksheet is shown. </param>
        /// <param name="titleString"> the String to display as the GUI title. </param>
        /// <param name="editable"> whether the data in the JFrame can be edited or not.  If true
        /// the data can be edited, if false they can not. </param>
        /// <exception cref="Exception"> if there is an error building the worksheet. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public StateMod_ReservoirAccount_Data_JFrame(java.util.List data, String titleString, boolean editable) throws Exception
        public StateMod_ReservoirAccount_Data_JFrame(System.Collections.IList data, string titleString, bool editable) : base()
        {
            int j     = 0;
            int size  = 0;
            int size2 = 0;
            StateMod_Reservoir        r = null;
            StateMod_ReservoirAccount a = null;

            System.Collections.IList accounts = null;
            System.Collections.IList v        = new List <object>();

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

            for (int i = 0; i < size; i++)
            {
                r        = (StateMod_Reservoir)data[i];
                accounts = r.getAccounts();
                if (accounts == null)
                {
                    continue;
                }

                size2 = accounts.Count;

                for (j = 0; j < size2; j++)
                {
                    a = (StateMod_ReservoirAccount)accounts[j];
                    a.setCgoto(r.getID());
                    v.Add(a);
                }
            }

            initialize(v, titleString, editable);
            setSize(691, getHeight());
        }
        /// <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_ReservoirAccount rac = (StateMod_ReservoirAccount)_data.get(row);

            // necessary for table models that display accounts for 1+ reservoirs,
            // 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 (!__singleReservoir)
            {
                col--;
            }

            switch (col)
            {
            case COL_RESERVOIR_ID:
                rac.setCgoto((string)value);
                break;

            case COL_OWNER_ID:
                rac.setID((string)value);
                break;

            case COL_OWNER_ACCOUNT:
                rac.setName((string)value);
                break;

            case COL_MAX_STORAGE:
                dval = ((double?)value).Value;
                rac.setOwnmax(dval);
                break;

            case COL_INITIAL_STORAGE:
                dval = ((double?)value).Value;
                rac.setCurown(dval);
                break;

            case COL_PRORATE_EVAP:
                if (value is double?)
                {
                    dval = ((double?)value).Value;
                    rac.setPcteva(dval);
                }
                else if (value is string)
                {
                    int    index = ((string)value).IndexOf(" -", StringComparison.Ordinal);
                    string s     = ((string)value).Substring(0, index);
                    dval = (Convert.ToDouble(s));
                    rac.setPcteva(dval);
                }
                break;

            case COL_OWNERSHIP_TIE:
                if (value is int?)
                {
                    ival = ((int?)value).Value;
                    rac.setN2own(ival);
                }
                else if (value is string)
                {
                    string n2owns = (string)value;
                    int    index  = n2owns.IndexOf(" -", StringComparison.Ordinal);
                    ival = (Convert.ToInt32(n2owns.Substring(0, index)));
                    rac.setN2own(ival);
                }
                break;
            }

            if (!__singleReservoir)
            {
                col++;
            }

            base.setValueAt(value, row, col);
        }
        /// <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_ReservoirAccount rac = (StateMod_ReservoirAccount)_data.get(row);

            switch (col)
            {
            case COL_RESERVOIR_ID:
                rac.setCgoto((string)value);
                break;

            case COL_OWNER_ID:
                rac.setID((string)value);
                break;

            case COL_OWNER_ACCOUNT:
                rac.setName((string)value);
                break;

            case COL_MAX_STORAGE:
                dval = ((double?)value).Value;
                rac.setOwnmax(dval);
                break;

            case COL_INITIAL_STORAGE:
                dval = ((double?)value).Value;
                rac.setCurown(dval);
                break;

            case COL_PRORATE_EVAP:
                if (value is double?)
                {
                    dval = ((double?)value).Value;
                    rac.setPcteva(dval);
                }
                else if (value is string)
                {
                    int    index = ((string)value).IndexOf(" -", StringComparison.Ordinal);
                    string s     = ((string)value).Substring(0, index);
                    dval = (Convert.ToDouble(s));
                    rac.setPcteva(dval);
                }
                break;

            case COL_OWNERSHIP_TIE:
                if (value is int?)
                {
                    ival = ((int?)value).Value;
                    rac.setN2own(ival);
                }
                else if (value is string)
                {
                    string n2owns = (string)value;
                    int    index  = n2owns.IndexOf(" -", StringComparison.Ordinal);
                    ival = (Convert.ToInt32(n2owns.Substring(0, index)));
                    rac.setN2own(ival);
                }
                break;
            }

            base.setValueAt(value, row, col);
        }