/// <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); } }