/// <summary> /// Constructor. </summary> /// <param name="dataset"> the dataset in which the data is contained. </param> /// <param name="plan"> the plan for which to display return information. </param> /// <param name="editable"> whether the gui data is editable or not. </param> public StateMod_Plan_Return_JFrame(StateMod_DataSet dataset, StateMod_Plan plan, bool editable) { StateMod_GUIUtil.setTitle(this, dataset, plan.getName() + " - Plan Return Flow Table Assignment", null); JGUIUtil.setIcon(this, JGUIUtil.getIconImage()); __currentPlan = plan; IList <StateMod_ReturnFlow> allReturns = (IList <StateMod_ReturnFlow>)dataset.getComponentForComponentType(StateMod_DataSet.COMP_PLAN_RETURN).getData(); __currentPlanReturnList = (IList <StateMod_ReturnFlow>)StateMod_Util.getDataList(allReturns, plan.getID()); Message.printStatus(2, "", "Have " + __currentPlanReturnList.Count + " return records for plan \"" + __currentPlan.getID() + "\" uniquetempvar."); __dataset = dataset; // TODO SAM 2011-01-02 For now editing is disabled... editable = false; __editable = editable; setupGUI(); }
/// <summary> /// Returns the data that should be placed in the JTable at the given row and column. </summary> /// <param name="row"> the row for which to return data. </param> /// <param name="col"> the column for which to return data. </param> /// <returns> the data that should be placed in the JTable at the given row and col. </returns> public virtual object getValueAt(int row, int col) { if (_sortOrder != null) { row = _sortOrder[row]; } StateMod_Plan smp = (StateMod_Plan)_data.get(row); switch (col) { case COL_ID: return(smp.getID()); case COL_NAME: return(smp.getName()); case COL_RIVER_NODE_ID: return(smp.getCgoto()); case COL_ON_OFF: return(new int?(smp.getSwitch())); case COL_TYPE: return(new int?(smp.getIPlnTyp())); case COL_EFFICIENCY: return(new int?(smp.getPeffFlag())); case COL_RETURN_FLOW_TABLE: return(new int?(smp.getIPrf())); case COL_FAILURE_SWITCH: return(new int?(smp.getIPfail())); case COL_INITIAL_STORAGE: return(new double?(smp.getPsto1())); case COL_SOURCE: return(smp.getPsource()); default: return(""); } }
/// <summary> /// Returns the data that should be placed in the JTable at the given row and column. </summary> /// <param name="row"> the row for which to return data. </param> /// <param name="col"> the column for which to return data. </param> /// <returns> the data that should be placed in the JTable at the given row and col. </returns> public virtual object getValueAt(int row, int col) { if (_sortOrder != null) { row = _sortOrder[row]; } StateMod_Plan smd = (StateMod_Plan)_data.get(row); switch (col) { case COL_ID: return(smd.getID()); case COL_NAME: return(smd.getName()); case COL_RIVER_NODE_ID: return(smd.getCgoto()); case COL_ON_OFF: return(new int?(smd.getSwitch())); case COL_TYPE: return(new int?(smd.getIPlnTyp())); case COL_RETURN_TYPE: return(new int?(smd.getIPrf())); case COL_FAILURE_SWITCH: return(new int?(smd.getIPfail())); case COL_INITIAL_STORAGE: return(new double?(smd.getPsto1())); case COL_SOURCE_ID: return(smd.getPsource()); case COL_SOURCE_ACCOUNT: return(smd.getIPAcc()); case COL_EFF_FLAG: return(new int?(smd.getPeffFlag())); case COL_EFF_01: case COL_EFF_02: case COL_EFF_03: case COL_EFF_04: case COL_EFF_05: case COL_EFF_06: case COL_EFF_07: case COL_EFF_08: case COL_EFF_09: case COL_EFF_10: case COL_EFF_11: case COL_EFF_12: int peffFlag = smd.getPeffFlag(); if (peffFlag == 1) { return(new double?(smd.getPeff(col - COL_EFF_01))); } else { return(""); } default: return(""); } }
/// <summary> /// Sets up the GUI. /// </summary> public virtual void setupGUI() { string routine = "setupGUI"; addWindowListener(this); PropList p = new PropList("StateMod_Plan_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_Plan_Return_Data_TableModel tmr = new StateMod_Plan_Return_Data_TableModel(__currentPlanReturnList, __editable); StateMod_Plan_Return_Data_CellRenderer crr = new StateMod_Plan_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("Plan:")); info_panel.add(new JLabel(__currentPlan.getID())); info_panel.add(new JLabel("Plan name:")); info_panel.add(new JLabel(__currentPlan.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 plan return data is not implemented."); __close_JButton.setEnabled(false); __close_JButton.setToolTipText("Editing plan 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); } }