Autopsy  4.21.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.Arrays;
23 import java.util.Collection;
24 import java.util.HashSet;
25 import java.util.List;
26 import javax.swing.Action;
27 import org.openide.util.NbBundle;
28 import org.openide.util.Utilities;
38 import org.sleuthkit.datamodel.AbstractFile;
39 import org.sleuthkit.datamodel.Directory;
40 import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
41 
46 public class DirectoryNode extends AbstractFsContentNode<AbstractFile> {
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  if (!getDirectoryBrowseMode()) {
83  actionsList.add(new ViewContextAction(
84  NbBundle.getMessage(this.getClass(), "DirectoryNode.getActions.viewFileInDir.text"), this));
85  actionsList.add(null); // creates a menu separator
86  }
87  actionsList.add(new NewWindowViewAction(NbBundle.getMessage(this.getClass(), "DirectoryNode.viewInNewWin.text"), this));
88  actionsList.add(ViewFileInTimelineAction.createViewFileAction(content));
89  actionsList.add(null); // creates a menu separator
90  actionsList.add(ExtractAction.getInstance());
91  actionsList.add(ExportCSVAction.getInstance());
92  actionsList.add(null); // creates a menu separator
93  actionsList.add(new RunIngestModulesAction(content));
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  actionsList.add(null);
104  actionsList.addAll(Arrays.asList(super.getActions(true)));
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-2022 Basis Technology. Generated on: Tue Feb 6 2024
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.