use of CCDD.CcddClassesComponent.ToolTipTreeNode in project CCDD by nasa.
the class CcddTableTreeHandler method getSelectedTablesWithoutChildren.
/**
********************************************************************************************
* Get a list of the tables (with their paths) represented by the selected nodes. If a header
* node (i.e., a non-table node one level above a table node, such as a group or type node) is
* selected then all of its child tables at the next level down are added to the list. If a
* selected node isn't a header node then ignore the node if it has a selected ancestor node
*
* @return List containing the table path+names of the selected node(s)
********************************************************************************************
*/
protected List<String> getSelectedTablesWithoutChildren() {
// 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()) {
// level above
if (path.getPathCount() >= getHeaderNodeLevel()) {
// Get the node for this path
ToolTipTreeNode node = (ToolTipTreeNode) path.getLastPathComponent();
// isn't a header node with no child nodes)
if (node.getChildCount() == 0 || path.getPathCount() > getHeaderNodeLevel()) {
boolean isParentSelected = false;
// Get the individual elements in the selected path
Object[] pathElements = path.getPath();
// Step through the node's ancestors
for (int index = getHeaderNodeLevel(); index < path.getPathCount() - 1; index++) {
// Check of the ancestor node is selected
if (tables.contains(pathElements[index].toString())) {
// Set the flag indicating that an ancestor of this node is
// selected and stop searching
isParentSelected = true;
break;
}
}
// Check if no ancestor of this node is selected
if (!isParentSelected) {
// Add the table path+name to the list
tables.add(getFullVariablePath(node.getPath()));
}
} else // The node is a header node (i.e., a node with table nodes as children)
{
// Step through each child node
for (int index = 0; index < node.getChildCount(); index++) {
// Add the path+name of the child to the table list
tables.add(getFullVariablePath(((ToolTipTreeNode) node.getChildAt(index)).getPath()));
}
}
}
}
}
return tables;
}
use of CCDD.CcddClassesComponent.ToolTipTreeNode in project CCDD by nasa.
the class CcddTableTreeHandler method buildNodes.
/**
********************************************************************************************
* Build the table tree nodes. This is a recursive method. In order to prevent an infinite
* loop, a check is made for a child node that exists in its own path; if found the recursion
* is terminated for that node
*
* @param thisMember
* TableMember class
*
* @param parentNode
* current working node for the table tree
*
* @param childNode
* new child node to add to the working node
********************************************************************************************
*/
private void buildNodes(TableMembers thisMember, ToolTipTreeNode parentNode, ToolTipTreeNode childNode) {
// Step through each node in the parent's path
for (TreeNode node : parentNode.getPath()) {
if (((ToolTipTreeNode) node).getLevel() >= getHeaderNodeLevel()) {
// Check if the child is in the path
if (((ToolTipTreeNode) node).getUserObject().toString().equals(childNode.getUserObject().toString())) {
// Store the name of the recursively referenced node
recursionTable = childNode.getUserObject().toString();
break;
}
}
}
// Check that a recursion error wasn't found; this prevents an infinite loop from occurring
if (recursionTable == null) {
// Add the child node to its parent
parentNode.add(childNode);
// Get the parent table and variable path for this variable
String fullTablePath = getFullVariablePath(childNode.getPath());
// Step through each table/variable referenced by the table member
for (int memIndex = 0; memIndex < thisMember.getDataTypes().size(); memIndex++) {
// Check if this data type is a primitive
if (dataTypeHandler.isPrimitive(thisMember.getDataTypes().get(memIndex))) {
String tablePath = fullTablePath;
// Set to true if the variable has a path (i.e., this is not a prototype's
// variable)
boolean isChildVariable = tablePath.contains(",");
// Check if the variable has a path
if (isChildVariable) {
// Add the data type and variable name to the variable path
tablePath += "," + thisMember.getDataTypes().get(memIndex) + "." + thisMember.getVariableNames().get(memIndex);
}
String rate = null;
// Check if a rate filter is in effect
if (rateFilter != null) {
// Get the rate value for this variable. Use the prototype's value if the
// variable doesn't have a specific rate assigned
int index = rateValues.indexOf(tablePath);
rate = isChildVariable && index != -1 ? rateValues.get(index)[2] : thisMember.getRates().get(memIndex)[rateIndex];
}
// specified rate filter
if (rateFilter == null || rate.equals(rateFilter)) {
// Get the full variable name in the form
// data_type.variable_name[:bit_length]
String variable = thisMember.getFullVariableNameWithBits(memIndex);
// the variable, using its full path and name, is not in the exclusion list
if (excludedVariables == null || !excludedVariables.contains(tablePath)) {
// Add the primitive as a node to this child node
childNode.add(new ToolTipTreeNode(variable, ""));
} else // The variable is in the exclusion list
{
// Add the variable with the node text grayed out
childNode.add(new ToolTipTreeNode(DISABLED_TEXT_COLOR + variable, ""));
}
}
} else // Data type is not a primitive, it's a structure
{
// Step through the other tables
for (TableMembers member : tableMembers) {
// Check if the table is a member of the target table
if (thisMember.getDataTypes().get(memIndex).equals(member.getTableName())) {
// Build the node name from the prototype and variable names
String nodeName = thisMember.getDataTypes().get(memIndex) + "." + thisMember.getVariableNames().get(memIndex);
// Get the variable name path to this node
String tablePath = fullTablePath + "," + nodeName;
// Add this table to the current table's node. The node name is in the
// format 'dataType.variableName<[arrayIndex]>'. If a specific
// description exists for the table then use it for the tool tip text;
// otherwise use the prototype's description
buildNodes(member, childNode, new ToolTipTreeNode(nodeName, getTableDescription(tablePath, thisMember.getDataTypes().get(memIndex))));
}
}
}
}
// (variables)
if ((treeType == STRUCTURES_WITH_PRIMITIVES || treeType == INSTANCE_STRUCTURES_WITH_PRIMITIVES || treeType == INSTANCE_STRUCTURES_WITH_PRIMITIVES_AND_RATES) && childNode.getChildCount() == 0) {
// Remove the node
parentNode.remove(childNode);
}
}
}
use of CCDD.CcddClassesComponent.ToolTipTreeNode in project CCDD by nasa.
the class CcddTableTreeHandler method addByType.
/**
********************************************************************************************
* Add tables to the specified prototype and instance nodes based on table type
*
* @param nameList
* list of table names belonging to the filtered selection; null if no filtering
*
* @param protoNode
* parent node for the prototype nodes
*
* @param instNode
* parent node for the instance nodes
*
* @param groupInfo
* reference to the group information is filtering also by group; null if not
* filtering by group
*
* @param parent
* GUI component calling this method
********************************************************************************************
*/
private void addByType(ToolTipTreeNode protoNode, ToolTipTreeNode instNode, GroupInformation groupInfo, Component parent) {
// Step through each table type
for (String type : tableTypeHandler.getTypes()) {
List<String> tables = new ArrayList<String>();
// Step through each table
for (TableMembers member : tableMembers) {
// it belongs to the current group
if (type.equals(member.getTableType()) && (groupInfo == null || groupInfo.getTableMembers().contains(member.getTableName()))) {
// Add the table name to the list for this type
tables.add(member.getTableName());
}
}
// Create nodes for the type and add them to the prototype and instance nodes
ToolTipTreeNode protoTypeNode = new ToolTipTreeNode(type, getDescriptions ? tableTypeHandler.getTypeDefinition(type).getDescription() : null);
ToolTipTreeNode instTypeNode = new ToolTipTreeNode(type, getDescriptions ? tableTypeHandler.getTypeDefinition(type).getDescription() : null);
instNode.add(instTypeNode);
protoNode.add(protoTypeNode);
// Build the prototype and instance nodes filtered by type (and group, if applicable)
buildTopLevelNodes(tables, instTypeNode, protoTypeNode, parent);
}
}
use of CCDD.CcddClassesComponent.ToolTipTreeNode in project CCDD by nasa.
the class CcddTableTreeHandler method addAllTablesGroup.
/**
********************************************************************************************
* Add the pseudo-group containing all tables to the specified prototype and instance nodes
*
* @param protoNode
* parent node for the prototype nodes
*
* @param instNode
* parent node for the instance nodes
*
* @param parent
* GUI component calling this method
********************************************************************************************
*/
private void addAllTablesGroup(ToolTipTreeNode protoNode, ToolTipTreeNode instNode, Component parent) {
// Create nodes for all tables
ToolTipTreeNode protoAllNode = new ToolTipTreeNode("<html><i>" + ALL_TABLES_GROUP_NODE_NAME, "Group containing every prototype table");
ToolTipTreeNode instAllNode = new ToolTipTreeNode("<html><i>" + ALL_TABLES_GROUP_NODE_NAME, "Group containing every table");
// Add the node to the prototype and instance nodes
protoNode.add(protoAllNode);
instNode.add(instAllNode);
// Check if the tree is filtered by table type
if (isByType) {
// Build the all tables node, filtered by table type
addByType(protoAllNode, instAllNode, null, parent);
} else // The tree is only filtered by group
{
// Build the all tables node
buildTopLevelNodes(null, instAllNode, protoAllNode, parent);
}
}
use of CCDD.CcddClassesComponent.ToolTipTreeNode in project CCDD by nasa.
the class CcddTableTreeHandler method setNodeEnableByExcludeList.
/**
********************************************************************************************
* Update the text color for the nodes that represent a primitive variable based on the
* variable exclusion list
********************************************************************************************
*/
private void setNodeEnableByExcludeList() {
// Step through elements and children of this node
for (Enumeration<?> element = root.preorderEnumeration(); element.hasMoreElements(); ) {
// Get the node reference
ToolTipTreeNode node = (ToolTipTreeNode) element.nextElement();
// that the node is for a structure or variable
if (node.isLeaf() && node.getLevel() >= getHeaderNodeLevel()) {
// Get the node name
String nodeName = node.getUserObject().toString();
// Set to true if the variable in this path is not excluded (as evidenced by having
// a HTML tag)
boolean wasExcluded = nodeName.contains(DISABLED_TEXT_COLOR);
// Get the path for this node as a string array
String[] nodes = CcddUtilities.convertObjectToString(node.getPath());
// Step through each node in the path
for (int index = 0; index < nodes.length; index++) {
// Remove the HTML tags from the node
nodes[index] = removeExtraText(nodes[index]);
}
// Get the variable path and name. Skip the link name node if present
String variablePath = getFullVariablePath(nodes, (nodes[1].equals(LINKED_VARIABLES_NODE_NAME) && !isFilteredByGroup() ? 1 : 0));
// Set the flag indicating the variable is excluded if it's in the exclusion lists
boolean isExcluded = excludedVariables.contains(variablePath) || (nodes[1].equals(UNLINKED_VARIABLES_NODE_NAME) && linkedVariables.contains(variablePath));
// Check if the variable exclusion state has changed
if (wasExcluded != isExcluded) {
// Reset the node name to indicate its inclusion/exclusion state. If excluded,
// prepend the HTML tag to gray out the name. Indicate that the node changed so
// that the tree redraws the name
node.setUserObject((isExcluded ? DISABLED_TEXT_COLOR : "") + nodes[nodes.length - 1]);
((DefaultTreeModel) getModel()).nodeChanged(node);
}
}
}
}
Aggregations