From ca80a4b4aef307f1f4d60fa74d6279b54351afd6 Mon Sep 17 00:00:00 2001 From: BobHanson Date: Thu, 28 May 2020 15:58:09 -0500 Subject: [PATCH] Varna fix for hashtable.remove(value) [unclear] --- .../applications/fragseq/FragSeqTreeModel.java | 31 ++++++++++++-------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/srcjar/fr/orsay/lri/varna/applications/fragseq/FragSeqTreeModel.java b/srcjar/fr/orsay/lri/varna/applications/fragseq/FragSeqTreeModel.java index 6586c04..70b858b 100644 --- a/srcjar/fr/orsay/lri/varna/applications/fragseq/FragSeqTreeModel.java +++ b/srcjar/fr/orsay/lri/varna/applications/fragseq/FragSeqTreeModel.java @@ -6,8 +6,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Enumeration; import java.util.Hashtable; -import java.util.PriorityQueue; -import java.util.Random; import java.util.TreeSet; import javax.swing.event.TreeExpansionEvent; @@ -22,11 +20,11 @@ public class FragSeqTreeModel extends DefaultTreeModel implements TreeWillExpand private FragSeqNode _rootIDs = new FragSeqNode("IDs"); private FragSeqNode _rootFolders = new FragSeqNode("Folders"); - private TreeSet _folders = new TreeSet(); - private Hashtable _folderPathToFolderNode = new Hashtable(); + private TreeSet _folders = new TreeSet<>(); + private Hashtable _folderPathToFolderNode = new Hashtable<>(); - private Hashtable _idsToNode = new Hashtable(); - private Hashtable> _pathToIDFileNodes = new Hashtable>(); + private Hashtable _idsToNode = new Hashtable<>(); + private Hashtable> _pathToIDFileNodes = new Hashtable<>(); public enum SORT_MODE{ PATH, @@ -77,7 +75,10 @@ public class FragSeqTreeModel extends DefaultTreeModel implements TreeWillExpand if (parent.getChildCount()==0) { parent.removeFromParent(); - _folderPathToFolderNode.remove(parent); + // BH was just parent -- + System.out.println("Varna FragSeqTreeModel removing " + parent + " " + + parent.toString()); + _folderPathToFolderNode.remove(parent.toString()); if (parent.getUserObject() instanceof String) { String path = parent.getUserObject().toString(); @@ -105,7 +106,7 @@ public class FragSeqTreeModel extends DefaultTreeModel implements TreeWillExpand public void removeFolder(String path) { - ArrayList toBeRemoved = new ArrayList(); + ArrayList toBeRemoved = new ArrayList<>(); Enumeration en = _folderPathToFolderNode.get(path).children(); while(en.hasMoreElements()) { @@ -168,6 +169,7 @@ public class FragSeqTreeModel extends DefaultTreeModel implements TreeWillExpand insertFileNode(_folderPathToFolderNode.get(folder), m); } + @Override public FragSeqNode getRoot() { return (FragSeqNode) super.getRoot(); @@ -175,13 +177,14 @@ public class FragSeqTreeModel extends DefaultTreeModel implements TreeWillExpand public ArrayList getFolders() { - ArrayList result = new ArrayList(_folders); + ArrayList result = new ArrayList<>(_folders); return result; } FilenameFilter _f = new FilenameFilter(){ - public boolean accept(File dir, String name) { + @Override + public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".dbn") || name.toLowerCase().endsWith(".ct") || name.toLowerCase().endsWith(".bpseq") @@ -199,7 +202,7 @@ public class FragSeqTreeModel extends DefaultTreeModel implements TreeWillExpand } -private Hashtable _isExpanded = new Hashtable(); +private Hashtable _isExpanded = new Hashtable<>(); public boolean isExpanded(FragSeqNode n) { @@ -208,9 +211,12 @@ public boolean isExpanded(FragSeqNode n) return _isExpanded.get(n); } else - return false; + { + return false; + } } +@Override public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { if (event.getSource() instanceof FragSeqTree) { @@ -242,6 +248,7 @@ public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException } } +@Override public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { // TODO Auto-generated method stub -- 1.7.10.2