From fa07a88b1ea738ac3bd6861cbccee2e4bac0225d Mon Sep 17 00:00:00 2001 From: Denis Molony Date: Mon, 27 Mar 2017 16:59:30 +1100 Subject: [PATCH] tidying --- .../bytezone/diskbrowser/gui/TreeBuilder.java | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/com/bytezone/diskbrowser/gui/TreeBuilder.java b/src/com/bytezone/diskbrowser/gui/TreeBuilder.java index 39972ae..b753ec0 100755 --- a/src/com/bytezone/diskbrowser/gui/TreeBuilder.java +++ b/src/com/bytezone/diskbrowser/gui/TreeBuilder.java @@ -48,7 +48,7 @@ public class TreeBuilder return tree; } - private void addFiles (DefaultMutableTreeNode node, File directory) + private void addFiles (DefaultMutableTreeNode parentNode, File directory) { File[] files = directory.listFiles (); if (files == null || files.length == 0) @@ -60,24 +60,19 @@ public class TreeBuilder Arrays.sort (files, fileComparator); for (File file : files) - { if (file.isDirectory ()) - { - FileNode fileNode = new FileNode (file); - DefaultMutableTreeNode newNode = new DefaultMutableTreeNode (fileNode); - fileNode.setTreeNode (newNode); - newNode.setAllowsChildren (true); - node.add (newNode); - } + parentNode.add (createNode (file, true)); else if (Utility.validFileType (file.getName ()) && file.length () > 0) - { - FileNode fileNode = new FileNode (file); - DefaultMutableTreeNode newNode = new DefaultMutableTreeNode (fileNode); - fileNode.setTreeNode (newNode); - newNode.setAllowsChildren (false); - node.add (newNode); - } - } + parentNode.add (createNode (file, false)); + } + + private DefaultMutableTreeNode createNode (File file, boolean allowsChildren) + { + FileNode fileNode = new FileNode (file); + DefaultMutableTreeNode newNode = new DefaultMutableTreeNode (fileNode); + fileNode.setTreeNode (newNode); + newNode.setAllowsChildren (allowsChildren); + return newNode; } private void setDiskIcon (String iconName)