19 package org.sleuthkit.autopsy.directorytree;
21 import java.util.Objects;
22 import org.openide.nodes.Node;
23 import org.openide.util.NbBundle;
29 @NbBundle.
Messages({
"SelectionContext.dataSources=Data Sources",
30 "SelectionContext.dataSourceFiles=Data Source Files",
31 "SelectionContext.views=Views"})
32 enum SelectionContext {
33 DATA_SOURCES(SelectionContext_dataSources()),
34 VIEWS(SelectionContext_views()),
36 DATA_SOURCE_FILES(SelectionContext_dataSourceFiles());
38 private final String displayName;
40 private SelectionContext(String displayName) {
41 this.displayName = displayName;
44 public static SelectionContext getContextFromName(String name) {
45 if (name.equals(DATA_SOURCES.getName()) || name.equals(DATA_SOURCE_FILES.getName())) {
47 }
else if (name.equals(VIEWS.getName())) {
54 private String getName() {
65 public static SelectionContext getSelectionContext(Node n) {
66 if (n == null || n.getParentNode() == null) {
68 return SelectionContext.OTHER;
69 }
else if ((!Objects.equals(CasePreferences.getGroupItemsInTreeByDataSource(),
true) && DataSourcesNode.getNameIdentifier().equals(n.getParentNode().getName()))
70 || (Objects.equals(CasePreferences.getGroupItemsInTreeByDataSource(),
true) && DataSourceFilesNode.getNameIdentifier().equals(n.getParentNode().getName()))) {
74 return SelectionContext.DATA_SOURCES;
75 }
else if (n.getParentNode().getParentNode() == null) {
77 return SelectionContext.getContextFromName(n.getDisplayName());
82 if (n.getParentNode().getParentNode().getParentNode() == null) {
83 SelectionContext context = SelectionContext.getContextFromName(n.getDisplayName());
84 if (context != SelectionContext.OTHER) {
89 return getSelectionContext(n.getParentNode());