Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
OpenTimelineAction.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2014-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 */
19package org.sleuthkit.autopsy.timeline;
20
21import java.awt.Component;
22import java.util.logging.Level;
23import javafx.application.Platform;
24import javax.swing.ImageIcon;
25import javax.swing.JButton;
26import javax.swing.JMenuItem;
27import org.joda.time.Interval;
28import org.openide.awt.ActionID;
29import org.openide.awt.ActionReference;
30import org.openide.awt.ActionReferences;
31import org.openide.awt.ActionRegistration;
32import org.openide.util.HelpCtx;
33import org.openide.util.NbBundle;
34import org.openide.util.actions.CallableSystemAction;
35import org.sleuthkit.autopsy.casemodule.Case;
36import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
37import org.sleuthkit.autopsy.core.Installer;
38import org.sleuthkit.autopsy.coreutils.Logger;
39import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
40import org.sleuthkit.autopsy.coreutils.ModuleSettings;
41import org.sleuthkit.autopsy.coreutils.ThreadConfined;
42import org.sleuthkit.datamodel.AbstractFile;
43import org.sleuthkit.datamodel.BlackboardArtifact;
44import org.sleuthkit.datamodel.TskCoreException;
45
50@ActionID(category = "Tools", id = "org.sleuthkit.autopsy.timeline.Timeline")
51@ActionRegistration(displayName = "#CTL_MakeTimeline", lazy = false)
52@ActionReferences(value = {
53 @ActionReference(path = "Menu/Tools", position = 104),
54 @ActionReference(path = "Toolbars/Case", position = 104)})
55public final class OpenTimelineAction extends CallableSystemAction {
56
57 private static final long serialVersionUID = 1L;
58 private static final Logger logger = Logger.getLogger(OpenTimelineAction.class.getName());
59 private static final int FILE_LIMIT = 6_000_000;
60
61 private final JMenuItem menuItem;
62 private final JButton toolbarButton = new JButton(getName(),
63 new ImageIcon(getClass().getResource("images/btn_icon_timeline_colorized_26.png"))); //NON-NLS
64
66 toolbarButton.addActionListener(actionEvent -> performAction());
67 menuItem = super.getMenuPresenter();
68 this.setEnabled(false);
69 }
70
71 @Override
72 public boolean isEnabled() {
79 return super.isEnabled() && Case.isCaseOpen() && Installer.isJavaFxInited();
80 }
81
82 @Override
84 public void performAction() {
85 if (tooManyFiles()) {
86 Platform.runLater(PromptDialogManager::showTooManyFiles);
87 setEnabled(false);
88 } else if ("false".equals(ModuleSettings.getConfigSetting("timeline", "enable_timeline"))) {
89 Platform.runLater(PromptDialogManager::showTimeLineDisabledMessage);
90 setEnabled(false);
91 } else {
92 try {
93 showTimeline();
94 } catch (TskCoreException ex) {
95 MessageNotifyUtil.Message.error(Bundle.OpenTimelineAction_settingsErrorMessage());
96 logger.log(Level.SEVERE, "Error showingtimeline.", ex);
97 }
98 }
99 }
100
101 @NbBundle.Messages({
102 "OpenTimelineAction.settingsErrorMessage=Failed to initialize timeline settings.",
103 "OpenTimeLineAction.msgdlg.text=Could not create timeline, there are no data sources."})
104 synchronized private void showTimeline(AbstractFile file, BlackboardArtifact artifact, Interval timeSpan) throws TskCoreException {
105 try {
106 Case currentCase = Case.getCurrentCaseThrows();
107 if (currentCase.hasDataSource() == false) {
108 MessageNotifyUtil.Message.info(Bundle.OpenTimeLineAction_msgdlg_text());
109 logger.log(Level.INFO, "Could not create timeline, there are no data sources.");// NON-NLS
110 return;
111 }
113 // if file or artifact not specified, specify the time range as either
114 // a) full range if timeSpan is null or b) the timeSpan
115 if (file == null && artifact == null) {
116 if (timeSpan == null) {
117 controller.showFullRange();
118 } else {
119 controller.pushTimeRange(timeSpan);
120 }
121 }
122 controller.showTimeLine(file, artifact);
123 } catch (NoCurrentCaseException e) {
124 //there is no case... Do nothing.
125 }
126 }
127
132 public void showTimeline() throws TskCoreException {
133 showTimeline(null, null, null);
134 }
135
143 public void showTimeline(Interval timeSpan) throws TskCoreException {
144 showTimeline(null, null, timeSpan);
145 }
146
155 public void showFileInTimeline(AbstractFile file) throws TskCoreException {
156 showTimeline(file, null, null);
157 }
158
166 public void showArtifactInTimeline(BlackboardArtifact artifact) throws TskCoreException {
167 showTimeline(null, artifact, null);
168 }
169
170 @Override
171 @NbBundle.Messages("OpenTimelineAction.displayName=Timeline")
172 public String getName() {
173 return Bundle.OpenTimelineAction_displayName();
174 }
175
176 @Override
177 public HelpCtx getHelpCtx() {
178 return HelpCtx.DEFAULT_HELP;
179 }
180
181 @Override
182 public boolean asynchronous() {
183 return false; // run on edt
184 }
185
191 @Override
192 public void setEnabled(boolean enable) {
193 super.setEnabled(enable);
194 menuItem.setEnabled(enable);
195 toolbarButton.setEnabled(enable);
196 }
197
203 @Override
204 public Component getToolbarPresenter() {
205 return toolbarButton;
206 }
207
208 @Override
209 public JMenuItem getMenuPresenter() {
210 return menuItem;
211 }
212
213 private boolean tooManyFiles() {
214 try {
215 return FILE_LIMIT < Case.getCurrentCaseThrows().getSleuthkitCase().countFilesWhere("1 = 1");
216 } catch (NoCurrentCaseException ex) {
217 logger.log(Level.SEVERE, "Can not open timeline with no case open.", ex);
218 } catch (TskCoreException ex) {
219 logger.log(Level.SEVERE, "Error counting files in the DB.", ex);
220 }
221 //if there is any doubt (no case, tskcore error, etc) just disable .
222 return false;
223 }
224}
synchronized static Logger getLogger(String name)
Definition Logger.java:124
static synchronized String getConfigSetting(String moduleName, String settingName)
synchronized void showTimeline(AbstractFile file, BlackboardArtifact artifact, Interval timeSpan)
void showArtifactInTimeline(BlackboardArtifact artifact)
synchronized boolean pushTimeRange(Interval timeRange)

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.