From 3c45ba76bbd32e6c21c636e39f5cf5dc016fdb85 Mon Sep 17 00:00:00 2001 From: James McLeod Date: Wed, 28 Oct 2020 13:19:47 -0400 Subject: [PATCH] Implement correct reset functionality to clear display when closing current file or opening a new one. This fixes Bug #7 --- .../jmcleodfoss/explorer/BlockBTreeDisplay.java | 13 ++++++++++++- .../jmcleodfoss/explorer/NodeBTreeDisplay.java | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/explorer/src/main/java/io/github/jmcleodfoss/explorer/BlockBTreeDisplay.java b/explorer/src/main/java/io/github/jmcleodfoss/explorer/BlockBTreeDisplay.java index 82768d9a..56e1fdbe 100644 --- a/explorer/src/main/java/io/github/jmcleodfoss/explorer/BlockBTreeDisplay.java +++ b/explorer/src/main/java/io/github/jmcleodfoss/explorer/BlockBTreeDisplay.java @@ -7,11 +7,15 @@ @SuppressWarnings("serial") class BlockBTreeDisplay extends BTreeWithData { + /** The current block's contents */ + private BlockDescriptionDisplay blockDescriptionDisplay; + /** Construct a BTreeWithData object with the appropriate orientation and contents for the block B-tree display. */ BlockBTreeDisplay() { super(JSplitPane.HORIZONTAL_SPLIT); - setDataView(new BlockDescriptionDisplay(tree)); + blockDescriptionDisplay = new BlockDescriptionDisplay(tree); + setDataView(blockDescriptionDisplay); } /** Get the tree model for the block B-tree. */ @@ -19,4 +23,11 @@ TreeModel treeModel() { return (TreeModel)pstExplorer.pst().blockBTree; } + + /** Clear the tree model. */ + void reset() + { + super.reset(); + blockDescriptionDisplay.reset(); + } } diff --git a/explorer/src/main/java/io/github/jmcleodfoss/explorer/NodeBTreeDisplay.java b/explorer/src/main/java/io/github/jmcleodfoss/explorer/NodeBTreeDisplay.java index e27e14f5..13e4e48e 100644 --- a/explorer/src/main/java/io/github/jmcleodfoss/explorer/NodeBTreeDisplay.java +++ b/explorer/src/main/java/io/github/jmcleodfoss/explorer/NodeBTreeDisplay.java @@ -11,11 +11,15 @@ @SuppressWarnings("serial") class NodeBTreeDisplay extends BTreeWithData { + /** The current node's contents */ + private NodeDescriptionDisplay nodeDescriptionDisplay; + /** Construct a BTreeWithData object with the given orientation and content pane. */ protected NodeBTreeDisplay(JFrame parentFrame) { super(JSplitPane.HORIZONTAL_SPLIT); - setDataView(new NodeDescriptionDisplay(tree, parentFrame)); + nodeDescriptionDisplay = new NodeDescriptionDisplay(tree, parentFrame); + setDataView(nodeDescriptionDisplay); } /** Update the views when a new file is read in. @@ -29,4 +33,11 @@ public void fileLoaded(final PST pst) tree.setModel(treeModel()); } } + + /** Clear the tree model. */ + void reset() + { + super.reset(); + nodeDescriptionDisplay.reset(); + } }