Autopsy  4.4.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 2011-2016 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.io.IOException;
23 import java.util.logging.Level;
24 import javax.swing.ImageIcon;
25 import javax.swing.JButton;
26 import org.openide.awt.ActionID;
27 import org.openide.awt.ActionReference;
28 import org.openide.awt.ActionReferences;
29 import org.openide.awt.ActionRegistration;
30 import org.openide.util.HelpCtx;
31 import org.openide.util.NbBundle;
32 import org.openide.util.actions.CallableSystemAction;
33 import org.openide.util.actions.Presenter;
39 import org.sleuthkit.datamodel.AbstractFile;
40 import org.sleuthkit.datamodel.BlackboardArtifact;
41 
46 @ActionID(category = "Tools", id = "org.sleuthkit.autopsy.timeline.Timeline")
47 @ActionRegistration(displayName = "#CTL_MakeTimeline", lazy = false)
48 @ActionReferences(value = {
49  @ActionReference(path = "Menu/Tools", position = 102),
50  @ActionReference(path = "Toolbars/Case", position = 102)})
51 public final class OpenTimelineAction extends CallableSystemAction implements Presenter.Toolbar {
52 
53  private static final long serialVersionUID = 1L;
54  private static final Logger LOGGER = Logger.getLogger(OpenTimelineAction.class.getName());
55 
56  private static final boolean FX_INITED = Installer.isJavaFxInited();
57 
58  private static TimeLineController timeLineController = null;
59 
60  private final JButton toolbarButton = new JButton(getName(),
61  new ImageIcon(getClass().getResource("images/btn_icon_timeline_colorized_26.png"))); //NON-NLS
62 
67  synchronized static void invalidateController() {
68  timeLineController = null;
69  }
70 
71  public OpenTimelineAction() {
72  toolbarButton.addActionListener(actionEvent -> performAction());
73  this.setEnabled(false);
74  }
75 
76  @Override
77  public boolean isEnabled() {
83  return Case.isCaseOpen() && FX_INITED;
84  }
85 
86  @Override
88  public void performAction() {
89  showTimeline();
90  }
91 
92  @NbBundle.Messages({
93  "OpenTimelineAction.settingsErrorMessage=Failed to initialize timeline settings.",
94  "OpenTimeLineAction.msgdlg.text=Could not create timeline, there are no data sources."})
95  synchronized private void showTimeline(AbstractFile file, BlackboardArtifact artifact) {
96  try {
97  Case currentCase = Case.getCurrentCase();
98  if (currentCase.hasData() == false) {
99  MessageNotifyUtil.Message.info(Bundle.OpenTimeLineAction_msgdlg_text());
100  LOGGER.log(Level.INFO, "Could not create timeline, there are no data sources.");// NON-NLS
101  return;
102  }
103  try {
104  if (timeLineController == null) {
105  timeLineController = new TimeLineController(currentCase);
106  } else if (timeLineController.getAutopsyCase() != currentCase) {
107  timeLineController.shutDownTimeLine();
108  timeLineController = new TimeLineController(currentCase);
109  }
110 
111  timeLineController.showTimeLine(file, artifact);
112 
113  } catch (IOException iOException) {
114  MessageNotifyUtil.Message.error(Bundle.OpenTimelineAction_settingsErrorMessage());
115  LOGGER.log(Level.SEVERE, "Failed to initialize per case timeline settings.", iOException);
116  }
117  } catch (IllegalStateException e) {
118  //there is no case... Do nothing.
119  }
120  }
121 
126  public void showTimeline() {
127  showTimeline(null, null);
128  }
129 
138  public void showFileInTimeline(AbstractFile file) {
139  showTimeline(file, null);
140  }
141 
149  public void showArtifactInTimeline(BlackboardArtifact artifact) {
150  showTimeline(null, artifact);
151  }
152 
153  @Override
154  @NbBundle.Messages("OpenTimelineAction.displayName=Timeline")
155  public String getName() {
156  return Bundle.OpenTimelineAction_displayName();
157  }
158 
159  @Override
160  public HelpCtx getHelpCtx() {
161  return HelpCtx.DEFAULT_HELP;
162  }
163 
164  @Override
165  public boolean asynchronous() {
166  return false; // run on edt
167  }
168 
174  @Override
175  public void setEnabled(boolean value) {
176  super.setEnabled(value);
177  toolbarButton.setEnabled(value);
178  }
179 
185  @Override
186  public Component getToolbarPresenter() {
187  ImageIcon icon = new ImageIcon(getClass().getResource("images/btn_icon_timeline_colorized_26.png")); //NON-NLS
188  toolbarButton.setIcon(icon);
189  toolbarButton.setText(this.getName());
190  return toolbarButton;
191  }
192 }
synchronized void showTimeline(AbstractFile file, BlackboardArtifact artifact)
synchronized static Logger getLogger(String name)
Definition: Logger.java:161

Copyright © 2012-2016 Basis Technology. Generated on: Fri Sep 29 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.