mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 09:17:42 +00:00
4961 some comments added some clean up
This commit is contained in:
parent
6feed3db22
commit
01cb54a03e
@ -59,7 +59,7 @@ final class HexView extends JPanel {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private final int bytesPerLine;
|
private final int bytesPerLine;
|
||||||
private final ByteBuffer buf;
|
private final ByteBuffer buf;
|
||||||
private final HexViewListener listener = new HexViewListener();
|
private final HexViewListener hexViewListener = new HexViewListener();
|
||||||
private final JTextComponent offsetView;
|
private final JTextComponent offsetView;
|
||||||
private final JTextComponent hexView;
|
private final JTextComponent hexView;
|
||||||
private final JTextComponent asciiView;
|
private final JTextComponent asciiView;
|
||||||
@ -156,8 +156,8 @@ final class HexView extends JPanel {
|
|||||||
this.offsetView.setText(offsetSB.toString());
|
this.offsetView.setText(offsetSB.toString());
|
||||||
this.hexView.setText(hexSB.toString());
|
this.hexView.setText(hexSB.toString());
|
||||||
this.asciiView.setText(asciiSB.toString());
|
this.asciiView.setText(asciiSB.toString());
|
||||||
this.hexView.addCaretListener(listener);
|
this.hexView.addCaretListener(hexViewListener);
|
||||||
this.asciiView.addCaretListener(listener);
|
this.asciiView.addCaretListener(hexViewListener);
|
||||||
this.asciiView.setSelectedTextColor(this.asciiView.getForeground());
|
this.asciiView.setSelectedTextColor(this.asciiView.getForeground());
|
||||||
this.hexView.setSelectedTextColor(this.asciiView.getForeground());
|
this.hexView.setSelectedTextColor(this.asciiView.getForeground());
|
||||||
this.highlightColor = this.hexView.getSelectionColor();
|
this.highlightColor = this.hexView.getSelectionColor();
|
||||||
|
@ -21,7 +21,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.rejview;
|
package org.sleuthkit.autopsy.rejview;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for listeners of tree node selection events
|
||||||
|
*/
|
||||||
public interface RejTreeNodeSelectionListener {
|
public interface RejTreeNodeSelectionListener {
|
||||||
|
|
||||||
public abstract void nodeSelected(RejTreeNodeSelectionEvent e);
|
public abstract void nodeSelected(RejTreeNodeSelectionEvent event);
|
||||||
}
|
}
|
||||||
|
@ -38,35 +38,40 @@ import javax.swing.JTree;
|
|||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tree view for registry hive information
|
||||||
|
*/
|
||||||
final class RejTreeView extends JScrollPane {
|
final class RejTreeView extends JScrollPane {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(HexView.class.getName());
|
private static final Logger logger = Logger.getLogger(HexView.class.getName());
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private final DefaultTreeModel treeModel;
|
private final DefaultTreeModel treeModel;
|
||||||
private final RejTreeViewListener listener = new RejTreeViewListener();
|
private final RejTreeViewListener rejTreeViewListener = new RejTreeViewListener();
|
||||||
private final RegistryHive hive;
|
private final RegistryHive hive;
|
||||||
private final CopyOnWriteArrayList<RejTreeNodeSelectionListener> nodeSelectionListeners;
|
private final CopyOnWriteArrayList<RejTreeNodeSelectionListener> nodeSelectionListeners;
|
||||||
private final JTree tree;
|
private final JTree tree;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new RejTreeView given the RegistrHive object
|
||||||
|
*
|
||||||
|
* @param hive the registryhive to construct the RejTreeView for
|
||||||
|
*/
|
||||||
@NbBundle.Messages({"RejTreeView.failureValueName.text=PARSE FAILED"})
|
@NbBundle.Messages({"RejTreeView.failureValueName.text=PARSE FAILED"})
|
||||||
RejTreeView(RegistryHive hive) {
|
RejTreeView(RegistryHive hive) {
|
||||||
this.hive = hive;
|
this.hive = hive;
|
||||||
DefaultMutableTreeNode rootNode;
|
DefaultMutableTreeNode rootNode;
|
||||||
this.nodeSelectionListeners = new CopyOnWriteArrayList<>();
|
this.nodeSelectionListeners = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
rootNode = getTreeNode(new RejTreeKeyNode(this.hive.getRoot()));
|
rootNode = getTreeNode(new RejTreeKeyNode(this.hive.getRoot()));
|
||||||
} catch (RegistryParseException ex) {
|
} catch (RegistryParseException ex) {
|
||||||
logger.log(Level.WARNING, "Failed to parse root key", ex);
|
logger.log(Level.WARNING, "Failed to parse root key", ex);
|
||||||
rootNode = new DefaultMutableTreeNode(Bundle.RejTreeView_failureValueName_text());
|
rootNode = new DefaultMutableTreeNode(Bundle.RejTreeView_failureValueName_text());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.treeModel = new DefaultTreeModel(rootNode);
|
this.treeModel = new DefaultTreeModel(rootNode);
|
||||||
this.treeModel.setAsksAllowsChildren(true);
|
this.treeModel.setAsksAllowsChildren(true);
|
||||||
|
|
||||||
this.tree = new JTree(this.treeModel);
|
this.tree = new JTree(this.treeModel);
|
||||||
this.tree.addTreeExpansionListener(listener);
|
this.tree.addTreeExpansionListener(rejTreeViewListener);
|
||||||
this.tree.addTreeSelectionListener(listener);
|
this.tree.addTreeSelectionListener(rejTreeViewListener);
|
||||||
// here's a bit of a hack to force the children to be loaded and shown
|
// here's a bit of a hack to force the children to be loaded and shown
|
||||||
this.tree.collapsePath(new TreePath(rootNode.getPath()));
|
this.tree.collapsePath(new TreePath(rootNode.getPath()));
|
||||||
this.tree.expandPath(new TreePath(rootNode.getPath()));
|
this.tree.expandPath(new TreePath(rootNode.getPath()));
|
||||||
@ -85,14 +90,29 @@ final class RejTreeView extends JScrollPane {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addRejTreeNodeSelectionListener(RejTreeNodeSelectionListener l) {
|
/**
|
||||||
this.nodeSelectionListeners.add(l);
|
* Add a RejTreeNodeSelectionListener to the list of node selection
|
||||||
|
* listeners the RejTreeView has
|
||||||
|
*
|
||||||
|
* @param selListener the RejTreeNodeSelectionListener to add
|
||||||
|
*/
|
||||||
|
void addRejTreeNodeSelectionListener(RejTreeNodeSelectionListener selListener) {
|
||||||
|
this.nodeSelectionListeners.add(selListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeRejTreeNodeSelectionListener(RejTreeNodeSelectionListener l) {
|
/**
|
||||||
this.nodeSelectionListeners.remove(l);
|
* Remove a RejTreeNodeSelectionListener from the list of node selection
|
||||||
|
* listeners the RejTreeView has
|
||||||
|
*
|
||||||
|
* @param selListener the RejTreeNodeSelectionListener to remove
|
||||||
|
*/
|
||||||
|
void removeRejTreeNodeSelectionListener(RejTreeNodeSelectionListener selListener) {
|
||||||
|
this.nodeSelectionListeners.remove(selListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private listener for TreeExpansionEvents and TreeSelectionEvents
|
||||||
|
*/
|
||||||
private class RejTreeViewListener implements TreeExpansionListener, TreeSelectionListener {
|
private class RejTreeViewListener implements TreeExpansionListener, TreeSelectionListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -120,6 +140,9 @@ final class RejTreeView extends JScrollPane {
|
|||||||
this.triggerRejTreeNodeSelection((RejTreeNode) node.getUserObject());
|
this.triggerRejTreeNodeSelection((RejTreeNode) node.getUserObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call each of the node selection listeners for a given node
|
||||||
|
*/
|
||||||
void triggerRejTreeNodeSelection(RejTreeNode n) {
|
void triggerRejTreeNodeSelection(RejTreeNode n) {
|
||||||
RejTreeNodeSelectionEvent e = new RejTreeNodeSelectionEvent(n);
|
RejTreeNodeSelectionEvent e = new RejTreeNodeSelectionEvent(n);
|
||||||
for (RejTreeNodeSelectionListener listener : nodeSelectionListeners) {
|
for (RejTreeNodeSelectionListener listener : nodeSelectionListeners) {
|
||||||
|
@ -29,6 +29,9 @@ import java.nio.ByteBuffer;
|
|||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JSplitPane;
|
import javax.swing.JSplitPane;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A panel for displaying information from a registry hive file
|
||||||
|
*/
|
||||||
public final class RejView extends JPanel implements RejTreeNodeSelectionListener {
|
public final class RejView extends JPanel implements RejTreeNodeSelectionListener {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@ -36,6 +39,11 @@ public final class RejView extends JPanel implements RejTreeNodeSelectionListene
|
|||||||
private final RejTreeView treeView;
|
private final RejTreeView treeView;
|
||||||
private final JSplitPane splitPane;
|
private final JSplitPane splitPane;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new RejView panel given a RegistryHive object
|
||||||
|
*
|
||||||
|
* @param hive the hive file to display information for
|
||||||
|
*/
|
||||||
public RejView(RegistryHive hive) {
|
public RejView(RegistryHive hive) {
|
||||||
super(new BorderLayout());
|
super(new BorderLayout());
|
||||||
this.hive = hive;
|
this.hive = hive;
|
||||||
@ -46,6 +54,11 @@ public final class RejView extends JPanel implements RejTreeNodeSelectionListene
|
|||||||
this.setupUI();
|
this.setupUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new RejView panel given a ByteBuffer object
|
||||||
|
*
|
||||||
|
* @param buf the ByteBuffer which represents the Reigstry Hive file
|
||||||
|
*/
|
||||||
public RejView(ByteBuffer buf) {
|
public RejView(ByteBuffer buf) {
|
||||||
super(new BorderLayout());
|
super(new BorderLayout());
|
||||||
this.hive = new RegistryHiveBuffer(buf);
|
this.hive = new RegistryHiveBuffer(buf);
|
||||||
@ -57,20 +70,28 @@ public final class RejView extends JPanel implements RejTreeNodeSelectionListene
|
|||||||
this.setupUI();
|
this.setupUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up the ui elements of the panel
|
||||||
|
*/
|
||||||
private void setupUI() {
|
private void setupUI() {
|
||||||
this.splitPane.setResizeWeight(0);
|
this.splitPane.setResizeWeight(0);
|
||||||
this.splitPane.setOneTouchExpandable(true);
|
this.splitPane.setOneTouchExpandable(true);
|
||||||
this.splitPane.setContinuousLayout(true);
|
this.splitPane.setContinuousLayout(true);
|
||||||
this.add(this.splitPane, BorderLayout.CENTER);
|
this.add(this.splitPane, BorderLayout.CENTER);
|
||||||
this.setPreferredSize(new Dimension(0,0));
|
this.setPreferredSize(new Dimension(0, 0));
|
||||||
this.treeView.addRejTreeNodeSelectionListener(this);
|
this.treeView.addRejTreeNodeSelectionListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the the right side of the panel to display the selected node
|
||||||
|
*
|
||||||
|
* @param event the selection event indicating what node was selecteds
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void nodeSelected(RejTreeNodeSelectionEvent e) {
|
public void nodeSelected(RejTreeNodeSelectionEvent event) {
|
||||||
RejTreeNodeView v = e.getNode().getView();
|
RejTreeNodeView view = event.getNode().getView();
|
||||||
int curDividerLocation = this.splitPane.getDividerLocation();
|
int curDividerLocation = this.splitPane.getDividerLocation();
|
||||||
this.splitPane.setRightComponent(v);
|
this.splitPane.setRightComponent(view);
|
||||||
this.splitPane.setDividerLocation(curDividerLocation);
|
this.splitPane.setDividerLocation(curDividerLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user