Autopsy  4.16.0
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  */
19 package org.sleuthkit.autopsy.timeline;
20 
21 import java.awt.Component;
22 import java.util.logging.Level;
23 import javafx.application.Platform;
24 import javax.swing.ImageIcon;
25 import javax.swing.JButton;
26 import javax.swing.JMenuItem;
27 import org.openide.awt.ActionID;
28 import org.openide.awt.ActionReference;
29 import org.openide.awt.ActionReferences;
30 import org.openide.awt.ActionRegistration;
31 import org.openide.util.HelpCtx;
32 import org.openide.util.NbBundle;
33 import org.openide.util.actions.CallableSystemAction;
41 import org.sleuthkit.datamodel.AbstractFile;
42 import org.sleuthkit.datamodel.BlackboardArtifact;
43 import org.sleuthkit.datamodel.TskCoreException;
44 
51 @ActionID(category = "Tools", id = "org.sleuthkit.autopsy.timeline.Timeline")
52 @ActionRegistration(displayName = "#CTL_MakeTimeline", lazy = false)
53 @ActionReferences(value = {
54  @ActionReference(path = "Menu/Tools", position = 104)
55  ,
56  @ActionReference(path = "Toolbars/Case", position = 104)})
57 public final class OpenTimelineAction extends CallableSystemAction {
58 
59  private static final long serialVersionUID = 1L;
60  private static final Logger logger = Logger.getLogger(OpenTimelineAction.class.getName());
61  private static final int FILE_LIMIT = 6_000_000;
62 
63  private final JMenuItem menuItem;
64  private final JButton toolbarButton = new JButton(getName(),
65  new ImageIcon(getClass().getResource("images/btn_icon_timeline_colorized_26.png"))); //NON-NLS
66 
67 
68  public OpenTimelineAction() {
69  toolbarButton.addActionListener(actionEvent -> performAction());
70  menuItem = super.getMenuPresenter();
71  this.setEnabled(false);
72  }
73 
74  @Override
75  public boolean isEnabled() {
81  return super.isEnabled() && Case.isCaseOpen() && Installer.isJavaFxInited();
82  }
83 
84  @Override
86  public void performAction() {
87  if (tooManyFiles()) {
88  Platform.runLater(PromptDialogManager::showTooManyFiles);
89  setEnabled(false);
90  } else if ("false".equals(ModuleSettings.getConfigSetting("timeline", "enable_timeline"))) {
91  Platform.runLater(PromptDialogManager::showTimeLineDisabledMessage);
92  setEnabled(false);
93  } else {
94  try {
95  showTimeline();
96  } catch (TskCoreException ex) {
97  MessageNotifyUtil.Message.error(Bundle.OpenTimelineAction_settingsErrorMessage());
98  logger.log(Level.SEVERE, "Error showingtimeline.", ex);
99  }
100  }
101  }
102 
103  @NbBundle.Messages({
104  "OpenTimelineAction.settingsErrorMessage=Failed to initialize timeline settings.",
105  "OpenTimeLineAction.msgdlg.text=Could not create timeline, there are no data sources."})
106  synchronized private void showTimeline(AbstractFile file, BlackboardArtifact artifact) throws TskCoreException {
107  try {
108  Case currentCase = Case.getCurrentCaseThrows();
109  if (currentCase.hasData() == false) {
110  MessageNotifyUtil.Message.info(Bundle.OpenTimeLineAction_msgdlg_text());
111  logger.log(Level.INFO, "Could not create timeline, there are no data sources.");// NON-NLS
112  return;
113  }
115  controller.showTimeLine(file, artifact);
116  } catch (NoCurrentCaseException e) {
117  //there is no case... Do nothing.
118  }
119  }
120 
125  public void showTimeline() throws TskCoreException {
126  showTimeline(null, null);
127  }
128 
137  public void showFileInTimeline(AbstractFile file) throws TskCoreException {
138  showTimeline(file, null);
139  }
140 
148  public void showArtifactInTimeline(BlackboardArtifact artifact) throws TskCoreException {
149  showTimeline(null, artifact);
150  }
151 
152  @Override
153  @NbBundle.Messages("OpenTimelineAction.displayName=Timeline")
154  public String getName() {
155  return Bundle.OpenTimelineAction_displayName();
156  }
157 
158  @Override
159  public HelpCtx getHelpCtx() {
160  return HelpCtx.DEFAULT_HELP;
161  }
162 
163  @Override
164  public boolean asynchronous() {
165  return false; // run on edt
166  }
167 
173  @Override
174  public void setEnabled(boolean enable) {
175  super.setEnabled(enable);
176  menuItem.setEnabled(enable);
177  toolbarButton.setEnabled(enable);
178  }
179 
185  @Override
186  public Component getToolbarPresenter() {
187  return toolbarButton;
188  }
189 
190  @Override
191  public JMenuItem getMenuPresenter() {
192  return menuItem;
193  }
194 
195  private boolean tooManyFiles() {
196  try {
197  return FILE_LIMIT < Case.getCurrentCaseThrows().getSleuthkitCase().countFilesWhere("1 = 1");
198  } catch (NoCurrentCaseException ex) {
199  logger.log(Level.SEVERE, "Can not open timeline with no case open.", ex);
200  } catch (TskCoreException ex) {
201  logger.log(Level.SEVERE, "Error counting files in the DB.", ex);
202  }
203  //if there is any doubt (no case, tskcore error, etc) just disable .
204  return false;
205  }
206 }
static synchronized String getConfigSetting(String moduleName, String settingName)
synchronized void showTimeline(AbstractFile file, BlackboardArtifact artifact)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2020 Basis Technology. Generated on: Tue Sep 22 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.