Autopsy  4.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;
42 
47 // 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.
48 // 1. Do the types of the wrapper nodes really need to vary? If not, it would mean a single
49 // static List<Action> getActions(AbstrctFile file, boolean isArtifactSource)
50 // method could be implemented. If the different nodes are necessary, is it merely because of some misuse of the Visitor pattern somewhere?
51 // 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
52 // handle selections.
54 
55  public static final String VIEW_SOURCE_FILE_IN_DIR = NbBundle
56  .getMessage(DataModelActionsFactory.class, "DataModelActionsFactory.srcFileInDir.text");
57  public static final String VIEW_FILE_IN_DIR = NbBundle
58  .getMessage(DataModelActionsFactory.class, "DataModelActionsFactory.fileInDir.text");
59  public static final String VIEW_IN_NEW_WINDOW = NbBundle
60  .getMessage(DataModelActionsFactory.class, "DataModelActionsFactory.viewNewWin.text");
61  public static final String OPEN_IN_EXTERNAL_VIEWER = NbBundle
62  .getMessage(DataModelActionsFactory.class, "DataModelActionsFactory.openExtViewer.text");
63  public static final String SEARCH_FOR_FILES_SAME_MD5 = NbBundle
64  .getMessage(DataModelActionsFactory.class, "DataModelActionsFactory.srfFileSameMD5.text");
65 
66  public static List<Action> getActions(File file, boolean isArtifactSource) {
67  List<Action> actions = new ArrayList<>();
68  actions.add(new ViewContextAction((isArtifactSource ? VIEW_SOURCE_FILE_IN_DIR : VIEW_FILE_IN_DIR), file));
69  final FileNode fileNode = new FileNode(file);
70  actions.add(null); // creates a menu separator
71  actions.add(new NewWindowViewAction(VIEW_IN_NEW_WINDOW, fileNode));
72  actions.add(new ExternalViewerAction(OPEN_IN_EXTERNAL_VIEWER, fileNode));
73  actions.add(null); // creates a menu separator
74  actions.add(ExtractAction.getInstance());
75  actions.add(new HashSearchAction(SEARCH_FOR_FILES_SAME_MD5, fileNode));
76  actions.add(null); // creates a menu separator
77  actions.add(AddContentTagAction.getInstance());
78  if (isArtifactSource) {
80  }
81  actions.addAll(ContextMenuExtensionPoint.getActions());
82  return actions;
83  }
84 
85  public static List<Action> getActions(SlackFile slackFile, boolean isArtifactSource) {
86  List<Action> actions = new ArrayList<>();
87  actions.add(new ViewContextAction((isArtifactSource ? VIEW_SOURCE_FILE_IN_DIR : VIEW_FILE_IN_DIR), slackFile));
88  final SlackFileNode slackFileNode = new SlackFileNode(slackFile);
89  actions.add(null); // creates a menu separator
90  actions.add(new NewWindowViewAction(VIEW_IN_NEW_WINDOW, slackFileNode));
91  actions.add(null); // creates a menu separator
92  actions.add(ExtractAction.getInstance());
93  actions.add(null); // creates a menu separator
94  actions.add(AddContentTagAction.getInstance());
95  if (isArtifactSource) {
97  }
98  actions.addAll(ContextMenuExtensionPoint.getActions());
99  return actions;
100  }
101 
102  public static List<Action> getActions(LayoutFile file, boolean isArtifactSource) {
103  List<Action> actions = new ArrayList<>();
104  actions.add(new ViewContextAction((isArtifactSource ? VIEW_SOURCE_FILE_IN_DIR : VIEW_FILE_IN_DIR), file));
105  LayoutFileNode layoutFileNode = new LayoutFileNode(file);
106  actions.add(null); // creates a menu separator
107  actions.add(new NewWindowViewAction(VIEW_IN_NEW_WINDOW, layoutFileNode));
108  actions.add(new ExternalViewerAction(OPEN_IN_EXTERNAL_VIEWER, layoutFileNode));
109  actions.add(null); // creates a menu separator
110  actions.add(ExtractAction.getInstance());//
111  actions.add(null); // creates a menu separator
112  actions.add(AddContentTagAction.getInstance());
113  if (isArtifactSource) {
115  }
116  actions.addAll(ContextMenuExtensionPoint.getActions());
117  return actions;
118  }
119 
120  public static List<Action> getActions(Directory directory, boolean isArtifactSource) {
121  List<Action> actions = new ArrayList<>();
122  actions.add(new ViewContextAction((isArtifactSource ? VIEW_SOURCE_FILE_IN_DIR : VIEW_FILE_IN_DIR), directory));
123  DirectoryNode directoryNode = new DirectoryNode(directory);
124  actions.add(null); // creates a menu separator
125  actions.add(new NewWindowViewAction(VIEW_IN_NEW_WINDOW, directoryNode));
126  actions.add(new ExternalViewerAction(OPEN_IN_EXTERNAL_VIEWER, directoryNode));
127  actions.add(null); // creates a menu separator
128  actions.add(ExtractAction.getInstance());
129  actions.add(null); // creates a menu separator
130  actions.add(AddContentTagAction.getInstance());
131  if (isArtifactSource) {
133  }
134  actions.addAll(ContextMenuExtensionPoint.getActions());
135  return actions;
136  }
137 
138  public static List<Action> getActions(VirtualDirectory directory, boolean isArtifactSource) {
139  List<Action> actions = new ArrayList<>();
140  actions.add(new ViewContextAction((isArtifactSource ? VIEW_SOURCE_FILE_IN_DIR : VIEW_FILE_IN_DIR), directory));
141  VirtualDirectoryNode directoryNode = new VirtualDirectoryNode(directory);
142  actions.add(null); // creates a menu separator
143  actions.add(new NewWindowViewAction(VIEW_IN_NEW_WINDOW, directoryNode));
144  actions.add(new ExternalViewerAction(OPEN_IN_EXTERNAL_VIEWER, directoryNode));
145  actions.add(null); // creates a menu separator
146  actions.add(ExtractAction.getInstance());
147  actions.add(null); // creates a menu separator
148  actions.add(AddContentTagAction.getInstance());
149  if (isArtifactSource) {
151  }
152  actions.addAll(ContextMenuExtensionPoint.getActions());
153  return actions;
154  }
155 
156  public static List<Action> getActions(LocalFile file, boolean isArtifactSource) {
157  List<Action> actions = new ArrayList<>();
158  actions.add(new ViewContextAction((isArtifactSource ? VIEW_SOURCE_FILE_IN_DIR : VIEW_FILE_IN_DIR), file));
159  final LocalFileNode localFileNode = new LocalFileNode(file);
160  actions.add(null); // creates a menu separator
161  actions.add(new NewWindowViewAction(VIEW_IN_NEW_WINDOW, localFileNode));
162  actions.add(new ExternalViewerAction(OPEN_IN_EXTERNAL_VIEWER, localFileNode));
163  actions.add(null); // creates a menu separator
164  actions.add(ExtractAction.getInstance());
165  actions.add(null); // creates a menu separator
166  actions.add(AddContentTagAction.getInstance());
167  if (isArtifactSource) {
169  }
170  actions.addAll(ContextMenuExtensionPoint.getActions());
171  return actions;
172  }
173 
174  public static List<Action> getActions(DerivedFile file, boolean isArtifactSource) {
175  List<Action> actions = new ArrayList<>();
176  actions.add(new ViewContextAction((isArtifactSource ? VIEW_SOURCE_FILE_IN_DIR : VIEW_FILE_IN_DIR), file));
177  final LocalFileNode localFileNode = new LocalFileNode(file);
178  actions.add(null); // creates a menu separator
179  actions.add(new NewWindowViewAction(VIEW_IN_NEW_WINDOW, localFileNode));
180  actions.add(new ExternalViewerAction(OPEN_IN_EXTERNAL_VIEWER, localFileNode));
181  actions.add(null); // creates a menu separator
182  actions.add(ExtractAction.getInstance());
183  actions.add(null); // creates a menu separator
184  actions.add(AddContentTagAction.getInstance());
185  if (isArtifactSource) {
187  }
188  actions.addAll(ContextMenuExtensionPoint.getActions());
189  return actions;
190  }
191 
192  public static List<Action> getActions(Content content, boolean isArtifactSource) {
193  if (content instanceof File) {
194  return getActions((File) content, isArtifactSource);
195  } else if (content instanceof LayoutFile) {
196  return getActions((LayoutFile) content, isArtifactSource);
197  } else if (content instanceof Directory) {
198  return getActions((Directory) content, isArtifactSource);
199  } else if (content instanceof VirtualDirectory) {
200  return getActions((VirtualDirectory) content, isArtifactSource);
201  } else if (content instanceof LocalFile) {
202  return getActions((LocalFile) content, isArtifactSource);
203  } else if (content instanceof DerivedFile) {
204  return getActions((DerivedFile) content, isArtifactSource);
205  } else if (content instanceof SlackFile) {
206  return getActions((SlackFile) content, isArtifactSource);
207  } else {
208  return new ArrayList<>();
209  }
210  }
211 }
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(SlackFile slackFile, 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-2016 Basis Technology. Generated on: Mon Apr 24 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.