diff --git a/Core/src/org/sleuthkit/autopsy/rejview/HexView.java b/Core/src/org/sleuthkit/autopsy/rejview/HexView.java index f165953c87..69d537a64e 100644 --- a/Core/src/org/sleuthkit/autopsy/rejview/HexView.java +++ b/Core/src/org/sleuthkit/autopsy/rejview/HexView.java @@ -21,25 +21,41 @@ */ package org.sleuthkit.autopsy.rejview; -import javax.swing.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; import javax.swing.border.BevelBorder; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import javax.swing.text.BadLocationException; import javax.swing.text.DefaultHighlighter; import javax.swing.text.JTextComponent; -import java.awt.*; import java.nio.ByteBuffer; +import java.util.logging.Level; +import javax.swing.BoxLayout; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTextArea; +import javax.swing.SwingConstants; +import org.sleuthkit.autopsy.coreutils.Logger; /** - * HexView is a standard three-paned hex editor widget that displays binary data. + * HexView is a standard three-paned hex editor widget that displays binary + * data. * - * Note, this does not do any intelligent paging of the data. You should estimate it to load three strings - * with length equal to the given ByteBuffer. So its probably not good to use this view with large files. + * Note, this does not do any intelligent paging of the data. You should + * estimate it to load three strings with length equal to the given ByteBuffer. + * So its probably not good to use this view with large files. */ public class HexView extends JPanel implements CaretListener { + private final static int DEFAULT_BYTES_PER_LINE = 0x10; - private final static char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; + private final static char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + private static final Logger logger = Logger.getLogger(HexView.class.getName()); + private static final long serialVersionUID = 1L; private final int _bytesPerLine; private final ByteBuffer _buf; private final JTextComponent _offsetView; @@ -59,7 +75,7 @@ public class HexView extends JPanel implements CaretListener { } /** - * @param buf The binary data to display within this hex view. + * @param buf The binary data to display within this hex view. * @param bytesPerLine The number of bytes to display per line. */ public HexView(ByteBuffer buf, int bytesPerLine) { @@ -118,7 +134,7 @@ public class HexView extends JPanel implements CaretListener { hexSB.append(hex); if (b >= ' ' && b <= '~') { - asciiSB.append((char)b); + asciiSB.append((char) b); } else { asciiSB.append('.'); } @@ -142,7 +158,6 @@ public class HexView extends JPanel implements CaretListener { this._highlighterPainter = new DefaultHighlighter.DefaultHighlightPainter(this._highlightColor); } - /** * clearHighlight removes any colors applied to the text views. */ @@ -153,8 +168,9 @@ public class HexView extends JPanel implements CaretListener { /** * setHighlight colors the given byte range. + * * @param startByte The starting byte index of the selection. - * @param endByte The ending byte index of the selection. + * @param endByte The ending byte index of the selection. */ private void setHighlight(int startByte, int endByte) { int startRows = (startByte - (startByte % this._bytesPerLine)) / this._bytesPerLine; @@ -164,17 +180,18 @@ public class HexView extends JPanel implements CaretListener { try { this._asciiView.getHighlighter().addHighlight(startByte + startRows, endByte + endRows, this._highlighterPainter); - this._hexView.getHighlighter().addHighlight((startByte * 3) + startRows, (endByte * 3) + endRows, this._highlighterPainter); - } catch (BadLocationException e1) { - System.out.println("bad location"); + this._hexView.getHighlighter().addHighlight((startByte * 3) + startRows, (endByte * 3) + endRows, this._highlighterPainter); + } catch (BadLocationException ex) { + logger.log(Level.WARNING, "bad location", ex); } } /** - * setSelection sets the given byte range as "selected", which from a GUI perspective means the - * bytes are highlighted, and the status bar updated. + * setSelection sets the given byte range as "selected", which from a GUI + * perspective means the bytes are highlighted, and the status bar updated. + * * @param startByte The starting byte index of the selection. - * @param endByte The ending byte index of the selection. + * @param endByte The ending byte index of the selection. */ private void setSelection(int startByte, int endByte) { this.setHighlight(startByte, endByte); @@ -224,8 +241,8 @@ public class HexView extends JPanel implements CaretListener { int endRows = (endByte - (endByte % this._bytesPerLine)) / this._bytesPerLine; // the byte index of the start,end points in the ASCII view - startByte = startByte - startRows; - endByte = endByte - endRows; + startByte -= startRows; + endByte -= endRows; // avoid the loop if (_asciiLastSelectionStart == startByte && _asciiLastSelectionEnd == endByte) { @@ -250,10 +267,10 @@ public class HexView extends JPanel implements CaretListener { int endRows = (endByte - (endByte % this._bytesPerLine)) / (3 * this._bytesPerLine); // the byte index of the start,end points in the ASCII view - startByte = startByte - startRows; - startByte = startByte / 3; - endByte = endByte - endRows; - endByte = endByte / 3; + startByte -= startRows; + startByte /= 3; + endByte -= endRows; + endByte /= 3; if (_hexLastSelectionStart == startByte && _hexLastSelectionEnd == endByte) { return; @@ -263,7 +280,7 @@ public class HexView extends JPanel implements CaretListener { this.setSelection(startByte, endByte); } else { - System.out.println("from unknown"); + logger.log(Level.INFO, "from unknown"); } } } diff --git a/Core/src/org/sleuthkit/autopsy/rejview/RegeditExeValueFormatter.java b/Core/src/org/sleuthkit/autopsy/rejview/RegeditExeValueFormatter.java index 85240b3381..3e8d4d5b0c 100644 --- a/Core/src/org/sleuthkit/autopsy/rejview/RegeditExeValueFormatter.java +++ b/Core/src/org/sleuthkit/autopsy/rejview/RegeditExeValueFormatter.java @@ -30,17 +30,18 @@ import java.nio.ByteBuffer; import java.util.Iterator; /** - * Formats a ValueData to a string similar to Regedit.exe on Windows. - * For an example, see the nice sample here: - * http://raja5.files.wordpress.com/2009/08/wincleanup_regedit.jpg + * Formats a ValueData to a string similar to Regedit.exe on Windows. For an + * example, see the nice sample here: + * http://raja5.files.wordpress.com/2009/08/wincleanup_regedit.jpg */ public class RegeditExeValueFormatter { + public static String format(ValueData val) throws UnsupportedEncodingException, RegistryParseException { StringBuilder sb = new StringBuilder(); - switch(val.getValueType()) { + switch (val.getValueType()) { case REG_SZ: - case REG_EXPAND_SZ:{ + case REG_EXPAND_SZ: { String valString = val.getAsString(); if (valString.length() == 0) { @@ -94,4 +95,8 @@ public class RegeditExeValueFormatter { } return sb.toString(); } + + private RegeditExeValueFormatter() { + //contrsuctor intentially left blank + } } diff --git a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeKeyNode.java b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeKeyNode.java index 7973dc35d2..101779f9e1 100644 --- a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeKeyNode.java +++ b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeKeyNode.java @@ -29,9 +29,12 @@ import java.io.UnsupportedEncodingException; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.logging.Level; +import org.sleuthkit.autopsy.coreutils.Logger; public class RejTreeKeyNode implements RejTreeNode { + private static final Logger logger = Logger.getLogger(RejTreeKeyNode.class.getName()); private final RegistryKey _key; public RejTreeKeyNode(RegistryKey key) { @@ -42,8 +45,8 @@ public class RejTreeKeyNode implements RejTreeNode { public String toString() { try { return this._key.getName(); - } catch (UnsupportedEncodingException e) { - System.err.println("Failed to parse key name"); + } catch (UnsupportedEncodingException ex) { + logger.log(Level.WARNING, "Failed to parse key name", ex); return "PARSE FAILED."; } } @@ -52,15 +55,15 @@ public class RejTreeKeyNode implements RejTreeNode { public boolean hasChildren() { try { return this._key.getValueList().size() > 0 || this._key.getSubkeyList().size() > 0; - } catch (RegistryParseException e) { - System.err.println("Failed to parse key children."); + } catch (RegistryParseException ex) { + logger.log(Level.WARNING, "Failed to parse key children.", ex); return false; } } @Override public List getChildren() { - LinkedList children = new LinkedList(); + LinkedList children = new LinkedList<>(); try { Iterator keyit = this._key.getSubkeyList().iterator(); @@ -72,8 +75,8 @@ public class RejTreeKeyNode implements RejTreeNode { while (valueit.hasNext()) { children.add(new RejTreeValueNode(valueit.next())); } - } catch (RegistryParseException e) { - System.err.println("Failed to parse key children."); + } catch (RegistryParseException ex) { + logger.log(Level.WARNING, "Failed to parse key children.", ex); } return children; } @@ -85,10 +88,10 @@ public class RejTreeKeyNode implements RejTreeNode { return this._key; } - /** * TODO(wb): this isn't exactly MVC... */ + @Override public RejTreeNodeView getView() { return new RejTreeKeyView(this); } diff --git a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeKeyView.java b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeKeyView.java index 9879e17f93..d37787bb4a 100644 --- a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeKeyView.java +++ b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeKeyView.java @@ -23,15 +23,22 @@ package org.sleuthkit.autopsy.rejview; import com.williballenthin.rejistry.RegistryParseException; import com.williballenthin.rejistry.RegistryValue; +import java.awt.BorderLayout; +import java.awt.Dimension; -import javax.swing.*; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; -import java.awt.*; import java.io.UnsupportedEncodingException; import java.util.Iterator; +import javax.swing.BorderFactory; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.SwingConstants; public class RejTreeKeyView extends RejTreeNodeView { + + private static final long serialVersionUID = 1L; private final RejTreeKeyNode _node; public RejTreeKeyView(RejTreeKeyNode node) { @@ -43,12 +50,12 @@ public class RejTreeKeyView extends RejTreeNodeView { * @param 2 Number of subkeys * @param 3 Number of values */ - String metadataTemplate = "" + - "" + - "Name: %1$s
" + - "Number of subkeys: %2$d
" + - "Number values: %3$d
" + - ""; + String metadataTemplate = "" + + "" + + "Name: %1$s
" + + "Number of subkeys: %2$d
" + + "Number values: %3$d
" + + ""; String keyName; int numSubkeys; int numValues; @@ -96,8 +103,7 @@ public class RejTreeKeyView extends RejTreeNodeView { // TODO(wb): need to add some warning here... // not sure how to do it, though, since some data may have already been added // but not necessarily all of it - } - catch (UnsupportedEncodingException e) { + } catch (UnsupportedEncodingException e) { // TODO(wb): need to add some warning here... } @@ -114,11 +120,11 @@ public class RejTreeKeyView extends RejTreeNodeView { int total = 0; for (int j = 0; j < width.length; j++) { TableColumn column = table.getColumnModel().getColumn(j); - int w = (int)table.getTableHeader().getDefaultRenderer().getTableCellRendererComponent(table, column.getIdentifier(), false, false, -1, j).getPreferredSize().getWidth(); + int w = (int) table.getTableHeader().getDefaultRenderer().getTableCellRendererComponent(table, column.getIdentifier(), false, false, -1, j).getPreferredSize().getWidth(); if (table.getRowCount() > 0) { for (int i = 0; i < table.getRowCount(); i++) { - int pw = (int)table.getCellRenderer(i, j).getTableCellRendererComponent(table, table.getValueAt(i, j), false, false, i, j).getPreferredSize().getWidth(); + int pw = (int) table.getCellRenderer(i, j).getTableCellRendererComponent(table, table.getValueAt(i, j), false, false, i, j).getPreferredSize().getWidth(); w = Math.max(w, pw); } } diff --git a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeNode.java b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeNode.java index 409641173c..33b379ace5 100644 --- a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeNode.java +++ b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeNode.java @@ -24,12 +24,18 @@ package org.sleuthkit.autopsy.rejview; import java.util.List; /** - * RejTreeNode is the adaptor between the Registry structure model and the JTree model. - * It may describe both the contents of the node, and how it should be displayed. + * RejTreeNode is the adaptor between the Registry structure model and the JTree + * model. It may describe both the contents of the node, and how it should be + * displayed. */ public interface RejTreeNode { + + @Override public abstract String toString(); + public abstract boolean hasChildren(); + public abstract List getChildren(); + public abstract RejTreeNodeView getView(); } diff --git a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeNodeSelectionEvent.java b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeNodeSelectionEvent.java index 54b27d809e..3409e0998d 100644 --- a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeNodeSelectionEvent.java +++ b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeNodeSelectionEvent.java @@ -22,7 +22,9 @@ package org.sleuthkit.autopsy.rejview; public class RejTreeNodeSelectionEvent { + private final RejTreeNode _node; + public RejTreeNodeSelectionEvent(RejTreeNode n) { this._node = n; } diff --git a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeNodeSelectionListener.java b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeNodeSelectionListener.java index 43b8728820..3d496346d5 100644 --- a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeNodeSelectionListener.java +++ b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeNodeSelectionListener.java @@ -22,5 +22,6 @@ package org.sleuthkit.autopsy.rejview; public interface RejTreeNodeSelectionListener { + public abstract void nodeSelected(RejTreeNodeSelectionEvent e); -} \ No newline at end of file +} diff --git a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeNodeView.java b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeNodeView.java index 9d982c59c9..d1eaf06a5c 100644 --- a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeNodeView.java +++ b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeNodeView.java @@ -21,10 +21,13 @@ */ package org.sleuthkit.autopsy.rejview; -import javax.swing.*; -import java.awt.*; +import java.awt.LayoutManager; +import javax.swing.JPanel; public class RejTreeNodeView extends JPanel { + + private static final long serialVersionUID = 1L; + public RejTreeNodeView() { super(); } diff --git a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeValueNode.java b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeValueNode.java index 32628be157..a51e11bbca 100644 --- a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeValueNode.java +++ b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeValueNode.java @@ -26,26 +26,32 @@ import com.williballenthin.rejistry.RegistryValue; import java.io.UnsupportedEncodingException; import java.util.LinkedList; import java.util.List; +import org.openide.util.NbBundle.Messages; +import java.util.logging.Level; +import org.sleuthkit.autopsy.coreutils.Logger; public class RejTreeValueNode implements RejTreeNode { + private static final Logger logger = Logger.getLogger(RejTreeValueNode.class.getName()); private final RegistryValue _value; public RejTreeValueNode(RegistryValue value) { this._value = value; } + @Messages({"RejTreeValueNode.defaultValueName.text=(Default)", + "RejTreeValueNode.failureValueName.text=PARSE FAILED"}) @Override public String toString() { try { String valueName = this._value.getName(); - if (valueName == "") { - return "(Default)"; + if (valueName.isEmpty()) { + return Bundle.RejTreeValueNode_defaultValueName_text(); } return valueName; - } catch (UnsupportedEncodingException e) { - System.err.println("Failed to parse _value name"); - return "PARSE FAILED."; + } catch (UnsupportedEncodingException ex) { + logger.log(Level.WARNING, "Failed to parse _value name", ex); + return Bundle.RejTreeValueNode_failureValueName_text(); } } @@ -56,7 +62,7 @@ public class RejTreeValueNode implements RejTreeNode { @Override public List getChildren() { - return new LinkedList(); + return new LinkedList<>(); } /** @@ -69,6 +75,7 @@ public class RejTreeValueNode implements RejTreeNode { /** * TODO(wb): this isn't exactly MVC... */ + @Override public RejTreeNodeView getView() { return new RejTreeValueView(this); } diff --git a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeValueView.java b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeValueView.java index 28995e8750..6b003dbe94 100644 --- a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeValueView.java +++ b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeValueView.java @@ -23,13 +23,17 @@ package org.sleuthkit.autopsy.rejview; import com.williballenthin.rejistry.RegistryParseException; import com.williballenthin.rejistry.ValueData; - -import javax.swing.*; -import java.awt.*; +import java.awt.BorderLayout; import java.io.UnsupportedEncodingException; -import java.util.Iterator; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.SwingConstants; public class RejTreeValueView extends RejTreeNodeView { + + private static final long serialVersionUID = 1L; private final RejTreeValueNode _node; public RejTreeValueView(RejTreeValueNode node) { @@ -40,21 +44,21 @@ public class RejTreeValueView extends RejTreeNodeView { * @param 1 Name * @param 2 Type */ - String metadataTemplate = "" + - "" + - "Name: %1$s
" + - "Type: %2$s" + - ""; + String metadataTemplate = "" + + "" + + "Name: %1$s
" + + "Type: %2$s" + + ""; String valueName; String valueType; /** * @param 1 Value */ - String valueTemplate = "" + - "" + - "%1$s" + - ""; + String valueTemplate = "" + + "" + + "%1$s" + + ""; try { valueName = this._node.getValue().getName(); } catch (UnsupportedEncodingException e) { @@ -63,7 +67,7 @@ public class RejTreeValueView extends RejTreeNodeView { try { valueType = this._node.getValue().getValueType().toString(); - } catch (RegistryParseException e ) { + } catch (RegistryParseException e) { valueType = "FAILED TO PARSE VALUE TYPE"; } @@ -77,11 +81,11 @@ public class RejTreeValueView extends RejTreeNodeView { ValueData data = this._node.getValue().getValue(); // the case statements are a bit repetitive, but i think make more sense than confusingly-nested if/elses - switch(data.getValueType()) { + switch (data.getValueType()) { case REG_SZ: case REG_EXPAND_SZ: { String valueValue = data.getAsString(); - JLabel valueLabel = new JLabel(String.format(valueTemplate, valueValue), JLabel.LEFT); + JLabel valueLabel = new JLabel(String.format(valueTemplate, valueValue), JLabel.LEFT); valueLabel.setBorder(BorderFactory.createTitledBorder("Value")); valueLabel.setVerticalAlignment(SwingConstants.TOP); valueComponent = valueLabel; @@ -94,7 +98,7 @@ public class RejTreeValueView extends RejTreeNodeView { sb.append("
"); } String valueValue = sb.toString(); - JLabel valueLabel = new JLabel(String.format(valueTemplate, valueValue), JLabel.LEFT); + JLabel valueLabel = new JLabel(String.format(valueTemplate, valueValue), JLabel.LEFT); valueLabel.setBorder(BorderFactory.createTitledBorder("Value")); valueLabel.setVerticalAlignment(SwingConstants.TOP); valueComponent = valueLabel; @@ -104,7 +108,7 @@ public class RejTreeValueView extends RejTreeNodeView { case REG_QWORD: case REG_BIG_ENDIAN: { String valueValue = String.format("0x%x", data.getAsNumber()); - JLabel valueLabel = new JLabel(String.format(valueTemplate, valueValue), JLabel.LEFT); + JLabel valueLabel = new JLabel(String.format(valueTemplate, valueValue), JLabel.LEFT); valueLabel.setBorder(BorderFactory.createTitledBorder("Value")); valueLabel.setVerticalAlignment(SwingConstants.TOP); valueComponent = valueLabel; @@ -117,13 +121,8 @@ public class RejTreeValueView extends RejTreeNodeView { break; } } - } catch (RegistryParseException e) { - JLabel valueLabel = new JLabel(String.format(valueTemplate, "FAILED TO PARSE VALUE VALUE"), JLabel.LEFT); - valueLabel.setBorder(BorderFactory.createTitledBorder("Value")); - valueLabel.setVerticalAlignment(SwingConstants.TOP); - valueComponent = valueLabel; - } catch (UnsupportedEncodingException e) { - JLabel valueLabel = new JLabel(String.format(valueTemplate, "FAILED TO PARSE VALUE VALUE"), JLabel.LEFT); + } catch (RegistryParseException | UnsupportedEncodingException e) { + JLabel valueLabel = new JLabel(String.format(valueTemplate, "FAILED TO PARSE VALUE VALUE"), JLabel.LEFT); valueLabel.setBorder(BorderFactory.createTitledBorder("Value")); valueLabel.setVerticalAlignment(SwingConstants.TOP); valueComponent = valueLabel; @@ -133,4 +132,3 @@ public class RejTreeValueView extends RejTreeNodeView { this.add(new JScrollPane(valueComponent), BorderLayout.CENTER); } } - diff --git a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeView.java b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeView.java index 562e4d5064..f65fb320b8 100644 --- a/Core/src/org/sleuthkit/autopsy/rejview/RejTreeView.java +++ b/Core/src/org/sleuthkit/autopsy/rejview/RejTreeView.java @@ -23,8 +23,7 @@ package org.sleuthkit.autopsy.rejview; import com.williballenthin.rejistry.RegistryHive; import com.williballenthin.rejistry.RegistryParseException; - -import javax.swing.*; +import java.awt.Dimension; import javax.swing.event.TreeExpansionEvent; import javax.swing.event.TreeExpansionListener; import javax.swing.event.TreeSelectionEvent; @@ -32,25 +31,30 @@ import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreePath; -import java.awt.*; import java.util.concurrent.CopyOnWriteArrayList; +import java.util.logging.Level; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import org.sleuthkit.autopsy.coreutils.Logger; public class RejTreeView extends JScrollPane implements TreeExpansionListener, TreeSelectionListener { + private static final Logger logger = Logger.getLogger(HexView.class.getName()); + private static final long serialVersionUID = 1L; private final DefaultTreeModel _tree_model; - private JTree _tree; private final RegistryHive _hive; private final CopyOnWriteArrayList _nodeSelectionListeners; + private final JTree _tree; public RejTreeView(RegistryHive hive) { this._hive = hive; DefaultMutableTreeNode rootNode; - this._nodeSelectionListeners = new CopyOnWriteArrayList(); + this._nodeSelectionListeners = new CopyOnWriteArrayList<>(); try { rootNode = getTreeNode(new RejTreeKeyNode(this._hive.getRoot())); - } catch (RegistryParseException e) { - System.err.println("Failed to parse root key"); + } catch (RegistryParseException ex) { + logger.log(Level.WARNING, "Failed to parse root key", ex); rootNode = new DefaultMutableTreeNode("PARSE FAILED"); } @@ -70,7 +74,8 @@ public class RejTreeView extends JScrollPane implements TreeExpansionListener, T } /** - * getTreeNode creates a TreeNode from a RejTreeNode, settings the appropriate fields. + * getTreeNode creates a TreeNode from a RejTreeNode, settings the + * appropriate fields. */ private DefaultMutableTreeNode getTreeNode(RejTreeNode node) { DefaultMutableTreeNode ret; @@ -85,7 +90,7 @@ public class RejTreeView extends JScrollPane implements TreeExpansionListener, T DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); if (node.getChildCount() == 0) { - RejTreeNode n = (RejTreeNode)node.getUserObject(); + RejTreeNode n = (RejTreeNode) node.getUserObject(); for (RejTreeNode rejTreeNode : n.getChildren()) { node.add(getTreeNode(rejTreeNode)); } @@ -100,16 +105,15 @@ public class RejTreeView extends JScrollPane implements TreeExpansionListener, T @Override public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getPath(); - System.out.println("Selected: " + path); DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); - this.triggerRejTreeNodeSelection((RejTreeNode)node.getUserObject()); + this.triggerRejTreeNodeSelection((RejTreeNode) node.getUserObject()); } public void addRejTreeNodeSelectionListener(RejTreeNodeSelectionListener l) { this._nodeSelectionListeners.add(l); } - public void removeRejTreeNodeSelectionListener(RejTreeNodeSelectionListener l ) { + public void removeRejTreeNodeSelectionListener(RejTreeNodeSelectionListener l) { this._nodeSelectionListeners.remove(l); } diff --git a/Core/src/org/sleuthkit/autopsy/rejview/RejView.java b/Core/src/org/sleuthkit/autopsy/rejview/RejView.java index f09366d913..e3a5d91cdf 100644 --- a/Core/src/org/sleuthkit/autopsy/rejview/RejView.java +++ b/Core/src/org/sleuthkit/autopsy/rejview/RejView.java @@ -23,13 +23,15 @@ package org.sleuthkit.autopsy.rejview; import com.williballenthin.rejistry.RegistryHive; import com.williballenthin.rejistry.RegistryHiveBuffer; - -import javax.swing.*; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Dimension; import java.nio.ByteBuffer; +import javax.swing.JPanel; +import javax.swing.JSplitPane; public class RejView extends JPanel implements RejTreeNodeSelectionListener { + private static final long serialVersionUID = 1L; private final RegistryHive _hive; private final RejTreeView _tree_view; private final JSplitPane _splitPane; @@ -37,12 +39,10 @@ public class RejView extends JPanel implements RejTreeNodeSelectionListener { public RejView(RegistryHive hive) { super(new BorderLayout()); this._hive = hive; - // have to do these cause they're final this._tree_view = new RejTreeView(this._hive); this._splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this._tree_view, new JPanel()); - this.setupUI(); } @@ -54,7 +54,6 @@ public class RejView extends JPanel implements RejTreeNodeSelectionListener { this._tree_view = new RejTreeView(this._hive); this._splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this._tree_view, new JPanel()); - this.setupUI(); } @@ -62,10 +61,8 @@ public class RejView extends JPanel implements RejTreeNodeSelectionListener { this._splitPane.setResizeWeight(0); this._splitPane.setOneTouchExpandable(true); this._splitPane.setContinuousLayout(true); - this.add(this._splitPane, BorderLayout.CENTER); this.setPreferredSize(new Dimension(800, 600)); - this._tree_view.addRejTreeNodeSelectionListener(this); }