use of CCDD.CcddClassesDataTable.LinkInformation in project CCDD by nasa.
the class CcddLinkTreeHandler method addLinkInformation.
/**
********************************************************************************************
* Add a new link to the link information class
*
* @param rateName
* rate column name
*
* @param linkName
* link name
*
* @param sampleRate
* link rate in samples per second
*
* @param description
* link description
********************************************************************************************
*/
protected void addLinkInformation(String rateName, String linkName, String sampleRate, String description) {
// Add the new link information
linkInformation.add(new LinkInformation(rateName, linkName, sampleRate, description));
// Update the link definitions to account for the added link
updateLinkDefinitions();
}
use of CCDD.CcddClassesDataTable.LinkInformation in project CCDD by nasa.
the class CcddLinkTreeHandler method getLinkInformation.
/**
********************************************************************************************
* Get the reference to a specified link's information
*
* @param name
* link name
*
* @return Reference to the link's information; null if the link doesn't exist
********************************************************************************************
*/
protected LinkInformation getLinkInformation(String name) {
LinkInformation linkInfo = null;
// Remove HTML tag(s) and rate/size information
name = removeExtraText(name);
// Step through each link's information
for (LinkInformation info : linkInformation) {
// Check if the link name matches the target name
if (info.getName().equals(name)) {
// Store the link information reference and stop searching
linkInfo = info;
break;
}
}
return linkInfo;
}
use of CCDD.CcddClassesDataTable.LinkInformation in project CCDD by nasa.
the class CcddLinkTreeHandler method getLinksMatchingRate.
/**
********************************************************************************************
* Create a subtree with only the links that contain variables with sample rates matching the
* selected rate
*
* @param rootNodeName
* name of the root node for the matching links
*
* @param rootNodeDescription
* tool tip text for the root node
*
* @return Node with only the links that contain variables with sample rates matching the
* selected rate
********************************************************************************************
*/
protected ToolTipTreeNode getLinksMatchingRate(String rootNodeName, String rootNodeDescription) {
// Create a node to contain the matching links
ToolTipTreeNode validLinks = new ToolTipTreeNode(rootNodeName, rootNodeDescription);
// Copy the current links tree to the new node
copySubTree(getRootNode(), validLinks);
// removed during the processing
for (int index = validLinks.getChildCount() - 1; index >= 0; index--) {
// Get the link information for this link
LinkInformation linkInfo = getLinkInformation(validLinks.getChildAt(index).toString());
// Check if the link exists and if the link's rate doesn't match the selected rate
if (linkInfo != null && !linkInfo.getSampleRate().equals(selectedRate)) {
// Remove this link's node from the valid links tree
validLinks.remove(index);
}
}
return validLinks;
}
use of CCDD.CcddClassesDataTable.LinkInformation in project CCDD by nasa.
the class CcddLinkTreeHandler method adjustNodeText.
/**
********************************************************************************************
* Append the sample rate and size in bytes to the nodes representing a link name. Set the node
* text color based on the currently selected sample rate and the rate of the link to which the
* node belongs: black for a match and gray for a mismatch
*
* @param startNode
* starting node for which to adjust the text and color
********************************************************************************************
*/
protected void adjustNodeText(ToolTipTreeNode startNode) {
// Step through the elements and children of this node
for (Enumeration<?> element = startNode.preorderEnumeration(); element.hasMoreElements(); ) {
// Get the node reference
ToolTipTreeNode node = (ToolTipTreeNode) element.nextElement();
// Get the tree level for this node
int level = node.getLevel();
// called when no nodes exist
if (level > 0) {
// Get the link name from the node path
String linkName = removeExtraText(node.getPath()[1].toString());
// Get the reference to the link's information. The link name is the second node in
// the path for this node
LinkInformation linkInfo = getLinkInformation(linkName);
// Check that the node references a link
if (linkInfo != null) {
// Get the node name
String nodeName = removeExtraText(node.getUserObject().toString());
// Check if this node represents a link name
if (level == 1) {
// Assign the link name formatted as HTML
nodeName = "<html>" + linkName + " <i>(";
// Get the link size in bytes
int sizeInBytes = linkHandler.getLinkSizeInBytes(linkInfo.getRateName(), linkName);
// Check if the size is non-zero; i.e., variables are assigned to this link
if (sizeInBytes != 0) {
// Append the link size to the link name
nodeName += linkInfo.getSampleRate() + " Hz, " + sizeInBytes + (sizeInBytes == 1 ? " byte)" : " bytes)");
} else // No variables are assigned to this link
{
// Indicate that the link is empty
nodeName += "empty)";
}
}
// Check if the selected sample rate doesn't match the link's rate
if (!linkInfo.getSampleRate().equals("0") && !selectedRate.equals(linkInfo.getSampleRate())) {
// Gray out the node text
nodeName = DISABLED_TEXT_COLOR + nodeName;
}
// Update the node name. Indicate that the node changed so that the tree
// redraws the name
node.setUserObject(nodeName);
((UndoableTreeModel) getModel()).nodeChanged(node);
}
}
}
}
use of CCDD.CcddClassesDataTable.LinkInformation in project CCDD by nasa.
the class CcddLinkTreeHandler method buildTree.
/**
********************************************************************************************
* Build the link tree from the database
*
* @param filterByType
* true if the tree is filtered by table type. This is not applicable to the link
* tree, which can only contain structure references
*
* @param filterByApp
* true if the tree is filtered by application. This is not applicable to the link
* tree, which can only contain structure references
*
* @param filterValue
* string value that may be used to modify the tree building method; null or blank
* if not filtering
*
* @param filterFlag
* flag used to filter the tree content. Not used for the link tree
*
* @param parent
* GUI component calling this method
********************************************************************************************
*/
@Override
protected void buildTree(boolean filterByType, boolean filterByApp, String filterValue, boolean filterFlag, Component parent) {
super.buildTree(false, false, filterValue, filterFlag, parent);
// Get the tree's root node
ToolTipTreeNode root = getRootNode();
// Create the storage for the link information
linkInformation = undoHandler.new UndoableArrayList<LinkInformation>();
// Register the tool tip manager for the link tree (otherwise the tool tips aren't
// displayed)
ToolTipManager.sharedInstance().registerComponent(this);
// Set the flag to indicate that the link tree is being built. This flag is used to inhibit
// actions involving tree selection value changes during the build process
isBuilding = true;
// Set the renderer for the tree so that the link information can be displayed, and so that
// custom icons can be used for the various node types
setCellRenderer(new TableTreeCellRenderer() {
/**
************************************************************************************
* Display the variable nodes using a special icon in the tree
************************************************************************************
*/
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
// Display the node name
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
// Get the tree level for this node
int level = ((ToolTipTreeNode) value).getLevel();
// is called when no nodes exist
if (level != 0) {
// Get the reference to the link's information. The link name is the second
// node in the path for this node
LinkInformation linkInfo = getLinkInformation(((ToolTipTreeNode) value).getPath()[1].toString());
// Check that the link information exists
if (linkInfo != null) {
// Check if this node represents a link name
if (level == 1) {
// Get the rate for this link
String linkRate = linkInfo.getSampleRate();
// has no assigned rate
if (linkRate.equals("0") || selectedRate.equals(linkRate)) {
setIcon(validLinkIcon);
} else // The link rate doesn't match the selected rate
{
setIcon(invalidLinkIcon);
}
} else // Check if this node represents a variable
if (leaf) {
// Set the icon for the variable node
setVariableNodeIcon(this, (ToolTipTreeNode) value, row, true);
}
}
}
return this;
}
});
// Step through each link
for (String[] linkDefn : linkDefinitions) {
// Check if the link definition matches the target data stream rate column name
if (linkDefn[LinksColumn.RATE_NAME.ordinal()].equals(filterValue)) {
// Extract the rate name, link name, and rate/description or member
String linkRate = linkDefn[LinksColumn.RATE_NAME.ordinal()];
String linkName = linkDefn[LinksColumn.LINK_NAME.ordinal()];
String linkMember = linkDefn[LinksColumn.MEMBER.ordinal()];
// character is a digit, which is the link rate
if (linkMember.matches(InputDataType.RATE.getInputMatch() + ",.*")) {
// Split the entry into the rate and description
String[] rateAndDesc = linkMember.split(",", 2);
// Store the link information
linkInformation.add(new LinkInformation(linkRate, linkName, rateAndDesc[0], rateAndDesc[1]));
// Create a node for the link and add it to the link tree
addInformationNode(linkName, rateAndDesc[1]);
} else // This is a variable path
{
// Step through each current link node
for (int index = 0; index < root.getChildCount(); index++) {
// Check if the link name matches the node name
if (linkName.equals(root.getChildAt(index).toString())) {
// Add the variable to the node and stop searching
addNodeToInfoNode((ToolTipTreeNode) root.getChildAt(index), linkMember.split(","), 0);
break;
}
}
}
}
}
// Expand or collapse the tree based on the expansion flag
setTreeExpansion(isExpanded);
// Clear the flag that indicates the link tree is being built
isBuilding = false;
}
Aggregations