/// <summary> /// Responds to button presses. </summary> /// <param name="event"> the ActionEvent that happened. </param> public virtual void actionPerformed(ActionEvent @event) { string command = @event.getActionCommand(); if (command.Equals(__BUTTON_APPLY)) { applyChanges(); __node = __parent.getAnnotationNode(__nodeNum); __applyButton.setEnabled(false); __okButton.setEnabled(false); } else if (command.Equals(__BUTTON_CANCEL)) { closeWindow(); } else if (command.Equals(__BUTTON_OK)) { if (__editable) { applyChanges(); } closeWindow(); } else { // a combo box action triggered it. validateData(); } }
private void checkValidity() { if (!__node1ComboBox.getSelected().Equals(__node2ComboBox.getSelected())) { __okJButton.setEnabled(true); } else { __okJButton.setEnabled(false); } }
/// <summary> /// Checks to make sure that the name entered in the node name field is valid. /// </summary> private void checkValidity() { if (!__nodeNameJTextField.getText().Trim().Equals("")) { __okJButton.setEnabled(true); } else { __okJButton.setEnabled(false); } }
/// <summary> /// Sets up the GUI. /// </summary> private void setupGUI() { string routine = "setupGUI"; addWindowListener(this); __addAreaCap = new JButton(__BUTTON_ADD_AREA_CAPACITY); __deleteAreaCap = new JButton(__BUTTON_DEL_AREA_CAPACITY); __deleteAreaCap.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 p0 = new JPanel(); p0.setLayout(fl); p0.add(__GraphArea_JButton = new SimpleJButton(__GraphArea_String, __GraphArea_String, this)); p0.add(__GraphSeepage_JButton = new SimpleJButton(__GraphSeepage_String, __GraphSeepage_String, this)); 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())); JPanel p1 = new JPanel(); p1.setLayout(fl); if (__editable) { p1.add(__addAreaCap); p1.add(__deleteAreaCap); } p1.add(applyJButton); p1.add(cancelJButton); // p1.add(__helpJButton); p1.add(__closeJButton); PropList p = new PropList("StateMod_Reservoir__AreaCap_JFrame.JWorksheet"); /* * 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.AllowCopy=true"); p.add("JWorksheet.SelectionMode=SingleRowSelection"); int[] widths = null; JScrollWorksheet jsw = null; try { IList <StateMod_ReservoirAreaCap> v = new List <StateMod_ReservoirAreaCap>(); IList <StateMod_ReservoirAreaCap> v2 = __currentRes.getAreaCaps(); for (int i = 0; i < v2.Count; i++) { v.Add((StateMod_ReservoirAreaCap)v2[i].clone()); } StateMod_ReservoirAreaCap_TableModel tmr = new StateMod_ReservoirAreaCap_TableModel(v, __editable, true); StateMod_ReservoirAreaCap_CellRenderer crr = new StateMod_ReservoirAreaCap_CellRenderer(tmr); jsw = new JScrollWorksheet(crr, tmr, p); __worksheet = jsw.getJWorksheet(); 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"); // Does not work well... //main_panel.add(p1, "South"); // assemble parts JGUIUtil.addComponent(bigPanel, info_panel, 0, 0, 1, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST); JGUIUtil.addComponent(bigPanel, jsw, 0, 1, 10, 10, 1.0, 1.0, GridBagConstraints.BOTH, GridBagConstraints.SOUTH); JPanel button_panel = new JPanel(); button_panel.setLayout(gb); JGUIUtil.addComponent(button_panel, p0, 0, 0, 10, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.SOUTHEAST); JGUIUtil.addComponent(button_panel, p1, 0, 1, 10, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.SOUTHEAST); JGUIUtil.addComponent(bigPanel, button_panel, 0, 11, 10, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.SOUTHEAST); __addAreaCap.addActionListener(this); __deleteAreaCap.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(); checkGUIState(); setSize(420, 400); 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> /// <param name="index"> the index in the worksheet to first select </param> private void setupGUI(int index) { string routine = "setupGUI"; addWindowListener(this); JPanel p1 = new JPanel(); // first 6 months' effeciency //JPanel p2 = new JPanel(); // last 6 months' effeciency JPanel p3 = new JPanel(); // div sta id -> switch for diversion JPanel p4 = new JPanel(); // user name -> data type switch JPanel left_panel = new JPanel(); // multilist and search area JPanel right_panel = new JPanel(); // everything else __cropIDJTextField = new JTextField(12); __nameJTextField = new JTextField(24); __plantMonthJTextField = new JTextField(6); __plantDayJTextField = new JTextField(6); __harvestMonthJTextField = new JTextField(6); __harvestDayJTextField = new JTextField(6); __daysToCoverJTextField = new JTextField(6); __seasonLengthJTextField = new JTextField(6); __earliestValueJTextField = new JTextField(6); __latestValueJTextField = new JTextField(6); __maxRootFeetJTextField = new JTextField(6); __maxAppDepthJTextField = new JTextField(6); __firstDaysBetweenJTextField = new JTextField(6); __secondDaysBetweenJTextField = new JTextField(6); IList <string> v = new List <string>(); v.Add(__0_MEAN_TEMP); v.Add(__1_28_DEG_FROST); v.Add(__2_32_DEG_FROST); v.Add(__999_NONE); __earliestFlagComboBox = new SimpleJComboBox(v); __latestFlagComboBox = new SimpleJComboBox(v); __searchID = new JTextField(10); __searchName = new JTextField(10); __searchName.setEditable(false); __findNextCrop = new JButton(__BUTTON_FIND_NEXT); __searchCriteriaGroup = new ButtonGroup(); __searchIDJRadioButton = new JRadioButton(__BUTTON_ID, true); __searchNameJRadioButton = new JRadioButton(__BUTTON_NAME, false); __searchCriteriaGroup.add(__searchIDJRadioButton); __searchCriteriaGroup.add(__searchNameJRadioButton); JButton applyJButton = new JButton(__BUTTON_APPLY); JButton cancelJButton = new JButton(__BUTTON_CANCEL); JButton helpJButton = new JButton(__BUTTON_HELP); helpJButton.setEnabled(false); JButton closeJButton = new JButton(__BUTTON_CLOSE); GridBagLayout gb = new GridBagLayout(); JPanel mainJPanel = new JPanel(); mainJPanel.setLayout(gb); p1.setLayout(new GridLayout(4, 6, 2, 0)); p3.setLayout(gb); p4.setLayout(gb); right_panel.setLayout(gb); left_panel.setLayout(gb); int y; PropList p = new PropList("StateCU_CropCharacteristics_JFrame.JWorksheet"); 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; try { StateCU_CropCharacteristics_TableModel tmw = new StateCU_CropCharacteristics_TableModel(__cropsVector); StateCU_CropCharacteristics_CellRenderer crw = new StateCU_CropCharacteristics_CellRenderer(tmw); __worksheet = new JWorksheet(crw, tmw, p); __worksheet.removeColumn(3); __worksheet.removeColumn(4); widths = crw.getColumnWidths(); } catch (Exception e) { Message.printWarning(2, routine, e); __worksheet = new JWorksheet(0, 0, p); Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } __worksheet.setPreferredScrollableViewportSize(null); __worksheet.setHourglassJFrame(this); __worksheet.addMouseListener(this); __worksheet.addKeyListener(this); JGUIUtil.addComponent(left_panel, new JScrollPane(__worksheet), 0, 0, 6, 14, 1, 1, 0, 0, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.CENTER); y = 0; JGUIUtil.addComponent(p3, new JLabel("Crop ID:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __cropIDJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); __cropIDJTextField.setEditable(false); y++; JGUIUtil.addComponent(p3, new JLabel("Name:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __nameJTextField, 1, y, 3, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Planting Month and Day:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __plantMonthJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, __plantDayJTextField, 2, y, 2, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Harvest Month and Day:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __harvestMonthJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, __harvestDayJTextField, 2, y, 2, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Days to Full Cover:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __daysToCoverJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Length of Season (days):"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __seasonLengthJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Earliest Moisture Use:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __earliestFlagComboBox, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, new JLabel("Value (F Deg.):"), 2, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, __earliestValueJTextField, 3, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Latest Moisture Use:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __latestFlagComboBox, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, new JLabel("Value (F Deg.):"), 2, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, __latestValueJTextField, 3, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Maximum Root Zone (feet):"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __maxRootFeetJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Maximum Application Depth (inches):"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __maxAppDepthJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Days between 1st and 2nd cuttings:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __firstDaysBetweenJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Days between 2nd and 3rd cuttings:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __secondDaysBetweenJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); // two top panels of info JGUIUtil.addComponent(right_panel, p3, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); int[] widths2 = null; try { __blaneyModel = new StateCU_CropCharacteristics_TableModel(__cropsVector); StateCU_CropCharacteristics_CellRenderer crw = new StateCU_CropCharacteristics_CellRenderer(__blaneyModel); __coeffWorksheet = new JWorksheet(crw, __blaneyModel, p); __coeffWorksheet.removeColumn(1); __coeffWorksheet.removeColumn(2); widths2 = crw.getColumnWidths(); } catch (Exception e) { Message.printWarning(2, routine, e); __coeffWorksheet = new JWorksheet(0, 0, p); Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } __coeffWorksheet.setPreferredScrollableViewportSize(null); __coeffWorksheet.setHourglassJFrame(this); JScrollPane jsp = new JScrollPane(__coeffWorksheet); jsp.setBorder(BorderFactory.createTitledBorder(jsp.getBorder(), "Blaney-Criddle Crop Coefficients")); JGUIUtil.addComponent(right_panel, jsp, 0, y, 4, 4, 1, 1, 0, 0, 0, 0, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); // add search areas y = 14; JPanel searchPanel = new JPanel(); searchPanel.setLayout(gb); searchPanel.setBorder(BorderFactory.createTitledBorder("Search above list for: ")); JGUIUtil.addComponent(left_panel, searchPanel, 0, y, 4, 1, 0, 0, 10, 10, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); int y2 = 0; JGUIUtil.addComponent(searchPanel, __searchIDJRadioButton, 0, y2, 1, 1, 0, 0, 5, 10, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); __searchIDJRadioButton.addActionListener(this); JGUIUtil.addComponent(searchPanel, __searchID, 1, y2, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); __searchID.addActionListener(this); y2++; JGUIUtil.addComponent(searchPanel, __searchNameJRadioButton, 0, y2, 1, 1, 0, 0, 5, 10, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); __searchNameJRadioButton.addActionListener(this); JGUIUtil.addComponent(searchPanel, __searchName, 1, y2, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); __searchName.addActionListener(this); y2++; JGUIUtil.addComponent(searchPanel, __findNextCrop, 0, y2, 4, 1, 0, 0, 20, 10, 20, 10, GridBagConstraints.NONE, GridBagConstraints.WEST); __findNextCrop.addActionListener(this); // add buttons which lead to crop // direct flow demand, and return flow information FlowLayout fl = new FlowLayout(FlowLayout.CENTER); // add help and close buttons y++; JPanel p6 = new JPanel(); p6.setLayout(fl); if (__editable) { p6.add(applyJButton); p6.add(cancelJButton); } p6.add(helpJButton); p6.add(closeJButton); JGUIUtil.addComponent(right_panel, p6, GridBagConstraints.RELATIVE, y, 4, 1, 1, 0, 30, 0, 0, 0, GridBagConstraints.BOTH, GridBagConstraints.SOUTH); applyJButton.addActionListener(this); cancelJButton.addActionListener(this); helpJButton.addActionListener(this); closeJButton.addActionListener(this); JGUIUtil.addComponent(mainJPanel, left_panel, 0, 0, 4, 10, 1, 1, 10, 10, 10, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST); JGUIUtil.addComponent(mainJPanel, right_panel, GridBagConstraints.RELATIVE, 0, 4, 10, 0, 1, 10, 10, 10, 10, GridBagConstraints.BOTH, GridBagConstraints.EAST); 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); initializeDisables(); // JGUIUtil.center(this); pack(); setSize(850, 620); selectTableIndex(index); setVisible(true); if (widths != null) { __worksheet.setColumnWidths(widths); } if (widths2 != null) { __coeffWorksheet.setColumnWidths(widths2); } }
/// <summary> /// Sets up the GUI. /// </summary> private void setupGUI() { addWindowListener(this); JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); int y = 0; JGUIUtil.addComponent(panel, new JLabel("Text:"), 0, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, new JLabel("X:"), 0, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, new JLabel("Y:"), 0, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, new JLabel("Text Position:"), 0, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, new JLabel("Font Name:"), 0, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, new JLabel("Font Size:"), 0, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, new JLabel("Font Style:"), 0, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); __textTextField = new JTextField(30); __textFieldBackground = __textTextField.getBackground(); __xTextField = new JTextField(15); __yTextField = new JTextField(15); __textPositionComboBox = new SimpleJComboBox(false); string[] positions = GRText.getTextPositions(); __textPositionComboBox.setMaximumRowCount(positions.Length); IList <string> positionsChoices = new List <string>(); for (int i = 0; i < positions.Length; i++) { positionsChoices.Add(positions[i]); } __textPositionComboBox.setData(positionsChoices); __fontNameComboBox = JGUIUtil.newFontNameJComboBox(); __fontSizeTextField = new JTextField(7); __fontStyleComboBox = JGUIUtil.newFontStyleJComboBox(); displayPropListValues(); __textTextField.addKeyListener(this); __xTextField.addKeyListener(this); __yTextField.addKeyListener(this); __fontSizeTextField.addKeyListener(this); __textPositionComboBox.addActionListener(this); __fontNameComboBox.addActionListener(this); __fontStyleComboBox.addActionListener(this); y = 0; JGUIUtil.addComponent(panel, __textTextField, 1, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(panel, __xTextField, 1, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(panel, __yTextField, 1, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(panel, __textPositionComboBox, 1, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(panel, __fontNameComboBox, 1, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(panel, __fontSizeTextField, 1, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(panel, __fontStyleComboBox, 1, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); if (!__editable) { __textTextField.setEditable(false); __xTextField.setEditable(false); __yTextField.setEditable(false); __textPositionComboBox.setEnabled(false); __fontNameComboBox.setEnabled(false); __fontSizeTextField.setEditable(false); __fontStyleComboBox.setEnabled(false); } __applyButton = new JButton(__BUTTON_APPLY); if (__editable) { __applyButton.setToolTipText("Apply changes."); __applyButton.addActionListener(this); } __applyButton.setEnabled(false); JButton cancelButton = new JButton(__BUTTON_CANCEL); cancelButton.setToolTipText("Discard changes and return."); cancelButton.addActionListener(this); __okButton = new JButton(__BUTTON_OK); __okButton.setToolTipText("Accept changes and return."); __okButton.setEnabled(false); __okButton.addActionListener(this); JPanel southPanel = new JPanel(); southPanel.setLayout(new GridBagLayout()); if (__editable) { JGUIUtil.addComponent(southPanel, __applyButton, 0, 0, 1, 1, 1, 1, 0, 10, 0, 10, GridBagConstraints.NONE, GridBagConstraints.EAST); } int space = 0; if (!__editable) { space = 1; } JGUIUtil.addComponent(southPanel, __okButton, 1, 0, 1, 1, space, space, 0, 10, 0, 10, GridBagConstraints.NONE, GridBagConstraints.EAST); if (__editable) { JGUIUtil.addComponent(southPanel, cancelButton, 2, 0, 1, 1, 0, 0, 0, 10, 0, 10, GridBagConstraints.NONE, GridBagConstraints.EAST); } else { __okButton.setEnabled(true); } getContentPane().add("Center", panel); getContentPane().add("South", southPanel); string app = JGUIUtil.getAppNameForWindows(); if (string.ReferenceEquals(app, null) || app.Trim().Equals("")) { app = ""; } else { app += " - "; } setTitle(app + "Node Properties"); pack(); setSize(getWidth() + 100, getHeight()); JGUIUtil.center(this); setVisible(true); }
/// <summary> /// Sets up the GUI. </summary> /// <param name="index"> the index to select </param> private void setupGUI(int index) { string routine = "setupGUI"; addWindowListener(this); JPanel p1 = new JPanel(); // first 6 months' effeciency //JPanel p2 = new JPanel(); // last 6 months' effeciency JPanel p3 = new JPanel(); // div sta id -> switch for diversion JPanel p4 = new JPanel(); // user name -> data type switch JPanel left_panel = new JPanel(); // multilist and search area __stationIDJTextField = new JTextField(12); __nameJTextField = new JTextField(24); __latitudeJTextField = new JTextField(12); __elevationJTextField = new JTextField(12); __region1JTextField = new JTextField(12); __region2JTextField = new JTextField(12); __searchID = new JTextField(10); __searchName = new JTextField(10); __searchName.setEditable(false); __findNextStation = new JButton(__BUTTON_FIND_NEXT); __searchCriteriaGroup = new ButtonGroup(); __searchIDJRadioButton = new JRadioButton(__BUTTON_ID, true); __searchNameJRadioButton = new JRadioButton(__BUTTON_NAME, false); __searchCriteriaGroup.add(__searchIDJRadioButton); __searchCriteriaGroup.add(__searchNameJRadioButton); JButton applyJButton = new JButton(__BUTTON_APPLY); JButton cancelJButton = new JButton(__BUTTON_CANCEL); JButton helpJButton = new JButton(__BUTTON_HELP); helpJButton.setEnabled(false); JButton closeJButton = new JButton(__BUTTON_CLOSE); GridBagLayout gb = new GridBagLayout(); JPanel mainJPanel = new JPanel(); mainJPanel.setLayout(gb); p1.setLayout(new GridLayout(4, 6, 2, 0)); p3.setLayout(gb); p4.setLayout(gb); left_panel.setLayout(gb); int y; PropList p = new PropList("StateCU_ClimateStation_JFrame.JWorksheet"); 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; try { StateCU_ClimateStation_TableModel tmw = new StateCU_ClimateStation_TableModel(__stationsVector); StateCU_ClimateStation_CellRenderer crw = new StateCU_ClimateStation_CellRenderer(tmw); __worksheet = new JWorksheet(crw, tmw, p); widths = crw.getColumnWidths(); } catch (Exception e) { Message.printWarning(2, routine, e); __worksheet = new JWorksheet(0, 0, p); Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } __worksheet.setPreferredScrollableViewportSize(null); __worksheet.setHourglassJFrame(this); __worksheet.addMouseListener(this); __worksheet.addKeyListener(this); JGUIUtil.addComponent(left_panel, new JScrollPane(__worksheet), 0, 0, 6, 6, 1, 1, 0, 0, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.CENTER); y = 0; JGUIUtil.addComponent(p3, new JLabel("Station ID:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __stationIDJTextField, 1, y, 1, 1, 1, 0, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); __stationIDJTextField.setEditable(false); y++; JGUIUtil.addComponent(p3, new JLabel("Name:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __nameJTextField, 1, y, 1, 1, 1, 0, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Latitude (Dec. Deg.):"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __latitudeJTextField, 1, y, 1, 1, 1, 0, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Elevation (Feet):"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __elevationJTextField, 1, y, 1, 1, 1, 0, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Region 1:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __region1JTextField, 1, y, 1, 1, 1, 0, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Region 2:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __region2JTextField, 1, y, 1, 1, 1, 0, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JPanel graphPanel = new JPanel(); graphPanel.setLayout(gb); graphPanel.setBorder(BorderFactory.createTitledBorder("Time Series")); int yy = 0; __precipitationCheckBox = new JCheckBox("Precipitation (Monthly)"); __temperatureCheckBox = new JCheckBox("Temperature (Monthly)"); __frostDatesCheckBox = new JCheckBox("Frost Dates (Yearly)"); JGUIUtil.addComponent(graphPanel, __precipitationCheckBox, 0, yy++, 3, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); JGUIUtil.addComponent(graphPanel, __temperatureCheckBox, 0, yy++, 3, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); JGUIUtil.addComponent(graphPanel, __frostDatesCheckBox, 0, yy++, 3, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); if (!__dataset.getComponentForComponentType(StateCU_DataSet.COMP_PRECIPITATION_TS_MONTHLY).hasData()) { __precipitationCheckBox.setEnabled(false); } if (!__dataset.getComponentForComponentType(StateCU_DataSet.COMP_TEMPERATURE_TS_MONTHLY_AVERAGE).hasData()) { __temperatureCheckBox.setEnabled(false); } if (!__dataset.getComponentForComponentType(StateCU_DataSet.COMP_FROST_DATES_TS_YEARLY).hasData()) { __frostDatesCheckBox.setEnabled(false); } JButton graphButton = new SimpleJButton(__BUTTON_GRAPH, __BUTTON_GRAPH, this); JButton tableButton = new SimpleJButton(__BUTTON_TABLE, __BUTTON_TABLE, this); JButton summaryButton = new SimpleJButton(__BUTTON_SUMMARY, __BUTTON_SUMMARY, this); JGUIUtil.addComponent(graphPanel, graphButton, 0, yy, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(graphPanel, tableButton, 1, yy, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(graphPanel, summaryButton, 2, yy++, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, graphPanel, 0, y++, 2, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST); // add search areas y = 7; JPanel searchPanel = new JPanel(); searchPanel.setLayout(gb); searchPanel.setBorder(BorderFactory.createTitledBorder("Search above list for: ")); JGUIUtil.addComponent(left_panel, searchPanel, 0, y, 4, 1, 0, 0, 10, 10, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); int y2 = 0; JGUIUtil.addComponent(searchPanel, __searchIDJRadioButton, 0, y2, 1, 1, 0, 0, 5, 10, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); __searchIDJRadioButton.addActionListener(this); JGUIUtil.addComponent(searchPanel, __searchID, 1, y2, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); __searchID.addActionListener(this); y2++; JGUIUtil.addComponent(searchPanel, __searchNameJRadioButton, 0, y2, 1, 1, 0, 0, 5, 10, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); __searchNameJRadioButton.addActionListener(this); JGUIUtil.addComponent(searchPanel, __searchName, 1, y2, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); __searchName.addActionListener(this); y2++; JGUIUtil.addComponent(searchPanel, __findNextStation, 0, y2, 4, 1, 0, 0, 20, 10, 20, 10, GridBagConstraints.NONE, GridBagConstraints.WEST); __findNextStation.addActionListener(this); // add buttons which lead to station water rights, // direct flow demand, and return flow information y = 6; FlowLayout fl = new FlowLayout(FlowLayout.CENTER); JPanel p5 = new JPanel(); p5.setLayout(new GridLayout(5, 2)); // add help and close buttons y = 10; JPanel p6 = new JPanel(); p6.setLayout(fl); if (__editable) { p6.add(applyJButton); p6.add(cancelJButton); } p6.add(helpJButton); p6.add(closeJButton); // two top panels of info JGUIUtil.addComponent(mainJPanel, p3, 6, 0, 1, 6, 0, 1, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST); JGUIUtil.addComponent(mainJPanel, p6, 6, 7, 1, 1, 0, 0, 30, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.SOUTH); applyJButton.addActionListener(this); cancelJButton.addActionListener(this); helpJButton.addActionListener(this); closeJButton.addActionListener(this); JGUIUtil.addComponent(mainJPanel, left_panel, 0, 0, 4, 10, 1, 1, 10, 10, 10, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST); 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); initializeDisables(); // JGUIUtil.center(this); pack(); setSize(900,440); selectTableIndex(index); setVisible(true); if (widths != null) { __worksheet.setColumnWidths(widths); } }
/// <summary> /// Sets up the GUI. /// </summary> private void setupGUI() { __fileJList = new JList(); __fileJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); __fileJList.addListSelectionListener(this); __fileJList.setToolTipText("<HTML>To view an output file, select a file and press " + "View/Edit.<br>Notepad will be used to view the file.</HTML>"); // REVISIT - SAM 2003-10-26 if a better help system is enabled. //__helpJButton = new JButton(__BUTTON_HELP); //__helpJButton.setEnabled(false); __closeJButton = new JButton(__BUTTON_CLOSE); __viewEditJButton = new JButton(__BUTTON_VIEW_EDIT); __viewEditJButton.setToolTipText("<HTML>Use Notepad to view/edit the selected file.</HTML>"); GridBagLayout gb = new GridBagLayout(); JPanel mainPanel = new JPanel(); mainPanel.setLayout(gb); FlowLayout fl = new FlowLayout(FlowLayout.CENTER); JPanel final_panel = new JPanel(); final_panel.setLayout(fl); Font orig = __fileJList.getFont(); Font @fixed = null; if (orig != null) { @fixed = new Font("Courier", orig.getStyle(), orig.getSize()); } else { @fixed = new Font("Courier", Font.PLAIN, 11); } __fileJList.setFont(@fixed); __fileJList.addMouseListener(this); JGUIUtil.addComponent(mainPanel, new JScrollPane(__fileJList), 0, 0, 10, 12, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.CENTER); // add contents to the list box fillFileJListContents(); final_panel.add(__viewEditJButton); __viewEditJButton.addActionListener(this); __viewEditJButton.setEnabled(false); // Change state when something // is selected. //final_panel.add(__helpJButton); //__helpJButton.addActionListener(this); final_panel.add(__closeJButton); __closeJButton.addActionListener(this); JGUIUtil.addComponent(mainPanel, final_panel, 0, 12, 10, 5, 0, 0, GridBagConstraints.NONE, GridBagConstraints.SOUTH); getContentPane().add("Center", mainPanel); pack(); setSize(700, 300); JGUIUtil.center(this); setVisible(true); }
/// <summary> /// Checks the current values for the node's data to make sure they are valid. If /// any are invalid their textfields are colored red and the OK button is /// disabled. /// </summary> private void checkValidity() { string id = __idTextField.getText(); bool valid = true; if (!__parent.inStateModGUI()) { if (id.Trim().Equals("")) { __idTextField.setBackground(Color.red); valid = false; } else if (!checkUniqueID(id)) { __idTextField.setBackground(Color.red); valid = false; } else { __idTextField.setBackground(Color.white); } } string xs = __xTextField.getText(); if (xs.Trim().Equals("")) { __xTextField.setBackground(Color.red); valid = false; } else { try { __xTextField.setBackground(Color.white); } catch (Exception) { __xTextField.setBackground(Color.red); valid = false; } } string ys = __yTextField.getText(); if (ys.Trim().Equals("")) { __yTextField.setBackground(Color.red); valid = false; } else { try { __yTextField.setBackground(Color.white); } catch (Exception) { __yTextField.setBackground(Color.red); valid = false; } } if (!__parent.inStateModGUI()) { string area = __areaTextField.getText(); if (area.Trim().Equals("")) { __areaTextField.setBackground(Color.red); valid = false; } else { try { __areaTextField.setBackground(Color.white); } catch (Exception) { __areaTextField.setBackground(Color.red); valid = false; } } } if (!__parent.inStateModGUI()) { string precipitation = __precipitationTextField.getText(); if (precipitation.Trim().Equals("")) { __precipitationTextField.setBackground(Color.red); valid = false; } else { try { __precipitationTextField.setBackground(Color.white); } catch (Exception) { __precipitationTextField.setBackground(Color.red); valid = false; } } } if (!valid) { __okButton.setEnabled(false); __applyButton.setEnabled(false); } else { __okButton.setEnabled(true); __applyButton.setEnabled(true); } }
/// <summary> /// Sets up the GUI. /// </summary> private void setupGUI() { addWindowListener(__parent); JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); int y = 0; IList <string> nodeIds = new List <object>(__nodes.Length); for (int i = 0; i < __nodes.Length; i++) { nodeIds.Add(__nodes[i].getCommonID()); } nodeIds.Sort(); JPanel top = new JPanel(); top.setLayout(new GridBagLayout()); JGUIUtil.addComponent(panel, top, 0, 0, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.WEST); y = 0; __node1ComboBox = new SimpleJComboBox(nodeIds); __node1ComboBox.addItemListener(this); __node1ComboBox.addActionListener(this); JGUIUtil.addComponent(top, new JLabel("From node: "), 0, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(top, __node1ComboBox, 1, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); __node2ComboBox = new SimpleJComboBox(nodeIds); __node2ComboBox.addItemListener(this); __node2ComboBox.addActionListener(this); JGUIUtil.addComponent(top, new JLabel("To node: "), 0, ++y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(top, __node2ComboBox, 1, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); __linkId_JTextField = new JTextField(10); JGUIUtil.addComponent(top, new JLabel("Link ID: "), 0, ++y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(top, __linkId_JTextField, 1, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); IList <string> lineStyleChoices = new List <object>(); lineStyleChoices.Add("" + GRLineStyleType.DASHED); lineStyleChoices.Add("" + GRLineStyleType.SOLID); __lineStyleComboBox = new SimpleJComboBox(lineStyleChoices); __lineStyleComboBox.addItemListener(this); __lineStyleComboBox.addActionListener(this); JGUIUtil.addComponent(top, new JLabel("Line style: "), 0, ++y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(top, __lineStyleComboBox, 1, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); IList <string> arrowEndChoices = new List <object>(); arrowEndChoices.Add("" + GRArrowStyleType.NONE); arrowEndChoices.Add("" + GRArrowStyleType.SOLID); __fromArrowStyleComboBox = new SimpleJComboBox(arrowEndChoices); __fromArrowStyleComboBox.addItemListener(this); __fromArrowStyleComboBox.addActionListener(this); JGUIUtil.addComponent(top, new JLabel("Arrow (from) style: "), 0, ++y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(top, __fromArrowStyleComboBox, 1, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); __toArrowStyleComboBox = new SimpleJComboBox(arrowEndChoices); __toArrowStyleComboBox.addItemListener(this); __toArrowStyleComboBox.addActionListener(this); JGUIUtil.addComponent(top, new JLabel("Arrow (to) style: "), 0, ++y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(top, __toArrowStyleComboBox, 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); }
/// <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() { 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); }
/// <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> /// <param name="index"> the index of the network node to preselect. </param> private void setupGUI(int index) { string routine = "StateMod_RiverNetworkNode_JFrame.setupGUI"; addWindowListener(this); JPanel p1 = new JPanel(); // entire top half __searchID = new JTextField(10); __searchName = new JTextField(10); __findNext = new JButton(__BUTTON_FIND_NEXT); __searchCriteriaGroup = new ButtonGroup(); __searchIDJRadioButton = new JRadioButton("ID", true); __searchIDJRadioButton.addActionListener(this); __searchCriteriaGroup.add(__searchIDJRadioButton); __searchNameJRadioButton = new JRadioButton("Name", false); __searchNameJRadioButton.addActionListener(this); __searchCriteriaGroup.add(__searchNameJRadioButton); __idJTextField = new JTextField(12); __idJTextField.setEditable(false); __nameJTextField = new JTextField(24); __nameJTextField.setEditable(false); __nodeJTextField = new JTextField(12); __commentJTextField = new JTextField(24); __showOnMap_JButton = new SimpleJButton(__BUTTON_SHOW_ON_MAP, this); __showOnMap_JButton.setToolTipText("Annotate map with location (button is disabled if layer does not have matching ID)"); __showOnNetwork_JButton = new SimpleJButton(__BUTTON_SHOW_ON_NETWORK, this); __showOnNetwork_JButton.setToolTipText("Annotate network with location"); __applyJButton = new JButton(__BUTTON_APPLY); __cancelJButton = new JButton(__BUTTON_CANCEL); __helpJButton = new JButton(__BUTTON_HELP); __closeJButton = new JButton(__BUTTON_CLOSE); GridBagLayout gb = new GridBagLayout(); p1.setLayout(gb); int y = 0; PropList p = new PropList("StateMod_RiverNetworkNode_JFrame.JWorksheet"); p.add("JWorksheet.ShowPopupMenu=true"); p.add("JWorksheet.AllowCopy=true"); p.add("JWorksheet.SelectionMode=SingleRowSelection"); int[] widths = null; JScrollWorksheet jsw = null; try { StateMod_RiverNetworkNode_TableModel tmr = new StateMod_RiverNetworkNode_TableModel(__riverNetworkNodesVector); StateMod_RiverNetworkNode_CellRenderer crr = new StateMod_RiverNetworkNode_CellRenderer(tmr); jsw = new JScrollWorksheet(crr, tmr, p); __worksheet = jsw.getJWorksheet(); 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); JGUIUtil.addComponent(p1, jsw, 0, y, 4, 9, 1, 1, 0, 0, 0, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST); JGUIUtil.addComponent(p1, new JLabel("ID:"), 5, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p1, __idJTextField, 6, y++, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p1, new JLabel("Name:"), 5, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p1, __nameJTextField, 6, y++, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p1, new JLabel("Downstream Node:"), 5, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p1, __nodeJTextField, 6, y++, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p1, new JLabel("Comment:"), 5, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p1, __commentJTextField, 6, y++, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); // // add search areas // y = 10; JPanel searchPanel = new JPanel(); searchPanel.setLayout(gb); searchPanel.setBorder(BorderFactory.createTitledBorder("Search list for: ")); JGUIUtil.addComponent(p1, searchPanel, 0, y, 1, 1, 0, 0, 10, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(searchPanel, __searchIDJRadioButton, 0, ++y, 1, 1, 0, 0, 5, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(searchPanel, __searchID, 1, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); __searchID.addActionListener(this); JGUIUtil.addComponent(searchPanel, __searchNameJRadioButton, 0, ++y, 1, 1, 0, 0, 5, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); __searchName.setEditable(false); JGUIUtil.addComponent(searchPanel, __searchName, 1, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); __searchName.addActionListener(this); JGUIUtil.addComponent(searchPanel, __findNext, 0, ++y, 4, 1, 0, 0, 10, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); __findNext.addActionListener(this); // // add close and help buttons // JPanel pfinal = new JPanel(); FlowLayout fl = new FlowLayout(FlowLayout.RIGHT); pfinal.setLayout(fl); __helpJButton.setEnabled(false); pfinal.add(__showOnMap_JButton); pfinal.add(__showOnNetwork_JButton); if (__editable) { pfinal.add(__applyJButton); pfinal.add(__cancelJButton); } pfinal.add(__closeJButton); // pfinal.add(__helpJButton); __applyJButton.addActionListener(this); __cancelJButton.addActionListener(this); __helpJButton.addActionListener(this); __closeJButton.addActionListener(this); getContentPane().add("Center", p1); getContentPane().add("South", pfinal); initializeDisables(); selectTableIndex(index); if (__dataset_wm != null) { __dataset_wm.setWindowOpen(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK, this); } pack(); setSize(690, 400); JGUIUtil.center(this); setVisible(true); if (widths != null) { __worksheet.setColumnWidths(widths); } __worksheet.addSortListener(this); }
/// <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> 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_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> /// Sets up the GUI. </summary> /// <param name="index"> Data item to display. </param> private void setupGUI(int index) { string routine = "StateMod_DelayTable_JFrame"; addWindowListener(this); // AWT portion JPanel p1 = new JPanel(); // selection list and grid JPanel p2 = new JPanel(); // search widgets JPanel pmain = new JPanel(); // everything but close and help buttons __searchID = new JTextField(10); __findNextDelay = new JButton("Find Next"); PropList p = new PropList("StateMod_DelayTable_JFrame.JWorksheet"); p.add("JWorksheet.ShowPopupMenu=true"); p.add("JWorksheet.AllowCopy=true"); p.add("JWorksheet.SelectionMode=SingleRowSelection"); bool percent = true; if (__dataset.getInterv() == -100 || __dataset.getInterv() < -1) { percent = false; } int[] widthsR = null; JScrollWorksheet jswR = null; try { StateMod_DelayTable_TableModel tmd = new StateMod_DelayTable_TableModel(new List<double?>(), __monthly_data, __editable, percent); tmd.setSubDelays(new List<double?>()); StateMod_DelayTable_CellRenderer crd = new StateMod_DelayTable_CellRenderer(tmd); jswR = new JScrollWorksheet(crd, tmd, p); __worksheetR = jswR.getJWorksheet(); // remove the ID column __worksheetR.removeColumn(0); widthsR = crd.getColumnWidths(); } catch (Exception e) { Message.printWarning(1, routine, "Error building worksheet."); Message.printWarning(2, routine, e); jswR = new JScrollWorksheet(0, 0, p); __worksheetR = jswR.getJWorksheet(); } __worksheetR.setPreferredScrollableViewportSize(null); // Assume all have the same units so pass in the first one... __worksheetR.setHourglassJFrame(this); __worksheetR.addMouseListener(this); __worksheetR.addKeyListener(this); __graphDelayJButton = new JButton("Graph"); if (__delaysVector.Count == 0) { __graphDelayJButton.setEnabled(false); } __helpJButton = new JButton(__BUTTON_HELP); __helpJButton.setEnabled(false); __closeJButton = new JButton(__BUTTON_CLOSE); __addReturn = new JButton(__BUTTON_ADD_RETURN); __deleteReturn = new JButton(__BUTTON_DELETE_RETURN); __deleteReturn.setEnabled(false); JButton cancelJButton = new JButton(__BUTTON_CANCEL); JButton applyJButton = new JButton(__BUTTON_APPLY); GridBagLayout gb = new GridBagLayout(); p1.setLayout(gb); p2.setLayout(gb); pmain.setLayout(gb); int y; int[] widthsL = null; JScrollWorksheet jswL = null; try { StateMod_DelayTable_TableModel tmd = new StateMod_DelayTable_TableModel(__delaysVector, __monthly_data, __editable, percent); StateMod_DelayTable_CellRenderer crd = new StateMod_DelayTable_CellRenderer(tmd); jswL = new JScrollWorksheet(crd, tmd, p); __worksheetL = jswL.getJWorksheet(); // remove all the columns but the ID column. __worksheetL.removeColumn(1); __worksheetL.removeColumn(2); widthsL = crd.getColumnWidths(); } catch (Exception e) { Message.printWarning(1, routine, "Error building worksheet."); Message.printWarning(2, routine, e); jswL = new JScrollWorksheet(0, 0, p); __worksheetL = jswL.getJWorksheet(); } __worksheetL.setPreferredScrollableViewportSize(null); __worksheetR.setPreferredScrollableViewportSize(null); __worksheetL.setHourglassJFrame(this); __worksheetL.addMouseListener(this); __worksheetL.addKeyListener(this); JGUIUtil.addComponent(pmain, jswL, 0, 0, 2, 12, .2, 1, 10, 10, 1, 10, GridBagConstraints.BOTH, GridBagConstraints.WEST); JGUIUtil.addComponent(pmain, jswR, 5, 1, 18, 24, 1, 1, 10, 10, 10, 10, GridBagConstraints.BOTH, GridBagConstraints.WEST); JPanel bottomJPanel = new JPanel(); bottomJPanel.setLayout(gb); __messageJTextField = new JTextField(); __messageJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 1, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); __statusJTextField = new JTextField(5); __statusJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST); // close and help buttons JPanel pfinal = new JPanel(); FlowLayout fl = new FlowLayout(FlowLayout.RIGHT); pfinal.setLayout(fl); if (__editable) { pfinal.add(__addReturn); pfinal.add(__deleteReturn); } pfinal.add(applyJButton); pfinal.add(cancelJButton); pfinal.add(__closeJButton); pfinal.add(__graphDelayJButton); // pfinal.add(__helpJButton); JGUIUtil.addComponent(bottomJPanel, pfinal, 0, 0, 8, 1, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); __helpJButton.addActionListener(this); __closeJButton.addActionListener(this); __graphDelayJButton.addActionListener(this); __addReturn.addActionListener(this); __deleteReturn.addActionListener(this); cancelJButton.addActionListener(this); applyJButton.addActionListener(this); // add search areas y = 0; JPanel searchPanel = new JPanel(); searchPanel.setLayout(gb); searchPanel.setBorder(BorderFactory.createTitledBorder("Search above list for: ")); JGUIUtil.addComponent(searchPanel, new JLabel("ID"), 0, y, 1, 1, 0, 0, 5, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(searchPanel, __searchID, 1, y, 1, 1, 1, 1, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); __searchID.addActionListener(this); y++; JGUIUtil.addComponent(searchPanel, __findNextDelay, 0, y, 4, 1, 0, 0, 10, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.CENTER); __findNextDelay.addActionListener(this); JGUIUtil.addComponent(pmain, searchPanel, 0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, 5, 10, 20, 10, GridBagConstraints.NONE, GridBagConstraints.SOUTHWEST); getContentPane().add("Center", pmain); getContentPane().add("South", bottomJPanel); if (__dataset_wm != null) { __dataset_wm.setWindowOpen(__window_type, this); } pack(); setSize(530, 400); JGUIUtil.center(this); setVisible(true); if (widthsR != null) { __worksheetR.setColumnWidths(widthsR); } if (widthsL != null) { __worksheetL.setColumnWidths(widthsL); } selectLeftTableIndex(index, false, true); }