From: BobHanson Date: Thu, 28 May 2020 20:52:54 +0000 (-0500) Subject: varna likely hashtable.remove(value) not .remove(key) X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f4bd90c4a9bc5c69b102e04ee286201525cbd811;p=jalview.git varna likely hashtable.remove(value) not .remove(key) I simply made this parent.toString() to do presumably what Java would do, though I am not certain of that. --- 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