/// <summary>
        /// Handle action events. </summary>
        /// <param name="event"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent @event)
        {
            string routine = "StateMod_QueryTool_JFrame.actionPerformed";

            string action = @event.getActionCommand();

            if (action.Equals(__Cancel_String))
            {
                closeWindow();
            }
            else if (action.Equals(__Display_String))
            {
                try
                {
                    displayQueryResults();
                }
                catch (Exception e)
                {
                    Message.printWarning(1, routine, "Unable to display query results.", this);
                    Message.printWarning(2, routine, e);
                }
            }
            else if (action.Equals(__Query_String))
            {
                try
                {
                    doQuery();
                }
                catch (Exception)
                {
                    __status_JTextField.setText(__Ready);
                    JGUIUtil.setWaitCursor(this, false);
                }
            }
        }
 /// <summary>
 /// Responds to mouse clicked events; does nothing. </summary>
 /// <param name="e"> the MouseEvent that happened. </param>
 public virtual void mouseClicked(MouseEvent e)
 {
     if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() >= 2)
     {
         JGUIUtil.setWaitCursor(this, true);
         editSelectedFile();
         JGUIUtil.setWaitCursor(this, false);
     }
 }
Example #3
0
        /// <summary>
        /// Exports a list of strings to a file. </summary>
        /// <param name="filename"> the name of the file to write. </param>
        /// <param name="strings"> a non-null Vector of Strings, each element of which will be
        /// another line in the file. </param>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void export(String filename, java.util.List<String> strings) throws Exception
        protected internal virtual void export(string filename, IList <string> strings)
        {
            string routine = "StateMod_Data_JFrame.export";

            // First see if we can write the file given the security
            // settings...
            if (!SecurityCheck.canWriteFile(filename))
            {
                Message.printWarning(1, routine, "Cannot save \"" + filename + "\".");
                throw new Exception("Security check failed - unable to write \"" + filename + "\"");
            }

            JGUIUtil.setWaitCursor(this, true);

            // Create a new FileOutputStream wrapped with a DataOutputStream
            // for writing to a file.
            PrintWriter oStream = null;

            try
            {
                oStream = new PrintWriter(new StreamWriter(filename));
            }
            catch (Exception)
            {
                JGUIUtil.setWaitCursor(this, false);
                throw new Exception("Error opening file \"" + filename + "\".");
            }

            try
            {
                // Write each element of the strings Vector to a file.
                // For some reason, when just using println in an
                // applet, the cr-nl pair is not output like it should
                // be on Windows95.  Java Bug???
                string linesep = System.getProperty("line.separator");
                int    size    = strings.Count;
                for (int i = 0; i < size; i++)
                {
                    oStream.print(strings[i].ToString() + linesep);
                }
                oStream.flush();
                oStream.close();
            }
            catch (Exception)
            {
                JGUIUtil.setWaitCursor(this, false);
                throw new Exception("Error writing to file \"" + filename + "\".");
            }

            JGUIUtil.setWaitCursor(this, false);
        }
Example #4
0
        /// <summary>
        /// Opens a dialog from which users can browse for delta plot files. </summary>
        /// <returns> the path to the file the user chose, or "" if no file was selected. </returns>
        private string browseForFile()
        {
            JGUIUtil.setWaitCursor(__parent, true);
            string directory = JGUIUtil.getLastFileDialogDirectory();

            JFileChooser fc = null;

            if (!string.ReferenceEquals(directory, null))
            {
                fc = new JFileChooser(directory);
            }
            else
            {
                fc = new JFileChooser();
            }

            fc.setDialogTitle("Select File");
            SimpleFileFilter xre = new SimpleFileFilter("xdd", "ASCII xre");
            SimpleFileFilter b44 = new SimpleFileFilter("b44", "Binary b44");
            SimpleFileFilter xdd = new SimpleFileFilter("xdd", "ASCII xdd");
            SimpleFileFilter b43 = new SimpleFileFilter("b43", "Binary b43");

            fc.addChoosableFileFilter(xre);
            fc.addChoosableFileFilter(b44);
            fc.addChoosableFileFilter(xdd);
            fc.addChoosableFileFilter(b43);
            fc.setAcceptAllFileFilterUsed(true);
            fc.setFileFilter(xre);
            fc.setDialogType(JFileChooser.SAVE_DIALOG);

            JGUIUtil.setWaitCursor(__parent, false);
            int retVal = fc.showSaveDialog(__parent);

            if (retVal != JFileChooser.APPROVE_OPTION)
            {
                return("");
            }

            string currDir = (fc.getCurrentDirectory()).ToString();

            if (!currDir.Equals(directory, StringComparison.OrdinalIgnoreCase))
            {
                JGUIUtil.setLastFileDialogDirectory(currDir);
            }
            string filename = fc.getSelectedFile().getName();

            return(currDir + File.separator + filename);
        }
Example #5
0
        private string browseForFile()
        {
            JGUIUtil.setWaitCursor(this, true);
            string directory = JGUIUtil.getLastFileDialogDirectory();

            JFileChooser fc = JFileChooserFactory.createJFileChooser(directory);

            string compName = __tableModel.getComponentName(__worksheet.getSelectedRow());

            string ext = __dataset.getComponentFileExtension(__tableModel.getComponentTypeForRow(__worksheet.getSelectedRow()));

            fc.setDialogTitle("Select " + compName + " File");
            SimpleFileFilter ff = new SimpleFileFilter(ext, compName + " files");

            fc.addChoosableFileFilter(ff);
            fc.setAcceptAllFileFilterUsed(true);
            fc.setDialogType(JFileChooser.OPEN_DIALOG);
            fc.setFileFilter(ff);

            JGUIUtil.setWaitCursor(this, false);
            int retVal = fc.showOpenDialog(this);

            if (retVal != JFileChooser.APPROVE_OPTION)
            {
                return("");
            }

            string currDir = (fc.getCurrentDirectory()).ToString();

            if (!currDir.Equals(directory, StringComparison.OrdinalIgnoreCase))
            {
                JGUIUtil.setLastFileDialogDirectory(currDir);
            }
            string filename = fc.getSelectedFile().getName();

            return(currDir + File.separator + filename);
        }
        /// <summary>
        /// Browse for a statemod output file.
        /// </summary>
        private string browseForFile()
        {
            JGUIUtil.setWaitCursor(__parent, true);
            string lastDirectorySelected = JGUIUtil.getLastFileDialogDirectory();

            JFileChooser fc = JFileChooserFactory.createJFileChooser(lastDirectorySelected);

            fc.setDialogTitle("Select file");
            //	SimpleFileFilter ff = new SimpleFileFilter("???", "?Some kind of file?");
            //	fc.addChoosableFileFilter(ff);
            //	fc.setAcceptAllFileFilterUsed(false);
            //	fc.setFileFilter(ff);
            fc.setAcceptAllFileFilterUsed(true);
            fc.setDialogType(JFileChooser.OPEN_DIALOG);

            JGUIUtil.setWaitCursor(__parent, false);
            int retVal = fc.showOpenDialog(__parent);

            if (retVal != JFileChooser.APPROVE_OPTION)
            {
                return(null);
            }

            string currDir = (fc.getCurrentDirectory()).ToString();

            if (!currDir.Equals(lastDirectorySelected, StringComparison.OrdinalIgnoreCase))
            {
                JGUIUtil.setLastFileDialogDirectory(currDir);
            }

            string filename = fc.getSelectedFile().getName();

            // do some work with the filename, perhaps

            return(currDir + File.separator + filename);
        }
        /// <summary>
        /// Perform the query.  Currently only diversion stations are supported.
        /// </summary>
        private void doQuery()
        {
            string             routine = "StateMod_QueryTool_JFrame.doQuery", message;
            InputFilter_JPanel ifp    = __input_filter_diversion_JPanel;
            InputFilter        filter = null;
            int size;  // Size of data Vector
            int i;     // Loop for data items.
            DataSetComponent comp = null;

            string where, @operator, input;
            int    where_length = 0; // Length of "where", to optimize code.
            bool   do_int, do_double, do_string;
            string input_string;     // Data parameters to check, as
            int    input_int;        // transferred from the data objects.
            double input_double;
            bool   do_ID, do_Name, do_RiverNodeID, do_OnOff, do_Capacity, do_ReplaceResOption, do_DailyID, do_UserName, do_DemandType, do_EffAnnual, do_Area, do_UseType, do_DemandSource;

            bool[] matches = null; // Indicates if a data item matches all
            // the filter criteria.
            bool item_matches;     // Indicates whether the itme matches a

            // single filter criteria.
            bool[] @checked = null;     // Indicates whether a data item has
            // already been checked for a criteria.
            // If checked and false, then a "true"
            // should not reset the false.
            int nfg = 0;       // Number of filter groups.

            do_int    = false; // Whether the data item is an integer.
            do_double = false; // Whether the data item is a double.
            do_string = false; // Whether the data item is a string.
            StateMod_Diversion dds = null;

            __status_JTextField.setText(__Wait);
            JGUIUtil.setWaitCursor(this, true);
            if (ifp is StateMod_Diversion_InputFilter_JPanel)
            {
                input_int    = StateMod_Util.MISSING_INT;
                input_double = StateMod_Util.MISSING_DOUBLE;
                input_string = StateMod_Util.MISSING_STRING;
                comp         = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DIVERSION_STATIONS);
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Diversion> dds_Vector = (java.util.List<StateMod_Diversion>)comp.getData();
                IList <StateMod_Diversion> dds_Vector = (IList <StateMod_Diversion>)comp.getData();
                size = 0;
                if (dds_Vector != null)
                {
                    size = dds_Vector.Count;
                }
                // REVISIT SAM 2004-10-27 Remove when debugging is complete
                //Message.printStatus ( 2, routine,
                //"Searching " + size + " diversion stations." );
                // Initialize the arrays indicating if data objects have been
                // checked and whether they matched the filter(s)...
                if (size > 0)
                {
                    matches  = new bool[size];
                    @checked = new bool[size];
                }
                for (i = 0; i < size; i++)
                {
                    matches[i]  = false;
                    @checked[i] = false;
                }
                // Loop through the where clauses...
                nfg = ifp.getNumFilterGroups();
                for (int ifg = 0; ifg < nfg; ifg++)
                {
                    // Get the filter information...
                    filter       = ifp.getInputFilter(ifg);
                    where        = filter.getWhereInternal();
                    where_length = where.Length;
                    @operator    = ifp.getOperator(ifg);
                    input        = filter.getInput(false);
                    // REVISIT SAM 2004-10-27 Remove when debugging is
                    // complete
                    //Message.printStatus ( 2, routine,
                    //"where=" + where + " operator=" + operator +
                    //" input=" + input );
                    // Initialize flags to indicate what data will be
                    // checked...
                    do_int              = false;
                    do_double           = false;
                    do_string           = false;
                    do_ID               = false;
                    do_Name             = false;
                    do_RiverNodeID      = false;
                    do_OnOff            = false;
                    do_Capacity         = false;
                    do_ReplaceResOption = false;
                    do_DailyID          = false;
                    do_UserName         = false;
                    do_DemandType       = false;
                    do_EffAnnual        = false;
                    do_Area             = false;
                    do_UseType          = false;
                    do_DemandSource     = false;
                    // The following checks on "where" need to match the
                    // input filter internal where labels assigned in
                    // StateMod_Diversion_InputFilter_JPanel.
                    // List in the order of the StateMod documentation...
                    if (where.Equals("ID", StringComparison.OrdinalIgnoreCase))
                    {
                        do_string = true;
                        do_ID     = true;
                    }
                    else if (where.Equals("Name", StringComparison.OrdinalIgnoreCase))
                    {
                        do_string = true;
                        do_Name   = true;
                    }
                    else if (where.Equals("RiverNodeID", StringComparison.OrdinalIgnoreCase))
                    {
                        do_string      = true;
                        do_RiverNodeID = true;
                    }
                    else if (where.Equals("OnOff", StringComparison.OrdinalIgnoreCase) && StringUtil.isInteger(input))
                    {
                        do_int   = true;
                        do_OnOff = true;
                    }
                    else if (where.Equals("Capacity", StringComparison.OrdinalIgnoreCase) && StringUtil.isDouble(input))
                    {
                        do_double   = true;
                        do_Capacity = true;
                    }
                    else if (where.Equals("ReplaceResOption", StringComparison.OrdinalIgnoreCase) && StringUtil.isInteger(input))
                    {
                        do_int = true;
                        do_ReplaceResOption = true;
                    }
                    else if (where.Equals("DailyID", StringComparison.OrdinalIgnoreCase))
                    {
                        do_string  = true;
                        do_DailyID = true;
                    }
                    else if (where.Equals("UserName", StringComparison.OrdinalIgnoreCase))
                    {
                        do_string   = true;
                        do_UserName = true;
                    }
                    else if (where.Equals("DemandType", StringComparison.OrdinalIgnoreCase))
                    {
                        do_int        = true;
                        do_DemandType = true;
                    }
                    else if (where.Equals("EffAnnual", StringComparison.OrdinalIgnoreCase) && StringUtil.isDouble(input))
                    {
                        do_double    = true;
                        do_EffAnnual = true;
                    }
                    else if (where.Equals("Area", StringComparison.OrdinalIgnoreCase) && StringUtil.isDouble(input))
                    {
                        do_double = true;
                        do_Area   = true;
                    }
                    else if (where.Equals("UseType", StringComparison.OrdinalIgnoreCase) && StringUtil.isInteger(input))
                    {
                        do_int     = true;
                        do_UseType = true;
                    }
                    else if (where.Equals("DemandSource", StringComparison.OrdinalIgnoreCase) && StringUtil.isInteger(input))
                    {
                        do_int          = true;
                        do_DemandSource = true;
                    }
                    else if (where_length == 0)
                    {
                        // WIll match anything.
                    }
                    else
                    {             // Unrecognized where...
                        continue;
                    }
                    // REVISIT SAM 2004-10-27 Remove when debugging is
                    // complete

                    /*
                     * Message.printStatus ( 2, routine,
                     * "do_string=" + do_string + " do_int=" + do_int +
                     * "do_double=" + do_double +
                     * " " + do_ID +
                     * " " + do_Name +
                     * " " + do_RiverNodeID +
                     * " " + do_OnOff +
                     * " " + do_Capacity +
                     * " " + do_ReplaceResOption +
                     * " " + do_DailyID +
                     * " " + do_UserName +
                     * " " + do_DemandType +
                     * " " + do_EffAnnual +
                     * " " + do_Area +
                     * " " + do_UseType +
                     * " " + do_DemandSource );
                     */
                    for (i = 0; i < size; i++)
                    {
                        dds = (StateMod_Diversion)dds_Vector[i];
                        // Get the specific data to compare...
                        if (do_ID)
                        {
                            input_string = dds.getID();
                        }
                        else if (do_Name)
                        {
                            input_string = dds.getName();
                        }
                        else if (do_RiverNodeID)
                        {
                            input_string = dds.getCgoto();
                        }
                        else if (do_OnOff)
                        {
                            input_int = dds.getSwitch();
                        }
                        else if (do_Capacity)
                        {
                            input_double = dds.getDivcap();
                        }
                        else if (do_ReplaceResOption)
                        {
                            input_int = dds.getIreptype();
                        }
                        else if (do_DailyID)
                        {
                            input_string = dds.getCdividy();
                        }
                        else if (do_UserName)
                        {
                            input_string = dds.getUsername();
                        }
                        else if (do_DemandType)
                        {
                            input_int = dds.getIdvcom();
                        }
                        else if (do_EffAnnual)
                        {
                            input_double = dds.getDivefc();
                        }
                        else if (do_Area)
                        {
                            input_double = dds.getArea();
                        }
                        else if (do_UseType)
                        {
                            input_int = dds.getIrturn();
                        }
                        else if (do_DemandSource)
                        {
                            input_int = dds.getDemsrc();
                        }
                        else
                        {                 // Unrecognized...
                            continue;
                        }
                        // Compare the data with the input filter...
                        item_matches = false;
                        if (do_string)
                        {
                            item_matches = filter.matches(input_string, @operator, true);
                        }
                        else if (do_int)
                        {
                            item_matches = filter.matches(input_int, @operator);
                        }
                        else if (do_double)
                        {
                            item_matches = filter.matches(input_double, @operator);
                        }
                        if (where_length == 0)
                        {
                            // Always consider a match...
                            item_matches = true;
                        }
                        if (item_matches && (!@checked[i] || (@checked[i] && matches[i])))
                        {
                            // So far the item matches all
                            // filters...
                            matches[i] = true;
                        }
                        else if (@checked[i] && !item_matches)
                        {
                            // Does not match this filter to reset
                            // result to false...
                            matches[i] = false;
                        }
                        // Indicate that we have checked the item
                        // against at least one filter...
                        @checked[i] = true;
                    }
                }
                // Get a count so the Vector can be sized appropriately (this
                // should be fast)...
                int match_count = 0;
                for (i = 0; i < size; i++)
                {
                    if (matches[i])
                    {
                        ++match_count;
                    }
                }
                // Loop through and set up the matches_Vector...
                __matches_Vector = null;
                if (match_count > 0)
                {
                    __matches_Vector = new List <StateMod_Diversion> (match_count);
                    for (i = 0; i < size; i++)
                    {
                        if (matches[i])
                        {
                            // The diversion station matches so add
                            // to the list...
                            __matches_Vector.Add(dds_Vector[i]);
                        }
                    }
                }
                message = "Matched " + match_count +
                          " diversion stations (from original " + size + ").";
                Message.printStatus(2, routine, message);
                __message_JTextField.setText(message);
                __status_JTextField.setText(__Ready);
                JGUIUtil.setWaitCursor(this, false);
            }
            if (__matches_Vector == null)
            {
                __display_JButton.setEnabled(false);
            }
            else
            {
                __display_JButton.setEnabled(true);
            }
        }
Example #8
0
        /// <summary>
        /// Returns the filename and format type of a file selected from a file chooser
        /// in order that the kind of delimiter for the file can be known when the data
        /// is formatted for output.  Currently the only kinds of files that the data
        /// can be exported to are delimited files.  No StateMod files are yet supported.<para>
        /// Also sets the last selected file dialog directory to whatever directory the
        /// file is located in, if the file selection was approved (i.e., Cancel was not
        /// pressed).
        /// </para>
        /// </summary>
        /// <param name="title"> the title of the file chooser. </param>
        /// <param name="formats"> a Vector of the valid formats for the file chooser. </param>
        /// <returns> a two-element String array where the first element is the name of the
        /// file and the second element is the delimiter selected. </returns>
        protected internal virtual string[] getFilenameAndFormat()
        {
            JGUIUtil.setWaitCursor(this, true);
            string       dir = JGUIUtil.getLastFileDialogDirectory();
            JFileChooser fc  = JFileChooserFactory.createJFileChooser(dir);

            fc.setDialogTitle("Select Export File");

            SimpleFileFilter tabFF   = new SimpleFileFilter("txt", "Tab-delimited");
            SimpleFileFilter commaFF = new SimpleFileFilter("csv", "Comma-delimited");
            SimpleFileFilter semiFF  = new SimpleFileFilter("txt", "Semicolon-delimited");
            SimpleFileFilter pipeFF  = new SimpleFileFilter("txt", "Pipe-delimited");

            fc.addChoosableFileFilter(commaFF);
            fc.addChoosableFileFilter(pipeFF);
            fc.addChoosableFileFilter(semiFF);
            fc.addChoosableFileFilter(tabFF);

            fc.setAcceptAllFileFilterUsed(false);
            fc.setFileFilter(commaFF);
            fc.setDialogType(JFileChooser.SAVE_DIALOG);

            JGUIUtil.setWaitCursor(this, false);
            int returnVal = fc.showSaveDialog(this);

            if (returnVal == JFileChooser.APPROVE_OPTION)
            {
                string[] ret      = new string[2];
                string   filename = fc.getCurrentDirectory() + File.separator + fc.getSelectedFile().getName();
                JGUIUtil.setLastFileDialogDirectory("" + fc.getCurrentDirectory());
                SimpleFileFilter sff = (SimpleFileFilter)fc.getFileFilter();

                // this will always return a one-element vector
                IList <string> extensionV = sff.getFilters();

                string extension = extensionV[0];

                string desc      = sff.getShortDescription();
                string delimiter = "\t";

                if (desc.Equals("Tab-delimited"))
                {
                    delimiter = "\t";
                }
                else if (desc.Equals("Comma-delimited"))
                {
                    delimiter = ",";
                }
                else if (desc.Equals("Semicolon-delimited"))
                {
                    delimiter = ";";
                }
                else if (desc.Equals("Pipe-delimited"))
                {
                    delimiter = "|";
                }

                ret[0] = IOUtil.enforceFileExtension(filename, extension);
                ret[1] = delimiter;

                return(ret);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// Responds to action performed events. </summary>
        /// <param name="ae"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent ae)
        {
            string routine = "StateMod_OutputControl_JFrame.actionPerformed";
            string action  = ae.getActionCommand();

            if (action.Equals(__BUTTON_ADD_ROW))
            {
                if (!__tableModel.canAddNewRow())
                {
                    return;
                }
                __dirty = true;
                int row = __worksheet.getRowCount();

                StateMod_GraphNode n = new StateMod_GraphNode();
                __worksheet.addRow(n);
                n.setType("");
                n.setID("");
                n.setSwitch(-1);
                __tableModel.setDirty(true);

                // when a row is added, mark the second and third columns
                // as uneditable.  They will be set to editable as soon as
                // the user enters a value in the first column
                __worksheet.setCellEditable(row, 1, false);
                __worksheet.setCellEditable(row, 2, false);
            }
            else if (action.Equals(__BUTTON_CLEAR_LIST))
            {
                __dirty = true;
                __worksheet.clear();
                setMessages("Add station to list.", "Ready");
                __tableModel.setDirty(true);
            }
            else if (action.Equals(__BUTTON_CLOSE))
            {
                closeWindow();
            }
            else if (action.Equals(__BUTTON_DELETE_ROW))
            {
                int[] rows = __worksheet.getSelectedRows();

                int length = rows.Length;
                __tableModel.setDirty(true);

                if (length == 0)
                {
                    return;
                }

                for (int i = (length - 1); i >= 0; i--)
                {
                    __worksheet.deleteRow(rows[i]);
                }
                __dirty = true;
                setMessages("Time series list has changed.", "Ready");
            }
            else if (action.Equals(__BUTTON_HELP))
            {
                // REVISIT HELP (JTS - 2003-07-09)
            }
            else if (action.Equals(__BUTTON_SAVE_FILE))
            {
                JGUIUtil.setWaitCursor(this, true);
                string lastDirectorySelected = JGUIUtil.getLastFileDialogDirectory();

                JFileChooser fc = null;
                if (!string.ReferenceEquals(lastDirectorySelected, null))
                {
                    fc = new JFileChooser(lastDirectorySelected);
                }
                else
                {
                    fc = new JFileChooser();
                }

                fc.setDialogTitle("Select Output Control File");
                SimpleFileFilter @out = new SimpleFileFilter("out", "StateMod Output Control Files");
                fc.addChoosableFileFilter(@out);
                SimpleFileFilter tpl = new SimpleFileFilter("tpo", "StateMod Output Control Files");
                fc.addChoosableFileFilter(tpl);
                SimpleFileFilter xou = new SimpleFileFilter("xou", "StateMod Output Control Files");
                fc.addChoosableFileFilter(xou);
                fc.setAcceptAllFileFilterUsed(false);
                fc.setFileFilter(tpl);
                fc.setDialogType(JFileChooser.SAVE_DIALOG);

                JGUIUtil.setWaitCursor(this, false);

                int retVal = fc.showSaveDialog(this);
                if (retVal != JFileChooser.APPROVE_OPTION)
                {
                    return;
                }

                string currDir = (fc.getCurrentDirectory()).ToString();

                if (!currDir.Equals(lastDirectorySelected, StringComparison.OrdinalIgnoreCase))
                {
                    JGUIUtil.setLastFileDialogDirectory(currDir);
                }
                string filename = fc.getSelectedFile().getName();

                FileFilter ff = fc.getFileFilter();
                if (ff == @out)
                {
                    filename = IOUtil.enforceFileExtension(filename, "out");
                }
                else if (ff == tpl)
                {
                    filename = IOUtil.enforceFileExtension(filename, "tpo");
                }
                else if (ff == xou)
                {
                    filename = IOUtil.enforceFileExtension(filename, "xou");
                }

                __dirty = false;
                __tableModel.setDirty(false);

                System.Collections.IList theGraphNodes = __worksheet.getAllData();

                try
                {
                    StateMod_GraphNode.writeStateModOutputControlFile(null, currDir + File.separator + filename, theGraphNodes, null);
                }
                catch (Exception e)
                {
                    Message.printWarning(1, routine, "Error saving output control file\n" + "\"" + currDir + File.separator + filename + "\"", this);
                    Message.printWarning(2, routine, e);
                }
            }
            else if (action.Equals(__BUTTON_LOAD_FILE))
            {
                JGUIUtil.setWaitCursor(this, true);
                string lastDirectorySelected = JGUIUtil.getLastFileDialogDirectory();

                JFileChooser fc = null;
                if (!string.ReferenceEquals(lastDirectorySelected, null))
                {
                    fc = new JFileChooser(lastDirectorySelected);
                }
                else
                {
                    fc = new JFileChooser();
                }

                fc.setDialogTitle("Select Output Control File");
                SimpleFileFilter @out = new SimpleFileFilter("out", "StateMod Output Control Files");
                fc.addChoosableFileFilter(@out);
                SimpleFileFilter tpl = new SimpleFileFilter("tpo", "StateMod Output Control Files");
                fc.addChoosableFileFilter(tpl);
                SimpleFileFilter xou = new SimpleFileFilter("xou", "StateMod Output Control Files");
                fc.addChoosableFileFilter(xou);
                fc.setAcceptAllFileFilterUsed(false);
                fc.setFileFilter(tpl);
                fc.setDialogType(JFileChooser.OPEN_DIALOG);

                JGUIUtil.setWaitCursor(this, false);
                int retVal = fc.showOpenDialog(this);
                if (retVal != JFileChooser.APPROVE_OPTION)
                {
                    return;
                }

                string currDir = (fc.getCurrentDirectory()).ToString();

                if (!currDir.Equals(lastDirectorySelected, StringComparison.OrdinalIgnoreCase))
                {
                    JGUIUtil.setLastFileDialogDirectory(currDir);
                }
                string filename = fc.getSelectedFile().getName();

                JGUIUtil.setWaitCursor(this, true);

                __dirty = false;

                System.Collections.IList theGraphNodes = new List <object>(20, 1);

                try
                {
                    __worksheet.clear();
                    __tableModel.setDirty(false);
                    StateMod_GraphNode.readStateModOutputControlFile(theGraphNodes, currDir + File.separator + filename);

                    int size             = theGraphNodes.Count;
                    StateMod_GraphNode g = null;
                    int row = 0;
                    for (int i = 0; i < size; i++)
                    {
                        row = __worksheet.getRowCount();
                        g   = (StateMod_GraphNode)theGraphNodes[i];
                        if (i == 0)
                        {
                            if (g.getID().Equals("All"))
                            {
                                __useAllJCheckBox.setSelected(true);
                            }
                            else
                            {
                                __useAllJCheckBox.setSelected(false);
                            }
                        }
                        __worksheet.addRow(g);

                        __tableModel.fillIDColumn(row, g.getType());
                    }
                    __worksheet.setData(theGraphNodes);
                }
                catch (Exception e)
                {
                    Message.printWarning(1, routine, "Error loading output control file\n" + "\"" + currDir + File.separator + filename + "\"", this);
                    Message.printWarning(2, routine, e);
                }
                JGUIUtil.setWaitCursor(this, false);
            }
            else if (action.Equals(__CHECKBOX_USE_ALL))
            {
                // if the use all checkbox is selected, subtle changes from the
                // default functionality are made.  The buttons to add and
                // delete rows are disabled, and the ID of the only record
                // in the worksheet is set to "All".  This ID value is used
                // in the table model to determine when the checkbox is
                // selected.  In addition, the ComboBox functionality of the
                // first and third data columns is turned off.

                if (__useAllJCheckBox.isSelected())
                {
                    __addRowButton.setEnabled(false);
                    __deleteRowButton.setEnabled(false);
                    __worksheet.setColumnJComboBoxValues(0, null);
                    __worksheet.setColumnJComboBoxValues(2, null);
                    __worksheet.clear();
                    StateMod_GraphNode g = new StateMod_GraphNode();
                    g.setID("All");
                    __worksheet.setCellEditable(0, 0, false);
                    __worksheet.setCellEditable(0, 1, false);
                    __worksheet.setCellEditable(0, 2, false);
                    __worksheet.addRow(g);
                }
                else
                {
                    __addRowButton.setEnabled(true);
                    __deleteRowButton.setEnabled(true);
                    System.Collections.IList v = StateMod_Util.arrayToList(StateMod_GraphNode.node_types);
                    v.Add("Other");
                    __worksheet.setColumnJComboBoxValues(0, v);
                    __worksheet.clear();
                    System.Collections.IList offOn = new List <object>();
                    offOn.Add("Off");
                    offOn.Add("On");
                    __worksheet.setCellEditable(0, 0, true);
                    __worksheet.setColumnJComboBoxValues(2, offOn);
                }
            }
        }