Autopsy  4.10.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
LayoutFileNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2019 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;
36 import org.sleuthkit.datamodel.AbstractFile;
37 import org.sleuthkit.datamodel.LayoutFile;
38 import org.sleuthkit.datamodel.TskData;
39 
43 public class LayoutFileNode extends AbstractAbstractFileNode<LayoutFile> {
44 
45  @Deprecated
46  public static enum LayoutContentPropertyType {
47 
48  PARTS {
49  @Override
50  public String toString() {
51  return NbBundle.getMessage(this.getClass(), "LayoutFileNode.propertyType.parts");
52  }
53  }
54  }
55 
56  public static String nameForLayoutFile(LayoutFile lf) {
57  return lf.getName();
58  }
59 
60  public LayoutFileNode(LayoutFile lf) {
61  super(lf);
62 
63  this.setDisplayName(nameForLayoutFile(lf));
64 
65  if (lf.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.CARVED)) {
66  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/carved-file-icon-16.png"); //NON-NLS
67  } else if (lf.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.LAYOUT_FILE)) {
68  if (lf.isDirNameFlagSet(TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC)) {
69  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/file-icon-deleted.png"); //NON-NLS
70  } else {
71  this.setIconBaseWithExtension(FileNode.getIconForFileType(lf));
72  }
73  } else {
74  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/file-icon-deleted.png"); //NON-NLS
75  }
76  }
77 
78  public <T> T accept(ContentNodeVisitor<T> visitor) {
79  return visitor.visit(this);
80  }
81 
82  @Override
83  public boolean isLeafTypeNode() {
84  return false;
85  }
86 
87  @Override
88  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
89  return visitor.visit(this);
90  }
91 
92  @Override
93  public Action[] getActions(boolean context) {
94  List<Action> actionsList = new ArrayList<>();
95  actionsList.addAll(Arrays.asList(super.getActions(true)));
96  actionsList.add(new NewWindowViewAction(
97  NbBundle.getMessage(this.getClass(), "LayoutFileNode.getActions.viewInNewWin.text"), this));
98  final Collection<AbstractFile> selectedFilesList
99  = new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
100  if (selectedFilesList.size() == 1) {
101  actionsList.add(new ExternalViewerAction(
102  NbBundle.getMessage(this.getClass(), "LayoutFileNode.getActions.openInExtViewer.text"), this));
103  } else {
104  actionsList.add(ExternalViewerShortcutAction.getInstance());
105  }
106  actionsList.add(null); // creates a menu separator
107  actionsList.add(ExtractAction.getInstance());
108  actionsList.add(null); // creates a menu separator
109  actionsList.add(AddContentTagAction.getInstance());
110 
111  if (selectedFilesList.size() == 1) {
112  actionsList.add(DeleteFileContentTagAction.getInstance());
113  }
114 
115  actionsList.addAll(ContextMenuExtensionPoint.getActions());
116  return actionsList.toArray(new Action[actionsList.size()]);
117  }
118 
119  @Override
120  public String getItemType() {
121  return getClass().getName();
122  }
123 
124 }
static synchronized ExtractAction getInstance()
static synchronized DeleteFileContentTagAction getInstance()
static String nameForLayoutFile(LayoutFile lf)
static synchronized AddContentTagAction getInstance()

Copyright © 2012-2018 Basis Technology. Generated on: Fri Mar 22 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.