Просмотр исходного кода

added Ramtree (DirectoryTreeImplementation without persistent saving structure in the model)

git-svn-id: http://repo.nplusc.de/svn/iZink@310 8b19561d-0d00-6744-8ac1-9afc8f58a8aa
masterX244 10 лет назад
Родитель
Сommit
45e31e3e2a

+ 21 - 1
ToolKit/src/de/nplusc/izc/tools/IOtools/DirectoryTreeNode.java

@@ -16,11 +16,21 @@ public class DirectoryTreeNode
     private String Name;
     private boolean isDirectory;
     private ArrayList<String> additionalData;
-    
+    private Object attachedObject;
+
     public DirectoryTreeNode(String lnodeID,String parentnodeID,String Name,boolean isDirectory)
+    {
+        this(lnodeID, parentnodeID, Name, isDirectory, false);
+    }           
+                
+    public DirectoryTreeNode(String lnodeID,String parentnodeID,String Name,boolean isDirectory,boolean autopopulateID)
     {
         parentNodeID=parentnodeID;
         nodeID=lnodeID;
+        if(autopopulateID)
+        {
+            nodeID=hashCode()+"";
+        }
         this.Name=Name;
         this.isDirectory=isDirectory;
         additionalData = new ArrayList<>();
@@ -56,4 +66,14 @@ public class DirectoryTreeNode
     {
         return additionalData.get(idx);
     }
+    
+    public Object getAttachedObject()
+    {
+        return attachedObject;
+    }
+
+    public void setAttachedObject(Object attachedObject)
+    {
+        this.attachedObject = attachedObject;
+    }
 }

+ 46 - 0
ToolKit/src/de/nplusc/izc/tools/IOtools/RamTree.java

@@ -0,0 +1,46 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package de.nplusc.izc.tools.IOtools;
+
+import de.nplusc.izc.tools.UiToolz.DirectoryTree;
+
+/**
+ *
+ * @author iZc <nplusc.de>
+ */
+public class RamTree extends DirectoryTree
+{
+    public RamTree()
+    {
+       autopopulateIDs=true;
+    }
+    @Override
+    public void insertDirectory(DirectoryTreeNode node)
+    {
+        directoryTree.add(node);
+    }
+
+    @Override
+    protected void rebuildDatabase()
+    {
+        //NOP
+        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public void insertFile(DirectoryTreeNode node)
+    {
+        directoryTree.add(node);
+    }
+
+    @Override
+    public String getRootPathValue()
+    {
+         return getRoot()+"";
+    }
+    
+}

+ 15 - 3
ToolKit/src/de/nplusc/izc/tools/UiToolz/DirectoryTree.java

@@ -20,7 +20,19 @@ import javax.swing.tree.TreePath;
 //kann als JTree-daten benutzt werden oder als Verzeichnisbrowser-Grundlage
 public abstract class DirectoryTree implements TreeModel
 {
-
+    
+    protected boolean autopopulateIDs;
+    public DirectoryTree()
+    {
+        autopopulateIDs=false;
+    }
+    public DirectoryTree(boolean apopIds)
+    {
+        autopopulateIDs=apopIds;
+    }
+    
+    
+    
     protected ArrayList<TreeModelListener> tml = new ArrayList<>();
     protected ArrayList<DirectoryTreeNode> directoryTree = new ArrayList<>();
 
@@ -189,7 +201,7 @@ public abstract class DirectoryTree implements TreeModel
     {
         
         path = clearPathFromInvalidSt00f(path);
-        DirectoryTreeNode[] content = new DirectoryTreeNode[]{new DirectoryTreeNode(0+"", 0+"","Fotze",true)};
+        DirectoryTreeNode[] content = new DirectoryTreeNode[]{new DirectoryTreeNode(0+"", 0+"","Fotze",true,autopopulateIDs)};
         DirectoryTreeNode rn = (DirectoryTreeNode) getRoot();
         if(!path.equals("\\"))//rootdetector
         {
@@ -225,7 +237,7 @@ public abstract class DirectoryTree implements TreeModel
                 //}
             }
             String pid = currentNode.getNodeID();
-            insertDirectory(new DirectoryTreeNode(null, pid, PathSplitted[PathSplitted.length-1], true));
+            insertDirectory(new DirectoryTreeNode(null, pid, PathSplitted[PathSplitted.length-1], true,autopopulateIDs));
         }            
         
         /*