Пример #1
0
	/// <summary>
	/// Updates the right table based on a new selection from the left table, 
	/// or if rows were added or deleted to the right table. </summary>
	/// <param name="dt"> the StateMod_DelayTable object selected in the left table. </param>
	private void updateRightTable(StateMod_DelayTable dt)
	{
		IList<double?> v = dt.getRet_val();
		IList<double?> v2 = new List<double?>();
		for (int i = 0; i < v.Count; i++)
		{
			v2.Add(new double?(v[i].Value));
		}

		((StateMod_DelayTable_TableModel)__worksheetR.getModel()).setSubDelays(v2);
		((StateMod_DelayTable_TableModel)__worksheetR.getModel()).fireTableDataChanged();
		((StateMod_DelayTable_TableModel)__worksheetR.getModel()).fireTableDataChanged();
		__deleteReturn.setEnabled(false);
	}
Пример #2
0
        /// <summary>
        /// Checks the text fields for validity before they are saved back into the data object. </summary>
        /// <returns> 0 if the text fields are okay, 1 if fatal errors exist, and -1 if only non-fatal errors exist. </returns>
        private int checkInput()
        {
            string routine = "StateMod_Response_JFrame.checkInput";

            string warning     = "";
            int    fatal_count = 0;

            // Check to make sure that no two files have the same name...

            int size = __worksheet.getModel().getRowCount();
            DataSetComponent comp = null, comp2 = null;
            string           file_name, file_name2;

            for (int i = 0; i < size; i++)
            {
                // Get the component corresponding to the line.
                comp      = __dataset_copy.getComponentForComponentType(((StateMod_Response_TableModel)__worksheet.getModel()).getComponentTypeForRow(i));
                file_name = ((string)__worksheet.getValueAt(i, StateMod_Response_TableModel.COL_NAME)).Trim();
                if (file_name.Equals(__dataset_copy.BLANK_FILE_NAME, StringComparison.OrdinalIgnoreCase) && comp.hasData())
                {
                    if (comp.getComponentType() != StateMod_DataSet.COMP_NETWORK)
                    {
                        warning += "\n" + comp.getComponentName() + " has data but no file name is specified.";
                        ++fatal_count;
                    }
                }
                // Check for duplicate file names.  In particular with the new
                // response file format, there is no need for "dum" empty files.
                for (int j = 0; j < size; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }
                    comp2      = __dataset_copy.getComponentForComponentType(((StateMod_Response_TableModel)__worksheet.getModel()).getComponentTypeForRow(j));
                    file_name2 = ((string)__worksheet.getValueAt(j, StateMod_Response_TableModel.COL_NAME)).Trim();
                    if (file_name2.Equals(file_name, StringComparison.OrdinalIgnoreCase) && !file_name2.Equals(__dataset_copy.BLANK_FILE_NAME, StringComparison.OrdinalIgnoreCase))
                    {
                        // Stream gage and stream estimate stations can be the same file name...
                        if (((comp.getComponentType() == StateMod_DataSet.COMP_STREAMGAGE_STATIONS) && (comp2.getComponentType() == StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS)) || ((comp.getComponentType() == StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS) && (comp2.getComponentType() == StateMod_DataSet.COMP_STREAMGAGE_STATIONS)))
                        {
                            // TODO SAM 2006-03-04 Need to finalize how the gage and estimate files are handled.
                            //&&
                            //!__dataset_copy.isFreeFormat() ) {
                            // No need for a warning because the single file is split internally when read...
                        }
                        else
                        {
                            warning += "\n" + comp.getComponentName() +
                                       " file name (" + file_name + ") is the same as another component.";
                            ++fatal_count;
                        }
                        // No need to look at more files...
                        break;
                    }
                }
                // Compare against the original copy...
                // Warn that time series file names cannot be changed from the
                // original because time series were not read in...
                comp2      = __dataset.getComponentForComponentType(comp.getComponentType());
                file_name2 = comp2.getDataFileName();
                if (!file_name.Equals(file_name2) && !__dataset.areTSRead() && __dataset.isDynamicTSComponent(comp.getComponentType()))
                {
                    warning += "\n" + comp.getComponentName() +
                               " time series were not read in - cannot change file name.";
                    ++fatal_count;
                }
            }

            if (warning.Length > 0)
            {
                warning = "\nResponse file:  " + warning + "\nCorrect or Cancel.";
                Message.printWarning(1, routine, warning, this);
                if (fatal_count > 0)
                {
                    // Fatal errors...
                    return(1);
                }
                else
                {
                    // Nonfatal errors...
                    return(-1);
                }
            }
            else
            {
                // No errors...
                return(0);
            }
        }