/// <summary> /// Initialize the interface. </summary> /// <param name="title"> Title to be displayed. </param> /// <param name="is_visible"> Indicates whether the display should be made visible at /// creation. </param> private void initialize(string title, bool is_visible) { GridBagLayout gbl = new GridBagLayout(); Insets insetsTLBR = new Insets(2, 2, 2, 2); // space around text // area // Add a panel to hold the main components... JPanel display_JPanel = new JPanel(); display_JPanel.setLayout(gbl); getContentPane().add(display_JPanel); JTabbedPane dataset_JTabbedPane = new JTabbedPane(); //dataset_JTabbedPane.addChangeListener ( this ); JGUIUtil.addComponent(display_JPanel, dataset_JTabbedPane, 0, 0, 10, 1, 0, 0, insetsTLBR, GridBagConstraints.BOTH, GridBagConstraints.CENTER); int y = 0; // Used for vertical positioning. // // Data Set Components... // // 1 row per component, each column width of 1 // JPanel components_JPanel = new JPanel(); components_JPanel.setLayout(gbl); dataset_JTabbedPane.addTab("Components", null, components_JPanel, "Components"); // Add the headers... int x = 0; JGUIUtil.addComponent(components_JPanel, new JLabel("Component"), x, y, 1, 1, 0.0, 0.0, insetsTLBR, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(components_JPanel, new JLabel("Created How"), ++x, y, 1, 1, 0.0, 0.0, insetsTLBR, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(components_JPanel, new JLabel("Input File"), ++x, y, 1, 1, 0.0, 0.0, insetsTLBR, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(components_JPanel, new JLabel("Count"), ++x, y, 1, 1, 0.0, 0.0, insetsTLBR, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(components_JPanel, new JLabel("Incomplete"), ++x, y, 1, 1, 0.0, 0.0, insetsTLBR, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(components_JPanel, new JLabel("Data File"), ++x, y, 1, 1, 0.0, 0.0, insetsTLBR, GridBagConstraints.NONE, GridBagConstraints.WEST); // Now add the contents for each component... IList <DataSetComponent> components_Vector = __dataset.getComponents(); int size = components_Vector.Count; DataSetComponent component; y = 0; // Incremented below. True row 0 is used for headers above. IList <DataSetComponent> data = null; int data_size = 0; for (int i = 0; i < size; i++) { x = 0; component = components_Vector[i]; JTextField component_JTextField = new JTextField(component.getComponentName(), 20); component_JTextField.setEditable(false); JGUIUtil.addComponent(components_JPanel, component_JTextField, x, ++y, 1, 1, 0.0, 0.0, insetsTLBR, GridBagConstraints.NONE, GridBagConstraints.WEST); if (component.isGroup()) { // Get each of the sub-component's information... if (component.getData() == null) { continue; } //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<RTi.Util.IO.DataSetComponent> data0 = (java.util.List<RTi.Util.IO.DataSetComponent>)component.getData(); IList <DataSetComponent> data0 = (IList <DataSetComponent>)component.getData(); data = data0; data_size = 0; if (data != null) { data_size = data.Count; } for (int j = 0; j < data_size; j++) { x = 0; component = (DataSetComponent)data[j]; component_JTextField = new JTextField(" " + component.getComponentName(), 20); component_JTextField.setEditable(false); JGUIUtil.addComponent(components_JPanel, component_JTextField, x, ++y, 1, 1, 0.0, 0.0, insetsTLBR, GridBagConstraints.NONE, GridBagConstraints.WEST); // REVISIT - need to track create method JTextField from_JTextField = new JTextField("?", 10); //from.getName(), 10 ); from_JTextField.setEditable(false); JGUIUtil.addComponent(components_JPanel, from_JTextField, ++x, y, 1, 1, 0.0, 0.0, insetsTLBR, GridBagConstraints.NONE, GridBagConstraints.WEST); // REVISIT - need to indicate list or commands // file JTextField inputfile_JTextField = new JTextField("?", 10); //from.getName(), 10 ); inputfile_JTextField.setEditable(false); JGUIUtil.addComponent(components_JPanel, inputfile_JTextField, ++x, y, 1, 1, 0.0, 0.0, insetsTLBR, GridBagConstraints.NONE, GridBagConstraints.WEST); int count = 0; try { count = ((System.Collections.IList)component.getData()).Count; } catch (Exception) { // REVISIT // Probably because not a Vector (GIS // and control) - need a more graceful // way to handle. count = -1; } JTextField object_JTextField = null; if (count >= 0) { object_JTextField = new JTextField("" + count, 5); } else { object_JTextField = new JTextField("-", 5); } object_JTextField.setEditable(false); JGUIUtil.addComponent(components_JPanel, object_JTextField, ++x, y, 1, 1, 0.0, 0.0, insetsTLBR, GridBagConstraints.NONE, GridBagConstraints.WEST); // REVISIT - need to indicate how many are // incomplete JTextField incomplete_JTextField = new JTextField("?", 5); //from.getName(), 10 ); incomplete_JTextField.setEditable(false); JGUIUtil.addComponent(components_JPanel, incomplete_JTextField, ++x, y, 1, 1, 0.0, 0.0, insetsTLBR, GridBagConstraints.NONE, GridBagConstraints.WEST); JTextField datafile_JTextField = new JTextField(component.getDataFileName(), 15); datafile_JTextField.setEditable(false); JGUIUtil.addComponent(components_JPanel, datafile_JTextField, ++x, y, 1, 1, 0.0, 0.0, insetsTLBR, GridBagConstraints.NONE, GridBagConstraints.WEST); } } } // // Data Set Properties... // // 1 grid for labels, 6 for text fields (resizable). // y = 0; JPanel properties_JPanel = new JPanel(); properties_JPanel.setLayout(gbl); JGUIUtil.addComponent(properties_JPanel, new JLabel("Data Set Type:"), 0, y, 1, 1, 0.0, 0.0, insetsTLBR, GridBagConstraints.NONE, GridBagConstraints.EAST); JTextField dataset_type_JTextField = new JTextField(__dataset.getDataSetName(), 20); dataset_type_JTextField.setEditable(false); JGUIUtil.addComponent(properties_JPanel, dataset_type_JTextField, 1, y, 2, 1, 0.0, 1.0, insetsTLBR, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); JGUIUtil.addComponent(properties_JPanel, new JLabel("Data Set Base Name:"), 0, ++y, 1, 1, 0.0, 0.0, insetsTLBR, GridBagConstraints.NONE, GridBagConstraints.EAST); JTextField dataset_basename_JTextField = new JTextField(__dataset.getBaseName(), 20); dataset_basename_JTextField.setEditable(false); JGUIUtil.addComponent(properties_JPanel, dataset_basename_JTextField, 1, y, 2, 1, 0.0, 1.0, insetsTLBR, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); JGUIUtil.addComponent(properties_JPanel, new JLabel("Data Set Directory:"), 0, ++y, 1, 1, 0.0, 0.0, insetsTLBR, GridBagConstraints.NONE, GridBagConstraints.EAST); JTextField dataset_dir_JTextField = new JTextField(__dataset.getDataSetDirectory(), 40); dataset_dir_JTextField.setEditable(false); JGUIUtil.addComponent(properties_JPanel, dataset_dir_JTextField, 1, y, 6, 1, 0.0, 1.0, insetsTLBR, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); JGUIUtil.addComponent(properties_JPanel, new JLabel("Data Set File:"), 0, ++y, 1, 1, 0.0, 0.0, insetsTLBR, GridBagConstraints.NONE, GridBagConstraints.EAST); JTextField dataset_file_JTextField = new JTextField(__dataset.getDataSetFileName(), 20); dataset_file_JTextField.setEditable(false); JGUIUtil.addComponent(properties_JPanel, dataset_file_JTextField, 1, y, 2, 1, 0.0, 1.0, insetsTLBR, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); dataset_JTabbedPane.addTab("Properties", null, properties_JPanel, "Properties"); // Show the interface... if ((string.ReferenceEquals(title, null)) || (title.Length == 0)) { setTitle("Data Set Manager"); } else { setTitle(title); } pack(); JGUIUtil.center(this); setResizable(true); setVisible(is_visible); }
/// <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() { 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> /// <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() { string routine = "setupGUI"; addWindowListener(this); __addReturnFlow = new JButton(__BUTTON_ADD_RETURN_FLOW); __deleteReturnFlow = new JButton(__BUTTON_DEL_RETURN_FLOW); __deleteReturnFlow.setEnabled(false); __helpJButton = new JButton(__BUTTON_HELP); __helpJButton.setEnabled(false); __closeJButton = new JButton(__BUTTON_CLOSE); JButton cancelJButton = new JButton(__BUTTON_CANCEL); JButton applyJButton = new JButton(__BUTTON_APPLY); GridBagLayout gb = new GridBagLayout(); JPanel mainJPanel = new JPanel(); mainJPanel.setLayout(gb); FlowLayout fl = new FlowLayout(FlowLayout.RIGHT); JPanel p1 = new JPanel(); p1.setLayout(fl); GridLayout gl = new GridLayout(2, 2, 1, 1); JPanel info_panel = new JPanel(); info_panel.setLayout(gl); JPanel main_panel = new JPanel(); main_panel.setLayout(new BorderLayout()); info_panel.add(new JLabel("Well:")); info_panel.add(new JLabel(__currentWell.getID())); info_panel.add(new JLabel("Well name:")); info_panel.add(new JLabel(__currentWell.getName())); if (__editable) { p1.add(__addReturnFlow); p1.add(__deleteReturnFlow); } p1.add(applyJButton); p1.add(cancelJButton); // p1.add(__helpJButton); p1.add(__closeJButton); PropList p = new PropList("StateMod_Well_ReturnFlow_JFrame.JWorksheet"); p.add("JWorksheet.ShowPopupMenu=true"); p.add("JWorksheet.AllowCopy=true"); p.add("JWorksheet.SelectionMode=SingleRowSelection"); int[] widths = null; JScrollWorksheet jsw = null; try { System.Collections.IList nodes = (System.Collections.IList)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK).getData()); System.Collections.IList v = new List <object>(); System.Collections.IList v2 = __currentWell.getReturnFlows(); StateMod_ReturnFlow rf; for (int i = 0; i < v2.Count; i++) { rf = (StateMod_ReturnFlow)((StateMod_ReturnFlow)v2[i]).clone(); rf.setCrtnid(rf.getCrtnid() + StateMod_Util.findNameInVector(rf.getCrtnid(), nodes, true)); v.Add(rf); } StateMod_ReturnFlow_TableModel tmw = new StateMod_ReturnFlow_TableModel(__dataset, v, __editable, true); StateMod_ReturnFlow_CellRenderer crw = new StateMod_ReturnFlow_CellRenderer(tmw); jsw = new JScrollWorksheet(crw, tmw, p); __worksheet = jsw.getJWorksheet(); v = StateMod_Util.createIdentifierListFromStateModData(nodes, true, null); __worksheet.setColumnJComboBoxValues(StateMod_ReturnFlow_TableModel.COL_RIVER_NODE, v, false); // 10 System.Collections.IList delayIDs = null; if (__dataset.getIday() == 1) { delayIDs = (System.Collections.IList)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_DAILY).getData()); } else { delayIDs = (System.Collections.IList)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY).getData()); } v = StateMod_Util.createIdentifierListFromStateModData(delayIDs, true, null); __worksheet.setColumnJComboBoxValues(StateMod_ReturnFlow_TableModel.COL_RETURN_ID, v, false); widths = crw.getColumnWidths(); } catch (Exception e) { Message.printWarning(2, routine, e); jsw = new JScrollWorksheet(0, 0, p); __worksheet = jsw.getJWorksheet(); } __worksheet.setPreferredScrollableViewportSize(null); __worksheet.setHourglassJFrame(this); __worksheet.addMouseListener(this); __worksheet.addKeyListener(this); main_panel.add(jsw, "Center"); main_panel.add(p1, "South"); JGUIUtil.addComponent(mainJPanel, info_panel, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); JGUIUtil.addComponent(mainJPanel, main_panel, 0, 1, 10, 10, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.SOUTH); getContentPane().add(mainJPanel); JPanel bottomJPanel = new JPanel(); bottomJPanel.setLayout(gb); __messageJTextField = new JTextField(); __messageJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 0, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); __statusJTextField = new JTextField(5); __statusJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST); getContentPane().add("South", bottomJPanel); __addReturnFlow.addActionListener(this); __deleteReturnFlow.addActionListener(this); __closeJButton.addActionListener(this); __helpJButton.addActionListener(this); applyJButton.addActionListener(this); cancelJButton.addActionListener(this); pack(); setSize(520, 280); JGUIUtil.center(this); setVisible(true); if (widths != null) { __worksheet.setColumnWidths(widths); } }
/// <summary> /// Sets up the GUI. /// </summary> private void setupGUI() { string routine = "setupGUI"; addWindowListener(this); __addRowButton = new SimpleJButton(__BUTTON_ADD_ROW, this); __deleteRowButton = new SimpleJButton(__BUTTON_DELETE_ROW, this); __saveTemplateButton = new SimpleJButton(__BUTTON_SAVE_FILE, this); __clearWorksheetButton = new SimpleJButton(__BUTTON_CLEAR_LIST, this); __loadTemplateButton = new SimpleJButton(__BUTTON_LOAD_FILE, this); __helpButton = new SimpleJButton(__BUTTON_HELP, this); __helpButton.setEnabled(false); __closeButton = new SimpleJButton(__BUTTON_CLOSE, this); __useAllJCheckBox = new JCheckBox(__CHECKBOX_USE_ALL, false); __useAllJCheckBox.addActionListener(this); // Make a main panel to be the resizable body of the frame... JPanel main_JPanel = new JPanel(); GridBagLayout gb = new GridBagLayout(); main_JPanel.setLayout(gb); GridLayout gl = new GridLayout(2, 2, 2, 2); JPanel top_panel = new JPanel(); top_panel.setLayout(gl); JPanel radio_panel = new JPanel(); radio_panel.setLayout(gb); GridLayout gl2 = new GridLayout(1, 0, 2, 0); JPanel bottom_JPanel = new JPanel(); bottom_JPanel.setLayout(gl2); FlowLayout fl = new FlowLayout(FlowLayout.CENTER); JPanel final_button_JPanel = new JPanel(); final_button_JPanel.setLayout(fl); JPanel grid_JPanel = new JPanel(); grid_JPanel.setLayout(gb); // add add a row, delete selected rows, clear spreadsheet, // select template, save template buttons top_panel.add(__addRowButton); top_panel.add(__deleteRowButton); top_panel.add(__clearWorksheetButton); top_panel.add(__loadTemplateButton); int y = 0; JGUIUtil.addComponent(main_JPanel, top_panel, 0, y, 10, 3, 0, 0, 10, 10, 10, 10, GridBagConstraints.NONE, GridBagConstraints.NORTH); y += 3; JGUIUtil.addComponent(main_JPanel, __useAllJCheckBox, 0, ++y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); PropList p = new PropList("StateMod_OutputControl_JFrame.JWorksheet"); p.add("JWorksheet.ShowRowHeader=true"); p.add("JWorksheet.AllowCopy=true"); p.add("JWorksheet.ShowPopupMenu=true"); int[] widths = null; JScrollWorksheet jsw = null; try { __tableModel = new StateMod_OutputControl_TableModel(this, new List <object>(), (System.Collections.IList)__riverNetworkComp.getData()); StateMod_OutputControl_CellRenderer cro = new StateMod_OutputControl_CellRenderer(__tableModel); jsw = new JScrollWorksheet(cro, __tableModel, p); __worksheet = jsw.getJWorksheet(); System.Collections.IList v = StateMod_Util.arrayToList(StateMod_GraphNode.node_types); v.Add("Other"); __worksheet.setColumnJComboBoxValues(0, v); __worksheet.setCellSpecificJComboBoxColumn(1, false); System.Collections.IList offOn = new List <object>(); offOn.Add("Off"); offOn.Add("On"); __worksheet.setColumnJComboBoxValues(2, offOn); __tableModel.setWorksheet(__worksheet); widths = cro.getColumnWidths(); } catch (Exception e) { Message.printWarning(1, routine, "Error building worksheet."); Message.printWarning(2, routine, e); jsw = new JScrollWorksheet(0, 0, p); __worksheet = jsw.getJWorksheet(); } __worksheet.setPreferredScrollableViewportSize(null); __worksheet.setHourglassJFrame(this); JGUIUtil.addComponent(grid_JPanel, jsw, 0, 0, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.CENTER); JGUIUtil.addComponent(main_JPanel, grid_JPanel, 0, ++y, 10, 12, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.CENTER); y += 11; // To account for grid height // Add bottom buttons - these are alphabetical so be // careful if you add more ... final_button_JPanel.add(__closeButton); // REVISIT SAM 2006-03-04 // Help is not currently enabled //final_button_JPanel.add(__helpButton); final_button_JPanel.add(__saveTemplateButton); // Add the final buttons on the bottom to the bottom panel... bottom_JPanel.add(final_button_JPanel); // Add the button panel to the frame... JGUIUtil.addComponent(main_JPanel, bottom_JPanel, 0, ++y, 10, 1, 0, 0, GridBagConstraints.VERTICAL, GridBagConstraints.SOUTH); // Add the main panel as the resizable content... getContentPane().add("Center", main_JPanel); // Add JTextFields for messages... JPanel message_JPanel = new JPanel(); message_JPanel.setLayout(gb); __messageJTextField = new JTextField(); __messageJTextField.setEditable(false); __statusJTextField = new JTextField(" "); __statusJTextField.setEditable(false); JGUIUtil.addComponent(message_JPanel, __messageJTextField, 0, 0, 9, 1, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); JGUIUtil.addComponent(message_JPanel, __statusJTextField, 9, 0, 1, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.SOUTH); getContentPane().add("South", message_JPanel); pack(); setSize(670, 500); JGUIUtil.center(this); setVisible(true); if (widths != null) { __worksheet.setColumnWidths(widths); } }
/// <summary> /// Responds to action performed events. </summary> /// <param name="ae"> the ActionEvent that happened. </param> public virtual void actionPerformed(ActionEvent ae) { string routine = "StateMod_OutputControl_JFrame.actionPerformed"; string action = ae.getActionCommand(); if (action.Equals(__BUTTON_ADD_ROW)) { if (!__tableModel.canAddNewRow()) { return; } __dirty = true; int row = __worksheet.getRowCount(); StateMod_GraphNode n = new StateMod_GraphNode(); __worksheet.addRow(n); n.setType(""); n.setID(""); n.setSwitch(-1); __tableModel.setDirty(true); // when a row is added, mark the second and third columns // as uneditable. They will be set to editable as soon as // the user enters a value in the first column __worksheet.setCellEditable(row, 1, false); __worksheet.setCellEditable(row, 2, false); } else if (action.Equals(__BUTTON_CLEAR_LIST)) { __dirty = true; __worksheet.clear(); setMessages("Add station to list.", "Ready"); __tableModel.setDirty(true); } else if (action.Equals(__BUTTON_CLOSE)) { closeWindow(); } else if (action.Equals(__BUTTON_DELETE_ROW)) { int[] rows = __worksheet.getSelectedRows(); int length = rows.Length; __tableModel.setDirty(true); if (length == 0) { return; } for (int i = (length - 1); i >= 0; i--) { __worksheet.deleteRow(rows[i]); } __dirty = true; setMessages("Time series list has changed.", "Ready"); } else if (action.Equals(__BUTTON_HELP)) { // REVISIT HELP (JTS - 2003-07-09) } else if (action.Equals(__BUTTON_SAVE_FILE)) { JGUIUtil.setWaitCursor(this, true); string lastDirectorySelected = JGUIUtil.getLastFileDialogDirectory(); JFileChooser fc = null; if (!string.ReferenceEquals(lastDirectorySelected, null)) { fc = new JFileChooser(lastDirectorySelected); } else { fc = new JFileChooser(); } fc.setDialogTitle("Select Output Control File"); SimpleFileFilter @out = new SimpleFileFilter("out", "StateMod Output Control Files"); fc.addChoosableFileFilter(@out); SimpleFileFilter tpl = new SimpleFileFilter("tpo", "StateMod Output Control Files"); fc.addChoosableFileFilter(tpl); SimpleFileFilter xou = new SimpleFileFilter("xou", "StateMod Output Control Files"); fc.addChoosableFileFilter(xou); fc.setAcceptAllFileFilterUsed(false); fc.setFileFilter(tpl); fc.setDialogType(JFileChooser.SAVE_DIALOG); JGUIUtil.setWaitCursor(this, false); int retVal = fc.showSaveDialog(this); if (retVal != JFileChooser.APPROVE_OPTION) { return; } string currDir = (fc.getCurrentDirectory()).ToString(); if (!currDir.Equals(lastDirectorySelected, StringComparison.OrdinalIgnoreCase)) { JGUIUtil.setLastFileDialogDirectory(currDir); } string filename = fc.getSelectedFile().getName(); FileFilter ff = fc.getFileFilter(); if (ff == @out) { filename = IOUtil.enforceFileExtension(filename, "out"); } else if (ff == tpl) { filename = IOUtil.enforceFileExtension(filename, "tpo"); } else if (ff == xou) { filename = IOUtil.enforceFileExtension(filename, "xou"); } __dirty = false; __tableModel.setDirty(false); System.Collections.IList theGraphNodes = __worksheet.getAllData(); try { StateMod_GraphNode.writeStateModOutputControlFile(null, currDir + File.separator + filename, theGraphNodes, null); } catch (Exception e) { Message.printWarning(1, routine, "Error saving output control file\n" + "\"" + currDir + File.separator + filename + "\"", this); Message.printWarning(2, routine, e); } } else if (action.Equals(__BUTTON_LOAD_FILE)) { JGUIUtil.setWaitCursor(this, true); string lastDirectorySelected = JGUIUtil.getLastFileDialogDirectory(); JFileChooser fc = null; if (!string.ReferenceEquals(lastDirectorySelected, null)) { fc = new JFileChooser(lastDirectorySelected); } else { fc = new JFileChooser(); } fc.setDialogTitle("Select Output Control File"); SimpleFileFilter @out = new SimpleFileFilter("out", "StateMod Output Control Files"); fc.addChoosableFileFilter(@out); SimpleFileFilter tpl = new SimpleFileFilter("tpo", "StateMod Output Control Files"); fc.addChoosableFileFilter(tpl); SimpleFileFilter xou = new SimpleFileFilter("xou", "StateMod Output Control Files"); fc.addChoosableFileFilter(xou); fc.setAcceptAllFileFilterUsed(false); fc.setFileFilter(tpl); fc.setDialogType(JFileChooser.OPEN_DIALOG); JGUIUtil.setWaitCursor(this, false); int retVal = fc.showOpenDialog(this); if (retVal != JFileChooser.APPROVE_OPTION) { return; } string currDir = (fc.getCurrentDirectory()).ToString(); if (!currDir.Equals(lastDirectorySelected, StringComparison.OrdinalIgnoreCase)) { JGUIUtil.setLastFileDialogDirectory(currDir); } string filename = fc.getSelectedFile().getName(); JGUIUtil.setWaitCursor(this, true); __dirty = false; System.Collections.IList theGraphNodes = new List <object>(20, 1); try { __worksheet.clear(); __tableModel.setDirty(false); StateMod_GraphNode.readStateModOutputControlFile(theGraphNodes, currDir + File.separator + filename); int size = theGraphNodes.Count; StateMod_GraphNode g = null; int row = 0; for (int i = 0; i < size; i++) { row = __worksheet.getRowCount(); g = (StateMod_GraphNode)theGraphNodes[i]; if (i == 0) { if (g.getID().Equals("All")) { __useAllJCheckBox.setSelected(true); } else { __useAllJCheckBox.setSelected(false); } } __worksheet.addRow(g); __tableModel.fillIDColumn(row, g.getType()); } __worksheet.setData(theGraphNodes); } catch (Exception e) { Message.printWarning(1, routine, "Error loading output control file\n" + "\"" + currDir + File.separator + filename + "\"", this); Message.printWarning(2, routine, e); } JGUIUtil.setWaitCursor(this, false); } else if (action.Equals(__CHECKBOX_USE_ALL)) { // if the use all checkbox is selected, subtle changes from the // default functionality are made. The buttons to add and // delete rows are disabled, and the ID of the only record // in the worksheet is set to "All". This ID value is used // in the table model to determine when the checkbox is // selected. In addition, the ComboBox functionality of the // first and third data columns is turned off. if (__useAllJCheckBox.isSelected()) { __addRowButton.setEnabled(false); __deleteRowButton.setEnabled(false); __worksheet.setColumnJComboBoxValues(0, null); __worksheet.setColumnJComboBoxValues(2, null); __worksheet.clear(); StateMod_GraphNode g = new StateMod_GraphNode(); g.setID("All"); __worksheet.setCellEditable(0, 0, false); __worksheet.setCellEditable(0, 1, false); __worksheet.setCellEditable(0, 2, false); __worksheet.addRow(g); } else { __addRowButton.setEnabled(true); __deleteRowButton.setEnabled(true); System.Collections.IList v = StateMod_Util.arrayToList(StateMod_GraphNode.node_types); v.Add("Other"); __worksheet.setColumnJComboBoxValues(0, v); __worksheet.clear(); System.Collections.IList offOn = new List <object>(); offOn.Add("Off"); offOn.Add("On"); __worksheet.setCellEditable(0, 0, true); __worksheet.setColumnJComboBoxValues(2, offOn); } } }
/// <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); __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("Instream flow:")); info_panel.add(new JLabel(__currentInstreamFlow.getID())); info_panel.add(new JLabel("Instream flow name:")); info_panel.add(new JLabel(__currentInstreamFlow.getName())); if (__editable) { p1.add(__addRight); p1.add(__deleteRight); } 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 { System.Collections.IList v = new List <object>(); System.Collections.IList v2 = __currentInstreamFlow.getRights(); for (int i = 0; i < v2.Count; i++) { v.Add(((StateMod_InstreamFlowRight)(v2[i])).clone()); } StateMod_InstreamFlowRight_TableModel tmi = new StateMod_InstreamFlowRight_TableModel(v, __editable, true); StateMod_InstreamFlowRight_CellRenderer cri = new StateMod_InstreamFlowRight_CellRenderer(tmi); jsw = new JScrollWorksheet(cri, tmi, p); __worksheet = jsw.getJWorksheet(); widths = cri.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); System.Collections.IList v = new List <object>(); v.Add("0 - Off"); v.Add("1 - On"); __worksheet.setColumnJComboBoxValues(StateMod_InstreamFlowRight_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); __addRight.addActionListener(this); __deleteRight.addActionListener(this); __helpJButton.addActionListener(this); __closeJButton.addActionListener(this); cancelJButton.addActionListener(this); applyJButton.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> /// Responds to action performed events. </summary> /// <param name="e"> the ActionEvent that happened. </param> public virtual void actionPerformed(ActionEvent e) { string routine = "StateMod_DelayTable_JFrame" + ".actionPerformed"; if (Message.isDebugOn) { Message.printDebug(1, routine, "In actionPerformed: " + e.getActionCommand()); } string action = e.getActionCommand(); if (action.Equals(__BUTTON_HELP)) { // REVISIT HELP (JTS - 2003-06-09) } else if (action.Equals(__BUTTON_CLOSE)) { closeWindow(); } else if (action.Equals(__BUTTON_APPLY)) { saveDelayTable(); int size = __delaysVector.Count; StateMod_DelayTable dt = null; bool changed = false; for (int i = 0; i < size; i++) { dt = (StateMod_DelayTable)__delaysVector[i]; if (!changed && dt.changed()) { changed = true; } dt.createBackup(); } if (changed) { __dataset.setDirty(__componentType, true); } } else if (action.Equals(__BUTTON_CANCEL)) { __worksheetR.deselectAll(); int size = __delaysVector.Count; StateMod_DelayTable dt = null; bool changed = false; for (int i = 0; i < size; i++) { dt = (StateMod_DelayTable)__delaysVector[i]; if (!changed && dt.changed()) { changed = true; } dt.restoreOriginal(); } if (__dataset_wm != null) { __dataset_wm.closeWindow(__window_type); } else { JGUIUtil.close(this); } } else if (action.Equals(__BUTTON_ADD_RETURN)) { int row = __worksheetR.getSelectedRow(); int total_num_rows = __worksheetR.getRowCount() - 1; if (row == -1) { row = total_num_rows; } if (row != -1) { if (row == total_num_rows) { int x = new ResponseJDialog(this, "Insert row", "Do you wish to add a new row above " + "the last row?\n" + "uniquetempvar.response(); if (x == ResponseJDialog.CANCEL) { return; } else if (x == ResponseJDialog.NO) { row += 1; } } __worksheetR.insertRowAt(new double?(0), row); __worksheetR.scrollToRow(row); __worksheetR.selectRow(row); } else { __worksheetR.addRow(new double?(0)); __worksheetR.scrollToRow(0); __worksheetR.selectRow(0); } __deleteReturn.setEnabled(true); } else if (action.Equals(__BUTTON_DELETE_RETURN)) { int row = __worksheetR.getSelectedRow(); if (row != -1) { int x = (new ResponseJDialog(this, "Delete Return", "Delete return?", ResponseJDialog.YES | ResponseJDialog.NO)).response(); if (x == ResponseJDialog.NO) { return; } //StateMod_DelayTable dt = (StateMod_DelayTable) //__worksheetL.getRowData( //__worksheetL.getSelectedRow()); __worksheetR.deleteRow(row); __deleteReturn.setEnabled(false); } else { Message.printWarning(1, routine, "Must select desired right to delete."); } } else if (e.getSource() == __findNextDelay) { searchLeftWorksheet(__worksheetL.getSelectedRow() + 1); } else if (e.getSource() == __searchID) { searchLeftWorksheet(); } else { if (__worksheetL.getSelectedRow() == -1) { new ResponseJDialog(this, "You must first select a delay from the list.", ResponseJDialog.OK); return; } else if (e.getSource() == __graphDelayJButton) { try { __worksheetR.deselectAll(); int index = __worksheetL.getSelectedRow(); if (index == -1) { return; } StateMod_DelayTable currentDelay = ((StateMod_DelayTable) __delaysVector[index]); int j; DateTime date; TSIdent tsident = new TSIdent(); tsident.setLocation(currentDelay.getID()); tsident.setSource("StateMod"); if (__monthly_data) { tsident.setInterval("Month"); } else { tsident.setInterval("Day"); } tsident.setType("Delay"); DateTime date1 = null; DateTime date2 = null; int interval_base; if (__monthly_data) { date1 = new DateTime(DateTime.PRECISION_MONTH); date2 = new DateTime(DateTime.PRECISION_MONTH); interval_base = TimeInterval.MONTH; } else { date1 = new DateTime(DateTime.PRECISION_DAY); date2 = new DateTime(DateTime.PRECISION_DAY); interval_base = TimeInterval.DAY; } date1.setMonth(1); date1.setYear(1); date2.setMonth(1); date2.setYear(1); date2.addInterval(interval_base, (currentDelay.getNdly() - 1)); TS ts = null; if (__monthly_data) { ts = new MonthTS(); } else { ts = new DayTS(); } ts.setDate1(date1); ts.setDate2(date2); ts.setIdentifier(tsident); if (__monthly_data) { ts.setDescription(ts.getLocation() + " Monthly Delay Table"); } else { ts.setDescription(ts.getLocation() + " Daily Delay Table"); } ts.setDataType("Delay"); ts.setDataUnits(currentDelay.getUnits()); ts.allocateDataSpace(); double max = 0.0; for (date = new DateTime(date1), j = 0; date.lessThanOrEqualTo(date2); date.addInterval(interval_base, 1), j++) { ts.setDataValue(date, currentDelay.getRet_val(j)); if (currentDelay.getRet_val(j) > max) { max = currentDelay.getRet_val(j); } } IList<TS> tslist = new List<TS>(); tslist.Add(ts); PropList graphProps = new PropList("TSView"); // If dealing with small values, use a high // of precision... if (max < 1.0) { graphProps.set("YAxisPrecision","6"); graphProps.set("OutputPrecision","6"); } else { graphProps.set("YAxisPrecision","3"); graphProps.set("OutputPrecision","3"); } graphProps.set("InitialView", "Graph"); graphProps.set("TotalWidth", "600"); graphProps.set("TotalHeight", "400"); if (__monthly_data) { graphProps.set("Title", ts.getLocation() + " Monthly Delay Table"); } else { graphProps.set("Title", ts.getLocation() + " Daily Delay Table"); } graphProps.set("DisplayFont", "Courier"); graphProps.set("DisplaySize", "11"); graphProps.set("PrintFont", "Courier"); graphProps.set("PrintSize", "7"); graphProps.set("PageLength", "100"); new TSViewJFrame(tslist, graphProps); } catch (Exception) { Message.printWarning(1, routine, "Unable to graph delay. "); } } } }
/// <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); }