/// <summary> /// Constructor. This builds the model for displaying the given component data. </summary> /// <param name="dataset"> StateCU_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 StateCU_DataSetComponent_TableModel(StateCU_DataSet dataset, RTi.Util.IO.DataSetComponent comp) throws Exception public StateCU_DataSetComponent_TableModel(StateCU_DataSet dataset, DataSetComponent comp) { System.Collections.IList data = null; string routine = "StateCU_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> /// 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); }