Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
VolumeNode.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.datamodel;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 import javax.swing.Action;
24 import org.openide.nodes.Sheet;
25 import org.openide.util.NbBundle;
29 
34 public class VolumeNode extends AbstractContentNode<Volume> {
35 
43  static String nameForVolume(Volume vol) {
44  return "vol" + Long.toString(vol.getAddr()); //NON-NLS
45  }
46 
51  public VolumeNode(Volume vol) {
52  super(vol);
53 
54  // set name, display name, and icon
55  String volName = nameForVolume(vol);
56 
57  long end = vol.getStart() + (vol.getSize() - 1);
58  String tempVolName = volName + " (" + vol.getDescription() + ": " + vol.getStart() + "-" + end + ")";
59  this.setDisplayName(tempVolName);
60 
61  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/vol-icon.png"); //NON-NLS
62  }
63 
70  @Override
71  public Action[] getActions(boolean popup) {
72  List<Action> actionsList = new ArrayList<>();
73 
74  actionsList.add(new NewWindowViewAction(
75  NbBundle.getMessage(this.getClass(), "VolumeNode.getActions.viewInNewWin.text"), this));
76  actionsList.addAll(ExplorerNodeActionVisitor.getActions(content));
77 
78  return actionsList.toArray(new Action[0]);
79  }
80 
81  @Override
82  protected Sheet createSheet() {
83  Sheet s = super.createSheet();
84  Sheet.Set ss = s.get(Sheet.PROPERTIES);
85  if (ss == null) {
86  ss = Sheet.createPropertiesSet();
87  s.put(ss);
88  }
89 
90  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.name.name"),
91  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.name.displayName"),
92  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.name.desc"),
93  this.getDisplayName()));
94  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.id.name"),
95  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.id.displayName"),
96  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.id.desc"),
97  content.getAddr()));
98  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.startSector.name"),
99  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.startSector.displayName"),
100  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.startSector.desc"),
101  content.getStart()));
102  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.lenSectors.name"),
103  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.lenSectors.displayName"),
104  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.lenSectors.desc"),
105  content.getLength()));
106  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.description.name"),
107  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.description.displayName"),
108  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.description.desc"),
109  content.getDescription()));
110  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.flags.name"),
111  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.flags.displayName"),
112  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.flags.desc"),
113  content.getFlagsAsString()));
114 
115  return s;
116  }
117 
118  @Override
119  public <T> T accept(ContentNodeVisitor<T> v) {
120  return v.visit(this);
121  }
122 
123  @Override
124  public boolean isLeafTypeNode() {
125  return false;
126  }
127 
128  @Override
129  public <T> T accept(DisplayableItemNodeVisitor<T> v) {
130  return v.visit(this);
131  }
132 }

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.