Autopsy  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 
63 
68  synchronized static void invalidateController() {
69  timeLineController = null;
70  }
71 
72  public OpenTimelineAction() {
73  toolbarButton.addActionListener(actionEvent -> performAction());
74  this.setEnabled(false);
75  }
76 
77  @Override
78  public boolean isEnabled() {
84  return Case.isCaseOpen() && FX_INITED;
85  }
86 
87  @Override
89  public void performAction() {
90  showTimeline();
91  }
92 
93  @NbBundle.Messages({
94  "OpenTimelineAction.settingsErrorMessage=Failed to initialize timeline settings.",
95  "OpenTimeLineAction.msgdlg.text=Could not create timeline, there are no data sources."})
96  synchronized private void showTimeline(AbstractFile file, BlackboardArtifact artifact) {
97  try {
98  Case currentCase = Case.getCurrentCase();
99  if (currentCase.hasData() == false) {
100  MessageNotifyUtil.Message.info(Bundle.OpenTimeLineAction_msgdlg_text());
101  LOGGER.log(Level.INFO, "Could not create timeline, there are no data sources.");// NON-NLS
102  return;
103  }
104  try {
105  if (timeLineController == null) {
106  timeLineController = new TimeLineController(currentCase);
107  } else if (timeLineController.getAutopsyCase() != currentCase) {
108  timeLineController.shutDownTimeLine();
109  timeLineController = new TimeLineController(currentCase);
110  }
111 
112  timeLineController.showTimeLine(file, artifact);
113 
114  } catch (IOException iOException) {
115  MessageNotifyUtil.Message.error(Bundle.OpenTimelineAction_settingsErrorMessage());
116  LOGGER.log(Level.SEVERE, "Failed to initialize per case timeline settings.", iOException);
117  }
118  } catch (IllegalStateException e) {
119  //there is no case... Do nothing.
120  }
121  }
122 
127  public void showTimeline() {
128  showTimeline(null, null);
129  }
130 
139  public void showFileInTimeline(AbstractFile file) {
140  showTimeline(file, null);
141  }
142 
150  public void showArtifactInTimeline(BlackboardArtifact artifact) {
151  showTimeline(null, artifact);
152  }
153 
154  @Override
155  @NbBundle.Messages("OpenTimelineAction.displayName=Timeline")
156  public String getName() {
157  return Bundle.OpenTimelineAction_displayName();
158  }
159 
160  @Override
161  public HelpCtx getHelpCtx() {
162  return HelpCtx.DEFAULT_HELP;
163  }
164 
165  @Override
166  public boolean asynchronous() {
167  return false; // run on edt
168  }
169 
175  @Override
176  public void setEnabled(boolean value) {
177  super.setEnabled(value);
178  toolbarButton.setEnabled(value);
179  }
180 
186  @Override
187  public Component getToolbarPresenter() {
188  ImageIcon icon = new ImageIcon(getClass().getResource("images/btn_icon_timeline_colorized_26.png")); //NON-NLS
189  toolbarButton.setIcon(icon);
190  toolbarButton.setText(this.getName());
191  return toolbarButton;
192  }
193 }
synchronized void showTimeline(AbstractFile file, BlackboardArtifact artifact)
synchronized static Logger getLogger(String name)
Definition: Logger.java:161

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