Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataModelActionsFactory.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013 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.List;
23 import javax.swing.Action;
24 
25 import org.openide.util.NbBundle;
41 
45 // TODO: All of the methods below that deal with classes derived from AbstractFile are the same except for the creation of wrapper nodes to pass to actions.
46 // 1. Do the types of the wrapper nodes really need to vary? If not, it would mean a single
47 // static List<Action> getActions(AbstrctFile file, boolean isArtifactSource)
48 // method could be implemented. If the different nodes are necessary, is it merely because of some misuse of the Visitor pattern somewhere?
49 // 2. All of this would be much improved by not constructing nodes with actions, but this might be necessary with pushing of nodes rather than use of lookups to
50 // handle selections.
52  public static final String VIEW_SOURCE_FILE_IN_DIR = NbBundle
53  .getMessage(DataModelActionsFactory.class, "DataModelActionsFactory.srcFileInDir.text");
54  public static final String VIEW_FILE_IN_DIR = NbBundle
55  .getMessage(DataModelActionsFactory.class, "DataModelActionsFactory.fileInDir.text");
56  public static final String VIEW_IN_NEW_WINDOW = NbBundle
57  .getMessage(DataModelActionsFactory.class, "DataModelActionsFactory.viewNewWin.text");
58  public static final String OPEN_IN_EXTERNAL_VIEWER = NbBundle
59  .getMessage(DataModelActionsFactory.class, "DataModelActionsFactory.openExtViewer.text");
60  public static final String SEARCH_FOR_FILES_SAME_MD5 = NbBundle
61  .getMessage(DataModelActionsFactory.class, "DataModelActionsFactory.srfFileSameMD5.text");
62 
63  public static List<Action> getActions(File file, boolean isArtifactSource) {
64  List<Action> actions = new ArrayList<>();
65  actions.add(new ViewContextAction((isArtifactSource ? VIEW_SOURCE_FILE_IN_DIR : VIEW_FILE_IN_DIR), file));
66  final FileNode fileNode = new FileNode(file);
67  actions.add(null); // creates a menu separator
68  actions.add(new NewWindowViewAction(VIEW_IN_NEW_WINDOW, fileNode));
69  actions.add(new ExternalViewerAction(OPEN_IN_EXTERNAL_VIEWER, fileNode));
70  actions.add(null); // creates a menu separator
71  actions.add(ExtractAction.getInstance());
72  actions.add(new HashSearchAction(SEARCH_FOR_FILES_SAME_MD5, fileNode));
73  actions.add(null); // creates a menu separator
74  actions.add(AddContentTagAction.getInstance());
75  if (isArtifactSource) {
77  }
78  actions.addAll(ContextMenuExtensionPoint.getActions());
79  return actions;
80  }
81 
82  public static List<Action> getActions(LayoutFile file, boolean isArtifactSource) {
83  List<Action> actions = new ArrayList<>();
84  actions.add(new ViewContextAction((isArtifactSource ? VIEW_SOURCE_FILE_IN_DIR : VIEW_FILE_IN_DIR), file));
85  LayoutFileNode layoutFileNode = new LayoutFileNode(file);
86  actions.add(null); // creates a menu separator
87  actions.add(new NewWindowViewAction(VIEW_IN_NEW_WINDOW, layoutFileNode));
88  actions.add(new ExternalViewerAction(OPEN_IN_EXTERNAL_VIEWER, layoutFileNode));
89  actions.add(null); // creates a menu separator
90  actions.add(ExtractAction.getInstance());//
91  actions.add(null); // creates a menu separator
92  actions.add(AddContentTagAction.getInstance());
93  if (isArtifactSource) {
95  }
96  actions.addAll(ContextMenuExtensionPoint.getActions());
97  return actions;
98  }
99 
100  public static List<Action> getActions(Directory directory, boolean isArtifactSource) {
101  List<Action> actions = new ArrayList<>();
102  actions.add(new ViewContextAction((isArtifactSource ? VIEW_SOURCE_FILE_IN_DIR : VIEW_FILE_IN_DIR), directory));
103  DirectoryNode directoryNode = new DirectoryNode(directory);
104  actions.add(null); // creates a menu separator
105  actions.add(new NewWindowViewAction(VIEW_IN_NEW_WINDOW, directoryNode));
106  actions.add(new ExternalViewerAction(OPEN_IN_EXTERNAL_VIEWER, directoryNode));
107  actions.add(null); // creates a menu separator
108  actions.add(ExtractAction.getInstance());
109  actions.add(null); // creates a menu separator
110  actions.add(AddContentTagAction.getInstance());
111  if (isArtifactSource) {
113  }
114  actions.addAll(ContextMenuExtensionPoint.getActions());
115  return actions;
116  }
117 
118  public static List<Action> getActions(VirtualDirectory directory, boolean isArtifactSource) {
119  List<Action> actions = new ArrayList<>();
120  actions.add(new ViewContextAction((isArtifactSource ? VIEW_SOURCE_FILE_IN_DIR : VIEW_FILE_IN_DIR), directory));
121  VirtualDirectoryNode directoryNode = new VirtualDirectoryNode(directory);
122  actions.add(null); // creates a menu separator
123  actions.add(new NewWindowViewAction(VIEW_IN_NEW_WINDOW, directoryNode));
124  actions.add(new ExternalViewerAction(OPEN_IN_EXTERNAL_VIEWER, directoryNode));
125  actions.add(null); // creates a menu separator
126  actions.add(ExtractAction.getInstance());
127  actions.add(null); // creates a menu separator
128  actions.add(AddContentTagAction.getInstance());
129  if (isArtifactSource) {
131  }
132  actions.addAll(ContextMenuExtensionPoint.getActions());
133  return actions;
134  }
135 
136  public static List<Action> getActions(LocalFile file, boolean isArtifactSource) {
137  List<Action> actions = new ArrayList<>();
138  actions.add(new ViewContextAction((isArtifactSource ? VIEW_SOURCE_FILE_IN_DIR : VIEW_FILE_IN_DIR), file));
139  final LocalFileNode localFileNode = new LocalFileNode(file);
140  actions.add(null); // creates a menu separator
141  actions.add(new NewWindowViewAction(VIEW_IN_NEW_WINDOW, localFileNode));
142  actions.add(new ExternalViewerAction(OPEN_IN_EXTERNAL_VIEWER, localFileNode));
143  actions.add(null); // creates a menu separator
144  actions.add(ExtractAction.getInstance());
145  actions.add(null); // creates a menu separator
146  actions.add(AddContentTagAction.getInstance());
147  if (isArtifactSource) {
149  }
150  actions.addAll(ContextMenuExtensionPoint.getActions());
151  return actions;
152  }
153 
154  public static List<Action> getActions(DerivedFile file, boolean isArtifactSource) {
155  List<Action> actions = new ArrayList<>();
156  actions.add(new ViewContextAction((isArtifactSource ? VIEW_SOURCE_FILE_IN_DIR : VIEW_FILE_IN_DIR), file));
157  final LocalFileNode localFileNode = new LocalFileNode(file);
158  actions.add(null); // creates a menu separator
159  actions.add(new NewWindowViewAction(VIEW_IN_NEW_WINDOW, localFileNode));
160  actions.add(new ExternalViewerAction(OPEN_IN_EXTERNAL_VIEWER, localFileNode));
161  actions.add(null); // creates a menu separator
162  actions.add(ExtractAction.getInstance());
163  actions.add(null); // creates a menu separator
164  actions.add(AddContentTagAction.getInstance());
165  if (isArtifactSource) {
167  }
168  actions.addAll(ContextMenuExtensionPoint.getActions());
169  return actions;
170  }
171 
172  public static List<Action> getActions(Content content, boolean isArtifactSource) {
173  if (content instanceof File) {
174  return getActions((File)content, isArtifactSource);
175  }
176  else if (content instanceof LayoutFile) {
177  return getActions((LayoutFile)content, isArtifactSource);
178  }
179  else if (content instanceof Directory) {
180  return getActions((Directory)content, isArtifactSource);
181  }
182  else if (content instanceof VirtualDirectory) {
183  return getActions((VirtualDirectory)content, isArtifactSource);
184  }
185  else if (content instanceof LocalFile) {
186  return getActions((LocalFile)content, isArtifactSource);
187  }
188  else if (content instanceof DerivedFile) {
189  return getActions((DerivedFile)content, isArtifactSource);
190  }
191  else {
192  return new ArrayList<>();
193  }
194  }
195 }
static List< Action > getActions(LayoutFile file, boolean isArtifactSource)
static List< Action > getActions(File file, boolean isArtifactSource)
static synchronized AddBlackboardArtifactTagAction getInstance()
static List< Action > getActions(Content content, boolean isArtifactSource)
static synchronized ExtractAction getInstance()
static List< Action > getActions(LocalFile file, boolean isArtifactSource)
static List< Action > getActions(DerivedFile file, boolean isArtifactSource)
static List< Action > getActions(Directory directory, boolean isArtifactSource)
static synchronized AddContentTagAction getInstance()
static List< Action > getActions(VirtualDirectory directory, boolean isArtifactSource)

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.