/// <summary> /// Sets up the data to be displayed in the table. /// </summary> private void setupData() { int num = 0; int size = _data.size(); StateMod_Diversion dt = null; string id = null; __data = new System.Collections.IList[__COLUMNS]; for (int i = 0; i < __COLUMNS; i++) { __data[i] = new List <object>(); } __rowMap = new List <object>(); double total = 0; int rowCount = 0; StateMod_ReturnFlow rf = null; System.Collections.IList returnFlows = null; for (int i = 0; i < size; i++) { total = 0; dt = (StateMod_Diversion)_data.get(i); id = dt.getID(); num = dt.getNrtn(); returnFlows = dt.getReturnFlows(); for (int j = 0; j < num; j++) { rf = (StateMod_ReturnFlow)returnFlows[j]; __data[__COL_ID].Add(id); __data[__COL_NODE_ID].Add(rf.getCrtnid()); __data[__COL_PERCENT].Add(new double?(rf.getPcttot())); __data[__COL_DELAY_ID].Add("" + rf.getIrtndl()); total += rf.getPcttot(); __rowMap.Add(new int?(rowCount)); rowCount++; } __data[__COL_ID].Add(id); __data[__COL_NODE_ID].Add("TOTAL"); __data[__COL_PERCENT].Add(new double?(total)); __data[__COL_DELAY_ID].Add(""); rowCount++; } _rows = rowCount; }
/// <summary> /// Perform the query. Currently only diversion stations are supported. /// </summary> private void doQuery() { string routine = "StateMod_QueryTool_JFrame.doQuery", message; InputFilter_JPanel ifp = __input_filter_diversion_JPanel; InputFilter filter = null; int size; // Size of data Vector int i; // Loop for data items. DataSetComponent comp = null; string where, @operator, input; int where_length = 0; // Length of "where", to optimize code. bool do_int, do_double, do_string; string input_string; // Data parameters to check, as int input_int; // transferred from the data objects. double input_double; bool do_ID, do_Name, do_RiverNodeID, do_OnOff, do_Capacity, do_ReplaceResOption, do_DailyID, do_UserName, do_DemandType, do_EffAnnual, do_Area, do_UseType, do_DemandSource; bool[] matches = null; // Indicates if a data item matches all // the filter criteria. bool item_matches; // Indicates whether the itme matches a // single filter criteria. bool[] @checked = null; // Indicates whether a data item has // already been checked for a criteria. // If checked and false, then a "true" // should not reset the false. int nfg = 0; // Number of filter groups. do_int = false; // Whether the data item is an integer. do_double = false; // Whether the data item is a double. do_string = false; // Whether the data item is a string. StateMod_Diversion dds = null; __status_JTextField.setText(__Wait); JGUIUtil.setWaitCursor(this, true); if (ifp is StateMod_Diversion_InputFilter_JPanel) { input_int = StateMod_Util.MISSING_INT; input_double = StateMod_Util.MISSING_DOUBLE; input_string = StateMod_Util.MISSING_STRING; comp = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DIVERSION_STATIONS); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Diversion> dds_Vector = (java.util.List<StateMod_Diversion>)comp.getData(); IList <StateMod_Diversion> dds_Vector = (IList <StateMod_Diversion>)comp.getData(); size = 0; if (dds_Vector != null) { size = dds_Vector.Count; } // REVISIT SAM 2004-10-27 Remove when debugging is complete //Message.printStatus ( 2, routine, //"Searching " + size + " diversion stations." ); // Initialize the arrays indicating if data objects have been // checked and whether they matched the filter(s)... if (size > 0) { matches = new bool[size]; @checked = new bool[size]; } for (i = 0; i < size; i++) { matches[i] = false; @checked[i] = false; } // Loop through the where clauses... nfg = ifp.getNumFilterGroups(); for (int ifg = 0; ifg < nfg; ifg++) { // Get the filter information... filter = ifp.getInputFilter(ifg); where = filter.getWhereInternal(); where_length = where.Length; @operator = ifp.getOperator(ifg); input = filter.getInput(false); // REVISIT SAM 2004-10-27 Remove when debugging is // complete //Message.printStatus ( 2, routine, //"where=" + where + " operator=" + operator + //" input=" + input ); // Initialize flags to indicate what data will be // checked... do_int = false; do_double = false; do_string = false; do_ID = false; do_Name = false; do_RiverNodeID = false; do_OnOff = false; do_Capacity = false; do_ReplaceResOption = false; do_DailyID = false; do_UserName = false; do_DemandType = false; do_EffAnnual = false; do_Area = false; do_UseType = false; do_DemandSource = false; // The following checks on "where" need to match the // input filter internal where labels assigned in // StateMod_Diversion_InputFilter_JPanel. // List in the order of the StateMod documentation... if (where.Equals("ID", StringComparison.OrdinalIgnoreCase)) { do_string = true; do_ID = true; } else if (where.Equals("Name", StringComparison.OrdinalIgnoreCase)) { do_string = true; do_Name = true; } else if (where.Equals("RiverNodeID", StringComparison.OrdinalIgnoreCase)) { do_string = true; do_RiverNodeID = true; } else if (where.Equals("OnOff", StringComparison.OrdinalIgnoreCase) && StringUtil.isInteger(input)) { do_int = true; do_OnOff = true; } else if (where.Equals("Capacity", StringComparison.OrdinalIgnoreCase) && StringUtil.isDouble(input)) { do_double = true; do_Capacity = true; } else if (where.Equals("ReplaceResOption", StringComparison.OrdinalIgnoreCase) && StringUtil.isInteger(input)) { do_int = true; do_ReplaceResOption = true; } else if (where.Equals("DailyID", StringComparison.OrdinalIgnoreCase)) { do_string = true; do_DailyID = true; } else if (where.Equals("UserName", StringComparison.OrdinalIgnoreCase)) { do_string = true; do_UserName = true; } else if (where.Equals("DemandType", StringComparison.OrdinalIgnoreCase)) { do_int = true; do_DemandType = true; } else if (where.Equals("EffAnnual", StringComparison.OrdinalIgnoreCase) && StringUtil.isDouble(input)) { do_double = true; do_EffAnnual = true; } else if (where.Equals("Area", StringComparison.OrdinalIgnoreCase) && StringUtil.isDouble(input)) { do_double = true; do_Area = true; } else if (where.Equals("UseType", StringComparison.OrdinalIgnoreCase) && StringUtil.isInteger(input)) { do_int = true; do_UseType = true; } else if (where.Equals("DemandSource", StringComparison.OrdinalIgnoreCase) && StringUtil.isInteger(input)) { do_int = true; do_DemandSource = true; } else if (where_length == 0) { // WIll match anything. } else { // Unrecognized where... continue; } // REVISIT SAM 2004-10-27 Remove when debugging is // complete /* * Message.printStatus ( 2, routine, * "do_string=" + do_string + " do_int=" + do_int + * "do_double=" + do_double + * " " + do_ID + * " " + do_Name + * " " + do_RiverNodeID + * " " + do_OnOff + * " " + do_Capacity + * " " + do_ReplaceResOption + * " " + do_DailyID + * " " + do_UserName + * " " + do_DemandType + * " " + do_EffAnnual + * " " + do_Area + * " " + do_UseType + * " " + do_DemandSource ); */ for (i = 0; i < size; i++) { dds = (StateMod_Diversion)dds_Vector[i]; // Get the specific data to compare... if (do_ID) { input_string = dds.getID(); } else if (do_Name) { input_string = dds.getName(); } else if (do_RiverNodeID) { input_string = dds.getCgoto(); } else if (do_OnOff) { input_int = dds.getSwitch(); } else if (do_Capacity) { input_double = dds.getDivcap(); } else if (do_ReplaceResOption) { input_int = dds.getIreptype(); } else if (do_DailyID) { input_string = dds.getCdividy(); } else if (do_UserName) { input_string = dds.getUsername(); } else if (do_DemandType) { input_int = dds.getIdvcom(); } else if (do_EffAnnual) { input_double = dds.getDivefc(); } else if (do_Area) { input_double = dds.getArea(); } else if (do_UseType) { input_int = dds.getIrturn(); } else if (do_DemandSource) { input_int = dds.getDemsrc(); } else { // Unrecognized... continue; } // Compare the data with the input filter... item_matches = false; if (do_string) { item_matches = filter.matches(input_string, @operator, true); } else if (do_int) { item_matches = filter.matches(input_int, @operator); } else if (do_double) { item_matches = filter.matches(input_double, @operator); } if (where_length == 0) { // Always consider a match... item_matches = true; } if (item_matches && (!@checked[i] || (@checked[i] && matches[i]))) { // So far the item matches all // filters... matches[i] = true; } else if (@checked[i] && !item_matches) { // Does not match this filter to reset // result to false... matches[i] = false; } // Indicate that we have checked the item // against at least one filter... @checked[i] = true; } } // Get a count so the Vector can be sized appropriately (this // should be fast)... int match_count = 0; for (i = 0; i < size; i++) { if (matches[i]) { ++match_count; } } // Loop through and set up the matches_Vector... __matches_Vector = null; if (match_count > 0) { __matches_Vector = new List <StateMod_Diversion> (match_count); for (i = 0; i < size; i++) { if (matches[i]) { // The diversion station matches so add // to the list... __matches_Vector.Add(dds_Vector[i]); } } } message = "Matched " + match_count + " diversion stations (from original " + size + ")."; Message.printStatus(2, routine, message); __message_JTextField.setText(message); __status_JTextField.setText(__Ready); JGUIUtil.setWaitCursor(this, false); } if (__matches_Vector == null) { __display_JButton.setEnabled(false); } else { __display_JButton.setEnabled(true); } }
/// <summary> /// Read diversion information in and store in a java vector. /// The new diversions are added to the end of the previously stored diversions. </summary> /// <param name="filename"> filename containing diversion information </param> /// <exception cref="Exception"> if an error occurs </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static java.util.List<StateMod_Diversion> readStateModFile(String filename) throws Exception public static IList <StateMod_Diversion> readStateModFile(string filename) { string routine = "StateMod_Diversion.readStateModFile"; string iline = null; IList <object> v = new List <object>(9); IList <StateMod_Diversion> theDiversions = new List <StateMod_Diversion>(); int i; int linecount = 0; string s = null; int[] format_0 = new int[] { StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_INTEGER, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING }; int[] format_0w = new int[] { 12, 24, 12, 8, 8, 8, 8, 1, 12 }; int[] format_1 = new int[] { StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER }; int[] format_1w = new int[] { 12, 24, 12, 8, 8, 8, 8, 8, 8 }; int[] format_2 = new int[] { StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER }; int[] format_2w = new int[] { 36, 12, 8, 8 }; StateMod_Diversion aDiversion = null; StateMod_ReturnFlow aReturnNode = null; StreamReader @in = null; Message.printStatus(1, routine, "Reading diversion file: " + filename); try { @in = new StreamReader(IOUtil.getPathUsingWorkingDir(filename)); while (!string.ReferenceEquals((iline = @in.ReadLine()), null)) { ++linecount; // check for comments if (iline.StartsWith("#", StringComparison.Ordinal) || iline.Trim().Length == 0) { continue; } // allocate new diversion node aDiversion = new StateMod_Diversion(); // line 1 if (Message.isDebugOn) { Message.printDebug(50, routine, "line 1: " + iline); } StringUtil.fixedRead(iline, format_0, format_0w, v); aDiversion.setID(((string)v[0]).Trim()); aDiversion.setName(((string)v[1]).Trim()); aDiversion.setCgoto(((string)v[2]).Trim()); aDiversion.setSwitch((int?)v[3]); aDiversion.setDivcap((double?)v[4]); aDiversion.setIreptype(((int?)v[6])); aDiversion.setCdividy(((string)v[8]).Trim()); // line 2 iline = @in.ReadLine(); ++linecount; if (Message.isDebugOn) { Message.printDebug(50, routine, "line 2: " + iline); } StringUtil.fixedRead(iline, format_1, format_1w, v); aDiversion.setUsername(((string)v[1]).Trim()); aDiversion.setIdvcom(((int?)v[3])); int nrtn = ((int?)v[4]).Value; aDiversion.setDivefc(((double?)v[5])); aDiversion.setArea(((double?)v[6])); aDiversion.setIrturn(((int?)v[7])); aDiversion.setDemsrc(((int?)v[8])); // get the efficiency information if (aDiversion.getDivefc() < 0) { // Negative value indicates monthly efficiencies will follow... iline = @in.ReadLine(); ++linecount; // Free format... char[] seps = { ' ', '\t', '\n', '\r', '\f' }; string[] split = iline.Split(seps); if (split != null && split.Length == 12) { for (i = 0; i < 12; i++) { aDiversion.setDiveff(i, split[0]); } } } else { // Annual efficiency so set monthly efficiencies to the annual... aDiversion.setDiveff(0, aDiversion.getDivefc()); aDiversion.setDiveff(1, aDiversion.getDivefc()); aDiversion.setDiveff(2, aDiversion.getDivefc()); aDiversion.setDiveff(3, aDiversion.getDivefc()); aDiversion.setDiveff(4, aDiversion.getDivefc()); aDiversion.setDiveff(5, aDiversion.getDivefc()); aDiversion.setDiveff(6, aDiversion.getDivefc()); aDiversion.setDiveff(7, aDiversion.getDivefc()); aDiversion.setDiveff(8, aDiversion.getDivefc()); aDiversion.setDiveff(9, aDiversion.getDivefc()); aDiversion.setDiveff(10, aDiversion.getDivefc()); aDiversion.setDiveff(11, aDiversion.getDivefc()); } // get the return information for (i = 0; i < nrtn; i++) { iline = @in.ReadLine(); ++linecount; StringUtil.fixedRead(iline, format_2, format_2w, v); aReturnNode = new StateMod_ReturnFlow(StateMod_DataSet.COMP_DIVERSION_STATIONS); s = ((string)v[1]).Trim(); if (s.Length <= 0) { aReturnNode.setCrtnid(((string)v[0]).Trim()); Message.printWarning(3, routine, "Return node for structure \"" + aDiversion.getID() + "\" is blank. "); } else { aReturnNode.setCrtnid(s); } aReturnNode.setPcttot(((double?)v[2])); aReturnNode.setIrtndl(((int?)v[3])); aDiversion.addReturnFlow(aReturnNode); } // Set the diversion to not dirty because it was just initialized... aDiversion.setDirty(false); // add the diversion to the vector of diversions theDiversions.Add(aDiversion); } } catch (Exception e) { Message.printWarning(3, routine, "Error reading line " + linecount + " \"" + iline + "\""); Message.printWarning(3, routine, e); throw e; } finally { if (@in != null) { @in.Close(); } } return(theDiversions); }
/// <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_Diversion smd = (StateMod_Diversion)_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_CAPACITY: return(new double?(smd.getDivcap())); case COL_REPLACE_RES_OPTION: return(new int?(smd.getIreptype())); case COL_DAILY_ID: return(smd.getCdividy()); case COL_USER_NAME: return(smd.getUsername()); case COL_DEMAND_TYPE: return(new int?(smd.getIdvcom())); case COL_AREA: return(new double?(smd.getArea())); case COL_USE_TYPE: return(new int?(smd.getIrturn())); case COL_DEMAND_SOURCE: return(new int?(smd.getDemsrc())); case COL_EFF_ANNUAL: return(new double?(smd.getDivefc())); case COL_EFF_01: return(new double?(smd.getDiveff(0))); case COL_EFF_02: return(new double?(smd.getDiveff(1))); case COL_EFF_03: return(new double?(smd.getDiveff(2))); case COL_EFF_04: return(new double?(smd.getDiveff(3))); case COL_EFF_05: return(new double?(smd.getDiveff(4))); case COL_EFF_06: return(new double?(smd.getDiveff(5))); case COL_EFF_07: return(new double?(smd.getDiveff(6))); case COL_EFF_08: return(new double?(smd.getDiveff(7))); case COL_EFF_09: return(new double?(smd.getDiveff(8))); case COL_EFF_10: return(new double?(smd.getDiveff(9))); case COL_EFF_11: return(new double?(smd.getDiveff(10))); case COL_EFF_12: return(new double?(smd.getDiveff(11))); default: return(""); } }
/// <summary> /// Sets up the data Vectors to display the diversion collection data in the /// GUI. /// </summary> private void setupData() { int[] years = null; int len = 0; int size = _data.size(); int size2 = 0; StateMod_Diversion l = null; string colType = null; string id = null; string partType = null; System.Collections.IList ids = null; __data = new System.Collections.IList[__COLUMNS]; for (int i = 0; i < __COLUMNS; i++) { __data[i] = new List<object>(); } int rows = 0; for (int i = 0; i < size; i++) { l = (StateMod_Diversion)_data.get(i); id = l.getID(); // div = new Integer(l.getCollectionDiv()); years = l.getCollectionYears(); colType = l.getCollectionType(); partType = l.getCollectionPartType(); if (years == null) { len = 0; } else { len = years.Length; } for (int j = 0; j < len; j++) { ids = l.getCollectionPartIDs(years[j]); if (ids == null) { size2 = 0; } else { size2 = ids.Count; } for (int k = 0; k < size2; k++) { __data[__COL_ID].Add(id); // __data[__COL_DIV].add(div); __data[__COL_YEAR].Add(new int?(years[j])); __data[__COL_COL_TYPE].Add(colType); __data[__COL_PART_TYPE].Add(partType); __data[__COL_PART_ID].Add(ids[k]); rows++; } } } _rows = rows; }
/// <summary> /// Sets up the GUI. /// </summary> public virtual void setupGUI() { string routine = "setupGUI"; addWindowListener(this); __addReturnFlow = new JButton(__BUTTON_ADD_RETURN_FLOW); __deleteReturnFlow = new JButton(__BUTTON_DEL_RETURN_FLOW); __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); JPanel p1 = new JPanel(); p1.setLayout(new FlowLayout(FlowLayout.RIGHT)); 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("Diversion:")); info_panel.add(new JLabel(__currentDiv.getID())); info_panel.add(new JLabel("Diversion name:")); info_panel.add(new JLabel(__currentDiv.getName())); if (__editable) { p1.add(__addReturnFlow); p1.add(__deleteReturnFlow); __deleteReturnFlow.setEnabled(false); } // p1.add(__helpJButton); p1.add(applyJButton); p1.add(cancelJButton); p1.add(__closeJButton); PropList p = new PropList("StateMod_Diversion_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 { //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_RiverNetworkNode> nodes = (java.util.List <StateMod_RiverNetworkNode>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK).getData()); IList <StateMod_RiverNetworkNode> nodes = (IList <StateMod_RiverNetworkNode>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK).getData()); IList <StateMod_ReturnFlow> v = new List <StateMod_ReturnFlow>(); IList <StateMod_ReturnFlow> v2 = __currentDiv.getReturnFlows(); int size = v2.Count; StateMod_ReturnFlow rf; for (int i = 0; i < size; i++) { rf = (StateMod_ReturnFlow)v2[i].clone(); rf.setCrtnid(rf.getCrtnid() + StateMod_Util.findNameInVector(rf.getCrtnid(), nodes, true)); v.Add(rf); } StateMod_ReturnFlow_TableModel tmd = new StateMod_ReturnFlow_TableModel(__dataset, v, __editable, true); StateMod_ReturnFlow_CellRenderer crd = new StateMod_ReturnFlow_CellRenderer(tmd); jsw = new JScrollWorksheet(crd, tmd, p); __worksheet = jsw.getJWorksheet(); // TODO SAM 2017-03-15 something not right here - looks like original list variable was wrong //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 = crd.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(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); __addReturnFlow.addActionListener(this); __deleteReturnFlow.addActionListener(this); __closeJButton.addActionListener(this); __helpJButton.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(530, 280); 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_Diversion_Right_JFrame::actionPerformed"; string action = e.getActionCommand(); if (action.Equals(__BUTTON_ADD_RIGHT)) { StateMod_DiversionRight aRight = new StateMod_DiversionRight(); aRight._isClone = true; StateMod_DiversionRight last = (StateMod_DiversionRight)__worksheet.getLastRowData(); if (last == null) { aRight.setID(StateMod_Util.createNewID(__currentDiv.getID())); aRight.setCgoto(__currentDiv.getID()); } else { aRight.setID(StateMod_Util.createNewID(last.getID())); aRight.setCgoto(last.getCgoto()); } __worksheet.addRow(aRight); __worksheet.scrollToLastRow(); __worksheet.selectLastRow(); __deleteRight.setEnabled(true); } else if (action.Equals(__BUTTON_DEL_RIGHT)) { int row = __worksheet.getSelectedRow(); if (row != -1) { int x = (new ResponseJDialog(this, "Delete Diversion Right", "Delete diversion right?", ResponseJDialog.YES | ResponseJDialog.NO)).response(); if (x == ResponseJDialog.NO) { return; } __worksheet.cancelEditing(); __worksheet.deleteRow(row); __deleteRight.setEnabled(false); } else { Message.printWarning(1, routine, "Must select desired right 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 (action.Equals(__BUTTON_HELP)) { // REVISIT (JTS - 2003-06-10) } }