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

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.