/// <summary> /// Creates a list of the available IDs for a Vector of StateMod_Data-extending /// objects. Reservoirs will include an identifier for each reservoir total and each account for the reservoir. </summary> /// <param name="nodes"> the nodes for which to create a list of IDs. </param> /// <param name="include_accounts"> If true, the </param> /// <returns> a Vector of Strings, each of which contains an ID followed by the name of Structure in parentheses </returns> private System.Collections.IList createAvailableIDsList(System.Collections.IList nodes) { System.Collections.IList v = new List <object>(); int num = 0; bool is_reservoir = false; // To allow check below if (nodes != null) { num = nodes.Count; if ((num > 0) && ((StateMod_Data)nodes[0]) is StateMod_Reservoir) { is_reservoir = true; } } StateMod_Reservoir res = null; // These are used if reservoirs. int nowner = 0; int ia = 0; for (int i = 0; i < num; i++) { // Add the normal item... v.Add(StateMod_Util.formatDataLabel(((StateMod_Data)nodes[i]).getID(), ((StateMod_Data)nodes[i]).getName())); if (is_reservoir) { // Also add reservoir owner/accounts... res = (StateMod_Reservoir)nodes[i]; nowner = res.getAccounts().Count; for (ia = 0; ia < nowner; ia++) { v.Add(StateMod_Util.formatDataLabel(res.getID() + "-" + (ia + 1), res.getName() + " - " + res.getAccount(ia).getName())); } } } return(v); }
/// <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. }