/// <summary> /// Constructor. </summary> /// <param name="tableModel"> the table model for which this class renders cells. </param> public StateMod_RiverNetworkNode_CellRenderer(StateMod_RiverNetworkNode_TableModel tableModel) { __tableModel = tableModel; }
/// <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); }