/// <summary> /// Sets up the GUI /// </summary> public virtual void setupGUI() { string routine = "setupGUI"; addWindowListener(this); __addDepletion = new JButton(__BUTTON_ADD_DEPLETION); __deleteDepletion = new JButton(__BUTTON_DELETE_DEPLETION); __deleteDepletion.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); // AWT portion GridBagLayout gb = new GridBagLayout(); JPanel mainJPanel = new JPanel(); mainJPanel.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("Well:")); info_panel.add(new JLabel(__currentWell.getID())); info_panel.add(new JLabel("Well name:")); info_panel.add(new JLabel(__currentWell.getName())); if (__editable) { p1.add(__addDepletion); p1.add(__deleteDepletion); } p1.add(applyJButton); p1.add(cancelJButton); // p1.add(__helpJButton); p1.add(__closeJButton); PropList p = new PropList("StateMod_Well_Depletion_JFrame.JWorksheet"); p.add("JWorksheet.ShowPopupMenu=true"); p.add("JWorksheet.AllowCopy=true"); p.add("JWorksheet.SelectionMode=SingleRowSelection"); int[] widths = null; JScrollWorksheet jsw = null; try { //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_RiverNetworkNode> nodes = (java.util.List<StateMod_RiverNetworkNode>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK).getData()); IList <StateMod_RiverNetworkNode> nodes = (IList <StateMod_RiverNetworkNode>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK).getData()); IList <StateMod_ReturnFlow> v = new List <StateMod_ReturnFlow>(); IList <StateMod_ReturnFlow> v2 = __currentWell.getDepletions(); StateMod_ReturnFlow rf; for (int i = 0; i < v2.Count; i++) { rf = (StateMod_ReturnFlow)v2[i].clone(); rf.setCrtnid(rf.getCrtnid() + StateMod_Util.findNameInVector(rf.getCrtnid(), nodes, true)); v.Add(rf); } StateMod_ReturnFlow_TableModel tmw = new StateMod_ReturnFlow_TableModel(__dataset, v, __editable, false); StateMod_ReturnFlow_CellRenderer crw = new StateMod_ReturnFlow_CellRenderer(tmw); jsw = new JScrollWorksheet(crw, tmw, p); __worksheet = jsw.getJWorksheet(); IList <string> ids = StateMod_Util.createIdentifierListFromStateModData(nodes, true, null); __worksheet.setColumnJComboBoxValues(StateMod_ReturnFlow_TableModel.COL_RIVER_NODE, ids, false); IList <StateMod_DelayTable> delayIDs = null; if (__dataset.getIday() == 1) { //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DelayTable> delayIDs0 = (java.util.List<StateMod_DelayTable>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_DAILY).getData()); IList <StateMod_DelayTable> delayIDs0 = (IList <StateMod_DelayTable>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_DAILY).getData()); delayIDs = delayIDs0; } else { //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DelayTable> delayIDs0 = (java.util.List<StateMod_DelayTable>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY).getData()); IList <StateMod_DelayTable> delayIDs0 = (IList <StateMod_DelayTable>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY).getData()); delayIDs = delayIDs0; } ids = StateMod_Util.createIdentifierListFromStateModData(delayIDs, true, null); __worksheet.setColumnJComboBoxValues(StateMod_ReturnFlow_TableModel.COL_RETURN_ID, ids, false); widths = crw.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); main_panel.add(jsw, "Center"); main_panel.add(p1, "South"); JGUIUtil.addComponent(mainJPanel, info_panel, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); JGUIUtil.addComponent(mainJPanel, main_panel, 0, 1, 10, 10, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.SOUTH); getContentPane().add(mainJPanel); 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); __addDepletion.addActionListener(this); __deleteDepletion.addActionListener(this); __closeJButton.addActionListener(this); __helpJButton.addActionListener(this); applyJButton.addActionListener(this); cancelJButton.addActionListener(this); pack(); setSize(520, 280); JGUIUtil.center(this); setVisible(true); if (widths != null) { __worksheet.setColumnWidths(widths); } }
/// <summary> /// Sets up the GUI. /// </summary> public virtual void setupGUI() { string routine = "setupGUI"; addWindowListener(this); __addPrecip = new JButton(__BUTTON_ADD_PRECIPITATION_STATION); __addEvap = new JButton(__BUTTON_ADD_EVAPORATION_STATION); __deleteStation = new JButton(__BUTTON_DELETE_PRECIPITATION_STATION); __deleteStation.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("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(__addPrecip); p1.add(__addEvap); p1.add(__deleteStation); } p1.add(applyJButton); p1.add(cancelJButton); // p1.add(__helpJButton); p1.add(__closeJButton); PropList p = new PropList("StateMod_Reservoir_Climate_JFrame.JWorksheet"); p.add("JWorksheet.ShowPopupMenu=true"); p.add("JWorksheet.AllowCopy=true"); p.add("JWorksheet.SelectionMode=SingleRowSelection"); int[] widthsP = null; JScrollWorksheet jswP = null; //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<String> stations = StateMod_Util.createIdentifierListFromTS(combineData((java.util.List<RTi.TS.MonthTS>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY).getData(), (java.util.List<RTi.TS.MonthTS>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY).getData()), true, null); IList <string> stations = StateMod_Util.createIdentifierListFromTS(combineData((IList <MonthTS>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY).getData(), (IList <MonthTS>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY).getData()), true, null); try { IList <StateMod_ReservoirClimate> temp = getPrecipitationStations(__currentRes.getClimates()); IList <StateMod_ReservoirClimate> clones = new List <StateMod_ReservoirClimate>(); StateMod_ReservoirClimate r = null; int size = temp.Count; for (int i = 0; i < size; i++) { r = temp[i]; clones.Add((StateMod_ReservoirClimate)r.clone()); } __tableModelP = new StateMod_ReservoirClimate_TableModel(clones, __editable, true); StateMod_ReservoirClimate_CellRenderer crr = new StateMod_ReservoirClimate_CellRenderer(__tableModelP); jswP = new JScrollWorksheet(crr, __tableModelP, p); __worksheetP = jswP.getJWorksheet(); __worksheetP.setColumnJComboBoxValues(StateMod_ReservoirClimate_TableModel.COL_STATION, stations, true); widthsP = crr.getColumnWidths(); } catch (Exception e) { Message.printWarning(1, routine, "Error building worksheet.", this); Message.printWarning(2, routine, e); jswP = new JScrollWorksheet(0, 0, p); __worksheetP = jswP.getJWorksheet(); } __worksheetP.setPreferredScrollableViewportSize(null); __worksheetP.setHourglassJFrame(this); __worksheetP.addMouseListener(this); __worksheetP.addKeyListener(this); int[] widthsE = null; JScrollWorksheet jswE = null; try { IList <StateMod_ReservoirClimate> temp = getEvaporationStations(__currentRes.getClimates()); IList <StateMod_ReservoirClimate> clones = new List <StateMod_ReservoirClimate>(); StateMod_ReservoirClimate r = null; int size = temp.Count; for (int i = 0; i < size; i++) { r = temp[i]; clones.Add((StateMod_ReservoirClimate)r.clone()); } __tableModelE = new StateMod_ReservoirClimate_TableModel(clones, __editable, true); StateMod_ReservoirClimate_CellRenderer crr = new StateMod_ReservoirClimate_CellRenderer(__tableModelE); jswE = new JScrollWorksheet(crr, __tableModelE, p); __worksheetE = jswE.getJWorksheet(); __worksheetE.setColumnJComboBoxValues(StateMod_ReservoirClimate_TableModel.COL_STATION, stations, true); widthsE = crr.getColumnWidths(); } catch (Exception e) { Message.printWarning(1, routine, "Error building worksheet.", this); Message.printWarning(2, routine, e); jswE = new JScrollWorksheet(0, 0, p); __worksheetE = jswE.getJWorksheet(); } __worksheetE.setPreferredScrollableViewportSize(null); __worksheetE.setHourglassJFrame(this); __worksheetE.addMouseListener(this); __worksheetE.addKeyListener(this); JPanel worksheets = new JPanel(); worksheets.setLayout(gb); JPanel panelP = new JPanel(); panelP.setLayout(gb); panelP.setBorder(BorderFactory.createTitledBorder("Precipitation Stations")); JGUIUtil.addComponent(panelP, jswP, 0, 0, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); JPanel panelE = new JPanel(); panelE.setLayout(gb); panelE.setBorder(BorderFactory.createTitledBorder("Evaporation Stations")); JGUIUtil.addComponent(panelE, jswE, 0, 0, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); JGUIUtil.addComponent(worksheets, panelP, 0, 0, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); JGUIUtil.addComponent(worksheets, panelE, 0, 1, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); main_panel.add(worksheets, "Center"); main_panel.add(p1, "South"); // assemble parts 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); __addEvap.addActionListener(this); __addPrecip.addActionListener(this); __deleteStation.addActionListener(this); __helpJButton.addActionListener(this); __closeJButton.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(650, 400); JGUIUtil.center(this); setVisible(true); if (widthsP != null) { __worksheetP.setColumnWidths(widthsP); } if (widthsE != null) { __worksheetE.setColumnWidths(widthsE); } }
/// <summary> /// Sets up the GUI. /// </summary> private void setupGUI() { string routine = "setupGUI"; addWindowListener(this); __addOwner = new JButton(__BUTTON_ADD_OWNER); __deleteOwner = new JButton(__BUTTON_DEL_OWNER); __deleteOwner.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("Reservoir ID:")); 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(__addOwner); p1.add(__deleteOwner); } 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 { IList <StateMod_ReservoirAccount> v = new List <StateMod_ReservoirAccount>(); IList <StateMod_ReservoirAccount> v2 = __currentRes.getAccounts(); StateMod_ReservoirAccount ra; for (int i = 0; i < v2.Count; i++) { ra = (StateMod_ReservoirAccount)v2[i].clone(); v.Add(ra); } StateMod_ReservoirAccount_TableModel tmr = new StateMod_ReservoirAccount_TableModel(v, __editable, true); StateMod_ReservoirAccount_CellRenderer crr = new StateMod_ReservoirAccount_CellRenderer(tmr); jsw = new JScrollWorksheet(crr, tmr, p); __worksheet = jsw.getJWorksheet(); IList <string> owner = StateMod_ReservoirAccount.getN2ownChoices(true); __worksheet.setColumnJComboBoxValues(StateMod_ReservoirAccount_TableModel.COL_OWNERSHIP_TIE, owner, 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); 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); __addOwner.addActionListener(this); __deleteOwner.addActionListener(this); __helpJButton.addActionListener(this); __closeJButton.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(700, 400); JGUIUtil.center(this); setVisible(true); if (widths != null) { __worksheet.setColumnWidths(widths); } }
/// <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); } }
/// <summary> /// Sets up the GUI. /// </summary> public virtual void setupGUI() { string routine = "setupGUI"; addWindowListener(this); PropList p = new PropList("StateMod_Reservoir_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 { IList <StateMod_ReservoirAccount> accounts = __currentRes.getAccounts(); IList <string> v3 = new List <string>(); int size = accounts.Count; StateMod_ReservoirAccount ra = null; for (int i = 0; i < size; i++) { ra = accounts[i]; v3.Add("" + ra.getID() + " - " + ra.getName()); } for (int i = 1; i < size; i++) { v3.Add("-" + (i + 1) + " - Fill first " + (i + 1) + " accounts"); } IList <StateMod_ReservoirRight> v = new List <StateMod_ReservoirRight>(); IList <StateMod_ReservoirRight> v2 = __currentRes.getRights(); StateMod_ReservoirRight rr; for (int i = 0; i < v2.Count; i++) { rr = (StateMod_ReservoirRight)v2[i].clone(); v.Add(rr); } StateMod_ReservoirRight_TableModel tmr = new StateMod_ReservoirRight_TableModel(v, __editable); StateMod_ReservoirRight_CellRenderer crr = new StateMod_ReservoirRight_CellRenderer(tmr); jsw = new JScrollWorksheet(crr, tmr, p); __worksheet = jsw.getJWorksheet(); IList <string> 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); IList <string> rightTypes = StateMod_ReservoirRight.getItyrsrChoices(true); __worksheet.setColumnJComboBoxValues(StateMod_ReservoirRight_TableModel.COL_RIGHT_TYPE, rightTypes, false); IList <string> 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); __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("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(__addRight); p1.add(__deleteRight); } p1.add(applyJButton); p1.add(cancelJButton); // p1.add(__helpJButton); p1.add(__closeJButton); 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); 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> /// Sets up the GUI. /// </summary> private void setupGUI() { string routine = "setupGUI"; addWindowListener(this); __addReturnFlow = new JButton(__BUTTON_ADD_RETURN_FLOW); __deleteReturnFlow = new JButton(__BUTTON_DEL_RETURN_FLOW); __deleteReturnFlow.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 mainJPanel = new JPanel(); mainJPanel.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("Well:")); info_panel.add(new JLabel(__currentWell.getID())); info_panel.add(new JLabel("Well name:")); info_panel.add(new JLabel(__currentWell.getName())); if (__editable) { p1.add(__addReturnFlow); p1.add(__deleteReturnFlow); } p1.add(applyJButton); p1.add(cancelJButton); // p1.add(__helpJButton); p1.add(__closeJButton); PropList p = new PropList("StateMod_Well_ReturnFlow_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 nodes = (System.Collections.IList)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK).getData()); System.Collections.IList v = new List <object>(); System.Collections.IList v2 = __currentWell.getReturnFlows(); StateMod_ReturnFlow rf; for (int i = 0; i < v2.Count; i++) { rf = (StateMod_ReturnFlow)((StateMod_ReturnFlow)v2[i]).clone(); rf.setCrtnid(rf.getCrtnid() + StateMod_Util.findNameInVector(rf.getCrtnid(), nodes, true)); v.Add(rf); } StateMod_ReturnFlow_TableModel tmw = new StateMod_ReturnFlow_TableModel(__dataset, v, __editable, true); StateMod_ReturnFlow_CellRenderer crw = new StateMod_ReturnFlow_CellRenderer(tmw); jsw = new JScrollWorksheet(crw, tmw, p); __worksheet = jsw.getJWorksheet(); v = StateMod_Util.createIdentifierListFromStateModData(nodes, true, null); __worksheet.setColumnJComboBoxValues(StateMod_ReturnFlow_TableModel.COL_RIVER_NODE, v, false); // 10 System.Collections.IList delayIDs = null; if (__dataset.getIday() == 1) { delayIDs = (System.Collections.IList)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_DAILY).getData()); } else { delayIDs = (System.Collections.IList)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY).getData()); } v = StateMod_Util.createIdentifierListFromStateModData(delayIDs, true, null); __worksheet.setColumnJComboBoxValues(StateMod_ReturnFlow_TableModel.COL_RETURN_ID, v, false); widths = crw.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); main_panel.add(jsw, "Center"); main_panel.add(p1, "South"); JGUIUtil.addComponent(mainJPanel, info_panel, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); JGUIUtil.addComponent(mainJPanel, main_panel, 0, 1, 10, 10, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.SOUTH); getContentPane().add(mainJPanel); 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); __addReturnFlow.addActionListener(this); __deleteReturnFlow.addActionListener(this); __closeJButton.addActionListener(this); __helpJButton.addActionListener(this); applyJButton.addActionListener(this); cancelJButton.addActionListener(this); pack(); setSize(520, 280); JGUIUtil.center(this); setVisible(true); if (widths != null) { __worksheet.setColumnWidths(widths); } }
/// <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); } }
/// <summary> /// Responds to action performed events. </summary> /// <param name="ae"> the ActionEvent that happened. </param> public virtual void actionPerformed(ActionEvent ae) { string routine = "StateMod_OutputControl_JFrame.actionPerformed"; string action = ae.getActionCommand(); if (action.Equals(__BUTTON_ADD_ROW)) { if (!__tableModel.canAddNewRow()) { return; } __dirty = true; int row = __worksheet.getRowCount(); StateMod_GraphNode n = new StateMod_GraphNode(); __worksheet.addRow(n); n.setType(""); n.setID(""); n.setSwitch(-1); __tableModel.setDirty(true); // when a row is added, mark the second and third columns // as uneditable. They will be set to editable as soon as // the user enters a value in the first column __worksheet.setCellEditable(row, 1, false); __worksheet.setCellEditable(row, 2, false); } else if (action.Equals(__BUTTON_CLEAR_LIST)) { __dirty = true; __worksheet.clear(); setMessages("Add station to list.", "Ready"); __tableModel.setDirty(true); } else if (action.Equals(__BUTTON_CLOSE)) { closeWindow(); } else if (action.Equals(__BUTTON_DELETE_ROW)) { int[] rows = __worksheet.getSelectedRows(); int length = rows.Length; __tableModel.setDirty(true); if (length == 0) { return; } for (int i = (length - 1); i >= 0; i--) { __worksheet.deleteRow(rows[i]); } __dirty = true; setMessages("Time series list has changed.", "Ready"); } else if (action.Equals(__BUTTON_HELP)) { // REVISIT HELP (JTS - 2003-07-09) } else if (action.Equals(__BUTTON_SAVE_FILE)) { JGUIUtil.setWaitCursor(this, true); string lastDirectorySelected = JGUIUtil.getLastFileDialogDirectory(); JFileChooser fc = null; if (!string.ReferenceEquals(lastDirectorySelected, null)) { fc = new JFileChooser(lastDirectorySelected); } else { fc = new JFileChooser(); } fc.setDialogTitle("Select Output Control File"); SimpleFileFilter @out = new SimpleFileFilter("out", "StateMod Output Control Files"); fc.addChoosableFileFilter(@out); SimpleFileFilter tpl = new SimpleFileFilter("tpo", "StateMod Output Control Files"); fc.addChoosableFileFilter(tpl); SimpleFileFilter xou = new SimpleFileFilter("xou", "StateMod Output Control Files"); fc.addChoosableFileFilter(xou); fc.setAcceptAllFileFilterUsed(false); fc.setFileFilter(tpl); fc.setDialogType(JFileChooser.SAVE_DIALOG); JGUIUtil.setWaitCursor(this, false); int retVal = fc.showSaveDialog(this); if (retVal != JFileChooser.APPROVE_OPTION) { return; } string currDir = (fc.getCurrentDirectory()).ToString(); if (!currDir.Equals(lastDirectorySelected, StringComparison.OrdinalIgnoreCase)) { JGUIUtil.setLastFileDialogDirectory(currDir); } string filename = fc.getSelectedFile().getName(); FileFilter ff = fc.getFileFilter(); if (ff == @out) { filename = IOUtil.enforceFileExtension(filename, "out"); } else if (ff == tpl) { filename = IOUtil.enforceFileExtension(filename, "tpo"); } else if (ff == xou) { filename = IOUtil.enforceFileExtension(filename, "xou"); } __dirty = false; __tableModel.setDirty(false); System.Collections.IList theGraphNodes = __worksheet.getAllData(); try { StateMod_GraphNode.writeStateModOutputControlFile(null, currDir + File.separator + filename, theGraphNodes, null); } catch (Exception e) { Message.printWarning(1, routine, "Error saving output control file\n" + "\"" + currDir + File.separator + filename + "\"", this); Message.printWarning(2, routine, e); } } else if (action.Equals(__BUTTON_LOAD_FILE)) { JGUIUtil.setWaitCursor(this, true); string lastDirectorySelected = JGUIUtil.getLastFileDialogDirectory(); JFileChooser fc = null; if (!string.ReferenceEquals(lastDirectorySelected, null)) { fc = new JFileChooser(lastDirectorySelected); } else { fc = new JFileChooser(); } fc.setDialogTitle("Select Output Control File"); SimpleFileFilter @out = new SimpleFileFilter("out", "StateMod Output Control Files"); fc.addChoosableFileFilter(@out); SimpleFileFilter tpl = new SimpleFileFilter("tpo", "StateMod Output Control Files"); fc.addChoosableFileFilter(tpl); SimpleFileFilter xou = new SimpleFileFilter("xou", "StateMod Output Control Files"); fc.addChoosableFileFilter(xou); fc.setAcceptAllFileFilterUsed(false); fc.setFileFilter(tpl); fc.setDialogType(JFileChooser.OPEN_DIALOG); JGUIUtil.setWaitCursor(this, false); int retVal = fc.showOpenDialog(this); if (retVal != JFileChooser.APPROVE_OPTION) { return; } string currDir = (fc.getCurrentDirectory()).ToString(); if (!currDir.Equals(lastDirectorySelected, StringComparison.OrdinalIgnoreCase)) { JGUIUtil.setLastFileDialogDirectory(currDir); } string filename = fc.getSelectedFile().getName(); JGUIUtil.setWaitCursor(this, true); __dirty = false; System.Collections.IList theGraphNodes = new List <object>(20, 1); try { __worksheet.clear(); __tableModel.setDirty(false); StateMod_GraphNode.readStateModOutputControlFile(theGraphNodes, currDir + File.separator + filename); int size = theGraphNodes.Count; StateMod_GraphNode g = null; int row = 0; for (int i = 0; i < size; i++) { row = __worksheet.getRowCount(); g = (StateMod_GraphNode)theGraphNodes[i]; if (i == 0) { if (g.getID().Equals("All")) { __useAllJCheckBox.setSelected(true); } else { __useAllJCheckBox.setSelected(false); } } __worksheet.addRow(g); __tableModel.fillIDColumn(row, g.getType()); } __worksheet.setData(theGraphNodes); } catch (Exception e) { Message.printWarning(1, routine, "Error loading output control file\n" + "\"" + currDir + File.separator + filename + "\"", this); Message.printWarning(2, routine, e); } JGUIUtil.setWaitCursor(this, false); } else if (action.Equals(__CHECKBOX_USE_ALL)) { // if the use all checkbox is selected, subtle changes from the // default functionality are made. The buttons to add and // delete rows are disabled, and the ID of the only record // in the worksheet is set to "All". This ID value is used // in the table model to determine when the checkbox is // selected. In addition, the ComboBox functionality of the // first and third data columns is turned off. if (__useAllJCheckBox.isSelected()) { __addRowButton.setEnabled(false); __deleteRowButton.setEnabled(false); __worksheet.setColumnJComboBoxValues(0, null); __worksheet.setColumnJComboBoxValues(2, null); __worksheet.clear(); StateMod_GraphNode g = new StateMod_GraphNode(); g.setID("All"); __worksheet.setCellEditable(0, 0, false); __worksheet.setCellEditable(0, 1, false); __worksheet.setCellEditable(0, 2, false); __worksheet.addRow(g); } else { __addRowButton.setEnabled(true); __deleteRowButton.setEnabled(true); System.Collections.IList v = StateMod_Util.arrayToList(StateMod_GraphNode.node_types); v.Add("Other"); __worksheet.setColumnJComboBoxValues(0, v); __worksheet.clear(); System.Collections.IList offOn = new List <object>(); offOn.Add("Off"); offOn.Add("On"); __worksheet.setCellEditable(0, 0, true); __worksheet.setColumnJComboBoxValues(2, offOn); } } }