コード例 #1
0
        /// <summary>
        /// Inserts the specified value into the data object at the given position.  This
        /// is not like setValueAt() because it doesn't change any combo box values or
        /// update other columns' data.  It simply puts the data into the data object
        /// and notifies the table that data has changed so that it displays the updated values. </summary>
        /// <param name="value"> the object to store in the table cell. </param>
        /// <param name="row"> the row of the cell in which to place the object. </param>
        /// <param name="col"> the column of the cell in which to place the object. </param>
        public virtual void setInternalValueAt(object value, int row, int col)
        {
            /*
             * Message.printStatus(1, "", "---------------------------------------");
             * Message.printStatus(1, "", "SET INTERNAL VALUE AT: " + row + ", " +col);
             * JWorksheet.except(1, 3);
             * Message.printStatus(1, "", "---------------------------------------");
             */

            TSIdent tsident = (TSIdent)_data.get(row);

            switch (col)
            {
            case _COL_STATION_TYPE:
                string type = tsident.getAlias();
                if (type.Equals((string)value))
                {
                    break;
                }
                tsident.setAlias((string)value);
                break;

            case _COL_ID:
                tsident.setLocation((string)value);
                break;

            case _COL_INTERVAL:
                try
                {
                    tsident.setInterval((string)value);
                }
                catch (Exception)
                {
                    // Should not happen.
                }
                break;

            case _COL_DATA_TYPE:
                tsident.setType((string)value);
                break;

            case _COL_INPUT_TYPE:
                tsident.setInputType((string)value);
                break;

            case _COL_INPUT_NAME:
                string s = (string)value;
                if (s.Equals(__BROWSE_INPUT_NAME_ABSOLUTE))
                {
                    s = browseForFile();
                }
                else if (s.Equals(__BROWSE_INPUT_NAME_RELATIVE))
                {
                    string file = browseForFile();
                    if (!string.ReferenceEquals(file, null))
                    {
                        try
                        {
                            int    index      = file.LastIndexOf(File.separator);
                            string workingDir = __dataset.getDataSetDirectory();
                            string dir        = IOUtil.toRelativePath(workingDir, file.Substring(0, index));
                            s = dir + File.separator + file.Substring(index + 1, file.Length - (index + 1));
                        }
                        catch (Exception)
                        {
                            // TODO (JTS - 2003-11-05) maybe handle this better.  Right now just defaults to the absolute filename
                            s = file;
                        }
                    }
                }
                tsident.setInputName(s);
                // don't go through the super.setValueAt() at the end of the method ...
                base.setValueAt(s, row, col);
                return;
            }

            fireTableDataChanged();
            base.setValueAt(value, row, col);
        }
コード例 #2
0
        /// <summary>
        /// Inserts the specified value into the table at the given position. </summary>
        /// <param name="value"> the object to store in the table cell. </param>
        /// <param name="row"> the row of the cell in which to place the object. </param>
        /// <param name="col"> the column of the cell in which to place the object. </param>
        public virtual void setValueAt(object value, int row, int col)
        {
            if (_sortOrder != null)
            {
                row = _sortOrder[row];
            }

            /*
             * Message.printStatus(1, "", "---------------------------------------");
             * Message.printStatus(1, "", "SET VALUE AT: " + row + ", " +col);
             * JWorksheet.except(1, 3);
             * Message.printStatus(1, "", "---------------------------------------");
             */

            TSIdent tsident = (TSIdent)_data.get(row);

            switch (col)
            {
            case _COL_STATION_TYPE:
                string type = tsident.getAlias();
                if (type.Equals((string)value))
                {
                    break;
                }
                tsident.setAlias((string)value);
                tsident.setLocation("");
                setValueAt("", row, _COL_INTERVAL);
                // this next line wouldn't seem to make any sense, but leave it in!!
                setValueAt(getValueAt(row, _COL_DATA_TYPE), row, _COL_DATA_TYPE);
                fireTableDataChanged();
                overrideCellEdit(row, _COL_ID, true);
                fillIDColumn(row, (string)value);
                // Since the ID is filled, select the first item by
                // default to force something to be displayed...
                if (__worksheet != null)
                {
                    System.Collections.IList ids = __worksheet.getCellSpecificJComboBoxValues(row, _COL_ID);
                    if (ids.Count > 0)
                    {
                        setValueAt(ids[0], row, _COL_ID);
                    }
                    else
                    {
                        setValueAt("", row, _COL_ID);
                    }
                }
                break;

            case _COL_ID:
                string id = (string)value;
                tsident.setLocation(id);
                bool   outputOnly = false;
                string staType    = (string)getValueAt(row, _COL_STATION_TYPE);
                if (staType.Equals(StateMod_Util.STATION_TYPE_RESERVOIR))
                {
                    if (id.IndexOf("-", StringComparison.Ordinal) > -1)
                    {
                        outputOnly = true;
                    }
                }
                overrideCellEdit(row, _COL_DATA_TYPE, true);
                // Fill the interval cell, given the station type and identifier...
                if (((string)value).Length == 0)
                {
                    fireTableDataChanged();
                }
                fillIntervalColumn(row, (string)getValueAt(row, _COL_STATION_TYPE), (string)value);
                if (outputOnly)
                {
                    fillDataTypeColumn(row, true, (string)getValueAt(row, _COL_STATION_TYPE), (string)getValueAt(row, _COL_ID), (string)value);
                }
                else
                {
                    fillDataTypeColumn(row, false, (string)getValueAt(row, _COL_STATION_TYPE), (string)getValueAt(row, _COL_ID), (string)value);
                }
                fireTableDataChanged();
                break;

            case _COL_INTERVAL:
                try
                {
                    tsident.setInterval((string)value);
                }
                catch (Exception)
                {
                    // Should not happen.
                }
                bool   ioutputOnly = false;
                string istaType    = (string)getValueAt(row, _COL_STATION_TYPE);
                string iid         = (string)getValueAt(row, _COL_ID);
                if (istaType.Equals(StateMod_Util.STATION_TYPE_RESERVOIR))
                {
                    if (iid.IndexOf("-", StringComparison.Ordinal) > -1)
                    {
                        ioutputOnly = true;
                    }
                }
                if (ioutputOnly)
                {
                    fillDataTypeColumn(row, true, (string)getValueAt(row, _COL_STATION_TYPE), (string)getValueAt(row, _COL_ID), (string)value);
                }
                else
                {
                    fillDataTypeColumn(row, false, (string)getValueAt(row, _COL_STATION_TYPE), (string)getValueAt(row, _COL_ID), (string)value);
                }
                // this next line wouldn't seem to make any sense, but leave it in!!
                setValueAt(getValueAt(row, _COL_DATA_TYPE), row, _COL_DATA_TYPE);
                fireTableDataChanged();
                break;

            case _COL_DATA_TYPE:
                tsident.setType((string)value);
                // Fill the input type cell, given the station type, identifier, and interval...
                fillInputTypeColumn(row, (string)getValueAt(row, _COL_STATION_TYPE), (string)getValueAt(row, _COL_ID), (string)getValueAt(row, _COL_INTERVAL), (string)value);
                fireTableDataChanged();
                break;

            case _COL_INPUT_TYPE:
                tsident.setInputType((string)value);
                // Fill the input name with defaults...
                fillInputNameColumn(row, (string)getValueAt(row, _COL_STATION_TYPE), (string)getValueAt(row, _COL_ID), (string)getValueAt(row, _COL_INTERVAL), (string)getValueAt(row, _COL_DATA_TYPE), (string)value);
                break;

            case _COL_INPUT_NAME:
                string s = (string)value;
                if (s.Equals(__BROWSE_INPUT_NAME_ABSOLUTE))
                {
                    s = browseForFile();
                }
                else if (s.Equals(__BROWSE_INPUT_NAME_RELATIVE))
                {
                    string file = browseForFile();
                    if (!string.ReferenceEquals(file, null))
                    {
                        try
                        {
                            int    index      = file.LastIndexOf(File.separator);
                            string workingDir = __dataset.getDataSetDirectory();
                            string dir        = IOUtil.toRelativePath(workingDir, file.Substring(0, index));
                            s = dir + File.separator + file.Substring(index + 1, file.Length - (index + 1));
                        }
                        catch (Exception)
                        {
                            // TODO (JTS - 2003-11-05)  maybe handle this better.  Right now just defaults to the absolute filename
                            s = file;
                        }
                    }
                }
                tsident.setInputName(s);
                // don't go through the super.setValueAt() at the end of the method ...
                base.setValueAt(s, row, col);
                return;
            }

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