Autopsy  4.7.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;
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  public static final String DOTDOTDIR = NbBundle.getMessage(DirectoryNode.class, "DirectoryNode.parFolder.text");
47  public static final String DOTDIR = NbBundle.getMessage(DirectoryNode.class, "DirectoryNode.curFolder.text");
48 
49  public DirectoryNode(Directory dir) {
50  this(dir, true);
51 
52  setIcon(dir);
53  }
54 
55  public DirectoryNode(AbstractFile dir, boolean directoryBrowseMode) {
56  super(dir, directoryBrowseMode);
57 
58  setIcon(dir);
59  }
60 
61  private void setIcon(AbstractFile dir) {
62  // set name, display name, and icon
63  if (dir.isDirNameFlagSet(TSK_FS_NAME_FLAG_ENUM.UNALLOC)) {
64  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/folder-icon-deleted.png"); //NON-NLS
65  } else {
66  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/Folder-icon.png"); //NON-NLS
67  }
68  }
69 
77  @Override
78  public Action[] getActions(boolean popup) {
79  List<Action> actionsList = new ArrayList<>();
80  for (Action a : super.getActions(true)) {
81  actionsList.add(a);
82  }
83  if (!getDirectoryBrowseMode()) {
84  actionsList.add(new ViewContextAction(
85  NbBundle.getMessage(this.getClass(), "DirectoryNode.getActions.viewFileInDir.text"), this));
86  actionsList.add(null); // creates a menu separator
87  }
88  actionsList.add(new NewWindowViewAction(NbBundle.getMessage(this.getClass(), "DirectoryNode.viewInNewWin.text"), this));
89  actionsList.add(ViewFileInTimelineAction.createViewFileAction(content));
90  actionsList.add(null); // creates a menu separator
91  actionsList.add(ExtractAction.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  return actionsList.toArray(new Action[actionsList.size()]);
104  }
105 
106  @Override
107  public <T> T accept(ContentNodeVisitor<T> visitor) {
108  return visitor.visit(this);
109  }
110 
111  @Override
112  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
113  return visitor.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()
static ViewFileInTimelineAction createViewFileAction(AbstractFile file)
static synchronized AddContentTagAction getInstance()

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