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