Autopsy 4.22.1
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 */
19package org.sleuthkit.autopsy.datamodel;
20
21import java.util.ArrayList;
22import java.util.Arrays;
23import java.util.Collection;
24import java.util.HashSet;
25import java.util.List;
26import javax.swing.Action;
27import org.openide.util.NbBundle;
28import org.openide.util.Utilities;
29import org.sleuthkit.autopsy.actions.AddContentTagAction;
30import org.sleuthkit.autopsy.actions.DeleteFileContentTagAction;
31import org.sleuthkit.autopsy.coreutils.ContextMenuExtensionPoint;
32import org.sleuthkit.autopsy.directorytree.ExportCSVAction;
33import org.sleuthkit.autopsy.directorytree.ExtractAction;
34import org.sleuthkit.autopsy.directorytree.NewWindowViewAction;
35import org.sleuthkit.autopsy.directorytree.ViewContextAction;
36import org.sleuthkit.autopsy.ingest.runIngestModuleWizard.RunIngestModulesAction;
37import org.sleuthkit.autopsy.timeline.actions.ViewFileInTimelineAction;
38import org.sleuthkit.datamodel.AbstractFile;
39import org.sleuthkit.datamodel.Directory;
40import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
41
46public 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<>();
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));
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}
static synchronized AddContentTagAction getInstance()
static synchronized DeleteFileContentTagAction getInstance()
DirectoryNode(AbstractFile dir, boolean directoryBrowseMode)
static synchronized ExportCSVAction getInstance()
static synchronized ExtractAction getInstance()
static ViewFileInTimelineAction createViewFileAction(AbstractFile file)

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.