Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
EventNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014 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.explorernodes;
20 
21 import java.lang.reflect.InvocationTargetException;
22 import java.util.ArrayList;
23 import java.util.Arrays;
24 import java.util.List;
25 import java.util.logging.Level;
26 import javafx.beans.Observable;
27 import javax.swing.Action;
28 import org.joda.time.DateTime;
29 import org.joda.time.DateTimeZone;
30 import org.openide.nodes.Children;
31 import org.openide.nodes.PropertySupport;
32 import org.openide.nodes.Sheet;
33 import org.openide.util.lookup.Lookups;
41 import org.sleuthkit.datamodel.AbstractFile;
42 import org.sleuthkit.datamodel.BlackboardArtifact;
43 import org.sleuthkit.datamodel.Content;
44 
48 class EventNode extends DisplayableItemNode {
49 
50  private static final Logger LOGGER = Logger.getLogger(EventNode.class.getName());
51 
52  private final TimeLineEvent e;
53 
54  EventNode(TimeLineEvent eventById, AbstractFile file, BlackboardArtifact artifact) {
55  super(Children.LEAF, Lookups.fixed(eventById, file, artifact));
56  this.e = eventById;
57  this.setIconBaseWithExtension("org/sleuthkit/autopsy/timeline/images/" + e.getType().getIconBase()); // NON-NLS
58  }
59 
60  EventNode(TimeLineEvent eventById, AbstractFile file) {
61  super(Children.LEAF, Lookups.fixed(eventById, file));
62  this.e = eventById;
63  this.setIconBaseWithExtension("org/sleuthkit/autopsy/timeline/images/" + e.getType().getIconBase()); // NON-NLS
64  }
65 
66  @Override
67  protected Sheet createSheet() {
68  Sheet s = super.createSheet();
69  Sheet.Set properties = s.get(Sheet.PROPERTIES);
70  if (properties == null) {
71  properties = Sheet.createPropertiesSet();
72  s.put(properties);
73  }
74 
75  final TimeProperty timePropery = new TimeProperty("time", "Date/Time", "time ", getDateTimeString()); // NON-NLS
76 
77  TimeLineController.getTimeZone().addListener((Observable observable) -> {
78  try {
79  timePropery.setValue(getDateTimeString());
80  } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
81  LOGGER.log(Level.SEVERE, "unexpected error setting date/time property on EventNode explorer node", ex); //NON-NLS
82  }
83  });
84 
85  properties.put(new NodeProperty<>("icon", "Icon", "icon", true)); // NON-NLS //gets overridden with icon
86  properties.put(timePropery);
87  properties.put(new NodeProperty<>("description", "Description", "description", e.getFullDescription())); // NON-NLS
88  properties.put(new NodeProperty<>("eventBaseType", "Base Type", "base type", e.getType().getSuperType().getDisplayName())); // NON-NLS
89  properties.put(new NodeProperty<>("eventSubType", "Sub Type", "sub type", e.getType().getDisplayName())); // NON-NLS
90  properties.put(new NodeProperty<>("Known", "Known", "known", e.getKnown().toString())); // NON-NLS
91 
92  return s;
93  }
94 
95  private String getDateTimeString() {
96  return new DateTime(e.getTime() * 1000, DateTimeZone.UTC).toString(TimeLineController.getZonedFormatter());
97  }
98 
99  @Override
100  public Action[] getActions(boolean context) {
101  Action[] superActions = super.getActions(context);
102  List<Action> actionsList = new ArrayList<>();
103  actionsList.addAll(Arrays.asList(superActions));
104 
105  final Content content = getLookup().lookup(Content.class);
106  final BlackboardArtifact artifact = getLookup().lookup(BlackboardArtifact.class);
107 
108  final List<Action> factoryActions = DataModelActionsFactory.getActions(content, artifact != null);
109 
110  actionsList.addAll(factoryActions);
111  return actionsList.toArray(new Action[actionsList.size()]);
112  }
113 
114  @Override
115  public boolean isLeafTypeNode() {
116  return true;
117  }
118 
119  @Override
120  public <T> T accept(DisplayableItemNodeVisitor<T> dinv) {
121  throw new UnsupportedOperationException("Not supported yet."); // NON-NLS //To change body of generated methods, choose Tools | Templates.
122  }
123 
124  /*
125  * TODO (AUT-1849): Correct or remove peristent column reordering code
126  *
127  * Added to support this feature.
128  */
129 // @Override
130 // public String getItemType() {
131 // return "Event";
132 // }
137  private class TimeProperty extends PropertySupport.ReadWrite<String> {
138 
139  private String value;
140 
141  @Override
142  public boolean canWrite() {
143  return false;
144  }
145 
146  TimeProperty(String name, String displayName, String shortDescription, String value) {
147  super(name, String.class, displayName, shortDescription);
148  setValue("suppressCustomEditor", Boolean.TRUE); // remove the "..." (editing) button NON-NLS
149  this.value = value;
150  }
151 
152  @Override
153  public String getValue() throws IllegalAccessException, InvocationTargetException {
154  return value;
155  }
156 
157  @Override
158  public void setValue(String t) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
159  String oldValue = getValue();
160  value = t;
161  firePropertyChange("time", oldValue, t); // NON-NLS
162  }
163  }
164 }
static ReadOnlyObjectProperty< TimeZone > getTimeZone()
static List< Action > getActions(File file, boolean isArtifactSource)
synchronized static Logger getLogger(String name)
Definition: Logger.java:166

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.