/// <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 in the title of the GUI. </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>
        /// <param name="precip"> if true, then the climate stations to view are precip stations.
        /// If false, they are evap stations. </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_ReservoirClimate_Data_JFrame(java.util.List data, String titleString, boolean editable, boolean precip) throws Exception
        public StateMod_ReservoirClimate_Data_JFrame(System.Collections.IList data, string titleString, bool editable, bool precip) : base()
        {
            int j     = 0;
            int size  = 0;
            int size2 = 0;
            StateMod_Reservoir        r = null;
            StateMod_ReservoirClimate c = null;

            System.Collections.IList climates = 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];
                climates = r.getClimates();
                if (climates == null)
                {
                    continue;
                }

                size2 = climates.Count;

                for (j = 0; j < size2; j++)
                {
                    c = (StateMod_ReservoirClimate)climates[j];
                    if (c == null)
                    {
                        // skip
                    }
                    else if (!precip && c.getType() == StateMod_ReservoirClimate.CLIMATE_EVAP)
                    {
                        c.setCgoto(r.getID());
                        v.Add(c);
                    }
                    else if (precip && c.getType() == StateMod_ReservoirClimate.CLIMATE_PTPX)
                    {
                        c.setCgoto(r.getID());
                        v.Add(c);
                    }
                }
            }

            initialize(v, titleString, editable);
            setSize(377, getHeight());
        }
Exemple #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. </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_Reservoir r = (StateMod_Reservoir)_data.get(row);

            switch (col)
            {
            case COL_ID:
                return(r.getID());

            case COL_NAME:
                return(r.getName());

            case COL_NODE_ID:
                return(r.getCgoto());

            case COL_SWITCH:
                return(new int?(r.getSwitch()));

            case COL_ONE_FILL_DATE:
                return(new int?((int)r.getRdate()));

            case COL_MIN_CONTENT:
                return(new double?(r.getVolmin()));

            case COL_MAX_CONTENT:
                return(new double?(r.getVolmax()));

            case COL_MAX_RELEASE:
                return(new double?(r.getFlomax()));

            case COL_DEAD_STORAGE:
                return(new double?(r.getDeadst()));

            case COL_DAILY_ID:
                return(r.getCresdy());

            case COL_NUM_OWNERS:
                return(new int?(r.getNowner()));

            case COL_NUM_PRECIP_STA:
                int nptpx = StateMod_ReservoirClimate.getNumPrecip(r.getClimates());
                return(new int?(nptpx));

            case COL_NUM_EVAP_STA:
                int nevap = StateMod_ReservoirClimate.getNumEvap(r.getClimates());
                return(new int?(nevap));

            case COL_NUM_CURVE_ROWS:
                System.Collections.IList v = r.getAreaCaps();
                if (v == null)
                {
                    return(new int?(0));
                }
                else
                {
                    return(new int?(v.Count));
                }

            default:
                return("");
            }
        }
        /// <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_Reservoir_Climate_JFrame.saveData";

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

            if (checkInput(__worksheetP, "Precipitation") > 0)
            {
                return(false);
            }
            if (checkInput(__worksheetE, "Evaporation") > 0)
            {
                return(false);
            }

            // if the Vectors are differently-sized, they're different
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_ReservoirClimate> wv1 = (java.util.List<StateMod_ReservoirClimate>)__worksheetP.getAllData();
            IList <StateMod_ReservoirClimate> wv1 = (IList <StateMod_ReservoirClimate>)__worksheetP.getAllData();   // w for worksheet
            IList <StateMod_ReservoirClimate> rv1 = getPrecipitationStations(__currentRes.getClimates());
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_ReservoirClimate> wv2 = (java.util.List<StateMod_ReservoirClimate>)__worksheetE.getAllData();
            IList <StateMod_ReservoirClimate> wv2 = (IList <StateMod_ReservoirClimate>)__worksheetE.getAllData();   // w for worksheet
            IList <StateMod_ReservoirClimate> rv2 = getEvaporationStations(__currentRes.getClimates());

            bool needToSave1 = !(StateMod_ReservoirClimate.Equals(wv1, rv1));
            bool needToSave2 = !(StateMod_ReservoirClimate.Equals(wv2, rv2));

            Message.printStatus(1, routine, "Saving Precip? .......[" + needToSave1 + "]");
            Message.printStatus(1, routine, "Saving Evap? .........[" + needToSave2 + "]");

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

            int size = wv1.Count;
            IList <StateMod_ReservoirClimate> clone = new List <StateMod_ReservoirClimate>();
            StateMod_ReservoirClimate         r     = null;
            StateMod_ReservoirClimate         cr    = null;

            for (int i = 0; i < size; i++)
            {
                r           = wv1[i];
                cr          = (StateMod_ReservoirClimate)r.clone();
                cr._isClone = false;
                clone.Add(cr);
            }

            size = wv2.Count;
            for (int i = 0; i < size; i++)
            {
                r           = wv2[i];
                cr          = (StateMod_ReservoirClimate)r.clone();
                cr._isClone = false;
                clone.Add(cr);
            }

            __currentRes.setClimates(clone);
            __dataset.setDirty(StateMod_DataSet.COMP_DIVERSION_STATIONS, true);
            return(true);
        }