Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
VirtualDirectoryNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2014 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.datamodel;
20 
21 import java.util.ArrayList;
22 import java.util.LinkedHashMap;
23 import java.util.List;
24 import java.util.Map;
25 import javax.swing.Action;
26 import org.openide.nodes.Sheet;
27 import org.openide.util.NbBundle;
34 
38 public class VirtualDirectoryNode extends AbstractAbstractFileNode<VirtualDirectory> {
39 
40  private static Logger logger = Logger.getLogger(VirtualDirectoryNode.class.getName());
41  //prefix for special VirtualDirectory root nodes grouping local files
42  public final static String LOGICAL_FILE_SET_PREFIX = "LogicalFileSet"; //NON-NLS
43 
44  public static String nameForLayoutFile(VirtualDirectory ld) {
45  return ld.getName();
46  }
47 
49  super(ld);
50 
51  this.setDisplayName(nameForLayoutFile(ld));
52 
53  String name = ld.getName();
54 
55  //set icon for name, special case for some built-ins
56  if (name.equals(VirtualDirectory.NAME_UNALLOC)) {
57  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/folder-icon-deleted.png"); //NON-NLS
58  } else if (name.startsWith(LOGICAL_FILE_SET_PREFIX)) {
59  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/fileset-icon-16.png"); //NON-NLS
60  } else if (name.equals(VirtualDirectory.NAME_CARVED)) {
61  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/Folder-icon.png"); //TODO NON-NLS
62  } else {
63  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/Folder-icon.png"); //NON-NLS
64  }
65 
66  }
67 
74  @Override
75  public Action[] getActions(boolean popup) {
76  List<Action> actions = new ArrayList<>();
77  actions.add(new NewWindowViewAction(
78  NbBundle.getMessage(this.getClass(), "VirtualDirectoryNode.getActions.viewInNewWin.text"), this));
79  actions.add(null); // creates a menu separator
80  actions.add(ExtractAction.getInstance());
81  actions.add(null); // creates a menu separator
82  actions.addAll(ContextMenuExtensionPoint.getActions());
83  return actions.toArray(new Action[0]);
84  }
85 
86  @Override
87  protected Sheet createSheet() {
88  Sheet s = super.createSheet();
89  Sheet.Set ss = s.get(Sheet.PROPERTIES);
90  if (ss == null) {
91  ss = Sheet.createPropertiesSet();
92  s.put(ss);
93  }
94 
95  Map<String, Object> map = new LinkedHashMap<>();
96  fillPropertyMap(map, content);
97 
98  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VirtualDirectoryNode.createSheet.name.name"),
99  NbBundle.getMessage(this.getClass(),
100  "VirtualDirectoryNode.createSheet.name.displayName"),
101  NbBundle.getMessage(this.getClass(), "VirtualDirectoryNode.createSheet.name.desc"),
102  getName()));
103 
104  final String NO_DESCR = NbBundle.getMessage(this.getClass(), "VirtualDirectoryNode.createSheet.noDesc");
105  for (Map.Entry<String, Object> entry : map.entrySet()) {
106  ss.put(new NodeProperty<>(entry.getKey(), entry.getKey(), NO_DESCR, entry.getValue()));
107  }
108 
109  return s;
110  }
111 
112  @Override
113  public <T> T accept(ContentNodeVisitor<T> v) {
114  return v.visit(this);
115  }
116 
117  @Override
118  public <T> T accept(DisplayableItemNodeVisitor<T> v) {
119  return v.visit(this);
120  }
121 
122  @Override
123  public boolean isLeafTypeNode() {
124  return true;
125  }
126 
133  public static String metaFlagToString(short metaFlag) {
134 
135  String result = "";
136 
137  short allocFlag = TskData.TSK_FS_META_FLAG_ENUM.ALLOC.getValue();
138  short unallocFlag = TskData.TSK_FS_META_FLAG_ENUM.UNALLOC.getValue();
139 
140  if ((metaFlag & allocFlag) == allocFlag) {
141  result = TskData.TSK_FS_META_FLAG_ENUM.ALLOC.toString();
142  }
143  if ((metaFlag & unallocFlag) == unallocFlag) {
144  result = TskData.TSK_FS_META_FLAG_ENUM.UNALLOC.toString();
145  }
146 
147  return result;
148  }
149 }
static void fillPropertyMap(Map< String, Object > map, AbstractFile content)
static synchronized ExtractAction getInstance()
static Logger getLogger(String name)
Definition: Logger.java:131

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.