Autopsy  3.1
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 javafx.beans.Observable;
26 import javax.swing.Action;
27 import org.joda.time.DateTime;
28 import org.joda.time.DateTimeZone;
29 import org.openide.nodes.Children;
30 import org.openide.nodes.PropertySupport;
31 import org.openide.nodes.Sheet;
32 import org.openide.util.Exceptions;
33 import org.openide.util.lookup.Lookups;
43 
45 class EventNode extends DisplayableItemNode {
46 
47  private final TimeLineEvent e;
48 
49  EventNode(TimeLineEvent eventById, AbstractFile file, BlackboardArtifact artifact) {
50  super(Children.LEAF, Lookups.fixed(eventById, file, artifact));
51  this.e = eventById;
52  this.setIconBaseWithExtension("org/sleuthkit/autopsy/timeline/images/" + e.getType().getIconBase()); // NON-NLS
53  }
54 
55  EventNode(TimeLineEvent eventById, AbstractFile file) {
56  super(Children.LEAF, Lookups.fixed(eventById, file));
57  this.e = eventById;
58  this.setIconBaseWithExtension("org/sleuthkit/autopsy/timeline/images/" + e.getType().getIconBase()); // NON-NLS
59  }
60 
61  @Override
62  protected Sheet createSheet() {
63  Sheet s = super.createSheet();
64  Sheet.Set properties = s.get(Sheet.PROPERTIES);
65  if (properties == null) {
66  properties = Sheet.createPropertiesSet();
67  s.put(properties);
68  }
69 
70  final TimeProperty timePropery = new TimeProperty("time", "Date/Time", "time ", getDateTimeString()); // NON-NLS
71 
72  TimeLineController.getTimeZone().addListener((Observable observable) -> {
73  try {
74  timePropery.setValue(getDateTimeString());
75  } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
76  Exceptions.printStackTrace(ex);
77  }
78  });
79 
80  properties.put(new NodeProperty<>("icon", "Icon", "icon", true)); // NON-NLS //gets overridden with icon
81  properties.put(timePropery);
82  properties.put(new NodeProperty<>("description", "Description", "description", e.getFullDescription())); // NON-NLS
83  properties.put(new NodeProperty<>("eventBaseType", "Base Type", "base type", e.getType().getSuperType().getDisplayName())); // NON-NLS
84  properties.put(new NodeProperty<>("eventSubType", "Sub Type", "sub type", e.getType().getDisplayName())); // NON-NLS
85  properties.put(new NodeProperty<>("Known", "Known", "known", e.getKnown().toString())); // NON-NLS
86 
87  return s;
88  }
89 
90  private String getDateTimeString() {
91  return new DateTime(e.getTime() * 1000, DateTimeZone.UTC).toString(TimeLineController.getZonedFormatter());
92  }
93 
94  @Override
95  public Action[] getActions(boolean context) {
96  Action[] superActions = super.getActions(context);
97  List<Action> actionsList = new ArrayList<>();
98  actionsList.addAll(Arrays.asList(superActions));
99 
100  final Content content = getLookup().lookup(Content.class);
101  final BlackboardArtifact artifact = getLookup().lookup(BlackboardArtifact.class);
102 
103  final List<Action> factoryActions = DataModelActionsFactory.getActions(content, artifact != null);
104 
105  actionsList.addAll(factoryActions);
106  return actionsList.toArray(new Action[0]);
107  }
108 
109  @Override
110  public boolean isLeafTypeNode() {
111  return true;
112  }
113 
114  @Override
115  public <T> T accept(DisplayableItemNodeVisitor<T> dinv) {
116  throw new UnsupportedOperationException("Not supported yet."); // NON-NLS //To change body of generated methods, choose Tools | Templates.
117  }
118 
119  class TimeProperty extends PropertySupport.ReadWrite<String> {
120 
121  private String value;
122 
123  @Override
124  public boolean canWrite() {
125  return false;
126  }
127 
128  public TimeProperty(String name, String displayName, String shortDescription, String value) {
129  super(name, String.class, displayName, shortDescription);
130  setValue("suppressCustomEditor", Boolean.TRUE); // remove the "..." (editing) button NON-NLS
131  this.value = value;
132  }
133 
134  @Override
135  public String getValue() throws IllegalAccessException, InvocationTargetException {
136  return value;
137  }
138 
139  @Override
140  public void setValue(String t) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
141  String oldValue = getValue();
142  value = t;
143  firePropertyChange("time", oldValue, t); // NON-NLS
144  }
145  }
146 }
static ReadOnlyObjectProperty< TimeZone > getTimeZone()
static List< Action > getActions(File file, boolean isArtifactSource)

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