Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
ExplorerNodeActionVisitor.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-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.directorytree;
20 
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.List;
24 import javax.swing.AbstractAction;
25 import javax.swing.Action;
26 import org.openide.util.NbBundle;
29 import org.sleuthkit.datamodel.Content;
30 import org.sleuthkit.datamodel.ContentVisitor;
31 import org.sleuthkit.datamodel.DerivedFile;
32 import org.sleuthkit.datamodel.Directory;
33 import org.sleuthkit.datamodel.FileSystem;
34 import org.sleuthkit.datamodel.Image;
35 import org.sleuthkit.datamodel.LocalFile;
36 import org.sleuthkit.datamodel.VirtualDirectory;
37 import org.sleuthkit.datamodel.Volume;
38 
39 public class ExplorerNodeActionVisitor extends ContentVisitor.Default<List<? extends Action>> {
40 
42 
43  public static List<Action> getActions(Content c) {
44  List<Action> actions = new ArrayList<>();
45 
46  actions.addAll(c.accept(instance));
47  //TODO: fix this
48  /*
49  * while (c.isOnto()) { try { List<? extends Content> children =
50  * c.getChildren(); if (!children.isEmpty()) { c =
51  * c.getChildren().get(0); } else { return actions; } } catch
52  * (TskException ex) {
53  * Log.get(ExplorerNodeActionVisitor.class).log(Level.WARNING, "Error
54  * getting show detail actions.", ex); return actions; }
55  * actions.addAll(c.accept(instance));
56  }
57  */
58  return actions;
59  }
60 
62  }
63 
64  @Override
65  public List<? extends Action> visit(final Image img) {
66  List<Action> lst = new ArrayList<>();
67  //TODO lst.add(new ExtractAction("Extract Image", img));
68  lst.add(new ExtractUnallocAction(
69  NbBundle.getMessage(this.getClass(), "ExplorerNodeActionVisitor.action.extUnallocToSingleFiles"), img));
70  return lst;
71  }
72 
73  @Override
74  public List<? extends Action> visit(final FileSystem fs) {
75  return new ArrayList<>();
76  }
77 
78  @Override
79  public List<? extends Action> visit(final Volume vol) {
80  List<AbstractAction> lst = new ArrayList<>();
81  lst.add(new ExtractUnallocAction(
82  NbBundle.getMessage(this.getClass(), "ExplorerNodeActionVisitor.action.extUnallocToSingleFile"), vol));
83  return lst;
84  }
85 
86  @Override
87  public List<? extends Action> visit(final Directory d) {
88  List<Action> actions = new ArrayList<>();
89  actions.add(AddContentTagAction.getInstance());
90  actions.addAll(ContextMenuExtensionPoint.getActions());
91  return actions;
92  }
93 
94  @Override
95  public List<? extends Action> visit(final VirtualDirectory d) {
96  List<Action> actions = new ArrayList<>();
97  if (!d.isDataSource()) {
98  actions.add(AddContentTagAction.getInstance());
99  }
100  actions.add(ExtractAction.getInstance());
101  actions.addAll(ContextMenuExtensionPoint.getActions());
102  return actions;
103  }
104 
105  @Override
106  public List<? extends Action> visit(final DerivedFile d) {
107  List<Action> actions = new ArrayList<>();
108  actions.add(ExtractAction.getInstance());
109  actions.add(AddContentTagAction.getInstance());
110  actions.addAll(ContextMenuExtensionPoint.getActions());
111  return actions;
112  }
113 
114  @Override
115  public List<? extends Action> visit(final LocalFile d) {
116  List<Action> actions = new ArrayList<>();
117  actions.add(ExtractAction.getInstance());
118  actions.add(AddContentTagAction.getInstance());
119  actions.addAll(ContextMenuExtensionPoint.getActions());
120  return actions;
121  }
122 
123  @Override
124  public List<? extends Action> visit(final org.sleuthkit.datamodel.File d) {
125  List<Action> actions = new ArrayList<>();
126  actions.add(ExtractAction.getInstance());
127  actions.add(AddContentTagAction.getInstance());
128  actions.addAll(ContextMenuExtensionPoint.getActions());
129  return actions;
130  }
131 
132  @Override
133  protected List<? extends Action> defaultVisit(Content di) {
134  return Collections.<Action>emptyList();
135  }
136 
137 }
static synchronized ExtractAction getInstance()
List<?extends Action > visit(final org.sleuthkit.datamodel.File d)
static synchronized AddContentTagAction getInstance()

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.