/// <summary> /// Creates a JScrollWorksheet for the current data and returns it. </summary> /// <returns> a JScrollWorksheet containing the data Vector passed in to the constructor. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: protected RTi.Util.GUI.JScrollWorksheet buildJScrollWorksheet() throws Exception protected internal override JScrollWorksheet buildJScrollWorksheet() { StateMod_Reservoir_Return_Data_TableModel tableModel = new StateMod_Reservoir_Return_Data_TableModel(_data, _editable); StateMod_Reservoir_Return_Data_CellRenderer cellRenderer = new StateMod_Reservoir_Return_Data_CellRenderer(tableModel); // Note (JTS - 2005-03-31) // while it would seem the right thing to do would be to here assign // the table model to __tableModel, JTS found that in practice for // some reason once the constructor was returned to (in order to finish // building the GUI with checkbox) that the table model was then // null! JTS didn't understand why it was happening but didn't // want to spend too long investigating. // _props is defined in the super class return(new JScrollWorksheet(cellRenderer, tableModel, _props)); }
/// <summary> /// Sets up the GUI. /// </summary> public virtual void setupGUI() { string routine = "setupGUI"; addWindowListener(this); PropList p = new PropList("StateMod_Reservoir_Return_JFrame.JWorksheet"); p.add("JWorksheet.AllowCopy=true"); p.add("JWorksheet.CellFont=Courier"); p.add("JWorksheet.CellStyle=Plain"); p.add("JWorksheet.CellSize=11"); p.add("JWorksheet.HeaderFont=Arial"); p.add("JWorksheet.HeaderStyle=Plain"); p.add("JWorksheet.HeaderSize=11"); p.add("JWorksheet.HeaderBackground=LightGray"); p.add("JWorksheet.RowColumnPresent=false"); p.add("JWorksheet.ShowPopupMenu=true"); p.add("JWorksheet.SelectionMode=SingleRowSelection"); int[] widths = null; JScrollWorksheet jsw = null; try { /* TODO SAM 2011-01-02 Comment out - might allow something similar if editing is enabled * and choices of IDs are provided * List accounts = __currentRes.getAccounts(); * List v3 = new Vector(); * int size = accounts.size(); * StateMod_ReservoirAccount ra = null; * for (int i = 0; i < size; i++) { * ra = (StateMod_ReservoirAccount)accounts.get(i); * v3.add("" + ra.getID() + " - " + ra.getName()); * } * for (int i = 1; i < size; i++) { * v3.add("-" + (i + 1) + " - Fill first " + (i + 1) + " accounts"); + } + + List v = new Vector(); + List v2 = __currentRes.getRights(); + StateMod_ReservoirRight rr; + for (int i = 0; i < v2.size(); i++) { + rr = (StateMod_ReservoirRight) + ((StateMod_ReservoirRight)v2.get(i)) + .clone(); + v.add(rr); + } */ // Get the list of all returns and filter for this reservoir // TODO SAM 2011-01-02 The code needs to use a table model with lists if editing is enabled StateMod_Reservoir_Return_Data_TableModel tmr = new StateMod_Reservoir_Return_Data_TableModel(__currentResReturnList, __editable); StateMod_Reservoir_Return_Data_CellRenderer crr = new StateMod_Reservoir_Return_Data_CellRenderer(tmr); jsw = new JScrollWorksheet(crr, tmr, p); __worksheet = jsw.getJWorksheet(); /* * List onOff = StateMod_ReservoirRight.getIrsrswChoices(true); * __worksheet.setColumnJComboBoxValues( * StateMod_ReservoirRight_TableModel.COL_ON_OFF, onOff, * false); * __worksheet.setColumnJComboBoxValues( * StateMod_ReservoirRight_TableModel.COL_ACCOUNT_DIST, * v3, false); * List rightTypes = * StateMod_ReservoirRight.getItyrsrChoices(true); * __worksheet.setColumnJComboBoxValues( * StateMod_ReservoirRight_TableModel.COL_RIGHT_TYPE, * rightTypes, false); * List fillTypes=StateMod_ReservoirRight.getN2fillChoices(true); * __worksheet.setColumnJComboBoxValues( * StateMod_ReservoirRight_TableModel.COL_FILL_TYPE, * fillTypes, false); */ widths = crr.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); __addReturn_JButton = new JButton(__BUTTON_ADD_RETURN); __deleteReturn_JButton = new JButton(__BUTTON_DEL_RETURN); __deleteReturn_JButton.setEnabled(false); __help_JButton = new JButton(__BUTTON_HELP); __help_JButton.setEnabled(false); __close_JButton = 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("Reservoir:")); info_panel.add(new JLabel(__currentRes.getID())); info_panel.add(new JLabel("Reservoir name:")); info_panel.add(new JLabel(__currentRes.getName())); if (__editable) { p1.add(__addReturn_JButton); p1.add(__deleteReturn_JButton); } p1.add(applyJButton); p1.add(cancelJButton); // p1.add(__helpJButton); p1.add(__close_JButton); if (!__editable) { applyJButton.setEnabled(false); applyJButton.setToolTipText("Editing reservoir return data is not implemented."); __close_JButton.setEnabled(false); __close_JButton.setToolTipText("Editing reservoir return data is not implemented."); } 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); __addReturn_JButton.addActionListener(this); __deleteReturn_JButton.addActionListener(this); __help_JButton.addActionListener(this); __close_JButton.addActionListener(this); applyJButton.addActionListener(this); cancelJButton.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(760, 400); JGUIUtil.center(this); setVisible(true); if (widths != null) { __worksheet.setColumnWidths(widths); } }
/// <summary> /// Constructor. </summary> /// <param name="tableModel"> the tableModel for which this will render the cells </param> public StateMod_Reservoir_Return_Data_CellRenderer(StateMod_Reservoir_Return_Data_TableModel tableModel) { __tableModel = tableModel; }