/// <summary>
 /// Constructor. </summary>
 /// <param name="tableModel"> the table model for which to render cells </param>
 public StateMod_OutputControl_CellRenderer(StateMod_OutputControl_TableModel tableModel)
 {
     __tableModel = tableModel;
 }
        /// <summary>
        /// Sets up the GUI.
        /// </summary>
        private void setupGUI()
        {
            string routine = "setupGUI";

            addWindowListener(this);

            __addRowButton         = new SimpleJButton(__BUTTON_ADD_ROW, this);
            __deleteRowButton      = new SimpleJButton(__BUTTON_DELETE_ROW, this);
            __saveTemplateButton   = new SimpleJButton(__BUTTON_SAVE_FILE, this);
            __clearWorksheetButton = new SimpleJButton(__BUTTON_CLEAR_LIST, this);
            __loadTemplateButton   = new SimpleJButton(__BUTTON_LOAD_FILE, this);
            __helpButton           = new SimpleJButton(__BUTTON_HELP, this);
            __helpButton.setEnabled(false);
            __closeButton = new SimpleJButton(__BUTTON_CLOSE, this);

            __useAllJCheckBox = new JCheckBox(__CHECKBOX_USE_ALL, false);
            __useAllJCheckBox.addActionListener(this);

            // Make a main panel to be the resizable body of the frame...

            JPanel        main_JPanel = new JPanel();
            GridBagLayout gb          = new GridBagLayout();

            main_JPanel.setLayout(gb);

            GridLayout gl        = new GridLayout(2, 2, 2, 2);
            JPanel     top_panel = new JPanel();

            top_panel.setLayout(gl);

            JPanel radio_panel = new JPanel();

            radio_panel.setLayout(gb);

            GridLayout gl2           = new GridLayout(1, 0, 2, 0);
            JPanel     bottom_JPanel = new JPanel();

            bottom_JPanel.setLayout(gl2);

            FlowLayout fl = new FlowLayout(FlowLayout.CENTER);
            JPanel     final_button_JPanel = new JPanel();

            final_button_JPanel.setLayout(fl);

            JPanel grid_JPanel = new JPanel();

            grid_JPanel.setLayout(gb);


            // add add a row, delete selected rows, clear spreadsheet,
            // select template, save template buttons
            top_panel.add(__addRowButton);
            top_panel.add(__deleteRowButton);
            top_panel.add(__clearWorksheetButton);
            top_panel.add(__loadTemplateButton);
            int y = 0;

            JGUIUtil.addComponent(main_JPanel, top_panel, 0, y, 10, 3, 0, 0, 10, 10, 10, 10, GridBagConstraints.NONE, GridBagConstraints.NORTH);

            y += 3;
            JGUIUtil.addComponent(main_JPanel, __useAllJCheckBox, 0, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);

            PropList p = new PropList("StateMod_OutputControl_JFrame.JWorksheet");

            p.add("JWorksheet.ShowRowHeader=true");
            p.add("JWorksheet.AllowCopy=true");
            p.add("JWorksheet.ShowPopupMenu=true");

            int[]            widths = null;
            JScrollWorksheet jsw    = null;

            try
            {
                __tableModel = new StateMod_OutputControl_TableModel(this, new List <object>(), (System.Collections.IList)__riverNetworkComp.getData());

                StateMod_OutputControl_CellRenderer cro = new StateMod_OutputControl_CellRenderer(__tableModel);

                jsw         = new JScrollWorksheet(cro, __tableModel, p);
                __worksheet = jsw.getJWorksheet();

                System.Collections.IList v = StateMod_Util.arrayToList(StateMod_GraphNode.node_types);
                v.Add("Other");
                __worksheet.setColumnJComboBoxValues(0, v);

                __worksheet.setCellSpecificJComboBoxColumn(1, false);

                System.Collections.IList offOn = new List <object>();
                offOn.Add("Off");
                offOn.Add("On");
                __worksheet.setColumnJComboBoxValues(2, offOn);

                __tableModel.setWorksheet(__worksheet);

                widths = cro.getColumnWidths();
            }
            catch (Exception e)
            {
                Message.printWarning(1, routine, "Error building worksheet.");
                Message.printWarning(2, routine, e);
                jsw         = new JScrollWorksheet(0, 0, p);
                __worksheet = jsw.getJWorksheet();
            }
            __worksheet.setPreferredScrollableViewportSize(null);
            __worksheet.setHourglassJFrame(this);

            JGUIUtil.addComponent(grid_JPanel, jsw, 0, 0, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.CENTER);

            JGUIUtil.addComponent(main_JPanel, grid_JPanel, 0, ++y, 10, 12, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.CENTER);

            y += 11;     // To account for grid height

            // Add bottom buttons - these are alphabetical so be
            //	careful if you add more ...

            final_button_JPanel.add(__closeButton);
            // REVISIT SAM 2006-03-04
            // Help is not currently enabled
            //final_button_JPanel.add(__helpButton);
            final_button_JPanel.add(__saveTemplateButton);

            // Add the final buttons on the bottom to the bottom panel...
            bottom_JPanel.add(final_button_JPanel);
            // Add the button panel to the frame...
            JGUIUtil.addComponent(main_JPanel, bottom_JPanel, 0, ++y, 10, 1, 0, 0, GridBagConstraints.VERTICAL, GridBagConstraints.SOUTH);

            // Add the main panel as the resizable content...

            getContentPane().add("Center", main_JPanel);

            // Add JTextFields for messages...
            JPanel message_JPanel = new JPanel();

            message_JPanel.setLayout(gb);
            __messageJTextField = new JTextField();
            __messageJTextField.setEditable(false);
            __statusJTextField = new JTextField("             ");
            __statusJTextField.setEditable(false);
            JGUIUtil.addComponent(message_JPanel, __messageJTextField, 0, 0, 9, 1, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
            JGUIUtil.addComponent(message_JPanel, __statusJTextField, 9, 0, 1, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.SOUTH);
            getContentPane().add("South", message_JPanel);

            pack();
            setSize(670, 500);
            JGUIUtil.center(this);
            setVisible(true);

            if (widths != null)
            {
                __worksheet.setColumnWidths(widths);
            }
        }