getNameIdentifier

This commit is contained in:
Greg DiCristofaro 2021-02-24 09:56:06 -05:00
parent aa41747841
commit 98bf69a788
3 changed files with 21 additions and 6 deletions

View File

@ -93,7 +93,14 @@ public class DataSourcesByTypeNode extends DisplayableItemNode {
}
public static final String NAME = Bundle.DataSourcesHostsNode_name();
private static final String NAME = Bundle.DataSourcesHostsNode_name();
/**
* @return The name used to identify the node of this type with a lookup.
*/
public static String getNameIdentifier() {
return NAME;
}
/**
* Main constructor.

View File

@ -43,7 +43,15 @@ import org.sleuthkit.datamodel.TskDataException;
*/
public class DataSourcesNode extends DisplayableItemNode {
public static final String NAME = NbBundle.getMessage(DataSourcesNode.class, "DataSourcesNode.name");
private static final String NAME = NbBundle.getMessage(DataSourcesNode.class, "DataSourcesNode.name");
/**
* @return The name used to identify the node of this type with a lookup.
*/
public static String getNameIdentifier() {
return NAME;
}
private final String displayName;
// NOTE: The images passed in via argument will be ignored.

View File

@ -211,7 +211,7 @@ public class ViewContextAction extends AbstractAction {
}
// for this data source, get the "Data Sources" child node
Node datasourceGroupingNode = treeNode.getChildren().findChild(DataSourcesNode.NAME);
Node datasourceGroupingNode = treeNode.getChildren().findChild(DataSourcesNode.getNameIdentifier());
// check whether this is the data source we are looking for
parentTreeViewNode = findParentNodeInTree(parentContent, datasourceGroupingNode);
@ -227,7 +227,7 @@ public class ViewContextAction extends AbstractAction {
Node datasourceGroupingNode = rootChildren.findChild(dsname);
if (!Objects.isNull(datasourceGroupingNode)) {
Children dsChildren = datasourceGroupingNode.getChildren();
parentTreeViewNode = dsChildren.findChild(DataSourcesNode.NAME);
parentTreeViewNode = dsChildren.findChild(DataSourcesNode.getNameIdentifier());
}
}
@ -244,7 +244,7 @@ public class ViewContextAction extends AbstractAction {
} else { // Classic view
// Start the search at the DataSourcesNode
Children rootChildren = treeViewExplorerMgr.getRootContext().getChildren();
Node rootDsNode = rootChildren == null ? null : rootChildren.findChild(DataSourcesByTypeNode.NAME);
Node rootDsNode = rootChildren == null ? null : rootChildren.findChild(DataSourcesByTypeNode.getNameIdentifier());
if (rootDsNode != null) {
for (Node dataSourceLevelNode : getDataSourceLevelNodes(rootDsNode)) {
DataSource dataSource = dataSourceLevelNode.getLookup().lookup(DataSource.class);
@ -313,7 +313,7 @@ public class ViewContextAction extends AbstractAction {
return Collections.emptyList();
} else if (node.getLookup().lookup(Host.class) != null ||
node.getLookup().lookup(Person.class) != null ||
DataSourcesByTypeNode.NAME.equals(node.getLookup().lookup(String.class))) {
DataSourcesByTypeNode.getNameIdentifier().equals(node.getLookup().lookup(String.class))) {
Children children = node.getChildren();
Node[] childNodes = children == null ? null : children.getNodes();
if (childNodes == null) {