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

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