/// <summary>
        /// Reponds to action performed events. </summary>
        /// <param name="e"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent e)
        {
            string action = e.getActionCommand();

            if (action.Equals(__BUTTON_ADD_PRECIPITATION_STATION))
            {
                StateMod_ReservoirClimate aClimateNode = new StateMod_ReservoirClimate();
                aClimateNode._isClone = true;
                aClimateNode.setType(StateMod_ReservoirClimate.CLIMATE_PTPX);
                __worksheetP.addRow(aClimateNode);
                __worksheetP.scrollToLastRow();
                __worksheetP.selectLastRow();
                checkDeleteStationButton();
            }
            else if (action.Equals(__BUTTON_ADD_EVAPORATION_STATION))
            {
                StateMod_ReservoirClimate aClimateNode = new StateMod_ReservoirClimate();
                aClimateNode._isClone = true;
                aClimateNode.setType(StateMod_ReservoirClimate.CLIMATE_EVAP);
                __worksheetE.addRow(aClimateNode);
                __worksheetE.scrollToLastRow();
                __worksheetE.selectLastRow();
                checkDeleteStationButton();
            }
            else if (action.Equals(__BUTTON_DELETE_PRECIPITATION_STATION))
            {
                int rowP  = __worksheetP.getSelectedRow();
                int rowE  = __worksheetE.getSelectedRow();
                int count = 0;
                if (rowP > -1)
                {
                    count++;
                }
                if (rowE > -1)
                {
                    count++;
                }
                if (count > 0)
                {
                    string plural = "s";
                    if (count == 1)
                    {
                        plural = "";
                    }
                    int x = (new ResponseJDialog(this, "Delete climate station" + plural, "Delete climate station" + plural + "?", ResponseJDialog.YES | ResponseJDialog.NO)).response();
                    if (x == ResponseJDialog.NO)
                    {
                        return;
                    }
                    if (rowP > -1)
                    {
                        __worksheetP.deleteRow(rowP);
                        __deleteStation.setEnabled(false);
                        __worksheetP.scrollToLastRow();
                    }
                    if (rowE > -1)
                    {
                        __worksheetE.deleteRow(rowE);
                        __deleteStation.setEnabled(false);
                        __worksheetE.scrollToLastRow();
                    }
                }
            }
            else if (action.Equals(__BUTTON_CLOSE))
            {
                if (saveData())
                {
                    setVisible(false);
                    dispose();
                }
            }
            else if (action.Equals(__BUTTON_APPLY))
            {
                saveData();
            }
            else if (action.Equals(__BUTTON_CANCEL))
            {
                setVisible(false);
                dispose();
            }
            else if (action.Equals(__BUTTON_HELP))
            {
                // REVISIT HELP (JTS - 2003-06-09)
            }
        }
        /// <summary>
        /// Read reservoir information in and store in a Vector. </summary>
        /// <param name="filename"> Name of file to read. </param>
        /// <exception cref="Exception"> if there is an error reading the file. </exception>
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public static java.util.List<StateMod_Reservoir> readStateModFile(String filename) throws Exception
        public static IList <StateMod_Reservoir> readStateModFile(string filename)
        {
            string routine = "StateMod_Reservoir.readStateModFile";
            IList <StateMod_Reservoir> theReservoirs = new List <StateMod_Reservoir>();
            string         iline = null;
            IList <object> v     = new List <object>(9);

            int[]                     format_0   = new int[] { StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_INTEGER, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_SPACE, StringUtil.TYPE_STRING };
            int[]                     format_0w  = new int[] { 12, 24, 12, 8, 8, 1, 12 };
            int[]                     format_1   = new int[] { StringUtil.TYPE_SPACE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER };
            int[]                     format_1w  = new int[] { 24, 8, 8, 8, 8, 8, 8, 8, 8 };
            int[]                     format_2   = new int[] { StringUtil.TYPE_SPACE, StringUtil.TYPE_STRING, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER };
            int[]                     format_2w  = new int[] { 12, 12, 8, 8, 8, 8 };
            int[]                     format_3   = new int[] { StringUtil.TYPE_SPACE, StringUtil.TYPE_STRING, StringUtil.TYPE_DOUBLE };
            int[]                     format_3w  = new int[] { 24, 12, 8 };
            int[]                     format_4   = new int[] { StringUtil.TYPE_SPACE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE };
            int[]                     format_4w  = new int[] { 24, 8, 8, 8 };
            StreamReader              @in        = null;
            StateMod_Reservoir        aReservoir = null;
            StateMod_ReservoirAccount anAccount  = null;
            StateMod_ReservoirClimate anEvap     = null;
            StateMod_ReservoirClimate aPtpx      = null;
            int i = 0;

            if (Message.isDebugOn)
            {
                Message.printDebug(10, routine, "in SMParseResFile reading file: " + filename);
            }
            int line_count = 0;

            try
            {
                @in = new StreamReader(IOUtil.getPathUsingWorkingDir(filename));
                while (!string.ReferenceEquals((iline = @in.ReadLine()), null))
                {
                    ++line_count;
                    // check for comments
                    if (iline.StartsWith("#", StringComparison.Ordinal) || iline.Trim().Length == 0)
                    {
                        continue;
                    }

                    // allocate new reservoir node
                    aReservoir = new StateMod_Reservoir();

                    // line 1
                    if (Message.isDebugOn)
                    {
                        Message.printDebug(50, routine, "line 1: " + iline);
                    }
                    StringUtil.fixedRead(iline, format_0, format_0w, v);
                    aReservoir.setID(((string)v[0]).Trim());
                    aReservoir.setName(((string)v[1]).Trim());
                    aReservoir.setCgoto(((string)v[2]).Trim());
                    aReservoir.setSwitch((int?)v[3]);
                    aReservoir.setRdate((double?)v[4]);
                    aReservoir.setCresdy(((string)v[5]).Trim());

                    // line 2
                    iline = @in.ReadLine();
                    ++line_count;
                    if (Message.isDebugOn)
                    {
                        Message.printDebug(50, routine, "line 2: " + iline);
                    }
                    StringUtil.fixedRead(iline, format_1, format_1w, v);
                    aReservoir.setVolmin(((double?)v[0]));
                    aReservoir.setVolmax(((double?)v[1]));
                    aReservoir.setFlomax(((double?)v[2]));
                    aReservoir.setDeadst(((double?)v[3]));
                    int nowner = ((int?)v[4]).Value;
                    int nevap  = ((int?)v[5]).Value;
                    int nptpx  = ((int?)v[6]).Value;
                    int nrange = ((int?)v[7]).Value;

                    // get the owner's information
                    if (Message.isDebugOn)
                    {
                        Message.printDebug(50, routine, "Number of owners: " + nowner);
                    }
                    for (i = 0; i < nowner; i++)
                    {
                        iline = @in.ReadLine();
                        ++line_count;
                        StringUtil.fixedRead(iline, format_2, format_2w, v);
                        anAccount = new StateMod_ReservoirAccount();
                        // Account ID is set to the numerical count (StateMod uses the number)
                        anAccount.setID("" + (i + 1));
                        anAccount.setName(((string)v[0]).Trim());
                        anAccount.setOwnmax(((double?)v[1]));
                        anAccount.setCurown(((double?)v[2]));
                        anAccount.setPcteva(((double?)v[3]));
                        anAccount.setN2own(((int?)v[4]));
                        aReservoir.addAccount(anAccount);
                    }

                    // get the evaporation information
                    for (i = 0; i < nevap; i++)
                    {
                        iline = @in.ReadLine();
                        ++line_count;
                        StringUtil.fixedRead(iline, format_3, format_3w, v);
                        anEvap = new StateMod_ReservoirClimate();
                        anEvap.setID(((string)v[0]).Trim());
                        anEvap.setType(StateMod_ReservoirClimate.CLIMATE_EVAP);
                        anEvap.setWeight(((double?)v[1]));
                        aReservoir.addClimate(anEvap);
                    }

                    // get the precipitation information
                    for (i = 0; i < nptpx; i++)
                    {
                        iline = @in.ReadLine();
                        ++line_count;
                        StringUtil.fixedRead(iline, format_3, format_3w, v);
                        aPtpx = new StateMod_ReservoirClimate();
                        aPtpx.setID(((string)v[0]).Trim());
                        aPtpx.setType(StateMod_ReservoirClimate.CLIMATE_PTPX);
                        aPtpx.setWeight(((double?)v[1]));
                        aReservoir.addClimate(aPtpx);
                    }

                    // get the area capacity information
                    for (i = 0; i < nrange; i++)
                    {
                        iline = @in.ReadLine();
                        ++line_count;
                        StringUtil.fixedRead(iline, format_4, format_4w, v);
                        StateMod_ReservoirAreaCap anAreaCap = new StateMod_ReservoirAreaCap();
                        anAreaCap.setConten(((double?)v[0]));
                        anAreaCap.setSurarea(((double?)v[1]));
                        anAreaCap.setSeepage(((double?)v[2]));
                        aReservoir.addAreaCap(anAreaCap);
                    }

                    // add the reservoir to the vector of reservoirs
                    theReservoirs.Add(aReservoir);
                }
            }
            catch (Exception e)
            {
                Message.printWarning(3, routine, "Error reading reservoir stations in line " + line_count);
                throw e;
            }
            finally
            {
                if (@in != null)
                {
                    @in.Close();
                }
            }
            return(theReservoirs);
        }