use of CCDD.CcddClassesComponent.ToolTipTreeNode in project CCDD by nasa.
the class CcddGroupManagerDialog method removeTableFromGroup.
/**
********************************************************************************************
* Remove the selected table(s) from the group tree
********************************************************************************************
*/
private void removeTableFromGroup() {
// Disable automatically ending the edit sequence. This allows all of the deleted group
// members to be grouped into a single sequence so that if undone, all members are restored
// together
undoHandler.setAutoEndEditSequence(false);
ToolTipTreeNode node = null;
// Check if a single group is selected
if (selectedGroup != null) {
// Store the selected group's node
node = (ToolTipTreeNode) groupTree.getSelectionPath().getPathComponent(1);
}
// Remove the selected tables from the groups in the group tree
groupTree.removeSelectedChildNodes(false);
// Check if a single group was selected prior to removing the selected table(s)
if (node != null) {
// Select the node for the group that had the table(s) removed
groupTree.setSelectionPath(new TreePath(node.getPath()));
}
// Update the group dialog's change indicator
updateChangeIndicator();
// Re-enable automatic edit sequence ending, then end the edit sequence to group the
// removed members
undoHandler.setAutoEndEditSequence(true);
undoManager.endEditSequence();
}
use of CCDD.CcddClassesComponent.ToolTipTreeNode in project CCDD by nasa.
the class CcddGroupManagerDialog method selectGroupByTable.
/**
********************************************************************************************
* Select the group in the group tree for which the selected table in the table tree is a
* member
********************************************************************************************
*/
private void selectGroupByTable() {
// Clear any currently selected group(s)
groupTree.clearSelection();
// Get the paths of the selected table tree nodes
TreePath[] selectionPaths = tableTree.getSelectionPaths();
// Check if a node is selected in the table tree
if (selectionPaths != null) {
List<String> selectedTables = new ArrayList<String>();
List<TreePath> paths = new ArrayList<TreePath>();
// Step through each selected node
for (TreePath path : selectionPaths) {
// Get the path for the node
String tablePath = tableTree.removeExtraText(tableTree.getFullVariablePath(path.getPath()));
// Check if the path is for a table and not a header or filter
if (!tablePath.isEmpty()) {
// Add the table path to the list of those to match
selectedTables.add(tablePath);
}
}
// Check if a table is selected
if (selectedTables.size() != 0) {
int matchCount = -1;
ToolTipTreeNode groupNode = null;
// Step through each element and child of the group tree
for (Enumeration<?> element = groupTree.getRootNode().preorderEnumeration(); element.hasMoreElements(); ) {
// Get the node reference
ToolTipTreeNode node = (ToolTipTreeNode) element.nextElement();
// Check if the node references a group (and not a filter or table)
if (node.getLevel() == groupTree.getGroupNodeLevel()) {
// Store the node referencing the group name and reset the matched tables
// counter
groupNode = node;
matchCount = 0;
} else // and the node references a table
if (matchCount != -1 && node.getLevel() >= groupTree.getItemNodeLevel()) {
// Get the full path to the table reference in the group tree
String groupTable = groupTree.removeExtraText(groupTree.getFullVariablePath(node.getPath(), 2));
// Step through the selected tables
for (String selectedTable : selectedTables) {
// Check if the group tree table matches the selected table
if (groupTable.equals(selectedTable)) {
// Increment the matched tables counter and stop searching
matchCount++;
break;
}
}
}
// Check if the previous group contains all of the selected tables
if (matchCount == selectedTables.size()) {
// Add the group to the list of those containing the selected table(s)
paths.add(CcddCommonTreeHandler.getPathFromNode(groupNode));
// Reset the matched tables counter so that any remaining tables in this
// group are ignored. When the next group's node is encountered the counter
// is reset
matchCount = -1;
}
}
// Check if the table belongs to any group(s)
if (!paths.isEmpty()) {
// Select the group(s) to which the table belongs
groupTree.setSelectionPaths(paths.toArray(new TreePath[0]));
}
}
}
}
use of CCDD.CcddClassesComponent.ToolTipTreeNode in project CCDD by nasa.
the class CcddInformationTreeHandler method removeSelectedChildNodes.
/**
********************************************************************************************
* Remove the currently selected child node(s) from the selected top level node(s)
*
* @param isVariable
* true if the this tree contains variables
********************************************************************************************
*/
protected void removeSelectedChildNodes(boolean isVariable) {
List<Object[]> selectedVariablePaths = new ArrayList<Object[]>();
// Check if at least one node is selected
if (getSelectionCount() != 0) {
// Step through each selected node
for (TreePath path : getSelectionPaths()) {
// Check if the selected variable node has children
addChildNodes((ToolTipTreeNode) path.getLastPathComponent(), selectedVariablePaths, new ArrayList<String>(), isVariable);
}
// Step through the selected paths
for (Object[] varPath : selectedVariablePaths) {
// Get the node referenced by the path
TreePath path = new TreePath(varPath);
ToolTipTreeNode node = (ToolTipTreeNode) path.getLastPathComponent();
// child node
while (node.getParent().getChildCount() == 1 && node.getLevel() > 2 + getHeaderNodeLevel()) {
// Get the parent node for the child(ren) to be removed
node = (ToolTipTreeNode) node.getParent();
}
// Remove the node from the information tree
infoTreeModel.removeNodeFromParent(node);
}
}
}
use of CCDD.CcddClassesComponent.ToolTipTreeNode in project CCDD by nasa.
the class CcddInformationTreeHandler method renameRootChildNode.
/**
********************************************************************************************
* Rename a top-level node (a node that is a direct child of the root node)
*
* @param oldName
* current name of the node
*
* @param newName
* new name for the node
*
* @return Reference to the renamed node
********************************************************************************************
*/
protected ToolTipTreeNode renameRootChildNode(Object oldName, Object newName) {
ToolTipTreeNode node = null;
// Step through each row in the information tree
for (int row = 0; row < root.getChildCount(); row++) {
// Check if this node's name matches the target
if (((ToolTipTreeNode) root.getChildAt(row)).getUserObject().toString().equals((oldName))) {
// Get the node from the path
node = (ToolTipTreeNode) root.getChildAt(row);
// Rename the node and update the tree, then stop searching
node.setUserObject(newName);
infoTreeModel.nodeChanged(node);
break;
}
}
return node;
}
use of CCDD.CcddClassesComponent.ToolTipTreeNode in project CCDD by nasa.
the class CcddLinkManagerDialog method renameLink.
/**
********************************************************************************************
* Rename the selected link
********************************************************************************************
*/
private void renameLink() {
// Get the selected link(s)
String[] selected = activeHandler.getLinkTree().getTopLevelSelectedNodeNames();
// Check that a single node is selected in the link tree
if (selected.length == 1) {
// Remove any HTML tags and parenthetical text from the selected link name
String nameOnly = activeHandler.getLinkTree().removeExtraText(selected[0]);
// Create a panel to contain the dialog components
JPanel dialogPnl = new JPanel(new GridBagLayout());
// Create the link renaming dialog label and field
addLinkNameField("Rename '" + nameOnly + "' to:", nameOnly, dialogPnl);
// Create the link renaming dialog
CcddDialogHandler linkDlg = new CcddDialogHandler() {
/**
********************************************************************************
* Verify that the dialog content is valid
*
* @return true if the input values are valid
********************************************************************************
*/
@Override
protected boolean verifySelection() {
return verifyLinkName(false);
}
};
// Display the link renaming dialog
if (linkDlg.showOptionsDialog(CcddLinkManagerDialog.this, dialogPnl, "Rename Link", DialogOption.RENAME_OPTION, true) == OK_BUTTON) {
// Disable automatically ending the edit sequence. This allows all of the deleted
// links to be grouped into a single sequence so that if undone, all fields are
// restored
activeHandler.getUndoHandler().setAutoEndEditSequence(false);
// Step through the link's definitions
for (String[] linkDefn : activeHandler.getLinkTree().getLinkHandler().getLinkDefinitionsByName(nameOnly, activeHandler.getRateName())) {
// Update the link definition's link name
linkDefn[LinksColumn.LINK_NAME.ordinal()] = linkNameFld.getText();
}
// Update the link's name in the link information
activeHandler.getLinkTree().getLinkInformation(nameOnly).setName(linkNameFld.getText());
// Rename the link's node in the link tree
ToolTipTreeNode renamedNode = activeHandler.getLinkTree().renameRootChildNode(selected[0], linkNameFld.getText());
// Adjust the link node's text to add the size and rate
activeHandler.getLinkTree().adjustNodeText(renamedNode);
// Update the link dialog's change indicator
updateChangeIndicator();
// Re-enable automatic edit sequence ending, then end the edit sequence to group
// the deleted links
activeHandler.getUndoHandler().setAutoEndEditSequence(true);
activeHandler.getUndoManager().endEditSequence();
}
}
}
Aggregations