use of CCDD.CcddClassesComponent.ToolTipTreeNode in project CCDD by nasa.
the class CcddTableTreeHandler method getPrimitiveVariablePaths.
/**
********************************************************************************************
* Get a list of full node paths for all nodes that represent a primitive variable, starting at
* the specified node. Disabled nodes may be ignored if desired
*
* @param startNode
* starting node from which to build the variable list
*
* @param ignoreDisabled
* true to ignore nodes that are flagged as disabled (via HTML color tag)
*
* @return List containing the full node paths for all nodes that represent a primitive
* variable, starting with the specified node
********************************************************************************************
*/
protected List<String> getPrimitiveVariablePaths(DefaultMutableTreeNode startNode, boolean ignoreDisabled) {
// Create storage for the primitive variable paths
List<String> allPrimitivePaths = new ArrayList<String>();
// Step through each element and child of this node
for (Enumeration<?> element = startNode.preorderEnumeration(); element.hasMoreElements(); ) {
// Get the node
ToolTipTreeNode node = (ToolTipTreeNode) element.nextElement();
// Check if disabled nodes should be included, or if not, that the node isn't disabled
if (!ignoreDisabled || !node.getUserObject().toString().contains(DISABLED_TEXT_COLOR)) {
// Get the data type for this node
String dataType = getTableFromNodeName(ignoreDisabled ? node.getUserObject().toString() : removeExtraText(node.getUserObject().toString()));
// Check if the data type is a primitive (versus a structure)
if (dataTypeHandler.isPrimitive(dataType)) {
// Convert the node path array to a string
String nodePath = CcddUtilities.convertArrayToString(node.getPath()).replaceAll(", ", ",");
// Add the variable's entire node path to the list
allPrimitivePaths.add(ignoreDisabled ? nodePath : removeExtraText(nodePath));
}
}
}
return allPrimitivePaths;
}
use of CCDD.CcddClassesComponent.ToolTipTreeNode in project CCDD by nasa.
the class CcddTableTreeHandler method getSelectedTablesWithChildren.
/**
********************************************************************************************
* Get a list of the tables (with their paths) represented by the selected nodes. If a header
* node (i.e., a non-table node, such as a group or type node) is selected then all of its
* child tables are added to the list
*
* @return List containing the table path+names of the selected node(s) with no duplicate table
* references
********************************************************************************************
*/
protected List<String> getSelectedTablesWithChildren() {
// Create storage for the table names
List<String> tables = new ArrayList<String>();
// Check if any tables are selected in the table tree
if (getSelectionPaths() != null) {
// Step through each selected table in the tree
for (TreePath path : getSelectionPaths()) {
// Get the node for this path
ToolTipTreeNode node = (ToolTipTreeNode) path.getLastPathComponent();
// Check that this node represents a header node
if (path.getPathCount() <= getHeaderNodeLevel()) {
// Check if the node has any children
if (node.getChildCount() != 0) {
List<Object[]> childPaths = new ArrayList<Object[]>();
// Get the children of this header node
addChildNodes(node, childPaths, null, false);
// Step through each of the child table paths
for (Object[] childPath : childPaths) {
// Get the table's full path (with the root table)
String fullPath = getFullVariablePath(childPath);
// Check if the table isn't already in the list
if (!tables.contains(fullPath)) {
// Add the table's full path (with the root table) to the full path
// list
tables.add(getFullVariablePath(childPath));
}
}
}
} else // The path represents a table
{
// Get the table's full path (with the root table)
String fullPath = getFullVariablePath(node.getPath());
// Check if the table isn't already in the list
if (!tables.contains(fullPath)) {
// Add the table full path list
tables.add(fullPath);
}
}
}
}
return tables;
}
use of CCDD.CcddClassesComponent.ToolTipTreeNode in project CCDD by nasa.
the class CcddTableTreeHandler method buildTopLevelNodes.
/**
********************************************************************************************
* Build the top-level nodes for the table tree (based on the selected filters)
*
* @param nameList
* list of table names belonging to the filtered selection; null if no filtering
*
* @param instNode
* parent node for the top-level nodes
*
* @param protoNode
* parent node for the prototype nodes
*
* @param parent
* GUI component calling this method
********************************************************************************************
*/
private void buildTopLevelNodes(List<String> nameList, ToolTipTreeNode instNode, ToolTipTreeNode protoNode, Component parent) {
// haven't already been loaded
if (getDescriptions && tableDescriptions == null) {
// Get an array containing the tables and their variable paths, if any, for those
// tables with descriptions
tableDescriptions = dbTable.queryTableDescriptions(parent);
}
// Step through each table
for (TableMembers member : tableMembers) {
// structure type tables for a tree showing structure instances with primitives
if ((nameList == null || nameList.contains(member.getTableName())) && ((treeType != STRUCTURES_WITH_PRIMITIVES && treeType != INSTANCE_STRUCTURES_WITH_PRIMITIVES && treeType != INSTANCE_STRUCTURES_WITH_PRIMITIVES_AND_RATES) || tableTypeHandler.getTypeDefinition(member.getTableType()).isStructure())) {
// prototype nodes are excluded if it is)
if (treeType != STRUCTURES_WITH_PRIMITIVES) {
// Add the table to the prototype node
protoNode.add(new ToolTipTreeNode(member.getTableName(), getTableDescription(member.getTableName(), "")));
}
boolean isParent = true;
// Step through each table
for (TableMembers otherMember : tableMembers) {
// is a member of the group
if (otherMember.getDataTypes().contains(member.getTableName()) && !member.equals(otherMember) && (!isByGroup || (nameList != null && nameList.contains(otherMember.getTableName())))) {
// Clear the flag indicating this is a parent table and stop searching
isParent = false;
break;
}
}
// the prototype node
if (isParent || treeType == STRUCTURES_WITH_PRIMITIVES) {
recursionTable = null;
// Build the nodes in the tree for this table and its member tables
buildNodes(member, (!isParent && treeType == STRUCTURES_WITH_PRIMITIVES ? protoNode : instNode), new ToolTipTreeNode(member.getTableName(), getTableDescription(member.getTableName(), "")));
// suppressed
if (recursionTable != null && !isSilent) {
// Inform the user that the table has a recursive reference
new CcddDialogHandler().showMessageDialog(parent, "<html><b>Table '</b>" + member.getTableName() + "<b>' contains a recursive reference to '</b>" + recursionTable + "<b>'", "Table Reference", JOptionPane.WARNING_MESSAGE, DialogOption.OK_OPTION);
}
}
}
}
}
use of CCDD.CcddClassesComponent.ToolTipTreeNode in project CCDD by nasa.
the class CcddTelemetrySchedulerInput method getSelectedVariableSize.
/**
********************************************************************************************
* Get the total number of bytes of the specified or selected variable(s)
*
* @param variables
* list of variables; null to use the currently selected variable(s)
*
* @return Total number of bytes of the specified variable(s)
********************************************************************************************
*/
@Override
public int getSelectedVariableSize(List<Variable> variables) {
// Check if no variable list is provided
if (variables == null) {
// Use the currently selected variables
variables = getSelectedVariable();
}
// Initialize the total number of bytes remaining in the message
int totalVarBytes = 0;
// Step through each variable
for (int varIndex = 0; varIndex < variables.size(); varIndex++) {
// Add the variable's number of bytes to the total
totalVarBytes += variables.get(varIndex).getSize();
// Check if this is a bit-wise variable
if (variables.get(varIndex).getFullName().contains(":")) {
// Variable's row index in the tree containing all variables
int treeIndex = allVariableTreePaths.indexOf(variables.get(varIndex).getFullName()) - 1;
// scheduler table isn't updated then the variable won't be located
if (treeIndex > -1) {
// Get the variable's tree node
ToolTipTreeNode last = (ToolTipTreeNode) allVariableTree.getPathForRow(treeIndex).getLastPathComponent();
// Get the node indices that encompass the packed variables (if applicable)
BitPackNodeIndex nodeIndex = allVariableTree.getBitPackedVariables(last);
// Update the variable index to skip the packed members, if present, so that
// their bytes don't affect the total
varIndex += nodeIndex.getLastIndex() - nodeIndex.getFirstIndex();
}
}
}
return totalVarBytes;
}
use of CCDD.CcddClassesComponent.ToolTipTreeNode in project CCDD by nasa.
the class CcddTelemetrySchedulerInput method getAssociatedVariables.
/**
********************************************************************************************
* For the specified list of variables, get (1) the total size in bytes of the variables that
* are associated with the first variable in the list, and (2) a list of Variable objects of
* the associated variables. Variables are considered 'associated' if (a) they are all bit-wise
* variables that are packed together, or (b) they are members of a string. If the first
* variable isn't associated with the succeeding variables then the return value references
* only the first variable
*
* @param variables
* list of variables where the first member of the list if the one to be checked for
* associates
*
* @return AssociatedVariable object containing the total size in bytes of the variables
* associated with the first variable in the specified list and the list of the
* associated variables
********************************************************************************************
*/
protected AssociatedVariable getAssociatedVariables(List<Variable> variables) {
// Get a reference to the lead variable. This is the variable that is checked for
// associated variables
Variable variable = variables.get(0);
// Store the size of the variable
int totalSize = variable.getSize();
// Create a list to store the lead variable and its associates and add the lead variable to
// the list
List<Variable> associatedVars = new ArrayList<Variable>();
associatedVars.add(variable);
// Set flag to true if the lead variable is a bit-wise variable
boolean isBitPack = variable.getFullName().contains(":");
// variables associated with it)
if (isBitPack || dataTypeHandler.isString(((TelemetryData) variable).getDataType())) {
// Get the variable's row index in the tree containing all variables
int treeIndex = allVariableTreePaths.indexOf(variable.getFullName()) - 1;
// Get the variable's tree node
ToolTipTreeNode last = (ToolTipTreeNode) allVariableTree.getPathForRow(treeIndex).getLastPathComponent();
// Get the indices of the other variables associated with this variable (i.e., other
// variable bit-packed or other members of the string)
BitPackNodeIndex nodeIndex = isBitPack ? allVariableTree.getBitPackedVariables(last) : allVariableTree.getStringVariableMembers(last);
// Calculate the number of other variables associated with the lead variable
int numVars = nodeIndex.getLastIndex() - nodeIndex.getFirstIndex();
// in the list provided
if (numVars <= variables.size()) {
// Step through the associated variables
for (int index = 1; index <= numVars; index++) {
// Check that this isn't a bit-wise variable (i.e, it's a string variable)
if (!isBitPack) {
// Add the variable's size to the total
totalSize += variables.get(index).getSize();
}
// Add the variable to the list of associated variables
associatedVars.add(variables.get(index));
}
} else // More associated variables were detected than were provided. This can only occur if
// the rates for associated variables don't match - this shouldn't be possible
{
// Inform the user if there is a rate assignment issue
new CcddDialogHandler().showMessageDialog(schedulerDlg.getDialog(), "<html><b> Auto-fill detected mismatched " + "rates for variable(s) associated with </b>" + variables.get(0).getFullName(), "Assign Failure", JOptionPane.WARNING_MESSAGE, DialogOption.OK_OPTION);
}
}
return new AssociatedVariable(totalSize, associatedVars);
}
Aggregations