Autopsy  4.7.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
SelectionContext.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2017 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.directorytree;
20 
21 import org.openide.nodes.Node;
22 import org.openide.util.NbBundle;
23 import static org.sleuthkit.autopsy.directorytree.Bundle.*;
24 
25 @NbBundle.Messages({"SelectionContext.dataSources=Data Sources",
26  "SelectionContext.views=Views"})
27 enum SelectionContext {
28  DATA_SOURCES(SelectionContext_dataSources()),
29  VIEWS(SelectionContext_views()),
30  OTHER(""); // Subnode of another node.
31 
32  private final String displayName;
33 
34  private SelectionContext(String displayName) {
35  this.displayName = displayName;
36  }
37 
38  public static SelectionContext getContextFromName(String name) {
39  if (name.equals(DATA_SOURCES.getName())) {
40  return DATA_SOURCES;
41  } else if (name.equals(VIEWS.getName())) {
42  return VIEWS;
43  } else {
44  return OTHER;
45  }
46  }
47 
48  private String getName() {
49  return displayName;
50  }
51 
59  public static SelectionContext getSelectionContext(Node n) {
60  if (n == null || n.getParentNode() == null) {
61  // Parent of root node or root node. Occurs during case open / close.
62  return SelectionContext.OTHER;
63  } else if (n.getParentNode().getParentNode() == null) {
64  // One level below root node. Should be one of DataSources, Views, or Results
65  return SelectionContext.getContextFromName(n.getDisplayName());
66  } else {
67  return getSelectionContext(n.getParentNode());
68  }
69  }
70 
71 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon Jun 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.