コード例 #1
0
 /// <summary>
 /// Constructor. </summary>
 /// <param name="tableModel"> the table model for which this class renders the cells. </param>
 public StateMod_DiversionRight_CellRenderer(StateMod_DiversionRight_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);
            __closeJButton = new JButton(__BUTTON_CLOSE);
            __helpJButton  = new JButton(__BUTTON_HELP);
            JButton cancelJButton = new JButton(__BUTTON_CANCEL);
            JButton applyJButton  = new JButton(__BUTTON_APPLY);

            __helpJButton.setEnabled(false);

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

            bigPanel.setLayout(gbl);

            JPanel p1 = new JPanel();

            p1.setLayout(new FlowLayout(FlowLayout.RIGHT));

            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("Diversion ID: "));
            info_panel.add(new JLabel(__currentDiv.getID()));
            info_panel.add(new JLabel("Diversion name: "));
            info_panel.add(new JLabel(__currentDiv.getName()));
            if (__editable)
            {
                p1.add(__addRight);
                p1.add(__deleteRight);
                __deleteRight.setEnabled(false);
            }
            //p1.add(__helpJButton);
            p1.add(applyJButton);
            p1.add(cancelJButton);
            p1.add(__closeJButton);

            PropList p = new PropList("StateMod_Diversion_Right_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 = __currentDiv.getRights();
                for (int i = 0; i < v2.Count; i++)
                {
                    v.Add(((StateMod_DiversionRight)(v2[i])).clone());
                }
                StateMod_DiversionRight_TableModel tmd = new StateMod_DiversionRight_TableModel(v, __editable, false);

                StateMod_DiversionRight_CellRenderer crd = new StateMod_DiversionRight_CellRenderer(tmd);

                jsw         = new JScrollWorksheet(crd, tmd, p);
                __worksheet = jsw.getJWorksheet();

                widths = crd.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);
            __worksheet.addMouseListener(this);
            __worksheet.addKeyListener(this);

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

            __worksheet.setColumnJComboBoxValues(StateMod_DiversionRight_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);

            getContentPane().add(bigPanel);

            JPanel bottomJPanel = new JPanel();

            bottomJPanel.setLayout(gbl);
            __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);

            __addRight.addActionListener(this);
            __deleteRight.addActionListener(this);
            __closeJButton.addActionListener(this);
            __helpJButton.addActionListener(this);
            cancelJButton.addActionListener(this);
            applyJButton.addActionListener(this);

            pack();
            setSize(600, 450);
            JGUIUtil.center(this);
            setVisible(true);

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