varna likely hashtable.remove(value) not .remove(key)
authorBobHanson <hansonr@stolaf.edu>
Thu, 28 May 2020 20:52:54 +0000 (15:52 -0500)
committerBobHanson <hansonr@stolaf.edu>
Thu, 28 May 2020 20:52:54 +0000 (15:52 -0500)
I simply made this parent.toString() to do presumably what Java would
do,
though I am not certain of that.

srcjar/fr/orsay/lri/varna/applications/fragseq/FragSeqTreeModel.java

index 6586c04..70b858b 100644 (file)
@@ -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<String> _folders = new TreeSet<String>();
-  private Hashtable<String,FragSeqNode> _folderPathToFolderNode = new Hashtable<String,FragSeqNode>();
+       private TreeSet<String> _folders = new TreeSet<>();
+  private Hashtable<String,FragSeqNode> _folderPathToFolderNode = new Hashtable<>();
 
-  private Hashtable<String,FragSeqNode> _idsToNode = new Hashtable<String,FragSeqNode>();
-  private Hashtable<String,ArrayList<FragSeqNode>> _pathToIDFileNodes = new Hashtable<String,ArrayList<FragSeqNode>>();
+  private Hashtable<String,FragSeqNode> _idsToNode = new Hashtable<>();
+  private Hashtable<String,ArrayList<FragSeqNode>> _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<FragSeqNode> toBeRemoved = new ArrayList<FragSeqNode>(); 
+         ArrayList<FragSeqNode> 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<String> getFolders()
   {
-         ArrayList<String> result = new ArrayList<String>(_folders);
+         ArrayList<String> 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<FragSeqNode,Boolean> _isExpanded = new Hashtable<FragSeqNode,Boolean>();
+private Hashtable<FragSeqNode,Boolean> _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