Пример #1
0
 /// <summary>
 /// Constructor. </summary>
 /// <param name="tableModel"> the table model for which this class renders cells. </param>
 public StateMod_InstreamFlowRight_CellRenderer(StateMod_InstreamFlowRight_TableModel tableModel)
 {
     __tableModel = tableModel;
 }
Пример #2
0
        /// <summary>
        /// Sets up the GUI.
        /// </summary>
        private void setupGUI()
        {
            string routine = "setupGUI";

            addWindowListener(this);

            __addRight    = new JButton(__BUTTON_ADD_RIGHT);
            __deleteRight = new JButton(__BUTTON_DEL_RIGHT);
            __deleteRight.setEnabled(false);
            __helpJButton = new JButton(__BUTTON_HELP);
            __helpJButton.setEnabled(false);
            __closeJButton = new JButton(__BUTTON_CLOSE);
            JButton cancelJButton = new JButton(__BUTTON_CANCEL);
            JButton applyJButton  = new JButton(__BUTTON_APPLY);

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

            bigPanel.setLayout(gb);

            FlowLayout fl = new FlowLayout(FlowLayout.RIGHT);
            JPanel     p1 = new JPanel();

            p1.setLayout(fl);

            GridLayout gl         = new GridLayout(2, 2, 1, 1);
            JPanel     info_panel = new JPanel();

            info_panel.setLayout(gl);

            JPanel main_panel = new JPanel();

            main_panel.setLayout(new BorderLayout());

            info_panel.add(new JLabel("Instream flow:"));
            info_panel.add(new JLabel(__currentInstreamFlow.getID()));
            info_panel.add(new JLabel("Instream flow name:"));
            info_panel.add(new JLabel(__currentInstreamFlow.getName()));

            if (__editable)
            {
                p1.add(__addRight);
                p1.add(__deleteRight);
            }
            p1.add(applyJButton);
            p1.add(cancelJButton);
            //	p1.add(__helpJButton);
            p1.add(__closeJButton);

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

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

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

            try
            {
                System.Collections.IList v  = new List <object>();
                System.Collections.IList v2 = __currentInstreamFlow.getRights();
                for (int i = 0; i < v2.Count; i++)
                {
                    v.Add(((StateMod_InstreamFlowRight)(v2[i])).clone());
                }
                StateMod_InstreamFlowRight_TableModel   tmi = new StateMod_InstreamFlowRight_TableModel(v, __editable, true);
                StateMod_InstreamFlowRight_CellRenderer cri = new StateMod_InstreamFlowRight_CellRenderer(tmi);

                jsw         = new JScrollWorksheet(cri, tmi, p);
                __worksheet = jsw.getJWorksheet();
                widths      = cri.getColumnWidths();
            }
            catch (Exception e)
            {
                Message.printWarning(2, routine, e);
                jsw         = new JScrollWorksheet(0, 0, p);
                __worksheet = jsw.getJWorksheet();
            }
            __worksheet.setPreferredScrollableViewportSize(null);
            __worksheet.setHourglassJFrame(this);
            __worksheet.addMouseListener(this);
            __worksheet.addKeyListener(this);

            System.Collections.IList v = new List <object>();
            v.Add("0 - Off");
            v.Add("1 - On");
            __worksheet.setColumnJComboBoxValues(StateMod_InstreamFlowRight_TableModel.COL_ON_OFF, v);

            main_panel.add(jsw, "Center");
            main_panel.add(p1, "South");

            JGUIUtil.addComponent(bigPanel, info_panel, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
            JGUIUtil.addComponent(bigPanel, main_panel, 0, 1, 10, 10, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.SOUTH);
            __addRight.addActionListener(this);
            __deleteRight.addActionListener(this);
            __helpJButton.addActionListener(this);
            __closeJButton.addActionListener(this);
            cancelJButton.addActionListener(this);
            applyJButton.addActionListener(this);

            getContentPane().add(bigPanel);

            JPanel bottomJPanel = new JPanel();

            bottomJPanel.setLayout(gb);
            __messageJTextField = new JTextField();
            __messageJTextField.setEditable(false);
            JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 0, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
            __statusJTextField = new JTextField(5);
            __statusJTextField.setEditable(false);
            JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            getContentPane().add("South", bottomJPanel);

            pack();
            setSize(700, 400);
            JGUIUtil.center(this);
            setVisible(true);

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