/// <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_Diversion_ReturnFlow_JFrame.saveData";

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

            if (checkInput() > 0)
            {
                return(false);
            }

            // now only save data if any are different.
            bool needToSave = false;

            // if the lists 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_ReturnFlow> wv = (java.util.List<StateMod_ReturnFlow>)__worksheet.getAllData();
            IList <StateMod_ReturnFlow> wv = (IList <StateMod_ReturnFlow>)__worksheet.getAllData(); // w for worksheet

            System.Collections.IList dv = __currentDiv.getReturnFlows();                            // d for diversion

            needToSave = !(StateMod_ReturnFlow.Equals(wv, dv));

            Message.printStatus(1, routine, "Saving? .........[" + needToSave + "]");

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

            // clone the objects from the worksheet vector and assign them
            // to the diversion object as its new return flows.
            int size = wv.Count;
            IList <StateMod_ReturnFlow> clone = new List <StateMod_ReturnFlow>();
            StateMod_ReturnFlow         rf    = null;
            StateMod_ReturnFlow         crf   = null;

            for (int i = 0; i < size; i++)
            {
                rf  = wv[i];
                crf = (StateMod_ReturnFlow)rf.clone();
                rf.setCrtnid(StringUtil.getToken(rf.getCrtnid(), " ", StringUtil.DELIM_SKIP_BLANKS, 0));
                crf._isClone = false;
                clone.Add(crf);
            }

            __currentDiv.setReturnFlow(clone);
            __dataset.setDirty(StateMod_DataSet.COMP_DIVERSION_STATIONS, true);

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Sets up the data to be displayed in the table.
        /// </summary>
        private void setupData()
        {
            int num  = 0;
            int size = _data.size();
            StateMod_Diversion dt = null;
            string             id = null;

            __data = new System.Collections.IList[__COLUMNS];
            for (int i = 0; i < __COLUMNS; i++)
            {
                __data[i] = new List <object>();
            }

            __rowMap = new List <object>();

            double total           = 0;
            int    rowCount        = 0;
            StateMod_ReturnFlow rf = null;

            System.Collections.IList returnFlows = null;
            for (int i = 0; i < size; i++)
            {
                total = 0;
                dt    = (StateMod_Diversion)_data.get(i);
                id    = dt.getID();

                num         = dt.getNrtn();
                returnFlows = dt.getReturnFlows();
                for (int j = 0; j < num; j++)
                {
                    rf = (StateMod_ReturnFlow)returnFlows[j];
                    __data[__COL_ID].Add(id);
                    __data[__COL_NODE_ID].Add(rf.getCrtnid());
                    __data[__COL_PERCENT].Add(new double?(rf.getPcttot()));
                    __data[__COL_DELAY_ID].Add("" + rf.getIrtndl());
                    total += rf.getPcttot();
                    __rowMap.Add(new int?(rowCount));
                    rowCount++;
                }

                __data[__COL_ID].Add(id);
                __data[__COL_NODE_ID].Add("TOTAL");
                __data[__COL_PERCENT].Add(new double?(total));
                __data[__COL_DELAY_ID].Add("");

                rowCount++;
            }
            _rows = rowCount;
        }