Example #1
0
        /// <summary>
        /// Constructor. </summary>
        /// <param name="data"> the data to display in the worksheet.  Can be null or empty. </param>
        /// <param name="titleString"> the String to display as the GUI title. </param>
        /// <param name="editable"> whether the data in the JFrame can be edited or not.  If true
        /// the data can be edited, if false they can not. </param>
        /// <exception cref="Exception"> if there is an error building the worksheet. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public StateMod_Diversion_DelayTableAssignment_Data_JFrame(java.util.List data, String titleString, boolean editable) throws Exception
        public StateMod_Diversion_DelayTableAssignment_Data_JFrame(System.Collections.IList data, string titleString, bool editable) : base(data, titleString, editable)
        {
            JPanel panel = new JPanel();

            panel.setLayout(new GridBagLayout());
            JLabel label = new JLabel("Show totals: ");

            JGUIUtil.addComponent(panel, label, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            __checkBox = new JCheckBox((string)null, true);
            __checkBox.addActionListener(this);
            JGUIUtil.addComponent(panel, __checkBox, 1, 0, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST);
            getContentPane().add("North", panel);
            pack();

            setSize(410, getHeight());
            __tableModel = (StateMod_Diversion_DelayTableAssignment_Data_TableModel)_worksheet.getTableModel();
            __tableModel.setJWorksheet(_worksheet);
        }
        /// <summary>
        /// Sets up the GUI.
        /// </summary>
        private void setupGUI()
        {
            addWindowListener(__parent);

            JPanel panel = new JPanel();

            panel.setLayout(new GridBagLayout());

            int y = 0;

            __downstreamIDJTextField = new JTextField(10);
            __downstreamIDJTextField.setEditable(false);
            __downstreamIDJTextField.setText(__ds.getCommonID());
            __upstreamIDComboBox = new SimpleJComboBox(false);
            __upstreamIDComboBox.setPrototypeDisplayValue("[none] - Start a new TributaryXX");
            __nodeNameJTextField = new JTextField(10);
            __nodeNameJTextField.addKeyListener(this);

            string[] usid = __ds.getUpstreamNodesIDs();
            for (int i = 0; i < usid.Length; i++)
            {
                __upstreamIDComboBox.add(usid[i]);
            }
            __upstreamIDComboBox.add("[none] - Start a new Tributary");

            __nodeTypeComboBox = new SimpleJComboBox();

            __nodeTypeComboBox.add(__NODE_CONFLUENCE);
            __nodeTypeComboBox.add(__NODE_DIVERSION);
            __nodeTypeComboBox.add(__NODE_DIVERSION_AND_WELL);
            __nodeTypeComboBox.add(__NODE_INSTREAM_FLOW);
            __nodeTypeComboBox.add(__NODE_OTHER);
            __nodeTypeComboBox.add(__NODE_PLAN);
            __nodeTypeComboBox.add(__NODE_RESERVOIR);
            __nodeTypeComboBox.add(__NODE_STREAMFLOW);
            __nodeTypeComboBox.add(__NODE_WELL);
            __nodeTypeComboBox.add(__NODE_XCONFLUENCE);
            __nodeTypeComboBox.select(__NODE_STREAMFLOW);
            __nodeTypeComboBox.setMaximumRowCount(__nodeTypeComboBox.getItemCount());
            __nodeTypeComboBox.addActionListener(this);

            __naturalFlowJCheckBox = new JCheckBox();
            __naturalFlowJCheckBox.addActionListener(this);

            __importJCheckBox = new JCheckBox();
            __importJCheckBox.addActionListener(this);

            JPanel top = new JPanel();

            top.setLayout(new GridBagLayout());
            top.setBorder(BorderFactory.createTitledBorder("Existing nodes"));

            JPanel bottom = new JPanel();

            bottom.setLayout(new GridBagLayout());
            bottom.setBorder(BorderFactory.createTitledBorder("New Node Data"));

            JGUIUtil.addComponent(panel, top, 0, 0, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.WEST);
            JGUIUtil.addComponent(panel, bottom, 0, 1, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.WEST);

            y = 0;
            JGUIUtil.addComponent(top, new JLabel("Downstream node: "), 0, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST);
            JGUIUtil.addComponent(top, __downstreamIDJTextField, 1, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST);
            y++;

            JGUIUtil.addComponent(top, new JLabel("Upstream node: "), 0, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST);
            JGUIUtil.addComponent(top, __upstreamIDComboBox, 1, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST);
            y++;

            y = 0;
            JGUIUtil.addComponent(bottom, new JLabel("Node ID: "), 0, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST);
            JGUIUtil.addComponent(bottom, __nodeNameJTextField, 1, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST);
            y++;

            JGUIUtil.addComponent(bottom, new JLabel("Node type: "), 0, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST);
            JGUIUtil.addComponent(bottom, __nodeTypeComboBox, 1, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST);
            y++;

            JGUIUtil.addComponent(bottom, new JLabel("Is natural flow?: "), 0, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST);
            JGUIUtil.addComponent(bottom, __naturalFlowJCheckBox, 1, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST);
            y++;

            JGUIUtil.addComponent(bottom, new JLabel("Is import?: "), 0, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST);
            JGUIUtil.addComponent(bottom, __importJCheckBox, 1, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST);

            JPanel southPanel = new JPanel();

            southPanel.setLayout(new GridBagLayout());

            __okJButton = new JButton(__BUTTON_OK);
            __okJButton.addActionListener(this);
            __okJButton.setEnabled(false);
            JButton cancelButton = new JButton(__BUTTON_CANCEL);

            cancelButton.addActionListener(this);

            JGUIUtil.addComponent(southPanel, __okJButton, 0, 0, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST);
            JGUIUtil.addComponent(southPanel, cancelButton, 1, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST);

            getContentPane().add(panel);
            getContentPane().add(southPanel, "South");

            pack();
            JGUIUtil.center(this);
            setVisible(true);
        }