/// <summary> /// Constructor. </summary> /// <param name="dataset"> the dataset for which to display data set component information. </param> /// <exception cref="Exception"> if an invalid data or dmi was passed in. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public StateMod_Response_TableModel(StateMod_DataSet dataset) throws Exception public StateMod_Response_TableModel(StateMod_DataSet dataset) { __dataset = dataset; // get the array of the ints that refer to the groups in // the data set. int[] groups = __dataset.getComponentGroupNumbers(); System.Collections.IList ints = new List <object>(); DataSetComponent dsc = null; System.Collections.IList v = null; // Go through each of the groups and get their data out. Group data // consists of the DataSetComponents the group contains. For each // of the group's DataSetComponents, if it has data, then add its // component type to the accumulation vector. for (int i = 0; i < groups.Length; i++) { dsc = __dataset.getComponentForComponentType(groups[i]); v = (System.Collections.IList)dsc.getData(); if (v == null) { v = new List <object>(); } for (int j = 0; j < v.Count; j++) { dsc = (DataSetComponent)v[j]; // the following makes sure that the response file // is not added here ... the response file is added // below because it must always be in the GUI. if (dsc.getComponentType() != StateMod_DataSet.COMP_RESPONSE && dsc.isVisible()) { ints.Add(new int?(dsc.getComponentType())); } } } // now transfer the numbers of the DataSetComponents with data into // an int array from the Vector. __data = new int[ints.Count + 1]; __data[0] = StateMod_DataSet.COMP_RESPONSE; for (int i = 0; i < ints.Count; i++) { __data[i + 1] = ((int?)ints[i]).Value; } _rows = __data.Length; }
/// <summary> /// From AbstractTableMode. 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]; } object o = (object)_data.get(row); if (o is TS) { TS ts = (TS)o; switch (col) { case COL_ID: return(ts.getIdentifier().ToString()); case COL_NAME: return(ts.getDescription()); default: return(""); } } else if ((__component.getComponentType() == StateMod_DataSet.COMP_IRRIGATION_PRACTICE_TS_YEARLY) || (__component.getComponentType() == StateMod_DataSet.COMP_CONSUMPTIVE_WATER_REQUIREMENT_TS_MONTHLY) || (__component.getComponentType() == StateMod_DataSet.COMP_CONSUMPTIVE_WATER_REQUIREMENT_TS_DAILY) || (__component.getComponentType() == StateMod_DataSet.COMP_STATECU_STRUCTURE)) { // StateCU_Data... StateCU_Data data = (StateCU_Data)_data.get(row); switch (col) { case COL_ID: return(data.getID()); case COL_NAME: return(data.getName()); default: return(""); } } else { // StateMod_Data... StateMod_Data data = (StateMod_Data)_data.get(row); switch (col) { case COL_ID: return(data.getID()); case COL_NAME: return(data.getName()); default: return(""); } } }
/// <summary> /// Constructor. This builds the model for displaying the given component data. </summary> /// <param name="dataset"> StateMod_DataSet that is being displayed. If not a group /// component, the group component will be determined. </param> /// <param name="comp"> the DataSetComponent to be displayed. </param> /// <exception cref="Exception"> an invalid component is passed in. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public StateMod_DataSetComponent_TableModel(StateMod_DataSet dataset, RTi.Util.IO.DataSetComponent comp) throws Exception public StateMod_DataSetComponent_TableModel(StateMod_DataSet dataset, DataSetComponent comp) { System.Collections.IList data = null; string routine = "StateMod_DataSetComponent_TableModel"; // Make sure that the list is for a group component... if ((comp != null) && !comp.isGroup()) { __component_group = comp.getParentComponent(); //Message.printStatus ( 1, routine, //"Component is not a group. Parent is: " +__component_group); } else { __component_group = comp; } if (__component_group == null) { _rows = 0; _data = null; return; } // Figure out the data component that is actually used to get the list // of data objects. For example, if working on climate stations, there // is no list with the group so we need to use the climate stations // component list... int comptype = dataset.lookupPrimaryComponentTypeForComponentGroup(__component_group.getComponentType()); if (comptype >= 0) { __component = dataset.getComponentForComponentType(comptype); } else { comp = null; Message.printWarning(2, routine, "Unable to find primary component for group: " + __component_group.getComponentName()); } if (__component == null) { _rows = 0; } else { data = ((System.Collections.IList)__component.getData()); if (data == null) { _rows = 0; } else { _rows = data.Count; } } _data = data; }
/// <summary> /// Constructor. </summary> /// <param name="dataset"> the dataset for which to display information in the worksheet. </param> /// <exception cref="Exception"> if an invalid data or dmi was passed in. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public StateMod_Save_TableModel(StateMod_DataSet dataset) throws Exception public StateMod_Save_TableModel(StateMod_DataSet dataset) { __dataset = dataset; // get the array of the ints that refer to the groups in // the data set. int[] groups = __dataset.getComponentGroupNumbers(); System.Collections.IList ints = new List <object>(); DataSetComponent dsc = null; System.Collections.IList v = null; // Go through each of the groups and get their data out. Group data // consists of the DataSetComponents the group contains. For each // of the group's DataSetComponents, if it has data, then add its // component type to the accumulation vector. for (int i = 0; i < groups.Length; i++) { dsc = __dataset.getComponentForComponentType(groups[i]); v = (System.Collections.IList)dsc.getData(); if (v == null) { v = new List <object>(); } for (int j = 0; j < v.Count; j++) { dsc = (DataSetComponent)v[j]; // get the dirty components -- they can be saved // (or not). if (dsc.isDirty()) { ints.Add(new int?(dsc.getComponentType())); } } } // now transfer the numbers of the DataSetComponents with data into // an int array from the Vector. __data = new int[ints.Count]; for (int i = 0; i < ints.Count; i++) { __data[i] = ((int?)ints[i]).Value; } _rows = __data.Length; }
/// <summary> /// From AbstractTableMode. 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) { // make sure the row numbers are never sorted ... if (_sortOrder != null) { row = _sortOrder[row]; } if (__component.getComponentType() == StateCU_DataSet.COMP_DELAY_TABLES_MONTHLY) { // StateMod_Data... StateMod_Data data = (StateMod_Data)_data.get(row); switch (col) { // case 0 handled above. case __COL_ID: return(data.getID()); case __COL_NAME: return(data.getName()); default: return(""); } } else { // StateCU_Data... StateCU_Data data = (StateCU_Data)_data.get(row); switch (col) { case __COL_ID: return(data.getID()); case __COL_NAME: return(data.getName()); default: return(""); } } }
/// <summary> /// Checks to see if the mouse event would trigger display of the popup menu. /// The popup menu does not display if it is null. </summary> /// <param name="e"> the MouseEvent that happened. </param> private void showPopupMenu(MouseEvent e) { string routine = "StateMod_DataSet_JTree.showPopupMenu"; if (!e.isPopupTrigger() || !__display_data_objects) { // Do not do anything... return; } TreePath path = getPathForLocation(e.getX(), e.getY()); if (path == null) { return; } __popup_Node = (SimpleJTree_Node)path.getLastPathComponent(); // First remove the menu items that are currently in the menu... __popup_JPopupMenu.removeAll(); object data = null; // Data object associated with the node DataSetComponent comp2; // Used to check components in groups. // Now reset the popup menu based on the selected node... if (__display_data_objects) { // Get the data for the node. If the node is a data object, // the type can be checked to know what to display. // The tree is displaying data objects so the popup will show // specific JFrames for each data group. If the group folder // was selected, then display the JFrame showing the first item // selected. If a specific data item in the group was selected, // then show the specific data item. JMenuItem item; data = __popup_Node.getData(); if (data is DataSetComponent) { // Specific checks need to be done to identify the component group... DataSetComponent comp = (DataSetComponent)data; int comp_type = comp.getComponentType(); if (comp_type == StateMod_DataSet.COMP_CONTROL_GROUP) { // For now display the control file information only... comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_CONTROL); if (comp2.hasData()) { item = new SimpleJMenuItem("Control Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_STREAMGAGE_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_STREAMGAGE_STATIONS); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Stream Gage Station Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_DELAY_TABLE_MONTHLY_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Delay Table Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_DELAY_TABLE_DAILY_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Delay Table Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_DIVERSION_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DIVERSION_STATIONS); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Diversion Properties", this); __popup_JPopupMenu.add(item); } } else if ((comp_type == StateMod_DataSet.COMP_PRECIPITATION_GROUP)) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Precipitation Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_EVAPORATION_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Evaporation Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_RESERVOIR_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_RESERVOIR_STATIONS); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Reservoir Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_INSTREAM_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_INSTREAM_STATIONS); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Instream Flow Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_WELL_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_WELL_STATIONS); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Well Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_PLAN_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_PLANS); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Plan Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_STREAMESTIMATE_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Stream Estimate Station Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_RIVER_NETWORK_GROUP) { // Only add if data are available... comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("River Network Properties", this); __popup_JPopupMenu.add(item); } } else if (comp_type == StateMod_DataSet.COMP_OPERATION_GROUP) { comp2 = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_OPERATION_RIGHTS); if ((comp2 != null) && comp2.hasData()) { item = new SimpleJMenuItem("Operation Rights Properties", this); __popup_JPopupMenu.add(item); } } } // The data are a specific data instance so display the // properties for the specific item if a primary data item. // Control... nothing for now. else if (data is StateMod_StreamGage) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_DelayTable) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_Diversion) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); __popup_JPopupMenu.add(new SimpleJMenuItem(__SUMMARIZE_HOW1 + "\"" + __popup_Node.getText() + "\"" + __SUMMARIZE_HOW2, this)); } else if (data is MonthTS) { // Precipitation or evaporation time series... __popup_JPopupMenu.add(new SimpleJMenuItem(__popup_Node.getText() + __PROPERTIES, this)); __popup_JPopupMenu.add(new SimpleJMenuItem(__SUMMARIZE_HOW1 + "\"" + __popup_Node.getText() + "\"" + __SUMMARIZE_HOW2, this)); } else if (data is StateMod_Reservoir) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_InstreamFlow) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_Well) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_Plan) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_StreamEstimate) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_OperationalRight) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_RiverNetworkNode) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } // Others (e.g., San Juan Sediment) supported later.... else { Message.printWarning(2, routine, "Node data is not recognized"); return; } } // Now display the popup so that the user can select the appropriate menu item... Point pt = JGUIUtil.computeOptimalPosition(e.getPoint(), e.getComponent(), __popup_JPopupMenu); __popup_JPopupMenu.show(e.getComponent(), pt.x, pt.y); }
/// <summary> /// Display the primary data for a component. This method is called when adding nodes under a group node. </summary> /// <param name="comp"> Component to display data. </param> /// <param name="node"> Parent node to display under. </param> private bool displayDataSetComponent(DataSetComponent comp, SimpleJTree_Node node) { string routine = "StateMod_DataSet_JTree.displayDataSetComponent"; bool hadData = false; // No data for component... string label = ""; int primary_type = __dataset.lookupPrimaryComponentTypeForComponentGroup(comp.getComponentType()); if (primary_type >= 0) { comp = __dataset.getComponentForComponentType(primary_type); } // Revisit - later may enable even if a component does // not have data - for example have an "Add" popup... if ((comp == null) || !comp.isVisible() || !comp.hasData()) { return(hadData); } object data_Object = comp.getData(); if (data_Object == null) { return(hadData); } System.Collections.IList data = null; if (data_Object is System.Collections.IList) { data = (System.Collections.IList)comp.getData(); } else { // Continue (REVISIT - what components would this happen for?)... Message.printWarning(2, routine, "Unexpected non-Vector for " + comp.getComponentName()); return(hadData); } StateCU_Data cudata; StateMod_Data smdata; SimpleJTree_Node node2 = null; TS tsdata; int dsize = 0; if (data != null) { dsize = data.Count; } for (int idata = 0; idata < dsize; idata++) { data_Object = data[idata]; if (data_Object is StateMod_Data) { smdata = (StateMod_Data)data[idata]; label = StateMod_Util.formatDataLabel(smdata.getID(), smdata.getName()); node2 = new SimpleJTree_Node(label); node2.setData(smdata); } else if (data_Object is StateCU_Data) { cudata = (StateCU_Data)data[idata]; label = StateMod_Util.formatDataLabel(cudata.getID(), cudata.getName()); node2 = new SimpleJTree_Node(label); node2.setData(cudata); } else if (data_Object is TS) { tsdata = (TS)data[idata]; label = StateMod_Util.formatDataLabel(tsdata.getLocation(), tsdata.getDescription()); node2 = new SimpleJTree_Node(label); node2.setData(tsdata); } try { addNode(node2, node); } catch (Exception e) { Message.printWarning(2, routine, "Error adding data \"" + label + "\""); Message.printWarning(2, routine, e); continue; } } if (dsize > 0) { hadData = true; } // Collapse the node because the lists are usually pretty long... try { collapseNode(node); } catch (Exception) { // Ignore. } return(hadData); // Needed in the calling code. }
/// <summary> /// Display all the information in the data set. This can be called, for example, /// after a data set has been read. /// </summary> public virtual void displayDataSet() { string routine = "StateMod_DataSet_JTree.displayDataSet"; System.Collections.IList v = __dataset.getComponentGroups(); int size = 0; if (v != null) { size = v.Count; } SimpleJTree_Node node = null, node2 = null; DataSetComponent comp = null; bool hadData = false; bool isGroup = false; int type; // Add each component group... setFastAdd(true); Icon folder_Icon = getClosedIcon(); for (int i = 0; i < size; i++) { hadData = false; isGroup = false; comp = (DataSetComponent)v[i]; if ((comp == null) || !comp.isVisible()) { continue; } type = comp.getComponentType(); if (type == StateMod_DataSet.COMP_GEOVIEW_GROUP) { // Don't want to list the groups because there is no // way to display edit (or they are displayed elsewhere)... continue; } node = new SimpleJTree_Node(comp.getComponentName()); node.setData(comp); if (comp.isGroup()) { isGroup = true; } // To force groups to be folders, even if no data underneath... node.setIcon(folder_Icon); try { addNode(node); } catch (Exception e) { Message.printWarning(2, routine, "Error adding component group " + comp.getComponentName()); Message.printWarning(2, routine, e); continue; } if (__display_data_objects) { // Display the primary object in each group hadData = displayDataSetComponent(comp, node); } else { // Add the components in the group... System.Collections.IList v2 = (System.Collections.IList)comp.getData(); int size2 = 0; if (v2 != null) { size2 = v2.Count; } for (int j = 0; j < size2; j++) { comp = (DataSetComponent)v2[j]; if ((comp == null) || !comp.isVisible()) { continue; } node2 = new SimpleJTree_Node(comp.getComponentName()); node2.setData(comp); try { addNode(node2, node); } catch (Exception e) { Message.printWarning(2, routine, "Error adding component " + comp.getComponentName()); Message.printWarning(2, routine, e); continue; } } if (size2 > 0) { hadData = true; } } if (isGroup && !hadData) { node.setIcon(__folderIcon); } } setFastAdd(false); }
/// <summary> /// Responds to action performed events sent by popup menus of the tree nodes. </summary> /// <param name="event"> the ActionEvent that happened. </param> public virtual void actionPerformed(ActionEvent @event) { string action = @event.getActionCommand(); string routine = "StateMod_DataSet_JTree.actionPerformed"; object data = __popup_Node.getData(); if (data is DataSetComponent) { DataSetComponent comp = (DataSetComponent)data; int comp_type = comp.getComponentType(); if (comp_type == StateMod_DataSet.COMP_CONTROL_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_CONTROL, __editable); } else if (comp_type == StateMod_DataSet.COMP_STREAMGAGE_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMGAGE, __editable); } else if (comp_type == StateMod_DataSet.COMP_DELAY_TABLE_MONTHLY_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY, __editable); } else if (comp_type == StateMod_DataSet.COMP_DELAY_TABLE_DAILY_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY, __editable); } else if (comp_type == StateMod_DataSet.COMP_DIVERSION_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DIVERSION, __editable); } else if (comp_type == StateMod_DataSet.COMP_PRECIPITATION_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_PRECIPITATION, __editable); } else if (comp_type == StateMod_DataSet.COMP_EVAPORATION_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_EVAPORATION, __editable); } else if (comp_type == StateMod_DataSet.COMP_RESERVOIR_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_RESERVOIR, __editable); } else if (comp_type == StateMod_DataSet.COMP_INSTREAM_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_INSTREAM, __editable); } else if (comp_type == StateMod_DataSet.COMP_WELL_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_WELL, __editable); } else if (comp_type == StateMod_DataSet.COMP_PLAN_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_PLAN, __editable); } else if (comp_type == StateMod_DataSet.COMP_STREAMESTIMATE_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMESTIMATE, __editable); } else if (comp_type == StateMod_DataSet.COMP_RIVER_NETWORK_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK, __editable); } else if (comp_type == StateMod_DataSet.COMP_OPERATION_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_OPERATIONAL_RIGHT, __editable); } } // Below here are specific instances of objects. Similar to above, // display the main window but then also select the specific object... else if (data is StateMod_StreamGage) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMGAGE, __editable); ((StateMod_StreamGage_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMGAGE)).selectID(((StateMod_StreamGage)data).getID()); } else if (data is StateMod_DelayTable) { StateMod_DelayTable dt = (StateMod_DelayTable)data; if (dt.isMonthly()) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY, __editable); ((StateMod_DelayTable_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY)).selectID(dt.getID()); } else { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY, __editable); ((StateMod_DelayTable_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY)).selectID(dt.getID()); } } else if (data is StateMod_Diversion) { if (action.IndexOf(__SUMMARIZE_HOW1, StringComparison.Ordinal) >= 0) { PropList props = new PropList("Diversion"); props.set("Title=" + ((StateMod_Diversion)data).getID() + " Diversion use in Data Set"); new ReportJFrame(__dataset.getDataObjectDetails(StateMod_DataSet.COMP_DIVERSION_STATIONS, ((StateMod_Diversion)data).getID()), props); } else { // Assume properties... __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DIVERSION, __editable); ((StateMod_Diversion_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_DIVERSION)).selectID(((StateMod_Diversion)data).getID()); } } else if (data is TS) { // Might be precipitation or evaporation. Check the data type to determine... TS ts = (TS)data; PropList props = new PropList("Precipitation/Evaporation"); if (action.IndexOf(__SUMMARIZE_HOW1, StringComparison.Ordinal) >= 0) { if (StringUtil.startsWithIgnoreCase(ts.getDataType(), "e")) { props.set("Title=" + ts.getLocation() + " Evaporation TS use in Data Set"); new ReportJFrame(__dataset.getDataObjectDetails(StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY, ts.getLocation()), props); } else if (StringUtil.startsWithIgnoreCase(ts.getDataType(), "p")) { props.set("Title=" + ts.getLocation() + " Precipitation TS use in Data Set"); new ReportJFrame(__dataset.getDataObjectDetails(StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY, ts.getLocation()), props); } } else if (action.IndexOf(__PROPERTIES, StringComparison.Ordinal) >= 0) { if (StringUtil.startsWithIgnoreCase(ts.getDataType(), "e")) { props.set("Title=Evaporation"); } else if (StringUtil.startsWithIgnoreCase(ts.getDataType(), "p")) { props.set("Title=Precipitation"); } props.set("InitialView=Graph"); props.set("GraphType=Bar"); System.Collections.IList tslist = new List <object>(1); tslist.Add(ts); try { new TSViewJFrame(tslist, props); } catch (Exception) { Message.printWarning(1, routine, "Error displaying data."); } } } else if (data is StateMod_Reservoir) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_RESERVOIR, __editable); ((StateMod_Reservoir_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_RESERVOIR)).selectID(((StateMod_Reservoir)data).getID()); } else if (data is StateMod_InstreamFlow) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_INSTREAM, __editable); ((StateMod_InstreamFlow_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_INSTREAM)).selectID(((StateMod_InstreamFlow)data).getID()); } else if (data is StateMod_Well) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_WELL, __editable); ((StateMod_Well_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_WELL)).selectID(((StateMod_Well)data).getID()); } else if (data is StateMod_Plan) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_PLAN, __editable); ((StateMod_Plan_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_PLAN)).selectID(((StateMod_Plan)data).getID()); } else if (data is StateMod_StreamEstimate) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMESTIMATE, __editable); ((StateMod_StreamEstimate_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMESTIMATE)).selectID(((StateMod_StreamEstimate)data).getID()); } else if (data is StateMod_RiverNetworkNode) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK, __editable); ((StateMod_RiverNetworkNode_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK)).selectID(((StateMod_RiverNetworkNode)data).getID()); } else if (data is StateMod_OperationalRight) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_OPERATIONAL_RIGHT, __editable); ((StateMod_OperationalRight_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_OPERATIONAL_RIGHT)).selectID(((StateMod_OperationalRight)data).getID()); } }
/// <summary> /// Checks to see if the mouse event would trigger display of the popup menu. /// The popup menu does not display if it is null. </summary> /// <param name="e"> the MouseEvent that happened. </param> private void showPopupMenu(MouseEvent e) { if (!e.isPopupTrigger() || !__display_data_objects) { // Do not do anything... return; } // Figure out which node is selected... TreePath path = getPathForLocation(e.getX(), e.getY()); if (path == null) { return; } __popup_Node = (SimpleJTree_Node)path.getLastPathComponent(); // First remove the menu items that are currently in the menu... __popup_JPopupMenu.removeAll(); object data = null; // Data object associated with the node // Now reset the popup menu based on the selected node... if (__display_data_objects) { // Get the data for the node. If the node is a data object, // the type can be checked to know what to display. // The tree is displaying data objects so the popup will show // specific JFrames for each data group. If the group folder // was selected, then display the JFrame showing the first item // selected. If a specific data item in the group was selected, // then show the specific data item. JMenuItem item; data = __popup_Node.getData(); if (data is DataSetComponent) { // Specific checks need to be done to identify the // component... DataSetComponent comp = (DataSetComponent)data; int comp_type = comp.getComponentType(); if (comp_type == StateCU_DataSet.COMP_CLIMATE_STATIONS_GROUP) { item = new SimpleJMenuItem("Climate Stations Properties", "Climate Stations Properties", this); __popup_JPopupMenu.add(item); } else if (comp_type == StateCU_DataSet.COMP_CROP_CHARACTERISTICS_GROUP) { item = new SimpleJMenuItem("Crop Properties", "Crop Properties", this); __popup_JPopupMenu.add(item); } else if (comp_type == StateCU_DataSet.COMP_DELAY_TABLES_GROUP) { item = new SimpleJMenuItem("Delay Tables Properties", "Delay Tables Properties", this); __popup_JPopupMenu.add(item); } else if (comp_type == StateCU_DataSet.COMP_CU_LOCATIONS_GROUP) { item = new SimpleJMenuItem("CU Locations Properties", "CU Locations Properties", this); __popup_JPopupMenu.add(item); } } // Check specific instances of the primary data object... else if (data is StateCU_ClimateStation) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", __popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateCU_CropCharacteristics) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", __popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateMod_DelayTable) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", __popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else if (data is StateCU_Location) { item = new SimpleJMenuItem(__popup_Node.getText() + " Properties", __popup_Node.getText() + " Properties", this); __popup_JPopupMenu.add(item); } else { return; } } // Now display the popup so that the user can select the appropriate // menu item... __popup_JPopupMenu.show(e.getComponent(), e.getX(), e.getY()); }
/// <summary> /// Handle action events from the popup menu. </summary> /// <param name="e"> ActionEvent to handle. </param> public virtual void actionPerformed(ActionEvent e) { object data = __popup_Node.getData(); bool editable = false; if (data is DataSetComponent) { DataSetComponent comp = (DataSetComponent)data; int comp_type = comp.getComponentType(); if (comp_type == StateCU_DataSet.COMP_CLIMATE_STATIONS_GROUP) { new StateCU_ClimateStation_JFrame("Climate Stations", __dataset, editable); } else if (comp_type == StateCU_DataSet.COMP_CROP_CHARACTERISTICS_GROUP) { new StateCU_CropCharacteristics_JFrame(__dataset, editable); } else if (comp_type == StateCU_DataSet.COMP_DELAY_TABLES_GROUP) { DataSetComponent comp2 = __dataset.getComponentForComponentType(StateCU_DataSet.COMP_DELAY_TABLES_MONTHLY); if (comp2 != null) { /* * REVISIT (JTS - 2003-10-06) * old constructor * new StateMod_DelayTable_JFrame( * "Delay Tables", (Vector)comp2.getData(), * true, editable); */ } } else if (comp_type == StateCU_DataSet.COMP_CU_LOCATIONS_GROUP) { // TODO SAM 2011-06-22 Need a way to pass a window manager new StateCU_Location_JFrame(__isStateCU, __dataset, null, editable); } } // Else, data are specific objects... else if (data is StateCU_ClimateStation) { new StateCU_ClimateStation_JFrame("Climate Stations", __dataset, (StateCU_ClimateStation)data, editable); } else if (data is StateCU_CropCharacteristics) { new StateCU_CropCharacteristics_JFrame(__dataset, (StateCU_CropCharacteristics)data, editable); } else if (data is StateMod_DelayTable) { DataSetComponent comp2 = __dataset.getComponentForComponentType(StateCU_DataSet.COMP_DELAY_TABLES_MONTHLY); if (comp2 != null) { /* * REVISIT (JTS - 2003-10-06) * old constructor * new StateMod_DelayTable_JFrame( * "Delay Tables", (Vector)comp2.getData(), * (StateMod_DelayTable)data, true, editable); */ } } else if (data is StateCU_Location) { new StateCU_Location_JFrame(false, __dataset, null, (StateCU_Location)data, editable); } }
/// <summary> /// Display all the information in the data set. This can be called, for example, /// after a data set has been read. /// </summary> public virtual void displayDataSet() { string routine = "StateCU_DataSet_JTree.displayDataSet"; System.Collections.IList v = __dataset.getComponentGroups(); int size = 0; if (v != null) { size = v.Count; } SimpleJTree_Node node = null, node2 = null; DataSetComponent comp = null; string name = ""; bool isGroup = false; bool hasData = false; int type; // Add each component group... setFastAdd(true); for (int i = 0; i < size; i++) { isGroup = false; hasData = false; comp = (DataSetComponent)v[i]; if ((comp == null) || !comp.isVisible()) { continue; } if (comp.isGroup()) { isGroup = true; } type = comp.getComponentType(); // Show the control data at the high level. if (type == StateCU_DataSet.COMP_GIS_GROUP) { // Don't want to list the GIS data... continue; } if ((type == StateCU_DataSet.COMP_GIS_GROUP) && __display_data_objects) { // Currently don't want to list GIS data in // results... continue; } node = new SimpleJTree_Node(comp.getComponentName()); node.setData(comp); try { addNode(node); } catch (Exception e) { Message.printWarning(2, routine, "Error adding component group " + comp.getComponentName()); Message.printWarning(2, routine, e); continue; } if (__display_data_objects) { // Display the primary object in each group int primary_type = __dataset.lookupPrimaryComponentTypeForComponentGroup(comp.getComponentType()); if (primary_type >= 0) { comp = __dataset.getComponentForComponentType(primary_type); } if ((comp == null) || !comp.isVisible()) { continue; } object data_Object = comp.getData(); if (data_Object == null) { continue; } System.Collections.IList data = null; if (data_Object is System.Collections.IList) { data = (System.Collections.IList)comp.getData(); } else { // Continue (REVISIT - what components would // this happen for?)... Message.printWarning(2, routine, "Unexpected non-Vector for " + comp.getComponentName()); } StateCU_Data cudata; StateMod_Data smdata; int dsize = 0; if (data != null) { dsize = data.Count; } for (int idata = 0; idata < dsize; idata++) { if (comp.getComponentType() == StateCU_DataSet.COMP_DELAY_TABLES_MONTHLY) { // StateMod data object so have to // handle separately because StateCU // uses the StateMod group... smdata = (StateMod_Data)data[idata]; name = smdata.getName(); node2 = new SimpleJTree_Node(name); node2.setData(smdata); } else { // StateCU data object... cudata = (StateCU_Data)data[idata]; name = cudata.getName(); node2 = new SimpleJTree_Node(name); node2.setData(cudata); } try { addNode(node2, node); } catch (Exception e) { Message.printWarning(2, routine, "Error adding data " + name); Message.printWarning(2, routine, e); continue; } } if (dsize > 0) { hasData = true; } // Collapse the node because the lists are // usually pretty long... try { collapseNode(node); } catch (Exception) { // Ignore. } } else { // Add the components in the group... Message.printStatus(1, "", "Not displaying data objects"); System.Collections.IList v2 = (System.Collections.IList)comp.getData(); int size2 = 0; if (v2 != null) { size2 = v2.Count; } Message.printStatus(1, "", "group has " + size2 + " subcomponents"); for (int j = 0; j < size2; j++) { comp = (DataSetComponent)v2[j]; if (!comp.isVisible()) { continue; } node2 = new SimpleJTree_Node(comp.getComponentName()); node2.setData(comp); try { addNode(node2, node); } catch (Exception e) { Message.printWarning(2, routine, "Error adding component " + comp.getComponentName()); Message.printWarning(2, routine, e); continue; } } if (size2 > 0) { hasData = true; } } if (isGroup && !hasData) { node.setIcon(__folderIcon); } } setFastAdd(false); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void saveComponent(RTi.Util.IO.DataSetComponent comp, String oldFilename,String newFilename, java.util.List<String> comments) throws Exception private void saveComponent(DataSetComponent comp, string oldFilename, string newFilename, IList <string> comments) { bool daily = false; int type = comp.getComponentType(); object data = comp.getData(); string name = null; switch (type) { //////////////////////////////////////////////////////// // StateMod_* classes case StateMod_DataSet.COMP_CONTROL: StateMod_DataSet.writeStateModControlFile(__dataset, oldFilename, newFilename, comments); name = "Control"; break; case StateMod_DataSet.COMP_DELAY_TABLES_DAILY: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DelayTable> delayTablesDaily = (java.util.List<StateMod_DelayTable>)data; IList <StateMod_DelayTable> delayTablesDaily = (IList <StateMod_DelayTable>)data; StateMod_DelayTable.writeStateModFile(oldFilename, newFilename, delayTablesDaily, comments, __dataset.getInterv(), -1); name = "Delay Tables Daily"; break; case StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DelayTable> delayTablesMonthly = (java.util.List<StateMod_DelayTable>)data; IList <StateMod_DelayTable> delayTablesMonthly = (IList <StateMod_DelayTable>)data; StateMod_DelayTable.writeStateModFile(oldFilename, newFilename, delayTablesMonthly, comments, __dataset.getInterv(), -1); name = "Delay Tables Monthly"; break; case 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> diversionStations = (java.util.List<StateMod_Diversion>)data; IList <StateMod_Diversion> diversionStations = (IList <StateMod_Diversion>)data; StateMod_Diversion.writeStateModFile(oldFilename, newFilename, diversionStations, comments, daily); name = "Diversion"; break; case StateMod_DataSet.COMP_DIVERSION_RIGHTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DiversionRight> diversionRights = (java.util.List<StateMod_DiversionRight>)data; IList <StateMod_DiversionRight> diversionRights = (IList <StateMod_DiversionRight>)data; StateMod_DiversionRight.writeStateModFile(oldFilename, newFilename, diversionRights, comments, daily); name = "Diversion Rights"; break; case StateMod_DataSet.COMP_INSTREAM_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_InstreamFlow> instreamFlow = (java.util.List<StateMod_InstreamFlow>)data; IList <StateMod_InstreamFlow> instreamFlow = (IList <StateMod_InstreamFlow>)data; StateMod_InstreamFlow.writeStateModFile(oldFilename, newFilename, instreamFlow, comments, daily); name = "Instream"; break; case StateMod_DataSet.COMP_INSTREAM_RIGHTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_InstreamFlowRight> instreamFlowRights = (java.util.List<StateMod_InstreamFlowRight>)data; IList <StateMod_InstreamFlowRight> instreamFlowRights = (IList <StateMod_InstreamFlowRight>)data; StateMod_InstreamFlowRight.writeStateModFile(oldFilename, newFilename, instreamFlowRights, comments); name = "Instream Rights"; break; case StateMod_DataSet.COMP_OPERATION_RIGHTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_OperationalRight> operationalRights = (java.util.List<StateMod_OperationalRight>)data; IList <StateMod_OperationalRight> operationalRights = (IList <StateMod_OperationalRight>)data; // 2 is the file version (introduced for StateMod version 12 change) StateMod_OperationalRight.writeStateModFile(oldFilename, newFilename, 2, operationalRights, comments, __dataset); name = "Operational Rights"; break; case StateMod_DataSet.COMP_PLANS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Plan> planStations = (java.util.List<StateMod_Plan>)data; IList <StateMod_Plan> planStations = (IList <StateMod_Plan>)data; StateMod_Plan.writeStateModFile(oldFilename, newFilename, planStations, comments); name = "Plan"; break; case StateMod_DataSet.COMP_RESERVOIR_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_Reservoir> reservoirStations = (java.util.List<StateMod_Reservoir>)data; IList <StateMod_Reservoir> reservoirStations = (IList <StateMod_Reservoir>)data; StateMod_Reservoir.writeStateModFile(oldFilename, newFilename, reservoirStations, comments, daily); name = "Reservoir"; break; case StateMod_DataSet.COMP_RESERVOIR_RIGHTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_ReservoirRight> reservoirRights = (java.util.List<StateMod_ReservoirRight>)data; IList <StateMod_ReservoirRight> reservoirRights = (IList <StateMod_ReservoirRight>)data; StateMod_ReservoirRight.writeStateModFile(oldFilename, newFilename, reservoirRights, comments); name = "Reservoir Rights"; break; case StateMod_DataSet.COMP_RESPONSE: StateMod_DataSet.writeStateModFile(__dataset, oldFilename, newFilename, comments); name = "Response"; break; case StateMod_DataSet.COMP_RIVER_NETWORK: //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> riverNodes = (java.util.List<StateMod_RiverNetworkNode>)data; IList <StateMod_RiverNetworkNode> riverNodes = (IList <StateMod_RiverNetworkNode>)data; StateMod_RiverNetworkNode.writeStateModFile(oldFilename, newFilename, riverNodes, comments, true); name = "River Network"; break; case StateMod_DataSet.COMP_STREAMESTIMATE_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_StreamEstimate> streamEstimateStations = (java.util.List<StateMod_StreamEstimate>)data; IList <StateMod_StreamEstimate> streamEstimateStations = (IList <StateMod_StreamEstimate>)data; StateMod_StreamEstimate.writeStateModFile(oldFilename, newFilename, streamEstimateStations, comments, daily); name = "Stream Estimate"; break; case StateMod_DataSet.COMP_STREAMESTIMATE_COEFFICIENTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_StreamEstimate_Coefficients> streamEstimateCoefficients = (java.util.List<StateMod_StreamEstimate_Coefficients>)data; IList <StateMod_StreamEstimate_Coefficients> streamEstimateCoefficients = (IList <StateMod_StreamEstimate_Coefficients>)data; StateMod_StreamEstimate_Coefficients.writeStateModFile(oldFilename, newFilename, streamEstimateCoefficients, comments); name = "Stream Estimate Coefficients"; break; case StateMod_DataSet.COMP_STREAMGAGE_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_StreamGage> streamGageStations = (java.util.List<StateMod_StreamGage>)data; IList <StateMod_StreamGage> streamGageStations = (IList <StateMod_StreamGage>)data; StateMod_StreamGage.writeStateModFile(oldFilename, newFilename, streamGageStations, comments, daily); name = "Streamgage Stations"; break; case StateMod_DataSet.COMP_WELL_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_Well> wellStations = (java.util.List<StateMod_Well>)data; IList <StateMod_Well> wellStations = (IList <StateMod_Well>)data; StateMod_Well.writeStateModFile(oldFilename, newFilename, wellStations, comments); name = "Well"; break; case StateMod_DataSet.COMP_WELL_RIGHTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_WellRight> wellRights = (java.util.List<StateMod_WellRight>)data; IList <StateMod_WellRight> wellRights = (IList <StateMod_WellRight>)data; StateMod_WellRight.writeStateModFile(oldFilename, newFilename, wellRights, comments, (PropList)null); name = "Well Rights"; break; ////////////////////////////////////////////////////// // StateMod Time Series case StateMod_DataSet.COMP_CONSUMPTIVE_WATER_REQUIREMENT_TS_DAILY: case StateMod_DataSet.COMP_CONSUMPTIVE_WATER_REQUIREMENT_TS_MONTHLY: case StateMod_DataSet.COMP_DEMAND_TS_DAILY: case StateMod_DataSet.COMP_DEMAND_TS_AVERAGE_MONTHLY: case StateMod_DataSet.COMP_DEMAND_TS_MONTHLY: case StateMod_DataSet.COMP_DEMAND_TS_OVERRIDE_MONTHLY: case StateMod_DataSet.COMP_DIVERSION_TS_DAILY: case StateMod_DataSet.COMP_DIVERSION_TS_MONTHLY: case StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY: case StateMod_DataSet.COMP_INSTREAM_DEMAND_TS_AVERAGE_MONTHLY: case StateMod_DataSet.COMP_INSTREAM_DEMAND_TS_DAILY: case StateMod_DataSet.COMP_INSTREAM_DEMAND_TS_MONTHLY: case StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY: case StateMod_DataSet.COMP_RESERVOIR_CONTENT_TS_DAILY: case StateMod_DataSet.COMP_RESERVOIR_CONTENT_TS_MONTHLY: case StateMod_DataSet.COMP_RESERVOIR_TARGET_TS_DAILY: case StateMod_DataSet.COMP_RESERVOIR_TARGET_TS_MONTHLY: case StateMod_DataSet.COMP_STREAMESTIMATE_NATURAL_FLOW_TS_DAILY: case StateMod_DataSet.COMP_STREAMESTIMATE_NATURAL_FLOW_TS_MONTHLY: case StateMod_DataSet.COMP_STREAMGAGE_NATURAL_FLOW_TS_DAILY: case StateMod_DataSet.COMP_STREAMGAGE_NATURAL_FLOW_TS_MONTHLY: case StateMod_DataSet.COMP_STREAMGAGE_HISTORICAL_TS_DAILY: case StateMod_DataSet.COMP_STREAMGAGE_HISTORICAL_TS_MONTHLY: case StateMod_DataSet.COMP_WELL_DEMAND_TS_DAILY: case StateMod_DataSet.COMP_WELL_DEMAND_TS_MONTHLY: case StateMod_DataSet.COMP_WELL_PUMPING_TS_DAILY: case StateMod_DataSet.COMP_WELL_PUMPING_TS_MONTHLY: double missing = -999.0; YearType yearType = null; if (__dataset.getCyrl() == YearType.CALENDAR) { yearType = YearType.CALENDAR; } else if (__dataset.getCyrl() == YearType.WATER) { yearType = YearType.WATER; } else if (__dataset.getCyrl() == YearType.NOV_TO_OCT) { yearType = YearType.NOV_TO_OCT; } int precision = 2; // Do the following to avoid warnings IList <TS> tslist = null; if (data != null) { //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<RTi.TS.TS> tslist0 = (java.util.List<RTi.TS.TS>)data; IList <TS> tslist0 = (IList <TS>)data; if (tslist0.Count > 0) { TS ts = tslist0[0]; missing = ts.getMissing(); } tslist = tslist0; } StateMod_TS.writeTimeSeriesList(oldFilename, newFilename, comments, tslist, null, null, yearType, missing, precision); name = "TS (" + type + ")"; break; default: name = "(something: " + type + ")"; break; } comp.setDirty(false); Message.printStatus(1, "", "Component '" + name + "' written"); }
/// <summary> /// Checks the text fields for validity before they are saved back into the data object. </summary> /// <returns> 0 if the text fields are okay, 1 if fatal errors exist, and -1 if only non-fatal errors exist. </returns> private int checkInput() { string routine = "StateMod_Response_JFrame.checkInput"; string warning = ""; int fatal_count = 0; // Check to make sure that no two files have the same name... int size = __worksheet.getModel().getRowCount(); DataSetComponent comp = null, comp2 = null; string file_name, file_name2; for (int i = 0; i < size; i++) { // Get the component corresponding to the line. comp = __dataset_copy.getComponentForComponentType(((StateMod_Response_TableModel)__worksheet.getModel()).getComponentTypeForRow(i)); file_name = ((string)__worksheet.getValueAt(i, StateMod_Response_TableModel.COL_NAME)).Trim(); if (file_name.Equals(__dataset_copy.BLANK_FILE_NAME, StringComparison.OrdinalIgnoreCase) && comp.hasData()) { if (comp.getComponentType() != StateMod_DataSet.COMP_NETWORK) { warning += "\n" + comp.getComponentName() + " has data but no file name is specified."; ++fatal_count; } } // Check for duplicate file names. In particular with the new // response file format, there is no need for "dum" empty files. for (int j = 0; j < size; j++) { if (i == j) { continue; } comp2 = __dataset_copy.getComponentForComponentType(((StateMod_Response_TableModel)__worksheet.getModel()).getComponentTypeForRow(j)); file_name2 = ((string)__worksheet.getValueAt(j, StateMod_Response_TableModel.COL_NAME)).Trim(); if (file_name2.Equals(file_name, StringComparison.OrdinalIgnoreCase) && !file_name2.Equals(__dataset_copy.BLANK_FILE_NAME, StringComparison.OrdinalIgnoreCase)) { // Stream gage and stream estimate stations can be the same file name... if (((comp.getComponentType() == StateMod_DataSet.COMP_STREAMGAGE_STATIONS) && (comp2.getComponentType() == StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS)) || ((comp.getComponentType() == StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS) && (comp2.getComponentType() == StateMod_DataSet.COMP_STREAMGAGE_STATIONS))) { // TODO SAM 2006-03-04 Need to finalize how the gage and estimate files are handled. //&& //!__dataset_copy.isFreeFormat() ) { // No need for a warning because the single file is split internally when read... } else { warning += "\n" + comp.getComponentName() + " file name (" + file_name + ") is the same as another component."; ++fatal_count; } // No need to look at more files... break; } } // Compare against the original copy... // Warn that time series file names cannot be changed from the // original because time series were not read in... comp2 = __dataset.getComponentForComponentType(comp.getComponentType()); file_name2 = comp2.getDataFileName(); if (!file_name.Equals(file_name2) && !__dataset.areTSRead() && __dataset.isDynamicTSComponent(comp.getComponentType())) { warning += "\n" + comp.getComponentName() + " time series were not read in - cannot change file name."; ++fatal_count; } } if (warning.Length > 0) { warning = "\nResponse file: " + warning + "\nCorrect or Cancel."; Message.printWarning(1, routine, warning, this); if (fatal_count > 0) { // Fatal errors... return(1); } else { // Nonfatal errors... return(-1); } } else { // No errors... return(0); } }