Autopsy  4.4
Graphical digital forensics platform for The Sleuth Kit and other tools.
DirectoryNode.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.datamodel;
20 
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.HashSet;
24 import java.util.List;
25 import javax.swing.Action;
26 import org.openide.util.NbBundle;
27 import org.openide.util.Utilities;
36 import org.sleuthkit.datamodel.AbstractFile;
37 import org.sleuthkit.datamodel.Directory;
38 import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
39 
44 public class DirectoryNode extends AbstractFsContentNode<AbstractFile> {
45 
46  private static final Logger LOGGER = Logger.getLogger(DirectoryNode.class.getName());
47 
48  public static final String DOTDOTDIR = NbBundle.getMessage(DirectoryNode.class, "DirectoryNode.parFolder.text");
49  public static final String DOTDIR = NbBundle.getMessage(DirectoryNode.class, "DirectoryNode.curFolder.text");
50 
51  public DirectoryNode(Directory dir) {
52  this(dir, true);
53 
54  setIcon(dir);
55  }
56 
57  public DirectoryNode(AbstractFile dir, boolean directoryBrowseMode) {
58  super(dir, directoryBrowseMode);
59 
60  setIcon(dir);
61  }
62 
63  private void setIcon(AbstractFile dir) {
64  // set name, display name, and icon
65  if (dir.isDirNameFlagSet(TSK_FS_NAME_FLAG_ENUM.UNALLOC)) {
66  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/folder-icon-deleted.png"); //NON-NLS
67  } else {
68  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/Folder-icon.png"); //NON-NLS
69  }
70  }
71 
79  @Override
80  public Action[] getActions(boolean popup) {
81  List<Action> actionsList = new ArrayList<>();
82  for (Action a : super.getActions(true)) {
83  actionsList.add(a);
84  }
85  if (!getDirectoryBrowseMode()) {
86  actionsList.add(new ViewContextAction(
87  NbBundle.getMessage(this.getClass(), "DirectoryNode.getActions.viewFileInDir.text"), this));
88  actionsList.add(null); // creates a menu separator
89  }
90  actionsList.add(new NewWindowViewAction(NbBundle.getMessage(this.getClass(), "DirectoryNode.viewInNewWin.text"), this));
91  actionsList.add(ViewFileInTimelineAction.createViewFileAction(getContent()));
92  actionsList.add(null); // creates a menu separator
93  actionsList.add(ExtractAction.getInstance());
94  actionsList.add(null); // creates a menu separator
95  actionsList.add(AddContentTagAction.getInstance());
96 
97  final Collection<AbstractFile> selectedFilesList = new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
98  if(selectedFilesList.size() == 1) {
99  actionsList.add(DeleteFileContentTagAction.getInstance());
100  }
101 
102  actionsList.addAll(ContextMenuExtensionPoint.getActions());
103  return actionsList.toArray(new Action[actionsList.size()]);
104  }
105 
106  @Override
107  public <T> T accept(ContentNodeVisitor<T> v) {
108  return v.visit(this);
109  }
110 
111  @Override
112  public <T> T accept(DisplayableItemNodeVisitor<T> v) {
113  return v.visit(this);
114  }
115 
116  @Override
117  public boolean isLeafTypeNode() {
118  return false;
119  }
120 
121  @Override
122  public String getItemType() {
123  return DisplayableItemNode.FILE_PARENT_NODE_KEY;
124  }
125 }
DirectoryNode(AbstractFile dir, boolean directoryBrowseMode)
static synchronized ExtractAction getInstance()
static synchronized DeleteFileContentTagAction getInstance()
synchronized static Logger getLogger(String name)
Definition: Logger.java:161
static ViewFileInTimelineAction createViewFileAction(AbstractFile file)
static synchronized AddContentTagAction getInstance()

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