/// <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> /// 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> /// Responds to action performed events. </summary> /// <param name="e"> the ActionEvent that happened. </param> public virtual void actionPerformed(ActionEvent e) { string routine = "StateMod_Plan_Return_JFrame.actionPerformed"; string action = e.getActionCommand(); if (action.Equals(__BUTTON_ADD_RETURN)) { StateMod_ReturnFlow aReturn = new StateMod_ReturnFlow(StateMod_DataSet.COMP_PLAN_RETURN); aReturn._isClone = true; StateMod_ReturnFlow last = (StateMod_ReturnFlow)__worksheet.getLastRowData(); if (last == null) { aReturn.setID(StateMod_Util.createNewID(__currentPlan.getID())); aReturn.setCgoto(__currentPlan.getID()); } else { aReturn.setID(StateMod_Util.createNewID(last.getID())); aReturn.setCgoto(last.getCgoto()); } __worksheet.scrollToLastRow(); __worksheet.addRow(aReturn); __worksheet.selectLastRow(); __deleteReturn_JButton.setEnabled(true); } else if (action.Equals(__BUTTON_DEL_RETURN)) { int row = __worksheet.getSelectedRow(); if (row != -1) { int x = (new ResponseJDialog(this, "Delete return", "Delete plan return?", ResponseJDialog.YES | ResponseJDialog.NO)).response(); if (x == ResponseJDialog.NO) { return; } __worksheet.cancelEditing(); __worksheet.deleteRow(row); __deleteReturn_JButton.setEnabled(false); } else { Message.printWarning(1, routine, "Must select desired return to delete."); } } else if (action.Equals(__BUTTON_CLOSE)) { if (saveData()) { setVisible(false); dispose(); } } else if (action.Equals(__BUTTON_APPLY)) { saveData(); } else if (action.Equals(__BUTTON_CANCEL)) { setVisible(false); dispose(); } else if (e.getSource() == __help_JButton) { // TODO HELP (JTS - 2003-06-09) } }